fib-orm 2.0.0 → 3.0.0
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/README.md +42 -6
- package/index.d.ts +11 -0
- package/index.js +15 -0
- package/package.json +36 -34
- package/{lib/cli/commands/ddlFrom.js → src/cli/commands/ddlFrom.ts} +40 -26
- package/{lib/cli/commands/dumpModel.js → src/cli/commands/dumpModel.ts} +78 -31
- package/{lib/cli/commands/escape.js → src/cli/commands/escape.ts} +51 -28
- package/{lib/cli/commands/spinner.js → src/cli/commands/spinner.ts} +20 -10
- package/{lib/cli/commands/upgrade.js → src/cli/commands/upgrade.ts} +53 -33
- package/src/cli/helpers/ddl.ts +84 -0
- package/src/cli/helpers/package.ts +81 -0
- package/src/cli/index.ts +24 -0
- package/src/cli/wrapSubcommand.ts +66 -0
- package/src/db-driver/Typo.d.ts +141 -0
- package/src/db-driver/built-ins/base.class.ts +260 -0
- package/src/db-driver/built-ins/driver-dm.ts +62 -0
- package/src/db-driver/built-ins/driver-mssql.ts +67 -0
- package/src/db-driver/built-ins/driver-mysql.ts +44 -0
- package/src/db-driver/built-ins/driver-postgresql.ts +94 -0
- package/src/db-driver/built-ins/driver-redis.ts +45 -0
- package/src/db-driver/built-ins/driver-sqlite.ts +41 -0
- package/src/db-driver/index.ts +6 -0
- package/src/db-driver/parseQueryString.ts +76 -0
- package/src/db-driver/utils.ts +204 -0
- package/src/knex/deps/tarn/PendingOperation.ts +56 -0
- package/src/knex/deps/tarn/Pool.ts +610 -0
- package/src/knex/deps/tarn/PromiseInspection.ts +29 -0
- package/src/knex/deps/tarn/Resource.ts +22 -0
- package/src/knex/deps/tarn/TimeoutError.ts +1 -0
- package/src/knex/deps/tarn/tarn.ts +7 -0
- package/src/knex/deps/tarn/utils.ts +62 -0
- package/src/knex/knex.ts +11 -0
- package/src/knex/result.d.ts +27 -0
- package/src/knex/sandbox.ts +45 -0
- package/src/knex/tables.d.ts +4 -0
- package/src/knex/types.d.ts +3228 -0
- package/src/orm/Adapters.ts +53 -0
- package/src/orm/AggregateFunctions.ts +254 -0
- package/src/orm/Associations/Extend.ts +405 -0
- package/src/orm/Associations/Many.ts +784 -0
- package/src/orm/Associations/One.ts +494 -0
- package/src/orm/Associations/_utils.ts +72 -0
- package/src/orm/ChainFind.ts +427 -0
- package/src/orm/ChainInstance.ts +97 -0
- package/src/orm/Debug.ts +21 -0
- package/src/orm/Drivers/DB/base.ts +7 -0
- package/src/orm/Drivers/DB/dm.ts +35 -0
- package/src/orm/Drivers/DB/mssql.ts +35 -0
- package/src/orm/Drivers/DB/mysql.ts +35 -0
- package/src/orm/Drivers/DB/postgres.ts +35 -0
- package/src/orm/Drivers/DB/sqlite3.ts +60 -0
- package/src/orm/Drivers/DML/_ddl-sql.ts +85 -0
- package/src/orm/Drivers/DML/_dml-helpers.ts +66 -0
- package/src/orm/Drivers/DML/_shared.ts +61 -0
- package/src/orm/Drivers/DML/_utils.ts +112 -0
- package/{lib/orm/Drivers/DML/dm.js → src/orm/Drivers/DML/dm.ts} +178 -85
- package/src/orm/Drivers/DML/index.ts +10 -0
- package/src/orm/Drivers/DML/mssql.ts +366 -0
- package/src/orm/Drivers/DML/mysql.ts +347 -0
- package/src/orm/Drivers/DML/postgres.ts +382 -0
- package/src/orm/Drivers/DML/sqlite.ts +361 -0
- package/src/orm/Error.ts +49 -0
- package/src/orm/Helpers.ts +297 -0
- package/src/orm/Hook.ts +125 -0
- package/src/orm/Instance.ts +944 -0
- package/src/orm/LazyLoad.ts +117 -0
- package/src/orm/Model.ts +1235 -0
- package/src/orm/ORM.ts +301 -0
- package/src/orm/Patch/fib-cache.ts +7 -0
- package/src/orm/Patch/plugin.ts +25 -0
- package/src/orm/Property.ts +86 -0
- package/src/orm/Settings.ts +134 -0
- package/src/orm/Singleton.ts +97 -0
- package/src/orm/Typo/Adapter.d.ts +5 -0
- package/src/orm/Typo/DMLDriver.d.ts +260 -0
- package/src/orm/Typo/Db.d.ts +100 -0
- package/src/orm/Typo/Error.d.ts +36 -0
- package/src/orm/Typo/ORM.d.ts +315 -0
- package/src/orm/Typo/Validators.d.ts +39 -0
- package/src/orm/Typo/_common.d.ts +44 -0
- package/src/orm/Typo/assoc.d.ts +280 -0
- package/src/orm/Typo/hook.d.ts +68 -0
- package/src/orm/Typo/instance.d.ts +214 -0
- package/{lib → src}/orm/Typo/model.d.ts +297 -176
- package/src/orm/Typo/patch.d.ts +39 -0
- package/src/orm/Typo/property.d.ts +79 -0
- package/src/orm/Typo/query.d.ts +266 -0
- package/{lib → src}/orm/Typo/settings.d.ts +14 -7
- package/{lib → src}/orm/Typo/synchronous.d.ts +51 -26
- package/src/orm/Utilities.ts +1313 -0
- package/src/orm/Validators.ts +127 -0
- package/src/orm/Where/common.ts +8 -0
- package/src/orm/Where/filterDate.ts +74 -0
- package/src/orm/cloneDeep.ts +45 -0
- package/src/orm/index.ts +231 -0
- package/src/orm-core/callback.d.ts +15 -0
- package/{lib → src}/orm-core/dialect.d.ts +75 -52
- package/src/orm-core/error.ts +71 -0
- package/{lib/orm-core/index.d.ts → src/orm-core/index.ts} +8 -2
- package/src/orm-core/sync.d.ts +14 -0
- package/src/orm-core/utils.ts +4 -0
- package/src/orm-property/Property.ts +110 -0
- package/src/orm-property/Utils.ts +26 -0
- package/src/orm-property/customTypes.ts +13 -0
- package/src/orm-property/index.ts +34 -0
- package/src/orm-property/transformer.ts +16 -0
- package/{lib/orm-property/transformers/dm.js → src/orm-property/transformers/dm.ts} +128 -68
- package/src/orm-property/transformers/index.ts +10 -0
- package/src/orm-property/transformers/mssql.ts +285 -0
- package/src/orm-property/transformers/mysql.ts +395 -0
- package/src/orm-property/transformers/postgresql.ts +267 -0
- package/src/orm-property/transformers/sqlite.ts +217 -0
- package/src/plugins/orm-plugin-uacl/Typo.d.ts +173 -0
- package/src/plugins/orm-plugin-uacl/_utils.ts +237 -0
- package/src/plugins/orm-plugin-uacl/acl-tree.ts +440 -0
- package/src/plugins/orm-plugin-uacl/config-acl-tree.ts +592 -0
- package/src/plugins/orm-plugin-uacl/index.ts +180 -0
- package/src/plugins/orm-plugin-uacl/tree.ts +331 -0
- package/src/sql-ddl-sync/Dialects/dm.ts +493 -0
- package/{lib/sql-query/Dialects/index.d.ts → src/sql-ddl-sync/Dialects/index.ts} +3 -3
- package/src/sql-ddl-sync/Dialects/mssql.ts +441 -0
- package/src/sql-ddl-sync/Dialects/mysql.ts +414 -0
- package/src/sql-ddl-sync/Dialects/postgresql.ts +474 -0
- package/src/sql-ddl-sync/Dialects/sqlite.ts +439 -0
- package/src/sql-ddl-sync/SQL.ts +157 -0
- package/src/sql-ddl-sync/Typo/Collection.d.ts +19 -0
- package/src/sql-ddl-sync/Typo/DbIndex.d.ts +11 -0
- package/{lib → src}/sql-ddl-sync/Typo/Dialect.d.ts +67 -52
- package/src/sql-ddl-sync/Typo/Driver.d.ts +67 -0
- package/src/sql-ddl-sync/Typo/Query.d.ts +8 -0
- package/src/sql-ddl-sync/Typo/SQL.d.ts +45 -0
- package/src/sql-ddl-sync/Typo/_common.d.ts +59 -0
- package/src/sql-ddl-sync/Utils.ts +291 -0
- package/src/sql-ddl-sync/index.ts +599 -0
- package/src/sql-query/Comparators.ts +115 -0
- package/src/sql-query/Create.ts +87 -0
- package/{lib/sql-query/Dialects/dm.js → src/sql-query/Dialects/dm.ts} +42 -21
- package/src/sql-query/Dialects/index.ts +14 -0
- package/src/sql-query/Dialects/mssql.ts +91 -0
- package/src/sql-query/Dialects/mysql.ts +120 -0
- package/src/sql-query/Dialects/postgresql.ts +99 -0
- package/src/sql-query/Dialects/sqlite.ts +80 -0
- package/src/sql-query/Helpers.ts +303 -0
- package/src/sql-query/Insert.ts +41 -0
- package/src/sql-query/Query.ts +140 -0
- package/src/sql-query/Remove.ts +111 -0
- package/src/sql-query/Select.ts +719 -0
- package/src/sql-query/Set.ts +25 -0
- package/src/sql-query/Typo/Aggregation.d.ts +34 -0
- package/src/sql-query/Typo/Comparators.d.ts +156 -0
- package/src/sql-query/Typo/Dialect.d.ts +51 -0
- package/src/sql-query/Typo/Field.d.ts +10 -0
- package/src/sql-query/Typo/Helper.d.ts +4 -0
- package/src/sql-query/Typo/Query-ChainBuilder.d.ts +110 -0
- package/src/sql-query/Typo/Query.d.ts +65 -0
- package/src/sql-query/Typo/Sql.d.ts +192 -0
- package/src/sql-query/Typo/SubQuery.d.ts +52 -0
- package/{lib/sql-query/Typo/index.d.ts → src/sql-query/Typo/index.ts} +5 -2
- package/src/sql-query/Update.ts +50 -0
- package/src/sql-query/Where.ts +435 -0
- package/{lib/orm/Patch → src/typings}/fib-cache.d.ts +4 -3
- package/lib/cli/commands/ddlFrom.d.ts +0 -2
- package/lib/cli/commands/dumpModel.d.ts +0 -2
- package/lib/cli/commands/escape.d.ts +0 -2
- package/lib/cli/commands/spinner.d.ts +0 -2
- package/lib/cli/commands/upgrade.d.ts +0 -2
- package/lib/cli/helpers/ddl.d.ts +0 -17
- package/lib/cli/helpers/ddl.js +0 -55
- package/lib/cli/helpers/package.d.ts +0 -26
- package/lib/cli/helpers/package.js +0 -56
- package/lib/cli/index.d.ts +0 -2
- package/lib/cli/index.js +0 -18
- package/lib/db-driver/Typo.d.ts +0 -112
- package/lib/db-driver/Typo.js +0 -1
- package/lib/db-driver/built-ins/base.class.d.ts +0 -96
- package/lib/db-driver/built-ins/base.class.js +0 -186
- package/lib/db-driver/built-ins/driver-dm.d.ts +0 -18
- package/lib/db-driver/built-ins/driver-dm.js +0 -53
- package/lib/db-driver/built-ins/driver-mongodb.d.ts +0 -24
- package/lib/db-driver/built-ins/driver-mongodb.js +0 -46
- package/lib/db-driver/built-ins/driver-mysql.d.ts +0 -18
- package/lib/db-driver/built-ins/driver-mysql.js +0 -37
- package/lib/db-driver/built-ins/driver-postgresql.d.ts +0 -22
- package/lib/db-driver/built-ins/driver-postgresql.js +0 -76
- package/lib/db-driver/built-ins/driver-redis.d.ts +0 -12
- package/lib/db-driver/built-ins/driver-redis.js +0 -35
- package/lib/db-driver/built-ins/driver-sqlite.d.ts +0 -17
- package/lib/db-driver/built-ins/driver-sqlite.js +0 -34
- package/lib/db-driver/index.d.ts +0 -3
- package/lib/db-driver/index.js +0 -4
- package/lib/db-driver/utils.d.ts +0 -14
- package/lib/db-driver/utils.js +0 -187
- package/lib/knex/deps/tarn/dist/PendingOperation.d.ts +0 -12
- package/lib/knex/deps/tarn/dist/PendingOperation.js +0 -48
- package/lib/knex/deps/tarn/dist/Pool.d.ts +0 -97
- package/lib/knex/deps/tarn/dist/Pool.js +0 -516
- package/lib/knex/deps/tarn/dist/PromiseInspection.d.ts +0 -16
- package/lib/knex/deps/tarn/dist/PromiseInspection.js +0 -21
- package/lib/knex/deps/tarn/dist/Resource.d.ts +0 -9
- package/lib/knex/deps/tarn/dist/Resource.js +0 -19
- package/lib/knex/deps/tarn/dist/TimeoutError.d.ts +0 -2
- package/lib/knex/deps/tarn/dist/TimeoutError.js +0 -5
- package/lib/knex/deps/tarn/dist/tarn.d.ts +0 -3
- package/lib/knex/deps/tarn/dist/tarn.js +0 -10
- package/lib/knex/deps/tarn/dist/utils.d.ts +0 -14
- package/lib/knex/deps/tarn/dist/utils.js +0 -60
- package/lib/knex/knex.d.ts +0 -2
- package/lib/knex/knex.js +0 -3
- package/lib/knex/sandbox.d.ts +0 -4
- package/lib/knex/sandbox.js +0 -22
- package/lib/orm/Adapters.d.ts +0 -3
- package/lib/orm/Adapters.js +0 -44
- package/lib/orm/AggregateFunctions.d.ts +0 -3
- package/lib/orm/AggregateFunctions.js +0 -176
- package/lib/orm/Associations/Extend.d.ts +0 -22
- package/lib/orm/Associations/Extend.js +0 -274
- package/lib/orm/Associations/Many.d.ts +0 -17
- package/lib/orm/Associations/Many.js +0 -569
- package/lib/orm/Associations/One.d.ts +0 -16
- package/lib/orm/Associations/One.js +0 -310
- package/lib/orm/Associations/_utils.d.ts +0 -15
- package/lib/orm/Associations/_utils.js +0 -52
- package/lib/orm/ChainFind.d.ts +0 -3
- package/lib/orm/ChainFind.js +0 -327
- package/lib/orm/ChainInstance.d.ts +0 -6
- package/lib/orm/ChainInstance.js +0 -73
- package/lib/orm/Debug.d.ts +0 -2
- package/lib/orm/Debug.js +0 -17
- package/lib/orm/Drivers/DB/base.d.ts +0 -3
- package/lib/orm/Drivers/DB/base.js +0 -3
- package/lib/orm/Drivers/DB/dm.d.ts +0 -11
- package/lib/orm/Drivers/DB/dm.js +0 -23
- package/lib/orm/Drivers/DB/mysql.d.ts +0 -11
- package/lib/orm/Drivers/DB/mysql.js +0 -23
- package/lib/orm/Drivers/DB/postgres.d.ts +0 -11
- package/lib/orm/Drivers/DB/postgres.js +0 -22
- package/lib/orm/Drivers/DB/sqlite3.d.ts +0 -16
- package/lib/orm/Drivers/DB/sqlite3.js +0 -39
- package/lib/orm/Drivers/DML/_ddl-sql.d.ts +0 -3
- package/lib/orm/Drivers/DML/_ddl-sql.js +0 -51
- package/lib/orm/Drivers/DML/_dml-helpers.d.ts +0 -19
- package/lib/orm/Drivers/DML/_dml-helpers.js +0 -51
- package/lib/orm/Drivers/DML/_shared.d.ts +0 -9
- package/lib/orm/Drivers/DML/_shared.js +0 -38
- package/lib/orm/Drivers/DML/_utils.d.ts +0 -8
- package/lib/orm/Drivers/DML/_utils.js +0 -67
- package/lib/orm/Drivers/DML/constants.d.ts +0 -3
- package/lib/orm/Drivers/DML/constants.js +0 -2
- package/lib/orm/Drivers/DML/dm.d.ts +0 -2
- package/lib/orm/Drivers/DML/index.d.ts +0 -4
- package/lib/orm/Drivers/DML/index.js +0 -6
- package/lib/orm/Drivers/DML/mysql.d.ts +0 -2
- package/lib/orm/Drivers/DML/mysql.js +0 -251
- package/lib/orm/Drivers/DML/postgres.d.ts +0 -3
- package/lib/orm/Drivers/DML/postgres.js +0 -276
- package/lib/orm/Drivers/DML/sqlite.d.ts +0 -2
- package/lib/orm/Drivers/DML/sqlite.js +0 -266
- package/lib/orm/Error.d.ts +0 -11
- package/lib/orm/Error.js +0 -40
- package/lib/orm/Helpers.d.ts +0 -35
- package/lib/orm/Helpers.js +0 -233
- package/lib/orm/Hook.d.ts +0 -13
- package/lib/orm/Hook.js +0 -99
- package/lib/orm/Instance.d.ts +0 -2
- package/lib/orm/Instance.js +0 -697
- package/lib/orm/LazyLoad.d.ts +0 -4
- package/lib/orm/LazyLoad.js +0 -76
- package/lib/orm/Model.d.ts +0 -7
- package/lib/orm/Model.js +0 -971
- package/lib/orm/ORM.d.ts +0 -37
- package/lib/orm/ORM.js +0 -241
- package/lib/orm/Patch/fib-cache.js +0 -2
- package/lib/orm/Patch/plugin.d.ts +0 -4
- package/lib/orm/Patch/plugin.js +0 -13
- package/lib/orm/Property.d.ts +0 -9
- package/lib/orm/Property.js +0 -71
- package/lib/orm/Settings.d.ts +0 -42
- package/lib/orm/Settings.js +0 -119
- package/lib/orm/Singleton.d.ts +0 -5
- package/lib/orm/Singleton.js +0 -72
- package/lib/orm/Typo/Adapter.d.ts +0 -5
- package/lib/orm/Typo/Adapter.js +0 -1
- package/lib/orm/Typo/DMLDriver.d.ts +0 -210
- package/lib/orm/Typo/DMLDriver.js +0 -1
- package/lib/orm/Typo/Db.d.ts +0 -38
- package/lib/orm/Typo/Db.js +0 -1
- package/lib/orm/Typo/Error.d.ts +0 -31
- package/lib/orm/Typo/Error.js +0 -1
- package/lib/orm/Typo/ORM.d.ts +0 -233
- package/lib/orm/Typo/ORM.js +0 -3
- package/lib/orm/Typo/Validators.d.ts +0 -32
- package/lib/orm/Typo/Validators.js +0 -2
- package/lib/orm/Typo/_common.d.ts +0 -38
- package/lib/orm/Typo/_common.js +0 -1
- package/lib/orm/Typo/assoc.d.ts +0 -221
- package/lib/orm/Typo/assoc.js +0 -1
- package/lib/orm/Typo/hook.d.ts +0 -42
- package/lib/orm/Typo/hook.js +0 -1
- package/lib/orm/Typo/instance.d.ts +0 -157
- package/lib/orm/Typo/instance.js +0 -1
- package/lib/orm/Typo/model.js +0 -6
- package/lib/orm/Typo/patch.d.ts +0 -31
- package/lib/orm/Typo/patch.js +0 -1
- package/lib/orm/Typo/property.d.ts +0 -57
- package/lib/orm/Typo/property.js +0 -1
- package/lib/orm/Typo/query.d.ts +0 -216
- package/lib/orm/Typo/query.js +0 -1
- package/lib/orm/Typo/settings.js +0 -5
- package/lib/orm/Typo/synchronous.js +0 -1
- package/lib/orm/Utilities.d.ts +0 -179
- package/lib/orm/Utilities.js +0 -975
- package/lib/orm/Validators.d.ts +0 -34
- package/lib/orm/Validators.js +0 -100
- package/lib/orm/Where/common.d.ts +0 -1
- package/lib/orm/Where/common.js +0 -7
- package/lib/orm/Where/filterDate.d.ts +0 -11
- package/lib/orm/Where/filterDate.js +0 -58
- package/lib/orm/index.d.ts +0 -68
- package/lib/orm/index.js +0 -157
- package/lib/orm-core/callback.d.ts +0 -12
- package/lib/orm-core/callback.js +0 -1
- package/lib/orm-core/dialect.js +0 -1
- package/lib/orm-core/error.d.ts +0 -16
- package/lib/orm-core/error.js +0 -29
- package/lib/orm-core/index.js +0 -6
- package/lib/orm-core/sync.d.ts +0 -12
- package/lib/orm-core/sync.js +0 -1
- package/lib/orm-core/utils.d.ts +0 -1
- package/lib/orm-core/utils.js +0 -5
- package/lib/orm-property/Property.d.ts +0 -78
- package/lib/orm-property/Property.js +0 -1
- package/lib/orm-property/Utils.d.ts +0 -9
- package/lib/orm-property/Utils.js +0 -13
- package/lib/orm-property/customTypes.d.ts +0 -2
- package/lib/orm-property/customTypes.js +0 -13
- package/lib/orm-property/index.d.ts +0 -10
- package/lib/orm-property/index.js +0 -22
- package/lib/orm-property/transformer.d.ts +0 -5
- package/lib/orm-property/transformer.js +0 -10
- package/lib/orm-property/transformers/dm.d.ts +0 -29
- package/lib/orm-property/transformers/index.d.ts +0 -4
- package/lib/orm-property/transformers/index.js +0 -5
- package/lib/orm-property/transformers/mysql.d.ts +0 -102
- package/lib/orm-property/transformers/mysql.js +0 -261
- package/lib/orm-property/transformers/postgresql.d.ts +0 -54
- package/lib/orm-property/transformers/postgresql.js +0 -189
- package/lib/orm-property/transformers/sqlite.d.ts +0 -19
- package/lib/orm-property/transformers/sqlite.js +0 -171
- package/lib/sql-ddl-sync/Dialects/dm.d.ts +0 -40
- package/lib/sql-ddl-sync/Dialects/dm.js +0 -296
- package/lib/sql-ddl-sync/Dialects/index.d.ts +0 -7
- package/lib/sql-ddl-sync/Dialects/index.js +0 -7
- package/lib/sql-ddl-sync/Dialects/mysql.d.ts +0 -39
- package/lib/sql-ddl-sync/Dialects/mysql.js +0 -240
- package/lib/sql-ddl-sync/Dialects/postgresql.d.ts +0 -40
- package/lib/sql-ddl-sync/Dialects/postgresql.js +0 -286
- package/lib/sql-ddl-sync/Dialects/sqlite.d.ts +0 -44
- package/lib/sql-ddl-sync/Dialects/sqlite.js +0 -256
- package/lib/sql-ddl-sync/SQL.d.ts +0 -12
- package/lib/sql-ddl-sync/SQL.js +0 -108
- package/lib/sql-ddl-sync/Typo/Collection.d.ts +0 -13
- package/lib/sql-ddl-sync/Typo/Collection.js +0 -1
- package/lib/sql-ddl-sync/Typo/DbIndex.d.ts +0 -13
- package/lib/sql-ddl-sync/Typo/DbIndex.js +0 -1
- package/lib/sql-ddl-sync/Typo/Dialect.js +0 -1
- package/lib/sql-ddl-sync/Typo/Driver.d.ts +0 -53
- package/lib/sql-ddl-sync/Typo/Driver.js +0 -1
- package/lib/sql-ddl-sync/Typo/Query.d.ts +0 -7
- package/lib/sql-ddl-sync/Typo/Query.js +0 -1
- package/lib/sql-ddl-sync/Typo/SQL.d.ts +0 -31
- package/lib/sql-ddl-sync/Typo/SQL.js +0 -1
- package/lib/sql-ddl-sync/Typo/_common.d.ts +0 -29
- package/lib/sql-ddl-sync/Typo/_common.js +0 -1
- package/lib/sql-ddl-sync/Utils.d.ts +0 -40
- package/lib/sql-ddl-sync/Utils.js +0 -217
- package/lib/sql-ddl-sync/index.d.ts +0 -87
- package/lib/sql-ddl-sync/index.js +0 -371
- package/lib/sql-query/Comparators.d.ts +0 -3
- package/lib/sql-query/Comparators.js +0 -94
- package/lib/sql-query/Create.d.ts +0 -35
- package/lib/sql-query/Create.js +0 -77
- package/lib/sql-query/Dialects/dm.d.ts +0 -3
- package/lib/sql-query/Dialects/index.js +0 -12
- package/lib/sql-query/Dialects/mssql.d.ts +0 -3
- package/lib/sql-query/Dialects/mssql.js +0 -73
- package/lib/sql-query/Dialects/mysql.d.ts +0 -3
- package/lib/sql-query/Dialects/mysql.js +0 -100
- package/lib/sql-query/Dialects/postgresql.d.ts +0 -3
- package/lib/sql-query/Dialects/postgresql.js +0 -76
- package/lib/sql-query/Dialects/sqlite.d.ts +0 -3
- package/lib/sql-query/Dialects/sqlite.js +0 -61
- package/lib/sql-query/Helpers.d.ts +0 -38
- package/lib/sql-query/Helpers.js +0 -259
- package/lib/sql-query/Insert.d.ts +0 -12
- package/lib/sql-query/Insert.js +0 -33
- package/lib/sql-query/Query.d.ts +0 -29
- package/lib/sql-query/Query.js +0 -119
- package/lib/sql-query/Remove.d.ts +0 -16
- package/lib/sql-query/Remove.js +0 -93
- package/lib/sql-query/Select.d.ts +0 -62
- package/lib/sql-query/Select.js +0 -533
- package/lib/sql-query/Set.d.ts +0 -4
- package/lib/sql-query/Set.js +0 -16
- package/lib/sql-query/Typo/Aggregation.d.ts +0 -32
- package/lib/sql-query/Typo/Aggregation.js +0 -1
- package/lib/sql-query/Typo/Comparators.d.ts +0 -140
- package/lib/sql-query/Typo/Comparators.js +0 -1
- package/lib/sql-query/Typo/Dialect.d.ts +0 -39
- package/lib/sql-query/Typo/Dialect.js +0 -1
- package/lib/sql-query/Typo/Field.d.ts +0 -8
- package/lib/sql-query/Typo/Field.js +0 -1
- package/lib/sql-query/Typo/Helper.d.ts +0 -4
- package/lib/sql-query/Typo/Helper.js +0 -1
- package/lib/sql-query/Typo/Query-ChainBuilder.d.ts +0 -80
- package/lib/sql-query/Typo/Query-ChainBuilder.js +0 -1
- package/lib/sql-query/Typo/Query.d.ts +0 -34
- package/lib/sql-query/Typo/Query.js +0 -16
- package/lib/sql-query/Typo/Sql.d.ts +0 -143
- package/lib/sql-query/Typo/Sql.js +0 -1
- package/lib/sql-query/Typo/SubQuery.d.ts +0 -39
- package/lib/sql-query/Typo/SubQuery.js +0 -1
- package/lib/sql-query/Typo/index.js +0 -1
- package/lib/sql-query/Update.d.ts +0 -15
- package/lib/sql-query/Update.js +0 -38
- package/lib/sql-query/Where.d.ts +0 -4
- package/lib/sql-query/Where.js +0 -280
- /package/{lib → src}/codepoints-map.json +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { escapeValForKnex } from './Helpers';
|
|
2
|
+
import type { FxSqlQueryDialect } from './Typo/Dialect';
|
|
3
|
+
import type { FxSqlQueryChainBuilder } from './Typo/Query-ChainBuilder';
|
|
4
|
+
import type { FxSqlQuerySql } from './Typo/Sql';
|
|
5
|
+
|
|
6
|
+
export function build (
|
|
7
|
+
knexQueryBuilder: import("../knex/types").Knex.QueryBuilder,
|
|
8
|
+
Dialect: FxSqlQueryDialect.Dialect,
|
|
9
|
+
set: FxSqlQuerySql.DataToSet,
|
|
10
|
+
opts: FxSqlQueryChainBuilder.ChainBuilderOptions
|
|
11
|
+
): void {
|
|
12
|
+
opts = opts || {};
|
|
13
|
+
|
|
14
|
+
if (!set || set.length === 0) {
|
|
15
|
+
return ;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const safeSet: typeof set = {};
|
|
19
|
+
|
|
20
|
+
for (let k in set) {
|
|
21
|
+
safeSet[k] = escapeValForKnex(set[k], Dialect, opts)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
knexQueryBuilder.update(safeSet);
|
|
25
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export namespace FxSqlAggregation {
|
|
2
|
+
export type AggregationFunction = (...args: any[]) => any
|
|
3
|
+
|
|
4
|
+
export interface SupportedAggregationsMixin {
|
|
5
|
+
abs: AggregationFunction
|
|
6
|
+
ceil: AggregationFunction
|
|
7
|
+
floor: AggregationFunction
|
|
8
|
+
round: AggregationFunction
|
|
9
|
+
avg: AggregationFunction
|
|
10
|
+
min: AggregationFunction
|
|
11
|
+
max: AggregationFunction
|
|
12
|
+
log: AggregationFunction
|
|
13
|
+
log2: AggregationFunction
|
|
14
|
+
log10: AggregationFunction
|
|
15
|
+
exp: AggregationFunction
|
|
16
|
+
power: AggregationFunction
|
|
17
|
+
acos: AggregationFunction
|
|
18
|
+
asin: AggregationFunction
|
|
19
|
+
atan: AggregationFunction
|
|
20
|
+
cos: AggregationFunction
|
|
21
|
+
sin: AggregationFunction
|
|
22
|
+
tan: AggregationFunction
|
|
23
|
+
conv: AggregationFunction
|
|
24
|
+
random: AggregationFunction
|
|
25
|
+
rand: AggregationFunction
|
|
26
|
+
radians: AggregationFunction
|
|
27
|
+
degrees: AggregationFunction
|
|
28
|
+
sum: AggregationFunction
|
|
29
|
+
count: AggregationFunction
|
|
30
|
+
distinct: AggregationFunction
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type SupportedAggregationFunction = keyof SupportedAggregationsMixin
|
|
34
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
export namespace FxSqlQueryComparator {
|
|
2
|
+
export type IdType = string | number
|
|
3
|
+
export type SimpleEqValueType = string | number | boolean | Date
|
|
4
|
+
export type NormalizedInOperator = 'in' | 'not_in' | 'IN' | 'NOT_IN'
|
|
5
|
+
|
|
6
|
+
export type InputValue_eq = { "eq": SimpleEqValueType }
|
|
7
|
+
export type InputValue_ne = { "ne": SimpleEqValueType }
|
|
8
|
+
export type InputValue_gt = { "gt": number }
|
|
9
|
+
export type InputValue_gte = { "gte": number }
|
|
10
|
+
export type InputValue_lt = { "lt": number }
|
|
11
|
+
export type InputValue_lte = { "lte": number }
|
|
12
|
+
export type InputValue_like = { "like": string }
|
|
13
|
+
export type InputValue_not_like = { "not_like": string }
|
|
14
|
+
export type InputValue_between = { "between": [number, number] }
|
|
15
|
+
export type InputValue_not_between = { "not_between": [number, number] }
|
|
16
|
+
|
|
17
|
+
export type InputValue_in = { "in": IdType[] }
|
|
18
|
+
export type InputValue_not_in = { "not_in": IdType[] }
|
|
19
|
+
|
|
20
|
+
export type InputComparatorObjectValue =
|
|
21
|
+
InputValue_eq
|
|
22
|
+
| InputValue_ne
|
|
23
|
+
| InputValue_gt
|
|
24
|
+
| InputValue_gte
|
|
25
|
+
| InputValue_lt
|
|
26
|
+
| InputValue_lte
|
|
27
|
+
| InputValue_like
|
|
28
|
+
| InputValue_not_like
|
|
29
|
+
| InputValue_between
|
|
30
|
+
| InputValue_not_between
|
|
31
|
+
| InputValue_in
|
|
32
|
+
| InputValue_not_in
|
|
33
|
+
|
|
34
|
+
export type InputValueType =
|
|
35
|
+
SimpleEqValueType | InputComparatorObjectValue
|
|
36
|
+
|
|
37
|
+
export interface SubQueryComparatorInput {
|
|
38
|
+
[k: string]: FxSqlQueryComparator.QueryComparatorObject
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// compatible
|
|
42
|
+
export interface SubQuerySimpleEqInput {
|
|
43
|
+
[k: string]: SimpleEqValueType
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface SubQueryInput {
|
|
47
|
+
[k: string]: FxSqlQueryComparator.QueryComparatorObject | SimpleEqValueType
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface Input {
|
|
51
|
+
[key: string]: InputValueType
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type QueryComparatorExprType = string
|
|
55
|
+
export type QueryComparatorObject<T = any> = {
|
|
56
|
+
sql_comparator (): ComparatorNames
|
|
57
|
+
// value
|
|
58
|
+
val?: T
|
|
59
|
+
// WIP: if use value as identifier
|
|
60
|
+
asIdentifier?: boolean
|
|
61
|
+
// expression regular
|
|
62
|
+
expr?: QueryComparatorExprType
|
|
63
|
+
// from field
|
|
64
|
+
from?: string
|
|
65
|
+
// to field
|
|
66
|
+
to?: string
|
|
67
|
+
}
|
|
68
|
+
export type SimpleQueryConjunctionWord_NonNegetive = "or" | "and"
|
|
69
|
+
export type SimpleQueryConjunctionWord = SimpleQueryConjunctionWord_NonNegetive | "not"
|
|
70
|
+
export type QueryConjunctionWord = SimpleQueryConjunctionWord | "not_or" | "not_and"
|
|
71
|
+
|
|
72
|
+
export interface QueryComparatorLiteralObject {
|
|
73
|
+
between: any | any[]
|
|
74
|
+
not_between: any | any[]
|
|
75
|
+
like: any | any[]
|
|
76
|
+
not_like: any | any[]
|
|
77
|
+
eq: any | any[]
|
|
78
|
+
ne: any | any[]
|
|
79
|
+
gt: any | any[]
|
|
80
|
+
gte: any | any[]
|
|
81
|
+
lt: any | any[]
|
|
82
|
+
lte: any | any[]
|
|
83
|
+
in: any | any[]
|
|
84
|
+
not_in: any | any[]
|
|
85
|
+
|
|
86
|
+
modifiers?: {
|
|
87
|
+
is_date?: boolean
|
|
88
|
+
// timezone?: FxSqlQuery.FxSqlQueryTimezone
|
|
89
|
+
|
|
90
|
+
[modifier_name: string]: any
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export type ComparatorHash = {
|
|
95
|
+
between: FxSqlQueryComparatorFunction.between
|
|
96
|
+
not_between: FxSqlQueryComparatorFunction.not_between
|
|
97
|
+
like: FxSqlQueryComparatorFunction.like
|
|
98
|
+
not_like: FxSqlQueryComparatorFunction.not_like
|
|
99
|
+
eq: FxSqlQueryComparatorFunction.eq
|
|
100
|
+
ne: FxSqlQueryComparatorFunction.ne
|
|
101
|
+
gt: FxSqlQueryComparatorFunction.gt
|
|
102
|
+
gte: FxSqlQueryComparatorFunction.gte
|
|
103
|
+
lt: FxSqlQueryComparatorFunction.lt
|
|
104
|
+
lte: FxSqlQueryComparatorFunction.lte
|
|
105
|
+
in: FxSqlQueryComparatorFunction.not_in
|
|
106
|
+
not_in: FxSqlQueryComparatorFunction.not_in
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export type ComparatorNameType = keyof ComparatorHash
|
|
110
|
+
// just compatible
|
|
111
|
+
export type ComparatorNames = ComparatorNameType
|
|
112
|
+
|
|
113
|
+
export type QueryComparatorType =
|
|
114
|
+
ComparatorNameType
|
|
115
|
+
| 'sql'
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export namespace FxSqlQueryComparatorFunction {
|
|
119
|
+
export interface between {
|
|
120
|
+
(a: string, b: string, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
|
|
121
|
+
}
|
|
122
|
+
export interface not_between {
|
|
123
|
+
(a: string, b: string, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
|
|
124
|
+
}
|
|
125
|
+
export interface like {
|
|
126
|
+
(expr: FxSqlQueryComparator.QueryComparatorExprType, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
|
|
127
|
+
}
|
|
128
|
+
export interface not_like {
|
|
129
|
+
(expr: FxSqlQueryComparator.QueryComparatorExprType, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
|
|
130
|
+
}
|
|
131
|
+
export interface eq {
|
|
132
|
+
(v: any, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
|
|
133
|
+
}
|
|
134
|
+
export interface ne {
|
|
135
|
+
(v: any, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
|
|
136
|
+
}
|
|
137
|
+
export interface gt {
|
|
138
|
+
(v: any, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
|
|
139
|
+
}
|
|
140
|
+
export interface gte {
|
|
141
|
+
(v: any, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
|
|
142
|
+
}
|
|
143
|
+
export interface lt {
|
|
144
|
+
(v: any, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
|
|
145
|
+
}
|
|
146
|
+
export interface lte {
|
|
147
|
+
(v: any, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
|
|
148
|
+
}
|
|
149
|
+
export interface not_in {
|
|
150
|
+
(v: any, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export type __Options = {
|
|
154
|
+
asIdentifier?: boolean
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { FxSqlQuery } from "./Query"
|
|
2
|
+
import type { FxSqlQuerySql } from "./Sql"
|
|
3
|
+
|
|
4
|
+
export namespace FxSqlQueryDialect {
|
|
5
|
+
export type DialectType = 'mysql' | 'mssql' | 'sqlite' | 'postgresql' | 'dm'
|
|
6
|
+
|
|
7
|
+
export interface DataTypesDescriptorBase {
|
|
8
|
+
id: string
|
|
9
|
+
int: string
|
|
10
|
+
float: string
|
|
11
|
+
bool: string
|
|
12
|
+
text: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type DialectFieldType = keyof DataTypesDescriptorBase
|
|
16
|
+
|
|
17
|
+
export interface DataTypesDescriptor extends DataTypesDescriptorBase {
|
|
18
|
+
isSQLITE?: boolean
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface Dialect<T extends DialectType = DialectType> {
|
|
22
|
+
DataTypes: DataTypesDescriptor
|
|
23
|
+
type: T
|
|
24
|
+
|
|
25
|
+
escape: {
|
|
26
|
+
(
|
|
27
|
+
query: FxSqlQuerySql.SqlFragmentStr,
|
|
28
|
+
args: FxSqlQuerySql.SqlAssignmentValues
|
|
29
|
+
): string
|
|
30
|
+
}
|
|
31
|
+
escapeId: {
|
|
32
|
+
(...els: (FxSqlQuerySql.SqlEscapeArgIdType | {str: string, escapes: string[]})[]): string
|
|
33
|
+
}
|
|
34
|
+
escapeVal: {
|
|
35
|
+
(val: FxSqlQuerySql.SqlEscapeArgType, timezone?: FxSqlQuery.FxSqlQueryTimezone): string
|
|
36
|
+
(vals: FxSqlQuerySql.DetailedQueryWhereCondition__InStyle['val'], timezone?: FxSqlQuery.FxSqlQueryTimezone): string
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
limitAsTop: boolean
|
|
40
|
+
|
|
41
|
+
/* @internal */
|
|
42
|
+
readonly knex: import('../../knex/types').Knex
|
|
43
|
+
|
|
44
|
+
// only postgresql has it
|
|
45
|
+
defaultValuesStmt?: T extends 'postgresql' ? string : never
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type fn_escape = Dialect['escape']
|
|
49
|
+
export type fn_escapeId = Dialect['escapeId']
|
|
50
|
+
export type fn_escapeVal = Dialect['escapeVal']
|
|
51
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FxSqlQueryDialect } from './Dialect'
|
|
2
|
+
import type { FxSqlQuerySql } from './Sql'
|
|
3
|
+
|
|
4
|
+
export namespace FxSqlQueryColumns {
|
|
5
|
+
export type SelectInputArgType = string | FxSqlQuerySql.SqlSelectFieldItemDescriptor
|
|
6
|
+
|
|
7
|
+
export interface FieldItemTypeMap {
|
|
8
|
+
[key: string]: FxSqlQueryDialect.DialectFieldType
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { FxSqlQuery } from "./Query"
|
|
2
|
+
import type { FxSqlQuerySql } from "./Sql"
|
|
3
|
+
import type { FxSqlAggregation } from "./Aggregation"
|
|
4
|
+
import type { FxSqlQueryDialect } from "./Dialect"
|
|
5
|
+
import type { FxSqlQueryColumns } from "./Field"
|
|
6
|
+
import type { FxSqlQuerySubQuery } from "./SubQuery"
|
|
7
|
+
import type { FxSqlQueryHelpler } from "./Helper"
|
|
8
|
+
|
|
9
|
+
export namespace FxSqlQueryChainBuilder {
|
|
10
|
+
export type QueryWhereConditionPayloadUnit = FxSqlQuerySql.DetailedQueryWhereCondition | string | null
|
|
11
|
+
|
|
12
|
+
export interface ChainBuilderOptions extends FxSqlQuery.QueryOptions {}
|
|
13
|
+
|
|
14
|
+
export interface ChainBuilder {
|
|
15
|
+
readonly knex: FxSqlQuery.Class_Query['knex']
|
|
16
|
+
build(): string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ChainBuilderPaginationMixin {
|
|
20
|
+
offset(offset: number): this
|
|
21
|
+
limit(limit: number|string): this
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ChainBuilderSortMixin {
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param column
|
|
28
|
+
* @param dir
|
|
29
|
+
*
|
|
30
|
+
* @sample
|
|
31
|
+
* .order('col1', 'Z')
|
|
32
|
+
* .order(['table1', 'col1'], 'A')
|
|
33
|
+
* .order('ID DESC')
|
|
34
|
+
* .order('?? DESC', ['ID'])
|
|
35
|
+
*/
|
|
36
|
+
order(column: FxSqlQuery.OrderNormalizedResult[0], dir?: FxSqlQuery.OrderNormalizedResult[1]): this
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type ChainBuilder__SelectAggregationFunColumnArg = (string | string[])[]
|
|
40
|
+
export interface ChainBuilder__Select
|
|
41
|
+
extends ChainBuilder, FxSqlAggregation.SupportedAggregationsMixin, ChainBuilderPaginationMixin, ChainBuilderSortMixin
|
|
42
|
+
{
|
|
43
|
+
Dialect: FxSqlQueryDialect.Dialect
|
|
44
|
+
|
|
45
|
+
select: (fields: FxSqlQueryColumns.SelectInputArgType[]) => this
|
|
46
|
+
/**
|
|
47
|
+
* .where('table1', {t1_col1: 'v1'}, 'table2', {t1_col2: 'v2'}, ...)
|
|
48
|
+
* .where({__sql: 'xxx'})
|
|
49
|
+
* .where({col1: 'v1', col1: 'v1'})
|
|
50
|
+
* .where(not: [ { col: 2 }, { col: 3 } ])
|
|
51
|
+
*/
|
|
52
|
+
where: (...whereConditions: (FxSqlQuerySubQuery.SubQueryBuildDescriptor['wheres'] | FxSqlQuerySubQuery.WhereExistsTuple_Flatten[0])[]) => this
|
|
53
|
+
whereExists: (
|
|
54
|
+
table: string,
|
|
55
|
+
table_link: string | FxSqlQuerySql.SqlFromTableInput,
|
|
56
|
+
link: FxSqlQuerySql.WhereExistsLinkTuple,
|
|
57
|
+
cond: FxSqlQuerySubQuery.SubQueryBuildDescriptor['wheres']
|
|
58
|
+
) => this
|
|
59
|
+
groupBy: (...args: FxSqlQuerySql.SqlGroupByType[]) => this
|
|
60
|
+
fun: (fun: string, column?: FxSqlQuerySql.SqlColumnType, _as?: string) => this
|
|
61
|
+
from: {
|
|
62
|
+
/**
|
|
63
|
+
* @warning can be only used in first call!
|
|
64
|
+
*/
|
|
65
|
+
(table: FxSqlQuerySql.SqlTableInputType): ChainBuilder__Select
|
|
66
|
+
(
|
|
67
|
+
table: FxSqlQuerySql.SqlTableInputType,
|
|
68
|
+
from_id: FxSqlQueryHelpler.Arraiable<string>,
|
|
69
|
+
to_id: FxSqlQueryHelpler.Arraiable<string>
|
|
70
|
+
): ChainBuilder__Select
|
|
71
|
+
(
|
|
72
|
+
table: FxSqlQuerySql.SqlTableInputType,
|
|
73
|
+
from_id: FxSqlQueryHelpler.Arraiable<string>,
|
|
74
|
+
to_table: string,
|
|
75
|
+
to_id: FxSqlQueryHelpler.Arraiable<string>,
|
|
76
|
+
fromOpts?: FxSqlQuerySql.QueryFromDescriptorOpts
|
|
77
|
+
): ChainBuilder__Select
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
[extra: string]: any
|
|
81
|
+
}
|
|
82
|
+
export interface ChainBuilder__Insert extends ChainBuilder {
|
|
83
|
+
into(table: string): this | ChainBuilder__Insert
|
|
84
|
+
set(values: FxSqlQuerySql.DataToSet): this | ChainBuilder__Insert
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface ChainBuilder__Create extends ChainBuilder {
|
|
88
|
+
table(table: string): this | ChainBuilder__Create
|
|
89
|
+
field(table: string, type: FxSqlQueryDialect.DialectFieldType): this | ChainBuilder__Create
|
|
90
|
+
|
|
91
|
+
fields: {
|
|
92
|
+
(): FxSqlQueryColumns.FieldItemTypeMap
|
|
93
|
+
(fields: FxSqlQueryColumns.FieldItemTypeMap): ChainBuilder__Create
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface ChainBuilder__Update extends ChainBuilder {
|
|
98
|
+
where: (...whereConditions: FxSqlQuerySubQuery.SubQueryBuildDescriptor['wheres'][]) => ChainBuilder__Update
|
|
99
|
+
into(table: string): this | ChainBuilder__Update
|
|
100
|
+
set(values: FxSqlQuerySql.DataToSet): this | ChainBuilder__Update
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface ChainBuilder__Remove
|
|
104
|
+
extends ChainBuilder, ChainBuilderPaginationMixin
|
|
105
|
+
{
|
|
106
|
+
order(column: string, dir: FxSqlQuery.QueryOrderDirection): this
|
|
107
|
+
where: (...whereConditions: FxSqlQuerySubQuery.SubQueryBuildDescriptor['wheres'][]) => this
|
|
108
|
+
from(table: string): this
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { FxSqlQueryDialect } from "./Dialect"
|
|
2
|
+
import type { FxSqlQueryChainBuilder } from "./Query-ChainBuilder"
|
|
3
|
+
import type { FxSqlQuerySql } from './Sql'
|
|
4
|
+
|
|
5
|
+
export namespace FxSqlQuery {
|
|
6
|
+
export type OrderNormalizedTuple = [string|string[], "Z" | "A"]
|
|
7
|
+
export type OrderSqlStyleTuple = [FxSqlQuerySql.SqlFragmentStr, FxSqlQuerySql.SqlAssignmentValues?]
|
|
8
|
+
export type OrderNormalizedResult = OrderNormalizedTuple | OrderSqlStyleTuple
|
|
9
|
+
|
|
10
|
+
export interface QueryOptions {
|
|
11
|
+
dialect?: FxSqlQueryDialect.DialectType /* | string */
|
|
12
|
+
timezone?: FxSqlQueryTimezone
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type QueryOrderDirection =
|
|
16
|
+
// Z means 'z->a'
|
|
17
|
+
'Z'
|
|
18
|
+
// other string means 'a->z'
|
|
19
|
+
| 'A'
|
|
20
|
+
| string
|
|
21
|
+
|
|
22
|
+
export type FxSqlQueryTimezone =
|
|
23
|
+
'Z'
|
|
24
|
+
| 'local'
|
|
25
|
+
| string
|
|
26
|
+
|
|
27
|
+
export interface TypedQueryObject<T = 'text' | string, TD = any> {
|
|
28
|
+
data: TD
|
|
29
|
+
type(): T
|
|
30
|
+
}
|
|
31
|
+
export interface TypedQueryObjectWrapper<T = 'text' | string, TD = any> {
|
|
32
|
+
(data: TD): FxSqlQuery.TypedQueryObject<T, TD>
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class Class_Query {
|
|
36
|
+
constructor (_opts?: string | FxSqlQuery.QueryOptions);
|
|
37
|
+
|
|
38
|
+
/* @internal */
|
|
39
|
+
readonly knex: FxSqlQueryDialect.Dialect['knex']
|
|
40
|
+
readonly Dialect: FxSqlQueryDialect.Dialect
|
|
41
|
+
|
|
42
|
+
escape: FxSqlQueryDialect.Dialect['escape']
|
|
43
|
+
escapeId: FxSqlQueryDialect.Dialect['escapeId']
|
|
44
|
+
escapeVal: FxSqlQueryDialect.Dialect['escapeVal']
|
|
45
|
+
|
|
46
|
+
create (): FxSqlQueryChainBuilder.ChainBuilder__Create
|
|
47
|
+
select (): FxSqlQueryChainBuilder.ChainBuilder__Select
|
|
48
|
+
insert (): FxSqlQueryChainBuilder.ChainBuilder__Insert
|
|
49
|
+
update (): FxSqlQueryChainBuilder.ChainBuilder__Update
|
|
50
|
+
remove (): FxSqlQueryChainBuilder.ChainBuilder__Remove
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// interface ExportModule {
|
|
54
|
+
// comparators: FxSqlQueryComparator.ComparatorHash
|
|
55
|
+
// Text: FxSqlQuery.TypedQueryObjectWrapper<'text'>
|
|
56
|
+
// Helpers: FxSqlQueryHelpler.HelperModule
|
|
57
|
+
|
|
58
|
+
// Dialects: {
|
|
59
|
+
// mysql: FxSqlQueryDialect.Dialect
|
|
60
|
+
// sqlite: FxSqlQueryDialect.Dialect
|
|
61
|
+
// mssql: FxSqlQueryDialect.Dialect
|
|
62
|
+
// }
|
|
63
|
+
// Query: typeof FxSqlQuery.Class_Query
|
|
64
|
+
// }
|
|
65
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import type { FxSqlAggregation } from "./Aggregation"
|
|
2
|
+
import type { FxSqlQueryComparator } from "./Comparators"
|
|
3
|
+
import type { FxSqlQueryDialect } from "./Dialect"
|
|
4
|
+
import type { FxSqlQueryHelpler } from "./Helper"
|
|
5
|
+
import type { FxSqlQuerySubQuery } from "./SubQuery"
|
|
6
|
+
import type { FxSqlQuery } from './Query'
|
|
7
|
+
|
|
8
|
+
export namespace FxSqlQuerySql {
|
|
9
|
+
// type ValueToSet = (string|number)
|
|
10
|
+
export type DataToSet = {
|
|
11
|
+
[key: string]: any
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type SqlResultStr = string
|
|
15
|
+
export type SqlFragmentStr = string
|
|
16
|
+
export type SqlQueryStr = string
|
|
17
|
+
|
|
18
|
+
export type SqlEscapeArgType = string | number | boolean | Date | String | Number | RegExp | Symbol
|
|
19
|
+
export type SqlEscapeArgIdType = string | number
|
|
20
|
+
|
|
21
|
+
export type SqlAssignmentValues = SqlEscapeArgType[]
|
|
22
|
+
export type SqlAssignmentTuple = [FxSqlQuerySql.SqlFragmentStr, [...SqlAssignmentValues]?]
|
|
23
|
+
|
|
24
|
+
export type SqlFromTableInput = import('../../knex/types').Knex.Raw | import('../../knex/types').Knex.QueryBuilder
|
|
25
|
+
export type SqlTableTuple = [table: string | `(${string})`| SqlFromTableInput, alis: string]
|
|
26
|
+
export type SqlTableInputType = string | SqlFromTableInput | SqlTableTuple
|
|
27
|
+
|
|
28
|
+
export type WhereObj = {
|
|
29
|
+
str: string
|
|
30
|
+
escapes: any[]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// ['f1', 'f2'] ---> (`t1.f1` = `t2.f2`)
|
|
34
|
+
export type WhereExistsLinkTuple_L1 = FxSqlQueryHelpler.BinaryTuple<string>
|
|
35
|
+
// [['f1', 'f2'[, ...]], ['ff1', 'ff2'[, ...]]] ---> (`t1.f1` = `t2.f2`) AND (`t1.ff1` = `t2.ff2`) [...]
|
|
36
|
+
export type WhereExistsLinkTuple_L2 = FxSqlQueryHelpler.BinaryTuple<string[]>
|
|
37
|
+
export type WhereExistsLinkTuple = WhereExistsLinkTuple_L1 | WhereExistsLinkTuple_L2
|
|
38
|
+
|
|
39
|
+
export interface DetailedQueryWhereCondition<T = any> extends FxSqlQueryComparator.QueryComparatorObject<T> {
|
|
40
|
+
// from table name
|
|
41
|
+
from: string
|
|
42
|
+
// target table name
|
|
43
|
+
to: string
|
|
44
|
+
expr: FxSqlQueryComparator.QueryComparatorExprType
|
|
45
|
+
val: T
|
|
46
|
+
where: WhereObj
|
|
47
|
+
}
|
|
48
|
+
export type DetailedQueryWhereCondition__InStyle = DetailedQueryWhereCondition<
|
|
49
|
+
FxSqlQueryComparator.InputValue_in['in'] | FxSqlQueryComparator.InputValue_not_in['not_in']
|
|
50
|
+
>
|
|
51
|
+
|
|
52
|
+
export interface QueryWhereConjunctionHash {
|
|
53
|
+
or?: FxSqlQueryComparator.Input[]
|
|
54
|
+
and?: FxSqlQueryComparator.Input[]
|
|
55
|
+
not_or?: FxSqlQueryComparator.Input[]
|
|
56
|
+
not_and?: FxSqlQueryComparator.Input[]
|
|
57
|
+
not?: FxSqlQueryComparator.Input[]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface QueryWhereExtendItem {
|
|
61
|
+
// table
|
|
62
|
+
table: string
|
|
63
|
+
// link
|
|
64
|
+
link_info: FxSqlQueryHelpler.Arraiable<any>
|
|
65
|
+
// table linked
|
|
66
|
+
table_linked: string
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type SqlColumnDescriptorDataType = any
|
|
70
|
+
export interface SqlColumnDescriptor {
|
|
71
|
+
data: SqlColumnDescriptorDataType,
|
|
72
|
+
type? (): string
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type NormalizedSimpleSqlColumnType = string | '*'
|
|
76
|
+
export type SqlColumnType = (SqlColumnDescriptor|string)[] | NormalizedSimpleSqlColumnType
|
|
77
|
+
|
|
78
|
+
// item to describe what columns to select
|
|
79
|
+
export interface SqlSelectFieldItemDescriptor {
|
|
80
|
+
/**
|
|
81
|
+
* @description fun name
|
|
82
|
+
*/
|
|
83
|
+
func_name?: string
|
|
84
|
+
/**
|
|
85
|
+
* @description column name
|
|
86
|
+
* expect NO table prefix
|
|
87
|
+
*
|
|
88
|
+
* ```
|
|
89
|
+
* recommended: `col`
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* but this allowed also
|
|
93
|
+
*
|
|
94
|
+
* ```
|
|
95
|
+
* allowed also: `table.col`
|
|
96
|
+
* ````
|
|
97
|
+
*
|
|
98
|
+
*/
|
|
99
|
+
column_name?: SqlColumnType
|
|
100
|
+
/**
|
|
101
|
+
* @description column as
|
|
102
|
+
*/
|
|
103
|
+
as?: FxSqlQuerySql.NormalizedSimpleSqlColumnType,
|
|
104
|
+
a?: SqlSelectFieldItemDescriptor['as'],
|
|
105
|
+
/**
|
|
106
|
+
* @description fun_stack
|
|
107
|
+
*/
|
|
108
|
+
func_stack?: FxSqlAggregation.SupportedAggregationFunction[]
|
|
109
|
+
/**
|
|
110
|
+
* @description pure sql
|
|
111
|
+
*/
|
|
112
|
+
sql?: string
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @description GUESS: useful when this object refer to one complex descriptor?
|
|
116
|
+
*/
|
|
117
|
+
select?: string
|
|
118
|
+
/**
|
|
119
|
+
* @description having sub query statement
|
|
120
|
+
*/
|
|
121
|
+
having?: string
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface SqlSelectFieldsGenerator {
|
|
125
|
+
(dialect: FxSqlQueryDialect.Dialect): string
|
|
126
|
+
}
|
|
127
|
+
export type SqlSelectFieldsType = SqlFragmentStr | SqlSelectFieldItemDescriptor | SqlSelectFieldsGenerator
|
|
128
|
+
|
|
129
|
+
export interface QueryFromDescriptorOpts {
|
|
130
|
+
joinType: string
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface QueryFromDescriptor {
|
|
134
|
+
// table
|
|
135
|
+
table: string | import('../../knex/types').Knex.Raw | import('../../knex/types').Knex.QueryBuilder
|
|
136
|
+
// table alias
|
|
137
|
+
alias: string, a?: string
|
|
138
|
+
// ?
|
|
139
|
+
joins?: QueryFromJoinTupleDescriptor[]
|
|
140
|
+
// selected fields
|
|
141
|
+
select?: SqlSelectFieldsType[]
|
|
142
|
+
// from opts
|
|
143
|
+
opts?: QueryFromDescriptorOpts
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export type QueryFromJoinTupleDescriptor = [
|
|
147
|
+
// from id column name
|
|
148
|
+
string,
|
|
149
|
+
// to table alias name
|
|
150
|
+
string,
|
|
151
|
+
// to id column name
|
|
152
|
+
string,
|
|
153
|
+
]
|
|
154
|
+
|
|
155
|
+
export type SqlTableOrderTuple = [
|
|
156
|
+
// table(alias) name
|
|
157
|
+
string,
|
|
158
|
+
// column name
|
|
159
|
+
string
|
|
160
|
+
]
|
|
161
|
+
export interface SqlOrderDescriptor {
|
|
162
|
+
// column name or SqlTableOrderTuple
|
|
163
|
+
c: string | SqlTableOrderTuple
|
|
164
|
+
// order
|
|
165
|
+
d: 'DESC' | 'ASC'
|
|
166
|
+
}
|
|
167
|
+
export type SqlOrderPayloadType = SqlOrderDescriptor | FxSqlQuery.OrderSqlStyleTuple[0]
|
|
168
|
+
|
|
169
|
+
export type SqlGroupByType = string
|
|
170
|
+
|
|
171
|
+
export interface SqlFoundRowItem {
|
|
172
|
+
[k: string]: any
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// type SqlQueryDescriptorWhereItem = SqlWhereDescriptor | string
|
|
176
|
+
|
|
177
|
+
export interface SqlQueryChainDescriptor {
|
|
178
|
+
from?: QueryFromDescriptor[]
|
|
179
|
+
table?: string
|
|
180
|
+
// values to set in UPDATE like command
|
|
181
|
+
set?: DataToSet
|
|
182
|
+
where?: FxSqlQuerySubQuery.SubQueryBuildDescriptor[]
|
|
183
|
+
order?: SqlOrderPayloadType[]
|
|
184
|
+
offset?: number
|
|
185
|
+
limit?: number
|
|
186
|
+
|
|
187
|
+
found_rows?: SqlFoundRowItem[] | boolean
|
|
188
|
+
group_by?: SqlGroupByType[]
|
|
189
|
+
|
|
190
|
+
where_exists?: boolean
|
|
191
|
+
}
|
|
192
|
+
}
|