drizzle-orm 1.0.0-beta.1-199e5ec → 1.0.0-beta.1-388a474
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 +6 -1
- package/aws-data-api/pg/driver.cjs.map +1 -1
- package/aws-data-api/pg/driver.d.cts +1 -0
- package/aws-data-api/pg/driver.d.ts +1 -0
- package/aws-data-api/pg/driver.js +6 -1
- package/aws-data-api/pg/driver.js.map +1 -1
- package/aws-data-api/pg/session.cjs +19 -6
- package/aws-data-api/pg/session.cjs.map +1 -1
- package/aws-data-api/pg/session.d.cts +13 -2
- package/aws-data-api/pg/session.d.ts +13 -2
- package/aws-data-api/pg/session.js +19 -6
- package/aws-data-api/pg/session.js.map +1 -1
- package/better-sqlite3/driver.cjs +1 -2
- package/better-sqlite3/driver.cjs.map +1 -1
- package/better-sqlite3/driver.js +1 -2
- package/better-sqlite3/driver.js.map +1 -1
- package/better-sqlite3/session.cjs +15 -9
- package/better-sqlite3/session.cjs.map +1 -1
- package/better-sqlite3/session.d.cts +12 -2
- package/better-sqlite3/session.d.ts +12 -2
- package/better-sqlite3/session.js +15 -9
- package/better-sqlite3/session.js.map +1 -1
- package/bun-sql/driver.cjs +6 -3
- package/bun-sql/driver.cjs.map +1 -1
- package/bun-sql/driver.js +6 -3
- package/bun-sql/driver.js.map +1 -1
- package/bun-sql/session.cjs +25 -11
- package/bun-sql/session.cjs.map +1 -1
- package/bun-sql/session.d.cts +12 -2
- package/bun-sql/session.d.ts +12 -2
- package/bun-sql/session.js +25 -11
- package/bun-sql/session.js.map +1 -1
- package/bun-sqlite/driver.cjs +1 -2
- package/bun-sqlite/driver.cjs.map +1 -1
- package/bun-sqlite/driver.js +1 -2
- package/bun-sqlite/driver.js.map +1 -1
- package/bun-sqlite/session.cjs +3 -6
- package/bun-sqlite/session.cjs.map +1 -1
- package/bun-sqlite/session.js +3 -6
- package/bun-sqlite/session.js.map +1 -1
- package/cache/core/cache.cjs +58 -0
- package/cache/core/cache.cjs.map +1 -0
- package/cache/core/cache.d.cts +36 -0
- package/cache/core/cache.d.ts +36 -0
- package/cache/core/cache.js +32 -0
- package/cache/core/cache.js.map +1 -0
- package/cache/core/index.cjs +23 -0
- package/cache/core/index.cjs.map +1 -0
- package/cache/core/index.d.cts +1 -0
- package/cache/core/index.d.ts +1 -0
- package/cache/core/index.js +2 -0
- package/cache/core/index.js.map +1 -0
- package/cache/core/types.cjs +17 -0
- package/cache/core/types.cjs.map +1 -0
- package/cache/core/types.d.cts +33 -0
- package/cache/core/types.d.ts +33 -0
- package/cache/core/types.js +1 -0
- package/cache/core/types.js.map +1 -0
- package/cache/upstash/cache.cjs +195 -0
- package/cache/upstash/cache.cjs.map +1 -0
- package/cache/upstash/cache.d.cts +59 -0
- package/cache/upstash/cache.d.ts +59 -0
- package/cache/upstash/cache.js +170 -0
- package/cache/upstash/cache.js.map +1 -0
- package/cache/upstash/index.cjs +23 -0
- package/cache/upstash/index.cjs.map +1 -0
- package/cache/upstash/index.d.cts +1 -0
- package/cache/upstash/index.d.ts +1 -0
- package/cache/upstash/index.js +2 -0
- package/cache/upstash/index.js.map +1 -0
- package/casing.cjs +2 -4
- package/casing.cjs.map +1 -1
- package/casing.js +2 -4
- package/casing.js.map +1 -1
- package/column-builder.cjs +1 -2
- package/column-builder.cjs.map +1 -1
- package/column-builder.js +1 -2
- package/column-builder.js.map +1 -1
- package/d1/driver.cjs +8 -1
- package/d1/driver.cjs.map +1 -1
- package/d1/driver.js +8 -1
- package/d1/driver.js.map +1 -1
- package/d1/session.cjs +28 -13
- package/d1/session.cjs.map +1 -1
- package/d1/session.d.cts +12 -2
- package/d1/session.d.ts +12 -2
- package/d1/session.js +28 -13
- package/d1/session.js.map +1 -1
- package/durable-sqlite/session.cjs +3 -5
- package/durable-sqlite/session.cjs.map +1 -1
- package/durable-sqlite/session.js +3 -5
- package/durable-sqlite/session.js.map +1 -1
- package/errors.cjs +14 -0
- package/errors.cjs.map +1 -1
- package/errors.d.cts +7 -0
- package/errors.d.ts +7 -0
- package/errors.js +13 -0
- package/errors.js.map +1 -1
- package/expo-sqlite/session.cjs +2 -4
- package/expo-sqlite/session.cjs.map +1 -1
- package/expo-sqlite/session.js +2 -4
- package/expo-sqlite/session.js.map +1 -1
- package/gel/driver.cjs +10 -4
- package/gel/driver.cjs.map +1 -1
- package/gel/driver.d.cts +3 -1
- package/gel/driver.d.ts +3 -1
- package/gel/driver.js +10 -4
- package/gel/driver.js.map +1 -1
- package/gel/session.cjs +29 -12
- package/gel/session.cjs.map +1 -1
- package/gel/session.d.cts +12 -2
- package/gel/session.d.ts +12 -2
- package/gel/session.js +29 -12
- package/gel/session.js.map +1 -1
- package/gel-core/columns/custom.cjs +1 -2
- package/gel-core/columns/custom.cjs.map +1 -1
- package/gel-core/columns/custom.js +1 -2
- package/gel-core/columns/custom.js.map +1 -1
- package/gel-core/columns/timestamptz.cjs +1 -2
- package/gel-core/columns/timestamptz.cjs.map +1 -1
- package/gel-core/columns/timestamptz.js +1 -2
- package/gel-core/columns/timestamptz.js.map +1 -1
- package/gel-core/db.cjs +3 -0
- package/gel-core/db.cjs.map +1 -1
- package/gel-core/db.d.cts +4 -0
- package/gel-core/db.d.ts +4 -0
- package/gel-core/db.js +3 -0
- package/gel-core/db.js.map +1 -1
- package/gel-core/dialect.cjs +9 -16
- package/gel-core/dialect.cjs.map +1 -1
- package/gel-core/dialect.js +9 -16
- package/gel-core/dialect.js.map +1 -1
- package/gel-core/query-builders/delete.cjs +5 -1
- package/gel-core/query-builders/delete.cjs.map +1 -1
- package/gel-core/query-builders/delete.js +5 -1
- package/gel-core/query-builders/delete.js.map +1 -1
- package/gel-core/query-builders/insert.cjs +5 -1
- package/gel-core/query-builders/insert.cjs.map +1 -1
- package/gel-core/query-builders/insert.js +5 -1
- package/gel-core/query-builders/insert.js.map +1 -1
- package/gel-core/query-builders/select.cjs +26 -4
- package/gel-core/query-builders/select.cjs.map +1 -1
- package/gel-core/query-builders/select.d.cts +18 -9
- package/gel-core/query-builders/select.d.ts +18 -9
- package/gel-core/query-builders/select.js +26 -4
- package/gel-core/query-builders/select.js.map +1 -1
- package/gel-core/query-builders/select.types.cjs.map +1 -1
- package/gel-core/query-builders/select.types.d.cts +2 -1
- package/gel-core/query-builders/select.types.d.ts +2 -1
- package/gel-core/query-builders/update.cjs +5 -1
- package/gel-core/query-builders/update.cjs.map +1 -1
- package/gel-core/query-builders/update.js +5 -1
- package/gel-core/query-builders/update.js.map +1 -1
- package/gel-core/session.cjs +77 -1
- package/gel-core/session.cjs.map +1 -1
- package/gel-core/session.d.cts +13 -2
- package/gel-core/session.d.ts +13 -2
- package/gel-core/session.js +79 -3
- package/gel-core/session.js.map +1 -1
- package/gel-core/utils.cjs +16 -0
- package/gel-core/utils.cjs.map +1 -1
- package/gel-core/utils.d.cts +8 -4
- package/gel-core/utils.d.ts +8 -4
- package/gel-core/utils.js +15 -0
- package/gel-core/utils.js.map +1 -1
- package/index.cjs +16 -16
- package/index.cjs.map +1 -1
- package/libsql/driver-core.cjs +5 -1
- package/libsql/driver-core.cjs.map +1 -1
- package/libsql/driver-core.js +5 -1
- package/libsql/driver-core.js.map +1 -1
- package/libsql/driver.cjs +1 -2
- package/libsql/driver.cjs.map +1 -1
- package/libsql/driver.js +1 -2
- package/libsql/driver.js.map +1 -1
- package/libsql/http/index.cjs +1 -2
- package/libsql/http/index.cjs.map +1 -1
- package/libsql/http/index.js +1 -2
- package/libsql/http/index.js.map +1 -1
- package/libsql/node/index.cjs +1 -2
- package/libsql/node/index.cjs.map +1 -1
- package/libsql/node/index.js +1 -2
- package/libsql/node/index.js.map +1 -1
- package/libsql/session.cjs +33 -19
- package/libsql/session.cjs.map +1 -1
- package/libsql/session.d.cts +12 -2
- package/libsql/session.d.ts +12 -2
- package/libsql/session.js +33 -19
- package/libsql/session.js.map +1 -1
- package/libsql/sqlite3/index.cjs +1 -2
- package/libsql/sqlite3/index.cjs.map +1 -1
- package/libsql/sqlite3/index.js +1 -2
- package/libsql/sqlite3/index.js.map +1 -1
- package/libsql/wasm/index.cjs +1 -2
- package/libsql/wasm/index.cjs.map +1 -1
- package/libsql/wasm/index.js +1 -2
- package/libsql/wasm/index.js.map +1 -1
- package/libsql/web/index.cjs +1 -2
- package/libsql/web/index.cjs.map +1 -1
- package/libsql/web/index.js +1 -2
- package/libsql/web/index.js.map +1 -1
- package/libsql/ws/index.cjs +1 -2
- package/libsql/ws/index.cjs.map +1 -1
- package/libsql/ws/index.js +1 -2
- package/libsql/ws/index.js.map +1 -1
- package/mysql-core/columns/binary.cjs +2 -4
- package/mysql-core/columns/binary.cjs.map +1 -1
- package/mysql-core/columns/binary.js +2 -4
- package/mysql-core/columns/binary.js.map +1 -1
- package/mysql-core/columns/custom.cjs +1 -2
- package/mysql-core/columns/custom.cjs.map +1 -1
- package/mysql-core/columns/custom.js +1 -2
- package/mysql-core/columns/custom.js.map +1 -1
- package/mysql-core/columns/decimal.cjs +2 -4
- package/mysql-core/columns/decimal.cjs.map +1 -1
- package/mysql-core/columns/decimal.js +2 -4
- package/mysql-core/columns/decimal.js.map +1 -1
- package/mysql-core/columns/varbinary.cjs +2 -4
- package/mysql-core/columns/varbinary.cjs.map +1 -1
- package/mysql-core/columns/varbinary.js +2 -4
- package/mysql-core/columns/varbinary.js.map +1 -1
- package/mysql-core/db.cjs +17 -0
- package/mysql-core/db.cjs.map +1 -1
- package/mysql-core/db.d.cts +4 -0
- package/mysql-core/db.d.ts +4 -0
- package/mysql-core/db.js +17 -0
- package/mysql-core/db.js.map +1 -1
- package/mysql-core/dialect.cjs +8 -16
- package/mysql-core/dialect.cjs.map +1 -1
- package/mysql-core/dialect.js +8 -16
- package/mysql-core/dialect.js.map +1 -1
- package/mysql-core/query-builders/delete.cjs +9 -1
- package/mysql-core/query-builders/delete.cjs.map +1 -1
- package/mysql-core/query-builders/delete.js +9 -1
- package/mysql-core/query-builders/delete.js.map +1 -1
- package/mysql-core/query-builders/insert.cjs +8 -1
- package/mysql-core/query-builders/insert.cjs.map +1 -1
- package/mysql-core/query-builders/insert.d.cts +2 -0
- package/mysql-core/query-builders/insert.d.ts +2 -0
- package/mysql-core/query-builders/insert.js +8 -1
- package/mysql-core/query-builders/insert.js.map +1 -1
- package/mysql-core/query-builders/select.cjs +24 -3
- package/mysql-core/query-builders/select.cjs.map +1 -1
- package/mysql-core/query-builders/select.d.cts +17 -8
- package/mysql-core/query-builders/select.d.ts +17 -8
- package/mysql-core/query-builders/select.js +25 -4
- package/mysql-core/query-builders/select.js.map +1 -1
- package/mysql-core/query-builders/select.types.cjs.map +1 -1
- package/mysql-core/query-builders/select.types.d.cts +2 -1
- package/mysql-core/query-builders/select.types.d.ts +2 -1
- package/mysql-core/query-builders/update.cjs +11 -1
- package/mysql-core/query-builders/update.cjs.map +1 -1
- package/mysql-core/query-builders/update.d.cts +2 -0
- package/mysql-core/query-builders/update.d.ts +2 -0
- package/mysql-core/query-builders/update.js +11 -1
- package/mysql-core/query-builders/update.js.map +1 -1
- package/mysql-core/session.cjs +78 -0
- package/mysql-core/session.cjs.map +1 -1
- package/mysql-core/session.d.cts +14 -1
- package/mysql-core/session.d.ts +14 -1
- package/mysql-core/session.js +80 -2
- package/mysql-core/session.js.map +1 -1
- package/mysql-core/utils.cjs +16 -0
- package/mysql-core/utils.cjs.map +1 -1
- package/mysql-core/utils.d.cts +6 -2
- package/mysql-core/utils.d.ts +6 -2
- package/mysql-core/utils.js +15 -0
- package/mysql-core/utils.js.map +1 -1
- package/mysql-proxy/session.cjs +19 -7
- package/mysql-proxy/session.cjs.map +1 -1
- package/mysql-proxy/session.d.cts +12 -2
- package/mysql-proxy/session.d.ts +12 -2
- package/mysql-proxy/session.js +19 -7
- package/mysql-proxy/session.js.map +1 -1
- package/mysql2/driver.cjs +11 -4
- package/mysql2/driver.cjs.map +1 -1
- package/mysql2/driver.d.cts +3 -1
- package/mysql2/driver.d.ts +3 -1
- package/mysql2/driver.js +11 -4
- package/mysql2/driver.js.map +1 -1
- package/mysql2/session.cjs +19 -7
- package/mysql2/session.cjs.map +1 -1
- package/mysql2/session.d.cts +12 -2
- package/mysql2/session.d.ts +12 -2
- package/mysql2/session.js +19 -7
- package/mysql2/session.js.map +1 -1
- package/neon/index.cjs +2 -2
- package/neon/index.cjs.map +1 -1
- package/neon/index.d.cts +1 -1
- package/neon/index.d.ts +1 -1
- package/neon/index.js +1 -1
- package/neon/index.js.map +1 -1
- package/neon/{neon-identity.cjs → neon-auth.cjs} +6 -5
- package/neon/neon-auth.cjs.map +1 -0
- package/neon/{neon-identity.d.cts → neon-auth.d.cts} +17 -0
- package/neon/{neon-identity.d.ts → neon-auth.d.ts} +17 -0
- package/neon/{neon-identity.js → neon-auth.js} +3 -2
- package/neon/neon-auth.js.map +1 -0
- package/neon-http/driver.cjs +11 -10
- package/neon-http/driver.cjs.map +1 -1
- package/neon-http/driver.d.cts +2 -0
- package/neon-http/driver.d.ts +2 -0
- package/neon-http/driver.js +11 -10
- package/neon-http/driver.js.map +1 -1
- package/neon-http/session.cjs +31 -19
- package/neon-http/session.cjs.map +1 -1
- package/neon-http/session.d.cts +12 -2
- package/neon-http/session.d.ts +12 -2
- package/neon-http/session.js +31 -19
- package/neon-http/session.js.map +1 -1
- package/neon-serverless/driver.cjs +10 -4
- package/neon-serverless/driver.cjs.map +1 -1
- package/neon-serverless/driver.d.cts +3 -1
- package/neon-serverless/driver.d.ts +3 -1
- package/neon-serverless/driver.js +10 -4
- package/neon-serverless/driver.js.map +1 -1
- package/neon-serverless/session.cjs +25 -9
- package/neon-serverless/session.cjs.map +1 -1
- package/neon-serverless/session.d.cts +12 -2
- package/neon-serverless/session.d.ts +12 -2
- package/neon-serverless/session.js +25 -9
- package/neon-serverless/session.js.map +1 -1
- package/node-postgres/driver.cjs +10 -4
- package/node-postgres/driver.cjs.map +1 -1
- package/node-postgres/driver.d.cts +7 -5
- package/node-postgres/driver.d.ts +7 -5
- package/node-postgres/driver.js +10 -4
- package/node-postgres/driver.js.map +1 -1
- package/node-postgres/session.cjs +23 -8
- package/node-postgres/session.cjs.map +1 -1
- package/node-postgres/session.d.cts +13 -2
- package/node-postgres/session.d.ts +13 -2
- package/node-postgres/session.js +23 -8
- package/node-postgres/session.js.map +1 -1
- package/op-sqlite/driver.cjs +5 -1
- package/op-sqlite/driver.cjs.map +1 -1
- package/op-sqlite/driver.js +5 -1
- package/op-sqlite/driver.js.map +1 -1
- package/op-sqlite/session.cjs +28 -13
- package/op-sqlite/session.cjs.map +1 -1
- package/op-sqlite/session.d.cts +12 -2
- package/op-sqlite/session.d.ts +12 -2
- package/op-sqlite/session.js +28 -13
- package/op-sqlite/session.js.map +1 -1
- package/package.json +78 -13
- package/pg-core/columns/bytea.cjs +1 -2
- package/pg-core/columns/bytea.cjs.map +1 -1
- package/pg-core/columns/bytea.js +1 -2
- package/pg-core/columns/bytea.js.map +1 -1
- package/pg-core/columns/common.cjs +1 -2
- package/pg-core/columns/common.cjs.map +1 -1
- package/pg-core/columns/common.js +1 -2
- package/pg-core/columns/common.js.map +1 -1
- package/pg-core/columns/custom.cjs +1 -2
- package/pg-core/columns/custom.cjs.map +1 -1
- package/pg-core/columns/custom.js +1 -2
- package/pg-core/columns/custom.js.map +1 -1
- package/pg-core/columns/numeric.cjs +2 -4
- package/pg-core/columns/numeric.cjs.map +1 -1
- package/pg-core/columns/numeric.js +2 -4
- package/pg-core/columns/numeric.js.map +1 -1
- package/pg-core/columns/postgis_extension/geometry.cjs +1 -2
- package/pg-core/columns/postgis_extension/geometry.cjs.map +1 -1
- package/pg-core/columns/postgis_extension/geometry.js +1 -2
- package/pg-core/columns/postgis_extension/geometry.js.map +1 -1
- package/pg-core/db.cjs +3 -0
- package/pg-core/db.cjs.map +1 -1
- package/pg-core/db.d.cts +4 -0
- package/pg-core/db.d.ts +4 -0
- package/pg-core/db.js +3 -0
- package/pg-core/db.js.map +1 -1
- package/pg-core/dialect.cjs +8 -16
- package/pg-core/dialect.cjs.map +1 -1
- package/pg-core/dialect.js +8 -16
- package/pg-core/dialect.js.map +1 -1
- package/pg-core/query-builders/delete.cjs +6 -1
- package/pg-core/query-builders/delete.cjs.map +1 -1
- package/pg-core/query-builders/delete.d.cts +3 -1
- package/pg-core/query-builders/delete.d.ts +3 -1
- package/pg-core/query-builders/delete.js +6 -1
- package/pg-core/query-builders/delete.js.map +1 -1
- package/pg-core/query-builders/insert.cjs +6 -1
- package/pg-core/query-builders/insert.cjs.map +1 -1
- package/pg-core/query-builders/insert.d.cts +2 -0
- package/pg-core/query-builders/insert.d.ts +2 -0
- package/pg-core/query-builders/insert.js +6 -1
- package/pg-core/query-builders/insert.js.map +1 -1
- package/pg-core/query-builders/select.cjs +28 -5
- package/pg-core/query-builders/select.cjs.map +1 -1
- package/pg-core/query-builders/select.d.cts +19 -10
- package/pg-core/query-builders/select.d.ts +19 -10
- package/pg-core/query-builders/select.js +28 -5
- 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 +2 -1
- package/pg-core/query-builders/select.types.d.ts +2 -1
- package/pg-core/query-builders/update.cjs +6 -1
- package/pg-core/query-builders/update.cjs.map +1 -1
- package/pg-core/query-builders/update.d.cts +4 -2
- package/pg-core/query-builders/update.d.ts +4 -2
- package/pg-core/query-builders/update.js +6 -1
- package/pg-core/query-builders/update.js.map +1 -1
- package/pg-core/session.cjs +77 -1
- package/pg-core/session.cjs.map +1 -1
- package/pg-core/session.d.cts +13 -2
- package/pg-core/session.d.ts +13 -2
- package/pg-core/session.js +79 -3
- package/pg-core/session.js.map +1 -1
- package/pg-core/utils.cjs +16 -0
- package/pg-core/utils.cjs.map +1 -1
- package/pg-core/utils.d.cts +8 -4
- package/pg-core/utils.d.ts +8 -4
- package/pg-core/utils.js +16 -1
- package/pg-core/utils.js.map +1 -1
- package/pg-proxy/driver.cjs +7 -2
- package/pg-proxy/driver.cjs.map +1 -1
- package/pg-proxy/driver.js +7 -2
- package/pg-proxy/driver.js.map +1 -1
- package/pg-proxy/session.cjs +19 -7
- package/pg-proxy/session.cjs.map +1 -1
- package/pg-proxy/session.d.cts +12 -2
- package/pg-proxy/session.d.ts +12 -2
- package/pg-proxy/session.js +19 -7
- package/pg-proxy/session.js.map +1 -1
- package/pglite/driver.cjs +10 -4
- package/pglite/driver.cjs.map +1 -1
- package/pglite/driver.d.cts +2 -0
- package/pglite/driver.d.ts +2 -0
- package/pglite/driver.js +10 -4
- package/pglite/driver.js.map +1 -1
- package/pglite/session.cjs +23 -9
- package/pglite/session.cjs.map +1 -1
- package/pglite/session.d.cts +12 -2
- package/pglite/session.d.ts +12 -2
- package/pglite/session.js +23 -9
- package/pglite/session.js.map +1 -1
- package/planetscale-serverless/driver.cjs +9 -3
- package/planetscale-serverless/driver.cjs.map +1 -1
- package/planetscale-serverless/driver.d.cts +1 -0
- package/planetscale-serverless/driver.d.ts +1 -0
- package/planetscale-serverless/driver.js +9 -3
- package/planetscale-serverless/driver.js.map +1 -1
- package/planetscale-serverless/session.cjs +19 -7
- package/planetscale-serverless/session.cjs.map +1 -1
- package/planetscale-serverless/session.d.cts +12 -2
- package/planetscale-serverless/session.d.ts +12 -2
- package/planetscale-serverless/session.js +19 -7
- package/planetscale-serverless/session.js.map +1 -1
- package/postgres-js/driver.cjs +6 -3
- package/postgres-js/driver.cjs.map +1 -1
- package/postgres-js/driver.js +6 -3
- package/postgres-js/driver.js.map +1 -1
- package/postgres-js/session.cjs +22 -8
- package/postgres-js/session.cjs.map +1 -1
- package/postgres-js/session.d.cts +12 -2
- package/postgres-js/session.d.ts +12 -2
- package/postgres-js/session.js +22 -8
- package/postgres-js/session.js.map +1 -1
- package/prisma/mysql/session.cjs +1 -1
- package/prisma/mysql/session.cjs.map +1 -1
- package/prisma/mysql/session.js +1 -1
- package/prisma/mysql/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 +2 -1
- package/query-builders/query-builder.d.ts +2 -1
- package/query-builders/query-builder.js.map +1 -1
- package/relations.cjs +23 -46
- package/relations.cjs.map +1 -1
- package/relations.js +23 -46
- package/relations.js.map +1 -1
- package/singlestore/driver.cjs +24 -19
- package/singlestore/driver.cjs.map +1 -1
- package/singlestore/driver.d.cts +3 -1
- package/singlestore/driver.d.ts +3 -1
- package/singlestore/driver.js +24 -19
- package/singlestore/driver.js.map +1 -1
- package/singlestore/session.cjs +15 -5
- package/singlestore/session.cjs.map +1 -1
- package/singlestore/session.d.cts +12 -2
- package/singlestore/session.d.ts +12 -2
- package/singlestore/session.js +15 -5
- package/singlestore/session.js.map +1 -1
- package/singlestore-core/columns/binary.cjs +2 -4
- package/singlestore-core/columns/binary.cjs.map +1 -1
- package/singlestore-core/columns/binary.js +2 -4
- package/singlestore-core/columns/binary.js.map +1 -1
- package/singlestore-core/columns/custom.cjs +1 -2
- package/singlestore-core/columns/custom.cjs.map +1 -1
- package/singlestore-core/columns/custom.js +1 -2
- package/singlestore-core/columns/custom.js.map +1 -1
- package/singlestore-core/columns/decimal.cjs +2 -4
- package/singlestore-core/columns/decimal.cjs.map +1 -1
- package/singlestore-core/columns/decimal.js +2 -4
- package/singlestore-core/columns/decimal.js.map +1 -1
- package/singlestore-core/columns/enum.cjs +0 -1
- package/singlestore-core/columns/enum.cjs.map +1 -1
- package/singlestore-core/columns/enum.js +0 -1
- package/singlestore-core/columns/enum.js.map +1 -1
- package/singlestore-core/columns/varbinary.cjs +2 -4
- package/singlestore-core/columns/varbinary.cjs.map +1 -1
- package/singlestore-core/columns/varbinary.js +2 -4
- package/singlestore-core/columns/varbinary.js.map +1 -1
- package/singlestore-core/columns/vector.cjs.map +1 -1
- package/singlestore-core/columns/vector.js.map +1 -1
- package/singlestore-core/db.cjs +3 -0
- package/singlestore-core/db.cjs.map +1 -1
- package/singlestore-core/db.d.cts +4 -0
- package/singlestore-core/db.d.ts +4 -0
- package/singlestore-core/db.js +3 -0
- package/singlestore-core/db.js.map +1 -1
- package/singlestore-core/dialect.cjs +1 -2
- package/singlestore-core/dialect.cjs.map +1 -1
- package/singlestore-core/dialect.js +1 -2
- package/singlestore-core/dialect.js.map +1 -1
- package/singlestore-core/query-builders/delete.cjs +9 -1
- package/singlestore-core/query-builders/delete.cjs.map +1 -1
- package/singlestore-core/query-builders/delete.js +9 -1
- package/singlestore-core/query-builders/delete.js.map +1 -1
- package/singlestore-core/query-builders/insert.cjs +6 -1
- package/singlestore-core/query-builders/insert.cjs.map +1 -1
- package/singlestore-core/query-builders/insert.js +6 -1
- package/singlestore-core/query-builders/insert.js.map +1 -1
- package/singlestore-core/query-builders/select.cjs +25 -3
- package/singlestore-core/query-builders/select.cjs.map +1 -1
- package/singlestore-core/query-builders/select.d.cts +18 -9
- package/singlestore-core/query-builders/select.d.ts +18 -9
- package/singlestore-core/query-builders/select.js +25 -3
- package/singlestore-core/query-builders/select.js.map +1 -1
- package/singlestore-core/query-builders/select.types.cjs.map +1 -1
- package/singlestore-core/query-builders/select.types.d.cts +2 -1
- package/singlestore-core/query-builders/select.types.d.ts +2 -1
- package/singlestore-core/query-builders/update.cjs +9 -1
- package/singlestore-core/query-builders/update.cjs.map +1 -1
- package/singlestore-core/query-builders/update.js +9 -1
- package/singlestore-core/query-builders/update.js.map +1 -1
- package/singlestore-core/session.cjs +78 -0
- package/singlestore-core/session.cjs.map +1 -1
- package/singlestore-core/session.d.cts +13 -1
- package/singlestore-core/session.d.ts +13 -1
- package/singlestore-core/session.js +80 -2
- package/singlestore-core/session.js.map +1 -1
- package/singlestore-core/utils.cjs +16 -0
- package/singlestore-core/utils.cjs.map +1 -1
- package/singlestore-core/utils.d.cts +3 -0
- package/singlestore-core/utils.d.ts +3 -0
- package/singlestore-core/utils.js +15 -0
- package/singlestore-core/utils.js.map +1 -1
- package/sql/sql.cjs +10 -0
- package/sql/sql.cjs.map +1 -1
- package/sql/sql.js +10 -0
- package/sql/sql.js.map +1 -1
- package/sql-js/session.cjs +3 -6
- package/sql-js/session.cjs.map +1 -1
- package/sql-js/session.js +3 -6
- package/sql-js/session.js.map +1 -1
- package/sqlite-core/columns/custom.cjs +1 -2
- package/sqlite-core/columns/custom.cjs.map +1 -1
- package/sqlite-core/columns/custom.js +1 -2
- package/sqlite-core/columns/custom.js.map +1 -1
- package/sqlite-core/columns/numeric.cjs +2 -4
- package/sqlite-core/columns/numeric.cjs.map +1 -1
- package/sqlite-core/columns/numeric.js +2 -4
- package/sqlite-core/columns/numeric.js.map +1 -1
- package/sqlite-core/db.cjs +3 -0
- package/sqlite-core/db.cjs.map +1 -1
- package/sqlite-core/db.d.cts +4 -0
- package/sqlite-core/db.d.ts +4 -0
- package/sqlite-core/db.js +3 -0
- package/sqlite-core/db.js.map +1 -1
- package/sqlite-core/dialect.cjs +7 -14
- package/sqlite-core/dialect.cjs.map +1 -1
- package/sqlite-core/dialect.js +7 -14
- package/sqlite-core/dialect.js.map +1 -1
- package/sqlite-core/query-builders/delete.cjs +7 -1
- package/sqlite-core/query-builders/delete.cjs.map +1 -1
- package/sqlite-core/query-builders/delete.js +7 -1
- package/sqlite-core/query-builders/delete.js.map +1 -1
- package/sqlite-core/query-builders/insert.cjs +9 -5
- package/sqlite-core/query-builders/insert.cjs.map +1 -1
- package/sqlite-core/query-builders/insert.js +9 -5
- package/sqlite-core/query-builders/insert.js.map +1 -1
- package/sqlite-core/query-builders/select.cjs +28 -3
- package/sqlite-core/query-builders/select.cjs.map +1 -1
- package/sqlite-core/query-builders/select.d.cts +15 -6
- package/sqlite-core/query-builders/select.d.ts +15 -6
- package/sqlite-core/query-builders/select.js +28 -3
- package/sqlite-core/query-builders/select.js.map +1 -1
- package/sqlite-core/query-builders/select.types.cjs.map +1 -1
- package/sqlite-core/query-builders/select.types.d.cts +2 -1
- package/sqlite-core/query-builders/select.types.d.ts +2 -1
- package/sqlite-core/query-builders/update.cjs +7 -1
- package/sqlite-core/query-builders/update.cjs.map +1 -1
- package/sqlite-core/query-builders/update.js +7 -1
- package/sqlite-core/query-builders/update.js.map +1 -1
- package/sqlite-core/session.cjs +87 -3
- package/sqlite-core/session.cjs.map +1 -1
- package/sqlite-core/session.d.cts +17 -3
- package/sqlite-core/session.d.ts +17 -3
- package/sqlite-core/session.js +89 -5
- package/sqlite-core/session.js.map +1 -1
- package/sqlite-core/utils.cjs +16 -0
- package/sqlite-core/utils.cjs.map +1 -1
- package/sqlite-core/utils.d.cts +6 -2
- package/sqlite-core/utils.d.ts +6 -2
- package/sqlite-core/utils.js +15 -0
- package/sqlite-core/utils.js.map +1 -1
- package/sqlite-proxy/driver.cjs +9 -2
- package/sqlite-proxy/driver.cjs.map +1 -1
- package/sqlite-proxy/driver.js +9 -2
- package/sqlite-proxy/driver.js.map +1 -1
- package/sqlite-proxy/session.cjs +27 -12
- package/sqlite-proxy/session.cjs.map +1 -1
- package/sqlite-proxy/session.d.cts +12 -2
- package/sqlite-proxy/session.d.ts +12 -2
- package/sqlite-proxy/session.js +27 -12
- package/sqlite-proxy/session.js.map +1 -1
- package/subquery.cjs +4 -3
- package/subquery.cjs.map +1 -1
- package/subquery.d.cts +2 -1
- package/subquery.d.ts +2 -1
- package/subquery.js +4 -3
- package/subquery.js.map +1 -1
- package/tidb-serverless/driver.cjs +9 -3
- package/tidb-serverless/driver.cjs.map +1 -1
- package/tidb-serverless/driver.d.cts +1 -0
- package/tidb-serverless/driver.d.ts +1 -0
- package/tidb-serverless/driver.js +9 -3
- package/tidb-serverless/driver.js.map +1 -1
- package/tidb-serverless/session.cjs +19 -7
- package/tidb-serverless/session.cjs.map +1 -1
- package/tidb-serverless/session.d.cts +12 -2
- package/tidb-serverless/session.d.ts +12 -2
- package/tidb-serverless/session.js +19 -7
- package/tidb-serverless/session.js.map +1 -1
- package/utils.cjs +10 -20
- package/utils.cjs.map +1 -1
- package/utils.d.cts +2 -0
- package/utils.d.ts +2 -0
- package/utils.js +10 -20
- package/utils.js.map +1 -1
- package/vercel-postgres/driver.cjs +9 -2
- package/vercel-postgres/driver.cjs.map +1 -1
- package/vercel-postgres/driver.d.cts +3 -1
- package/vercel-postgres/driver.d.ts +3 -1
- package/vercel-postgres/driver.js +9 -2
- package/vercel-postgres/driver.js.map +1 -1
- package/vercel-postgres/session.cjs +25 -9
- package/vercel-postgres/session.cjs.map +1 -1
- package/vercel-postgres/session.d.cts +12 -2
- package/vercel-postgres/session.d.ts +12 -2
- package/vercel-postgres/session.js +25 -9
- 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 +7 -2
- package/xata-http/driver.cjs.map +1 -1
- package/xata-http/driver.d.cts +2 -0
- package/xata-http/driver.d.ts +2 -0
- package/xata-http/driver.js +7 -2
- package/xata-http/driver.js.map +1 -1
- package/xata-http/session.cjs +27 -13
- package/xata-http/session.cjs.map +1 -1
- package/xata-http/session.d.cts +12 -2
- package/xata-http/session.d.ts +12 -2
- package/xata-http/session.js +27 -13
- package/xata-http/session.js.map +1 -1
- package/neon/neon-identity.cjs.map +0 -1
- package/neon/neon-identity.js.map +0 -1
package/bun-sqlite/session.js
CHANGED
|
@@ -92,8 +92,7 @@ class PreparedQuery extends PreparedQueryBase {
|
|
|
92
92
|
return this.stmt.run(...params);
|
|
93
93
|
}
|
|
94
94
|
all(placeholderValues) {
|
|
95
|
-
if (this.isRqbV2Query)
|
|
96
|
-
return this.allRqbV2(placeholderValues);
|
|
95
|
+
if (this.isRqbV2Query) return this.allRqbV2(placeholderValues);
|
|
97
96
|
const { fields, query, logger, joinsNotNullableMap, stmt, customResultMapper } = this;
|
|
98
97
|
if (!fields && !customResultMapper) {
|
|
99
98
|
const params = fillPlaceholders(query.params, placeholderValues ?? {});
|
|
@@ -107,8 +106,7 @@ class PreparedQuery extends PreparedQueryBase {
|
|
|
107
106
|
return rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
|
108
107
|
}
|
|
109
108
|
get(placeholderValues) {
|
|
110
|
-
if (this.isRqbV2Query)
|
|
111
|
-
return this.getRqbV2(placeholderValues);
|
|
109
|
+
if (this.isRqbV2Query) return this.getRqbV2(placeholderValues);
|
|
112
110
|
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
|
|
113
111
|
this.logger.logQuery(this.query.sql, params);
|
|
114
112
|
const row = this.stmt.values(...params)[0];
|
|
@@ -137,8 +135,7 @@ class PreparedQuery extends PreparedQueryBase {
|
|
|
137
135
|
this.logger.logQuery(this.query.sql, params);
|
|
138
136
|
const { stmt, customResultMapper } = this;
|
|
139
137
|
const row = stmt.get(...params);
|
|
140
|
-
if (row === void 0)
|
|
141
|
-
return row;
|
|
138
|
+
if (row === void 0) return row;
|
|
142
139
|
return customResultMapper(
|
|
143
140
|
[row]
|
|
144
141
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bun-sqlite/session.ts"],"sourcesContent":["/// <reference types=\"bun-types\" />\n\nimport type { Database, Statement as BunStatement } from 'bun:sqlite';\nimport type * as V1 from '~/_relations.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { NoopLogger } from '~/logger.ts';\nimport type { AnyRelations, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type Query, sql } from '~/sql/sql.ts';\nimport type { SQLiteSyncDialect } from '~/sqlite-core/dialect.ts';\nimport { SQLiteTransaction } from '~/sqlite-core/index.ts';\nimport type { SelectedFieldsOrdered } from '~/sqlite-core/query-builders/select.types.ts';\nimport type {\n\tPreparedQueryConfig as PreparedQueryConfigBase,\n\tSQLiteExecuteMethod,\n\tSQLiteTransactionConfig,\n} from '~/sqlite-core/session.ts';\nimport { SQLitePreparedQuery as PreparedQueryBase, SQLiteSession } from '~/sqlite-core/session.ts';\nimport { mapResultRow } from '~/utils.ts';\n\nexport interface SQLiteBunSessionOptions {\n\tlogger?: Logger;\n}\n\ntype PreparedQueryConfig = Omit<PreparedQueryConfigBase, 'statement' | 'run'>;\ntype Statement = BunStatement<any>;\n\nexport class SQLiteBunSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends SQLiteSession<'sync', void, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'SQLiteBunSession';\n\n\tprivate logger: Logger;\n\n\tconstructor(\n\t\tprivate client: Database,\n\t\tdialect: SQLiteSyncDialect,\n\t\tprivate relations: AnyRelations | undefined,\n\t\tprivate schema: V1.RelationalSchemaConfig<TSchema> | undefined,\n\t\toptions: SQLiteBunSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t}\n\n\texec(query: string): void {\n\t\tthis.client.exec(query);\n\t}\n\n\tprepareQuery<T extends Omit<PreparedQueryConfig, 'run'>>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\texecuteMethod: SQLiteExecuteMethod,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => unknown,\n\t): PreparedQuery<T> {\n\t\tconst stmt = this.client.prepare(query.sql);\n\t\treturn new PreparedQuery(\n\t\t\tstmt,\n\t\t\tquery,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\texecuteMethod,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\tprepareRelationalQuery<T extends Omit<PreparedQueryConfig, 'run'>>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\texecuteMethod: SQLiteExecuteMethod,\n\t\tcustomResultMapper: (rows: Record<string, unknown>[]) => unknown,\n\t): PreparedQuery<T, true> {\n\t\tconst stmt = this.client.prepare(query.sql);\n\t\treturn new PreparedQuery(\n\t\t\tstmt,\n\t\t\tquery,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\texecuteMethod,\n\t\t\tfalse,\n\t\t\tcustomResultMapper,\n\t\t\ttrue,\n\t\t);\n\t}\n\n\toverride transaction<T>(\n\t\ttransaction: (tx: SQLiteBunTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => T,\n\t\tconfig: SQLiteTransactionConfig = {},\n\t): T {\n\t\tconst tx = new SQLiteBunTransaction('sync', this.dialect, this, this.relations, this.schema);\n\t\tlet result: T | undefined;\n\t\tconst nativeTx = this.client.transaction(() => {\n\t\t\tresult = transaction(tx);\n\t\t});\n\t\tnativeTx[config.behavior ?? 'deferred']();\n\t\treturn result!;\n\t}\n}\n\nexport class SQLiteBunTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends SQLiteTransaction<'sync', void, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'SQLiteBunTransaction';\n\n\toverride transaction<T>(\n\t\ttransaction: (tx: SQLiteBunTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => T,\n\t): T {\n\t\tconst savepointName = `sp${this.nestedIndex}`;\n\t\tconst tx = new SQLiteBunTransaction(\n\t\t\t'sync',\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tthis.relations,\n\t\t\tthis.schema,\n\t\t\tthis.nestedIndex + 1,\n\t\t);\n\t\tthis.session.run(sql.raw(`savepoint ${savepointName}`));\n\t\ttry {\n\t\t\tconst result = transaction(tx);\n\t\t\tthis.session.run(sql.raw(`release savepoint ${savepointName}`));\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tthis.session.run(sql.raw(`rollback to savepoint ${savepointName}`));\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n\nexport class PreparedQuery<T extends PreparedQueryConfig = PreparedQueryConfig, TIsRqbV2 extends boolean = false>\n\textends PreparedQueryBase<\n\t\t{ type: 'sync'; run: void; all: T['all']; get: T['get']; values: T['values']; execute: T['execute'] }\n\t>\n{\n\tstatic override readonly [entityKind]: string = 'SQLiteBunPreparedQuery';\n\n\tconstructor(\n\t\tprivate stmt: Statement,\n\t\tquery: Query,\n\t\tprivate logger: Logger,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\texecuteMethod: SQLiteExecuteMethod,\n\t\tprivate _isResponseInArrayMode: boolean,\n\t\tprivate customResultMapper?: (\n\t\t\trows: TIsRqbV2 extends true ? Record<string, unknown>[] : unknown[][],\n\t\t) => unknown,\n\t\tprivate isRqbV2Query?: TIsRqbV2,\n\t) {\n\t\tsuper('sync', executeMethod, query);\n\t}\n\n\trun(placeholderValues?: Record<string, unknown>) {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues ?? {});\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\treturn this.stmt.run(...params);\n\t}\n\n\tall(placeholderValues?: Record<string, unknown>): T['all'] {\n\t\tif (this.isRqbV2Query) return this.allRqbV2(placeholderValues);\n\n\t\tconst { fields, query, logger, joinsNotNullableMap, stmt, customResultMapper } = this;\n\t\tif (!fields && !customResultMapper) {\n\t\t\tconst params = fillPlaceholders(query.params, placeholderValues ?? {});\n\t\t\tlogger.logQuery(query.sql, params);\n\t\t\treturn stmt.all(...params);\n\t\t}\n\n\t\tconst rows = this.values(placeholderValues) as unknown[][];\n\n\t\tif (customResultMapper) {\n\t\t\treturn (customResultMapper as (rows: unknown[][]) => unknown)(rows) as T['all'];\n\t\t}\n\n\t\treturn rows.map((row) => mapResultRow(fields!, row, joinsNotNullableMap));\n\t}\n\n\tget(placeholderValues?: Record<string, unknown>): T['get'] {\n\t\tif (this.isRqbV2Query) return this.getRqbV2(placeholderValues);\n\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues ?? {});\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\tconst row = this.stmt.values(...params)[0];\n\n\t\tif (!row) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { fields, joinsNotNullableMap, customResultMapper } = this;\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn row;\n\t\t}\n\n\t\tif (customResultMapper) {\n\t\t\treturn (customResultMapper as (rows: unknown[][]) => unknown)([row]) as T['get'];\n\t\t}\n\n\t\treturn mapResultRow(fields!, row, joinsNotNullableMap);\n\t}\n\n\tprivate allRqbV2(placeholderValues?: Record<string, unknown>): T['all'] {\n\t\tconst { query, logger, stmt, customResultMapper } = this;\n\t\tconst params = fillPlaceholders(query.params, placeholderValues ?? {});\n\n\t\tlogger.logQuery(query.sql, params);\n\n\t\treturn (customResultMapper as (rows: Record<string, unknown>[]) => unknown)(\n\t\t\tstmt.all(...params) as Record<string, unknown>[],\n\t\t);\n\t}\n\n\tprivate getRqbV2(placeholderValues?: Record<string, unknown>): T['get'] {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues ?? {});\n\t\tthis.logger.logQuery(this.query.sql, params);\n\n\t\tconst { stmt, customResultMapper } = this;\n\n\t\tconst row = stmt.get(...params) as Record<string, unknown>;\n\t\tif (row === undefined) return row;\n\n\t\treturn (customResultMapper as (rows: Record<string, unknown>[]) => unknown)(\n\t\t\t[row],\n\t\t);\n\t}\n\n\tvalues(placeholderValues?: Record<string, unknown>): T['values'] {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues ?? {});\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\treturn this.stmt.values(...params);\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n"],"mappings":"AAIA,SAAS,kBAAkB;AAE3B,SAAS,kBAAkB;AAE3B,SAAS,kBAA8B,WAAW;AAElD,SAAS,yBAAyB;AAOlC,SAAS,uBAAuB,mBAAmB,qBAAqB;AACxE,SAAS,oBAAoB;AAStB,MAAM,yBAKH,cAA6E;AAAA,EAKtF,YACS,QACR,SACQ,WACA,QACR,UAAmC,CAAC,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C;AAAA;AAAA,EAGA,wBAAiC;AAChC,WAAO,KAAK;AAAA,EACb;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/bun-sqlite/session.ts"],"sourcesContent":["/// <reference types=\"bun-types\" />\n\nimport type { Database, Statement as BunStatement } from 'bun:sqlite';\nimport type * as V1 from '~/_relations.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { NoopLogger } from '~/logger.ts';\nimport type { AnyRelations, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type Query, sql } from '~/sql/sql.ts';\nimport type { SQLiteSyncDialect } from '~/sqlite-core/dialect.ts';\nimport { SQLiteTransaction } from '~/sqlite-core/index.ts';\nimport type { SelectedFieldsOrdered } from '~/sqlite-core/query-builders/select.types.ts';\nimport type {\n\tPreparedQueryConfig as PreparedQueryConfigBase,\n\tSQLiteExecuteMethod,\n\tSQLiteTransactionConfig,\n} from '~/sqlite-core/session.ts';\nimport { SQLitePreparedQuery as PreparedQueryBase, SQLiteSession } from '~/sqlite-core/session.ts';\nimport { mapResultRow } from '~/utils.ts';\n\nexport interface SQLiteBunSessionOptions {\n\tlogger?: Logger;\n}\n\ntype PreparedQueryConfig = Omit<PreparedQueryConfigBase, 'statement' | 'run'>;\ntype Statement = BunStatement<any>;\n\nexport class SQLiteBunSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends SQLiteSession<'sync', void, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'SQLiteBunSession';\n\n\tprivate logger: Logger;\n\n\tconstructor(\n\t\tprivate client: Database,\n\t\tdialect: SQLiteSyncDialect,\n\t\tprivate relations: AnyRelations | undefined,\n\t\tprivate schema: V1.RelationalSchemaConfig<TSchema> | undefined,\n\t\toptions: SQLiteBunSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t}\n\n\texec(query: string): void {\n\t\tthis.client.exec(query);\n\t}\n\n\tprepareQuery<T extends Omit<PreparedQueryConfig, 'run'>>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\texecuteMethod: SQLiteExecuteMethod,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => unknown,\n\t): PreparedQuery<T> {\n\t\tconst stmt = this.client.prepare(query.sql);\n\t\treturn new PreparedQuery(\n\t\t\tstmt,\n\t\t\tquery,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\texecuteMethod,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\tprepareRelationalQuery<T extends Omit<PreparedQueryConfig, 'run'>>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\texecuteMethod: SQLiteExecuteMethod,\n\t\tcustomResultMapper: (rows: Record<string, unknown>[]) => unknown,\n\t): PreparedQuery<T, true> {\n\t\tconst stmt = this.client.prepare(query.sql);\n\t\treturn new PreparedQuery(\n\t\t\tstmt,\n\t\t\tquery,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\texecuteMethod,\n\t\t\tfalse,\n\t\t\tcustomResultMapper,\n\t\t\ttrue,\n\t\t);\n\t}\n\n\toverride transaction<T>(\n\t\ttransaction: (tx: SQLiteBunTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => T,\n\t\tconfig: SQLiteTransactionConfig = {},\n\t): T {\n\t\tconst tx = new SQLiteBunTransaction('sync', this.dialect, this, this.relations, this.schema);\n\t\tlet result: T | undefined;\n\t\tconst nativeTx = this.client.transaction(() => {\n\t\t\tresult = transaction(tx);\n\t\t});\n\t\tnativeTx[config.behavior ?? 'deferred']();\n\t\treturn result!;\n\t}\n}\n\nexport class SQLiteBunTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends SQLiteTransaction<'sync', void, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'SQLiteBunTransaction';\n\n\toverride transaction<T>(\n\t\ttransaction: (tx: SQLiteBunTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => T,\n\t): T {\n\t\tconst savepointName = `sp${this.nestedIndex}`;\n\t\tconst tx = new SQLiteBunTransaction(\n\t\t\t'sync',\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tthis.relations,\n\t\t\tthis.schema,\n\t\t\tthis.nestedIndex + 1,\n\t\t);\n\t\tthis.session.run(sql.raw(`savepoint ${savepointName}`));\n\t\ttry {\n\t\t\tconst result = transaction(tx);\n\t\t\tthis.session.run(sql.raw(`release savepoint ${savepointName}`));\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tthis.session.run(sql.raw(`rollback to savepoint ${savepointName}`));\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n\nexport class PreparedQuery<T extends PreparedQueryConfig = PreparedQueryConfig, TIsRqbV2 extends boolean = false>\n\textends PreparedQueryBase<\n\t\t{ type: 'sync'; run: void; all: T['all']; get: T['get']; values: T['values']; execute: T['execute'] }\n\t>\n{\n\tstatic override readonly [entityKind]: string = 'SQLiteBunPreparedQuery';\n\n\tconstructor(\n\t\tprivate stmt: Statement,\n\t\tquery: Query,\n\t\tprivate logger: Logger,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\texecuteMethod: SQLiteExecuteMethod,\n\t\tprivate _isResponseInArrayMode: boolean,\n\t\tprivate customResultMapper?: (\n\t\t\trows: TIsRqbV2 extends true ? Record<string, unknown>[] : unknown[][],\n\t\t) => unknown,\n\t\tprivate isRqbV2Query?: TIsRqbV2,\n\t) {\n\t\tsuper('sync', executeMethod, query);\n\t}\n\n\trun(placeholderValues?: Record<string, unknown>) {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues ?? {});\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\treturn this.stmt.run(...params);\n\t}\n\n\tall(placeholderValues?: Record<string, unknown>): T['all'] {\n\t\tif (this.isRqbV2Query) return this.allRqbV2(placeholderValues);\n\n\t\tconst { fields, query, logger, joinsNotNullableMap, stmt, customResultMapper } = this;\n\t\tif (!fields && !customResultMapper) {\n\t\t\tconst params = fillPlaceholders(query.params, placeholderValues ?? {});\n\t\t\tlogger.logQuery(query.sql, params);\n\t\t\treturn stmt.all(...params);\n\t\t}\n\n\t\tconst rows = this.values(placeholderValues) as unknown[][];\n\n\t\tif (customResultMapper) {\n\t\t\treturn (customResultMapper as (rows: unknown[][]) => unknown)(rows) as T['all'];\n\t\t}\n\n\t\treturn rows.map((row) => mapResultRow(fields!, row, joinsNotNullableMap));\n\t}\n\n\tget(placeholderValues?: Record<string, unknown>): T['get'] {\n\t\tif (this.isRqbV2Query) return this.getRqbV2(placeholderValues);\n\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues ?? {});\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\tconst row = this.stmt.values(...params)[0];\n\n\t\tif (!row) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { fields, joinsNotNullableMap, customResultMapper } = this;\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn row;\n\t\t}\n\n\t\tif (customResultMapper) {\n\t\t\treturn (customResultMapper as (rows: unknown[][]) => unknown)([row]) as T['get'];\n\t\t}\n\n\t\treturn mapResultRow(fields!, row, joinsNotNullableMap);\n\t}\n\n\tprivate allRqbV2(placeholderValues?: Record<string, unknown>): T['all'] {\n\t\tconst { query, logger, stmt, customResultMapper } = this;\n\t\tconst params = fillPlaceholders(query.params, placeholderValues ?? {});\n\n\t\tlogger.logQuery(query.sql, params);\n\n\t\treturn (customResultMapper as (rows: Record<string, unknown>[]) => unknown)(\n\t\t\tstmt.all(...params) as Record<string, unknown>[],\n\t\t);\n\t}\n\n\tprivate getRqbV2(placeholderValues?: Record<string, unknown>): T['get'] {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues ?? {});\n\t\tthis.logger.logQuery(this.query.sql, params);\n\n\t\tconst { stmt, customResultMapper } = this;\n\n\t\tconst row = stmt.get(...params) as Record<string, unknown>;\n\t\tif (row === undefined) return row;\n\n\t\treturn (customResultMapper as (rows: Record<string, unknown>[]) => unknown)(\n\t\t\t[row],\n\t\t);\n\t}\n\n\tvalues(placeholderValues?: Record<string, unknown>): T['values'] {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues ?? {});\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\treturn this.stmt.values(...params);\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n"],"mappings":"AAIA,SAAS,kBAAkB;AAE3B,SAAS,kBAAkB;AAE3B,SAAS,kBAA8B,WAAW;AAElD,SAAS,yBAAyB;AAOlC,SAAS,uBAAuB,mBAAmB,qBAAqB;AACxE,SAAS,oBAAoB;AAStB,MAAM,yBAKH,cAA6E;AAAA,EAKtF,YACS,QACR,SACQ,WACA,QACR,UAAmC,CAAC,GACnC;AACD,UAAM,OAAO;AANL;AAEA;AACA;AAIR,SAAK,SAAS,QAAQ,UAAU,IAAI,WAAW;AAAA,EAChD;AAAA,EAbA,QAA0B,UAAU,IAAY;AAAA,EAExC;AAAA,EAaR,KAAK,OAAqB;AACzB,SAAK,OAAO,KAAK,KAAK;AAAA,EACvB;AAAA,EAEA,aACC,OACA,QACA,eACA,uBACA,oBACmB;AACnB,UAAM,OAAO,KAAK,OAAO,QAAQ,MAAM,GAAG;AAC1C,WAAO,IAAI;AAAA,MACV;AAAA,MACA;AAAA,MACA,KAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAAA,EAEA,uBACC,OACA,QACA,eACA,oBACyB;AACzB,UAAM,OAAO,KAAK,OAAO,Q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mBAAuD;AACvE,UAAM,EAAE,OAAO,QAAQ,MAAM,mBAAmB,IAAI;AACpD,UAAM,SAAS,iBAAiB,MAAM,QAAQ,qBAAqB,CAAC,CAAC;AAErE,WAAO,SAAS,MAAM,KAAK,MAAM;AAEjC,WAAQ;AAAA,MACP,KAAK,IAAI,GAAG,MAAM;AAAA,IACnB;AAAA,EACD;AAAA,EAEQ,SAAS,mBAAuD;AACvE,UAAM,SAAS,iBAAiB,KAAK,MAAM,QAAQ,qBAAqB,CAAC,CAAC;AAC1E,SAAK,OAAO,SAAS,KAAK,MAAM,KAAK,MAAM;AAE3C,UAAM,EAAE,MAAM,mBAAmB,IAAI;AAErC,UAAM,MAAM,KAAK,IAAI,GAAG,MAAM;AAC9B,QAAI,QAAQ,OAAW,QAAO;AAE9B,WAAQ;AAAA,MACP,CAAC,GAAG;AAAA,IACL;AAAA,EACD;AAAA,EAEA,OAAO,mBAA0D;AAChE,UAAM,SAAS,iBAAiB,KAAK,MAAM,QAAQ,qBAAqB,CAAC,CAAC;AAC1E,SAAK,OAAO,SAAS,KAAK,MAAM,KAAK,MAAM;AAC3C,WAAO,KAAK,KAAK,OAAO,GAAG,MAAM;AAAA,EAClC;AAAA;AAAA,EAGA,wBAAiC;AAChC,WAAO,KAAK;AAAA,EACb;AACD;","names":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var cache_exports = {};
|
|
20
|
+
__export(cache_exports, {
|
|
21
|
+
Cache: () => Cache,
|
|
22
|
+
NoopCache: () => NoopCache,
|
|
23
|
+
hashQuery: () => hashQuery
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(cache_exports);
|
|
26
|
+
var import_entity = require("../../entity.cjs");
|
|
27
|
+
class Cache {
|
|
28
|
+
static [import_entity.entityKind] = "Cache";
|
|
29
|
+
}
|
|
30
|
+
class NoopCache extends Cache {
|
|
31
|
+
strategy() {
|
|
32
|
+
return "all";
|
|
33
|
+
}
|
|
34
|
+
static [import_entity.entityKind] = "NoopCache";
|
|
35
|
+
async get(_key) {
|
|
36
|
+
return void 0;
|
|
37
|
+
}
|
|
38
|
+
async put(_hashedQuery, _response, _tables, _config) {
|
|
39
|
+
}
|
|
40
|
+
async onMutate(_params) {
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function hashQuery(sql, params) {
|
|
44
|
+
const dataToHash = `${sql}-${JSON.stringify(params)}`;
|
|
45
|
+
const encoder = new TextEncoder();
|
|
46
|
+
const data = encoder.encode(dataToHash);
|
|
47
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
48
|
+
const hashArray = [...new Uint8Array(hashBuffer)];
|
|
49
|
+
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
50
|
+
return hashHex;
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
Cache,
|
|
55
|
+
NoopCache,
|
|
56
|
+
hashQuery
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=cache.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/cache/core/cache.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport type { Table } from '~/index.ts';\nimport type { CacheConfig } from './types.ts';\n\nexport abstract class Cache {\n\tstatic readonly [entityKind]: string = 'Cache';\n\n\tabstract strategy(): 'explicit' | 'all';\n\n\t/**\n\t * Invoked if we should check cache for cached response\n\t * @param sql\n\t * @param tables\n\t */\n\tabstract get(\n\t\tkey: string,\n\t\ttables: string[],\n\t\tisTag: boolean,\n\t\tisAutoInvalidate?: boolean,\n\t): Promise<any[] | undefined>;\n\n\t/**\n\t * Invoked if new query should be inserted to cache\n\t * @param sql\n\t * @param tables\n\t */\n\tabstract put(\n\t\thashedQuery: string,\n\t\tresponse: any,\n\t\ttables: string[],\n\t\tisTag: boolean,\n\t\tconfig?: CacheConfig,\n\t): Promise<void>;\n\n\t/**\n\t * Invoked if insert, update, delete was invoked\n\t * @param tables\n\t */\n\tabstract onMutate(\n\t\tparams: MutationOption,\n\t): Promise<void>;\n}\n\nexport class NoopCache extends Cache {\n\toverride strategy() {\n\t\treturn 'all' as const;\n\t}\n\n\tstatic override readonly [entityKind]: string = 'NoopCache';\n\n\toverride async get(_key: string): Promise<any[] | undefined> {\n\t\treturn undefined;\n\t}\n\toverride async put(\n\t\t_hashedQuery: string,\n\t\t_response: any,\n\t\t_tables: string[],\n\t\t_config?: any,\n\t): Promise<void> {\n\t\t// noop\n\t}\n\toverride async onMutate(_params: MutationOption): Promise<void> {\n\t\t// noop\n\t}\n}\n\nexport type MutationOption = { tags?: string | string[]; tables?: Table<any> | Table<any>[] | string | string[] };\n\nexport async function hashQuery(sql: string, params?: any[]) {\n\tconst dataToHash = `${sql}-${JSON.stringify(params)}`;\n\tconst encoder = new TextEncoder();\n\tconst data = encoder.encode(dataToHash);\n\tconst hashBuffer = await crypto.subtle.digest('SHA-256', data);\n\tconst hashArray = [...new Uint8Array(hashBuffer)];\n\tconst hashHex = hashArray.map((b) => b.toString(16).padStart(2, '0')).join('');\n\n\treturn hashHex;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAIpB,MAAe,MAAM;AAAA,EAC3B,QAAiB,wBAAU,IAAY;AAoCxC;AAEO,MAAM,kBAAkB,MAAM;AAAA,EAC3B,WAAW;AACnB,WAAO;AAAA,EACR;AAAA,EAEA,QAA0B,wBAAU,IAAY;AAAA,EAEhD,MAAe,IAAI,MAA0C;AAC5D,WAAO;AAAA,EACR;AAAA,EACA,MAAe,IACd,cACA,WACA,SACA,SACgB;AAAA,EAEjB;AAAA,EACA,MAAe,SAAS,SAAwC;AAAA,EAEhE;AACD;AAIA,eAAsB,UAAU,KAAa,QAAgB;AAC5D,QAAM,aAAa,GAAG,GAAG,IAAI,KAAK,UAAU,MAAM,CAAC;AACnD,QAAM,UAAU,IAAI,YAAY;AAChC,QAAM,OAAO,QAAQ,OAAO,UAAU;AACtC,QAAM,aAAa,MAAM,OAAO,OAAO,OAAO,WAAW,IAAI;AAC7D,QAAM,YAAY,CAAC,GAAG,IAAI,WAAW,UAAU,CAAC;AAChD,QAAM,UAAU,UAAU,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AAE7E,SAAO;AACR;","names":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { entityKind } from "../../entity.cjs";
|
|
2
|
+
import type { Table } from "../../index.cjs";
|
|
3
|
+
import type { CacheConfig } from "./types.cjs";
|
|
4
|
+
export declare abstract class Cache {
|
|
5
|
+
static readonly [entityKind]: string;
|
|
6
|
+
abstract strategy(): 'explicit' | 'all';
|
|
7
|
+
/**
|
|
8
|
+
* Invoked if we should check cache for cached response
|
|
9
|
+
* @param sql
|
|
10
|
+
* @param tables
|
|
11
|
+
*/
|
|
12
|
+
abstract get(key: string, tables: string[], isTag: boolean, isAutoInvalidate?: boolean): Promise<any[] | undefined>;
|
|
13
|
+
/**
|
|
14
|
+
* Invoked if new query should be inserted to cache
|
|
15
|
+
* @param sql
|
|
16
|
+
* @param tables
|
|
17
|
+
*/
|
|
18
|
+
abstract put(hashedQuery: string, response: any, tables: string[], isTag: boolean, config?: CacheConfig): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Invoked if insert, update, delete was invoked
|
|
21
|
+
* @param tables
|
|
22
|
+
*/
|
|
23
|
+
abstract onMutate(params: MutationOption): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export declare class NoopCache extends Cache {
|
|
26
|
+
strategy(): "all";
|
|
27
|
+
static readonly [entityKind]: string;
|
|
28
|
+
get(_key: string): Promise<any[] | undefined>;
|
|
29
|
+
put(_hashedQuery: string, _response: any, _tables: string[], _config?: any): Promise<void>;
|
|
30
|
+
onMutate(_params: MutationOption): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export type MutationOption = {
|
|
33
|
+
tags?: string | string[];
|
|
34
|
+
tables?: Table<any> | Table<any>[] | string | string[];
|
|
35
|
+
};
|
|
36
|
+
export declare function hashQuery(sql: string, params?: any[]): Promise<string>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { entityKind } from "../../entity.js";
|
|
2
|
+
import type { Table } from "../../index.js";
|
|
3
|
+
import type { CacheConfig } from "./types.js";
|
|
4
|
+
export declare abstract class Cache {
|
|
5
|
+
static readonly [entityKind]: string;
|
|
6
|
+
abstract strategy(): 'explicit' | 'all';
|
|
7
|
+
/**
|
|
8
|
+
* Invoked if we should check cache for cached response
|
|
9
|
+
* @param sql
|
|
10
|
+
* @param tables
|
|
11
|
+
*/
|
|
12
|
+
abstract get(key: string, tables: string[], isTag: boolean, isAutoInvalidate?: boolean): Promise<any[] | undefined>;
|
|
13
|
+
/**
|
|
14
|
+
* Invoked if new query should be inserted to cache
|
|
15
|
+
* @param sql
|
|
16
|
+
* @param tables
|
|
17
|
+
*/
|
|
18
|
+
abstract put(hashedQuery: string, response: any, tables: string[], isTag: boolean, config?: CacheConfig): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Invoked if insert, update, delete was invoked
|
|
21
|
+
* @param tables
|
|
22
|
+
*/
|
|
23
|
+
abstract onMutate(params: MutationOption): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export declare class NoopCache extends Cache {
|
|
26
|
+
strategy(): "all";
|
|
27
|
+
static readonly [entityKind]: string;
|
|
28
|
+
get(_key: string): Promise<any[] | undefined>;
|
|
29
|
+
put(_hashedQuery: string, _response: any, _tables: string[], _config?: any): Promise<void>;
|
|
30
|
+
onMutate(_params: MutationOption): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export type MutationOption = {
|
|
33
|
+
tags?: string | string[];
|
|
34
|
+
tables?: Table<any> | Table<any>[] | string | string[];
|
|
35
|
+
};
|
|
36
|
+
export declare function hashQuery(sql: string, params?: any[]): Promise<string>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { entityKind } from "../../entity.js";
|
|
2
|
+
class Cache {
|
|
3
|
+
static [entityKind] = "Cache";
|
|
4
|
+
}
|
|
5
|
+
class NoopCache extends Cache {
|
|
6
|
+
strategy() {
|
|
7
|
+
return "all";
|
|
8
|
+
}
|
|
9
|
+
static [entityKind] = "NoopCache";
|
|
10
|
+
async get(_key) {
|
|
11
|
+
return void 0;
|
|
12
|
+
}
|
|
13
|
+
async put(_hashedQuery, _response, _tables, _config) {
|
|
14
|
+
}
|
|
15
|
+
async onMutate(_params) {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async function hashQuery(sql, params) {
|
|
19
|
+
const dataToHash = `${sql}-${JSON.stringify(params)}`;
|
|
20
|
+
const encoder = new TextEncoder();
|
|
21
|
+
const data = encoder.encode(dataToHash);
|
|
22
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
23
|
+
const hashArray = [...new Uint8Array(hashBuffer)];
|
|
24
|
+
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
25
|
+
return hashHex;
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
Cache,
|
|
29
|
+
NoopCache,
|
|
30
|
+
hashQuery
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/cache/core/cache.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport type { Table } from '~/index.ts';\nimport type { CacheConfig } from './types.ts';\n\nexport abstract class Cache {\n\tstatic readonly [entityKind]: string = 'Cache';\n\n\tabstract strategy(): 'explicit' | 'all';\n\n\t/**\n\t * Invoked if we should check cache for cached response\n\t * @param sql\n\t * @param tables\n\t */\n\tabstract get(\n\t\tkey: string,\n\t\ttables: string[],\n\t\tisTag: boolean,\n\t\tisAutoInvalidate?: boolean,\n\t): Promise<any[] | undefined>;\n\n\t/**\n\t * Invoked if new query should be inserted to cache\n\t * @param sql\n\t * @param tables\n\t */\n\tabstract put(\n\t\thashedQuery: string,\n\t\tresponse: any,\n\t\ttables: string[],\n\t\tisTag: boolean,\n\t\tconfig?: CacheConfig,\n\t): Promise<void>;\n\n\t/**\n\t * Invoked if insert, update, delete was invoked\n\t * @param tables\n\t */\n\tabstract onMutate(\n\t\tparams: MutationOption,\n\t): Promise<void>;\n}\n\nexport class NoopCache extends Cache {\n\toverride strategy() {\n\t\treturn 'all' as const;\n\t}\n\n\tstatic override readonly [entityKind]: string = 'NoopCache';\n\n\toverride async get(_key: string): Promise<any[] | undefined> {\n\t\treturn undefined;\n\t}\n\toverride async put(\n\t\t_hashedQuery: string,\n\t\t_response: any,\n\t\t_tables: string[],\n\t\t_config?: any,\n\t): Promise<void> {\n\t\t// noop\n\t}\n\toverride async onMutate(_params: MutationOption): Promise<void> {\n\t\t// noop\n\t}\n}\n\nexport type MutationOption = { tags?: string | string[]; tables?: Table<any> | Table<any>[] | string | string[] };\n\nexport async function hashQuery(sql: string, params?: any[]) {\n\tconst dataToHash = `${sql}-${JSON.stringify(params)}`;\n\tconst encoder = new TextEncoder();\n\tconst data = encoder.encode(dataToHash);\n\tconst hashBuffer = await crypto.subtle.digest('SHA-256', data);\n\tconst hashArray = [...new Uint8Array(hashBuffer)];\n\tconst hashHex = hashArray.map((b) => b.toString(16).padStart(2, '0')).join('');\n\n\treturn hashHex;\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAIpB,MAAe,MAAM;AAAA,EAC3B,QAAiB,UAAU,IAAY;AAoCxC;AAEO,MAAM,kBAAkB,MAAM;AAAA,EAC3B,WAAW;AACnB,WAAO;AAAA,EACR;AAAA,EAEA,QAA0B,UAAU,IAAY;AAAA,EAEhD,MAAe,IAAI,MAA0C;AAC5D,WAAO;AAAA,EACR;AAAA,EACA,MAAe,IACd,cACA,WACA,SACA,SACgB;AAAA,EAEjB;AAAA,EACA,MAAe,SAAS,SAAwC;AAAA,EAEhE;AACD;AAIA,eAAsB,UAAU,KAAa,QAAgB;AAC5D,QAAM,aAAa,GAAG,GAAG,IAAI,KAAK,UAAU,MAAM,CAAC;AACnD,QAAM,UAAU,IAAI,YAAY;AAChC,QAAM,OAAO,QAAQ,OAAO,UAAU;AACtC,QAAM,aAAa,MAAM,OAAO,OAAO,OAAO,WAAW,IAAI;AAC7D,QAAM,YAAY,CAAC,GAAG,IAAI,WAAW,UAAU,CAAC;AAChD,QAAM,UAAU,UAAU,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AAE7E,SAAO;AACR;","names":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var core_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(core_exports);
|
|
18
|
+
__reExport(core_exports, require("./cache.cjs"), module.exports);
|
|
19
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require("./cache.cjs")
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/cache/core/index.ts"],"sourcesContent":["export * from './cache.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,yBAAc,uBAAd;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./cache.cjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./cache.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/cache/core/index.ts"],"sourcesContent":["export * from './cache.ts';\n"],"mappings":"AAAA,cAAc;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
|
17
|
+
//# sourceMappingURL=types.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/cache/core/types.ts"],"sourcesContent":["export type CacheConfig = {\n\t/**\n\t * expire time, in seconds (a positive integer)\n\t */\n\tex?: number;\n\t/**\n\t * expire time, in milliseconds (a positive integer).\n\t */\n\tpx?: number;\n\t/**\n\t * Unix time at which the key will expire, in seconds (a positive integer).\n\t */\n\texat?: number;\n\t/**\n\t * Unix time at which the key will expire, in milliseconds (a positive integer)\n\t */\n\tpxat?: number;\n\t/**\n\t * Retain the time to live associated with the key.\n\t */\n\tkeepTtl?: boolean;\n\t/**\n\t * Set an expiration (TTL or time to live) on one or more fields of a given hash key.\n\t * Used for HEXPIRE command\n\t */\n\thexOptions?: 'NX' | 'nx' | 'XX' | 'xx' | 'GT' | 'gt' | 'LT' | 'lt';\n};\n\nexport type WithCacheConfig = { enable: boolean; config?: CacheConfig; tag?: string; autoInvalidate?: boolean };\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type CacheConfig = {
|
|
2
|
+
/**
|
|
3
|
+
* expire time, in seconds (a positive integer)
|
|
4
|
+
*/
|
|
5
|
+
ex?: number;
|
|
6
|
+
/**
|
|
7
|
+
* expire time, in milliseconds (a positive integer).
|
|
8
|
+
*/
|
|
9
|
+
px?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Unix time at which the key will expire, in seconds (a positive integer).
|
|
12
|
+
*/
|
|
13
|
+
exat?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Unix time at which the key will expire, in milliseconds (a positive integer)
|
|
16
|
+
*/
|
|
17
|
+
pxat?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Retain the time to live associated with the key.
|
|
20
|
+
*/
|
|
21
|
+
keepTtl?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Set an expiration (TTL or time to live) on one or more fields of a given hash key.
|
|
24
|
+
* Used for HEXPIRE command
|
|
25
|
+
*/
|
|
26
|
+
hexOptions?: 'NX' | 'nx' | 'XX' | 'xx' | 'GT' | 'gt' | 'LT' | 'lt';
|
|
27
|
+
};
|
|
28
|
+
export type WithCacheConfig = {
|
|
29
|
+
enable: boolean;
|
|
30
|
+
config?: CacheConfig;
|
|
31
|
+
tag?: string;
|
|
32
|
+
autoInvalidate?: boolean;
|
|
33
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type CacheConfig = {
|
|
2
|
+
/**
|
|
3
|
+
* expire time, in seconds (a positive integer)
|
|
4
|
+
*/
|
|
5
|
+
ex?: number;
|
|
6
|
+
/**
|
|
7
|
+
* expire time, in milliseconds (a positive integer).
|
|
8
|
+
*/
|
|
9
|
+
px?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Unix time at which the key will expire, in seconds (a positive integer).
|
|
12
|
+
*/
|
|
13
|
+
exat?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Unix time at which the key will expire, in milliseconds (a positive integer)
|
|
16
|
+
*/
|
|
17
|
+
pxat?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Retain the time to live associated with the key.
|
|
20
|
+
*/
|
|
21
|
+
keepTtl?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Set an expiration (TTL or time to live) on one or more fields of a given hash key.
|
|
24
|
+
* Used for HEXPIRE command
|
|
25
|
+
*/
|
|
26
|
+
hexOptions?: 'NX' | 'nx' | 'XX' | 'xx' | 'GT' | 'gt' | 'LT' | 'lt';
|
|
27
|
+
};
|
|
28
|
+
export type WithCacheConfig = {
|
|
29
|
+
enable: boolean;
|
|
30
|
+
config?: CacheConfig;
|
|
31
|
+
tag?: string;
|
|
32
|
+
autoInvalidate?: boolean;
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var cache_exports = {};
|
|
20
|
+
__export(cache_exports, {
|
|
21
|
+
UpstashCache: () => UpstashCache,
|
|
22
|
+
upstashCache: () => upstashCache
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(cache_exports);
|
|
25
|
+
var import_redis = require("@upstash/redis");
|
|
26
|
+
var import_core = require("../core/index.cjs");
|
|
27
|
+
var import_entity = require("../../entity.cjs");
|
|
28
|
+
var import__ = require("../../index.cjs");
|
|
29
|
+
const getByTagScript = `
|
|
30
|
+
local tagsMapKey = KEYS[1] -- tags map key
|
|
31
|
+
local tag = ARGV[1] -- tag
|
|
32
|
+
|
|
33
|
+
local compositeTableName = redis.call('HGET', tagsMapKey, tag)
|
|
34
|
+
if not compositeTableName then
|
|
35
|
+
return nil
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
local value = redis.call('HGET', compositeTableName, tag)
|
|
39
|
+
return value
|
|
40
|
+
`;
|
|
41
|
+
const onMutateScript = `
|
|
42
|
+
local tagsMapKey = KEYS[1] -- tags map key
|
|
43
|
+
local tables = {} -- initialize tables array
|
|
44
|
+
local tags = ARGV -- tags array
|
|
45
|
+
|
|
46
|
+
for i = 2, #KEYS do
|
|
47
|
+
tables[#tables + 1] = KEYS[i] -- add all keys except the first one to tables
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
if #tags > 0 then
|
|
51
|
+
for _, tag in ipairs(tags) do
|
|
52
|
+
if tag ~= nil and tag ~= '' then
|
|
53
|
+
local compositeTableName = redis.call('HGET', tagsMapKey, tag)
|
|
54
|
+
if compositeTableName then
|
|
55
|
+
redis.call('HDEL', compositeTableName, tag)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
redis.call('HDEL', tagsMapKey, unpack(tags))
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
local keysToDelete = {}
|
|
63
|
+
|
|
64
|
+
if #tables > 0 then
|
|
65
|
+
local compositeTableNames = redis.call('SUNION', unpack(tables))
|
|
66
|
+
for _, compositeTableName in ipairs(compositeTableNames) do
|
|
67
|
+
keysToDelete[#keysToDelete + 1] = compositeTableName
|
|
68
|
+
end
|
|
69
|
+
for _, table in ipairs(tables) do
|
|
70
|
+
keysToDelete[#keysToDelete + 1] = table
|
|
71
|
+
end
|
|
72
|
+
redis.call('DEL', unpack(keysToDelete))
|
|
73
|
+
end
|
|
74
|
+
`;
|
|
75
|
+
class UpstashCache extends import_core.Cache {
|
|
76
|
+
constructor(redis, config, useGlobally) {
|
|
77
|
+
super();
|
|
78
|
+
this.redis = redis;
|
|
79
|
+
this.useGlobally = useGlobally;
|
|
80
|
+
this.internalConfig = this.toInternalConfig(config);
|
|
81
|
+
this.luaScripts = {
|
|
82
|
+
getByTagScript: this.redis.createScript(getByTagScript, { readonly: true }),
|
|
83
|
+
onMutateScript: this.redis.createScript(onMutateScript)
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
static [import_entity.entityKind] = "UpstashCache";
|
|
87
|
+
/**
|
|
88
|
+
* Prefix for sets which denote the composite table names for each unique table
|
|
89
|
+
*
|
|
90
|
+
* Example: In the composite table set of "table1", you may find
|
|
91
|
+
* `${compositeTablePrefix}table1,table2` and `${compositeTablePrefix}table1,table3`
|
|
92
|
+
*/
|
|
93
|
+
static compositeTableSetPrefix = "__CTS__";
|
|
94
|
+
/**
|
|
95
|
+
* Prefix for hashes which map hash or tags to cache values
|
|
96
|
+
*/
|
|
97
|
+
static compositeTablePrefix = "__CT__";
|
|
98
|
+
/**
|
|
99
|
+
* Key which holds the mapping of tags to composite table names
|
|
100
|
+
*
|
|
101
|
+
* Using this tagsMapKey, you can find the composite table name for a given tag
|
|
102
|
+
* and get the cache value for that tag:
|
|
103
|
+
*
|
|
104
|
+
* ```ts
|
|
105
|
+
* const compositeTable = redis.hget(tagsMapKey, 'tag1')
|
|
106
|
+
* console.log(compositeTable) // `${compositeTablePrefix}table1,table2`
|
|
107
|
+
*
|
|
108
|
+
* const cachevalue = redis.hget(compositeTable, 'tag1')
|
|
109
|
+
*/
|
|
110
|
+
static tagsMapKey = "__tagsMap__";
|
|
111
|
+
/**
|
|
112
|
+
* Queries whose auto invalidation is false aren't stored in their respective
|
|
113
|
+
* composite table hashes because those hashes are deleted when a mutation
|
|
114
|
+
* occurs on related tables.
|
|
115
|
+
*
|
|
116
|
+
* Instead, they are stored in a separate hash with the prefix
|
|
117
|
+
* `__nonAutoInvalidate__` to prevent them from being deleted when a mutation
|
|
118
|
+
*/
|
|
119
|
+
static nonAutoInvalidateTablePrefix = "__nonAutoInvalidate__";
|
|
120
|
+
luaScripts;
|
|
121
|
+
internalConfig;
|
|
122
|
+
strategy() {
|
|
123
|
+
return this.useGlobally ? "all" : "explicit";
|
|
124
|
+
}
|
|
125
|
+
toInternalConfig(config) {
|
|
126
|
+
return config ? {
|
|
127
|
+
seconds: config.ex,
|
|
128
|
+
hexOptions: config.hexOptions
|
|
129
|
+
} : {
|
|
130
|
+
seconds: 1
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
async get(key, tables, isTag = false, isAutoInvalidate) {
|
|
134
|
+
if (!isAutoInvalidate) {
|
|
135
|
+
const result2 = await this.redis.hget(UpstashCache.nonAutoInvalidateTablePrefix, key);
|
|
136
|
+
return result2 === null ? void 0 : result2;
|
|
137
|
+
}
|
|
138
|
+
if (isTag) {
|
|
139
|
+
const result2 = await this.luaScripts.getByTagScript.exec([UpstashCache.tagsMapKey], [key]);
|
|
140
|
+
return result2 === null ? void 0 : result2;
|
|
141
|
+
}
|
|
142
|
+
const compositeKey = this.getCompositeKey(tables);
|
|
143
|
+
const result = (await this.redis.hget(compositeKey, key)) ?? void 0;
|
|
144
|
+
return result === null ? void 0 : result;
|
|
145
|
+
}
|
|
146
|
+
async put(key, response, tables, isTag = false, config) {
|
|
147
|
+
const isAutoInvalidate = tables.length !== 0;
|
|
148
|
+
const pipeline = this.redis.pipeline();
|
|
149
|
+
const ttlSeconds = config && config.ex ? config.ex : this.internalConfig.seconds;
|
|
150
|
+
const hexOptions = config && config.hexOptions ? config.hexOptions : this.internalConfig?.hexOptions;
|
|
151
|
+
if (!isAutoInvalidate) {
|
|
152
|
+
if (isTag) {
|
|
153
|
+
pipeline.hset(UpstashCache.tagsMapKey, { [key]: UpstashCache.nonAutoInvalidateTablePrefix });
|
|
154
|
+
pipeline.hexpire(UpstashCache.tagsMapKey, key, ttlSeconds, hexOptions);
|
|
155
|
+
}
|
|
156
|
+
pipeline.hset(UpstashCache.nonAutoInvalidateTablePrefix, { [key]: response });
|
|
157
|
+
pipeline.hexpire(UpstashCache.nonAutoInvalidateTablePrefix, key, ttlSeconds, hexOptions);
|
|
158
|
+
await pipeline.exec();
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const compositeKey = this.getCompositeKey(tables);
|
|
162
|
+
pipeline.hset(compositeKey, { [key]: response });
|
|
163
|
+
pipeline.hexpire(compositeKey, key, ttlSeconds, hexOptions);
|
|
164
|
+
if (isTag) {
|
|
165
|
+
pipeline.hset(UpstashCache.tagsMapKey, { [key]: compositeKey });
|
|
166
|
+
pipeline.hexpire(UpstashCache.tagsMapKey, key, ttlSeconds, hexOptions);
|
|
167
|
+
}
|
|
168
|
+
for (const table of tables) {
|
|
169
|
+
pipeline.sadd(this.addTablePrefix(table), compositeKey);
|
|
170
|
+
}
|
|
171
|
+
await pipeline.exec();
|
|
172
|
+
}
|
|
173
|
+
async onMutate(params) {
|
|
174
|
+
const tags = Array.isArray(params.tags) ? params.tags : params.tags ? [params.tags] : [];
|
|
175
|
+
const tables = Array.isArray(params.tables) ? params.tables : params.tables ? [params.tables] : [];
|
|
176
|
+
const tableNames = tables.map((table) => (0, import_entity.is)(table, import__.Table) ? table[import__.OriginalName] : table);
|
|
177
|
+
const compositeTableSets = tableNames.map((table) => this.addTablePrefix(table));
|
|
178
|
+
await this.luaScripts.onMutateScript.exec([UpstashCache.tagsMapKey, ...compositeTableSets], tags);
|
|
179
|
+
}
|
|
180
|
+
addTablePrefix = (table) => `${UpstashCache.compositeTableSetPrefix}${table}`;
|
|
181
|
+
getCompositeKey = (tables) => `${UpstashCache.compositeTablePrefix}${tables.sort().join(",")}`;
|
|
182
|
+
}
|
|
183
|
+
function upstashCache({ url, token, config, global = false }) {
|
|
184
|
+
const redis = new import_redis.Redis({
|
|
185
|
+
url,
|
|
186
|
+
token
|
|
187
|
+
});
|
|
188
|
+
return new UpstashCache(redis, config, global);
|
|
189
|
+
}
|
|
190
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
191
|
+
0 && (module.exports = {
|
|
192
|
+
UpstashCache,
|
|
193
|
+
upstashCache
|
|
194
|
+
});
|
|
195
|
+
//# sourceMappingURL=cache.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/cache/upstash/cache.ts"],"sourcesContent":["import { Redis } from '@upstash/redis';\nimport type { MutationOption } from '~/cache/core/index.ts';\nimport { Cache } from '~/cache/core/index.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport { OriginalName, Table } from '~/index.ts';\nimport type { CacheConfig } from '../core/types.ts';\n\nconst getByTagScript = `\nlocal tagsMapKey = KEYS[1] -- tags map key\nlocal tag = ARGV[1] -- tag\n\nlocal compositeTableName = redis.call('HGET', tagsMapKey, tag)\nif not compositeTableName then\n return nil\nend\n\nlocal value = redis.call('HGET', compositeTableName, tag)\nreturn value\n`;\n\nconst onMutateScript = `\nlocal tagsMapKey = KEYS[1] -- tags map key\nlocal tables = {} -- initialize tables array\nlocal tags = ARGV -- tags array\n\nfor i = 2, #KEYS do\n tables[#tables + 1] = KEYS[i] -- add all keys except the first one to tables\nend\n\nif #tags > 0 then\n for _, tag in ipairs(tags) do\n if tag ~= nil and tag ~= '' then\n local compositeTableName = redis.call('HGET', tagsMapKey, tag)\n if compositeTableName then\n redis.call('HDEL', compositeTableName, tag)\n end\n end\n end\n redis.call('HDEL', tagsMapKey, unpack(tags))\nend\n\nlocal keysToDelete = {}\n\nif #tables > 0 then\n local compositeTableNames = redis.call('SUNION', unpack(tables))\n for _, compositeTableName in ipairs(compositeTableNames) do\n keysToDelete[#keysToDelete + 1] = compositeTableName\n end\n for _, table in ipairs(tables) do\n keysToDelete[#keysToDelete + 1] = table\n end\n redis.call('DEL', unpack(keysToDelete))\nend\n`;\n\ntype Script = ReturnType<Redis['createScript']>;\n\ntype ExpireOptions = 'NX' | 'nx' | 'XX' | 'xx' | 'GT' | 'gt' | 'LT' | 'lt';\n\nexport class UpstashCache extends Cache {\n\tstatic override readonly [entityKind]: string = 'UpstashCache';\n\t/**\n\t * Prefix for sets which denote the composite table names for each unique table\n\t *\n\t * Example: In the composite table set of \"table1\", you may find\n\t * `${compositeTablePrefix}table1,table2` and `${compositeTablePrefix}table1,table3`\n\t */\n\tprivate static compositeTableSetPrefix = '__CTS__';\n\t/**\n\t * Prefix for hashes which map hash or tags to cache values\n\t */\n\tprivate static compositeTablePrefix = '__CT__';\n\t/**\n\t * Key which holds the mapping of tags to composite table names\n\t *\n\t * Using this tagsMapKey, you can find the composite table name for a given tag\n\t * and get the cache value for that tag:\n\t *\n\t * ```ts\n\t * const compositeTable = redis.hget(tagsMapKey, 'tag1')\n\t * console.log(compositeTable) // `${compositeTablePrefix}table1,table2`\n\t *\n\t * const cachevalue = redis.hget(compositeTable, 'tag1')\n\t */\n\tprivate static tagsMapKey = '__tagsMap__';\n\t/**\n\t * Queries whose auto invalidation is false aren't stored in their respective\n\t * composite table hashes because those hashes are deleted when a mutation\n\t * occurs on related tables.\n\t *\n\t * Instead, they are stored in a separate hash with the prefix\n\t * `__nonAutoInvalidate__` to prevent them from being deleted when a mutation\n\t */\n\tprivate static nonAutoInvalidateTablePrefix = '__nonAutoInvalidate__';\n\n\tprivate luaScripts: {\n\t\tgetByTagScript: Script;\n\t\tonMutateScript: Script;\n\t};\n\n\tprivate internalConfig: { seconds: number; hexOptions?: ExpireOptions };\n\n\tconstructor(public redis: Redis, config?: CacheConfig, protected useGlobally?: boolean) {\n\t\tsuper();\n\t\tthis.internalConfig = this.toInternalConfig(config);\n\t\tthis.luaScripts = {\n\t\t\tgetByTagScript: this.redis.createScript(getByTagScript, { readonly: true }),\n\t\t\tonMutateScript: this.redis.createScript(onMutateScript),\n\t\t};\n\t}\n\n\tpublic strategy() {\n\t\treturn this.useGlobally ? 'all' : 'explicit';\n\t}\n\n\tprivate toInternalConfig(config?: CacheConfig): { seconds: number; hexOptions?: ExpireOptions } {\n\t\treturn config\n\t\t\t? {\n\t\t\t\tseconds: config.ex!,\n\t\t\t\thexOptions: config.hexOptions,\n\t\t\t}\n\t\t\t: {\n\t\t\t\tseconds: 1,\n\t\t\t};\n\t}\n\n\toverride async get(\n\t\tkey: string,\n\t\ttables: string[],\n\t\tisTag: boolean = false,\n\t\tisAutoInvalidate?: boolean,\n\t): Promise<any[] | undefined> {\n\t\tif (!isAutoInvalidate) {\n\t\t\tconst result = await this.redis.hget(UpstashCache.nonAutoInvalidateTablePrefix, key);\n\t\t\treturn result === null ? undefined : result as any[];\n\t\t}\n\n\t\tif (isTag) {\n\t\t\tconst result = await this.luaScripts.getByTagScript.exec([UpstashCache.tagsMapKey], [key]);\n\t\t\treturn result === null ? undefined : result as any[];\n\t\t}\n\n\t\t// Normal cache lookup for the composite key\n\t\tconst compositeKey = this.getCompositeKey(tables);\n\t\tconst result = await this.redis.hget(compositeKey, key) ?? undefined; // Retrieve result for normal query\n\t\treturn result === null ? undefined : result as any[];\n\t}\n\n\toverride async put(\n\t\tkey: string,\n\t\tresponse: any,\n\t\ttables: string[],\n\t\tisTag: boolean = false,\n\t\tconfig?: CacheConfig,\n\t): Promise<void> {\n\t\tconst isAutoInvalidate = tables.length !== 0;\n\n\t\tconst pipeline = this.redis.pipeline();\n\t\tconst ttlSeconds = config && config.ex ? config.ex : this.internalConfig.seconds;\n\t\tconst hexOptions = config && config.hexOptions ? config.hexOptions : this.internalConfig?.hexOptions;\n\n\t\tif (!isAutoInvalidate) {\n\t\t\tif (isTag) {\n\t\t\t\tpipeline.hset(UpstashCache.tagsMapKey, { [key]: UpstashCache.nonAutoInvalidateTablePrefix });\n\t\t\t\tpipeline.hexpire(UpstashCache.tagsMapKey, key, ttlSeconds, hexOptions);\n\t\t\t}\n\n\t\t\tpipeline.hset(UpstashCache.nonAutoInvalidateTablePrefix, { [key]: response });\n\t\t\tpipeline.hexpire(UpstashCache.nonAutoInvalidateTablePrefix, key, ttlSeconds, hexOptions);\n\t\t\tawait pipeline.exec();\n\t\t\treturn;\n\t\t}\n\n\t\tconst compositeKey = this.getCompositeKey(tables);\n\n\t\tpipeline.hset(compositeKey, { [key]: response }); // Store the result with the tag under the composite key\n\t\tpipeline.hexpire(compositeKey, key, ttlSeconds, hexOptions); // Set expiration for the composite key\n\n\t\tif (isTag) {\n\t\t\tpipeline.hset(UpstashCache.tagsMapKey, { [key]: compositeKey }); // Store the tag and its composite key in the map\n\t\t\tpipeline.hexpire(UpstashCache.tagsMapKey, key, ttlSeconds, hexOptions); // Set expiration for the tag\n\t\t}\n\n\t\tfor (const table of tables) {\n\t\t\tpipeline.sadd(this.addTablePrefix(table), compositeKey);\n\t\t}\n\n\t\tawait pipeline.exec();\n\t}\n\n\toverride async onMutate(params: MutationOption) {\n\t\tconst tags = Array.isArray(params.tags) ? params.tags : params.tags ? [params.tags] : [];\n\t\tconst tables = Array.isArray(params.tables) ? params.tables : params.tables ? [params.tables] : [];\n\t\tconst tableNames: string[] = tables.map((table) => is(table, Table) ? table[OriginalName] : table as string);\n\n\t\tconst compositeTableSets = tableNames.map((table) => this.addTablePrefix(table));\n\t\tawait this.luaScripts.onMutateScript.exec([UpstashCache.tagsMapKey, ...compositeTableSets], tags);\n\t}\n\n\tprivate addTablePrefix = (table: string) => `${UpstashCache.compositeTableSetPrefix}${table}`;\n\tprivate getCompositeKey = (tables: string[]) => `${UpstashCache.compositeTablePrefix}${tables.sort().join(',')}`;\n}\n\nexport function upstashCache(\n\t{ url, token, config, global = false }: { url: string; token: string; config?: CacheConfig; global?: boolean },\n): UpstashCache {\n\tconst redis = new Redis({\n\t\turl,\n\t\ttoken,\n\t});\n\n\treturn new UpstashCache(redis, config, global);\n}\n"],"mappings":";;;;;;;;;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