drizzle-orm 0.39.2 → 0.40.0-262a7b0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/column-builder.cjs.map +1 -1
- package/column-builder.d.cts +6 -5
- package/column-builder.d.ts +6 -5
- package/column-builder.js.map +1 -1
- package/gel/driver.cjs +97 -0
- package/gel/driver.cjs.map +1 -0
- package/gel/driver.d.cts +38 -0
- package/gel/driver.d.ts +38 -0
- package/gel/driver.js +74 -0
- package/gel/driver.js.map +1 -0
- package/gel/index.cjs +25 -0
- package/gel/index.cjs.map +1 -0
- package/gel/index.d.cts +2 -0
- package/gel/index.d.ts +2 -0
- package/gel/index.js +3 -0
- package/gel/index.js.map +1 -0
- package/gel/migrator.cjs +5 -0
- package/gel/migrator.cjs.map +1 -0
- package/gel/migrator.d.cts +1 -0
- package/gel/migrator.d.ts +1 -0
- package/gel/migrator.js +4 -0
- package/gel/migrator.js.map +1 -0
- package/gel/session.cjs +139 -0
- package/gel/session.cjs.map +1 -0
- package/gel/session.d.cts +47 -0
- package/gel/session.d.ts +47 -0
- package/gel/session.js +113 -0
- package/gel/session.js.map +1 -0
- package/gel-core/alias.cjs +32 -0
- package/gel-core/alias.cjs.map +1 -0
- package/gel-core/alias.d.cts +4 -0
- package/gel-core/alias.d.ts +4 -0
- package/gel-core/alias.js +8 -0
- package/gel-core/alias.js.map +1 -0
- package/gel-core/checks.cjs +58 -0
- package/gel-core/checks.cjs.map +1 -0
- package/gel-core/checks.d.cts +18 -0
- package/gel-core/checks.d.ts +18 -0
- package/gel-core/checks.js +32 -0
- package/gel-core/checks.js.map +1 -0
- package/gel-core/columns/all.cjs +72 -0
- package/gel-core/columns/all.cjs.map +1 -0
- package/gel-core/columns/all.d.cts +43 -0
- package/gel-core/columns/all.d.ts +43 -0
- package/gel-core/columns/all.js +48 -0
- package/gel-core/columns/all.js.map +1 -0
- package/gel-core/columns/bigint.cjs +54 -0
- package/gel-core/columns/bigint.cjs.map +1 -0
- package/gel-core/columns/bigint.d.cts +23 -0
- package/gel-core/columns/bigint.d.ts +23 -0
- package/gel-core/columns/bigint.js +28 -0
- package/gel-core/columns/bigint.js.map +1 -0
- package/gel-core/columns/bigintT.cjs +60 -0
- package/gel-core/columns/bigintT.cjs.map +1 -0
- package/gel-core/columns/bigintT.d.cts +24 -0
- package/gel-core/columns/bigintT.d.ts +24 -0
- package/gel-core/columns/bigintT.js +34 -0
- package/gel-core/columns/bigintT.js.map +1 -0
- package/gel-core/columns/boolean.cjs +53 -0
- package/gel-core/columns/boolean.cjs.map +1 -0
- package/gel-core/columns/boolean.d.cts +22 -0
- package/gel-core/columns/boolean.d.ts +22 -0
- package/gel-core/columns/boolean.js +27 -0
- package/gel-core/columns/boolean.js.map +1 -0
- package/gel-core/columns/bytes.cjs +56 -0
- package/gel-core/columns/bytes.cjs.map +1 -0
- package/gel-core/columns/bytes.d.cts +22 -0
- package/gel-core/columns/bytes.d.ts +22 -0
- package/gel-core/columns/bytes.js +30 -0
- package/gel-core/columns/bytes.js.map +1 -0
- package/gel-core/columns/common.cjs +213 -0
- package/gel-core/columns/common.cjs.map +1 -0
- package/gel-core/columns/common.d.cts +147 -0
- package/gel-core/columns/common.d.ts +147 -0
- package/gel-core/columns/common.js +184 -0
- package/gel-core/columns/common.js.map +1 -0
- package/gel-core/columns/custom.cjs +77 -0
- package/gel-core/columns/custom.cjs.map +1 -0
- package/gel-core/columns/custom.d.cts +155 -0
- package/gel-core/columns/custom.d.ts +155 -0
- package/gel-core/columns/custom.js +51 -0
- package/gel-core/columns/custom.js.map +1 -0
- package/gel-core/columns/date-duration.cjs +56 -0
- package/gel-core/columns/date-duration.cjs.map +1 -0
- package/gel-core/columns/date-duration.d.cts +23 -0
- package/gel-core/columns/date-duration.d.ts +23 -0
- package/gel-core/columns/date-duration.js +30 -0
- package/gel-core/columns/date-duration.js.map +1 -0
- package/gel-core/columns/date.common.cjs +37 -0
- package/gel-core/columns/date.common.cjs.map +1 -0
- package/gel-core/columns/date.common.d.cts +7 -0
- package/gel-core/columns/date.common.d.ts +7 -0
- package/gel-core/columns/date.common.js +13 -0
- package/gel-core/columns/date.common.js.map +1 -0
- package/gel-core/columns/decimal.cjs +56 -0
- package/gel-core/columns/decimal.cjs.map +1 -0
- package/gel-core/columns/decimal.d.cts +26 -0
- package/gel-core/columns/decimal.d.ts +26 -0
- package/gel-core/columns/decimal.js +30 -0
- package/gel-core/columns/decimal.js.map +1 -0
- package/gel-core/columns/double-precision.cjs +62 -0
- package/gel-core/columns/double-precision.cjs.map +1 -0
- package/gel-core/columns/double-precision.d.cts +23 -0
- package/gel-core/columns/double-precision.d.ts +23 -0
- package/gel-core/columns/double-precision.js +36 -0
- package/gel-core/columns/double-precision.js.map +1 -0
- package/gel-core/columns/duration.cjs +53 -0
- package/gel-core/columns/duration.cjs.map +1 -0
- package/gel-core/columns/duration.d.cts +23 -0
- package/gel-core/columns/duration.d.ts +23 -0
- package/gel-core/columns/duration.js +27 -0
- package/gel-core/columns/duration.js.map +1 -0
- package/gel-core/columns/index.cjs +65 -0
- package/gel-core/columns/index.cjs.map +1 -0
- package/gel-core/columns/index.d.cts +22 -0
- package/gel-core/columns/index.d.ts +22 -0
- package/gel-core/columns/index.js +23 -0
- package/gel-core/columns/index.js.map +1 -0
- package/gel-core/columns/int.common.cjs +67 -0
- package/gel-core/columns/int.common.cjs.map +1 -0
- package/gel-core/columns/int.common.d.cts +15 -0
- package/gel-core/columns/int.common.d.ts +15 -0
- package/gel-core/columns/int.common.js +43 -0
- package/gel-core/columns/int.common.js.map +1 -0
- package/gel-core/columns/integer.cjs +54 -0
- package/gel-core/columns/integer.cjs.map +1 -0
- package/gel-core/columns/integer.d.cts +23 -0
- package/gel-core/columns/integer.d.ts +23 -0
- package/gel-core/columns/integer.js +28 -0
- package/gel-core/columns/integer.js.map +1 -0
- package/gel-core/columns/json.cjs +56 -0
- package/gel-core/columns/json.cjs.map +1 -0
- package/gel-core/columns/json.d.cts +26 -0
- package/gel-core/columns/json.d.ts +26 -0
- package/gel-core/columns/json.js +30 -0
- package/gel-core/columns/json.js.map +1 -0
- package/gel-core/columns/localdate.cjs +57 -0
- package/gel-core/columns/localdate.cjs.map +1 -0
- package/gel-core/columns/localdate.d.cts +24 -0
- package/gel-core/columns/localdate.d.ts +24 -0
- package/gel-core/columns/localdate.js +31 -0
- package/gel-core/columns/localdate.js.map +1 -0
- package/gel-core/columns/localtime.cjs +57 -0
- package/gel-core/columns/localtime.cjs.map +1 -0
- package/gel-core/columns/localtime.d.cts +24 -0
- package/gel-core/columns/localtime.d.ts +24 -0
- package/gel-core/columns/localtime.js +31 -0
- package/gel-core/columns/localtime.js.map +1 -0
- package/gel-core/columns/real.cjs +57 -0
- package/gel-core/columns/real.cjs.map +1 -0
- package/gel-core/columns/real.d.cts +28 -0
- package/gel-core/columns/real.d.ts +28 -0
- package/gel-core/columns/real.js +31 -0
- package/gel-core/columns/real.js.map +1 -0
- package/gel-core/columns/relative-duration.cjs +56 -0
- package/gel-core/columns/relative-duration.cjs.map +1 -0
- package/gel-core/columns/relative-duration.d.cts +23 -0
- package/gel-core/columns/relative-duration.d.ts +23 -0
- package/gel-core/columns/relative-duration.js +30 -0
- package/gel-core/columns/relative-duration.js.map +1 -0
- package/gel-core/columns/smallint.cjs +54 -0
- package/gel-core/columns/smallint.cjs.map +1 -0
- package/gel-core/columns/smallint.d.cts +23 -0
- package/gel-core/columns/smallint.d.ts +23 -0
- package/gel-core/columns/smallint.js +28 -0
- package/gel-core/columns/smallint.js.map +1 -0
- package/gel-core/columns/text.cjs +54 -0
- package/gel-core/columns/text.cjs.map +1 -0
- package/gel-core/columns/text.d.cts +26 -0
- package/gel-core/columns/text.d.ts +26 -0
- package/gel-core/columns/text.js +28 -0
- package/gel-core/columns/text.js.map +1 -0
- package/gel-core/columns/timestamp.cjs +60 -0
- package/gel-core/columns/timestamp.cjs.map +1 -0
- package/gel-core/columns/timestamp.d.cts +28 -0
- package/gel-core/columns/timestamp.d.ts +28 -0
- package/gel-core/columns/timestamp.js +34 -0
- package/gel-core/columns/timestamp.js.map +1 -0
- package/gel-core/columns/timestamptz.cjs +60 -0
- package/gel-core/columns/timestamptz.cjs.map +1 -0
- package/gel-core/columns/timestamptz.d.cts +27 -0
- package/gel-core/columns/timestamptz.d.ts +27 -0
- package/gel-core/columns/timestamptz.js +34 -0
- package/gel-core/columns/timestamptz.js.map +1 -0
- package/gel-core/columns/uuid.cjs +53 -0
- package/gel-core/columns/uuid.cjs.map +1 -0
- package/gel-core/columns/uuid.d.cts +22 -0
- package/gel-core/columns/uuid.d.ts +22 -0
- package/gel-core/columns/uuid.js +27 -0
- package/gel-core/columns/uuid.js.map +1 -0
- package/gel-core/db.cjs +338 -0
- package/gel-core/db.cjs.map +1 -0
- package/gel-core/db.d.cts +281 -0
- package/gel-core/db.d.ts +281 -0
- package/gel-core/db.js +319 -0
- package/gel-core/db.js.map +1 -0
- package/gel-core/dialect.cjs +1142 -0
- package/gel-core/dialect.cjs.map +1 -0
- package/gel-core/dialect.d.cts +62 -0
- package/gel-core/dialect.d.ts +62 -0
- package/gel-core/dialect.js +1128 -0
- package/gel-core/dialect.js.map +1 -0
- package/gel-core/expressions.cjs +49 -0
- package/gel-core/expressions.cjs.map +1 -0
- package/gel-core/expressions.d.cts +8 -0
- package/gel-core/expressions.d.ts +8 -0
- package/gel-core/expressions.js +22 -0
- package/gel-core/expressions.js.map +1 -0
- package/gel-core/foreign-keys.cjs +100 -0
- package/gel-core/foreign-keys.cjs.map +1 -0
- package/gel-core/foreign-keys.d.cts +48 -0
- package/gel-core/foreign-keys.d.ts +48 -0
- package/gel-core/foreign-keys.js +74 -0
- package/gel-core/foreign-keys.js.map +1 -0
- package/gel-core/index.cjs +61 -0
- package/gel-core/index.cjs.map +1 -0
- package/gel-core/index.d.cts +20 -0
- package/gel-core/index.d.ts +20 -0
- package/gel-core/index.js +21 -0
- package/gel-core/index.js.map +1 -0
- package/gel-core/indexes.cjs +149 -0
- package/gel-core/indexes.cjs.map +1 -0
- package/gel-core/indexes.d.cts +79 -0
- package/gel-core/indexes.d.ts +79 -0
- package/gel-core/indexes.js +121 -0
- package/gel-core/indexes.js.map +1 -0
- package/gel-core/policies.cjs +58 -0
- package/gel-core/policies.cjs.map +1 -0
- package/gel-core/policies.d.cts +24 -0
- package/gel-core/policies.d.ts +24 -0
- package/gel-core/policies.js +33 -0
- package/gel-core/policies.js.map +1 -0
- package/gel-core/primary-keys.cjs +68 -0
- package/gel-core/primary-keys.cjs.map +1 -0
- package/gel-core/primary-keys.d.cts +30 -0
- package/gel-core/primary-keys.d.ts +30 -0
- package/gel-core/primary-keys.js +42 -0
- package/gel-core/primary-keys.js.map +1 -0
- package/gel-core/query-builders/count.cjs +73 -0
- package/gel-core/query-builders/count.cjs.map +1 -0
- package/gel-core/query-builders/count.d.cts +25 -0
- package/gel-core/query-builders/count.d.ts +25 -0
- package/gel-core/query-builders/count.js +49 -0
- package/gel-core/query-builders/count.js.map +1 -0
- package/gel-core/query-builders/delete.cjs +105 -0
- package/gel-core/query-builders/delete.cjs.map +1 -0
- package/gel-core/query-builders/delete.d.cts +99 -0
- package/gel-core/query-builders/delete.d.ts +99 -0
- package/gel-core/query-builders/delete.js +81 -0
- package/gel-core/query-builders/delete.js.map +1 -0
- package/gel-core/query-builders/index.cjs +35 -0
- package/gel-core/query-builders/index.cjs.map +1 -0
- package/gel-core/query-builders/index.d.cts +7 -0
- package/gel-core/query-builders/index.d.ts +7 -0
- package/gel-core/query-builders/index.js +8 -0
- package/gel-core/query-builders/index.js.map +1 -0
- package/gel-core/query-builders/insert.cjs +218 -0
- package/gel-core/query-builders/insert.cjs.map +1 -0
- package/gel-core/query-builders/insert.d.cts +116 -0
- package/gel-core/query-builders/insert.d.ts +116 -0
- package/gel-core/query-builders/insert.js +193 -0
- package/gel-core/query-builders/insert.js.map +1 -0
- package/gel-core/query-builders/query-builder.cjs +114 -0
- package/gel-core/query-builders/query-builder.cjs.map +1 -0
- package/gel-core/query-builders/query-builder.d.cts +40 -0
- package/gel-core/query-builders/query-builder.d.ts +40 -0
- package/gel-core/query-builders/query-builder.js +90 -0
- package/gel-core/query-builders/query-builder.js.map +1 -0
- package/gel-core/query-builders/query.cjs +139 -0
- package/gel-core/query-builders/query.cjs.map +1 -0
- package/gel-core/query-builders/query.d.cts +46 -0
- package/gel-core/query-builders/query.d.ts +46 -0
- package/gel-core/query-builders/query.js +116 -0
- package/gel-core/query-builders/query.js.map +1 -0
- package/gel-core/query-builders/raw.cjs +57 -0
- package/gel-core/query-builders/raw.cjs.map +1 -0
- package/gel-core/query-builders/raw.d.cts +22 -0
- package/gel-core/query-builders/raw.d.ts +22 -0
- package/gel-core/query-builders/raw.js +33 -0
- package/gel-core/query-builders/raw.js.map +1 -0
- package/gel-core/query-builders/refresh-materialized-view.cjs +77 -0
- package/gel-core/query-builders/refresh-materialized-view.cjs.map +1 -0
- package/gel-core/query-builders/refresh-materialized-view.d.cts +27 -0
- package/gel-core/query-builders/refresh-materialized-view.d.ts +27 -0
- package/gel-core/query-builders/refresh-materialized-view.js +53 -0
- package/gel-core/query-builders/refresh-materialized-view.js.map +1 -0
- package/gel-core/query-builders/select.cjs +775 -0
- package/gel-core/query-builders/select.cjs.map +1 -0
- package/gel-core/query-builders/select.d.cts +721 -0
- package/gel-core/query-builders/select.d.ts +721 -0
- package/gel-core/query-builders/select.js +748 -0
- package/gel-core/query-builders/select.js.map +1 -0
- package/gel-core/query-builders/select.types.cjs +17 -0
- package/gel-core/query-builders/select.types.cjs.map +1 -0
- package/gel-core/query-builders/select.types.d.cts +138 -0
- package/gel-core/query-builders/select.types.d.ts +138 -0
- package/gel-core/query-builders/select.types.js +1 -0
- package/gel-core/query-builders/select.types.js.map +1 -0
- package/gel-core/query-builders/update.cjs +226 -0
- package/gel-core/query-builders/update.cjs.map +1 -0
- package/gel-core/query-builders/update.d.cts +166 -0
- package/gel-core/query-builders/update.d.ts +166 -0
- package/gel-core/query-builders/update.js +205 -0
- package/gel-core/query-builders/update.js.map +1 -0
- package/gel-core/roles.cjs +57 -0
- package/gel-core/roles.cjs.map +1 -0
- package/gel-core/roles.d.cts +13 -0
- package/gel-core/roles.d.ts +13 -0
- package/gel-core/roles.js +32 -0
- package/gel-core/roles.js.map +1 -0
- package/gel-core/schema.cjs +74 -0
- package/gel-core/schema.cjs.map +1 -0
- package/gel-core/schema.d.cts +15 -0
- package/gel-core/schema.d.ts +15 -0
- package/gel-core/schema.js +48 -0
- package/gel-core/schema.js.map +1 -0
- package/gel-core/sequence.cjs +52 -0
- package/gel-core/sequence.cjs.map +1 -0
- package/gel-core/sequence.d.cts +18 -0
- package/gel-core/sequence.d.ts +18 -0
- package/gel-core/sequence.js +25 -0
- package/gel-core/sequence.js.map +1 -0
- package/gel-core/session.cjs +94 -0
- package/gel-core/session.cjs.map +1 -0
- package/gel-core/session.d.cts +56 -0
- package/gel-core/session.d.ts +56 -0
- package/gel-core/session.js +68 -0
- package/gel-core/session.js.map +1 -0
- package/gel-core/subquery.cjs +17 -0
- package/gel-core/subquery.cjs.map +1 -0
- package/gel-core/subquery.d.cts +5 -0
- package/gel-core/subquery.d.ts +5 -0
- package/gel-core/subquery.js +1 -0
- package/gel-core/subquery.js.map +1 -0
- package/gel-core/table.cjs +100 -0
- package/gel-core/table.cjs.map +1 -0
- package/gel-core/table.d.cts +95 -0
- package/gel-core/table.d.ts +95 -0
- package/gel-core/table.js +71 -0
- package/gel-core/table.js.map +1 -0
- package/gel-core/unique-constraint.cjs +89 -0
- package/gel-core/unique-constraint.cjs.map +1 -0
- package/gel-core/unique-constraint.d.cts +25 -0
- package/gel-core/unique-constraint.d.ts +25 -0
- package/gel-core/unique-constraint.js +61 -0
- package/gel-core/unique-constraint.js.map +1 -0
- package/gel-core/utils.cjs +100 -0
- package/gel-core/utils.cjs.map +1 -0
- package/gel-core/utils.d.cts +51 -0
- package/gel-core/utils.d.ts +51 -0
- package/gel-core/utils.js +74 -0
- package/gel-core/utils.js.map +1 -0
- package/gel-core/view-base.cjs +33 -0
- package/gel-core/view-base.cjs.map +1 -0
- package/gel-core/view-base.d.cts +8 -0
- package/gel-core/view-base.d.ts +8 -0
- package/gel-core/view-base.js +9 -0
- package/gel-core/view-base.js.map +1 -0
- package/gel-core/view-common.cjs +29 -0
- package/gel-core/view-common.cjs.map +1 -0
- package/gel-core/view-common.d.cts +1 -0
- package/gel-core/view-common.d.ts +1 -0
- package/gel-core/view-common.js +5 -0
- package/gel-core/view-common.js.map +1 -0
- package/gel-core/view.cjs +302 -0
- package/gel-core/view.cjs.map +1 -0
- package/gel-core/view.d.cts +150 -0
- package/gel-core/view.d.ts +150 -0
- package/gel-core/view.js +268 -0
- package/gel-core/view.js.map +1 -0
- package/package.json +1062 -325
- package/pg-core/table.cjs +2 -0
- package/pg-core/table.cjs.map +1 -1
- package/pg-core/table.js +2 -0
- package/pg-core/table.js.map +1 -1
- package/table.cjs.map +1 -1
- package/table.js.map +1 -1
- package/version.cjs +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/gel-core/index.ts"],"sourcesContent":["export * from './alias.ts';\nexport * from './checks.ts';\nexport * from './columns/index.ts';\nexport * from './db.ts';\nexport * from './dialect.ts';\nexport * from './foreign-keys.ts';\nexport * from './indexes.ts';\nexport * from './policies.ts';\nexport * from './primary-keys.ts';\nexport * from './query-builders/index.ts';\nexport * from './roles.ts';\nexport * from './schema.ts';\nexport * from './sequence.ts';\nexport * from './session.ts';\nexport * from './subquery.ts';\nexport * from './table.ts';\nexport * from './unique-constraint.ts';\nexport * from './utils.ts';\nexport * from './view-common.ts';\nexport * from './view.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAc,uBAAd;AACA,6BAAc,wBADd;AAEA,6BAAc,+BAFd;AAGA,6BAAc,oBAHd;AAIA,6BAAc,yBAJd;AAKA,6BAAc,8BALd;AAMA,6BAAc,yBANd;AAOA,6BAAc,0BAPd;AAQA,6BAAc,8BARd;AASA,6BAAc,sCATd;AAUA,6BAAc,uBAVd;AAWA,6BAAc,wBAXd;AAYA,6BAAc,0BAZd;AAaA,6BAAc,yBAbd;AAcA,6BAAc,0BAdd;AAeA,6BAAc,uBAfd;AAgBA,6BAAc,mCAhBd;AAiBA,6BAAc,uBAjBd;AAkBA,6BAAc,6BAlBd;AAmBA,6BAAc,sBAnBd;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from "./alias.cjs";
|
|
2
|
+
export * from "./checks.cjs";
|
|
3
|
+
export * from "./columns/index.cjs";
|
|
4
|
+
export * from "./db.cjs";
|
|
5
|
+
export * from "./dialect.cjs";
|
|
6
|
+
export * from "./foreign-keys.cjs";
|
|
7
|
+
export * from "./indexes.cjs";
|
|
8
|
+
export * from "./policies.cjs";
|
|
9
|
+
export * from "./primary-keys.cjs";
|
|
10
|
+
export * from "./query-builders/index.cjs";
|
|
11
|
+
export * from "./roles.cjs";
|
|
12
|
+
export * from "./schema.cjs";
|
|
13
|
+
export * from "./sequence.cjs";
|
|
14
|
+
export * from "./session.cjs";
|
|
15
|
+
export * from "./subquery.cjs";
|
|
16
|
+
export * from "./table.cjs";
|
|
17
|
+
export * from "./unique-constraint.cjs";
|
|
18
|
+
export * from "./utils.cjs";
|
|
19
|
+
export * from "./view-common.cjs";
|
|
20
|
+
export * from "./view.cjs";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from "./alias.js";
|
|
2
|
+
export * from "./checks.js";
|
|
3
|
+
export * from "./columns/index.js";
|
|
4
|
+
export * from "./db.js";
|
|
5
|
+
export * from "./dialect.js";
|
|
6
|
+
export * from "./foreign-keys.js";
|
|
7
|
+
export * from "./indexes.js";
|
|
8
|
+
export * from "./policies.js";
|
|
9
|
+
export * from "./primary-keys.js";
|
|
10
|
+
export * from "./query-builders/index.js";
|
|
11
|
+
export * from "./roles.js";
|
|
12
|
+
export * from "./schema.js";
|
|
13
|
+
export * from "./sequence.js";
|
|
14
|
+
export * from "./session.js";
|
|
15
|
+
export * from "./subquery.js";
|
|
16
|
+
export * from "./table.js";
|
|
17
|
+
export * from "./unique-constraint.js";
|
|
18
|
+
export * from "./utils.js";
|
|
19
|
+
export * from "./view-common.js";
|
|
20
|
+
export * from "./view.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from "./alias.js";
|
|
2
|
+
export * from "./checks.js";
|
|
3
|
+
export * from "./columns/index.js";
|
|
4
|
+
export * from "./db.js";
|
|
5
|
+
export * from "./dialect.js";
|
|
6
|
+
export * from "./foreign-keys.js";
|
|
7
|
+
export * from "./indexes.js";
|
|
8
|
+
export * from "./policies.js";
|
|
9
|
+
export * from "./primary-keys.js";
|
|
10
|
+
export * from "./query-builders/index.js";
|
|
11
|
+
export * from "./roles.js";
|
|
12
|
+
export * from "./schema.js";
|
|
13
|
+
export * from "./sequence.js";
|
|
14
|
+
export * from "./session.js";
|
|
15
|
+
export * from "./subquery.js";
|
|
16
|
+
export * from "./table.js";
|
|
17
|
+
export * from "./unique-constraint.js";
|
|
18
|
+
export * from "./utils.js";
|
|
19
|
+
export * from "./view-common.js";
|
|
20
|
+
export * from "./view.js";
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/gel-core/index.ts"],"sourcesContent":["export * from './alias.ts';\nexport * from './checks.ts';\nexport * from './columns/index.ts';\nexport * from './db.ts';\nexport * from './dialect.ts';\nexport * from './foreign-keys.ts';\nexport * from './indexes.ts';\nexport * from './policies.ts';\nexport * from './primary-keys.ts';\nexport * from './query-builders/index.ts';\nexport * from './roles.ts';\nexport * from './schema.ts';\nexport * from './sequence.ts';\nexport * from './session.ts';\nexport * from './subquery.ts';\nexport * from './table.ts';\nexport * from './unique-constraint.ts';\nexport * from './utils.ts';\nexport * from './view-common.ts';\nexport * from './view.ts';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,149 @@
|
|
|
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 indexes_exports = {};
|
|
20
|
+
__export(indexes_exports, {
|
|
21
|
+
Index: () => Index,
|
|
22
|
+
IndexBuilder: () => IndexBuilder,
|
|
23
|
+
IndexBuilderOn: () => IndexBuilderOn,
|
|
24
|
+
index: () => index,
|
|
25
|
+
uniqueIndex: () => uniqueIndex
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(indexes_exports);
|
|
28
|
+
var import_sql = require("../sql/sql.cjs");
|
|
29
|
+
var import_entity = require("../entity.cjs");
|
|
30
|
+
var import_columns = require("./columns/index.cjs");
|
|
31
|
+
class IndexBuilderOn {
|
|
32
|
+
constructor(unique, name) {
|
|
33
|
+
this.unique = unique;
|
|
34
|
+
this.name = name;
|
|
35
|
+
}
|
|
36
|
+
static [import_entity.entityKind] = "GelIndexBuilderOn";
|
|
37
|
+
on(...columns) {
|
|
38
|
+
return new IndexBuilder(
|
|
39
|
+
columns.map((it) => {
|
|
40
|
+
if ((0, import_entity.is)(it, import_sql.SQL)) {
|
|
41
|
+
return it;
|
|
42
|
+
}
|
|
43
|
+
it = it;
|
|
44
|
+
const clonedIndexedColumn = new import_columns.IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
|
45
|
+
it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
|
|
46
|
+
return clonedIndexedColumn;
|
|
47
|
+
}),
|
|
48
|
+
this.unique,
|
|
49
|
+
false,
|
|
50
|
+
this.name
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
onOnly(...columns) {
|
|
54
|
+
return new IndexBuilder(
|
|
55
|
+
columns.map((it) => {
|
|
56
|
+
if ((0, import_entity.is)(it, import_sql.SQL)) {
|
|
57
|
+
return it;
|
|
58
|
+
}
|
|
59
|
+
it = it;
|
|
60
|
+
const clonedIndexedColumn = new import_columns.IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
|
61
|
+
it.indexConfig = it.defaultConfig;
|
|
62
|
+
return clonedIndexedColumn;
|
|
63
|
+
}),
|
|
64
|
+
this.unique,
|
|
65
|
+
true,
|
|
66
|
+
this.name
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Specify what index method to use. Choices are `btree`, `hash`, `gist`, `sGelist`, `gin`, `brin`, or user-installed access methods like `bloom`. The default method is `btree.
|
|
71
|
+
*
|
|
72
|
+
* If you have the `Gel_vector` extension installed in your database, you can use the `hnsw` and `ivfflat` options, which are predefined types.
|
|
73
|
+
*
|
|
74
|
+
* **You can always specify any string you want in the method, in case Drizzle doesn't have it natively in its types**
|
|
75
|
+
*
|
|
76
|
+
* @param method The name of the index method to be used
|
|
77
|
+
* @param columns
|
|
78
|
+
* @returns
|
|
79
|
+
*/
|
|
80
|
+
using(method, ...columns) {
|
|
81
|
+
return new IndexBuilder(
|
|
82
|
+
columns.map((it) => {
|
|
83
|
+
if ((0, import_entity.is)(it, import_sql.SQL)) {
|
|
84
|
+
return it;
|
|
85
|
+
}
|
|
86
|
+
it = it;
|
|
87
|
+
const clonedIndexedColumn = new import_columns.IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
|
88
|
+
it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
|
|
89
|
+
return clonedIndexedColumn;
|
|
90
|
+
}),
|
|
91
|
+
this.unique,
|
|
92
|
+
true,
|
|
93
|
+
this.name,
|
|
94
|
+
method
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
class IndexBuilder {
|
|
99
|
+
static [import_entity.entityKind] = "GelIndexBuilder";
|
|
100
|
+
/** @internal */
|
|
101
|
+
config;
|
|
102
|
+
constructor(columns, unique, only, name, method = "btree") {
|
|
103
|
+
this.config = {
|
|
104
|
+
name,
|
|
105
|
+
columns,
|
|
106
|
+
unique,
|
|
107
|
+
only,
|
|
108
|
+
method
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
concurrently() {
|
|
112
|
+
this.config.concurrently = true;
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
with(obj) {
|
|
116
|
+
this.config.with = obj;
|
|
117
|
+
return this;
|
|
118
|
+
}
|
|
119
|
+
where(condition) {
|
|
120
|
+
this.config.where = condition;
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
123
|
+
/** @internal */
|
|
124
|
+
build(table) {
|
|
125
|
+
return new Index(this.config, table);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
class Index {
|
|
129
|
+
static [import_entity.entityKind] = "GelIndex";
|
|
130
|
+
config;
|
|
131
|
+
constructor(config, table) {
|
|
132
|
+
this.config = { ...config, table };
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function index(name) {
|
|
136
|
+
return new IndexBuilderOn(false, name);
|
|
137
|
+
}
|
|
138
|
+
function uniqueIndex(name) {
|
|
139
|
+
return new IndexBuilderOn(true, name);
|
|
140
|
+
}
|
|
141
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
142
|
+
0 && (module.exports = {
|
|
143
|
+
Index,
|
|
144
|
+
IndexBuilder,
|
|
145
|
+
IndexBuilderOn,
|
|
146
|
+
index,
|
|
147
|
+
uniqueIndex
|
|
148
|
+
});
|
|
149
|
+
//# sourceMappingURL=indexes.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/gel-core/indexes.ts"],"sourcesContent":["import { SQL } from '~/sql/sql.ts';\n\nimport { entityKind, is } from '~/entity.ts';\nimport type { GelColumn, GelExtraConfigColumn } from './columns/index.ts';\nimport { IndexedColumn } from './columns/index.ts';\nimport type { GelTable } from './table.ts';\n\ninterface IndexConfig {\n\tname?: string;\n\n\tcolumns: Partial<IndexedColumn | SQL>[];\n\n\t/**\n\t * If true, the index will be created as `create unique index` instead of `create index`.\n\t */\n\tunique: boolean;\n\n\t/**\n\t * If true, the index will be created as `create index concurrently` instead of `create index`.\n\t */\n\tconcurrently?: boolean;\n\n\t/**\n\t * If true, the index will be created as `create index ... on only <table>` instead of `create index ... on <table>`.\n\t */\n\tonly: boolean;\n\n\t/**\n\t * Condition for partial index.\n\t */\n\twhere?: SQL;\n\n\t/**\n\t * The optional WITH clause specifies storage parameters for the index\n\t */\n\twith?: Record<string, any>;\n\n\t/**\n\t * The optional WITH clause method for the index\n\t */\n\tmethod?: 'btree' | string;\n}\n\nexport type IndexColumn = GelColumn;\n\nexport type GelIndexMethod =\n\t| 'btree'\n\t| 'hash'\n\t| 'gist'\n\t| 'sGelist'\n\t| 'gin'\n\t| 'brin'\n\t| 'hnsw'\n\t| 'ivfflat'\n\t| (string & {});\n\nexport type GelIndexOpClass =\n\t| 'abstime_ops'\n\t| 'access_method'\n\t| 'anyarray_eq'\n\t| 'anyarray_ge'\n\t| 'anyarray_gt'\n\t| 'anyarray_le'\n\t| 'anyarray_lt'\n\t| 'anyarray_ne'\n\t| 'bigint_ops'\n\t| 'bit_ops'\n\t| 'bool_ops'\n\t| 'box_ops'\n\t| 'bpchar_ops'\n\t| 'char_ops'\n\t| 'cidr_ops'\n\t| 'cstring_ops'\n\t| 'date_ops'\n\t| 'float_ops'\n\t| 'int2_ops'\n\t| 'int4_ops'\n\t| 'int8_ops'\n\t| 'interval_ops'\n\t| 'jsonb_ops'\n\t| 'macaddr_ops'\n\t| 'name_ops'\n\t| 'numeric_ops'\n\t| 'oid_ops'\n\t| 'oidint4_ops'\n\t| 'oidint8_ops'\n\t| 'oidname_ops'\n\t| 'oidvector_ops'\n\t| 'point_ops'\n\t| 'polygon_ops'\n\t| 'range_ops'\n\t| 'record_eq'\n\t| 'record_ge'\n\t| 'record_gt'\n\t| 'record_le'\n\t| 'record_lt'\n\t| 'record_ne'\n\t| 'text_ops'\n\t| 'time_ops'\n\t| 'timestamp_ops'\n\t| 'timestamptz_ops'\n\t| 'timetz_ops'\n\t| 'uuid_ops'\n\t| 'varbit_ops'\n\t| 'varchar_ops'\n\t| 'xml_ops'\n\t| 'vector_l2_ops'\n\t| 'vector_ip_ops'\n\t| 'vector_cosine_ops'\n\t| 'vector_l1_ops'\n\t| 'bit_hamming_ops'\n\t| 'bit_jaccard_ops'\n\t| 'halfvec_l2_ops'\n\t| 'sparsevec_l2_op'\n\t| (string & {});\n\nexport class IndexBuilderOn {\n\tstatic readonly [entityKind]: string = 'GelIndexBuilderOn';\n\n\tconstructor(private unique: boolean, private name?: string) {}\n\n\ton(...columns: [Partial<GelExtraConfigColumn> | SQL, ...Partial<GelExtraConfigColumn | SQL>[]]): IndexBuilder {\n\t\treturn new IndexBuilder(\n\t\t\tcolumns.map((it) => {\n\t\t\t\tif (is(it, SQL)) {\n\t\t\t\t\treturn it;\n\t\t\t\t}\n\t\t\t\tit = it as GelExtraConfigColumn;\n\t\t\t\tconst clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType!, it.indexConfig!);\n\t\t\t\tit.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));\n\t\t\t\treturn clonedIndexedColumn;\n\t\t\t}),\n\t\t\tthis.unique,\n\t\t\tfalse,\n\t\t\tthis.name,\n\t\t);\n\t}\n\n\tonOnly(...columns: [Partial<GelExtraConfigColumn | SQL>, ...Partial<GelExtraConfigColumn | SQL>[]]): IndexBuilder {\n\t\treturn new IndexBuilder(\n\t\t\tcolumns.map((it) => {\n\t\t\t\tif (is(it, SQL)) {\n\t\t\t\t\treturn it;\n\t\t\t\t}\n\t\t\t\tit = it as GelExtraConfigColumn;\n\t\t\t\tconst clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType!, it.indexConfig!);\n\t\t\t\tit.indexConfig = it.defaultConfig;\n\t\t\t\treturn clonedIndexedColumn;\n\t\t\t}),\n\t\t\tthis.unique,\n\t\t\ttrue,\n\t\t\tthis.name,\n\t\t);\n\t}\n\n\t/**\n\t * Specify what index method to use. Choices are `btree`, `hash`, `gist`, `sGelist`, `gin`, `brin`, or user-installed access methods like `bloom`. The default method is `btree.\n\t *\n\t * If you have the `Gel_vector` extension installed in your database, you can use the `hnsw` and `ivfflat` options, which are predefined types.\n\t *\n\t * **You can always specify any string you want in the method, in case Drizzle doesn't have it natively in its types**\n\t *\n\t * @param method The name of the index method to be used\n\t * @param columns\n\t * @returns\n\t */\n\tusing(\n\t\tmethod: GelIndexMethod,\n\t\t...columns: [Partial<GelExtraConfigColumn | SQL>, ...Partial<GelExtraConfigColumn | SQL>[]]\n\t): IndexBuilder {\n\t\treturn new IndexBuilder(\n\t\t\tcolumns.map((it) => {\n\t\t\t\tif (is(it, SQL)) {\n\t\t\t\t\treturn it;\n\t\t\t\t}\n\t\t\t\tit = it as GelExtraConfigColumn;\n\t\t\t\tconst clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType!, it.indexConfig!);\n\t\t\t\tit.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));\n\t\t\t\treturn clonedIndexedColumn;\n\t\t\t}),\n\t\t\tthis.unique,\n\t\t\ttrue,\n\t\t\tthis.name,\n\t\t\tmethod,\n\t\t);\n\t}\n}\n\nexport interface AnyIndexBuilder {\n\tbuild(table: GelTable): Index;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IndexBuilder extends AnyIndexBuilder {}\n\nexport class IndexBuilder implements AnyIndexBuilder {\n\tstatic readonly [entityKind]: string = 'GelIndexBuilder';\n\n\t/** @internal */\n\tconfig: IndexConfig;\n\n\tconstructor(\n\t\tcolumns: Partial<IndexedColumn | SQL>[],\n\t\tunique: boolean,\n\t\tonly: boolean,\n\t\tname?: string,\n\t\tmethod: string = 'btree',\n\t) {\n\t\tthis.config = {\n\t\t\tname,\n\t\t\tcolumns,\n\t\t\tunique,\n\t\t\tonly,\n\t\t\tmethod,\n\t\t};\n\t}\n\n\tconcurrently(): this {\n\t\tthis.config.concurrently = true;\n\t\treturn this;\n\t}\n\n\twith(obj: Record<string, any>): this {\n\t\tthis.config.with = obj;\n\t\treturn this;\n\t}\n\n\twhere(condition: SQL): this {\n\t\tthis.config.where = condition;\n\t\treturn this;\n\t}\n\n\t/** @internal */\n\tbuild(table: GelTable): Index {\n\t\treturn new Index(this.config, table);\n\t}\n}\n\nexport class Index {\n\tstatic readonly [entityKind]: string = 'GelIndex';\n\n\treadonly config: IndexConfig & { table: GelTable };\n\n\tconstructor(config: IndexConfig, table: GelTable) {\n\t\tthis.config = { ...config, table };\n\t}\n}\n\nexport type GetColumnsTableName<TColumns> = TColumns extends GelColumn ? TColumns['_']['name']\n\t: TColumns extends GelColumn[] ? TColumns[number]['_']['name']\n\t: never;\n\nexport function index(name?: string): IndexBuilderOn {\n\treturn new IndexBuilderOn(false, name);\n}\n\nexport function uniqueIndex(name?: string): IndexBuilderOn {\n\treturn new IndexBuilderOn(true, name);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoB;AAEpB,oBAA+B;AAE/B,qBAA8B;AAgHvB,MAAM,eAAe;AAAA,EAG3B,YAAoB,QAAyB,MAAe;AAAxC;AAAyB;AAAA,EAAgB;AAAA,EAF7D,QAAiB,wBAAU,IAAY;AAAA,EAIvC,MAAM,SAAwG;AAC7G,WAAO,IAAI;AAAA,MACV,QAAQ,IAAI,CAAC,OAAO;AACnB,gBAAI,kBAAG,IAAI,cAAG,GAAG;AAChB,iBAAO;AAAA,QACR;AACA,aAAK;AACL,cAAM,sBAAsB,IAAI,6BAAc,GAAG,MAAM,CAAC,CAAC,GAAG,WAAW,GAAG,YAAa,GAAG,WAAY;AACtG,WAAG,cAAc,KAAK,MAAM,KAAK,UAAU,GAAG,aAAa,CAAC;AAC5D,eAAO;AAAA,MACR,CAAC;AAAA,MACD,KAAK;AAAA,MACL;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AAAA,EAEA,UAAU,SAAwG;AACjH,WAAO,IAAI;AAAA,MACV,QAAQ,IAAI,CAAC,OAAO;AACnB,gBAAI,kBAAG,IAAI,cAAG,GAAG;AAChB,iBAAO;AAAA,QACR;AACA,aAAK;AACL,cAAM,sBAAsB,IAAI,6BAAc,GAAG,MAAM,CAAC,CAAC,GAAG,WAAW,GAAG,YAAa,GAAG,WAAY;AACtG,WAAG,cAAc,GAAG;AACpB,eAAO;AAAA,MACR,CAAC;AAAA,MACD,KAAK;AAAA,MACL;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,MACC,WACG,SACY;AACf,WAAO,IAAI;AAAA,MACV,QAAQ,IAAI,CAAC,OAAO;AACnB,gBAAI,kBAAG,IAAI,cAAG,GAAG;AAChB,iBAAO;AAAA,QACR;AACA,aAAK;AACL,cAAM,sBAAsB,IAAI,6BAAc,GAAG,MAAM,CAAC,CAAC,GAAG,WAAW,GAAG,YAAa,GAAG,WAAY;AACtG,WAAG,cAAc,KAAK,MAAM,KAAK,UAAU,GAAG,aAAa,CAAC;AAC5D,eAAO;AAAA,MACR,CAAC;AAAA,MACD,KAAK;AAAA,MACL;AAAA,MACA,KAAK;AAAA,MACL;AAAA,IACD;AAAA,EACD;AACD;AASO,MAAM,aAAwC;AAAA,EACpD,QAAiB,wBAAU,IAAY;AAAA;AAAA,EAGvC;AAAA,EAEA,YACC,SACA,QACA,MACA,MACA,SAAiB,SAChB;AACD,SAAK,SAAS;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAAA,EAEA,eAAqB;AACpB,SAAK,OAAO,eAAe;AAC3B,WAAO;AAAA,EACR;AAAA,EAEA,KAAK,KAAgC;AACpC,SAAK,OAAO,OAAO;AACnB,WAAO;AAAA,EACR;AAAA,EAEA,MAAM,WAAsB;AAC3B,SAAK,OAAO,QAAQ;AACpB,WAAO;AAAA,EACR;AAAA;AAAA,EAGA,MAAM,OAAwB;AAC7B,WAAO,IAAI,MAAM,KAAK,QAAQ,KAAK;AAAA,EACpC;AACD;AAEO,MAAM,MAAM;AAAA,EAClB,QAAiB,wBAAU,IAAY;AAAA,EAE9B;AAAA,EAET,YAAY,QAAqB,OAAiB;AACjD,SAAK,SAAS,EAAE,GAAG,QAAQ,MAAM;AAAA,EAClC;AACD;AAMO,SAAS,MAAM,MAA+B;AACpD,SAAO,IAAI,eAAe,OAAO,IAAI;AACtC;AAEO,SAAS,YAAY,MAA+B;AAC1D,SAAO,IAAI,eAAe,MAAM,IAAI;AACrC;","names":[]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { SQL } from "../sql/sql.cjs";
|
|
2
|
+
import { entityKind } from "../entity.cjs";
|
|
3
|
+
import type { GelColumn, GelExtraConfigColumn } from "./columns/index.cjs";
|
|
4
|
+
import { IndexedColumn } from "./columns/index.cjs";
|
|
5
|
+
import type { GelTable } from "./table.cjs";
|
|
6
|
+
interface IndexConfig {
|
|
7
|
+
name?: string;
|
|
8
|
+
columns: Partial<IndexedColumn | SQL>[];
|
|
9
|
+
/**
|
|
10
|
+
* If true, the index will be created as `create unique index` instead of `create index`.
|
|
11
|
+
*/
|
|
12
|
+
unique: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* If true, the index will be created as `create index concurrently` instead of `create index`.
|
|
15
|
+
*/
|
|
16
|
+
concurrently?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* If true, the index will be created as `create index ... on only <table>` instead of `create index ... on <table>`.
|
|
19
|
+
*/
|
|
20
|
+
only: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Condition for partial index.
|
|
23
|
+
*/
|
|
24
|
+
where?: SQL;
|
|
25
|
+
/**
|
|
26
|
+
* The optional WITH clause specifies storage parameters for the index
|
|
27
|
+
*/
|
|
28
|
+
with?: Record<string, any>;
|
|
29
|
+
/**
|
|
30
|
+
* The optional WITH clause method for the index
|
|
31
|
+
*/
|
|
32
|
+
method?: 'btree' | string;
|
|
33
|
+
}
|
|
34
|
+
export type IndexColumn = GelColumn;
|
|
35
|
+
export type GelIndexMethod = 'btree' | 'hash' | 'gist' | 'sGelist' | 'gin' | 'brin' | 'hnsw' | 'ivfflat' | (string & {});
|
|
36
|
+
export type GelIndexOpClass = 'abstime_ops' | 'access_method' | 'anyarray_eq' | 'anyarray_ge' | 'anyarray_gt' | 'anyarray_le' | 'anyarray_lt' | 'anyarray_ne' | 'bigint_ops' | 'bit_ops' | 'bool_ops' | 'box_ops' | 'bpchar_ops' | 'char_ops' | 'cidr_ops' | 'cstring_ops' | 'date_ops' | 'float_ops' | 'int2_ops' | 'int4_ops' | 'int8_ops' | 'interval_ops' | 'jsonb_ops' | 'macaddr_ops' | 'name_ops' | 'numeric_ops' | 'oid_ops' | 'oidint4_ops' | 'oidint8_ops' | 'oidname_ops' | 'oidvector_ops' | 'point_ops' | 'polygon_ops' | 'range_ops' | 'record_eq' | 'record_ge' | 'record_gt' | 'record_le' | 'record_lt' | 'record_ne' | 'text_ops' | 'time_ops' | 'timestamp_ops' | 'timestamptz_ops' | 'timetz_ops' | 'uuid_ops' | 'varbit_ops' | 'varchar_ops' | 'xml_ops' | 'vector_l2_ops' | 'vector_ip_ops' | 'vector_cosine_ops' | 'vector_l1_ops' | 'bit_hamming_ops' | 'bit_jaccard_ops' | 'halfvec_l2_ops' | 'sparsevec_l2_op' | (string & {});
|
|
37
|
+
export declare class IndexBuilderOn {
|
|
38
|
+
private unique;
|
|
39
|
+
private name?;
|
|
40
|
+
static readonly [entityKind]: string;
|
|
41
|
+
constructor(unique: boolean, name?: string | undefined);
|
|
42
|
+
on(...columns: [Partial<GelExtraConfigColumn> | SQL, ...Partial<GelExtraConfigColumn | SQL>[]]): IndexBuilder;
|
|
43
|
+
onOnly(...columns: [Partial<GelExtraConfigColumn | SQL>, ...Partial<GelExtraConfigColumn | SQL>[]]): IndexBuilder;
|
|
44
|
+
/**
|
|
45
|
+
* Specify what index method to use. Choices are `btree`, `hash`, `gist`, `sGelist`, `gin`, `brin`, or user-installed access methods like `bloom`. The default method is `btree.
|
|
46
|
+
*
|
|
47
|
+
* If you have the `Gel_vector` extension installed in your database, you can use the `hnsw` and `ivfflat` options, which are predefined types.
|
|
48
|
+
*
|
|
49
|
+
* **You can always specify any string you want in the method, in case Drizzle doesn't have it natively in its types**
|
|
50
|
+
*
|
|
51
|
+
* @param method The name of the index method to be used
|
|
52
|
+
* @param columns
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
using(method: GelIndexMethod, ...columns: [Partial<GelExtraConfigColumn | SQL>, ...Partial<GelExtraConfigColumn | SQL>[]]): IndexBuilder;
|
|
56
|
+
}
|
|
57
|
+
export interface AnyIndexBuilder {
|
|
58
|
+
build(table: GelTable): Index;
|
|
59
|
+
}
|
|
60
|
+
export interface IndexBuilder extends AnyIndexBuilder {
|
|
61
|
+
}
|
|
62
|
+
export declare class IndexBuilder implements AnyIndexBuilder {
|
|
63
|
+
static readonly [entityKind]: string;
|
|
64
|
+
constructor(columns: Partial<IndexedColumn | SQL>[], unique: boolean, only: boolean, name?: string, method?: string);
|
|
65
|
+
concurrently(): this;
|
|
66
|
+
with(obj: Record<string, any>): this;
|
|
67
|
+
where(condition: SQL): this;
|
|
68
|
+
}
|
|
69
|
+
export declare class Index {
|
|
70
|
+
static readonly [entityKind]: string;
|
|
71
|
+
readonly config: IndexConfig & {
|
|
72
|
+
table: GelTable;
|
|
73
|
+
};
|
|
74
|
+
constructor(config: IndexConfig, table: GelTable);
|
|
75
|
+
}
|
|
76
|
+
export type GetColumnsTableName<TColumns> = TColumns extends GelColumn ? TColumns['_']['name'] : TColumns extends GelColumn[] ? TColumns[number]['_']['name'] : never;
|
|
77
|
+
export declare function index(name?: string): IndexBuilderOn;
|
|
78
|
+
export declare function uniqueIndex(name?: string): IndexBuilderOn;
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { SQL } from "../sql/sql.js";
|
|
2
|
+
import { entityKind } from "../entity.js";
|
|
3
|
+
import type { GelColumn, GelExtraConfigColumn } from "./columns/index.js";
|
|
4
|
+
import { IndexedColumn } from "./columns/index.js";
|
|
5
|
+
import type { GelTable } from "./table.js";
|
|
6
|
+
interface IndexConfig {
|
|
7
|
+
name?: string;
|
|
8
|
+
columns: Partial<IndexedColumn | SQL>[];
|
|
9
|
+
/**
|
|
10
|
+
* If true, the index will be created as `create unique index` instead of `create index`.
|
|
11
|
+
*/
|
|
12
|
+
unique: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* If true, the index will be created as `create index concurrently` instead of `create index`.
|
|
15
|
+
*/
|
|
16
|
+
concurrently?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* If true, the index will be created as `create index ... on only <table>` instead of `create index ... on <table>`.
|
|
19
|
+
*/
|
|
20
|
+
only: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Condition for partial index.
|
|
23
|
+
*/
|
|
24
|
+
where?: SQL;
|
|
25
|
+
/**
|
|
26
|
+
* The optional WITH clause specifies storage parameters for the index
|
|
27
|
+
*/
|
|
28
|
+
with?: Record<string, any>;
|
|
29
|
+
/**
|
|
30
|
+
* The optional WITH clause method for the index
|
|
31
|
+
*/
|
|
32
|
+
method?: 'btree' | string;
|
|
33
|
+
}
|
|
34
|
+
export type IndexColumn = GelColumn;
|
|
35
|
+
export type GelIndexMethod = 'btree' | 'hash' | 'gist' | 'sGelist' | 'gin' | 'brin' | 'hnsw' | 'ivfflat' | (string & {});
|
|
36
|
+
export type GelIndexOpClass = 'abstime_ops' | 'access_method' | 'anyarray_eq' | 'anyarray_ge' | 'anyarray_gt' | 'anyarray_le' | 'anyarray_lt' | 'anyarray_ne' | 'bigint_ops' | 'bit_ops' | 'bool_ops' | 'box_ops' | 'bpchar_ops' | 'char_ops' | 'cidr_ops' | 'cstring_ops' | 'date_ops' | 'float_ops' | 'int2_ops' | 'int4_ops' | 'int8_ops' | 'interval_ops' | 'jsonb_ops' | 'macaddr_ops' | 'name_ops' | 'numeric_ops' | 'oid_ops' | 'oidint4_ops' | 'oidint8_ops' | 'oidname_ops' | 'oidvector_ops' | 'point_ops' | 'polygon_ops' | 'range_ops' | 'record_eq' | 'record_ge' | 'record_gt' | 'record_le' | 'record_lt' | 'record_ne' | 'text_ops' | 'time_ops' | 'timestamp_ops' | 'timestamptz_ops' | 'timetz_ops' | 'uuid_ops' | 'varbit_ops' | 'varchar_ops' | 'xml_ops' | 'vector_l2_ops' | 'vector_ip_ops' | 'vector_cosine_ops' | 'vector_l1_ops' | 'bit_hamming_ops' | 'bit_jaccard_ops' | 'halfvec_l2_ops' | 'sparsevec_l2_op' | (string & {});
|
|
37
|
+
export declare class IndexBuilderOn {
|
|
38
|
+
private unique;
|
|
39
|
+
private name?;
|
|
40
|
+
static readonly [entityKind]: string;
|
|
41
|
+
constructor(unique: boolean, name?: string | undefined);
|
|
42
|
+
on(...columns: [Partial<GelExtraConfigColumn> | SQL, ...Partial<GelExtraConfigColumn | SQL>[]]): IndexBuilder;
|
|
43
|
+
onOnly(...columns: [Partial<GelExtraConfigColumn | SQL>, ...Partial<GelExtraConfigColumn | SQL>[]]): IndexBuilder;
|
|
44
|
+
/**
|
|
45
|
+
* Specify what index method to use. Choices are `btree`, `hash`, `gist`, `sGelist`, `gin`, `brin`, or user-installed access methods like `bloom`. The default method is `btree.
|
|
46
|
+
*
|
|
47
|
+
* If you have the `Gel_vector` extension installed in your database, you can use the `hnsw` and `ivfflat` options, which are predefined types.
|
|
48
|
+
*
|
|
49
|
+
* **You can always specify any string you want in the method, in case Drizzle doesn't have it natively in its types**
|
|
50
|
+
*
|
|
51
|
+
* @param method The name of the index method to be used
|
|
52
|
+
* @param columns
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
using(method: GelIndexMethod, ...columns: [Partial<GelExtraConfigColumn | SQL>, ...Partial<GelExtraConfigColumn | SQL>[]]): IndexBuilder;
|
|
56
|
+
}
|
|
57
|
+
export interface AnyIndexBuilder {
|
|
58
|
+
build(table: GelTable): Index;
|
|
59
|
+
}
|
|
60
|
+
export interface IndexBuilder extends AnyIndexBuilder {
|
|
61
|
+
}
|
|
62
|
+
export declare class IndexBuilder implements AnyIndexBuilder {
|
|
63
|
+
static readonly [entityKind]: string;
|
|
64
|
+
constructor(columns: Partial<IndexedColumn | SQL>[], unique: boolean, only: boolean, name?: string, method?: string);
|
|
65
|
+
concurrently(): this;
|
|
66
|
+
with(obj: Record<string, any>): this;
|
|
67
|
+
where(condition: SQL): this;
|
|
68
|
+
}
|
|
69
|
+
export declare class Index {
|
|
70
|
+
static readonly [entityKind]: string;
|
|
71
|
+
readonly config: IndexConfig & {
|
|
72
|
+
table: GelTable;
|
|
73
|
+
};
|
|
74
|
+
constructor(config: IndexConfig, table: GelTable);
|
|
75
|
+
}
|
|
76
|
+
export type GetColumnsTableName<TColumns> = TColumns extends GelColumn ? TColumns['_']['name'] : TColumns extends GelColumn[] ? TColumns[number]['_']['name'] : never;
|
|
77
|
+
export declare function index(name?: string): IndexBuilderOn;
|
|
78
|
+
export declare function uniqueIndex(name?: string): IndexBuilderOn;
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { SQL } from "../sql/sql.js";
|
|
2
|
+
import { entityKind, is } from "../entity.js";
|
|
3
|
+
import { IndexedColumn } from "./columns/index.js";
|
|
4
|
+
class IndexBuilderOn {
|
|
5
|
+
constructor(unique, name) {
|
|
6
|
+
this.unique = unique;
|
|
7
|
+
this.name = name;
|
|
8
|
+
}
|
|
9
|
+
static [entityKind] = "GelIndexBuilderOn";
|
|
10
|
+
on(...columns) {
|
|
11
|
+
return new IndexBuilder(
|
|
12
|
+
columns.map((it) => {
|
|
13
|
+
if (is(it, SQL)) {
|
|
14
|
+
return it;
|
|
15
|
+
}
|
|
16
|
+
it = it;
|
|
17
|
+
const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
|
18
|
+
it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
|
|
19
|
+
return clonedIndexedColumn;
|
|
20
|
+
}),
|
|
21
|
+
this.unique,
|
|
22
|
+
false,
|
|
23
|
+
this.name
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
onOnly(...columns) {
|
|
27
|
+
return new IndexBuilder(
|
|
28
|
+
columns.map((it) => {
|
|
29
|
+
if (is(it, SQL)) {
|
|
30
|
+
return it;
|
|
31
|
+
}
|
|
32
|
+
it = it;
|
|
33
|
+
const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
|
34
|
+
it.indexConfig = it.defaultConfig;
|
|
35
|
+
return clonedIndexedColumn;
|
|
36
|
+
}),
|
|
37
|
+
this.unique,
|
|
38
|
+
true,
|
|
39
|
+
this.name
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Specify what index method to use. Choices are `btree`, `hash`, `gist`, `sGelist`, `gin`, `brin`, or user-installed access methods like `bloom`. The default method is `btree.
|
|
44
|
+
*
|
|
45
|
+
* If you have the `Gel_vector` extension installed in your database, you can use the `hnsw` and `ivfflat` options, which are predefined types.
|
|
46
|
+
*
|
|
47
|
+
* **You can always specify any string you want in the method, in case Drizzle doesn't have it natively in its types**
|
|
48
|
+
*
|
|
49
|
+
* @param method The name of the index method to be used
|
|
50
|
+
* @param columns
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
using(method, ...columns) {
|
|
54
|
+
return new IndexBuilder(
|
|
55
|
+
columns.map((it) => {
|
|
56
|
+
if (is(it, SQL)) {
|
|
57
|
+
return it;
|
|
58
|
+
}
|
|
59
|
+
it = it;
|
|
60
|
+
const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
|
61
|
+
it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
|
|
62
|
+
return clonedIndexedColumn;
|
|
63
|
+
}),
|
|
64
|
+
this.unique,
|
|
65
|
+
true,
|
|
66
|
+
this.name,
|
|
67
|
+
method
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
class IndexBuilder {
|
|
72
|
+
static [entityKind] = "GelIndexBuilder";
|
|
73
|
+
/** @internal */
|
|
74
|
+
config;
|
|
75
|
+
constructor(columns, unique, only, name, method = "btree") {
|
|
76
|
+
this.config = {
|
|
77
|
+
name,
|
|
78
|
+
columns,
|
|
79
|
+
unique,
|
|
80
|
+
only,
|
|
81
|
+
method
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
concurrently() {
|
|
85
|
+
this.config.concurrently = true;
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
with(obj) {
|
|
89
|
+
this.config.with = obj;
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
where(condition) {
|
|
93
|
+
this.config.where = condition;
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
/** @internal */
|
|
97
|
+
build(table) {
|
|
98
|
+
return new Index(this.config, table);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
class Index {
|
|
102
|
+
static [entityKind] = "GelIndex";
|
|
103
|
+
config;
|
|
104
|
+
constructor(config, table) {
|
|
105
|
+
this.config = { ...config, table };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function index(name) {
|
|
109
|
+
return new IndexBuilderOn(false, name);
|
|
110
|
+
}
|
|
111
|
+
function uniqueIndex(name) {
|
|
112
|
+
return new IndexBuilderOn(true, name);
|
|
113
|
+
}
|
|
114
|
+
export {
|
|
115
|
+
Index,
|
|
116
|
+
IndexBuilder,
|
|
117
|
+
IndexBuilderOn,
|
|
118
|
+
index,
|
|
119
|
+
uniqueIndex
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=indexes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/gel-core/indexes.ts"],"sourcesContent":["import { SQL } from '~/sql/sql.ts';\n\nimport { entityKind, is } from '~/entity.ts';\nimport type { GelColumn, GelExtraConfigColumn } from './columns/index.ts';\nimport { IndexedColumn } from './columns/index.ts';\nimport type { GelTable } from './table.ts';\n\ninterface IndexConfig {\n\tname?: string;\n\n\tcolumns: Partial<IndexedColumn | SQL>[];\n\n\t/**\n\t * If true, the index will be created as `create unique index` instead of `create index`.\n\t */\n\tunique: boolean;\n\n\t/**\n\t * If true, the index will be created as `create index concurrently` instead of `create index`.\n\t */\n\tconcurrently?: boolean;\n\n\t/**\n\t * If true, the index will be created as `create index ... on only <table>` instead of `create index ... on <table>`.\n\t */\n\tonly: boolean;\n\n\t/**\n\t * Condition for partial index.\n\t */\n\twhere?: SQL;\n\n\t/**\n\t * The optional WITH clause specifies storage parameters for the index\n\t */\n\twith?: Record<string, any>;\n\n\t/**\n\t * The optional WITH clause method for the index\n\t */\n\tmethod?: 'btree' | string;\n}\n\nexport type IndexColumn = GelColumn;\n\nexport type GelIndexMethod =\n\t| 'btree'\n\t| 'hash'\n\t| 'gist'\n\t| 'sGelist'\n\t| 'gin'\n\t| 'brin'\n\t| 'hnsw'\n\t| 'ivfflat'\n\t| (string & {});\n\nexport type GelIndexOpClass =\n\t| 'abstime_ops'\n\t| 'access_method'\n\t| 'anyarray_eq'\n\t| 'anyarray_ge'\n\t| 'anyarray_gt'\n\t| 'anyarray_le'\n\t| 'anyarray_lt'\n\t| 'anyarray_ne'\n\t| 'bigint_ops'\n\t| 'bit_ops'\n\t| 'bool_ops'\n\t| 'box_ops'\n\t| 'bpchar_ops'\n\t| 'char_ops'\n\t| 'cidr_ops'\n\t| 'cstring_ops'\n\t| 'date_ops'\n\t| 'float_ops'\n\t| 'int2_ops'\n\t| 'int4_ops'\n\t| 'int8_ops'\n\t| 'interval_ops'\n\t| 'jsonb_ops'\n\t| 'macaddr_ops'\n\t| 'name_ops'\n\t| 'numeric_ops'\n\t| 'oid_ops'\n\t| 'oidint4_ops'\n\t| 'oidint8_ops'\n\t| 'oidname_ops'\n\t| 'oidvector_ops'\n\t| 'point_ops'\n\t| 'polygon_ops'\n\t| 'range_ops'\n\t| 'record_eq'\n\t| 'record_ge'\n\t| 'record_gt'\n\t| 'record_le'\n\t| 'record_lt'\n\t| 'record_ne'\n\t| 'text_ops'\n\t| 'time_ops'\n\t| 'timestamp_ops'\n\t| 'timestamptz_ops'\n\t| 'timetz_ops'\n\t| 'uuid_ops'\n\t| 'varbit_ops'\n\t| 'varchar_ops'\n\t| 'xml_ops'\n\t| 'vector_l2_ops'\n\t| 'vector_ip_ops'\n\t| 'vector_cosine_ops'\n\t| 'vector_l1_ops'\n\t| 'bit_hamming_ops'\n\t| 'bit_jaccard_ops'\n\t| 'halfvec_l2_ops'\n\t| 'sparsevec_l2_op'\n\t| (string & {});\n\nexport class IndexBuilderOn {\n\tstatic readonly [entityKind]: string = 'GelIndexBuilderOn';\n\n\tconstructor(private unique: boolean, private name?: string) {}\n\n\ton(...columns: [Partial<GelExtraConfigColumn> | SQL, ...Partial<GelExtraConfigColumn | SQL>[]]): IndexBuilder {\n\t\treturn new IndexBuilder(\n\t\t\tcolumns.map((it) => {\n\t\t\t\tif (is(it, SQL)) {\n\t\t\t\t\treturn it;\n\t\t\t\t}\n\t\t\t\tit = it as GelExtraConfigColumn;\n\t\t\t\tconst clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType!, it.indexConfig!);\n\t\t\t\tit.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));\n\t\t\t\treturn clonedIndexedColumn;\n\t\t\t}),\n\t\t\tthis.unique,\n\t\t\tfalse,\n\t\t\tthis.name,\n\t\t);\n\t}\n\n\tonOnly(...columns: [Partial<GelExtraConfigColumn | SQL>, ...Partial<GelExtraConfigColumn | SQL>[]]): IndexBuilder {\n\t\treturn new IndexBuilder(\n\t\t\tcolumns.map((it) => {\n\t\t\t\tif (is(it, SQL)) {\n\t\t\t\t\treturn it;\n\t\t\t\t}\n\t\t\t\tit = it as GelExtraConfigColumn;\n\t\t\t\tconst clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType!, it.indexConfig!);\n\t\t\t\tit.indexConfig = it.defaultConfig;\n\t\t\t\treturn clonedIndexedColumn;\n\t\t\t}),\n\t\t\tthis.unique,\n\t\t\ttrue,\n\t\t\tthis.name,\n\t\t);\n\t}\n\n\t/**\n\t * Specify what index method to use. Choices are `btree`, `hash`, `gist`, `sGelist`, `gin`, `brin`, or user-installed access methods like `bloom`. The default method is `btree.\n\t *\n\t * If you have the `Gel_vector` extension installed in your database, you can use the `hnsw` and `ivfflat` options, which are predefined types.\n\t *\n\t * **You can always specify any string you want in the method, in case Drizzle doesn't have it natively in its types**\n\t *\n\t * @param method The name of the index method to be used\n\t * @param columns\n\t * @returns\n\t */\n\tusing(\n\t\tmethod: GelIndexMethod,\n\t\t...columns: [Partial<GelExtraConfigColumn | SQL>, ...Partial<GelExtraConfigColumn | SQL>[]]\n\t): IndexBuilder {\n\t\treturn new IndexBuilder(\n\t\t\tcolumns.map((it) => {\n\t\t\t\tif (is(it, SQL)) {\n\t\t\t\t\treturn it;\n\t\t\t\t}\n\t\t\t\tit = it as GelExtraConfigColumn;\n\t\t\t\tconst clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType!, it.indexConfig!);\n\t\t\t\tit.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));\n\t\t\t\treturn clonedIndexedColumn;\n\t\t\t}),\n\t\t\tthis.unique,\n\t\t\ttrue,\n\t\t\tthis.name,\n\t\t\tmethod,\n\t\t);\n\t}\n}\n\nexport interface AnyIndexBuilder {\n\tbuild(table: GelTable): Index;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IndexBuilder extends AnyIndexBuilder {}\n\nexport class IndexBuilder implements AnyIndexBuilder {\n\tstatic readonly [entityKind]: string = 'GelIndexBuilder';\n\n\t/** @internal */\n\tconfig: IndexConfig;\n\n\tconstructor(\n\t\tcolumns: Partial<IndexedColumn | SQL>[],\n\t\tunique: boolean,\n\t\tonly: boolean,\n\t\tname?: string,\n\t\tmethod: string = 'btree',\n\t) {\n\t\tthis.config = {\n\t\t\tname,\n\t\t\tcolumns,\n\t\t\tunique,\n\t\t\tonly,\n\t\t\tmethod,\n\t\t};\n\t}\n\n\tconcurrently(): this {\n\t\tthis.config.concurrently = true;\n\t\treturn this;\n\t}\n\n\twith(obj: Record<string, any>): this {\n\t\tthis.config.with = obj;\n\t\treturn this;\n\t}\n\n\twhere(condition: SQL): this {\n\t\tthis.config.where = condition;\n\t\treturn this;\n\t}\n\n\t/** @internal */\n\tbuild(table: GelTable): Index {\n\t\treturn new Index(this.config, table);\n\t}\n}\n\nexport class Index {\n\tstatic readonly [entityKind]: string = 'GelIndex';\n\n\treadonly config: IndexConfig & { table: GelTable };\n\n\tconstructor(config: IndexConfig, table: GelTable) {\n\t\tthis.config = { ...config, table };\n\t}\n}\n\nexport type GetColumnsTableName<TColumns> = TColumns extends GelColumn ? TColumns['_']['name']\n\t: TColumns extends GelColumn[] ? TColumns[number]['_']['name']\n\t: never;\n\nexport function index(name?: string): IndexBuilderOn {\n\treturn new IndexBuilderOn(false, name);\n}\n\nexport function uniqueIndex(name?: string): IndexBuilderOn {\n\treturn new IndexBuilderOn(true, name);\n}\n"],"mappings":"AAAA,SAAS,WAAW;AAEpB,SAAS,YAAY,UAAU;AAE/B,SAAS,qBAAqB;AAgHvB,MAAM,eAAe;AAAA,EAG3B,YAAoB,QAAyB,MAAe;AAAxC;AAAyB;AAAA,EAAgB;AAAA,EAF7D,QAAiB,UAAU,IAAY;AAAA,EAIvC,MAAM,SAAwG;AAC7G,WAAO,IAAI;AAAA,MACV,QAAQ,IAAI,CAAC,OAAO;AACnB,YAAI,GAAG,IAAI,GAAG,GAAG;AAChB,iBAAO;AAAA,QACR;AACA,aAAK;AACL,cAAM,sBAAsB,IAAI,cAAc,GAAG,MAAM,CAAC,CAAC,GAAG,WAAW,GAAG,YAAa,GAAG,WAAY;AACtG,WAAG,cAAc,KAAK,MAAM,KAAK,UAAU,GAAG,aAAa,CAAC;AAC5D,eAAO;AAAA,MACR,CAAC;AAAA,MACD,KAAK;AAAA,MACL;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AAAA,EAEA,UAAU,SAAwG;AACjH,WAAO,IAAI;AAAA,MACV,QAAQ,IAAI,CAAC,OAAO;AACnB,YAAI,GAAG,IAAI,GAAG,GAAG;AAChB,iBAAO;AAAA,QACR;AACA,aAAK;AACL,cAAM,sBAAsB,IAAI,cAAc,GAAG,MAAM,CAAC,CAAC,GAAG,WAAW,GAAG,YAAa,GAAG,WAAY;AACtG,WAAG,cAAc,GAAG;AACpB,eAAO;AAAA,MACR,CAAC;AAAA,MACD,KAAK;AAAA,MACL;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,MACC,WACG,SACY;AACf,WAAO,IAAI;AAAA,MACV,QAAQ,IAAI,CAAC,OAAO;AACnB,YAAI,GAAG,IAAI,GAAG,GAAG;AAChB,iBAAO;AAAA,QACR;AACA,aAAK;AACL,cAAM,sBAAsB,IAAI,cAAc,GAAG,MAAM,CAAC,CAAC,GAAG,WAAW,GAAG,YAAa,GAAG,WAAY;AACtG,WAAG,cAAc,KAAK,MAAM,KAAK,UAAU,GAAG,aAAa,CAAC;AAC5D,eAAO;AAAA,MACR,CAAC;AAAA,MACD,KAAK;AAAA,MACL;AAAA,MACA,KAAK;AAAA,MACL;AAAA,IACD;AAAA,EACD;AACD;AASO,MAAM,aAAwC;AAAA,EACpD,QAAiB,UAAU,IAAY;AAAA;AAAA,EAGvC;AAAA,EAEA,YACC,SACA,QACA,MACA,MACA,SAAiB,SAChB;AACD,SAAK,SAAS;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAAA,EAEA,eAAqB;AACpB,SAAK,OAAO,eAAe;AAC3B,WAAO;AAAA,EACR;AAAA,EAEA,KAAK,KAAgC;AACpC,SAAK,OAAO,OAAO;AACnB,WAAO;AAAA,EACR;AAAA,EAEA,MAAM,WAAsB;AAC3B,SAAK,OAAO,QAAQ;AACpB,WAAO;AAAA,EACR;AAAA;AAAA,EAGA,MAAM,OAAwB;AAC7B,WAAO,IAAI,MAAM,KAAK,QAAQ,KAAK;AAAA,EACpC;AACD;AAEO,MAAM,MAAM;AAAA,EAClB,QAAiB,UAAU,IAAY;AAAA,EAE9B;AAAA,EAET,YAAY,QAAqB,OAAiB;AACjD,SAAK,SAAS,EAAE,GAAG,QAAQ,MAAM;AAAA,EAClC;AACD;AAMO,SAAS,MAAM,MAA+B;AACpD,SAAO,IAAI,eAAe,OAAO,IAAI;AACtC;AAEO,SAAS,YAAY,MAA+B;AAC1D,SAAO,IAAI,eAAe,MAAM,IAAI;AACrC;","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 policies_exports = {};
|
|
20
|
+
__export(policies_exports, {
|
|
21
|
+
GelPolicy: () => GelPolicy,
|
|
22
|
+
gelPolicy: () => gelPolicy
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(policies_exports);
|
|
25
|
+
var import_entity = require("../entity.cjs");
|
|
26
|
+
class GelPolicy {
|
|
27
|
+
constructor(name, config) {
|
|
28
|
+
this.name = name;
|
|
29
|
+
if (config) {
|
|
30
|
+
this.as = config.as;
|
|
31
|
+
this.for = config.for;
|
|
32
|
+
this.to = config.to;
|
|
33
|
+
this.using = config.using;
|
|
34
|
+
this.withCheck = config.withCheck;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
static [import_entity.entityKind] = "GelPolicy";
|
|
38
|
+
as;
|
|
39
|
+
for;
|
|
40
|
+
to;
|
|
41
|
+
using;
|
|
42
|
+
withCheck;
|
|
43
|
+
/** @internal */
|
|
44
|
+
_linkedTable;
|
|
45
|
+
link(table) {
|
|
46
|
+
this._linkedTable = table;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function gelPolicy(name, config) {
|
|
51
|
+
return new GelPolicy(name, config);
|
|
52
|
+
}
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
GelPolicy,
|
|
56
|
+
gelPolicy
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=policies.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/gel-core/policies.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport type { SQL } from '~/sql/sql.ts';\nimport type { GelRole } from './roles.ts';\nimport type { GelTable } from './table.ts';\n\nexport type GelPolicyToOption =\n\t| 'public'\n\t| 'current_role'\n\t| 'current_user'\n\t| 'session_user'\n\t| (string & {})\n\t| GelPolicyToOption[]\n\t| GelRole;\n\nexport interface GelPolicyConfig {\n\tas?: 'permissive' | 'restrictive';\n\tfor?: 'all' | 'select' | 'insert' | 'update' | 'delete';\n\tto?: GelPolicyToOption;\n\tusing?: SQL;\n\twithCheck?: SQL;\n}\n\nexport class GelPolicy implements GelPolicyConfig {\n\tstatic readonly [entityKind]: string = 'GelPolicy';\n\n\treadonly as: GelPolicyConfig['as'];\n\treadonly for: GelPolicyConfig['for'];\n\treadonly to: GelPolicyConfig['to'];\n\treadonly using: GelPolicyConfig['using'];\n\treadonly withCheck: GelPolicyConfig['withCheck'];\n\n\t/** @internal */\n\t_linkedTable?: GelTable;\n\n\tconstructor(\n\t\treadonly name: string,\n\t\tconfig?: GelPolicyConfig,\n\t) {\n\t\tif (config) {\n\t\t\tthis.as = config.as;\n\t\t\tthis.for = config.for;\n\t\t\tthis.to = config.to;\n\t\t\tthis.using = config.using;\n\t\t\tthis.withCheck = config.withCheck;\n\t\t}\n\t}\n\n\tlink(table: GelTable): this {\n\t\tthis._linkedTable = table;\n\t\treturn this;\n\t}\n}\n\nexport function gelPolicy(name: string, config?: GelPolicyConfig) {\n\treturn new GelPolicy(name, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAsBpB,MAAM,UAAqC;AAAA,EAYjD,YACU,MACT,QACC;AAFQ;AAGT,QAAI,QAAQ;AACX,WAAK,KAAK,OAAO;AACjB,WAAK,MAAM,OAAO;AAClB,WAAK,KAAK,OAAO;AACjB,WAAK,QAAQ,OAAO;AACpB,WAAK,YAAY,OAAO;AAAA,IACzB;AAAA,EACD;AAAA,EAtBA,QAAiB,wBAAU,IAAY;AAAA,EAE9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGT;AAAA,EAeA,KAAK,OAAuB;AAC3B,SAAK,eAAe;AACpB,WAAO;AAAA,EACR;AACD;AAEO,SAAS,UAAU,MAAc,QAA0B;AACjE,SAAO,IAAI,UAAU,MAAM,MAAM;AAClC;","names":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { entityKind } from "../entity.cjs";
|
|
2
|
+
import type { SQL } from "../sql/sql.cjs";
|
|
3
|
+
import type { GelRole } from "./roles.cjs";
|
|
4
|
+
import type { GelTable } from "./table.cjs";
|
|
5
|
+
export type GelPolicyToOption = 'public' | 'current_role' | 'current_user' | 'session_user' | (string & {}) | GelPolicyToOption[] | GelRole;
|
|
6
|
+
export interface GelPolicyConfig {
|
|
7
|
+
as?: 'permissive' | 'restrictive';
|
|
8
|
+
for?: 'all' | 'select' | 'insert' | 'update' | 'delete';
|
|
9
|
+
to?: GelPolicyToOption;
|
|
10
|
+
using?: SQL;
|
|
11
|
+
withCheck?: SQL;
|
|
12
|
+
}
|
|
13
|
+
export declare class GelPolicy implements GelPolicyConfig {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
static readonly [entityKind]: string;
|
|
16
|
+
readonly as: GelPolicyConfig['as'];
|
|
17
|
+
readonly for: GelPolicyConfig['for'];
|
|
18
|
+
readonly to: GelPolicyConfig['to'];
|
|
19
|
+
readonly using: GelPolicyConfig['using'];
|
|
20
|
+
readonly withCheck: GelPolicyConfig['withCheck'];
|
|
21
|
+
constructor(name: string, config?: GelPolicyConfig);
|
|
22
|
+
link(table: GelTable): this;
|
|
23
|
+
}
|
|
24
|
+
export declare function gelPolicy(name: string, config?: GelPolicyConfig): GelPolicy;
|