drizzle-orm 0.39.2-1177ad8 → 0.39.2-8628c8a
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/aws-data-api/pg/driver.cjs +1 -5
- package/aws-data-api/pg/driver.cjs.map +1 -1
- package/aws-data-api/pg/driver.d.cts +0 -1
- package/aws-data-api/pg/driver.d.ts +0 -1
- package/aws-data-api/pg/driver.js +1 -5
- package/aws-data-api/pg/driver.js.map +1 -1
- package/aws-data-api/pg/session.cjs +4 -15
- package/aws-data-api/pg/session.cjs.map +1 -1
- package/aws-data-api/pg/session.d.cts +3 -13
- package/aws-data-api/pg/session.d.ts +3 -13
- package/aws-data-api/pg/session.js +4 -15
- package/aws-data-api/pg/session.js.map +1 -1
- package/bun-sql/driver.cjs +1 -5
- package/bun-sql/driver.cjs.map +1 -1
- package/bun-sql/driver.js +1 -5
- package/bun-sql/driver.js.map +1 -1
- package/bun-sql/session.cjs +9 -21
- package/bun-sql/session.cjs.map +1 -1
- package/bun-sql/session.d.cts +3 -12
- package/bun-sql/session.d.ts +3 -12
- package/bun-sql/session.js +9 -21
- package/bun-sql/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/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/{cache/core → gel}/index.cjs +6 -4
- 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/{cache/core/cache.cjs → gel-core/columns/date.common.cjs} +12 -22
- package/gel-core/columns/date.common.cjs.map +1 -0
- package/gel-core/columns/date.common.d.cts +7 -0
- package/gel-core/columns/date.common.d.ts +7 -0
- package/gel-core/columns/date.common.js +13 -0
- package/gel-core/columns/date.common.js.map +1 -0
- package/gel-core/columns/decimal.cjs +56 -0
- package/gel-core/columns/decimal.cjs.map +1 -0
- package/gel-core/columns/decimal.d.cts +26 -0
- package/gel-core/columns/decimal.d.ts +26 -0
- package/gel-core/columns/decimal.js +30 -0
- package/gel-core/columns/decimal.js.map +1 -0
- package/gel-core/columns/double-precision.cjs +62 -0
- package/gel-core/columns/double-precision.cjs.map +1 -0
- package/gel-core/columns/double-precision.d.cts +23 -0
- package/gel-core/columns/double-precision.d.ts +23 -0
- package/gel-core/columns/double-precision.js +36 -0
- package/gel-core/columns/double-precision.js.map +1 -0
- package/gel-core/columns/duration.cjs +53 -0
- package/gel-core/columns/duration.cjs.map +1 -0
- package/gel-core/columns/duration.d.cts +23 -0
- package/gel-core/columns/duration.d.ts +23 -0
- package/gel-core/columns/duration.js +27 -0
- package/gel-core/columns/duration.js.map +1 -0
- package/gel-core/columns/index.cjs +65 -0
- package/gel-core/columns/index.cjs.map +1 -0
- package/gel-core/columns/index.d.cts +22 -0
- package/gel-core/columns/index.d.ts +22 -0
- package/gel-core/columns/index.js +23 -0
- package/gel-core/columns/index.js.map +1 -0
- package/gel-core/columns/int.common.cjs +67 -0
- package/gel-core/columns/int.common.cjs.map +1 -0
- package/gel-core/columns/int.common.d.cts +15 -0
- package/gel-core/columns/int.common.d.ts +15 -0
- package/gel-core/columns/int.common.js +43 -0
- package/gel-core/columns/int.common.js.map +1 -0
- package/gel-core/columns/integer.cjs +54 -0
- package/gel-core/columns/integer.cjs.map +1 -0
- package/gel-core/columns/integer.d.cts +23 -0
- package/gel-core/columns/integer.d.ts +23 -0
- package/gel-core/columns/integer.js +28 -0
- package/gel-core/columns/integer.js.map +1 -0
- package/gel-core/columns/json.cjs +56 -0
- package/gel-core/columns/json.cjs.map +1 -0
- package/gel-core/columns/json.d.cts +26 -0
- package/gel-core/columns/json.d.ts +26 -0
- package/gel-core/columns/json.js +30 -0
- package/gel-core/columns/json.js.map +1 -0
- package/gel-core/columns/localdate.cjs +57 -0
- package/gel-core/columns/localdate.cjs.map +1 -0
- package/gel-core/columns/localdate.d.cts +24 -0
- package/gel-core/columns/localdate.d.ts +24 -0
- package/gel-core/columns/localdate.js +31 -0
- package/gel-core/columns/localdate.js.map +1 -0
- package/gel-core/columns/localtime.cjs +57 -0
- package/gel-core/columns/localtime.cjs.map +1 -0
- package/gel-core/columns/localtime.d.cts +24 -0
- package/gel-core/columns/localtime.d.ts +24 -0
- package/gel-core/columns/localtime.js +31 -0
- package/gel-core/columns/localtime.js.map +1 -0
- package/gel-core/columns/real.cjs +57 -0
- package/gel-core/columns/real.cjs.map +1 -0
- package/gel-core/columns/real.d.cts +28 -0
- package/gel-core/columns/real.d.ts +28 -0
- package/gel-core/columns/real.js +31 -0
- package/gel-core/columns/real.js.map +1 -0
- package/gel-core/columns/relative-duration.cjs +56 -0
- package/gel-core/columns/relative-duration.cjs.map +1 -0
- package/gel-core/columns/relative-duration.d.cts +23 -0
- package/gel-core/columns/relative-duration.d.ts +23 -0
- package/gel-core/columns/relative-duration.js +30 -0
- package/gel-core/columns/relative-duration.js.map +1 -0
- package/gel-core/columns/smallint.cjs +54 -0
- package/gel-core/columns/smallint.cjs.map +1 -0
- package/gel-core/columns/smallint.d.cts +23 -0
- package/gel-core/columns/smallint.d.ts +23 -0
- package/gel-core/columns/smallint.js +28 -0
- package/gel-core/columns/smallint.js.map +1 -0
- package/gel-core/columns/text.cjs +54 -0
- package/gel-core/columns/text.cjs.map +1 -0
- package/gel-core/columns/text.d.cts +26 -0
- package/gel-core/columns/text.d.ts +26 -0
- package/gel-core/columns/text.js +28 -0
- package/gel-core/columns/text.js.map +1 -0
- package/gel-core/columns/timestamp.cjs +60 -0
- package/gel-core/columns/timestamp.cjs.map +1 -0
- package/gel-core/columns/timestamp.d.cts +28 -0
- package/gel-core/columns/timestamp.d.ts +28 -0
- package/gel-core/columns/timestamp.js +34 -0
- package/gel-core/columns/timestamp.js.map +1 -0
- package/gel-core/columns/timestamptz.cjs +60 -0
- package/gel-core/columns/timestamptz.cjs.map +1 -0
- package/gel-core/columns/timestamptz.d.cts +27 -0
- package/gel-core/columns/timestamptz.d.ts +27 -0
- package/gel-core/columns/timestamptz.js +34 -0
- package/gel-core/columns/timestamptz.js.map +1 -0
- package/gel-core/columns/uuid.cjs +53 -0
- package/gel-core/columns/uuid.cjs.map +1 -0
- package/gel-core/columns/uuid.d.cts +22 -0
- package/gel-core/columns/uuid.d.ts +22 -0
- package/gel-core/columns/uuid.js +27 -0
- package/gel-core/columns/uuid.js.map +1 -0
- package/gel-core/db.cjs +338 -0
- package/gel-core/db.cjs.map +1 -0
- package/gel-core/db.d.cts +281 -0
- package/gel-core/db.d.ts +281 -0
- package/gel-core/db.js +319 -0
- package/gel-core/db.js.map +1 -0
- package/gel-core/dialect.cjs +1142 -0
- package/gel-core/dialect.cjs.map +1 -0
- package/gel-core/dialect.d.cts +62 -0
- package/gel-core/dialect.d.ts +62 -0
- package/gel-core/dialect.js +1128 -0
- package/gel-core/dialect.js.map +1 -0
- package/gel-core/expressions.cjs +49 -0
- package/gel-core/expressions.cjs.map +1 -0
- package/gel-core/expressions.d.cts +8 -0
- package/gel-core/expressions.d.ts +8 -0
- package/gel-core/expressions.js +22 -0
- package/gel-core/expressions.js.map +1 -0
- package/gel-core/foreign-keys.cjs +100 -0
- package/gel-core/foreign-keys.cjs.map +1 -0
- package/gel-core/foreign-keys.d.cts +48 -0
- package/gel-core/foreign-keys.d.ts +48 -0
- package/gel-core/foreign-keys.js +74 -0
- package/gel-core/foreign-keys.js.map +1 -0
- package/gel-core/index.cjs +61 -0
- package/gel-core/index.cjs.map +1 -0
- package/gel-core/index.d.cts +20 -0
- package/gel-core/index.d.ts +20 -0
- package/gel-core/index.js +21 -0
- package/gel-core/index.js.map +1 -0
- package/gel-core/indexes.cjs +149 -0
- package/gel-core/indexes.cjs.map +1 -0
- package/gel-core/indexes.d.cts +79 -0
- package/gel-core/indexes.d.ts +79 -0
- package/gel-core/indexes.js +121 -0
- package/gel-core/indexes.js.map +1 -0
- package/gel-core/policies.cjs +58 -0
- package/gel-core/policies.cjs.map +1 -0
- package/gel-core/policies.d.cts +24 -0
- package/gel-core/policies.d.ts +24 -0
- package/gel-core/policies.js +33 -0
- package/gel-core/policies.js.map +1 -0
- package/gel-core/primary-keys.cjs +68 -0
- package/gel-core/primary-keys.cjs.map +1 -0
- package/gel-core/primary-keys.d.cts +30 -0
- package/gel-core/primary-keys.d.ts +30 -0
- package/gel-core/primary-keys.js +42 -0
- package/gel-core/primary-keys.js.map +1 -0
- package/gel-core/query-builders/count.cjs +73 -0
- package/gel-core/query-builders/count.cjs.map +1 -0
- package/gel-core/query-builders/count.d.cts +25 -0
- package/gel-core/query-builders/count.d.ts +25 -0
- package/gel-core/query-builders/count.js +49 -0
- package/gel-core/query-builders/count.js.map +1 -0
- package/gel-core/query-builders/delete.cjs +105 -0
- package/gel-core/query-builders/delete.cjs.map +1 -0
- package/gel-core/query-builders/delete.d.cts +99 -0
- package/gel-core/query-builders/delete.d.ts +99 -0
- package/gel-core/query-builders/delete.js +81 -0
- package/gel-core/query-builders/delete.js.map +1 -0
- package/gel-core/query-builders/index.cjs +35 -0
- package/gel-core/query-builders/index.cjs.map +1 -0
- package/gel-core/query-builders/index.d.cts +7 -0
- package/gel-core/query-builders/index.d.ts +7 -0
- package/gel-core/query-builders/index.js +8 -0
- package/gel-core/query-builders/index.js.map +1 -0
- package/gel-core/query-builders/insert.cjs +218 -0
- package/gel-core/query-builders/insert.cjs.map +1 -0
- package/gel-core/query-builders/insert.d.cts +116 -0
- package/gel-core/query-builders/insert.d.ts +116 -0
- package/gel-core/query-builders/insert.js +193 -0
- package/gel-core/query-builders/insert.js.map +1 -0
- package/gel-core/query-builders/query-builder.cjs +114 -0
- package/gel-core/query-builders/query-builder.cjs.map +1 -0
- package/gel-core/query-builders/query-builder.d.cts +40 -0
- package/gel-core/query-builders/query-builder.d.ts +40 -0
- package/gel-core/query-builders/query-builder.js +90 -0
- package/gel-core/query-builders/query-builder.js.map +1 -0
- package/gel-core/query-builders/query.cjs +139 -0
- package/gel-core/query-builders/query.cjs.map +1 -0
- package/gel-core/query-builders/query.d.cts +46 -0
- package/gel-core/query-builders/query.d.ts +46 -0
- package/gel-core/query-builders/query.js +116 -0
- package/gel-core/query-builders/query.js.map +1 -0
- package/gel-core/query-builders/raw.cjs +57 -0
- package/gel-core/query-builders/raw.cjs.map +1 -0
- package/gel-core/query-builders/raw.d.cts +22 -0
- package/gel-core/query-builders/raw.d.ts +22 -0
- package/gel-core/query-builders/raw.js +33 -0
- package/gel-core/query-builders/raw.js.map +1 -0
- package/gel-core/query-builders/refresh-materialized-view.cjs +77 -0
- package/gel-core/query-builders/refresh-materialized-view.cjs.map +1 -0
- package/gel-core/query-builders/refresh-materialized-view.d.cts +27 -0
- package/gel-core/query-builders/refresh-materialized-view.d.ts +27 -0
- package/gel-core/query-builders/refresh-materialized-view.js +53 -0
- package/gel-core/query-builders/refresh-materialized-view.js.map +1 -0
- package/gel-core/query-builders/select.cjs +775 -0
- package/gel-core/query-builders/select.cjs.map +1 -0
- package/gel-core/query-builders/select.d.cts +721 -0
- package/gel-core/query-builders/select.d.ts +721 -0
- package/gel-core/query-builders/select.js +748 -0
- package/gel-core/query-builders/select.js.map +1 -0
- package/gel-core/query-builders/select.types.cjs +17 -0
- package/gel-core/query-builders/select.types.cjs.map +1 -0
- package/gel-core/query-builders/select.types.d.cts +138 -0
- package/gel-core/query-builders/select.types.d.ts +138 -0
- package/gel-core/query-builders/select.types.js +1 -0
- package/gel-core/query-builders/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/{cache/core/types.cjs → gel-core/subquery.cjs} +3 -3
- 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/{cache/upstash/index.cjs → gel-core/view-common.cjs} +12 -6
- 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/neon-http/driver.cjs +2 -9
- package/neon-http/driver.cjs.map +1 -1
- package/neon-http/driver.d.cts +0 -2
- package/neon-http/driver.d.ts +0 -2
- package/neon-http/driver.js +2 -9
- package/neon-http/driver.js.map +1 -1
- package/neon-http/session.cjs +15 -25
- package/neon-http/session.cjs.map +1 -1
- package/neon-http/session.d.cts +3 -12
- package/neon-http/session.d.ts +3 -12
- package/neon-http/session.js +15 -25
- package/neon-http/session.js.map +1 -1
- package/neon-serverless/driver.cjs +2 -9
- package/neon-serverless/driver.cjs.map +1 -1
- package/neon-serverless/driver.d.cts +0 -2
- package/neon-serverless/driver.d.ts +0 -2
- package/neon-serverless/driver.js +2 -9
- package/neon-serverless/driver.js.map +1 -1
- package/neon-serverless/session.cjs +7 -21
- package/neon-serverless/session.cjs.map +1 -1
- package/neon-serverless/session.d.cts +3 -12
- package/neon-serverless/session.d.ts +3 -12
- package/neon-serverless/session.js +7 -21
- package/neon-serverless/session.js.map +1 -1
- package/node-postgres/driver.cjs +2 -9
- package/node-postgres/driver.cjs.map +1 -1
- package/node-postgres/driver.d.cts +0 -2
- package/node-postgres/driver.d.ts +0 -2
- package/node-postgres/driver.js +2 -9
- package/node-postgres/driver.js.map +1 -1
- package/node-postgres/session.cjs +6 -19
- package/node-postgres/session.cjs.map +1 -1
- package/node-postgres/session.d.cts +3 -13
- package/node-postgres/session.d.ts +3 -13
- package/node-postgres/session.js +6 -19
- package/node-postgres/session.js.map +1 -1
- package/package.json +1036 -364
- package/pg-core/db.cjs +0 -1
- package/pg-core/db.cjs.map +1 -1
- package/pg-core/db.d.cts +0 -4
- package/pg-core/db.d.ts +0 -4
- package/pg-core/db.js +0 -1
- package/pg-core/db.js.map +1 -1
- package/pg-core/query-builders/delete.cjs +1 -6
- package/pg-core/query-builders/delete.cjs.map +1 -1
- package/pg-core/query-builders/delete.d.cts +1 -2
- package/pg-core/query-builders/delete.d.ts +1 -2
- package/pg-core/query-builders/delete.js +1 -6
- package/pg-core/query-builders/delete.js.map +1 -1
- package/pg-core/query-builders/insert.cjs +1 -6
- package/pg-core/query-builders/insert.cjs.map +1 -1
- package/pg-core/query-builders/insert.d.cts +1 -2
- package/pg-core/query-builders/insert.d.ts +1 -2
- package/pg-core/query-builders/insert.js +1 -6
- package/pg-core/query-builders/insert.js.map +1 -1
- package/pg-core/query-builders/select.cjs +5 -31
- package/pg-core/query-builders/select.cjs.map +1 -1
- package/pg-core/query-builders/select.d.cts +2 -11
- package/pg-core/query-builders/select.d.ts +2 -11
- package/pg-core/query-builders/select.js +5 -31
- package/pg-core/query-builders/select.js.map +1 -1
- package/pg-core/query-builders/select.types.cjs.map +1 -1
- package/pg-core/query-builders/select.types.d.cts +0 -7
- package/pg-core/query-builders/select.types.d.ts +0 -7
- package/pg-core/query-builders/update.cjs +1 -6
- package/pg-core/query-builders/update.cjs.map +1 -1
- package/pg-core/query-builders/update.d.cts +3 -4
- package/pg-core/query-builders/update.d.ts +3 -4
- package/pg-core/query-builders/update.js +1 -6
- package/pg-core/query-builders/update.js.map +1 -1
- package/pg-core/session.cjs +1 -53
- package/pg-core/session.cjs.map +1 -1
- package/pg-core/session.d.cts +3 -14
- package/pg-core/session.d.ts +3 -14
- package/pg-core/session.js +2 -54
- 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-core/utils.cjs +0 -16
- package/pg-core/utils.cjs.map +1 -1
- package/pg-core/utils.d.cts +4 -8
- package/pg-core/utils.d.ts +4 -8
- package/pg-core/utils.js +1 -16
- package/pg-core/utils.js.map +1 -1
- package/pg-proxy/driver.cjs +2 -7
- package/pg-proxy/driver.cjs.map +1 -1
- package/pg-proxy/driver.js +2 -7
- package/pg-proxy/driver.js.map +1 -1
- package/pg-proxy/session.cjs +5 -15
- package/pg-proxy/session.cjs.map +1 -1
- package/pg-proxy/session.d.cts +3 -12
- package/pg-proxy/session.d.ts +3 -12
- package/pg-proxy/session.js +5 -15
- package/pg-proxy/session.js.map +1 -1
- package/pglite/driver.cjs +2 -9
- package/pglite/driver.cjs.map +1 -1
- package/pglite/driver.d.cts +0 -2
- package/pglite/driver.d.ts +0 -2
- package/pglite/driver.js +2 -9
- package/pglite/driver.js.map +1 -1
- package/pglite/session.cjs +7 -19
- package/pglite/session.cjs.map +1 -1
- package/pglite/session.d.cts +3 -12
- package/pglite/session.d.ts +3 -12
- package/pglite/session.js +7 -19
- package/pglite/session.js.map +1 -1
- package/postgres-js/driver.cjs +1 -5
- package/postgres-js/driver.cjs.map +1 -1
- package/postgres-js/driver.js +1 -5
- package/postgres-js/driver.js.map +1 -1
- package/postgres-js/session.cjs +6 -18
- package/postgres-js/session.cjs.map +1 -1
- package/postgres-js/session.d.cts +3 -12
- package/postgres-js/session.d.ts +3 -12
- package/postgres-js/session.js +6 -18
- package/postgres-js/session.js.map +1 -1
- package/prisma/pg/session.cjs +1 -1
- package/prisma/pg/session.cjs.map +1 -1
- package/prisma/pg/session.js +1 -1
- package/prisma/pg/session.js.map +1 -1
- package/query-builders/query-builder.cjs.map +1 -1
- package/query-builders/query-builder.d.cts +1 -2
- package/query-builders/query-builder.d.ts +1 -2
- package/query-builders/query-builder.js.map +1 -1
- package/sql/sql.cjs +0 -7
- package/sql/sql.cjs.map +1 -1
- package/sql/sql.js +0 -7
- package/sql/sql.js.map +1 -1
- package/subquery.cjs +3 -4
- package/subquery.cjs.map +1 -1
- package/subquery.d.cts +1 -2
- package/subquery.d.ts +1 -2
- package/subquery.js +3 -4
- package/subquery.js.map +1 -1
- package/table.cjs.map +1 -1
- package/table.js.map +1 -1
- package/utils.cjs.map +1 -1
- package/utils.d.cts +0 -2
- package/utils.d.ts +0 -2
- package/utils.js.map +1 -1
- package/vercel-postgres/driver.cjs +2 -9
- package/vercel-postgres/driver.cjs.map +1 -1
- package/vercel-postgres/driver.d.cts +0 -2
- package/vercel-postgres/driver.d.ts +0 -2
- package/vercel-postgres/driver.js +2 -9
- package/vercel-postgres/driver.js.map +1 -1
- package/vercel-postgres/session.cjs +7 -21
- package/vercel-postgres/session.cjs.map +1 -1
- package/vercel-postgres/session.d.cts +3 -12
- package/vercel-postgres/session.d.ts +3 -12
- package/vercel-postgres/session.js +7 -21
- 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 +2 -7
- package/xata-http/driver.cjs.map +1 -1
- package/xata-http/driver.d.cts +0 -2
- package/xata-http/driver.d.ts +0 -2
- package/xata-http/driver.js +2 -7
- package/xata-http/driver.js.map +1 -1
- package/xata-http/session.cjs +7 -21
- package/xata-http/session.cjs.map +1 -1
- package/xata-http/session.d.cts +3 -12
- package/xata-http/session.d.ts +3 -12
- package/xata-http/session.js +7 -21
- package/xata-http/session.js.map +1 -1
- package/cache/core/cache.cjs.map +0 -1
- package/cache/core/cache.d.cts +0 -35
- package/cache/core/cache.d.ts +0 -35
- package/cache/core/cache.js +0 -22
- package/cache/core/cache.js.map +0 -1
- package/cache/core/index.cjs.map +0 -1
- package/cache/core/index.d.cts +0 -1
- package/cache/core/index.d.ts +0 -1
- package/cache/core/index.js +0 -2
- package/cache/core/index.js.map +0 -1
- package/cache/core/types.cjs.map +0 -1
- package/cache/core/types.d.cts +0 -22
- package/cache/core/types.d.ts +0 -22
- package/cache/core/types.js +0 -1
- package/cache/upstash/cache.cjs +0 -98
- package/cache/upstash/cache.cjs.map +0 -1
- package/cache/upstash/cache.d.cts +0 -23
- package/cache/upstash/cache.d.ts +0 -23
- package/cache/upstash/cache.js +0 -73
- package/cache/upstash/cache.js.map +0 -1
- package/cache/upstash/index.cjs.map +0 -1
- package/cache/upstash/index.d.cts +0 -1
- package/cache/upstash/index.d.ts +0 -1
- package/cache/upstash/index.js +0 -2
- package/cache/upstash/index.js.map +0 -1
- /package/{cache/core/types.js.map → gel-core/query-builders/select.types.js.map} +0 -0
package/utils.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Cache } from "./cache/core/cache.js";
|
|
2
1
|
import type { AnyColumn } from "./column.js";
|
|
3
2
|
import type { Logger } from "./logger.js";
|
|
4
3
|
import { Param, SQL, View } from "./sql/sql.js";
|
|
@@ -42,7 +41,6 @@ export interface DrizzleConfig<TSchema extends Record<string, unknown> = Record<
|
|
|
42
41
|
logger?: boolean | Logger;
|
|
43
42
|
schema?: TSchema;
|
|
44
43
|
casing?: Casing;
|
|
45
|
-
cache?: Cache;
|
|
46
44
|
}
|
|
47
45
|
export type ValidateShape<T, ValidShape, TResult = T> = T extends ValidShape ? Exclude<keyof T, keyof ValidShape> extends never ? TResult : DrizzleTypeError<`Invalid key(s): ${Exclude<(keyof T) & (string | number | bigint | boolean | null | undefined), keyof ValidShape>}`> : never;
|
|
48
46
|
export type KnownKeysOnly<T, U> = {
|
package/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils.ts"],"sourcesContent":["import type { Cache } from './cache/core/cache.ts';\nimport type { AnyColumn } from './column.ts';\nimport { Column } from './column.ts';\nimport { is } from './entity.ts';\nimport type { Logger } from './logger.ts';\nimport type { SelectedFieldsOrdered } from './operations.ts';\nimport type { TableLike } from './query-builders/select.types.ts';\nimport { Param, SQL, View } from './sql/sql.ts';\nimport type { DriverValueDecoder } from './sql/sql.ts';\nimport { Subquery } from './subquery.ts';\nimport { getTableName, Table } from './table.ts';\nimport { ViewBaseConfig } from './view-common.ts';\n\n/** @internal */\nexport function mapResultRow<TResult>(\n\tcolumns: SelectedFieldsOrdered<AnyColumn>,\n\trow: unknown[],\n\tjoinsNotNullableMap: Record<string, boolean> | undefined,\n): TResult {\n\t// Key -> nested object key, value -> table name if all fields in the nested object are from the same table, false otherwise\n\tconst nullifyMap: Record<string, string | false> = {};\n\n\tconst result = columns.reduce<Record<string, any>>(\n\t\t(result, { path, field }, columnIndex) => {\n\t\t\tlet decoder: DriverValueDecoder<unknown, unknown>;\n\t\t\tif (is(field, Column)) {\n\t\t\t\tdecoder = field;\n\t\t\t} else if (is(field, SQL)) {\n\t\t\t\tdecoder = field.decoder;\n\t\t\t} else {\n\t\t\t\tdecoder = field.sql.decoder;\n\t\t\t}\n\t\t\tlet node = result;\n\t\t\tfor (const [pathChunkIndex, pathChunk] of path.entries()) {\n\t\t\t\tif (pathChunkIndex < path.length - 1) {\n\t\t\t\t\tif (!(pathChunk in node)) {\n\t\t\t\t\t\tnode[pathChunk] = {};\n\t\t\t\t\t}\n\t\t\t\t\tnode = node[pathChunk];\n\t\t\t\t} else {\n\t\t\t\t\tconst rawValue = row[columnIndex]!;\n\t\t\t\t\tconst value = node[pathChunk] = rawValue === null ? null : decoder.mapFromDriverValue(rawValue);\n\n\t\t\t\t\tif (joinsNotNullableMap && is(field, Column) && path.length === 2) {\n\t\t\t\t\t\tconst objectName = path[0]!;\n\t\t\t\t\t\tif (!(objectName in nullifyMap)) {\n\t\t\t\t\t\t\tnullifyMap[objectName] = value === null ? getTableName(field.table) : false;\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\ttypeof nullifyMap[objectName] === 'string' && nullifyMap[objectName] !== getTableName(field.table)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnullifyMap[objectName] = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn result;\n\t\t},\n\t\t{},\n\t);\n\n\t// Nullify all nested objects from nullifyMap that are nullable\n\tif (joinsNotNullableMap && Object.keys(nullifyMap).length > 0) {\n\t\tfor (const [objectName, tableName] of Object.entries(nullifyMap)) {\n\t\t\tif (typeof tableName === 'string' && !joinsNotNullableMap[tableName]) {\n\t\t\t\tresult[objectName] = null;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result as TResult;\n}\n\n/** @internal */\nexport function orderSelectedFields<TColumn extends AnyColumn>(\n\tfields: Record<string, unknown>,\n\tpathPrefix?: string[],\n): SelectedFieldsOrdered<TColumn> {\n\treturn Object.entries(fields).reduce<SelectedFieldsOrdered<AnyColumn>>((result, [name, field]) => {\n\t\tif (typeof name !== 'string') {\n\t\t\treturn result;\n\t\t}\n\n\t\tconst newPath = pathPrefix ? [...pathPrefix, name] : [name];\n\t\tif (is(field, Column) || is(field, SQL) || is(field, SQL.Aliased)) {\n\t\t\tresult.push({ path: newPath, field });\n\t\t} else if (is(field, Table)) {\n\t\t\tresult.push(...orderSelectedFields(field[Table.Symbol.Columns], newPath));\n\t\t} else {\n\t\t\tresult.push(...orderSelectedFields(field as Record<string, unknown>, newPath));\n\t\t}\n\t\treturn result;\n\t}, []) as SelectedFieldsOrdered<TColumn>;\n}\n\nexport function haveSameKeys(left: Record<string, unknown>, right: Record<string, unknown>) {\n\tconst leftKeys = Object.keys(left);\n\tconst rightKeys = Object.keys(right);\n\n\tif (leftKeys.length !== rightKeys.length) {\n\t\treturn false;\n\t}\n\n\tfor (const [index, key] of leftKeys.entries()) {\n\t\tif (key !== rightKeys[index]) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/** @internal */\nexport function mapUpdateSet(table: Table, values: Record<string, unknown>): UpdateSet {\n\tconst entries: [string, UpdateSet[string]][] = Object.entries(values)\n\t\t.filter(([, value]) => value !== undefined)\n\t\t.map(([key, value]) => {\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (is(value, SQL) || is(value, Column)) {\n\t\t\t\treturn [key, value];\n\t\t\t} else {\n\t\t\t\treturn [key, new Param(value, table[Table.Symbol.Columns][key])];\n\t\t\t}\n\t\t});\n\n\tif (entries.length === 0) {\n\t\tthrow new Error('No values to set');\n\t}\n\n\treturn Object.fromEntries(entries);\n}\n\nexport type UpdateSet = Record<string, SQL | Param | AnyColumn | null | undefined>;\n\nexport type OneOrMany<T> = T | T[];\n\nexport type Update<T, TUpdate> =\n\t& {\n\t\t[K in Exclude<keyof T, keyof TUpdate>]: T[K];\n\t}\n\t& TUpdate;\n\nexport type Simplify<T> =\n\t& {\n\t\t// @ts-ignore - \"Type parameter 'K' has a circular constraint\", not sure why\n\t\t[K in keyof T]: T[K];\n\t}\n\t& {};\n\nexport type SimplifyMappedType<T> = [T] extends [unknown] ? T : never;\n\nexport type ShallowRecord<K extends keyof any, T> = SimplifyMappedType<{ [P in K]: T }>;\n\nexport type Assume<T, U> = T extends U ? T : U;\n\nexport type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;\n\nexport interface DrizzleTypeError<T extends string> {\n\t$drizzleTypeError: T;\n}\n\nexport type ValueOrArray<T> = T | T[];\n\n/** @internal */\nexport function applyMixins(baseClass: any, extendedClasses: any[]) {\n\tfor (const extendedClass of extendedClasses) {\n\t\tfor (const name of Object.getOwnPropertyNames(extendedClass.prototype)) {\n\t\t\tif (name === 'constructor') continue;\n\n\t\t\tObject.defineProperty(\n\t\t\t\tbaseClass.prototype,\n\t\t\t\tname,\n\t\t\t\tObject.getOwnPropertyDescriptor(extendedClass.prototype, name) || Object.create(null),\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport type Or<T1, T2> = T1 extends true ? true : T2 extends true ? true : false;\n\nexport type IfThenElse<If, Then, Else> = If extends true ? Then : Else;\n\nexport type PromiseOf<T> = T extends Promise<infer U> ? U : T;\n\nexport type Writable<T> = {\n\t-readonly [P in keyof T]: T[P];\n};\n\nexport function getTableColumns<T extends Table>(table: T): T['_']['columns'] {\n\treturn table[Table.Symbol.Columns];\n}\n\nexport function getViewSelectedFields<T extends View>(view: T): T['_']['selectedFields'] {\n\treturn view[ViewBaseConfig].selectedFields;\n}\n\n/** @internal */\nexport function getTableLikeName(table: TableLike): string | undefined {\n\treturn is(table, Subquery)\n\t\t? table._.alias\n\t\t: is(table, View)\n\t\t? table[ViewBaseConfig].name\n\t\t: is(table, SQL)\n\t\t? undefined\n\t\t: table[Table.Symbol.IsAlias]\n\t\t? table[Table.Symbol.Name]\n\t\t: table[Table.Symbol.BaseName];\n}\n\nexport type ColumnsWithTable<\n\tTTableName extends string,\n\tTForeignTableName extends string,\n\tTColumns extends AnyColumn<{ tableName: TTableName }>[],\n> = { [Key in keyof TColumns]: AnyColumn<{ tableName: TForeignTableName }> };\n\nexport type Casing = 'snake_case' | 'camelCase';\n\nexport interface DrizzleConfig<TSchema extends Record<string, unknown> = Record<string, never>> {\n\tlogger?: boolean | Logger;\n\tschema?: TSchema;\n\tcasing?: Casing;\n\tcache?: Cache;\n}\nexport type ValidateShape<T, ValidShape, TResult = T> = T extends ValidShape\n\t? Exclude<keyof T, keyof ValidShape> extends never ? TResult\n\t: DrizzleTypeError<\n\t\t`Invalid key(s): ${Exclude<(keyof T) & (string | number | bigint | boolean | null | undefined), keyof ValidShape>}`\n\t>\n\t: never;\n\nexport type KnownKeysOnly<T, U> = {\n\t[K in keyof T]: K extends keyof U ? T[K] : never;\n};\n\nexport type IsAny<T> = 0 extends (1 & T) ? true : false;\n\n/** @internal */\nexport function getColumnNameAndConfig<\n\tTConfig extends Record<string, any> | undefined,\n>(a: string | TConfig | undefined, b: TConfig | undefined) {\n\treturn {\n\t\tname: typeof a === 'string' && a.length > 0 ? a : '' as string,\n\t\tconfig: typeof a === 'object' ? a : b as TConfig,\n\t};\n}\n\nexport type IfNotImported<T, Y, N> = unknown extends T ? Y : N;\n\nexport type ImportTypeError<TPackageName extends string> =\n\t`Please install \\`${TPackageName}\\` to allow Drizzle ORM to connect to the database`;\n\nexport type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Keys extends any\n\t? Required<Pick<T, Keys>> & Partial<Omit<T, Keys>>\n\t: never;\n\ntype ExpectedConfigShape = {\n\tlogger?: boolean | {\n\t\tlogQuery(query: string, params: unknown[]): void;\n\t};\n\tschema?: Record<string, never>;\n\tcasing?: 'snake_case' | 'camelCase';\n};\n\n// If this errors, you must update config shape checker function with new config specs\nconst _: DrizzleConfig = {} as ExpectedConfigShape;\nconst __: ExpectedConfigShape = {} as DrizzleConfig;\n\nexport function isConfig(data: any): boolean {\n\tif (typeof data !== 'object' || data === null) return false;\n\n\tif (data.constructor.name !== 'Object') return false;\n\n\tif ('logger' in data) {\n\t\tconst type = typeof data['logger'];\n\t\tif (\n\t\t\ttype !== 'boolean' && (type !== 'object' || typeof data['logger']['logQuery'] !== 'function')\n\t\t\t&& type !== 'undefined'\n\t\t) return false;\n\n\t\treturn true;\n\t}\n\n\tif ('schema' in data) {\n\t\tconst type = typeof data['logger'];\n\t\tif (type !== 'object' && type !== 'undefined') return false;\n\n\t\treturn true;\n\t}\n\n\tif ('casing' in data) {\n\t\tconst type = typeof data['logger'];\n\t\tif (type !== 'string' && type !== 'undefined') return false;\n\n\t\treturn true;\n\t}\n\n\tif ('mode' in data) {\n\t\tif (data['mode'] !== 'default' || data['mode'] !== 'planetscale' || data['mode'] !== undefined) return false;\n\n\t\treturn true;\n\t}\n\n\tif ('connection' in data) {\n\t\tconst type = typeof data['connection'];\n\t\tif (type !== 'string' && type !== 'object' && type !== 'undefined') return false;\n\n\t\treturn true;\n\t}\n\n\tif ('client' in data) {\n\t\tconst type = typeof data['client'];\n\t\tif (type !== 'object' && type !== 'function' && type !== 'undefined') return false;\n\n\t\treturn true;\n\t}\n\n\tif (Object.keys(data).length === 0) return true;\n\n\treturn false;\n}\n\nexport type NeonAuthToken = string | (() => string | Promise<string>);\n"],"mappings":"AAEA,SAAS,cAAc;AACvB,SAAS,UAAU;AAInB,SAAS,OAAO,KAAK,YAAY;AAEjC,SAAS,gBAAgB;AACzB,SAAS,cAAc,aAAa;AACpC,SAAS,sBAAsB;AAGxB,SAAS,aACf,SACA,KACA,qBACU;AAEV,QAAM,aAA6C,CAAC;AAEpD,QAAM,SAAS,QAAQ;AAAA,IACtB,CAACA,SAAQ,EAAE,MAAM,MAAM,GAAG,gBAAgB;AACzC,UAAI;AACJ,UAAI,GAAG,OAAO,MAAM,GAAG;AACtB,kBAAU;AAAA,MACX,WAAW,GAAG,OAAO,GAAG,GAAG;AAC1B,kBAAU,MAAM;AAAA,MACjB,OAAO;AACN,kBAAU,MAAM,IAAI;AAAA,MACrB;AACA,UAAI,OAAOA;AACX,iBAAW,CAAC,gBAAgB,SAAS,KAAK,KAAK,QAAQ,GAAG;AACzD,YAAI,iB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AO,KAAK,QAAQ;AACjC,QAAI,SAAS,YAAY,SAAS;AAAa,aAAO;AAEtD,WAAO;AAAA,EACR;AAEA,MAAI,UAAU,MAAM;AACnB,QAAI,KAAK,MAAM,MAAM,aAAa,KAAK,MAAM,MAAM,iBAAiB,KAAK,MAAM,MAAM;AAAW,aAAO;AAEvG,WAAO;AAAA,EACR;AAEA,MAAI,gBAAgB,MAAM;AACzB,UAAM,OAAO,OAAO,KAAK,YAAY;AACrC,QAAI,SAAS,YAAY,SAAS,YAAY,SAAS;AAAa,aAAO;AAE3E,WAAO;AAAA,EACR;AAEA,MAAI,YAAY,MAAM;AACrB,UAAM,OAAO,OAAO,KAAK,QAAQ;AACjC,QAAI,SAAS,YAAY,SAAS,cAAc,SAAS;AAAa,aAAO;AAE7E,WAAO;AAAA,EACR;AAEA,MAAI,OAAO,KAAK,IAAI,EAAE,WAAW;AAAG,WAAO;AAE3C,SAAO;AACR;","names":["result"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils.ts"],"sourcesContent":["import type { AnyColumn } from './column.ts';\nimport { Column } from './column.ts';\nimport { is } from './entity.ts';\nimport type { Logger } from './logger.ts';\nimport type { SelectedFieldsOrdered } from './operations.ts';\nimport type { TableLike } from './query-builders/select.types.ts';\nimport { Param, SQL, View } from './sql/sql.ts';\nimport type { DriverValueDecoder } from './sql/sql.ts';\nimport { Subquery } from './subquery.ts';\nimport { getTableName, Table } from './table.ts';\nimport { ViewBaseConfig } from './view-common.ts';\n\n/** @internal */\nexport function mapResultRow<TResult>(\n\tcolumns: SelectedFieldsOrdered<AnyColumn>,\n\trow: unknown[],\n\tjoinsNotNullableMap: Record<string, boolean> | undefined,\n): TResult {\n\t// Key -> nested object key, value -> table name if all fields in the nested object are from the same table, false otherwise\n\tconst nullifyMap: Record<string, string | false> = {};\n\n\tconst result = columns.reduce<Record<string, any>>(\n\t\t(result, { path, field }, columnIndex) => {\n\t\t\tlet decoder: DriverValueDecoder<unknown, unknown>;\n\t\t\tif (is(field, Column)) {\n\t\t\t\tdecoder = field;\n\t\t\t} else if (is(field, SQL)) {\n\t\t\t\tdecoder = field.decoder;\n\t\t\t} else {\n\t\t\t\tdecoder = field.sql.decoder;\n\t\t\t}\n\t\t\tlet node = result;\n\t\t\tfor (const [pathChunkIndex, pathChunk] of path.entries()) {\n\t\t\t\tif (pathChunkIndex < path.length - 1) {\n\t\t\t\t\tif (!(pathChunk in node)) {\n\t\t\t\t\t\tnode[pathChunk] = {};\n\t\t\t\t\t}\n\t\t\t\t\tnode = node[pathChunk];\n\t\t\t\t} else {\n\t\t\t\t\tconst rawValue = row[columnIndex]!;\n\t\t\t\t\tconst value = node[pathChunk] = rawValue === null ? null : decoder.mapFromDriverValue(rawValue);\n\n\t\t\t\t\tif (joinsNotNullableMap && is(field, Column) && path.length === 2) {\n\t\t\t\t\t\tconst objectName = path[0]!;\n\t\t\t\t\t\tif (!(objectName in nullifyMap)) {\n\t\t\t\t\t\t\tnullifyMap[objectName] = value === null ? getTableName(field.table) : false;\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\ttypeof nullifyMap[objectName] === 'string' && nullifyMap[objectName] !== getTableName(field.table)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnullifyMap[objectName] = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn result;\n\t\t},\n\t\t{},\n\t);\n\n\t// Nullify all nested objects from nullifyMap that are nullable\n\tif (joinsNotNullableMap && Object.keys(nullifyMap).length > 0) {\n\t\tfor (const [objectName, tableName] of Object.entries(nullifyMap)) {\n\t\t\tif (typeof tableName === 'string' && !joinsNotNullableMap[tableName]) {\n\t\t\t\tresult[objectName] = null;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result as TResult;\n}\n\n/** @internal */\nexport function orderSelectedFields<TColumn extends AnyColumn>(\n\tfields: Record<string, unknown>,\n\tpathPrefix?: string[],\n): SelectedFieldsOrdered<TColumn> {\n\treturn Object.entries(fields).reduce<SelectedFieldsOrdered<AnyColumn>>((result, [name, field]) => {\n\t\tif (typeof name !== 'string') {\n\t\t\treturn result;\n\t\t}\n\n\t\tconst newPath = pathPrefix ? [...pathPrefix, name] : [name];\n\t\tif (is(field, Column) || is(field, SQL) || is(field, SQL.Aliased)) {\n\t\t\tresult.push({ path: newPath, field });\n\t\t} else if (is(field, Table)) {\n\t\t\tresult.push(...orderSelectedFields(field[Table.Symbol.Columns], newPath));\n\t\t} else {\n\t\t\tresult.push(...orderSelectedFields(field as Record<string, unknown>, newPath));\n\t\t}\n\t\treturn result;\n\t}, []) as SelectedFieldsOrdered<TColumn>;\n}\n\nexport function haveSameKeys(left: Record<string, unknown>, right: Record<string, unknown>) {\n\tconst leftKeys = Object.keys(left);\n\tconst rightKeys = Object.keys(right);\n\n\tif (leftKeys.length !== rightKeys.length) {\n\t\treturn false;\n\t}\n\n\tfor (const [index, key] of leftKeys.entries()) {\n\t\tif (key !== rightKeys[index]) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/** @internal */\nexport function mapUpdateSet(table: Table, values: Record<string, unknown>): UpdateSet {\n\tconst entries: [string, UpdateSet[string]][] = Object.entries(values)\n\t\t.filter(([, value]) => value !== undefined)\n\t\t.map(([key, value]) => {\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (is(value, SQL) || is(value, Column)) {\n\t\t\t\treturn [key, value];\n\t\t\t} else {\n\t\t\t\treturn [key, new Param(value, table[Table.Symbol.Columns][key])];\n\t\t\t}\n\t\t});\n\n\tif (entries.length === 0) {\n\t\tthrow new Error('No values to set');\n\t}\n\n\treturn Object.fromEntries(entries);\n}\n\nexport type UpdateSet = Record<string, SQL | Param | AnyColumn | null | undefined>;\n\nexport type OneOrMany<T> = T | T[];\n\nexport type Update<T, TUpdate> =\n\t& {\n\t\t[K in Exclude<keyof T, keyof TUpdate>]: T[K];\n\t}\n\t& TUpdate;\n\nexport type Simplify<T> =\n\t& {\n\t\t// @ts-ignore - \"Type parameter 'K' has a circular constraint\", not sure why\n\t\t[K in keyof T]: T[K];\n\t}\n\t& {};\n\nexport type SimplifyMappedType<T> = [T] extends [unknown] ? T : never;\n\nexport type ShallowRecord<K extends keyof any, T> = SimplifyMappedType<{ [P in K]: T }>;\n\nexport type Assume<T, U> = T extends U ? T : U;\n\nexport type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;\n\nexport interface DrizzleTypeError<T extends string> {\n\t$drizzleTypeError: T;\n}\n\nexport type ValueOrArray<T> = T | T[];\n\n/** @internal */\nexport function applyMixins(baseClass: any, extendedClasses: any[]) {\n\tfor (const extendedClass of extendedClasses) {\n\t\tfor (const name of Object.getOwnPropertyNames(extendedClass.prototype)) {\n\t\t\tif (name === 'constructor') continue;\n\n\t\t\tObject.defineProperty(\n\t\t\t\tbaseClass.prototype,\n\t\t\t\tname,\n\t\t\t\tObject.getOwnPropertyDescriptor(extendedClass.prototype, name) || Object.create(null),\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport type Or<T1, T2> = T1 extends true ? true : T2 extends true ? true : false;\n\nexport type IfThenElse<If, Then, Else> = If extends true ? Then : Else;\n\nexport type PromiseOf<T> = T extends Promise<infer U> ? U : T;\n\nexport type Writable<T> = {\n\t-readonly [P in keyof T]: T[P];\n};\n\nexport function getTableColumns<T extends Table>(table: T): T['_']['columns'] {\n\treturn table[Table.Symbol.Columns];\n}\n\nexport function getViewSelectedFields<T extends View>(view: T): T['_']['selectedFields'] {\n\treturn view[ViewBaseConfig].selectedFields;\n}\n\n/** @internal */\nexport function getTableLikeName(table: TableLike): string | undefined {\n\treturn is(table, Subquery)\n\t\t? table._.alias\n\t\t: is(table, View)\n\t\t? table[ViewBaseConfig].name\n\t\t: is(table, SQL)\n\t\t? undefined\n\t\t: table[Table.Symbol.IsAlias]\n\t\t? table[Table.Symbol.Name]\n\t\t: table[Table.Symbol.BaseName];\n}\n\nexport type ColumnsWithTable<\n\tTTableName extends string,\n\tTForeignTableName extends string,\n\tTColumns extends AnyColumn<{ tableName: TTableName }>[],\n> = { [Key in keyof TColumns]: AnyColumn<{ tableName: TForeignTableName }> };\n\nexport type Casing = 'snake_case' | 'camelCase';\n\nexport interface DrizzleConfig<TSchema extends Record<string, unknown> = Record<string, never>> {\n\tlogger?: boolean | Logger;\n\tschema?: TSchema;\n\tcasing?: Casing;\n}\nexport type ValidateShape<T, ValidShape, TResult = T> = T extends ValidShape\n\t? Exclude<keyof T, keyof ValidShape> extends never ? TResult\n\t: DrizzleTypeError<\n\t\t`Invalid key(s): ${Exclude<(keyof T) & (string | number | bigint | boolean | null | undefined), keyof ValidShape>}`\n\t>\n\t: never;\n\nexport type KnownKeysOnly<T, U> = {\n\t[K in keyof T]: K extends keyof U ? T[K] : never;\n};\n\nexport type IsAny<T> = 0 extends (1 & T) ? true : false;\n\n/** @internal */\nexport function getColumnNameAndConfig<\n\tTConfig extends Record<string, any> | undefined,\n>(a: string | TConfig | undefined, b: TConfig | undefined) {\n\treturn {\n\t\tname: typeof a === 'string' && a.length > 0 ? a : '' as string,\n\t\tconfig: typeof a === 'object' ? a : b as TConfig,\n\t};\n}\n\nexport type IfNotImported<T, Y, N> = unknown extends T ? Y : N;\n\nexport type ImportTypeError<TPackageName extends string> =\n\t`Please install \\`${TPackageName}\\` to allow Drizzle ORM to connect to the database`;\n\nexport type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Keys extends any\n\t? Required<Pick<T, Keys>> & Partial<Omit<T, Keys>>\n\t: never;\n\ntype ExpectedConfigShape = {\n\tlogger?: boolean | {\n\t\tlogQuery(query: string, params: unknown[]): void;\n\t};\n\tschema?: Record<string, never>;\n\tcasing?: 'snake_case' | 'camelCase';\n};\n\n// If this errors, you must update config shape checker function with new config specs\nconst _: DrizzleConfig = {} as ExpectedConfigShape;\nconst __: ExpectedConfigShape = {} as DrizzleConfig;\n\nexport function isConfig(data: any): boolean {\n\tif (typeof data !== 'object' || data === null) return false;\n\n\tif (data.constructor.name !== 'Object') return false;\n\n\tif ('logger' in data) {\n\t\tconst type = typeof data['logger'];\n\t\tif (\n\t\t\ttype !== 'boolean' && (type !== 'object' || typeof data['logger']['logQuery'] !== 'function')\n\t\t\t&& type !== 'undefined'\n\t\t) return false;\n\n\t\treturn true;\n\t}\n\n\tif ('schema' in data) {\n\t\tconst type = typeof data['logger'];\n\t\tif (type !== 'object' && type !== 'undefined') return false;\n\n\t\treturn true;\n\t}\n\n\tif ('casing' in data) {\n\t\tconst type = typeof data['logger'];\n\t\tif (type !== 'string' && type !== 'undefined') return false;\n\n\t\treturn true;\n\t}\n\n\tif ('mode' in data) {\n\t\tif (data['mode'] !== 'default' || data['mode'] !== 'planetscale' || data['mode'] !== undefined) return false;\n\n\t\treturn true;\n\t}\n\n\tif ('connection' in data) {\n\t\tconst type = typeof data['connection'];\n\t\tif (type !== 'string' && type !== 'object' && type !== 'undefined') return false;\n\n\t\treturn true;\n\t}\n\n\tif ('client' in data) {\n\t\tconst type = typeof data['client'];\n\t\tif (type !== 'object' && type !== 'function' && type !== 'undefined') return false;\n\n\t\treturn true;\n\t}\n\n\tif (Object.keys(data).length === 0) return true;\n\n\treturn false;\n}\n\nexport type NeonAuthToken = string | (() => string | Promise<string>);\n"],"mappings":"AACA,SAAS,cAAc;AACvB,SAAS,UAAU;AAInB,SAAS,OAAO,KAAK,YAAY;AAEjC,SAAS,gBAAgB;AACzB,SAAS,cAAc,aAAa;AACpC,SAAS,sBAAsB;AAGxB,SAAS,aACf,SACA,KACA,qBACU;AAEV,QAAM,aAA6C,CAAC;AAEpD,QAAM,SAAS,QAAQ;AAAA,IACtB,CAACA,SAAQ,EAAE,MAAM,MAAM,GAAG,gBAAgB;AACzC,UAAI;AACJ,UAAI,GAAG,OAAO,MAAM,GAAG;AACtB,kBAAU;AAAA,MACX,WAAW,GAAG,OAAO,GAAG,GAAG;AAC1B,kBAAU,MAAM;AAAA,MACjB,OAAO;AACN,kBAAU,MAAM,IA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,QAAI,SAAS,YAAY,SAAS;AAAa,aAAO;AAEtD,WAAO;AAAA,EACR;AAEA,MAAI,YAAY,MAAM;AACrB,UAAM,OAAO,OAAO,KAAK,QAAQ;AACjC,QAAI,SAAS,YAAY,SAAS;AAAa,aAAO;AAEtD,WAAO;AAAA,EACR;AAEA,MAAI,UAAU,MAAM;AACnB,QAAI,KAAK,MAAM,MAAM,aAAa,KAAK,MAAM,MAAM,iBAAiB,KAAK,MAAM,MAAM;AAAW,aAAO;AAEvG,WAAO;AAAA,EACR;AAEA,MAAI,gBAAgB,MAAM;AACzB,UAAM,OAAO,OAAO,KAAK,YAAY;AACrC,QAAI,SAAS,YAAY,SAAS,YAAY,SAAS;AAAa,aAAO;AAE3E,WAAO;AAAA,EACR;AAEA,MAAI,YAAY,MAAM;AACrB,UAAM,OAAO,OAAO,KAAK,QAAQ;AACjC,QAAI,SAAS,YAAY,SAAS,cAAc,SAAS;AAAa,aAAO;AAE7E,WAAO;AAAA,EACR;AAEA,MAAI,OAAO,KAAK,IAAI,EAAE,WAAW;AAAG,WAAO;AAE3C,SAAO;AACR;","names":["result"]}
|
|
@@ -39,10 +39,7 @@ class VercelPgDriver {
|
|
|
39
39
|
}
|
|
40
40
|
static [import_entity.entityKind] = "VercelPgDriver";
|
|
41
41
|
createSession(schema) {
|
|
42
|
-
return new import_session.VercelPgSession(this.client, this.dialect, schema, {
|
|
43
|
-
logger: this.options.logger,
|
|
44
|
-
cache: this.options.cache
|
|
45
|
-
});
|
|
42
|
+
return new import_session.VercelPgSession(this.client, this.dialect, schema, { logger: this.options.logger });
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
45
|
class VercelPgDatabase extends import_db.PgDatabase {
|
|
@@ -68,14 +65,10 @@ function construct(client, config = {}) {
|
|
|
68
65
|
tableNamesMap: tablesConfig.tableNamesMap
|
|
69
66
|
};
|
|
70
67
|
}
|
|
71
|
-
const driver = new VercelPgDriver(client, dialect, { logger
|
|
68
|
+
const driver = new VercelPgDriver(client, dialect, { logger });
|
|
72
69
|
const session = driver.createSession(schema);
|
|
73
70
|
const db = new VercelPgDatabase(dialect, session, schema);
|
|
74
71
|
db.$client = client;
|
|
75
|
-
db.$cache = config.cache;
|
|
76
|
-
if (db.$cache) {
|
|
77
|
-
db.$cache["invalidate"] = config.cache?.onMutate;
|
|
78
|
-
}
|
|
79
72
|
return db;
|
|
80
73
|
}
|
|
81
74
|
function drizzle(...params) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/vercel-postgres/driver.ts"],"sourcesContent":["import { sql } from '@vercel/postgres';\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/vercel-postgres/driver.ts"],"sourcesContent":["import { sql } from '@vercel/postgres';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport { PgDatabase } from '~/pg-core/db.ts';\nimport { PgDialect } from '~/pg-core/index.ts';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport { type DrizzleConfig, isConfig } from '~/utils.ts';\nimport { type VercelPgClient, type VercelPgQueryResultHKT, VercelPgSession } from './session.ts';\n\nexport interface VercelPgDriverOptions {\n\tlogger?: Logger;\n}\n\nexport class VercelPgDriver {\n\tstatic readonly [entityKind]: string = 'VercelPgDriver';\n\n\tconstructor(\n\t\tprivate client: VercelPgClient,\n\t\tprivate dialect: PgDialect,\n\t\tprivate options: VercelPgDriverOptions = {},\n\t) {\n\t}\n\n\tcreateSession(\n\t\tschema: RelationalSchemaConfig<TablesRelationalConfig> | undefined,\n\t): VercelPgSession<Record<string, unknown>, TablesRelationalConfig> {\n\t\treturn new VercelPgSession(this.client, this.dialect, schema, { logger: this.options.logger });\n\t}\n}\n\nexport class VercelPgDatabase<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> extends PgDatabase<VercelPgQueryResultHKT, TSchema> {\n\tstatic override readonly [entityKind]: string = 'VercelPgDatabase';\n}\n\nfunction construct<TSchema extends Record<string, unknown> = Record<string, never>>(\n\tclient: VercelPgClient,\n\tconfig: DrizzleConfig<TSchema> = {},\n): VercelPgDatabase<TSchema> & {\n\t$client: VercelPgClient;\n} {\n\tconst dialect = new PgDialect({ 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 driver = new VercelPgDriver(client, dialect, { logger });\n\tconst session = driver.createSession(schema);\n\tconst db = new VercelPgDatabase(dialect, session, schema as any) as VercelPgDatabase<TSchema>;\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\tTClient extends VercelPgClient = typeof sql,\n>(\n\t...params: [] | [\n\t\tTClient,\n\t] | [\n\t\tTClient,\n\t\tDrizzleConfig<TSchema>,\n\t] | [\n\t\t(\n\t\t\t& DrizzleConfig<TSchema>\n\t\t\t& ({\n\t\t\t\tclient?: TClient;\n\t\t\t})\n\t\t),\n\t]\n): VercelPgDatabase<TSchema> & {\n\t$client: TClient;\n} {\n\tif (isConfig(params[0])) {\n\t\tconst { client, ...drizzleConfig } = params[0] as ({ client?: TClient } & DrizzleConfig<TSchema>);\n\t\treturn construct(client ?? sql, drizzleConfig) as any;\n\t}\n\n\treturn construct((params[0] ?? sql) as TClient, 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): VercelPgDatabase<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;AAAA,sBAAoB;AACpB,oBAA2B;AAE3B,oBAA8B;AAC9B,gBAA2B;AAC3B,qBAA0B;AAC1B,uBAKO;AACP,mBAA6C;AAC7C,qBAAkF;AAM3E,MAAM,eAAe;AAAA,EAG3B,YACS,QACA,SACA,UAAiC,CAAC,GACzC;AAHO;AACA;AACA;AAAA,EAET;AAAA,EAPA,QAAiB,wBAAU,IAAY;AAAA,EASvC,cACC,QACmE;AACnE,WAAO,IAAI,+BAAgB,KAAK,QAAQ,KAAK,SAAS,QAAQ,EAAE,QAAQ,KAAK,QAAQ,OAAO,CAAC;AAAA,EAC9F;AACD;AAEO,MAAM,yBAEH,qBAA4C;AAAA,EACrD,QAA0B,wBAAU,IAAY;AACjD;AAEA,SAAS,UACR,QACA,SAAiC,CAAC,GAGjC;AACD,QAAM,UAAU,IAAI,yBAAU,EAAE,QAAQ,OAAO,OAAO,CAAC;AACvD,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;AAClB,UAAM,mBAAe;AAAA,MACpB,OAAO;AAAA,MACP;AAAA,IACD;AACA,aAAS;AAAA,MACR,YAAY,OAAO;AAAA,MACnB,QAAQ,aAAa;AAAA,MACrB,eAAe,aAAa;AAAA,IAC7B;AAAA,EACD;AAEA,QAAM,SAAS,IAAI,eAAe,QAAQ,SAAS,EAAE,OAAO,CAAC;AAC7D,QAAM,UAAU,OAAO,cAAc,MAAM;AAC3C,QAAM,KAAK,IAAI,iBAAiB,SAAS,SAAS,MAAa;AAC/D,EAAO,GAAI,UAAU;AAErB,SAAO;AACR;AAEO,SAAS,WAIZ,QAeF;AACD,UAAI,uBAAS,OAAO,CAAC,CAAC,GAAG;AACxB,UAAM,EAAE,QAAQ,GAAG,cAAc,IAAI,OAAO,CAAC;AAC7C,WAAO,UAAU,UAAU,qBAAK,aAAa;AAAA,EAC9C;AAEA,SAAO,UAAW,OAAO,CAAC,KAAK,qBAAiB,OAAO,CAAC,CAAuC;AAChG;AAAA,CAEO,CAAUA,aAAV;AACC,WAAS,KACf,QAGC;AACD,WAAO,UAAU,CAAC,GAAU,MAAM;AAAA,EACnC;AANO,EAAAA,SAAS;AAAA,GADA;","names":["drizzle"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { sql } from '@vercel/postgres';
|
|
2
|
-
import type { Cache } from "../cache/core/cache.cjs";
|
|
3
2
|
import { entityKind } from "../entity.cjs";
|
|
4
3
|
import type { Logger } from "../logger.cjs";
|
|
5
4
|
import { PgDatabase } from "../pg-core/db.cjs";
|
|
@@ -9,7 +8,6 @@ import { type DrizzleConfig } from "../utils.cjs";
|
|
|
9
8
|
import { type VercelPgClient, type VercelPgQueryResultHKT, VercelPgSession } from "./session.cjs";
|
|
10
9
|
export interface VercelPgDriverOptions {
|
|
11
10
|
logger?: Logger;
|
|
12
|
-
cache?: Cache;
|
|
13
11
|
}
|
|
14
12
|
export declare class VercelPgDriver {
|
|
15
13
|
private client;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { sql } from '@vercel/postgres';
|
|
2
|
-
import type { Cache } from "../cache/core/cache.js";
|
|
3
2
|
import { entityKind } from "../entity.js";
|
|
4
3
|
import type { Logger } from "../logger.js";
|
|
5
4
|
import { PgDatabase } from "../pg-core/db.js";
|
|
@@ -9,7 +8,6 @@ import { type DrizzleConfig } from "../utils.js";
|
|
|
9
8
|
import { type VercelPgClient, type VercelPgQueryResultHKT, VercelPgSession } from "./session.js";
|
|
10
9
|
export interface VercelPgDriverOptions {
|
|
11
10
|
logger?: Logger;
|
|
12
|
-
cache?: Cache;
|
|
13
11
|
}
|
|
14
12
|
export declare class VercelPgDriver {
|
|
15
13
|
private client;
|
|
@@ -17,10 +17,7 @@ class VercelPgDriver {
|
|
|
17
17
|
}
|
|
18
18
|
static [entityKind] = "VercelPgDriver";
|
|
19
19
|
createSession(schema) {
|
|
20
|
-
return new VercelPgSession(this.client, this.dialect, schema, {
|
|
21
|
-
logger: this.options.logger,
|
|
22
|
-
cache: this.options.cache
|
|
23
|
-
});
|
|
20
|
+
return new VercelPgSession(this.client, this.dialect, schema, { logger: this.options.logger });
|
|
24
21
|
}
|
|
25
22
|
}
|
|
26
23
|
class VercelPgDatabase extends PgDatabase {
|
|
@@ -46,14 +43,10 @@ function construct(client, config = {}) {
|
|
|
46
43
|
tableNamesMap: tablesConfig.tableNamesMap
|
|
47
44
|
};
|
|
48
45
|
}
|
|
49
|
-
const driver = new VercelPgDriver(client, dialect, { logger
|
|
46
|
+
const driver = new VercelPgDriver(client, dialect, { logger });
|
|
50
47
|
const session = driver.createSession(schema);
|
|
51
48
|
const db = new VercelPgDatabase(dialect, session, schema);
|
|
52
49
|
db.$client = client;
|
|
53
|
-
db.$cache = config.cache;
|
|
54
|
-
if (db.$cache) {
|
|
55
|
-
db.$cache["invalidate"] = config.cache?.onMutate;
|
|
56
|
-
}
|
|
57
50
|
return db;
|
|
58
51
|
}
|
|
59
52
|
function drizzle(...params) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/vercel-postgres/driver.ts"],"sourcesContent":["import { sql } from '@vercel/postgres';\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/vercel-postgres/driver.ts"],"sourcesContent":["import { sql } from '@vercel/postgres';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport { PgDatabase } from '~/pg-core/db.ts';\nimport { PgDialect } from '~/pg-core/index.ts';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport { type DrizzleConfig, isConfig } from '~/utils.ts';\nimport { type VercelPgClient, type VercelPgQueryResultHKT, VercelPgSession } from './session.ts';\n\nexport interface VercelPgDriverOptions {\n\tlogger?: Logger;\n}\n\nexport class VercelPgDriver {\n\tstatic readonly [entityKind]: string = 'VercelPgDriver';\n\n\tconstructor(\n\t\tprivate client: VercelPgClient,\n\t\tprivate dialect: PgDialect,\n\t\tprivate options: VercelPgDriverOptions = {},\n\t) {\n\t}\n\n\tcreateSession(\n\t\tschema: RelationalSchemaConfig<TablesRelationalConfig> | undefined,\n\t): VercelPgSession<Record<string, unknown>, TablesRelationalConfig> {\n\t\treturn new VercelPgSession(this.client, this.dialect, schema, { logger: this.options.logger });\n\t}\n}\n\nexport class VercelPgDatabase<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> extends PgDatabase<VercelPgQueryResultHKT, TSchema> {\n\tstatic override readonly [entityKind]: string = 'VercelPgDatabase';\n}\n\nfunction construct<TSchema extends Record<string, unknown> = Record<string, never>>(\n\tclient: VercelPgClient,\n\tconfig: DrizzleConfig<TSchema> = {},\n): VercelPgDatabase<TSchema> & {\n\t$client: VercelPgClient;\n} {\n\tconst dialect = new PgDialect({ 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 driver = new VercelPgDriver(client, dialect, { logger });\n\tconst session = driver.createSession(schema);\n\tconst db = new VercelPgDatabase(dialect, session, schema as any) as VercelPgDatabase<TSchema>;\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\tTClient extends VercelPgClient = typeof sql,\n>(\n\t...params: [] | [\n\t\tTClient,\n\t] | [\n\t\tTClient,\n\t\tDrizzleConfig<TSchema>,\n\t] | [\n\t\t(\n\t\t\t& DrizzleConfig<TSchema>\n\t\t\t& ({\n\t\t\t\tclient?: TClient;\n\t\t\t})\n\t\t),\n\t]\n): VercelPgDatabase<TSchema> & {\n\t$client: TClient;\n} {\n\tif (isConfig(params[0])) {\n\t\tconst { client, ...drizzleConfig } = params[0] as ({ client?: TClient } & DrizzleConfig<TSchema>);\n\t\treturn construct(client ?? sql, drizzleConfig) as any;\n\t}\n\n\treturn construct((params[0] ?? sql) as TClient, 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): VercelPgDatabase<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,SAAS,WAAW;AACpB,SAAS,kBAAkB;AAE3B,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP,SAA6B,gBAAgB;AAC7C,SAA2D,uBAAuB;AAM3E,MAAM,eAAe;AAAA,EAG3B,YACS,QACA,SACA,UAAiC,CAAC,GACzC;AAHO;AACA;AACA;AAAA,EAET;AAAA,EAPA,QAAiB,UAAU,IAAY;AAAA,EASvC,cACC,QACmE;AACnE,WAAO,IAAI,gBAAgB,KAAK,QAAQ,KAAK,S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|
26
26
|
var import_postgres = require("@vercel/postgres");
|
|
27
|
-
var import_cache = require("../cache/core/cache.cjs");
|
|
28
27
|
var import_entity = require("../entity.cjs");
|
|
29
28
|
var import_logger = require("../logger.cjs");
|
|
30
29
|
var import_pg_core = require("../pg-core/index.cjs");
|
|
@@ -32,8 +31,8 @@ var import_session = require("../pg-core/session.cjs");
|
|
|
32
31
|
var import_sql = require("../sql/sql.cjs");
|
|
33
32
|
var import_utils = require("../utils.cjs");
|
|
34
33
|
class VercelPgPreparedQuery extends import_session.PgPreparedQuery {
|
|
35
|
-
constructor(client, queryString, params, logger,
|
|
36
|
-
super({ sql: queryString, params }
|
|
34
|
+
constructor(client, queryString, params, logger, fields, name, _isResponseInArrayMode, customResultMapper) {
|
|
35
|
+
super({ sql: queryString, params });
|
|
37
36
|
this.client = client;
|
|
38
37
|
this.params = params;
|
|
39
38
|
this.logger = logger;
|
|
@@ -94,13 +93,9 @@ class VercelPgPreparedQuery extends import_session.PgPreparedQuery {
|
|
|
94
93
|
this.logger.logQuery(this.rawQuery.text, params);
|
|
95
94
|
const { fields, rawQuery, client, queryConfig: query, joinsNotNullableMap, customResultMapper } = this;
|
|
96
95
|
if (!fields && !customResultMapper) {
|
|
97
|
-
return
|
|
98
|
-
return await client.query(rawQuery, params);
|
|
99
|
-
});
|
|
96
|
+
return client.query(rawQuery, params);
|
|
100
97
|
}
|
|
101
|
-
const { rows } = await
|
|
102
|
-
return await client.query(query, params);
|
|
103
|
-
});
|
|
98
|
+
const { rows } = await client.query(query, params);
|
|
104
99
|
if (customResultMapper) {
|
|
105
100
|
return customResultMapper(rows);
|
|
106
101
|
}
|
|
@@ -109,16 +104,12 @@ class VercelPgPreparedQuery extends import_session.PgPreparedQuery {
|
|
|
109
104
|
all(placeholderValues = {}) {
|
|
110
105
|
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
|
|
111
106
|
this.logger.logQuery(this.rawQuery.text, params);
|
|
112
|
-
return this.
|
|
113
|
-
return await this.client.query(this.rawQuery, params);
|
|
114
|
-
}).then((result) => result.rows);
|
|
107
|
+
return this.client.query(this.rawQuery, params).then((result) => result.rows);
|
|
115
108
|
}
|
|
116
109
|
values(placeholderValues = {}) {
|
|
117
110
|
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
|
|
118
111
|
this.logger.logQuery(this.rawQuery.text, params);
|
|
119
|
-
return this.
|
|
120
|
-
return await this.client.query(this.queryConfig, params);
|
|
121
|
-
}).then((result) => result.rows);
|
|
112
|
+
return this.client.query(this.queryConfig, params).then((result) => result.rows);
|
|
122
113
|
}
|
|
123
114
|
/** @internal */
|
|
124
115
|
isResponseInArrayMode() {
|
|
@@ -132,20 +123,15 @@ class VercelPgSession extends import_session.PgSession {
|
|
|
132
123
|
this.schema = schema;
|
|
133
124
|
this.options = options;
|
|
134
125
|
this.logger = options.logger ?? new import_logger.NoopLogger();
|
|
135
|
-
this.cache = options.cache ?? new import_cache.NoopCache();
|
|
136
126
|
}
|
|
137
127
|
static [import_entity.entityKind] = "VercelPgSession";
|
|
138
128
|
logger;
|
|
139
|
-
|
|
140
|
-
prepareQuery(query, fields, name, isResponseInArrayMode, customResultMapper, queryMetadata, cacheConfig) {
|
|
129
|
+
prepareQuery(query, fields, name, isResponseInArrayMode, customResultMapper) {
|
|
141
130
|
return new VercelPgPreparedQuery(
|
|
142
131
|
this.client,
|
|
143
132
|
query.sql,
|
|
144
133
|
query.params,
|
|
145
134
|
this.logger,
|
|
146
|
-
this.cache,
|
|
147
|
-
queryMetadata,
|
|
148
|
-
cacheConfig,
|
|
149
135
|
fields,
|
|
150
136
|
name,
|
|
151
137
|
isResponseInArrayMode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/vercel-postgres/session.ts"],"sourcesContent":["import {\n\ttype QueryArrayConfig,\n\ttype QueryConfig,\n\ttype QueryResult,\n\ttype QueryResultRow,\n\ttypes,\n\ttype VercelClient,\n\tVercelPool,\n\ttype VercelPoolClient,\n} from '@vercel/postgres';\nimport type { Cache } from '~/cache/core/cache.ts';\nimport { NoopCache } from '~/cache/core/cache.ts';\nimport { entityKind } from '~/entity.ts';\nimport { type Logger, NoopLogger } from '~/logger.ts';\nimport { type PgDialect, PgTransaction } from '~/pg-core/index.ts';\nimport type { SelectedFieldsOrdered, WithCacheConfig } from '~/pg-core/query-builders/select.types.ts';\nimport type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from '~/pg-core/session.ts';\nimport { PgPreparedQuery, PgSession } from '~/pg-core/session.ts';\nimport type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type Query, type SQL, sql } from '~/sql/sql.ts';\nimport { type Assume, mapResultRow } from '~/utils.ts';\n\nexport type VercelPgClient = VercelPool | VercelClient | VercelPoolClient;\n\nexport class VercelPgPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {\n\tstatic override readonly [entityKind]: string = 'VercelPgPreparedQuery';\n\n\tprivate rawQuery: QueryConfig;\n\tprivate queryConfig: QueryArrayConfig;\n\n\tconstructor(\n\t\tprivate client: VercelPgClient,\n\t\tqueryString: string,\n\t\tprivate params: unknown[],\n\t\tprivate logger: Logger,\n\t\tcache: Cache,\n\t\tqueryMetadata: {\n\t\t\ttype: 'select' | 'update' | 'delete' | 'insert';\n\t\t\ttables: string[];\n\t\t} | undefined,\n\t\tcacheConfig: WithCacheConfig | undefined,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tprivate _isResponseInArrayMode: boolean,\n\t\tprivate customResultMapper?: (rows: unknown[][]) => T['execute'],\n\t) {\n\t\tsuper({ sql: queryString, params }, cache, queryMetadata, cacheConfig);\n\t\tthis.rawQuery = {\n\t\t\tname,\n\t\t\ttext: queryString,\n\t\t\ttypes: {\n\t\t\t\t// @ts-ignore\n\t\t\t\tgetTypeParser: (typeId, format) => {\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMPTZ) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMP) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.DATE) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.INTERVAL) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\treturn types.getTypeParser(typeId, format);\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t\tthis.queryConfig = {\n\t\t\tname,\n\t\t\ttext: queryString,\n\t\t\trowMode: 'array',\n\t\t\ttypes: {\n\t\t\t\t// @ts-ignore\n\t\t\t\tgetTypeParser: (typeId, format) => {\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMPTZ) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMP) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.DATE) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.INTERVAL) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\treturn types.getTypeParser(typeId, format);\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\tasync execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\n\t\tthis.logger.logQuery(this.rawQuery.text, params);\n\n\t\tconst { fields, rawQuery, client, queryConfig: query, joinsNotNullableMap, customResultMapper } = this;\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn this.queryWithCache(rawQuery.text, params, async () => {\n\t\t\t\treturn await client.query(rawQuery, params);\n\t\t\t});\n\t\t}\n\n\t\tconst { rows } = await this.queryWithCache(query.text, params, async () => {\n\t\t\treturn await client.query(query, params);\n\t\t});\n\n\t\tif (customResultMapper) {\n\t\t\treturn customResultMapper(rows);\n\t\t}\n\n\t\treturn rows.map((row) => mapResultRow<T['execute']>(fields!, row, joinsNotNullableMap));\n\t}\n\n\tall(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['all']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\t\tthis.logger.logQuery(this.rawQuery.text, params);\n\t\treturn this.queryWithCache(this.rawQuery.text, params, async () => {\n\t\t\treturn await this.client.query(this.rawQuery, params);\n\t\t}).then((result) => result.rows);\n\t}\n\n\tvalues(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['values']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\t\tthis.logger.logQuery(this.rawQuery.text, params);\n\t\treturn this.queryWithCache(this.queryConfig.text, params, async () => {\n\t\t\treturn await this.client.query(this.queryConfig, params);\n\t\t}).then((result) => result.rows);\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface VercelPgSessionOptions {\n\tlogger?: Logger;\n\tcache?: Cache;\n}\n\nexport class VercelPgSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgSession<VercelPgQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'VercelPgSession';\n\n\tprivate logger: Logger;\n\tprivate cache: Cache;\n\n\tconstructor(\n\t\tprivate client: VercelPgClient,\n\t\tdialect: PgDialect,\n\t\tprivate schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: VercelPgSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t\tthis.cache = options.cache ?? new NoopCache();\n\t}\n\n\tprepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\tqueryMetadata?: {\n\t\t\ttype: 'select' | 'update' | 'delete' | 'insert';\n\t\t\ttables: string[];\n\t\t},\n\t\tcacheConfig?: WithCacheConfig,\n\t): PgPreparedQuery<T> {\n\t\treturn new VercelPgPreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery.sql,\n\t\t\tquery.params,\n\t\t\tthis.logger,\n\t\t\tthis.cache,\n\t\t\tqueryMetadata,\n\t\t\tcacheConfig,\n\t\t\tfields,\n\t\t\tname,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\tasync query(query: string, params: unknown[]): Promise<QueryResult> {\n\t\tthis.logger.logQuery(query, params);\n\t\tconst result = await this.client.query({\n\t\t\trowMode: 'array',\n\t\t\ttext: query,\n\t\t\tvalues: params,\n\t\t});\n\t\treturn result;\n\t}\n\n\tasync queryObjects<T extends QueryResultRow>(\n\t\tquery: string,\n\t\tparams: unknown[],\n\t): Promise<QueryResult<T>> {\n\t\treturn this.client.query<T>(query, params);\n\t}\n\n\toverride async count(sql: SQL): Promise<number> {\n\t\tconst result = await this.execute(sql);\n\n\t\treturn Number((result as any)['rows'][0]['count']);\n\t}\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t\tconfig?: PgTransactionConfig | undefined,\n\t): Promise<T> {\n\t\tconst session = this.client instanceof VercelPool // eslint-disable-line no-instanceof/no-instanceof\n\t\t\t? new VercelPgSession(await this.client.connect(), this.dialect, this.schema, this.options)\n\t\t\t: this;\n\t\tconst tx = new VercelPgTransaction<TFullSchema, TSchema>(this.dialect, session, this.schema);\n\t\tawait tx.execute(sql`begin${config ? sql` ${tx.getTransactionConfigSQL(config)}` : undefined}`);\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait tx.execute(sql`commit`);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tawait tx.execute(sql`rollback`);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tif (this.client instanceof VercelPool) { // eslint-disable-line no-instanceof/no-instanceof\n\t\t\t\t(session.client as VercelPoolClient).release();\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport class VercelPgTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgTransaction<VercelPgQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'VercelPgTransaction';\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new VercelPgTransaction<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 tx.execute(sql.raw(`savepoint ${savepointName}`));\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait tx.execute(sql.raw(`release savepoint ${savepointName}`));\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tawait tx.execute(sql.raw(`rollback to savepoint ${savepointName}`));\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n\nexport interface VercelPgQueryResultHKT extends PgQueryResultHKT {\n\ttype: QueryResult<Assume<this['row'], QueryResultRow>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBASO;AAEP,mBAA0B;AAC1B,oBAA2B;AAC3B,oBAAwC;AACxC,qBAA8C;AAG9C,qBAA2C;AAE3C,iBAA4D;AAC5D,mBAA0C;AAInC,MAAM,8BAA6D,+BAAmB;AAAA,EAM5F,YACS,QACR,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SAAS,SAAS,KAAK,MAAM;AAC3F,UAAM,GAAG,QAAQ,sBAAW,SAAS,kBAAO,GAAG,wBAAwB,MAAM,CAAC,KAAK,MAAS,EAAE;AAC9F,QAAI;AACH,YAAM,SAAS,MAAM,YAAY,EAAE;AACnC,YAAM,GAAG,QAAQ,sBAAW;AAC5B,aAAO;AAAA,IACR,SAAS,OAAO;AACf,YAAM,GAAG,QAAQ,wBAAa;AAC9B,YAAM;AAAA,IACP,UAAE;AACD,UAAI,KAAK,kBAAkB,4BAAY;AACtC,QAAC,QAAQ,OAA4B,QAAQ;AAAA,MAC9C;AAAA,IACD;AAAA,EACD;AACD;AAEO,MAAM,4BAGH,6BAA4D;AAAA,EACrE,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,GAAG,QAAQ,eAAI,IAAI,aAAa,aAAa,EAAE,CAAC;AACtD,QAAI;AACH,YAAM,SAAS,MAAM,YAAY,EAAE;AACnC,YAAM,GAAG,QAAQ,eAAI,IAAI,qBAAqB,aAAa,EAAE,CAAC;AAC9D,aAAO;AAAA,IACR,SAAS,KAAK;AACb,YAAM,GAAG,QAAQ,eAAI,IAAI,yBAAyB,aAAa,EAAE,CAAC;AAClE,YAAM;AAAA,IACP;AAAA,EACD;AACD;","names":["sql"]}
|
|
1
|
+
{"version":3,"sources":["../../src/vercel-postgres/session.ts"],"sourcesContent":["import {\n\ttype QueryArrayConfig,\n\ttype QueryConfig,\n\ttype QueryResult,\n\ttype QueryResultRow,\n\ttypes,\n\ttype VercelClient,\n\tVercelPool,\n\ttype VercelPoolClient,\n} from '@vercel/postgres';\nimport { entityKind } from '~/entity.ts';\nimport { type Logger, NoopLogger } from '~/logger.ts';\nimport { type PgDialect, PgTransaction } from '~/pg-core/index.ts';\nimport type { SelectedFieldsOrdered } from '~/pg-core/query-builders/select.types.ts';\nimport type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from '~/pg-core/session.ts';\nimport { PgPreparedQuery, PgSession } from '~/pg-core/session.ts';\nimport type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type Query, type SQL, sql } from '~/sql/sql.ts';\nimport { type Assume, mapResultRow } from '~/utils.ts';\n\nexport type VercelPgClient = VercelPool | VercelClient | VercelPoolClient;\n\nexport class VercelPgPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {\n\tstatic override readonly [entityKind]: string = 'VercelPgPreparedQuery';\n\n\tprivate rawQuery: QueryConfig;\n\tprivate queryConfig: QueryArrayConfig;\n\n\tconstructor(\n\t\tprivate client: VercelPgClient,\n\t\tqueryString: string,\n\t\tprivate params: unknown[],\n\t\tprivate logger: Logger,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\tname: 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 = {\n\t\t\tname,\n\t\t\ttext: queryString,\n\t\t\ttypes: {\n\t\t\t\t// @ts-ignore\n\t\t\t\tgetTypeParser: (typeId, format) => {\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMPTZ) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMP) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.DATE) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.INTERVAL) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\treturn types.getTypeParser(typeId, format);\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t\tthis.queryConfig = {\n\t\t\tname,\n\t\t\ttext: queryString,\n\t\t\trowMode: 'array',\n\t\t\ttypes: {\n\t\t\t\t// @ts-ignore\n\t\t\t\tgetTypeParser: (typeId, format) => {\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMPTZ) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMP) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.DATE) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.INTERVAL) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\treturn types.getTypeParser(typeId, format);\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\tasync execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\n\t\tthis.logger.logQuery(this.rawQuery.text, params);\n\n\t\tconst { fields, rawQuery, client, queryConfig: query, joinsNotNullableMap, customResultMapper } = this;\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn client.query(rawQuery, params);\n\t\t}\n\n\t\tconst { rows } = await client.query(query, params);\n\n\t\tif (customResultMapper) {\n\t\t\treturn customResultMapper(rows);\n\t\t}\n\n\t\treturn rows.map((row) => mapResultRow<T['execute']>(fields!, row, joinsNotNullableMap));\n\t}\n\n\tall(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['all']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\t\tthis.logger.logQuery(this.rawQuery.text, params);\n\t\treturn this.client.query(this.rawQuery, params).then((result) => result.rows);\n\t}\n\n\tvalues(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['values']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\t\tthis.logger.logQuery(this.rawQuery.text, params);\n\t\treturn this.client.query(this.queryConfig, params).then((result) => result.rows);\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface VercelPgSessionOptions {\n\tlogger?: Logger;\n}\n\nexport class VercelPgSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgSession<VercelPgQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'VercelPgSession';\n\n\tprivate logger: Logger;\n\n\tconstructor(\n\t\tprivate client: VercelPgClient,\n\t\tdialect: PgDialect,\n\t\tprivate schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: VercelPgSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t}\n\n\tprepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t): PgPreparedQuery<T> {\n\t\treturn new VercelPgPreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery.sql,\n\t\t\tquery.params,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\tname,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\tasync query(query: string, params: unknown[]): Promise<QueryResult> {\n\t\tthis.logger.logQuery(query, params);\n\t\tconst result = await this.client.query({\n\t\t\trowMode: 'array',\n\t\t\ttext: query,\n\t\t\tvalues: params,\n\t\t});\n\t\treturn result;\n\t}\n\n\tasync queryObjects<T extends QueryResultRow>(\n\t\tquery: string,\n\t\tparams: unknown[],\n\t): Promise<QueryResult<T>> {\n\t\treturn this.client.query<T>(query, params);\n\t}\n\n\toverride async count(sql: SQL): Promise<number> {\n\t\tconst result = await this.execute(sql);\n\n\t\treturn Number((result as any)['rows'][0]['count']);\n\t}\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t\tconfig?: PgTransactionConfig | undefined,\n\t): Promise<T> {\n\t\tconst session = this.client instanceof VercelPool // eslint-disable-line no-instanceof/no-instanceof\n\t\t\t? new VercelPgSession(await this.client.connect(), this.dialect, this.schema, this.options)\n\t\t\t: this;\n\t\tconst tx = new VercelPgTransaction<TFullSchema, TSchema>(this.dialect, session, this.schema);\n\t\tawait tx.execute(sql`begin${config ? sql` ${tx.getTransactionConfigSQL(config)}` : undefined}`);\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait tx.execute(sql`commit`);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tawait tx.execute(sql`rollback`);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tif (this.client instanceof VercelPool) { // eslint-disable-line no-instanceof/no-instanceof\n\t\t\t\t(session.client as VercelPoolClient).release();\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport class VercelPgTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgTransaction<VercelPgQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'VercelPgTransaction';\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new VercelPgTransaction<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 tx.execute(sql.raw(`savepoint ${savepointName}`));\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait tx.execute(sql.raw(`release savepoint ${savepointName}`));\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tawait tx.execute(sql.raw(`rollback to savepoint ${savepointName}`));\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n\nexport interface VercelPgQueryResultHKT extends PgQueryResultHKT {\n\ttype: QueryResult<Assume<this['row'], QueryResultRow>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBASO;AACP,oBAA2B;AAC3B,oBAAwC;AACxC,qBAA8C;AAG9C,qBAA2C;AAE3C,iBAA4D;AAC5D,mBAA0C;AAInC,MAAM,8BAA6D,+BAAmB;AAAA,EAM5F,YACS,QACR,aACQ,QACA,QACA,QACR,MACQ,wBACA,oBACP;AACD,UAAM,EAAE,KAAK,aAAa,OAAO,CAAC;AAT1B;AAEA;AACA;AACA;AAEA;AACA;AAGR,SAAK,WAAW;AAAA,MACf;AAAA,MACA,MAAM;AAAA,MACN,OAAO;AAAA;AAAA,QAEN,eAAe,CAAC,QAAQ,WAAW;AAClC,cAAI,WAAW,sBAAM,SAAS,aAAa;AAC1C,mBAAO,CAAC,QAAa;AAAA,UACtB;AACA,cAAI,WAAW,sBAAM,SAAS,WAAW;AACxC,mBAAO,CAAC,QAAa;AAAA,UACtB;AACA,cAAI,WAAW,sBAAM,SAAS,MAAM;AACnC,mBAAO,CAAC,QAAa;AAAA,UACtB;AACA,cAAI,WAAW,sBAAM,SAAS,UAAU;AACvC,mBAAO,CAAC,QAAa;AAAA,UACtB;AAEA,iBAAO,sBAAM,cAAc,QAAQ,MAAM;AAAA,QAC1C;AAAA,MACD;AAAA,IACD;AACA,SAAK,cAAc;AAAA,MAClB;AAAA,MACA,MAAM;AAAA,MACN,SAAS;AAAA,MACT,OAAO;AAAA;AAAA,QAEN,eAAe,CAAC,QAAQ,WAAW;AAClC,cAAI,WAAW,sBAAM,SAAS,aAAa;AAC1C,mBA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AAK,IAAI,oBAA0C,KAAK,SAAS,SAAS,KAAK,MAAM;AAC3F,UAAM,GAAG,QAAQ,sBAAW,SAAS,kBAAO,GAAG,wBAAwB,MAAM,CAAC,KAAK,MAAS,EAAE;AAC9F,QAAI;AACH,YAAM,SAAS,MAAM,YAAY,EAAE;AACnC,YAAM,GAAG,QAAQ,sBAAW;AAC5B,aAAO;AAAA,IACR,SAAS,OAAO;AACf,YAAM,GAAG,QAAQ,wBAAa;AAC9B,YAAM;AAAA,IACP,UAAE;AACD,UAAI,KAAK,kBAAkB,4BAAY;AACtC,QAAC,QAAQ,OAA4B,QAAQ;AAAA,MAC9C;AAAA,IACD;AAAA,EACD;AACD;AAEO,MAAM,4BAGH,6BAA4D;AAAA,EACrE,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,GAAG,QAAQ,eAAI,IAAI,aAAa,aAAa,EAAE,CAAC;AACtD,QAAI;AACH,YAAM,SAAS,MAAM,YAAY,EAAE;AACnC,YAAM,GAAG,QAAQ,eAAI,IAAI,qBAAqB,aAAa,EAAE,CAAC;AAC9D,aAAO;AAAA,IACR,SAAS,KAAK;AACb,YAAM,GAAG,QAAQ,eAAI,IAAI,yBAAyB,aAAa,EAAE,CAAC;AAClE,YAAM;AAAA,IACP;AAAA,EACD;AACD;","names":["sql"]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { type QueryResult, type QueryResultRow, type VercelClient, VercelPool, type VercelPoolClient } from '@vercel/postgres';
|
|
2
|
-
import type { Cache } from "../cache/core/cache.cjs";
|
|
3
2
|
import { entityKind } from "../entity.cjs";
|
|
4
3
|
import { type Logger } from "../logger.cjs";
|
|
5
4
|
import { type PgDialect, PgTransaction } from "../pg-core/index.cjs";
|
|
6
|
-
import type { SelectedFieldsOrdered
|
|
5
|
+
import type { SelectedFieldsOrdered } from "../pg-core/query-builders/select.types.cjs";
|
|
7
6
|
import type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from "../pg-core/session.cjs";
|
|
8
7
|
import { PgPreparedQuery, PgSession } from "../pg-core/session.cjs";
|
|
9
8
|
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.cjs";
|
|
@@ -20,17 +19,13 @@ export declare class VercelPgPreparedQuery<T extends PreparedQueryConfig> extend
|
|
|
20
19
|
static readonly [entityKind]: string;
|
|
21
20
|
private rawQuery;
|
|
22
21
|
private queryConfig;
|
|
23
|
-
constructor(client: VercelPgClient, queryString: string, params: unknown[], logger: Logger,
|
|
24
|
-
type: 'select' | 'update' | 'delete' | 'insert';
|
|
25
|
-
tables: string[];
|
|
26
|
-
} | undefined, cacheConfig: WithCacheConfig | undefined, fields: SelectedFieldsOrdered | undefined, name: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
|
22
|
+
constructor(client: VercelPgClient, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, name: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
|
27
23
|
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
28
24
|
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
|
29
25
|
values(placeholderValues?: Record<string, unknown> | undefined): Promise<T['values']>;
|
|
30
26
|
}
|
|
31
27
|
export interface VercelPgSessionOptions {
|
|
32
28
|
logger?: Logger;
|
|
33
|
-
cache?: Cache;
|
|
34
29
|
}
|
|
35
30
|
export declare class VercelPgSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<VercelPgQueryResultHKT, TFullSchema, TSchema> {
|
|
36
31
|
private client;
|
|
@@ -38,12 +33,8 @@ export declare class VercelPgSession<TFullSchema extends Record<string, unknown>
|
|
|
38
33
|
private options;
|
|
39
34
|
static readonly [entityKind]: string;
|
|
40
35
|
private logger;
|
|
41
|
-
private cache;
|
|
42
36
|
constructor(client: VercelPgClient, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: VercelPgSessionOptions);
|
|
43
|
-
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']
|
|
44
|
-
type: 'select' | 'update' | 'delete' | 'insert';
|
|
45
|
-
tables: string[];
|
|
46
|
-
}, cacheConfig?: WithCacheConfig): PgPreparedQuery<T>;
|
|
37
|
+
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']): PgPreparedQuery<T>;
|
|
47
38
|
query(query: string, params: unknown[]): Promise<QueryResult>;
|
|
48
39
|
queryObjects<T extends QueryResultRow>(query: string, params: unknown[]): Promise<QueryResult<T>>;
|
|
49
40
|
count(sql: SQL): Promise<number>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { type QueryResult, type QueryResultRow, type VercelClient, VercelPool, type VercelPoolClient } from '@vercel/postgres';
|
|
2
|
-
import type { Cache } from "../cache/core/cache.js";
|
|
3
2
|
import { entityKind } from "../entity.js";
|
|
4
3
|
import { type Logger } from "../logger.js";
|
|
5
4
|
import { type PgDialect, PgTransaction } from "../pg-core/index.js";
|
|
6
|
-
import type { SelectedFieldsOrdered
|
|
5
|
+
import type { SelectedFieldsOrdered } from "../pg-core/query-builders/select.types.js";
|
|
7
6
|
import type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from "../pg-core/session.js";
|
|
8
7
|
import { PgPreparedQuery, PgSession } from "../pg-core/session.js";
|
|
9
8
|
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.js";
|
|
@@ -20,17 +19,13 @@ export declare class VercelPgPreparedQuery<T extends PreparedQueryConfig> extend
|
|
|
20
19
|
static readonly [entityKind]: string;
|
|
21
20
|
private rawQuery;
|
|
22
21
|
private queryConfig;
|
|
23
|
-
constructor(client: VercelPgClient, queryString: string, params: unknown[], logger: Logger,
|
|
24
|
-
type: 'select' | 'update' | 'delete' | 'insert';
|
|
25
|
-
tables: string[];
|
|
26
|
-
} | undefined, cacheConfig: WithCacheConfig | undefined, fields: SelectedFieldsOrdered | undefined, name: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
|
22
|
+
constructor(client: VercelPgClient, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, name: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
|
27
23
|
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
28
24
|
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
|
29
25
|
values(placeholderValues?: Record<string, unknown> | undefined): Promise<T['values']>;
|
|
30
26
|
}
|
|
31
27
|
export interface VercelPgSessionOptions {
|
|
32
28
|
logger?: Logger;
|
|
33
|
-
cache?: Cache;
|
|
34
29
|
}
|
|
35
30
|
export declare class VercelPgSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<VercelPgQueryResultHKT, TFullSchema, TSchema> {
|
|
36
31
|
private client;
|
|
@@ -38,12 +33,8 @@ export declare class VercelPgSession<TFullSchema extends Record<string, unknown>
|
|
|
38
33
|
private options;
|
|
39
34
|
static readonly [entityKind]: string;
|
|
40
35
|
private logger;
|
|
41
|
-
private cache;
|
|
42
36
|
constructor(client: VercelPgClient, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: VercelPgSessionOptions);
|
|
43
|
-
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']
|
|
44
|
-
type: 'select' | 'update' | 'delete' | 'insert';
|
|
45
|
-
tables: string[];
|
|
46
|
-
}, cacheConfig?: WithCacheConfig): PgPreparedQuery<T>;
|
|
37
|
+
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']): PgPreparedQuery<T>;
|
|
47
38
|
query(query: string, params: unknown[]): Promise<QueryResult>;
|
|
48
39
|
queryObjects<T extends QueryResultRow>(query: string, params: unknown[]): Promise<QueryResult<T>>;
|
|
49
40
|
count(sql: SQL): Promise<number>;
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
types,
|
|
3
3
|
VercelPool
|
|
4
4
|
} from "@vercel/postgres";
|
|
5
|
-
import { NoopCache } from "../cache/core/cache.js";
|
|
6
5
|
import { entityKind } from "../entity.js";
|
|
7
6
|
import { NoopLogger } from "../logger.js";
|
|
8
7
|
import { PgTransaction } from "../pg-core/index.js";
|
|
@@ -10,8 +9,8 @@ import { PgPreparedQuery, PgSession } from "../pg-core/session.js";
|
|
|
10
9
|
import { fillPlaceholders, sql } from "../sql/sql.js";
|
|
11
10
|
import { mapResultRow } from "../utils.js";
|
|
12
11
|
class VercelPgPreparedQuery extends PgPreparedQuery {
|
|
13
|
-
constructor(client, queryString, params, logger,
|
|
14
|
-
super({ sql: queryString, params }
|
|
12
|
+
constructor(client, queryString, params, logger, fields, name, _isResponseInArrayMode, customResultMapper) {
|
|
13
|
+
super({ sql: queryString, params });
|
|
15
14
|
this.client = client;
|
|
16
15
|
this.params = params;
|
|
17
16
|
this.logger = logger;
|
|
@@ -72,13 +71,9 @@ class VercelPgPreparedQuery extends PgPreparedQuery {
|
|
|
72
71
|
this.logger.logQuery(this.rawQuery.text, params);
|
|
73
72
|
const { fields, rawQuery, client, queryConfig: query, joinsNotNullableMap, customResultMapper } = this;
|
|
74
73
|
if (!fields && !customResultMapper) {
|
|
75
|
-
return
|
|
76
|
-
return await client.query(rawQuery, params);
|
|
77
|
-
});
|
|
74
|
+
return client.query(rawQuery, params);
|
|
78
75
|
}
|
|
79
|
-
const { rows } = await
|
|
80
|
-
return await client.query(query, params);
|
|
81
|
-
});
|
|
76
|
+
const { rows } = await client.query(query, params);
|
|
82
77
|
if (customResultMapper) {
|
|
83
78
|
return customResultMapper(rows);
|
|
84
79
|
}
|
|
@@ -87,16 +82,12 @@ class VercelPgPreparedQuery extends PgPreparedQuery {
|
|
|
87
82
|
all(placeholderValues = {}) {
|
|
88
83
|
const params = fillPlaceholders(this.params, placeholderValues);
|
|
89
84
|
this.logger.logQuery(this.rawQuery.text, params);
|
|
90
|
-
return this.
|
|
91
|
-
return await this.client.query(this.rawQuery, params);
|
|
92
|
-
}).then((result) => result.rows);
|
|
85
|
+
return this.client.query(this.rawQuery, params).then((result) => result.rows);
|
|
93
86
|
}
|
|
94
87
|
values(placeholderValues = {}) {
|
|
95
88
|
const params = fillPlaceholders(this.params, placeholderValues);
|
|
96
89
|
this.logger.logQuery(this.rawQuery.text, params);
|
|
97
|
-
return this.
|
|
98
|
-
return await this.client.query(this.queryConfig, params);
|
|
99
|
-
}).then((result) => result.rows);
|
|
90
|
+
return this.client.query(this.queryConfig, params).then((result) => result.rows);
|
|
100
91
|
}
|
|
101
92
|
/** @internal */
|
|
102
93
|
isResponseInArrayMode() {
|
|
@@ -110,20 +101,15 @@ class VercelPgSession extends PgSession {
|
|
|
110
101
|
this.schema = schema;
|
|
111
102
|
this.options = options;
|
|
112
103
|
this.logger = options.logger ?? new NoopLogger();
|
|
113
|
-
this.cache = options.cache ?? new NoopCache();
|
|
114
104
|
}
|
|
115
105
|
static [entityKind] = "VercelPgSession";
|
|
116
106
|
logger;
|
|
117
|
-
|
|
118
|
-
prepareQuery(query, fields, name, isResponseInArrayMode, customResultMapper, queryMetadata, cacheConfig) {
|
|
107
|
+
prepareQuery(query, fields, name, isResponseInArrayMode, customResultMapper) {
|
|
119
108
|
return new VercelPgPreparedQuery(
|
|
120
109
|
this.client,
|
|
121
110
|
query.sql,
|
|
122
111
|
query.params,
|
|
123
112
|
this.logger,
|
|
124
|
-
this.cache,
|
|
125
|
-
queryMetadata,
|
|
126
|
-
cacheConfig,
|
|
127
113
|
fields,
|
|
128
114
|
name,
|
|
129
115
|
isResponseInArrayMode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/vercel-postgres/session.ts"],"sourcesContent":["import {\n\ttype QueryArrayConfig,\n\ttype QueryConfig,\n\ttype QueryResult,\n\ttype QueryResultRow,\n\ttypes,\n\ttype VercelClient,\n\tVercelPool,\n\ttype VercelPoolClient,\n} from '@vercel/postgres';\nimport type { Cache } from '~/cache/core/cache.ts';\nimport { NoopCache } from '~/cache/core/cache.ts';\nimport { entityKind } from '~/entity.ts';\nimport { type Logger, NoopLogger } from '~/logger.ts';\nimport { type PgDialect, PgTransaction } from '~/pg-core/index.ts';\nimport type { SelectedFieldsOrdered, WithCacheConfig } from '~/pg-core/query-builders/select.types.ts';\nimport type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from '~/pg-core/session.ts';\nimport { PgPreparedQuery, PgSession } from '~/pg-core/session.ts';\nimport type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type Query, type SQL, sql } from '~/sql/sql.ts';\nimport { type Assume, mapResultRow } from '~/utils.ts';\n\nexport type VercelPgClient = VercelPool | VercelClient | VercelPoolClient;\n\nexport class VercelPgPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {\n\tstatic override readonly [entityKind]: string = 'VercelPgPreparedQuery';\n\n\tprivate rawQuery: QueryConfig;\n\tprivate queryConfig: QueryArrayConfig;\n\n\tconstructor(\n\t\tprivate client: VercelPgClient,\n\t\tqueryString: string,\n\t\tprivate params: unknown[],\n\t\tprivate logger: Logger,\n\t\tcache: Cache,\n\t\tqueryMetadata: {\n\t\t\ttype: 'select' | 'update' | 'delete' | 'insert';\n\t\t\ttables: string[];\n\t\t} | undefined,\n\t\tcacheConfig: WithCacheConfig | undefined,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tprivate _isResponseInArrayMode: boolean,\n\t\tprivate customResultMapper?: (rows: unknown[][]) => T['execute'],\n\t) {\n\t\tsuper({ sql: queryString, params }, cache, queryMetadata, cacheConfig);\n\t\tthis.rawQuery = {\n\t\t\tname,\n\t\t\ttext: queryString,\n\t\t\ttypes: {\n\t\t\t\t// @ts-ignore\n\t\t\t\tgetTypeParser: (typeId, format) => {\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMPTZ) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMP) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.DATE) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.INTERVAL) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\treturn types.getTypeParser(typeId, format);\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t\tthis.queryConfig = {\n\t\t\tname,\n\t\t\ttext: queryString,\n\t\t\trowMode: 'array',\n\t\t\ttypes: {\n\t\t\t\t// @ts-ignore\n\t\t\t\tgetTypeParser: (typeId, format) => {\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMPTZ) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMP) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.DATE) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.INTERVAL) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\treturn types.getTypeParser(typeId, format);\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\tasync execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\n\t\tthis.logger.logQuery(this.rawQuery.text, params);\n\n\t\tconst { fields, rawQuery, client, queryConfig: query, joinsNotNullableMap, customResultMapper } = this;\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn this.queryWithCache(rawQuery.text, params, async () => {\n\t\t\t\treturn await client.query(rawQuery, params);\n\t\t\t});\n\t\t}\n\n\t\tconst { rows } = await this.queryWithCache(query.text, params, async () => {\n\t\t\treturn await client.query(query, params);\n\t\t});\n\n\t\tif (customResultMapper) {\n\t\t\treturn customResultMapper(rows);\n\t\t}\n\n\t\treturn rows.map((row) => mapResultRow<T['execute']>(fields!, row, joinsNotNullableMap));\n\t}\n\n\tall(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['all']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\t\tthis.logger.logQuery(this.rawQuery.text, params);\n\t\treturn this.queryWithCache(this.rawQuery.text, params, async () => {\n\t\t\treturn await this.client.query(this.rawQuery, params);\n\t\t}).then((result) => result.rows);\n\t}\n\n\tvalues(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['values']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\t\tthis.logger.logQuery(this.rawQuery.text, params);\n\t\treturn this.queryWithCache(this.queryConfig.text, params, async () => {\n\t\t\treturn await this.client.query(this.queryConfig, params);\n\t\t}).then((result) => result.rows);\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface VercelPgSessionOptions {\n\tlogger?: Logger;\n\tcache?: Cache;\n}\n\nexport class VercelPgSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgSession<VercelPgQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'VercelPgSession';\n\n\tprivate logger: Logger;\n\tprivate cache: Cache;\n\n\tconstructor(\n\t\tprivate client: VercelPgClient,\n\t\tdialect: PgDialect,\n\t\tprivate schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: VercelPgSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t\tthis.cache = options.cache ?? new NoopCache();\n\t}\n\n\tprepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\tqueryMetadata?: {\n\t\t\ttype: 'select' | 'update' | 'delete' | 'insert';\n\t\t\ttables: string[];\n\t\t},\n\t\tcacheConfig?: WithCacheConfig,\n\t): PgPreparedQuery<T> {\n\t\treturn new VercelPgPreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery.sql,\n\t\t\tquery.params,\n\t\t\tthis.logger,\n\t\t\tthis.cache,\n\t\t\tqueryMetadata,\n\t\t\tcacheConfig,\n\t\t\tfields,\n\t\t\tname,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\tasync query(query: string, params: unknown[]): Promise<QueryResult> {\n\t\tthis.logger.logQuery(query, params);\n\t\tconst result = await this.client.query({\n\t\t\trowMode: 'array',\n\t\t\ttext: query,\n\t\t\tvalues: params,\n\t\t});\n\t\treturn result;\n\t}\n\n\tasync queryObjects<T extends QueryResultRow>(\n\t\tquery: string,\n\t\tparams: unknown[],\n\t): Promise<QueryResult<T>> {\n\t\treturn this.client.query<T>(query, params);\n\t}\n\n\toverride async count(sql: SQL): Promise<number> {\n\t\tconst result = await this.execute(sql);\n\n\t\treturn Number((result as any)['rows'][0]['count']);\n\t}\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t\tconfig?: PgTransactionConfig | undefined,\n\t): Promise<T> {\n\t\tconst session = this.client instanceof VercelPool // eslint-disable-line no-instanceof/no-instanceof\n\t\t\t? new VercelPgSession(await this.client.connect(), this.dialect, this.schema, this.options)\n\t\t\t: this;\n\t\tconst tx = new VercelPgTransaction<TFullSchema, TSchema>(this.dialect, session, this.schema);\n\t\tawait tx.execute(sql`begin${config ? sql` ${tx.getTransactionConfigSQL(config)}` : undefined}`);\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait tx.execute(sql`commit`);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tawait tx.execute(sql`rollback`);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tif (this.client instanceof VercelPool) { // eslint-disable-line no-instanceof/no-instanceof\n\t\t\t\t(session.client as VercelPoolClient).release();\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport class VercelPgTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgTransaction<VercelPgQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'VercelPgTransaction';\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new VercelPgTransaction<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 tx.execute(sql.raw(`savepoint ${savepointName}`));\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait tx.execute(sql.raw(`release savepoint ${savepointName}`));\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tawait tx.execute(sql.raw(`rollback to savepoint ${savepointName}`));\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n\nexport interface VercelPgQueryResultHKT extends PgQueryResultHKT {\n\ttype: QueryResult<Assume<this['row'], QueryResultRow>>;\n}\n"],"mappings":"AAAA;AAAA,EAKC;AAAA,EAEA;AAAA,OAEM;AAEP,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAsB,kBAAkB;AACxC,SAAyB,qBAAqB;AAG9C,SAAS,iBAAiB,iBAAiB;AAE3C,SAAS,kBAAwC,WAAW;AAC5D,SAAsB,oBAAoB;AAInC,MAAM,8BAA6D,gBAAmB;AAAA,EAM5F,YACS,QACR,aACQ,QACA,QACR,OACA,eAIA,aACQ,QACR,MACQ,wBACA,oBACP;AACD,UAAM,EAAE,KAAK,aAAa,OAAO,GAAG,OAAO,eAAe,WAAW;AAf7D;AAEA;AACA;AAOA;AAEA;AACA;AAGR,SAAK,WAAW;AAAA,MACf;AAAA,MACA,MAAM;AAAA,MACN,OAAO;AAAA;AAAA,QAEN,eAAe,CAAC,QAAQ,WAAW;AAClC,cAAI,WAAW,MAAM,SAAS,aAAa;AAC1C,mBAAO,CAAC,QAAa;AAAA,UACtB;AACA,cAAI,WAAW,MAAM,SAAS,WAAW;AACxC,mBAAO,CAAC,QAAa;AAAA,UACtB;AACA,cAAI,WAAW,MAAM,SAAS,MAAM;AACnC,mBAAO,CAAC,QAAa;AAAA,UACtB;AACA,cAAI,WAAW,MAAM,SAAS,UAAU;AACvC,mBAAO,CAAC,QAAa;AAAA,UACtB;AAEA,iBAAO,MAAM,cAAc,QAAQ,MAAM;AAAA,QAC1C;AAAA,MACD;AAAA,IACD;AACA,SAAK,cAAc;AA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AAI,IAAI,aAAa,aAAa,EAAE,CAAC;AACtD,QAAI;AACH,YAAM,SAAS,MAAM,YAAY,EAAE;AACnC,YAAM,GAAG,QAAQ,IAAI,IAAI,qBAAqB,aAAa,EAAE,CAAC;AAC9D,aAAO;AAAA,IACR,SAAS,KAAK;AACb,YAAM,GAAG,QAAQ,IAAI,IAAI,yBAAyB,aAAa,EAAE,CAAC;AAClE,YAAM;AAAA,IACP;AAAA,EACD;AACD;","names":["sql"]}
|
|
1
|
+
{"version":3,"sources":["../../src/vercel-postgres/session.ts"],"sourcesContent":["import {\n\ttype QueryArrayConfig,\n\ttype QueryConfig,\n\ttype QueryResult,\n\ttype QueryResultRow,\n\ttypes,\n\ttype VercelClient,\n\tVercelPool,\n\ttype VercelPoolClient,\n} from '@vercel/postgres';\nimport { entityKind } from '~/entity.ts';\nimport { type Logger, NoopLogger } from '~/logger.ts';\nimport { type PgDialect, PgTransaction } from '~/pg-core/index.ts';\nimport type { SelectedFieldsOrdered } from '~/pg-core/query-builders/select.types.ts';\nimport type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from '~/pg-core/session.ts';\nimport { PgPreparedQuery, PgSession } from '~/pg-core/session.ts';\nimport type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type Query, type SQL, sql } from '~/sql/sql.ts';\nimport { type Assume, mapResultRow } from '~/utils.ts';\n\nexport type VercelPgClient = VercelPool | VercelClient | VercelPoolClient;\n\nexport class VercelPgPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {\n\tstatic override readonly [entityKind]: string = 'VercelPgPreparedQuery';\n\n\tprivate rawQuery: QueryConfig;\n\tprivate queryConfig: QueryArrayConfig;\n\n\tconstructor(\n\t\tprivate client: VercelPgClient,\n\t\tqueryString: string,\n\t\tprivate params: unknown[],\n\t\tprivate logger: Logger,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\tname: 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 = {\n\t\t\tname,\n\t\t\ttext: queryString,\n\t\t\ttypes: {\n\t\t\t\t// @ts-ignore\n\t\t\t\tgetTypeParser: (typeId, format) => {\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMPTZ) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMP) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.DATE) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.INTERVAL) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\treturn types.getTypeParser(typeId, format);\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t\tthis.queryConfig = {\n\t\t\tname,\n\t\t\ttext: queryString,\n\t\t\trowMode: 'array',\n\t\t\ttypes: {\n\t\t\t\t// @ts-ignore\n\t\t\t\tgetTypeParser: (typeId, format) => {\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMPTZ) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMP) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.DATE) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.INTERVAL) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\treturn types.getTypeParser(typeId, format);\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\tasync execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\n\t\tthis.logger.logQuery(this.rawQuery.text, params);\n\n\t\tconst { fields, rawQuery, client, queryConfig: query, joinsNotNullableMap, customResultMapper } = this;\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn client.query(rawQuery, params);\n\t\t}\n\n\t\tconst { rows } = await client.query(query, params);\n\n\t\tif (customResultMapper) {\n\t\t\treturn customResultMapper(rows);\n\t\t}\n\n\t\treturn rows.map((row) => mapResultRow<T['execute']>(fields!, row, joinsNotNullableMap));\n\t}\n\n\tall(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['all']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\t\tthis.logger.logQuery(this.rawQuery.text, params);\n\t\treturn this.client.query(this.rawQuery, params).then((result) => result.rows);\n\t}\n\n\tvalues(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['values']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\t\tthis.logger.logQuery(this.rawQuery.text, params);\n\t\treturn this.client.query(this.queryConfig, params).then((result) => result.rows);\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface VercelPgSessionOptions {\n\tlogger?: Logger;\n}\n\nexport class VercelPgSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgSession<VercelPgQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'VercelPgSession';\n\n\tprivate logger: Logger;\n\n\tconstructor(\n\t\tprivate client: VercelPgClient,\n\t\tdialect: PgDialect,\n\t\tprivate schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: VercelPgSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t}\n\n\tprepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t): PgPreparedQuery<T> {\n\t\treturn new VercelPgPreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery.sql,\n\t\t\tquery.params,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\tname,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\tasync query(query: string, params: unknown[]): Promise<QueryResult> {\n\t\tthis.logger.logQuery(query, params);\n\t\tconst result = await this.client.query({\n\t\t\trowMode: 'array',\n\t\t\ttext: query,\n\t\t\tvalues: params,\n\t\t});\n\t\treturn result;\n\t}\n\n\tasync queryObjects<T extends QueryResultRow>(\n\t\tquery: string,\n\t\tparams: unknown[],\n\t): Promise<QueryResult<T>> {\n\t\treturn this.client.query<T>(query, params);\n\t}\n\n\toverride async count(sql: SQL): Promise<number> {\n\t\tconst result = await this.execute(sql);\n\n\t\treturn Number((result as any)['rows'][0]['count']);\n\t}\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t\tconfig?: PgTransactionConfig | undefined,\n\t): Promise<T> {\n\t\tconst session = this.client instanceof VercelPool // eslint-disable-line no-instanceof/no-instanceof\n\t\t\t? new VercelPgSession(await this.client.connect(), this.dialect, this.schema, this.options)\n\t\t\t: this;\n\t\tconst tx = new VercelPgTransaction<TFullSchema, TSchema>(this.dialect, session, this.schema);\n\t\tawait tx.execute(sql`begin${config ? sql` ${tx.getTransactionConfigSQL(config)}` : undefined}`);\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait tx.execute(sql`commit`);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tawait tx.execute(sql`rollback`);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tif (this.client instanceof VercelPool) { // eslint-disable-line no-instanceof/no-instanceof\n\t\t\t\t(session.client as VercelPoolClient).release();\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport class VercelPgTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgTransaction<VercelPgQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'VercelPgTransaction';\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new VercelPgTransaction<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 tx.execute(sql.raw(`savepoint ${savepointName}`));\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait tx.execute(sql.raw(`release savepoint ${savepointName}`));\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tawait tx.execute(sql.raw(`rollback to savepoint ${savepointName}`));\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n\nexport interface VercelPgQueryResultHKT extends PgQueryResultHKT {\n\ttype: QueryResult<Assume<this['row'], QueryResultRow>>;\n}\n"],"mappings":"AAAA;AAAA,EAKC;AAAA,EAEA;AAAA,OAEM;AACP,SAAS,kBAAkB;AAC3B,SAAsB,kBAAkB;AACxC,SAAyB,qBAAqB;AAG9C,SAAS,iBAAiB,iBAAiB;AAE3C,SAAS,kBAAwC,WAAW;AAC5D,SAAsB,oBAAoB;AAInC,MAAM,8BAA6D,gBAAmB;AAAA,EAM5F,YACS,QACR,aACQ,QACA,QACA,QACR,MACQ,wBACA,oBACP;AACD,UAAM,EAAE,KAAK,aAAa,OAAO,CAAC;AAT1B;AAEA;AACA;AACA;AAEA;AACA;AAGR,SAAK,WAAW;AAAA,MACf;AAAA,MACA,MAAM;AAAA,MACN,OAAO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