drizzle-orm 0.39.2-aaa57ff → 0.39.2-eba7324
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/alias.cjs.map +1 -1
- package/alias.d.cts +3 -3
- package/alias.d.ts +3 -3
- package/alias.js.map +1 -1
- package/aws-data-api/pg/driver.cjs +5 -19
- package/aws-data-api/pg/driver.cjs.map +1 -1
- package/aws-data-api/pg/driver.d.cts +8 -9
- package/aws-data-api/pg/driver.d.ts +8 -9
- package/aws-data-api/pg/driver.js +8 -9
- package/aws-data-api/pg/driver.js.map +1 -1
- package/aws-data-api/pg/migrator.cjs.map +1 -1
- package/aws-data-api/pg/migrator.d.cts +1 -2
- package/aws-data-api/pg/migrator.d.ts +1 -2
- package/aws-data-api/pg/migrator.js.map +1 -1
- package/aws-data-api/pg/session.cjs +4 -67
- package/aws-data-api/pg/session.cjs.map +1 -1
- package/aws-data-api/pg/session.d.cts +8 -13
- package/aws-data-api/pg/session.d.ts +8 -13
- package/aws-data-api/pg/session.js +4 -67
- package/aws-data-api/pg/session.js.map +1 -1
- package/better-sqlite3/driver.cjs +5 -12
- package/better-sqlite3/driver.cjs.map +1 -1
- package/better-sqlite3/driver.d.cts +6 -7
- package/better-sqlite3/driver.d.ts +6 -7
- package/better-sqlite3/driver.js +8 -12
- package/better-sqlite3/driver.js.map +1 -1
- package/better-sqlite3/migrator.cjs.map +1 -1
- package/better-sqlite3/migrator.d.cts +1 -2
- package/better-sqlite3/migrator.d.ts +1 -2
- package/better-sqlite3/migrator.js.map +1 -1
- package/better-sqlite3/session.cjs +4 -49
- package/better-sqlite3/session.cjs.map +1 -1
- package/better-sqlite3/session.d.cts +8 -14
- package/better-sqlite3/session.d.ts +8 -14
- package/better-sqlite3/session.js +4 -49
- package/better-sqlite3/session.js.map +1 -1
- package/bun-sql/driver.cjs +5 -16
- package/bun-sql/driver.cjs.map +1 -1
- package/bun-sql/driver.d.cts +6 -7
- package/bun-sql/driver.d.ts +6 -7
- package/bun-sql/driver.js +8 -6
- package/bun-sql/driver.js.map +1 -1
- package/bun-sql/migrator.cjs.map +1 -1
- package/bun-sql/migrator.d.cts +1 -2
- package/bun-sql/migrator.d.ts +1 -2
- package/bun-sql/migrator.js.map +1 -1
- package/bun-sql/session.cjs +6 -50
- package/bun-sql/session.cjs.map +1 -1
- package/bun-sql/session.d.cts +9 -14
- package/bun-sql/session.d.ts +9 -14
- package/bun-sql/session.js +6 -50
- package/bun-sql/session.js.map +1 -1
- package/bun-sqlite/driver.cjs +5 -22
- package/bun-sqlite/driver.cjs.map +1 -1
- package/bun-sqlite/driver.d.cts +6 -7
- package/bun-sqlite/driver.d.ts +6 -7
- package/bun-sqlite/driver.js +8 -12
- package/bun-sqlite/driver.js.map +1 -1
- package/bun-sqlite/migrator.cjs.map +1 -1
- package/bun-sqlite/migrator.d.cts +1 -2
- package/bun-sqlite/migrator.d.ts +1 -2
- package/bun-sqlite/migrator.js.map +1 -1
- package/bun-sqlite/session.cjs +4 -49
- package/bun-sqlite/session.cjs.map +1 -1
- package/bun-sqlite/session.d.cts +8 -14
- package/bun-sqlite/session.d.ts +8 -14
- package/bun-sqlite/session.js +4 -49
- package/bun-sqlite/session.js.map +1 -1
- 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/d1/driver.cjs +5 -22
- package/d1/driver.cjs.map +1 -1
- package/d1/driver.d.cts +2 -3
- package/d1/driver.d.ts +2 -3
- package/d1/driver.js +8 -12
- package/d1/driver.js.map +1 -1
- package/d1/migrator.cjs.map +1 -1
- package/d1/migrator.d.cts +1 -2
- package/d1/migrator.d.ts +1 -2
- package/d1/migrator.js.map +1 -1
- package/d1/session.cjs +8 -50
- package/d1/session.cjs.map +1 -1
- package/d1/session.d.cts +8 -15
- package/d1/session.d.ts +8 -15
- package/d1/session.js +8 -50
- package/d1/session.js.map +1 -1
- package/durable-sqlite/driver.cjs +5 -16
- package/durable-sqlite/driver.cjs.map +1 -1
- package/durable-sqlite/driver.d.cts +2 -3
- package/durable-sqlite/driver.d.ts +2 -3
- package/durable-sqlite/driver.js +8 -6
- package/durable-sqlite/driver.js.map +1 -1
- package/durable-sqlite/migrator.cjs.map +1 -1
- package/durable-sqlite/migrator.d.cts +1 -2
- package/durable-sqlite/migrator.d.ts +1 -2
- package/durable-sqlite/migrator.js.map +1 -1
- package/durable-sqlite/session.cjs +4 -46
- package/durable-sqlite/session.cjs.map +1 -1
- package/durable-sqlite/session.d.cts +8 -14
- package/durable-sqlite/session.d.ts +8 -14
- package/durable-sqlite/session.js +4 -46
- package/durable-sqlite/session.js.map +1 -1
- package/expo-sqlite/driver.cjs +5 -22
- package/expo-sqlite/driver.cjs.map +1 -1
- package/expo-sqlite/driver.d.cts +2 -3
- package/expo-sqlite/driver.d.ts +2 -3
- package/expo-sqlite/driver.js +8 -12
- package/expo-sqlite/driver.js.map +1 -1
- package/expo-sqlite/migrator.cjs.map +1 -1
- package/expo-sqlite/migrator.d.cts +2 -3
- package/expo-sqlite/migrator.d.ts +2 -3
- package/expo-sqlite/migrator.js.map +1 -1
- package/expo-sqlite/query.cjs +2 -13
- package/expo-sqlite/query.cjs.map +1 -1
- package/expo-sqlite/query.d.cts +1 -2
- package/expo-sqlite/query.d.ts +1 -2
- package/expo-sqlite/query.js +2 -3
- package/expo-sqlite/query.js.map +1 -1
- package/expo-sqlite/session.cjs +4 -47
- package/expo-sqlite/session.cjs.map +1 -1
- package/expo-sqlite/session.d.cts +8 -14
- package/expo-sqlite/session.d.ts +8 -14
- package/expo-sqlite/session.js +4 -47
- package/expo-sqlite/session.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/{pg-core/query-builders/_query.cjs → gel-core/query-builders/query.cjs} +15 -31
- 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/{pg-core/query-builders/_query.js → gel-core/query-builders/query.js} +15 -19
- 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/libsql/driver-core.cjs +5 -22
- package/libsql/driver-core.cjs.map +1 -1
- package/libsql/driver-core.d.cts +1 -2
- package/libsql/driver-core.d.ts +1 -2
- package/libsql/driver-core.js +8 -12
- package/libsql/driver-core.js.map +1 -1
- package/libsql/driver.cjs.map +1 -1
- package/libsql/driver.d.cts +5 -6
- package/libsql/driver.d.ts +5 -6
- package/libsql/driver.js.map +1 -1
- package/libsql/http/index.cjs.map +1 -1
- package/libsql/http/index.d.cts +5 -6
- package/libsql/http/index.d.ts +5 -6
- package/libsql/http/index.js.map +1 -1
- package/libsql/migrator.cjs.map +1 -1
- package/libsql/migrator.d.cts +1 -2
- package/libsql/migrator.d.ts +1 -2
- package/libsql/migrator.js.map +1 -1
- package/libsql/node/index.cjs.map +1 -1
- package/libsql/node/index.d.cts +5 -6
- package/libsql/node/index.d.ts +5 -6
- package/libsql/node/index.js.map +1 -1
- package/libsql/session.cjs +4 -56
- package/libsql/session.cjs.map +1 -1
- package/libsql/session.d.cts +9 -15
- package/libsql/session.d.ts +9 -15
- package/libsql/session.js +4 -56
- package/libsql/session.js.map +1 -1
- package/libsql/sqlite3/index.cjs.map +1 -1
- package/libsql/sqlite3/index.d.cts +5 -6
- package/libsql/sqlite3/index.d.ts +5 -6
- package/libsql/sqlite3/index.js.map +1 -1
- package/libsql/wasm/index.cjs.map +1 -1
- package/libsql/wasm/index.d.cts +5 -6
- package/libsql/wasm/index.d.ts +5 -6
- package/libsql/wasm/index.js.map +1 -1
- package/libsql/web/index.cjs.map +1 -1
- package/libsql/web/index.d.cts +5 -6
- package/libsql/web/index.d.ts +5 -6
- package/libsql/web/index.js.map +1 -1
- package/libsql/ws/index.cjs.map +1 -1
- package/libsql/ws/index.d.cts +5 -6
- package/libsql/ws/index.d.ts +5 -6
- package/libsql/ws/index.js.map +1 -1
- package/mysql-core/db.cjs +6 -30
- package/mysql-core/db.cjs.map +1 -1
- package/mysql-core/db.d.cts +8 -15
- package/mysql-core/db.d.ts +8 -15
- package/mysql-core/db.js +5 -29
- package/mysql-core/db.js.map +1 -1
- package/mysql-core/dialect.cjs +15 -197
- package/mysql-core/dialect.cjs.map +1 -1
- package/mysql-core/dialect.d.cts +13 -36
- package/mysql-core/dialect.d.ts +13 -36
- package/mysql-core/dialect.js +22 -196
- package/mysql-core/dialect.js.map +1 -1
- package/mysql-core/query-builders/count.cjs.map +1 -1
- package/mysql-core/query-builders/count.d.cts +1 -1
- package/mysql-core/query-builders/count.d.ts +1 -1
- package/mysql-core/query-builders/count.js.map +1 -1
- package/mysql-core/query-builders/query.cjs +31 -18
- package/mysql-core/query-builders/query.cjs.map +1 -1
- package/mysql-core/query-builders/query.d.cts +10 -8
- package/mysql-core/query-builders/query.d.ts +10 -8
- package/mysql-core/query-builders/query.js +31 -18
- package/mysql-core/query-builders/query.js.map +1 -1
- package/mysql-core/session.cjs +2 -3
- package/mysql-core/session.cjs.map +1 -1
- package/mysql-core/session.d.cts +7 -10
- package/mysql-core/session.d.ts +7 -10
- package/mysql-core/session.js +2 -3
- package/mysql-core/session.js.map +1 -1
- package/mysql-proxy/driver.cjs +5 -22
- package/mysql-proxy/driver.cjs.map +1 -1
- package/mysql-proxy/driver.d.cts +2 -3
- package/mysql-proxy/driver.d.ts +2 -3
- package/mysql-proxy/driver.js +8 -12
- package/mysql-proxy/driver.js.map +1 -1
- package/mysql-proxy/migrator.cjs.map +1 -1
- package/mysql-proxy/migrator.d.cts +1 -2
- package/mysql-proxy/migrator.d.ts +1 -2
- package/mysql-proxy/migrator.js.map +1 -1
- package/mysql-proxy/session.cjs +2 -27
- package/mysql-proxy/session.cjs.map +1 -1
- package/mysql-proxy/session.d.cts +8 -13
- package/mysql-proxy/session.d.ts +8 -13
- package/mysql-proxy/session.js +2 -27
- package/mysql-proxy/session.js.map +1 -1
- package/mysql2/driver.cjs +7 -24
- package/mysql2/driver.cjs.map +1 -1
- package/mysql2/driver.d.cts +9 -10
- package/mysql2/driver.d.ts +9 -10
- package/mysql2/driver.js +10 -14
- package/mysql2/driver.js.map +1 -1
- package/mysql2/migrator.cjs.map +1 -1
- package/mysql2/migrator.d.cts +1 -2
- package/mysql2/migrator.d.ts +1 -2
- package/mysql2/migrator.js.map +1 -1
- package/mysql2/session.cjs +2 -30
- package/mysql2/session.cjs.map +1 -1
- package/mysql2/session.d.cts +8 -13
- package/mysql2/session.d.ts +8 -13
- package/mysql2/session.js +2 -30
- package/mysql2/session.js.map +1 -1
- package/neon-http/driver.cjs +7 -21
- package/neon-http/driver.cjs.map +1 -1
- package/neon-http/driver.d.cts +9 -10
- package/neon-http/driver.d.ts +9 -10
- package/neon-http/driver.js +7 -11
- package/neon-http/driver.js.map +1 -1
- package/neon-http/migrator.cjs.map +1 -1
- package/neon-http/migrator.d.cts +1 -2
- package/neon-http/migrator.d.ts +1 -2
- package/neon-http/migrator.js.map +1 -1
- package/neon-http/session.cjs +2 -32
- package/neon-http/session.cjs.map +1 -1
- package/neon-http/session.d.cts +8 -13
- package/neon-http/session.d.ts +8 -13
- package/neon-http/session.js +2 -32
- package/neon-http/session.js.map +1 -1
- package/neon-serverless/driver.cjs +7 -18
- package/neon-serverless/driver.cjs.map +1 -1
- package/neon-serverless/driver.d.cts +8 -9
- package/neon-serverless/driver.d.ts +8 -9
- package/neon-serverless/driver.js +10 -8
- package/neon-serverless/driver.js.map +1 -1
- package/neon-serverless/migrator.cjs.map +1 -1
- package/neon-serverless/migrator.d.cts +1 -2
- package/neon-serverless/migrator.d.ts +1 -2
- package/neon-serverless/migrator.js.map +1 -1
- package/neon-serverless/session.cjs +5 -40
- package/neon-serverless/session.cjs.map +1 -1
- package/neon-serverless/session.d.cts +8 -13
- package/neon-serverless/session.d.ts +8 -13
- package/neon-serverless/session.js +5 -40
- package/neon-serverless/session.js.map +1 -1
- package/node-postgres/driver.cjs +7 -13
- package/node-postgres/driver.cjs.map +1 -1
- package/node-postgres/driver.d.cts +8 -9
- package/node-postgres/driver.d.ts +8 -9
- package/node-postgres/driver.js +10 -13
- package/node-postgres/driver.js.map +1 -1
- package/node-postgres/migrator.cjs.map +1 -1
- package/node-postgres/migrator.d.cts +1 -2
- package/node-postgres/migrator.d.ts +1 -2
- package/node-postgres/migrator.js.map +1 -1
- package/node-postgres/session.cjs +4 -45
- package/node-postgres/session.cjs.map +1 -1
- package/node-postgres/session.d.cts +8 -13
- package/node-postgres/session.d.ts +8 -13
- package/node-postgres/session.js +4 -45
- package/node-postgres/session.js.map +1 -1
- package/op-sqlite/driver.cjs +5 -22
- package/op-sqlite/driver.cjs.map +1 -1
- package/op-sqlite/driver.d.cts +2 -3
- package/op-sqlite/driver.d.ts +2 -3
- package/op-sqlite/driver.js +8 -12
- package/op-sqlite/driver.js.map +1 -1
- package/op-sqlite/migrator.cjs.map +1 -1
- package/op-sqlite/migrator.d.cts +2 -3
- package/op-sqlite/migrator.d.ts +2 -3
- package/op-sqlite/migrator.js.map +1 -1
- package/op-sqlite/session.cjs +4 -47
- package/op-sqlite/session.cjs.map +1 -1
- package/op-sqlite/session.d.cts +8 -14
- package/op-sqlite/session.d.ts +8 -14
- package/op-sqlite/session.js +4 -47
- package/op-sqlite/session.js.map +1 -1
- package/package.json +784 -99
- package/pg-core/db.cjs +5 -32
- package/pg-core/db.cjs.map +1 -1
- package/pg-core/db.d.cts +9 -16
- package/pg-core/db.d.ts +9 -16
- package/pg-core/db.js +4 -31
- package/pg-core/db.js.map +1 -1
- package/pg-core/dialect.cjs +488 -173
- package/pg-core/dialect.cjs.map +1 -1
- package/pg-core/dialect.d.cts +8 -27
- package/pg-core/dialect.d.ts +8 -27
- package/pg-core/dialect.js +495 -172
- package/pg-core/dialect.js.map +1 -1
- package/pg-core/query-builders/count.cjs.map +1 -1
- package/pg-core/query-builders/count.d.cts +1 -1
- package/pg-core/query-builders/count.d.ts +1 -1
- package/pg-core/query-builders/count.js.map +1 -1
- package/pg-core/query-builders/query.cjs +18 -15
- package/pg-core/query-builders/query.cjs.map +1 -1
- package/pg-core/query-builders/query.d.cts +6 -6
- package/pg-core/query-builders/query.d.ts +6 -6
- package/pg-core/query-builders/query.js +18 -15
- package/pg-core/query-builders/query.js.map +1 -1
- package/pg-core/session.cjs +2 -3
- package/pg-core/session.cjs.map +1 -1
- package/pg-core/session.d.cts +6 -9
- package/pg-core/session.d.ts +6 -9
- package/pg-core/session.js +2 -3
- package/pg-core/session.js.map +1 -1
- 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/pg-proxy/driver.cjs +5 -21
- package/pg-proxy/driver.cjs.map +1 -1
- package/pg-proxy/driver.d.cts +2 -3
- package/pg-proxy/driver.d.ts +2 -3
- package/pg-proxy/driver.js +8 -11
- package/pg-proxy/driver.js.map +1 -1
- package/pg-proxy/migrator.cjs.map +1 -1
- package/pg-proxy/migrator.d.cts +1 -2
- package/pg-proxy/migrator.d.ts +1 -2
- package/pg-proxy/migrator.js.map +1 -1
- package/pg-proxy/session.cjs +2 -37
- package/pg-proxy/session.cjs.map +1 -1
- package/pg-proxy/session.d.cts +8 -13
- package/pg-proxy/session.d.ts +8 -13
- package/pg-proxy/session.js +2 -37
- package/pg-proxy/session.js.map +1 -1
- package/pglite/driver.cjs +7 -23
- package/pglite/driver.cjs.map +1 -1
- package/pglite/driver.d.cts +8 -9
- package/pglite/driver.d.ts +8 -9
- package/pglite/driver.js +10 -13
- package/pglite/driver.js.map +1 -1
- package/pglite/migrator.cjs.map +1 -1
- package/pglite/migrator.d.cts +1 -2
- package/pglite/migrator.d.ts +1 -2
- package/pglite/migrator.js.map +1 -1
- package/pglite/session.cjs +3 -34
- package/pglite/session.cjs.map +1 -1
- package/pglite/session.d.cts +8 -13
- package/pglite/session.d.ts +8 -13
- package/pglite/session.js +3 -34
- package/pglite/session.js.map +1 -1
- package/planetscale-serverless/driver.cjs +5 -22
- package/planetscale-serverless/driver.cjs.map +1 -1
- package/planetscale-serverless/driver.d.cts +6 -7
- package/planetscale-serverless/driver.d.ts +6 -7
- package/planetscale-serverless/driver.js +8 -12
- package/planetscale-serverless/driver.js.map +1 -1
- package/planetscale-serverless/migrator.cjs.map +1 -1
- package/planetscale-serverless/migrator.d.cts +1 -2
- package/planetscale-serverless/migrator.d.ts +1 -2
- package/planetscale-serverless/migrator.js.map +1 -1
- package/planetscale-serverless/session.cjs +5 -45
- package/planetscale-serverless/session.cjs.map +1 -1
- package/planetscale-serverless/session.d.cts +9 -14
- package/planetscale-serverless/session.d.ts +9 -14
- package/planetscale-serverless/session.js +5 -45
- package/planetscale-serverless/session.js.map +1 -1
- package/postgres-js/driver.cjs +5 -6
- package/postgres-js/driver.cjs.map +1 -1
- package/postgres-js/driver.d.cts +6 -7
- package/postgres-js/driver.d.ts +6 -7
- package/postgres-js/driver.js +8 -6
- package/postgres-js/driver.js.map +1 -1
- package/postgres-js/migrator.cjs.map +1 -1
- package/postgres-js/migrator.d.cts +1 -2
- package/postgres-js/migrator.d.ts +1 -2
- package/postgres-js/migrator.js.map +1 -1
- package/postgres-js/session.cjs +6 -51
- package/postgres-js/session.cjs.map +1 -1
- package/postgres-js/session.d.cts +9 -15
- package/postgres-js/session.d.ts +9 -15
- package/postgres-js/session.js +6 -51
- package/postgres-js/session.js.map +1 -1
- package/prisma/mysql/driver.cjs +1 -1
- package/prisma/mysql/driver.cjs.map +1 -1
- package/prisma/mysql/driver.js +1 -1
- package/prisma/mysql/driver.js.map +1 -1
- package/prisma/mysql/session.cjs +0 -3
- package/prisma/mysql/session.cjs.map +1 -1
- package/prisma/mysql/session.d.cts +1 -3
- package/prisma/mysql/session.d.ts +1 -3
- package/prisma/mysql/session.js +0 -3
- package/prisma/mysql/session.js.map +1 -1
- package/prisma/pg/driver.cjs +1 -1
- package/prisma/pg/driver.cjs.map +1 -1
- package/prisma/pg/driver.js +1 -1
- package/prisma/pg/driver.js.map +1 -1
- package/prisma/pg/session.cjs +0 -3
- package/prisma/pg/session.cjs.map +1 -1
- package/prisma/pg/session.d.cts +1 -3
- package/prisma/pg/session.d.ts +1 -3
- package/prisma/pg/session.js +0 -3
- package/prisma/pg/session.js.map +1 -1
- package/prisma/sqlite/driver.cjs +1 -1
- package/prisma/sqlite/driver.cjs.map +1 -1
- package/prisma/sqlite/driver.js +1 -1
- package/prisma/sqlite/driver.js.map +1 -1
- package/prisma/sqlite/session.cjs +0 -3
- package/prisma/sqlite/session.cjs.map +1 -1
- package/prisma/sqlite/session.d.cts +2 -4
- package/prisma/sqlite/session.d.ts +2 -4
- package/prisma/sqlite/session.js +0 -3
- package/prisma/sqlite/session.js.map +1 -1
- package/relations.cjs +245 -596
- package/relations.cjs.map +1 -1
- package/relations.d.cts +140 -292
- package/relations.d.ts +140 -292
- package/relations.js +240 -589
- package/relations.js.map +1 -1
- package/singlestore/driver.cjs +1 -1
- package/singlestore/driver.cjs.map +1 -1
- package/singlestore/driver.d.cts +1 -1
- package/singlestore/driver.d.ts +1 -1
- package/singlestore/driver.js +3 -3
- package/singlestore/driver.js.map +1 -1
- package/singlestore/session.cjs.map +1 -1
- package/singlestore/session.d.cts +4 -4
- package/singlestore/session.d.ts +4 -4
- package/singlestore/session.js.map +1 -1
- package/singlestore-core/db.cjs.map +1 -1
- package/singlestore-core/db.d.cts +3 -3
- package/singlestore-core/db.d.ts +3 -3
- package/singlestore-core/db.js.map +1 -1
- package/singlestore-core/dialect.cjs +6 -16
- package/singlestore-core/dialect.cjs.map +1 -1
- package/singlestore-core/dialect.d.cts +6 -6
- package/singlestore-core/dialect.d.ts +6 -6
- package/singlestore-core/dialect.js +12 -6
- package/singlestore-core/dialect.js.map +1 -1
- package/singlestore-core/query-builders/query.cjs +2 -12
- package/singlestore-core/query-builders/query.cjs.map +1 -1
- package/singlestore-core/query-builders/query.d.cts +6 -6
- package/singlestore-core/query-builders/query.d.ts +6 -6
- package/singlestore-core/query-builders/query.js +4 -2
- package/singlestore-core/query-builders/query.js.map +1 -1
- package/singlestore-core/session.cjs.map +1 -1
- package/singlestore-core/session.d.cts +5 -5
- package/singlestore-core/session.d.ts +5 -5
- package/singlestore-core/session.js.map +1 -1
- package/singlestore-proxy/driver.cjs +1 -1
- package/singlestore-proxy/driver.cjs.map +1 -1
- package/singlestore-proxy/driver.js +3 -3
- package/singlestore-proxy/driver.js.map +1 -1
- package/singlestore-proxy/session.cjs.map +1 -1
- package/singlestore-proxy/session.d.cts +4 -4
- package/singlestore-proxy/session.d.ts +4 -4
- package/singlestore-proxy/session.js.map +1 -1
- package/sql/expressions/conditions.cjs.map +1 -1
- package/sql/expressions/conditions.d.cts +4 -4
- package/sql/expressions/conditions.d.ts +4 -4
- package/sql/expressions/conditions.js.map +1 -1
- package/sql/sql.cjs +0 -21
- package/sql/sql.cjs.map +1 -1
- package/sql/sql.d.cts +8 -8
- package/sql/sql.d.ts +8 -8
- package/sql/sql.js +1 -22
- package/sql/sql.js.map +1 -1
- package/sql-js/driver.cjs +5 -16
- package/sql-js/driver.cjs.map +1 -1
- package/sql-js/driver.d.cts +2 -3
- package/sql-js/driver.d.ts +2 -3
- package/sql-js/driver.js +8 -6
- package/sql-js/driver.js.map +1 -1
- package/sql-js/migrator.cjs.map +1 -1
- package/sql-js/migrator.d.cts +1 -2
- package/sql-js/migrator.d.ts +1 -2
- package/sql-js/migrator.js.map +1 -1
- package/sql-js/session.cjs +36 -71
- package/sql-js/session.cjs.map +1 -1
- package/sql-js/session.d.cts +13 -16
- package/sql-js/session.d.ts +13 -16
- package/sql-js/session.js +36 -71
- package/sql-js/session.js.map +1 -1
- package/sqlite-core/db.cjs +12 -39
- package/sqlite-core/db.cjs.map +1 -1
- package/sqlite-core/db.d.cts +8 -16
- package/sqlite-core/db.d.ts +8 -16
- package/sqlite-core/db.js +11 -38
- package/sqlite-core/db.js.map +1 -1
- package/sqlite-core/dialect.cjs +7 -186
- package/sqlite-core/dialect.cjs.map +1 -1
- package/sqlite-core/dialect.d.cts +9 -31
- package/sqlite-core/dialect.d.ts +9 -31
- package/sqlite-core/dialect.js +14 -185
- package/sqlite-core/dialect.js.map +1 -1
- package/sqlite-core/query-builders/count.cjs.map +1 -1
- package/sqlite-core/query-builders/count.d.cts +1 -1
- package/sqlite-core/query-builders/count.d.ts +1 -1
- package/sqlite-core/query-builders/count.js.map +1 -1
- package/sqlite-core/query-builders/delete.cjs.map +1 -1
- package/sqlite-core/query-builders/delete.d.cts +1 -1
- package/sqlite-core/query-builders/delete.d.ts +1 -1
- package/sqlite-core/query-builders/delete.js.map +1 -1
- package/sqlite-core/query-builders/insert.cjs.map +1 -1
- package/sqlite-core/query-builders/insert.d.cts +3 -3
- package/sqlite-core/query-builders/insert.d.ts +3 -3
- package/sqlite-core/query-builders/insert.js.map +1 -1
- package/sqlite-core/query-builders/query.cjs +35 -56
- package/sqlite-core/query-builders/query.cjs.map +1 -1
- package/sqlite-core/query-builders/query.d.cts +17 -18
- package/sqlite-core/query-builders/query.d.ts +17 -18
- package/sqlite-core/query-builders/query.js +35 -56
- package/sqlite-core/query-builders/query.js.map +1 -1
- package/sqlite-core/query-builders/select.cjs.map +1 -1
- package/sqlite-core/query-builders/select.d.cts +3 -3
- package/sqlite-core/query-builders/select.d.ts +3 -3
- package/sqlite-core/query-builders/select.js.map +1 -1
- package/sqlite-core/query-builders/update.cjs.map +1 -1
- package/sqlite-core/query-builders/update.d.cts +3 -3
- package/sqlite-core/query-builders/update.d.ts +3 -3
- package/sqlite-core/query-builders/update.js.map +1 -1
- package/sqlite-core/session.cjs +2 -6
- package/sqlite-core/session.cjs.map +1 -1
- package/sqlite-core/session.d.cts +7 -15
- package/sqlite-core/session.d.ts +7 -15
- package/sqlite-core/session.js +2 -6
- package/sqlite-core/session.js.map +1 -1
- package/sqlite-proxy/driver.cjs +5 -23
- package/sqlite-proxy/driver.cjs.map +1 -1
- package/sqlite-proxy/driver.d.cts +3 -4
- package/sqlite-proxy/driver.d.ts +3 -4
- package/sqlite-proxy/driver.js +5 -13
- package/sqlite-proxy/driver.js.map +1 -1
- package/sqlite-proxy/migrator.cjs.map +1 -1
- package/sqlite-proxy/migrator.d.cts +1 -2
- package/sqlite-proxy/migrator.d.ts +1 -2
- package/sqlite-proxy/migrator.js.map +1 -1
- package/sqlite-proxy/session.cjs +6 -50
- package/sqlite-proxy/session.cjs.map +1 -1
- package/sqlite-proxy/session.d.cts +8 -14
- package/sqlite-proxy/session.d.ts +8 -14
- package/sqlite-proxy/session.js +6 -50
- package/sqlite-proxy/session.js.map +1 -1
- package/table.cjs.map +1 -1
- package/table.d.cts +2 -2
- package/table.d.ts +2 -2
- package/table.js.map +1 -1
- package/tidb-serverless/driver.cjs +5 -22
- package/tidb-serverless/driver.cjs.map +1 -1
- package/tidb-serverless/driver.d.cts +6 -7
- package/tidb-serverless/driver.d.ts +6 -7
- package/tidb-serverless/driver.js +8 -12
- package/tidb-serverless/driver.js.map +1 -1
- package/tidb-serverless/migrator.cjs.map +1 -1
- package/tidb-serverless/migrator.d.cts +1 -2
- package/tidb-serverless/migrator.d.ts +1 -2
- package/tidb-serverless/migrator.js.map +1 -1
- package/tidb-serverless/session.cjs +5 -62
- package/tidb-serverless/session.cjs.map +1 -1
- package/tidb-serverless/session.d.cts +9 -14
- package/tidb-serverless/session.d.ts +9 -14
- package/tidb-serverless/session.js +5 -62
- package/tidb-serverless/session.js.map +1 -1
- package/utils.cjs +2 -2
- package/utils.cjs.map +1 -1
- package/utils.d.cts +1 -3
- package/utils.d.ts +1 -3
- package/utils.js +2 -2
- package/utils.js.map +1 -1
- package/vercel-postgres/driver.cjs +7 -23
- package/vercel-postgres/driver.cjs.map +1 -1
- package/vercel-postgres/driver.d.cts +8 -9
- package/vercel-postgres/driver.d.ts +8 -9
- package/vercel-postgres/driver.js +10 -13
- package/vercel-postgres/driver.js.map +1 -1
- package/vercel-postgres/migrator.cjs.map +1 -1
- package/vercel-postgres/migrator.d.cts +1 -2
- package/vercel-postgres/migrator.d.ts +1 -2
- package/vercel-postgres/migrator.js.map +1 -1
- package/vercel-postgres/session.cjs +4 -34
- package/vercel-postgres/session.cjs.map +1 -1
- package/vercel-postgres/session.d.cts +8 -13
- package/vercel-postgres/session.d.ts +8 -13
- package/vercel-postgres/session.js +4 -34
- package/vercel-postgres/session.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/xata-http/driver.cjs +5 -17
- package/xata-http/driver.cjs.map +1 -1
- package/xata-http/driver.d.cts +4 -5
- package/xata-http/driver.d.ts +4 -5
- package/xata-http/driver.js +5 -7
- package/xata-http/driver.js.map +1 -1
- package/xata-http/migrator.cjs.map +1 -1
- package/xata-http/migrator.d.cts +1 -2
- package/xata-http/migrator.d.ts +1 -2
- package/xata-http/migrator.js.map +1 -1
- package/xata-http/session.cjs +2 -30
- package/xata-http/session.cjs.map +1 -1
- package/xata-http/session.d.cts +8 -13
- package/xata-http/session.d.ts +8 -13
- package/xata-http/session.js +2 -30
- package/xata-http/session.js.map +1 -1
- package/_relations.cjs +0 -328
- package/_relations.cjs.map +0 -1
- package/_relations.d.cts +0 -215
- package/_relations.d.ts +0 -215
- package/_relations.js +0 -316
- package/_relations.js.map +0 -1
- package/mysql-core/query-builders/_query.cjs +0 -149
- package/mysql-core/query-builders/_query.cjs.map +0 -1
- package/mysql-core/query-builders/_query.d.cts +0 -44
- package/mysql-core/query-builders/_query.d.ts +0 -44
- package/mysql-core/query-builders/_query.js +0 -114
- package/mysql-core/query-builders/_query.js.map +0 -1
- package/pg-core/query-builders/_query.cjs.map +0 -1
- package/pg-core/query-builders/_query.d.cts +0 -47
- package/pg-core/query-builders/_query.d.ts +0 -47
- package/pg-core/query-builders/_query.js.map +0 -1
- package/sqlite-core/query-builders/_query.cjs +0 -187
- package/sqlite-core/query-builders/_query.cjs.map +0 -1
- package/sqlite-core/query-builders/_query.d.cts +0 -55
- package/sqlite-core/query-builders/_query.d.ts +0 -55
- package/sqlite-core/query-builders/_query.js +0 -151
- package/sqlite-core/query-builders/_query.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/aws-data-api/pg/session.ts"],"sourcesContent":["import type { ColumnMetadata, ExecuteStatementCommandOutput, Field, RDSDataClient } from '@aws-sdk/client-rds-data';\nimport {\n\tBeginTransactionCommand,\n\tCommitTransactionCommand,\n\tExecuteStatementCommand,\n\tRollbackTransactionCommand,\n} from '@aws-sdk/client-rds-data';\nimport type * as V1 from '~/_relations.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport {\n\ttype PgDialect,\n\tPgPreparedQuery,\n\ttype PgQueryResultHKT,\n\tPgSession,\n\tPgTransaction,\n\ttype PgTransactionConfig,\n\ttype PreparedQueryConfig,\n} from '~/pg-core/index.ts';\nimport type { SelectedFieldsOrdered } from '~/pg-core/query-builders/select.types.ts';\nimport type { AnyRelations, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type QueryTypingsValue, type QueryWithTypings, type SQL, sql } from '~/sql/sql.ts';\nimport { mapResultRow } from '~/utils.ts';\nimport { getValueFromDataApi, toValueParam } from '../common/index.ts';\n\nexport type AwsDataApiClient = RDSDataClient;\n\nexport class AwsDataApiPreparedQuery<\n\tT extends PreparedQueryConfig & { values: AwsDataApiPgQueryResult<unknown[]> },\n\tTIsRqbV2 extends boolean = false,\n> extends PgPreparedQuery<T> {\n\tstatic override readonly [entityKind]: string = 'AwsDataApiPreparedQuery';\n\n\tprivate rawQuery: ExecuteStatementCommand;\n\n\tconstructor(\n\t\tprivate client: AwsDataApiClient,\n\t\tqueryString: string,\n\t\tprivate params: unknown[],\n\t\tprivate typings: QueryTypingsValue[],\n\t\tprivate options: AwsDataApiSessionOptions,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\t/** @internal */\n\t\treadonly transactionId: string | undefined,\n\t\tprivate _isResponseInArrayMode: boolean,\n\t\tprivate customResultMapper?: (\n\t\t\trows: TIsRqbV2 extends true ? Record<string, unknown>[] : unknown[][],\n\t\t) => T['execute'],\n\t\tprivate isRqbV2Query?: TIsRqbV2,\n\t) {\n\t\tsuper({ sql: queryString, params });\n\t\tthis.rawQuery = new ExecuteStatementCommand({\n\t\t\tsql: queryString,\n\t\t\tparameters: [],\n\t\t\tsecretArn: options.secretArn,\n\t\t\tresourceArn: options.resourceArn,\n\t\t\tdatabase: options.database,\n\t\t\ttransactionId,\n\t\t\tincludeResultMetadata: !fields && !customResultMapper,\n\t\t});\n\t}\n\n\tasync execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tif (this.isRqbV2Query) return this.executeRqbV2(placeholderValues);\n\n\t\tconst { fields, joinsNotNullableMap, customResultMapper } = this;\n\n\t\tconst result = await this.values(placeholderValues);\n\t\tif (!fields && !customResultMapper) {\n\t\t\tconst { columnMetadata, rows } = result;\n\t\t\tif (!columnMetadata) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tconst mappedRows = rows.map((sourceRow) => {\n\t\t\t\tconst row: Record<string, unknown> = {};\n\t\t\t\tfor (const [index, value] of sourceRow.entries()) {\n\t\t\t\t\tconst metadata = columnMetadata[index];\n\t\t\t\t\tif (!metadata) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Unexpected state: no column metadata found for index ${index}. Please report this issue on GitHub: https://github.com/drizzle-team/drizzle-orm/issues/new/choose`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (!metadata.name) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Unexpected state: no column name for index ${index} found in the column metadata. Please report this issue on GitHub: https://github.com/drizzle-team/drizzle-orm/issues/new/choose`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\trow[metadata.name] = value;\n\t\t\t\t}\n\t\t\t\treturn row;\n\t\t\t});\n\t\t\treturn Object.assign(result, { rows: mappedRows });\n\t\t}\n\n\t\treturn customResultMapper\n\t\t\t? (customResultMapper as (rows: unknown[][]) => T['execute'])(result.rows!)\n\t\t\t: result.rows!.map((row) => mapResultRow(fields!, row, joinsNotNullableMap));\n\t}\n\n\tprivate async executeRqbV2(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tconst { customResultMapper } = this;\n\n\t\tconst result = await this.values(placeholderValues);\n\t\tconst { columnMetadata, rows } = result;\n\t\tif (!columnMetadata) {\n\t\t\treturn (customResultMapper as (rows: Record<string, unknown>[]) => T['execute'])(\n\t\t\t\trows as any as Record<string, unknown>[],\n\t\t\t);\n\t\t}\n\t\tconst mappedRows = rows.map((sourceRow) => {\n\t\t\tconst row: Record<string, unknown> = {};\n\t\t\tfor (const [index, value] of sourceRow.entries()) {\n\t\t\t\tconst metadata = columnMetadata[index];\n\t\t\t\tif (!metadata) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Unexpected state: no column metadata found for index ${index}. Please report this issue on GitHub: https://github.com/drizzle-team/drizzle-orm/issues/new/choose`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (!metadata.name) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Unexpected state: no column name for index ${index} found in the column metadata. Please report this issue on GitHub: https://github.com/drizzle-team/drizzle-orm/issues/new/choose`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\trow[metadata.name] = value;\n\t\t\t}\n\t\t\treturn row;\n\t\t});\n\n\t\tObject.assign(result, { rows: mappedRows });\n\n\t\treturn (customResultMapper as (rows: Record<string, unknown>[]) => T['execute'])(\n\t\t\tmappedRows,\n\t\t);\n\t}\n\n\tasync all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']> {\n\t\tconst result = await this.execute(placeholderValues);\n\t\tif (!this.fields && !this.customResultMapper) {\n\t\t\treturn (result as AwsDataApiPgQueryResult<unknown>).rows;\n\t\t}\n\t\treturn result;\n\t}\n\n\tasync values(placeholderValues: Record<string, unknown> = {}): Promise<T['values']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues ?? {});\n\n\t\tthis.rawQuery.input.parameters = params.map((param, index) => ({\n\t\t\tname: `${index + 1}`,\n\t\t\t...toValueParam(param, this.typings[index]),\n\t\t}));\n\n\t\tthis.options.logger?.logQuery(this.rawQuery.input.sql!, this.rawQuery.input.parameters);\n\n\t\tconst result = await this.client.send(this.rawQuery);\n\t\tconst rows = result.records?.map((row) => {\n\t\t\treturn row.map((field) => getValueFromDataApi(field));\n\t\t}) ?? [];\n\n\t\treturn {\n\t\t\t...result,\n\t\t\trows,\n\t\t};\n\t}\n\n\t/** @internal */\n\tmapResultRows(records: Field[][], columnMetadata: ColumnMetadata[]) {\n\t\treturn records.map((record) => {\n\t\t\tconst row: Record<string, unknown> = {};\n\t\t\tfor (const [index, field] of record.entries()) {\n\t\t\t\tconst { name } = columnMetadata[index]!;\n\t\t\t\trow[name ?? index] = getValueFromDataApi(field); // not what to default if name is undefined\n\t\t\t}\n\t\t\treturn row;\n\t\t});\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface AwsDataApiSessionOptions {\n\tlogger?: Logger;\n\tdatabase: string;\n\tresourceArn: string;\n\tsecretArn: string;\n}\n\ninterface AwsDataApiQueryBase {\n\tresourceArn: string;\n\tsecretArn: string;\n\tdatabase: string;\n}\n\nexport class AwsDataApiSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends PgSession<AwsDataApiPgQueryResultHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'AwsDataApiSession';\n\n\t/** @internal */\n\treadonly rawQuery: AwsDataApiQueryBase;\n\n\tconstructor(\n\t\t/** @internal */\n\t\treadonly client: AwsDataApiClient,\n\t\tdialect: PgDialect,\n\t\tprivate relations: AnyRelations | undefined,\n\t\tprivate schema: V1.RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: AwsDataApiSessionOptions,\n\t\t/** @internal */\n\t\treadonly transactionId: string | undefined,\n\t) {\n\t\tsuper(dialect);\n\t\tthis.rawQuery = {\n\t\t\tsecretArn: options.secretArn,\n\t\t\tresourceArn: options.resourceArn,\n\t\t\tdatabase: options.database,\n\t\t};\n\t}\n\n\tprepareQuery<\n\t\tT extends PreparedQueryConfig & {\n\t\t\tvalues: AwsDataApiPgQueryResult<unknown[]>;\n\t\t} = PreparedQueryConfig & {\n\t\t\tvalues: AwsDataApiPgQueryResult<unknown[]>;\n\t\t},\n\t>(\n\t\tquery: QueryWithTypings,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\ttransactionId?: string,\n\t): AwsDataApiPreparedQuery<T> {\n\t\treturn new AwsDataApiPreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery.sql,\n\t\t\tquery.params,\n\t\t\tquery.typings ?? [],\n\t\t\tthis.options,\n\t\t\tfields,\n\t\t\ttransactionId ?? this.transactionId,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\tprepareRelationalQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(\n\t\tquery: QueryWithTypings,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tcustomResultMapper: (rows: Record<string, unknown>[]) => T['execute'],\n\t\ttransactionId?: string,\n\t): PgPreparedQuery<T> {\n\t\treturn new AwsDataApiPreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery.sql,\n\t\t\tquery.params,\n\t\t\tquery.typings ?? [],\n\t\t\tthis.options,\n\t\t\tfields,\n\t\t\ttransactionId ?? this.transactionId,\n\t\t\tfalse,\n\t\t\tcustomResultMapper,\n\t\t\ttrue,\n\t\t);\n\t}\n\n\toverride execute<T>(query: SQL): Promise<T> {\n\t\treturn this.prepareQuery<PreparedQueryConfig & { execute: T; values: AwsDataApiPgQueryResult<unknown[]> }>(\n\t\t\tthis.dialect.sqlToQuery(query),\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\tfalse,\n\t\t\tundefined,\n\t\t\tthis.transactionId,\n\t\t).execute();\n\t}\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: AwsDataApiTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>,\n\t\tconfig?: PgTransactionConfig | undefined,\n\t): Promise<T> {\n\t\tconst { transactionId } = await this.client.send(new BeginTransactionCommand(this.rawQuery));\n\t\tconst session = new AwsDataApiSession(\n\t\t\tthis.client,\n\t\t\tthis.dialect,\n\t\t\tthis.relations,\n\t\t\tthis.schema,\n\t\t\tthis.options,\n\t\t\ttransactionId,\n\t\t);\n\t\tconst tx = new AwsDataApiTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>(\n\t\t\tthis.dialect,\n\t\t\tsession,\n\t\t\tthis.relations,\n\t\t\tthis.schema,\n\t\t);\n\t\tif (config) {\n\t\t\tawait tx.setTransaction(config);\n\t\t}\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait this.client.send(new CommitTransactionCommand({ ...this.rawQuery, transactionId }));\n\t\t\treturn result;\n\t\t} catch (e) {\n\t\t\tawait this.client.send(new RollbackTransactionCommand({ ...this.rawQuery, transactionId }));\n\t\t\tthrow e;\n\t\t}\n\t}\n}\n\nexport class AwsDataApiTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends PgTransaction<AwsDataApiPgQueryResultHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'AwsDataApiTransaction';\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: AwsDataApiTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new AwsDataApiTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>(\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tthis.relations,\n\t\t\tthis.schema,\n\t\t\tthis.nestedIndex + 1,\n\t\t);\n\t\tawait this.session.execute(sql.raw(`savepoint ${savepointName}`));\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait this.session.execute(sql.raw(`release savepoint ${savepointName}`));\n\t\t\treturn result;\n\t\t} catch (e) {\n\t\t\tawait this.session.execute(sql.raw(`rollback to savepoint ${savepointName}`));\n\t\t\tthrow e;\n\t\t}\n\t}\n}\n\nexport type AwsDataApiPgQueryResult<T> = ExecuteStatementCommandOutput & { rows: T[] };\n\nexport interface AwsDataApiPgQueryResultHKT extends PgQueryResultHKT {\n\ttype: AwsDataApiPgQueryResult<any>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,6BAKO;AAEP,oBAA2B;AAE3B,qBAQO;AAGP,iBAA+F;AAC/F,mBAA6B;AAC7B,oBAAkD;AAI3C,MAAM,gCAGH,+BAAmB;AAAA,EAK5B,YACS,QACR,aACQ,QACA,SACA,SACA,QAEC,eACD,wBACA,oBAGA,cACP;AACD,UAAM,EAAE,KAAK,aAAa,OAAO,CAAC;AAd1B;AAEA;AACA;AACA;AACA;AAEC;AACD;AACA;AAGA;AAGR,SAAK,WAAW,IAAI,+CAAwB;AAAA,MAC3C,KAAK;AAAA,MACL,YAAY,CAAC;AAAA,MACb,WAAW,QAAQ;AAAA,MACnB,aAAa,QAAQ;AAAA,MACrB,UAAU,QAAQ;AAAA,MAClB;AAAA,MACA,uBAAuB,CAAC,UAAU,CAAC;AAAA,IACpC,CAAC;AAAA,EACF;AAAA,EA7BA,QAA0B,wBAAU,IAAY;AAAA,EAExC;AAAA,EA6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E,aAAO;AAAA,IACR,SAAS,GAAG;AACX,YAAM,KAAK,QAAQ,QAAQ,eAAI,IAAI,yBAAyB,aAAa,EAAE,CAAC;AAC5E,YAAM;AAAA,IACP;AAAA,EACD;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/aws-data-api/pg/session.ts"],"sourcesContent":["import type { ColumnMetadata, ExecuteStatementCommandOutput, Field, RDSDataClient } from '@aws-sdk/client-rds-data';\nimport {\n\tBeginTransactionCommand,\n\tCommitTransactionCommand,\n\tExecuteStatementCommand,\n\tRollbackTransactionCommand,\n} from '@aws-sdk/client-rds-data';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport {\n\ttype PgDialect,\n\tPgPreparedQuery,\n\ttype PgQueryResultHKT,\n\tPgSession,\n\tPgTransaction,\n\ttype PgTransactionConfig,\n\ttype PreparedQueryConfig,\n} from '~/pg-core/index.ts';\nimport type { SelectedFieldsOrdered } from '~/pg-core/query-builders/select.types.ts';\nimport type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type QueryTypingsValue, type QueryWithTypings, type SQL, sql } from '~/sql/sql.ts';\nimport { mapResultRow } from '~/utils.ts';\nimport { getValueFromDataApi, toValueParam } from '../common/index.ts';\n\nexport type AwsDataApiClient = RDSDataClient;\n\nexport class AwsDataApiPreparedQuery<\n\tT extends PreparedQueryConfig & { values: AwsDataApiPgQueryResult<unknown[]> },\n> extends PgPreparedQuery<T> {\n\tstatic override readonly [entityKind]: string = 'AwsDataApiPreparedQuery';\n\n\tprivate rawQuery: ExecuteStatementCommand;\n\n\tconstructor(\n\t\tprivate client: AwsDataApiClient,\n\t\tqueryString: string,\n\t\tprivate params: unknown[],\n\t\tprivate typings: QueryTypingsValue[],\n\t\tprivate options: AwsDataApiSessionOptions,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\t/** @internal */\n\t\treadonly transactionId: string | undefined,\n\t\tprivate _isResponseInArrayMode: boolean,\n\t\tprivate customResultMapper?: (rows: unknown[][]) => T['execute'],\n\t) {\n\t\tsuper({ sql: queryString, params });\n\t\tthis.rawQuery = new ExecuteStatementCommand({\n\t\t\tsql: queryString,\n\t\t\tparameters: [],\n\t\t\tsecretArn: options.secretArn,\n\t\t\tresourceArn: options.resourceArn,\n\t\t\tdatabase: options.database,\n\t\t\ttransactionId,\n\t\t\tincludeResultMetadata: !fields && !customResultMapper,\n\t\t});\n\t}\n\n\tasync execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tconst { fields, joinsNotNullableMap, customResultMapper } = this;\n\n\t\tconst result = await this.values(placeholderValues);\n\t\tif (!fields && !customResultMapper) {\n\t\t\tconst { columnMetadata, rows } = result;\n\t\t\tif (!columnMetadata) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tconst mappedRows = rows.map((sourceRow) => {\n\t\t\t\tconst row: Record<string, unknown> = {};\n\t\t\t\tfor (const [index, value] of sourceRow.entries()) {\n\t\t\t\t\tconst metadata = columnMetadata[index];\n\t\t\t\t\tif (!metadata) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Unexpected state: no column metadata found for index ${index}. Please report this issue on GitHub: https://github.com/drizzle-team/drizzle-orm/issues/new/choose`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (!metadata.name) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Unexpected state: no column name for index ${index} found in the column metadata. Please report this issue on GitHub: https://github.com/drizzle-team/drizzle-orm/issues/new/choose`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\trow[metadata.name] = value;\n\t\t\t\t}\n\t\t\t\treturn row;\n\t\t\t});\n\t\t\treturn Object.assign(result, { rows: mappedRows });\n\t\t}\n\n\t\treturn customResultMapper\n\t\t\t? customResultMapper(result.rows!)\n\t\t\t: result.rows!.map((row) => mapResultRow(fields!, row, joinsNotNullableMap));\n\t}\n\n\tasync all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']> {\n\t\tconst result = await this.execute(placeholderValues);\n\t\tif (!this.fields && !this.customResultMapper) {\n\t\t\treturn (result as AwsDataApiPgQueryResult<unknown>).rows;\n\t\t}\n\t\treturn result;\n\t}\n\n\tasync values(placeholderValues: Record<string, unknown> = {}): Promise<T['values']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues ?? {});\n\n\t\tthis.rawQuery.input.parameters = params.map((param, index) => ({\n\t\t\tname: `${index + 1}`,\n\t\t\t...toValueParam(param, this.typings[index]),\n\t\t}));\n\n\t\tthis.options.logger?.logQuery(this.rawQuery.input.sql!, this.rawQuery.input.parameters);\n\n\t\tconst result = await this.client.send(this.rawQuery);\n\t\tconst rows = result.records?.map((row) => {\n\t\t\treturn row.map((field) => getValueFromDataApi(field));\n\t\t}) ?? [];\n\n\t\treturn {\n\t\t\t...result,\n\t\t\trows,\n\t\t};\n\t}\n\n\t/** @internal */\n\tmapResultRows(records: Field[][], columnMetadata: ColumnMetadata[]) {\n\t\treturn records.map((record) => {\n\t\t\tconst row: Record<string, unknown> = {};\n\t\t\tfor (const [index, field] of record.entries()) {\n\t\t\t\tconst { name } = columnMetadata[index]!;\n\t\t\t\trow[name ?? index] = getValueFromDataApi(field); // not what to default if name is undefined\n\t\t\t}\n\t\t\treturn row;\n\t\t});\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface AwsDataApiSessionOptions {\n\tlogger?: Logger;\n\tdatabase: string;\n\tresourceArn: string;\n\tsecretArn: string;\n}\n\ninterface AwsDataApiQueryBase {\n\tresourceArn: string;\n\tsecretArn: string;\n\tdatabase: string;\n}\n\nexport class AwsDataApiSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgSession<AwsDataApiPgQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'AwsDataApiSession';\n\n\t/** @internal */\n\treadonly rawQuery: AwsDataApiQueryBase;\n\n\tconstructor(\n\t\t/** @internal */\n\t\treadonly client: AwsDataApiClient,\n\t\tdialect: PgDialect,\n\t\tprivate schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: AwsDataApiSessionOptions,\n\t\t/** @internal */\n\t\treadonly transactionId: string | undefined,\n\t) {\n\t\tsuper(dialect);\n\t\tthis.rawQuery = {\n\t\t\tsecretArn: options.secretArn,\n\t\t\tresourceArn: options.resourceArn,\n\t\t\tdatabase: options.database,\n\t\t};\n\t}\n\n\tprepareQuery<\n\t\tT extends PreparedQueryConfig & {\n\t\t\tvalues: AwsDataApiPgQueryResult<unknown[]>;\n\t\t} = PreparedQueryConfig & {\n\t\t\tvalues: AwsDataApiPgQueryResult<unknown[]>;\n\t\t},\n\t>(\n\t\tquery: QueryWithTypings,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\ttransactionId?: string,\n\t): AwsDataApiPreparedQuery<T> {\n\t\treturn new AwsDataApiPreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery.sql,\n\t\t\tquery.params,\n\t\t\tquery.typings ?? [],\n\t\t\tthis.options,\n\t\t\tfields,\n\t\t\ttransactionId ?? this.transactionId,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\toverride execute<T>(query: SQL): Promise<T> {\n\t\treturn this.prepareQuery<PreparedQueryConfig & { execute: T; values: AwsDataApiPgQueryResult<unknown[]> }>(\n\t\t\tthis.dialect.sqlToQuery(query),\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\tfalse,\n\t\t\tundefined,\n\t\t\tthis.transactionId,\n\t\t).execute();\n\t}\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: AwsDataApiTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t\tconfig?: PgTransactionConfig | undefined,\n\t): Promise<T> {\n\t\tconst { transactionId } = await this.client.send(new BeginTransactionCommand(this.rawQuery));\n\t\tconst session = new AwsDataApiSession(this.client, this.dialect, this.schema, this.options, transactionId);\n\t\tconst tx = new AwsDataApiTransaction<TFullSchema, TSchema>(this.dialect, session, this.schema);\n\t\tif (config) {\n\t\t\tawait tx.setTransaction(config);\n\t\t}\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait this.client.send(new CommitTransactionCommand({ ...this.rawQuery, transactionId }));\n\t\t\treturn result;\n\t\t} catch (e) {\n\t\t\tawait this.client.send(new RollbackTransactionCommand({ ...this.rawQuery, transactionId }));\n\t\t\tthrow e;\n\t\t}\n\t}\n}\n\nexport class AwsDataApiTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgTransaction<AwsDataApiPgQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'AwsDataApiTransaction';\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: AwsDataApiTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new AwsDataApiTransaction<TFullSchema, TSchema>(\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tthis.schema,\n\t\t\tthis.nestedIndex + 1,\n\t\t);\n\t\tawait this.session.execute(sql.raw(`savepoint ${savepointName}`));\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait this.session.execute(sql.raw(`release savepoint ${savepointName}`));\n\t\t\treturn result;\n\t\t} catch (e) {\n\t\t\tawait this.session.execute(sql.raw(`rollback to savepoint ${savepointName}`));\n\t\t\tthrow e;\n\t\t}\n\t}\n}\n\nexport type AwsDataApiPgQueryResult<T> = ExecuteStatementCommandOutput & { rows: T[] };\n\nexport interface AwsDataApiPgQueryResultHKT extends PgQueryResultHKT {\n\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,MAAM;AAAA,IAC/B;AACA,QAAI;AACH,YAAM,SAAS,MAAM,YAAY,EAAE;AACnC,YAAM,KAAK,OAAO,KAAK,IAAI,gDAAyB,EAAE,GAAG,KAAK,UAAU,cAAc,CAAC,CAAC;AACxF,aAAO;AAAA,IACR,SAAS,GAAG;AACX,YAAM,KAAK,OAAO,KAAK,IAAI,kDAA2B,EAAE,GAAG,KAAK,UAAU,cAAc,CAAC,CAAC;AAC1F,YAAM;AAAA,IACP;AAAA,EACD;AACD;AAEO,MAAM,8BAGH,6BAAgE;AAAA,EACzE,QAA0B,wBAAU,IAAY;AAAA,EAEhD,MAAe,YACd,aACa;AACb,UAAM,gBAAgB,KAAK,KAAK,cAAc,CAAC;AAC/C,UAAM,KAAK,IAAI;AAAA,MACd,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK,cAAc;AAAA,IACpB;AACA,UAAM,KAAK,QAAQ,QAAQ,eAAI,IAAI,aAAa,aAAa,EAAE,CAAC;AAChE,QAAI;AACH,YAAM,SAAS,MAAM,YAAY,EAAE;AACnC,YAAM,KAAK,QAAQ,QAAQ,eAAI,IAAI,qBAAqB,aAAa,EAAE,CAAC;AACxE,aAAO;AAAA,IACR,SAAS,GAAG;AACX,YAAM,KAAK,QAAQ,QAAQ,eAAI,IAAI,yBAAyB,aAAa,EAAE,CAAC;AAC5E,YAAM;AAAA,IACP;AAAA,EACD;AACD;","names":[]}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import type { ExecuteStatementCommandOutput, RDSDataClient } from '@aws-sdk/client-rds-data';
|
|
2
|
-
import type * as V1 from "../../_relations.cjs";
|
|
3
2
|
import { entityKind } from "../../entity.cjs";
|
|
4
3
|
import type { Logger } from "../../logger.cjs";
|
|
5
4
|
import { type PgDialect, PgPreparedQuery, type PgQueryResultHKT, PgSession, PgTransaction, type PgTransactionConfig, type PreparedQueryConfig } from "../../pg-core/index.cjs";
|
|
6
5
|
import type { SelectedFieldsOrdered } from "../../pg-core/query-builders/select.types.cjs";
|
|
7
|
-
import type {
|
|
6
|
+
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../../relations.cjs";
|
|
8
7
|
import { type QueryTypingsValue, type QueryWithTypings, type SQL } from "../../sql/sql.cjs";
|
|
9
8
|
export type AwsDataApiClient = RDSDataClient;
|
|
10
9
|
export declare class AwsDataApiPreparedQuery<T extends PreparedQueryConfig & {
|
|
11
10
|
values: AwsDataApiPgQueryResult<unknown[]>;
|
|
12
|
-
}
|
|
11
|
+
}> extends PgPreparedQuery<T> {
|
|
13
12
|
private client;
|
|
14
13
|
private params;
|
|
15
14
|
private typings;
|
|
@@ -17,14 +16,12 @@ export declare class AwsDataApiPreparedQuery<T extends PreparedQueryConfig & {
|
|
|
17
16
|
private fields;
|
|
18
17
|
private _isResponseInArrayMode;
|
|
19
18
|
private customResultMapper?;
|
|
20
|
-
private isRqbV2Query?;
|
|
21
19
|
static readonly [entityKind]: string;
|
|
22
20
|
private rawQuery;
|
|
23
21
|
constructor(client: AwsDataApiClient, queryString: string, params: unknown[], typings: QueryTypingsValue[], options: AwsDataApiSessionOptions, fields: SelectedFieldsOrdered | undefined,
|
|
24
22
|
/** @internal */
|
|
25
|
-
transactionId: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows:
|
|
23
|
+
transactionId: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
|
26
24
|
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
27
|
-
private executeRqbV2;
|
|
28
25
|
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
|
29
26
|
values(placeholderValues?: Record<string, unknown>): Promise<T['values']>;
|
|
30
27
|
}
|
|
@@ -34,14 +31,13 @@ export interface AwsDataApiSessionOptions {
|
|
|
34
31
|
resourceArn: string;
|
|
35
32
|
secretArn: string;
|
|
36
33
|
}
|
|
37
|
-
export declare class AwsDataApiSession<TFullSchema extends Record<string, unknown>,
|
|
38
|
-
private relations;
|
|
34
|
+
export declare class AwsDataApiSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<AwsDataApiPgQueryResultHKT, TFullSchema, TSchema> {
|
|
39
35
|
private schema;
|
|
40
36
|
private options;
|
|
41
37
|
static readonly [entityKind]: string;
|
|
42
38
|
constructor(
|
|
43
39
|
/** @internal */
|
|
44
|
-
client: AwsDataApiClient, dialect: PgDialect,
|
|
40
|
+
client: AwsDataApiClient, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options: AwsDataApiSessionOptions,
|
|
45
41
|
/** @internal */
|
|
46
42
|
transactionId: string | undefined);
|
|
47
43
|
prepareQuery<T extends PreparedQueryConfig & {
|
|
@@ -49,13 +45,12 @@ export declare class AwsDataApiSession<TFullSchema extends Record<string, unknow
|
|
|
49
45
|
} = PreparedQueryConfig & {
|
|
50
46
|
values: AwsDataApiPgQueryResult<unknown[]>;
|
|
51
47
|
}>(query: QueryWithTypings, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute'], transactionId?: string): AwsDataApiPreparedQuery<T>;
|
|
52
|
-
prepareRelationalQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: QueryWithTypings, fields: SelectedFieldsOrdered | undefined, name: string | undefined, customResultMapper: (rows: Record<string, unknown>[]) => T['execute'], transactionId?: string): PgPreparedQuery<T>;
|
|
53
48
|
execute<T>(query: SQL): Promise<T>;
|
|
54
|
-
transaction<T>(transaction: (tx: AwsDataApiTransaction<TFullSchema,
|
|
49
|
+
transaction<T>(transaction: (tx: AwsDataApiTransaction<TFullSchema, TSchema>) => Promise<T>, config?: PgTransactionConfig | undefined): Promise<T>;
|
|
55
50
|
}
|
|
56
|
-
export declare class AwsDataApiTransaction<TFullSchema extends Record<string, unknown>,
|
|
51
|
+
export declare class AwsDataApiTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgTransaction<AwsDataApiPgQueryResultHKT, TFullSchema, TSchema> {
|
|
57
52
|
static readonly [entityKind]: string;
|
|
58
|
-
transaction<T>(transaction: (tx: AwsDataApiTransaction<TFullSchema,
|
|
53
|
+
transaction<T>(transaction: (tx: AwsDataApiTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
59
54
|
}
|
|
60
55
|
export type AwsDataApiPgQueryResult<T> = ExecuteStatementCommandOutput & {
|
|
61
56
|
rows: T[];
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import type { ExecuteStatementCommandOutput, RDSDataClient } from '@aws-sdk/client-rds-data';
|
|
2
|
-
import type * as V1 from "../../_relations.js";
|
|
3
2
|
import { entityKind } from "../../entity.js";
|
|
4
3
|
import type { Logger } from "../../logger.js";
|
|
5
4
|
import { type PgDialect, PgPreparedQuery, type PgQueryResultHKT, PgSession, PgTransaction, type PgTransactionConfig, type PreparedQueryConfig } from "../../pg-core/index.js";
|
|
6
5
|
import type { SelectedFieldsOrdered } from "../../pg-core/query-builders/select.types.js";
|
|
7
|
-
import type {
|
|
6
|
+
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../../relations.js";
|
|
8
7
|
import { type QueryTypingsValue, type QueryWithTypings, type SQL } from "../../sql/sql.js";
|
|
9
8
|
export type AwsDataApiClient = RDSDataClient;
|
|
10
9
|
export declare class AwsDataApiPreparedQuery<T extends PreparedQueryConfig & {
|
|
11
10
|
values: AwsDataApiPgQueryResult<unknown[]>;
|
|
12
|
-
}
|
|
11
|
+
}> extends PgPreparedQuery<T> {
|
|
13
12
|
private client;
|
|
14
13
|
private params;
|
|
15
14
|
private typings;
|
|
@@ -17,14 +16,12 @@ export declare class AwsDataApiPreparedQuery<T extends PreparedQueryConfig & {
|
|
|
17
16
|
private fields;
|
|
18
17
|
private _isResponseInArrayMode;
|
|
19
18
|
private customResultMapper?;
|
|
20
|
-
private isRqbV2Query?;
|
|
21
19
|
static readonly [entityKind]: string;
|
|
22
20
|
private rawQuery;
|
|
23
21
|
constructor(client: AwsDataApiClient, queryString: string, params: unknown[], typings: QueryTypingsValue[], options: AwsDataApiSessionOptions, fields: SelectedFieldsOrdered | undefined,
|
|
24
22
|
/** @internal */
|
|
25
|
-
transactionId: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows:
|
|
23
|
+
transactionId: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
|
26
24
|
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
27
|
-
private executeRqbV2;
|
|
28
25
|
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
|
29
26
|
values(placeholderValues?: Record<string, unknown>): Promise<T['values']>;
|
|
30
27
|
}
|
|
@@ -34,14 +31,13 @@ export interface AwsDataApiSessionOptions {
|
|
|
34
31
|
resourceArn: string;
|
|
35
32
|
secretArn: string;
|
|
36
33
|
}
|
|
37
|
-
export declare class AwsDataApiSession<TFullSchema extends Record<string, unknown>,
|
|
38
|
-
private relations;
|
|
34
|
+
export declare class AwsDataApiSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<AwsDataApiPgQueryResultHKT, TFullSchema, TSchema> {
|
|
39
35
|
private schema;
|
|
40
36
|
private options;
|
|
41
37
|
static readonly [entityKind]: string;
|
|
42
38
|
constructor(
|
|
43
39
|
/** @internal */
|
|
44
|
-
client: AwsDataApiClient, dialect: PgDialect,
|
|
40
|
+
client: AwsDataApiClient, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options: AwsDataApiSessionOptions,
|
|
45
41
|
/** @internal */
|
|
46
42
|
transactionId: string | undefined);
|
|
47
43
|
prepareQuery<T extends PreparedQueryConfig & {
|
|
@@ -49,13 +45,12 @@ export declare class AwsDataApiSession<TFullSchema extends Record<string, unknow
|
|
|
49
45
|
} = PreparedQueryConfig & {
|
|
50
46
|
values: AwsDataApiPgQueryResult<unknown[]>;
|
|
51
47
|
}>(query: QueryWithTypings, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute'], transactionId?: string): AwsDataApiPreparedQuery<T>;
|
|
52
|
-
prepareRelationalQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: QueryWithTypings, fields: SelectedFieldsOrdered | undefined, name: string | undefined, customResultMapper: (rows: Record<string, unknown>[]) => T['execute'], transactionId?: string): PgPreparedQuery<T>;
|
|
53
48
|
execute<T>(query: SQL): Promise<T>;
|
|
54
|
-
transaction<T>(transaction: (tx: AwsDataApiTransaction<TFullSchema,
|
|
49
|
+
transaction<T>(transaction: (tx: AwsDataApiTransaction<TFullSchema, TSchema>) => Promise<T>, config?: PgTransactionConfig | undefined): Promise<T>;
|
|
55
50
|
}
|
|
56
|
-
export declare class AwsDataApiTransaction<TFullSchema extends Record<string, unknown>,
|
|
51
|
+
export declare class AwsDataApiTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgTransaction<AwsDataApiPgQueryResultHKT, TFullSchema, TSchema> {
|
|
57
52
|
static readonly [entityKind]: string;
|
|
58
|
-
transaction<T>(transaction: (tx: AwsDataApiTransaction<TFullSchema,
|
|
53
|
+
transaction<T>(transaction: (tx: AwsDataApiTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
59
54
|
}
|
|
60
55
|
export type AwsDataApiPgQueryResult<T> = ExecuteStatementCommandOutput & {
|
|
61
56
|
rows: T[];
|
|
@@ -14,7 +14,7 @@ import { fillPlaceholders, sql } from "../../sql/sql.js";
|
|
|
14
14
|
import { mapResultRow } from "../../utils.js";
|
|
15
15
|
import { getValueFromDataApi, toValueParam } from "../common/index.js";
|
|
16
16
|
class AwsDataApiPreparedQuery extends PgPreparedQuery {
|
|
17
|
-
constructor(client, queryString, params, typings, options, fields, transactionId, _isResponseInArrayMode, customResultMapper
|
|
17
|
+
constructor(client, queryString, params, typings, options, fields, transactionId, _isResponseInArrayMode, customResultMapper) {
|
|
18
18
|
super({ sql: queryString, params });
|
|
19
19
|
this.client = client;
|
|
20
20
|
this.params = params;
|
|
@@ -24,7 +24,6 @@ class AwsDataApiPreparedQuery extends PgPreparedQuery {
|
|
|
24
24
|
this.transactionId = transactionId;
|
|
25
25
|
this._isResponseInArrayMode = _isResponseInArrayMode;
|
|
26
26
|
this.customResultMapper = customResultMapper;
|
|
27
|
-
this.isRqbV2Query = isRqbV2Query;
|
|
28
27
|
this.rawQuery = new ExecuteStatementCommand({
|
|
29
28
|
sql: queryString,
|
|
30
29
|
parameters: [],
|
|
@@ -38,8 +37,6 @@ class AwsDataApiPreparedQuery extends PgPreparedQuery {
|
|
|
38
37
|
static [entityKind] = "AwsDataApiPreparedQuery";
|
|
39
38
|
rawQuery;
|
|
40
39
|
async execute(placeholderValues = {}) {
|
|
41
|
-
if (this.isRqbV2Query)
|
|
42
|
-
return this.executeRqbV2(placeholderValues);
|
|
43
40
|
const { fields, joinsNotNullableMap, customResultMapper } = this;
|
|
44
41
|
const result = await this.values(placeholderValues);
|
|
45
42
|
if (!fields && !customResultMapper) {
|
|
@@ -69,38 +66,6 @@ class AwsDataApiPreparedQuery extends PgPreparedQuery {
|
|
|
69
66
|
}
|
|
70
67
|
return customResultMapper ? customResultMapper(result.rows) : result.rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
|
71
68
|
}
|
|
72
|
-
async executeRqbV2(placeholderValues = {}) {
|
|
73
|
-
const { customResultMapper } = this;
|
|
74
|
-
const result = await this.values(placeholderValues);
|
|
75
|
-
const { columnMetadata, rows } = result;
|
|
76
|
-
if (!columnMetadata) {
|
|
77
|
-
return customResultMapper(
|
|
78
|
-
rows
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
const mappedRows = rows.map((sourceRow) => {
|
|
82
|
-
const row = {};
|
|
83
|
-
for (const [index, value] of sourceRow.entries()) {
|
|
84
|
-
const metadata = columnMetadata[index];
|
|
85
|
-
if (!metadata) {
|
|
86
|
-
throw new Error(
|
|
87
|
-
`Unexpected state: no column metadata found for index ${index}. Please report this issue on GitHub: https://github.com/drizzle-team/drizzle-orm/issues/new/choose`
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
if (!metadata.name) {
|
|
91
|
-
throw new Error(
|
|
92
|
-
`Unexpected state: no column name for index ${index} found in the column metadata. Please report this issue on GitHub: https://github.com/drizzle-team/drizzle-orm/issues/new/choose`
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
row[metadata.name] = value;
|
|
96
|
-
}
|
|
97
|
-
return row;
|
|
98
|
-
});
|
|
99
|
-
Object.assign(result, { rows: mappedRows });
|
|
100
|
-
return customResultMapper(
|
|
101
|
-
mappedRows
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
69
|
async all(placeholderValues) {
|
|
105
70
|
const result = await this.execute(placeholderValues);
|
|
106
71
|
if (!this.fields && !this.customResultMapper) {
|
|
@@ -141,10 +106,9 @@ class AwsDataApiPreparedQuery extends PgPreparedQuery {
|
|
|
141
106
|
}
|
|
142
107
|
}
|
|
143
108
|
class AwsDataApiSession extends PgSession {
|
|
144
|
-
constructor(client, dialect,
|
|
109
|
+
constructor(client, dialect, schema, options, transactionId) {
|
|
145
110
|
super(dialect);
|
|
146
111
|
this.client = client;
|
|
147
|
-
this.relations = relations;
|
|
148
112
|
this.schema = schema;
|
|
149
113
|
this.options = options;
|
|
150
114
|
this.transactionId = transactionId;
|
|
@@ -170,20 +134,6 @@ class AwsDataApiSession extends PgSession {
|
|
|
170
134
|
customResultMapper
|
|
171
135
|
);
|
|
172
136
|
}
|
|
173
|
-
prepareRelationalQuery(query, fields, name, customResultMapper, transactionId) {
|
|
174
|
-
return new AwsDataApiPreparedQuery(
|
|
175
|
-
this.client,
|
|
176
|
-
query.sql,
|
|
177
|
-
query.params,
|
|
178
|
-
query.typings ?? [],
|
|
179
|
-
this.options,
|
|
180
|
-
fields,
|
|
181
|
-
transactionId ?? this.transactionId,
|
|
182
|
-
false,
|
|
183
|
-
customResultMapper,
|
|
184
|
-
true
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
137
|
execute(query) {
|
|
188
138
|
return this.prepareQuery(
|
|
189
139
|
this.dialect.sqlToQuery(query),
|
|
@@ -196,20 +146,8 @@ class AwsDataApiSession extends PgSession {
|
|
|
196
146
|
}
|
|
197
147
|
async transaction(transaction, config) {
|
|
198
148
|
const { transactionId } = await this.client.send(new BeginTransactionCommand(this.rawQuery));
|
|
199
|
-
const session = new AwsDataApiSession(
|
|
200
|
-
|
|
201
|
-
this.dialect,
|
|
202
|
-
this.relations,
|
|
203
|
-
this.schema,
|
|
204
|
-
this.options,
|
|
205
|
-
transactionId
|
|
206
|
-
);
|
|
207
|
-
const tx = new AwsDataApiTransaction(
|
|
208
|
-
this.dialect,
|
|
209
|
-
session,
|
|
210
|
-
this.relations,
|
|
211
|
-
this.schema
|
|
212
|
-
);
|
|
149
|
+
const session = new AwsDataApiSession(this.client, this.dialect, this.schema, this.options, transactionId);
|
|
150
|
+
const tx = new AwsDataApiTransaction(this.dialect, session, this.schema);
|
|
213
151
|
if (config) {
|
|
214
152
|
await tx.setTransaction(config);
|
|
215
153
|
}
|
|
@@ -230,7 +168,6 @@ class AwsDataApiTransaction extends PgTransaction {
|
|
|
230
168
|
const tx = new AwsDataApiTransaction(
|
|
231
169
|
this.dialect,
|
|
232
170
|
this.session,
|
|
233
|
-
this.relations,
|
|
234
171
|
this.schema,
|
|
235
172
|
this.nestedIndex + 1
|
|
236
173
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/aws-data-api/pg/session.ts"],"sourcesContent":["import type { ColumnMetadata, ExecuteStatementCommandOutput, Field, RDSDataClient } from '@aws-sdk/client-rds-data';\nimport {\n\tBeginTransactionCommand,\n\tCommitTransactionCommand,\n\tExecuteStatementCommand,\n\tRollbackTransactionCommand,\n} from '@aws-sdk/client-rds-data';\nimport type * as V1 from '~/_relations.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport {\n\ttype PgDialect,\n\tPgPreparedQuery,\n\ttype PgQueryResultHKT,\n\tPgSession,\n\tPgTransaction,\n\ttype PgTransactionConfig,\n\ttype PreparedQueryConfig,\n} from '~/pg-core/index.ts';\nimport type { SelectedFieldsOrdered } from '~/pg-core/query-builders/select.types.ts';\nimport type { AnyRelations, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type QueryTypingsValue, type QueryWithTypings, type SQL, sql } from '~/sql/sql.ts';\nimport { mapResultRow } from '~/utils.ts';\nimport { getValueFromDataApi, toValueParam } from '../common/index.ts';\n\nexport type AwsDataApiClient = RDSDataClient;\n\nexport class AwsDataApiPreparedQuery<\n\tT extends PreparedQueryConfig & { values: AwsDataApiPgQueryResult<unknown[]> },\n\tTIsRqbV2 extends boolean = false,\n> extends PgPreparedQuery<T> {\n\tstatic override readonly [entityKind]: string = 'AwsDataApiPreparedQuery';\n\n\tprivate rawQuery: ExecuteStatementCommand;\n\n\tconstructor(\n\t\tprivate client: AwsDataApiClient,\n\t\tqueryString: string,\n\t\tprivate params: unknown[],\n\t\tprivate typings: QueryTypingsValue[],\n\t\tprivate options: AwsDataApiSessionOptions,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\t/** @internal */\n\t\treadonly transactionId: string | undefined,\n\t\tprivate _isResponseInArrayMode: boolean,\n\t\tprivate customResultMapper?: (\n\t\t\trows: TIsRqbV2 extends true ? Record<string, unknown>[] : unknown[][],\n\t\t) => T['execute'],\n\t\tprivate isRqbV2Query?: TIsRqbV2,\n\t) {\n\t\tsuper({ sql: queryString, params });\n\t\tthis.rawQuery = new ExecuteStatementCommand({\n\t\t\tsql: queryString,\n\t\t\tparameters: [],\n\t\t\tsecretArn: options.secretArn,\n\t\t\tresourceArn: options.resourceArn,\n\t\t\tdatabase: options.database,\n\t\t\ttransactionId,\n\t\t\tincludeResultMetadata: !fields && !customResultMapper,\n\t\t});\n\t}\n\n\tasync execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tif (this.isRqbV2Query) return this.executeRqbV2(placeholderValues);\n\n\t\tconst { fields, joinsNotNullableMap, customResultMapper } = this;\n\n\t\tconst result = await this.values(placeholderValues);\n\t\tif (!fields && !customResultMapper) {\n\t\t\tconst { columnMetadata, rows } = result;\n\t\t\tif (!columnMetadata) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tconst mappedRows = rows.map((sourceRow) => {\n\t\t\t\tconst row: Record<string, unknown> = {};\n\t\t\t\tfor (const [index, value] of sourceRow.entries()) {\n\t\t\t\t\tconst metadata = columnMetadata[index];\n\t\t\t\t\tif (!metadata) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Unexpected state: no column metadata found for index ${index}. Please report this issue on GitHub: https://github.com/drizzle-team/drizzle-orm/issues/new/choose`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (!metadata.name) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Unexpected state: no column name for index ${index} found in the column metadata. Please report this issue on GitHub: https://github.com/drizzle-team/drizzle-orm/issues/new/choose`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\trow[metadata.name] = value;\n\t\t\t\t}\n\t\t\t\treturn row;\n\t\t\t});\n\t\t\treturn Object.assign(result, { rows: mappedRows });\n\t\t}\n\n\t\treturn customResultMapper\n\t\t\t? (customResultMapper as (rows: unknown[][]) => T['execute'])(result.rows!)\n\t\t\t: result.rows!.map((row) => mapResultRow(fields!, row, joinsNotNullableMap));\n\t}\n\n\tprivate async executeRqbV2(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tconst { customResultMapper } = this;\n\n\t\tconst result = await this.values(placeholderValues);\n\t\tconst { columnMetadata, rows } = result;\n\t\tif (!columnMetadata) {\n\t\t\treturn (customResultMapper as (rows: Record<string, unknown>[]) => T['execute'])(\n\t\t\t\trows as any as Record<string, unknown>[],\n\t\t\t);\n\t\t}\n\t\tconst mappedRows = rows.map((sourceRow) => {\n\t\t\tconst row: Record<string, unknown> = {};\n\t\t\tfor (const [index, value] of sourceRow.entries()) {\n\t\t\t\tconst metadata = columnMetadata[index];\n\t\t\t\tif (!metadata) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Unexpected state: no column metadata found for index ${index}. Please report this issue on GitHub: https://github.com/drizzle-team/drizzle-orm/issues/new/choose`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (!metadata.name) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Unexpected state: no column name for index ${index} found in the column metadata. Please report this issue on GitHub: https://github.com/drizzle-team/drizzle-orm/issues/new/choose`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\trow[metadata.name] = value;\n\t\t\t}\n\t\t\treturn row;\n\t\t});\n\n\t\tObject.assign(result, { rows: mappedRows });\n\n\t\treturn (customResultMapper as (rows: Record<string, unknown>[]) => T['execute'])(\n\t\t\tmappedRows,\n\t\t);\n\t}\n\n\tasync all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']> {\n\t\tconst result = await this.execute(placeholderValues);\n\t\tif (!this.fields && !this.customResultMapper) {\n\t\t\treturn (result as AwsDataApiPgQueryResult<unknown>).rows;\n\t\t}\n\t\treturn result;\n\t}\n\n\tasync values(placeholderValues: Record<string, unknown> = {}): Promise<T['values']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues ?? {});\n\n\t\tthis.rawQuery.input.parameters = params.map((param, index) => ({\n\t\t\tname: `${index + 1}`,\n\t\t\t...toValueParam(param, this.typings[index]),\n\t\t}));\n\n\t\tthis.options.logger?.logQuery(this.rawQuery.input.sql!, this.rawQuery.input.parameters);\n\n\t\tconst result = await this.client.send(this.rawQuery);\n\t\tconst rows = result.records?.map((row) => {\n\t\t\treturn row.map((field) => getValueFromDataApi(field));\n\t\t}) ?? [];\n\n\t\treturn {\n\t\t\t...result,\n\t\t\trows,\n\t\t};\n\t}\n\n\t/** @internal */\n\tmapResultRows(records: Field[][], columnMetadata: ColumnMetadata[]) {\n\t\treturn records.map((record) => {\n\t\t\tconst row: Record<string, unknown> = {};\n\t\t\tfor (const [index, field] of record.entries()) {\n\t\t\t\tconst { name } = columnMetadata[index]!;\n\t\t\t\trow[name ?? index] = getValueFromDataApi(field); // not what to default if name is undefined\n\t\t\t}\n\t\t\treturn row;\n\t\t});\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface AwsDataApiSessionOptions {\n\tlogger?: Logger;\n\tdatabase: string;\n\tresourceArn: string;\n\tsecretArn: string;\n}\n\ninterface AwsDataApiQueryBase {\n\tresourceArn: string;\n\tsecretArn: string;\n\tdatabase: string;\n}\n\nexport class AwsDataApiSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends PgSession<AwsDataApiPgQueryResultHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'AwsDataApiSession';\n\n\t/** @internal */\n\treadonly rawQuery: AwsDataApiQueryBase;\n\n\tconstructor(\n\t\t/** @internal */\n\t\treadonly client: AwsDataApiClient,\n\t\tdialect: PgDialect,\n\t\tprivate relations: AnyRelations | undefined,\n\t\tprivate schema: V1.RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: AwsDataApiSessionOptions,\n\t\t/** @internal */\n\t\treadonly transactionId: string | undefined,\n\t) {\n\t\tsuper(dialect);\n\t\tthis.rawQuery = {\n\t\t\tsecretArn: options.secretArn,\n\t\t\tresourceArn: options.resourceArn,\n\t\t\tdatabase: options.database,\n\t\t};\n\t}\n\n\tprepareQuery<\n\t\tT extends PreparedQueryConfig & {\n\t\t\tvalues: AwsDataApiPgQueryResult<unknown[]>;\n\t\t} = PreparedQueryConfig & {\n\t\t\tvalues: AwsDataApiPgQueryResult<unknown[]>;\n\t\t},\n\t>(\n\t\tquery: QueryWithTypings,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\ttransactionId?: string,\n\t): AwsDataApiPreparedQuery<T> {\n\t\treturn new AwsDataApiPreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery.sql,\n\t\t\tquery.params,\n\t\t\tquery.typings ?? [],\n\t\t\tthis.options,\n\t\t\tfields,\n\t\t\ttransactionId ?? this.transactionId,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\tprepareRelationalQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(\n\t\tquery: QueryWithTypings,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tcustomResultMapper: (rows: Record<string, unknown>[]) => T['execute'],\n\t\ttransactionId?: string,\n\t): PgPreparedQuery<T> {\n\t\treturn new AwsDataApiPreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery.sql,\n\t\t\tquery.params,\n\t\t\tquery.typings ?? [],\n\t\t\tthis.options,\n\t\t\tfields,\n\t\t\ttransactionId ?? this.transactionId,\n\t\t\tfalse,\n\t\t\tcustomResultMapper,\n\t\t\ttrue,\n\t\t);\n\t}\n\n\toverride execute<T>(query: SQL): Promise<T> {\n\t\treturn this.prepareQuery<PreparedQueryConfig & { execute: T; values: AwsDataApiPgQueryResult<unknown[]> }>(\n\t\t\tthis.dialect.sqlToQuery(query),\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\tfalse,\n\t\t\tundefined,\n\t\t\tthis.transactionId,\n\t\t).execute();\n\t}\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: AwsDataApiTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>,\n\t\tconfig?: PgTransactionConfig | undefined,\n\t): Promise<T> {\n\t\tconst { transactionId } = await this.client.send(new BeginTransactionCommand(this.rawQuery));\n\t\tconst session = new AwsDataApiSession(\n\t\t\tthis.client,\n\t\t\tthis.dialect,\n\t\t\tthis.relations,\n\t\t\tthis.schema,\n\t\t\tthis.options,\n\t\t\ttransactionId,\n\t\t);\n\t\tconst tx = new AwsDataApiTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>(\n\t\t\tthis.dialect,\n\t\t\tsession,\n\t\t\tthis.relations,\n\t\t\tthis.schema,\n\t\t);\n\t\tif (config) {\n\t\t\tawait tx.setTransaction(config);\n\t\t}\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait this.client.send(new CommitTransactionCommand({ ...this.rawQuery, transactionId }));\n\t\t\treturn result;\n\t\t} catch (e) {\n\t\t\tawait this.client.send(new RollbackTransactionCommand({ ...this.rawQuery, transactionId }));\n\t\t\tthrow e;\n\t\t}\n\t}\n}\n\nexport class AwsDataApiTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends PgTransaction<AwsDataApiPgQueryResultHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'AwsDataApiTransaction';\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: AwsDataApiTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new AwsDataApiTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>(\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tthis.relations,\n\t\t\tthis.schema,\n\t\t\tthis.nestedIndex + 1,\n\t\t);\n\t\tawait this.session.execute(sql.raw(`savepoint ${savepointName}`));\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait this.session.execute(sql.raw(`release savepoint ${savepointName}`));\n\t\t\treturn result;\n\t\t} catch (e) {\n\t\t\tawait this.session.execute(sql.raw(`rollback to savepoint ${savepointName}`));\n\t\t\tthrow e;\n\t\t}\n\t}\n}\n\nexport type AwsDataApiPgQueryResult<T> = ExecuteStatementCommandOutput & { rows: T[] };\n\nexport interface AwsDataApiPgQueryResultHKT extends PgQueryResultHKT {\n\ttype: AwsDataApiPgQueryResult<any>;\n}\n"],"mappings":"AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEP,SAAS,kBAAkB;AAE3B;AAAA,EAEC;AAAA,EAEA;AAAA,EACA;AAAA,OAGM;AAGP,SAAS,kBAA2E,WAAW;AAC/F,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB,oBAAoB;AAI3C,MAAM,gCAGH,gBAAmB;AAAA,EAK5B,YACS,QACR,aACQ,QACA,SACA,SACA,QAEC,eACD,wBACA,oBAGA,cACP;AACD,UAAM,EAAE,KAAK,aAAa,OAAO,CAAC;AAd1B;AAEA;AACA;AACA;AACA;AAEC;AACD;AACA;AAGA;AAGR,SAAK,WAAW,IAAI,wBAAwB;AAAA,MAC3C,KAAK;AAAA,MACL,YAAY,CAAC;AAAA,MACb,WAAW,QAAQ;AAAA,MACnB,aAAa,QAAQ;AAAA,MACrB,UAAU,QAAQ;AAAA,MAClB;AAAA,MACA,uBAAuB,CAAC,UAAU,CAAC;AAAA,IACpC,CAAC;AAAA,EACF;AAAA,EA7BA,QAA0B,UAAU,IAAY;AAAA,EAExC;AAAA,EA6BR,MAAM,QAAQ,oBAAyD,CAAC,GAA0B;AACjG,QAAI,KAAK;AAAc,aAAO,KAAK,aAAa,iBAAiB;AAEjE,UAAM,EAAE,QAAQ,qBAAqB,mBAAmB,IAAI;AAE5D,UAAM,SAAS,MAAM,KAAK,OAAO,iBAAiB;AAClD,QAAI,CAAC,UAAU,CAAC,oB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,IAAI;AAAA,MACnB,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL;AAAA,IACD;AACA,UAAM,KAAK,IAAI;AAAA,MACd,KAAK;AAAA,MACL;AAAA,MACA,KAAK;AAAA,MACL,KAAK;AAAA,IACN;AACA,QAAI,QAAQ;AACX,YAAM,GAAG,eAAe,MAAM;AAAA,IAC/B;AACA,QAAI;AACH,YAAM,SAAS,MAAM,YAAY,EAAE;AACnC,YAAM,KAAK,OAAO,KAAK,IAAI,yBAAyB,EAAE,GAAG,KAAK,UAAU,cAAc,CAAC,CAAC;AACxF,aAAO;AAAA,IACR,SAAS,GAAG;AACX,YAAM,KAAK,OAAO,KAAK,IAAI,2BAA2B,EAAE,GAAG,KAAK,UAAU,cAAc,CAAC,CAAC;AAC1F,YAAM;AAAA,IACP;AAAA,EACD;AACD;AAEO,MAAM,8BAKH,cAA2F;AAAA,EACpG,QAA0B,UAAU,IAAY;AAAA,EAEhD,MAAe,YACd,aACa;AACb,UAAM,gBAAgB,KAAK,KAAK,cAAc,CAAC;AAC/C,UAAM,KAAK,IAAI;AAAA,MACd,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK,cAAc;AAAA,IACpB;AACA,UAAM,KAAK,QAAQ,QAAQ,IAAI,IAAI,aAAa,aAAa,EAAE,CAAC;AAChE,QAAI;AACH,YAAM,SAAS,MAAM,YAAY,EAAE;AACnC,YAAM,KAAK,QAAQ,QAAQ,IAAI,IAAI,qBAAqB,aAAa,EAAE,CAAC;AACxE,aAAO;AAAA,IACR,SAAS,GAAG;AACX,YAAM,KAAK,QAAQ,QAAQ,IAAI,IAAI,yBAAyB,aAAa,EAAE,CAAC;AAC5E,YAAM;AAAA,IACP;AAAA,EACD;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/aws-data-api/pg/session.ts"],"sourcesContent":["import type { ColumnMetadata, ExecuteStatementCommandOutput, Field, RDSDataClient } from '@aws-sdk/client-rds-data';\nimport {\n\tBeginTransactionCommand,\n\tCommitTransactionCommand,\n\tExecuteStatementCommand,\n\tRollbackTransactionCommand,\n} from '@aws-sdk/client-rds-data';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport {\n\ttype PgDialect,\n\tPgPreparedQuery,\n\ttype PgQueryResultHKT,\n\tPgSession,\n\tPgTransaction,\n\ttype PgTransactionConfig,\n\ttype PreparedQueryConfig,\n} from '~/pg-core/index.ts';\nimport type { SelectedFieldsOrdered } from '~/pg-core/query-builders/select.types.ts';\nimport type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type QueryTypingsValue, type QueryWithTypings, type SQL, sql } from '~/sql/sql.ts';\nimport { mapResultRow } from '~/utils.ts';\nimport { getValueFromDataApi, toValueParam } from '../common/index.ts';\n\nexport type AwsDataApiClient = RDSDataClient;\n\nexport class AwsDataApiPreparedQuery<\n\tT extends PreparedQueryConfig & { values: AwsDataApiPgQueryResult<unknown[]> },\n> extends PgPreparedQuery<T> {\n\tstatic override readonly [entityKind]: string = 'AwsDataApiPreparedQuery';\n\n\tprivate rawQuery: ExecuteStatementCommand;\n\n\tconstructor(\n\t\tprivate client: AwsDataApiClient,\n\t\tqueryString: string,\n\t\tprivate params: unknown[],\n\t\tprivate typings: QueryTypingsValue[],\n\t\tprivate options: AwsDataApiSessionOptions,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\t/** @internal */\n\t\treadonly transactionId: string | undefined,\n\t\tprivate _isResponseInArrayMode: boolean,\n\t\tprivate customResultMapper?: (rows: unknown[][]) => T['execute'],\n\t) {\n\t\tsuper({ sql: queryString, params });\n\t\tthis.rawQuery = new ExecuteStatementCommand({\n\t\t\tsql: queryString,\n\t\t\tparameters: [],\n\t\t\tsecretArn: options.secretArn,\n\t\t\tresourceArn: options.resourceArn,\n\t\t\tdatabase: options.database,\n\t\t\ttransactionId,\n\t\t\tincludeResultMetadata: !fields && !customResultMapper,\n\t\t});\n\t}\n\n\tasync execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tconst { fields, joinsNotNullableMap, customResultMapper } = this;\n\n\t\tconst result = await this.values(placeholderValues);\n\t\tif (!fields && !customResultMapper) {\n\t\t\tconst { columnMetadata, rows } = result;\n\t\t\tif (!columnMetadata) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tconst mappedRows = rows.map((sourceRow) => {\n\t\t\t\tconst row: Record<string, unknown> = {};\n\t\t\t\tfor (const [index, value] of sourceRow.entries()) {\n\t\t\t\t\tconst metadata = columnMetadata[index];\n\t\t\t\t\tif (!metadata) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Unexpected state: no column metadata found for index ${index}. Please report this issue on GitHub: https://github.com/drizzle-team/drizzle-orm/issues/new/choose`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (!metadata.name) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Unexpected state: no column name for index ${index} found in the column metadata. Please report this issue on GitHub: https://github.com/drizzle-team/drizzle-orm/issues/new/choose`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\trow[metadata.name] = value;\n\t\t\t\t}\n\t\t\t\treturn row;\n\t\t\t});\n\t\t\treturn Object.assign(result, { rows: mappedRows });\n\t\t}\n\n\t\treturn customResultMapper\n\t\t\t? customResultMapper(result.rows!)\n\t\t\t: result.rows!.map((row) => mapResultRow(fields!, row, joinsNotNullableMap));\n\t}\n\n\tasync all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']> {\n\t\tconst result = await this.execute(placeholderValues);\n\t\tif (!this.fields && !this.customResultMapper) {\n\t\t\treturn (result as AwsDataApiPgQueryResult<unknown>).rows;\n\t\t}\n\t\treturn result;\n\t}\n\n\tasync values(placeholderValues: Record<string, unknown> = {}): Promise<T['values']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues ?? {});\n\n\t\tthis.rawQuery.input.parameters = params.map((param, index) => ({\n\t\t\tname: `${index + 1}`,\n\t\t\t...toValueParam(param, this.typings[index]),\n\t\t}));\n\n\t\tthis.options.logger?.logQuery(this.rawQuery.input.sql!, this.rawQuery.input.parameters);\n\n\t\tconst result = await this.client.send(this.rawQuery);\n\t\tconst rows = result.records?.map((row) => {\n\t\t\treturn row.map((field) => getValueFromDataApi(field));\n\t\t}) ?? [];\n\n\t\treturn {\n\t\t\t...result,\n\t\t\trows,\n\t\t};\n\t}\n\n\t/** @internal */\n\tmapResultRows(records: Field[][], columnMetadata: ColumnMetadata[]) {\n\t\treturn records.map((record) => {\n\t\t\tconst row: Record<string, unknown> = {};\n\t\t\tfor (const [index, field] of record.entries()) {\n\t\t\t\tconst { name } = columnMetadata[index]!;\n\t\t\t\trow[name ?? index] = getValueFromDataApi(field); // not what to default if name is undefined\n\t\t\t}\n\t\t\treturn row;\n\t\t});\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface AwsDataApiSessionOptions {\n\tlogger?: Logger;\n\tdatabase: string;\n\tresourceArn: string;\n\tsecretArn: string;\n}\n\ninterface AwsDataApiQueryBase {\n\tresourceArn: string;\n\tsecretArn: string;\n\tdatabase: string;\n}\n\nexport class AwsDataApiSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgSession<AwsDataApiPgQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'AwsDataApiSession';\n\n\t/** @internal */\n\treadonly rawQuery: AwsDataApiQueryBase;\n\n\tconstructor(\n\t\t/** @internal */\n\t\treadonly client: AwsDataApiClient,\n\t\tdialect: PgDialect,\n\t\tprivate schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: AwsDataApiSessionOptions,\n\t\t/** @internal */\n\t\treadonly transactionId: string | undefined,\n\t) {\n\t\tsuper(dialect);\n\t\tthis.rawQuery = {\n\t\t\tsecretArn: options.secretArn,\n\t\t\tresourceArn: options.resourceArn,\n\t\t\tdatabase: options.database,\n\t\t};\n\t}\n\n\tprepareQuery<\n\t\tT extends PreparedQueryConfig & {\n\t\t\tvalues: AwsDataApiPgQueryResult<unknown[]>;\n\t\t} = PreparedQueryConfig & {\n\t\t\tvalues: AwsDataApiPgQueryResult<unknown[]>;\n\t\t},\n\t>(\n\t\tquery: QueryWithTypings,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\ttransactionId?: string,\n\t): AwsDataApiPreparedQuery<T> {\n\t\treturn new AwsDataApiPreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery.sql,\n\t\t\tquery.params,\n\t\t\tquery.typings ?? [],\n\t\t\tthis.options,\n\t\t\tfields,\n\t\t\ttransactionId ?? this.transactionId,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\toverride execute<T>(query: SQL): Promise<T> {\n\t\treturn this.prepareQuery<PreparedQueryConfig & { execute: T; values: AwsDataApiPgQueryResult<unknown[]> }>(\n\t\t\tthis.dialect.sqlToQuery(query),\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\tfalse,\n\t\t\tundefined,\n\t\t\tthis.transactionId,\n\t\t).execute();\n\t}\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: AwsDataApiTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t\tconfig?: PgTransactionConfig | undefined,\n\t): Promise<T> {\n\t\tconst { transactionId } = await this.client.send(new BeginTransactionCommand(this.rawQuery));\n\t\tconst session = new AwsDataApiSession(this.client, this.dialect, this.schema, this.options, transactionId);\n\t\tconst tx = new AwsDataApiTransaction<TFullSchema, TSchema>(this.dialect, session, this.schema);\n\t\tif (config) {\n\t\t\tawait tx.setTransaction(config);\n\t\t}\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait this.client.send(new CommitTransactionCommand({ ...this.rawQuery, transactionId }));\n\t\t\treturn result;\n\t\t} catch (e) {\n\t\t\tawait this.client.send(new RollbackTransactionCommand({ ...this.rawQuery, transactionId }));\n\t\t\tthrow e;\n\t\t}\n\t}\n}\n\nexport class AwsDataApiTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgTransaction<AwsDataApiPgQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'AwsDataApiTransaction';\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: AwsDataApiTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new AwsDataApiTransaction<TFullSchema, TSchema>(\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tthis.schema,\n\t\t\tthis.nestedIndex + 1,\n\t\t);\n\t\tawait this.session.execute(sql.raw(`savepoint ${savepointName}`));\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait this.session.execute(sql.raw(`release savepoint ${savepointName}`));\n\t\t\treturn result;\n\t\t} catch (e) {\n\t\t\tawait this.session.execute(sql.raw(`rollback to savepoint ${savepointName}`));\n\t\t\tthrow e;\n\t\t}\n\t}\n}\n\nexport type AwsDataApiPgQueryResult<T> = ExecuteStatementCommandOutput & { rows: T[] };\n\nexport interface AwsDataApiPgQueryResultHKT extends PgQueryResultHKT {\n\ttype: AwsDataApiPgQueryResult<any>;\n}\n"],"mappings":"AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,kBAAkB;AAE3B;AAAA,EAEC;AAAA,EAEA;AAAA,EACA;AAAA,OAGM;AAGP,SAAS,kBAA2E,WAAW;AAC/F,SAAS,oBAAoB;A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AA,IACR,SAAS,GAAG;AACX,YAAM,KAAK,OAAO,KAAK,IAAI,2BAA2B,EAAE,GAAG,KAAK,UAAU,cAAc,CAAC,CAAC;AAC1F,YAAM;AAAA,IACP;AAAA,EACD;AACD;AAEO,MAAM,8BAGH,cAAgE;AAAA,EACzE,QAA0B,UAAU,IAAY;AAAA,EAEhD,MAAe,YACd,aACa;AACb,UAAM,gBAAgB,KAAK,KAAK,cAAc,CAAC;AAC/C,UAAM,KAAK,IAAI;AAAA,MACd,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK,cAAc;AAAA,IACpB;AACA,UAAM,KAAK,QAAQ,QAAQ,IAAI,IAAI,aAAa,aAAa,EAAE,CAAC;AAChE,QAAI;AACH,YAAM,SAAS,MAAM,YAAY,EAAE;AACnC,YAAM,KAAK,QAAQ,QAAQ,IAAI,IAAI,qBAAqB,aAAa,EAAE,CAAC;AACxE,aAAO;AAAA,IACR,SAAS,GAAG;AACX,YAAM,KAAK,QAAQ,QAAQ,IAAI,IAAI,yBAAyB,aAAa,EAAE,CAAC;AAC5E,YAAM;AAAA,IACP;AAAA,EACD;AACD;","names":[]}
|
|
@@ -33,9 +33,9 @@ __export(driver_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(driver_exports);
|
|
35
35
|
var import_better_sqlite3 = __toESM(require("better-sqlite3"), 1);
|
|
36
|
-
var V1 = __toESM(require("../_relations.cjs"), 1);
|
|
37
36
|
var import_entity = require("../entity.cjs");
|
|
38
37
|
var import_logger = require("../logger.cjs");
|
|
38
|
+
var import_relations = require("../relations.cjs");
|
|
39
39
|
var import_db = require("../sqlite-core/db.cjs");
|
|
40
40
|
var import_dialect = require("../sqlite-core/dialect.cjs");
|
|
41
41
|
var import_utils = require("../utils.cjs");
|
|
@@ -53,9 +53,9 @@ function construct(client, config = {}) {
|
|
|
53
53
|
}
|
|
54
54
|
let schema;
|
|
55
55
|
if (config.schema) {
|
|
56
|
-
const tablesConfig =
|
|
56
|
+
const tablesConfig = (0, import_relations.extractTablesRelationalConfig)(
|
|
57
57
|
config.schema,
|
|
58
|
-
|
|
58
|
+
import_relations.createTableRelationsHelpers
|
|
59
59
|
);
|
|
60
60
|
schema = {
|
|
61
61
|
fullSchema: config.schema,
|
|
@@ -63,15 +63,8 @@ function construct(client, config = {}) {
|
|
|
63
63
|
tableNamesMap: tablesConfig.tableNamesMap
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
const db = new BetterSQLite3Database(
|
|
69
|
-
"sync",
|
|
70
|
-
dialect,
|
|
71
|
-
session,
|
|
72
|
-
relations,
|
|
73
|
-
schema
|
|
74
|
-
);
|
|
66
|
+
const session = new import_session.BetterSQLiteSession(client, dialect, schema, { logger });
|
|
67
|
+
const db = new BetterSQLite3Database("sync", dialect, session, schema);
|
|
75
68
|
db.$client = client;
|
|
76
69
|
return db;
|
|
77
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/better-sqlite3/driver.ts"],"sourcesContent":["import Client, { type Database, type Options, type RunResult } from 'better-sqlite3';\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/better-sqlite3/driver.ts"],"sourcesContent":["import Client, { type Database, type Options, type RunResult } from 'better-sqlite3';\nimport { entityKind } from '~/entity.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport { BaseSQLiteDatabase } from '~/sqlite-core/db.ts';\nimport { SQLiteSyncDialect } from '~/sqlite-core/dialect.ts';\nimport { type DrizzleConfig, isConfig } from '~/utils.ts';\nimport { BetterSQLiteSession } from './session.ts';\n\nexport type DrizzleBetterSQLite3DatabaseConfig =\n\t| ({\n\t\tsource?:\n\t\t\t| string\n\t\t\t| Buffer;\n\t} & Options)\n\t| string\n\t| undefined;\n\nexport class BetterSQLite3Database<TSchema extends Record<string, unknown> = Record<string, never>>\n\textends BaseSQLiteDatabase<'sync', RunResult, TSchema>\n{\n\tstatic override readonly [entityKind]: string = 'BetterSQLite3Database';\n}\n\nfunction construct<TSchema extends Record<string, unknown> = Record<string, never>>(\n\tclient: Database,\n\tconfig: DrizzleConfig<TSchema> = {},\n): BetterSQLite3Database<TSchema> & {\n\t$client: Database;\n} {\n\tconst dialect = new SQLiteSyncDialect({ casing: config.casing });\n\tlet logger;\n\tif (config.logger === true) {\n\t\tlogger = new DefaultLogger();\n\t} else if (config.logger !== false) {\n\t\tlogger = config.logger;\n\t}\n\n\tlet schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined;\n\tif (config.schema) {\n\t\tconst tablesConfig = extractTablesRelationalConfig(\n\t\t\tconfig.schema,\n\t\t\tcreateTableRelationsHelpers,\n\t\t);\n\t\tschema = {\n\t\t\tfullSchema: config.schema,\n\t\t\tschema: tablesConfig.tables,\n\t\t\ttableNamesMap: tablesConfig.tableNamesMap,\n\t\t};\n\t}\n\n\tconst session = new BetterSQLiteSession(client, dialect, schema, { logger });\n\tconst db = new BetterSQLite3Database('sync', dialect, session, schema);\n\t(<any> db).$client = client;\n\n\treturn db as any;\n}\n\nexport function drizzle<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n>(\n\t...params:\n\t\t| []\n\t\t| [\n\t\t\tDatabase | string,\n\t\t]\n\t\t| [\n\t\t\tDatabase | string,\n\t\t\tDrizzleConfig<TSchema>,\n\t\t]\n\t\t| [\n\t\t\t(\n\t\t\t\t& DrizzleConfig<TSchema>\n\t\t\t\t& ({\n\t\t\t\t\tconnection?: DrizzleBetterSQLite3DatabaseConfig;\n\t\t\t\t} | {\n\t\t\t\t\tclient: Database;\n\t\t\t\t})\n\t\t\t),\n\t\t]\n): BetterSQLite3Database<TSchema> & {\n\t$client: Database;\n} {\n\tif (params[0] === undefined || typeof params[0] === 'string') {\n\t\tconst instance = params[0] === undefined ? new Client() : new Client(params[0]);\n\n\t\treturn construct(instance, params[1]) as any;\n\t}\n\n\tif (isConfig(params[0])) {\n\t\tconst { connection, client, ...drizzleConfig } = params[0] as\n\t\t\t& {\n\t\t\t\tconnection?: DrizzleBetterSQLite3DatabaseConfig;\n\t\t\t\tclient?: Database;\n\t\t\t}\n\t\t\t& DrizzleConfig<TSchema>;\n\n\t\tif (client) return construct(client, drizzleConfig) as any;\n\n\t\tif (typeof connection === 'object') {\n\t\t\tconst { source, ...options } = connection;\n\n\t\t\tconst instance = new Client(source, options);\n\n\t\t\treturn construct(instance, drizzleConfig) as any;\n\t\t}\n\n\t\tconst instance = new Client(connection);\n\n\t\treturn construct(instance, drizzleConfig) as any;\n\t}\n\n\treturn construct(params[0] as Database, params[1] as DrizzleConfig<TSchema> | undefined) as any;\n}\n\nexport namespace drizzle {\n\texport function mock<TSchema extends Record<string, unknown> = Record<string, never>>(\n\t\tconfig?: DrizzleConfig<TSchema>,\n\t): BetterSQLite3Database<TSchema> & {\n\t\t$client: '$client is not available on drizzle.mock()';\n\t} {\n\t\treturn construct({} as any, config) as any;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAoE;AACpE,oBAA2B;AAC3B,oBAA8B;AAC9B,uBAKO;AACP,gBAAmC;AACnC,qBAAkC;AAClC,mBAA6C;AAC7C,qBAAoC;AAW7B,MAAM,8BACJ,6BACT;AAAA,EACC,QAA0B,wBAAU,IAAY;AACjD;AAEA,SAAS,UACR,QACA,SAAiC,CAAC,GAGjC;AACD,QAAM,UAAU,IAAI,iCAAkB,EAAE,QAAQ,OAAO,OAAO,CAAC;AAC/D,MAAI;AACJ,MAAI,OAAO,WAAW,MAAM;AAC3B,aAAS,IAAI,4BAAc;AAAA,EAC5B,WAAW,OAAO,WAAW,OAAO;AACnC,aAAS,OAAO;AAAA,EACjB;AAEA,MAAI;AACJ,MAAI,OAAO,QAAQ;A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|
|
|
1
1
|
import { type Database, type Options, type RunResult } from 'better-sqlite3';
|
|
2
2
|
import { entityKind } from "../entity.cjs";
|
|
3
|
-
import type { AnyRelations, EmptyRelations } from "../relations.cjs";
|
|
4
3
|
import { BaseSQLiteDatabase } from "../sqlite-core/db.cjs";
|
|
5
4
|
import { type DrizzleConfig } from "../utils.cjs";
|
|
6
5
|
export type DrizzleBetterSQLite3DatabaseConfig = ({
|
|
7
6
|
source?: string | Buffer;
|
|
8
7
|
} & Options) | string | undefined;
|
|
9
|
-
export declare class BetterSQLite3Database<TSchema extends Record<string, unknown> = Record<string, never
|
|
8
|
+
export declare class BetterSQLite3Database<TSchema extends Record<string, unknown> = Record<string, never>> extends BaseSQLiteDatabase<'sync', RunResult, TSchema> {
|
|
10
9
|
static readonly [entityKind]: string;
|
|
11
10
|
}
|
|
12
|
-
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never
|
|
11
|
+
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(...params: [] | [
|
|
13
12
|
Database | string
|
|
14
13
|
] | [
|
|
15
14
|
Database | string,
|
|
16
|
-
DrizzleConfig<TSchema
|
|
15
|
+
DrizzleConfig<TSchema>
|
|
17
16
|
] | [
|
|
18
|
-
(DrizzleConfig<TSchema
|
|
17
|
+
(DrizzleConfig<TSchema> & ({
|
|
19
18
|
connection?: DrizzleBetterSQLite3DatabaseConfig;
|
|
20
19
|
} | {
|
|
21
20
|
client: Database;
|
|
22
21
|
}))
|
|
23
|
-
]): BetterSQLite3Database<TSchema
|
|
22
|
+
]): BetterSQLite3Database<TSchema> & {
|
|
24
23
|
$client: Database;
|
|
25
24
|
};
|
|
26
25
|
export declare namespace drizzle {
|
|
27
|
-
function mock<TSchema extends Record<string, unknown> = Record<string, never
|
|
26
|
+
function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): BetterSQLite3Database<TSchema> & {
|
|
28
27
|
$client: '$client is not available on drizzle.mock()';
|
|
29
28
|
};
|
|
30
29
|
}
|
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import { type Database, type Options, type RunResult } from 'better-sqlite3';
|
|
2
2
|
import { entityKind } from "../entity.js";
|
|
3
|
-
import type { AnyRelations, EmptyRelations } from "../relations.js";
|
|
4
3
|
import { BaseSQLiteDatabase } from "../sqlite-core/db.js";
|
|
5
4
|
import { type DrizzleConfig } from "../utils.js";
|
|
6
5
|
export type DrizzleBetterSQLite3DatabaseConfig = ({
|
|
7
6
|
source?: string | Buffer;
|
|
8
7
|
} & Options) | string | undefined;
|
|
9
|
-
export declare class BetterSQLite3Database<TSchema extends Record<string, unknown> = Record<string, never
|
|
8
|
+
export declare class BetterSQLite3Database<TSchema extends Record<string, unknown> = Record<string, never>> extends BaseSQLiteDatabase<'sync', RunResult, TSchema> {
|
|
10
9
|
static readonly [entityKind]: string;
|
|
11
10
|
}
|
|
12
|
-
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never
|
|
11
|
+
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(...params: [] | [
|
|
13
12
|
Database | string
|
|
14
13
|
] | [
|
|
15
14
|
Database | string,
|
|
16
|
-
DrizzleConfig<TSchema
|
|
15
|
+
DrizzleConfig<TSchema>
|
|
17
16
|
] | [
|
|
18
|
-
(DrizzleConfig<TSchema
|
|
17
|
+
(DrizzleConfig<TSchema> & ({
|
|
19
18
|
connection?: DrizzleBetterSQLite3DatabaseConfig;
|
|
20
19
|
} | {
|
|
21
20
|
client: Database;
|
|
22
21
|
}))
|
|
23
|
-
]): BetterSQLite3Database<TSchema
|
|
22
|
+
]): BetterSQLite3Database<TSchema> & {
|
|
24
23
|
$client: Database;
|
|
25
24
|
};
|
|
26
25
|
export declare namespace drizzle {
|
|
27
|
-
function mock<TSchema extends Record<string, unknown> = Record<string, never
|
|
26
|
+
function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): BetterSQLite3Database<TSchema> & {
|
|
28
27
|
$client: '$client is not available on drizzle.mock()';
|
|
29
28
|
};
|
|
30
29
|
}
|
package/better-sqlite3/driver.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import Client from "better-sqlite3";
|
|
2
|
-
import * as V1 from "../_relations.js";
|
|
3
2
|
import { entityKind } from "../entity.js";
|
|
4
3
|
import { DefaultLogger } from "../logger.js";
|
|
4
|
+
import {
|
|
5
|
+
createTableRelationsHelpers,
|
|
6
|
+
extractTablesRelationalConfig
|
|
7
|
+
} from "../relations.js";
|
|
5
8
|
import { BaseSQLiteDatabase } from "../sqlite-core/db.js";
|
|
6
9
|
import { SQLiteSyncDialect } from "../sqlite-core/dialect.js";
|
|
7
10
|
import { isConfig } from "../utils.js";
|
|
@@ -19,9 +22,9 @@ function construct(client, config = {}) {
|
|
|
19
22
|
}
|
|
20
23
|
let schema;
|
|
21
24
|
if (config.schema) {
|
|
22
|
-
const tablesConfig =
|
|
25
|
+
const tablesConfig = extractTablesRelationalConfig(
|
|
23
26
|
config.schema,
|
|
24
|
-
|
|
27
|
+
createTableRelationsHelpers
|
|
25
28
|
);
|
|
26
29
|
schema = {
|
|
27
30
|
fullSchema: config.schema,
|
|
@@ -29,15 +32,8 @@ function construct(client, config = {}) {
|
|
|
29
32
|
tableNamesMap: tablesConfig.tableNamesMap
|
|
30
33
|
};
|
|
31
34
|
}
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const db = new BetterSQLite3Database(
|
|
35
|
-
"sync",
|
|
36
|
-
dialect,
|
|
37
|
-
session,
|
|
38
|
-
relations,
|
|
39
|
-
schema
|
|
40
|
-
);
|
|
35
|
+
const session = new BetterSQLiteSession(client, dialect, schema, { logger });
|
|
36
|
+
const db = new BetterSQLite3Database("sync", dialect, session, schema);
|
|
41
37
|
db.$client = client;
|
|
42
38
|
return db;
|
|
43
39
|
}
|