fib-orm 2.1.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 +37 -34
- package/{lib/cli/commands/ddlFrom.js → src/cli/commands/ddlFrom.ts} +40 -27
- package/{lib/cli/commands/dumpModel.js → src/cli/commands/dumpModel.ts} +78 -32
- package/{lib/cli/commands/escape.js → src/cli/commands/escape.ts} +51 -29
- package/{lib/cli/commands/spinner.js → src/cli/commands/spinner.ts} +20 -11
- package/{lib/cli/commands/upgrade.js → src/cli/commands/upgrade.ts} +53 -34
- 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 -86
- 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 -174
- 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 -69
- 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 -22
- 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 -2
- 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 -25
- package/lib/cli/helpers/package.js +0 -56
- package/lib/cli/index.d.ts +0 -2
- package/lib/cli/index.js +0 -19
- package/lib/db-driver/Typo.d.ts +0 -111
- package/lib/db-driver/Typo.js +0 -2
- package/lib/db-driver/built-ins/base.class.d.ts +0 -91
- package/lib/db-driver/built-ins/base.class.js +0 -187
- package/lib/db-driver/built-ins/driver-dm.d.ts +0 -17
- package/lib/db-driver/built-ins/driver-dm.js +0 -54
- package/lib/db-driver/built-ins/driver-mongodb.d.ts +0 -23
- package/lib/db-driver/built-ins/driver-mongodb.js +0 -47
- package/lib/db-driver/built-ins/driver-mysql.d.ts +0 -17
- package/lib/db-driver/built-ins/driver-mysql.js +0 -38
- package/lib/db-driver/built-ins/driver-postgresql.d.ts +0 -21
- package/lib/db-driver/built-ins/driver-postgresql.js +0 -77
- package/lib/db-driver/built-ins/driver-redis.d.ts +0 -11
- package/lib/db-driver/built-ins/driver-redis.js +0 -36
- package/lib/db-driver/built-ins/driver-sqlite.d.ts +0 -16
- package/lib/db-driver/built-ins/driver-sqlite.js +0 -35
- package/lib/db-driver/index.d.ts +0 -3
- package/lib/db-driver/index.js +0 -5
- 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 -4
- package/lib/knex/sandbox.d.ts +0 -4
- package/lib/knex/sandbox.js +0 -23
- 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 -177
- 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 -16
- 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 -14
- package/lib/orm/Associations/_utils.js +0 -53
- package/lib/orm/ChainFind.d.ts +0 -3
- package/lib/orm/ChainFind.js +0 -328
- package/lib/orm/ChainInstance.d.ts +0 -6
- package/lib/orm/ChainInstance.js +0 -74
- package/lib/orm/Debug.d.ts +0 -2
- package/lib/orm/Debug.js +0 -17
- package/lib/orm/Drivers/DB/base.d.ts +0 -2
- package/lib/orm/Drivers/DB/base.js +0 -4
- package/lib/orm/Drivers/DB/dm.d.ts +0 -9
- package/lib/orm/Drivers/DB/dm.js +0 -24
- package/lib/orm/Drivers/DB/mysql.d.ts +0 -9
- package/lib/orm/Drivers/DB/mysql.js +0 -24
- package/lib/orm/Drivers/DB/postgres.d.ts +0 -9
- package/lib/orm/Drivers/DB/postgres.js +0 -23
- package/lib/orm/Drivers/DB/sqlite3.d.ts +0 -14
- package/lib/orm/Drivers/DB/sqlite3.js +0 -40
- package/lib/orm/Drivers/DML/_ddl-sql.d.ts +0 -3
- package/lib/orm/Drivers/DML/_ddl-sql.js +0 -52
- 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 -39
- 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 -3
- 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 -7
- package/lib/orm/Drivers/DML/mysql.d.ts +0 -2
- package/lib/orm/Drivers/DML/mysql.js +0 -252
- package/lib/orm/Drivers/DML/postgres.d.ts +0 -2
- package/lib/orm/Drivers/DML/postgres.js +0 -277
- package/lib/orm/Drivers/DML/sqlite.d.ts +0 -2
- package/lib/orm/Drivers/DML/sqlite.js +0 -267
- package/lib/orm/Error.d.ts +0 -11
- package/lib/orm/Error.js +0 -41
- package/lib/orm/Helpers.d.ts +0 -35
- package/lib/orm/Helpers.js +0 -234
- package/lib/orm/Hook.d.ts +0 -13
- package/lib/orm/Hook.js +0 -100
- package/lib/orm/Instance.d.ts +0 -2
- package/lib/orm/Instance.js +0 -698
- package/lib/orm/LazyLoad.d.ts +0 -4
- package/lib/orm/LazyLoad.js +0 -76
- package/lib/orm/Model.d.ts +0 -6
- package/lib/orm/Model.js +0 -974
- package/lib/orm/ORM.d.ts +0 -37
- package/lib/orm/ORM.js +0 -242
- 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 -14
- 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 -120
- package/lib/orm/Singleton.d.ts +0 -5
- package/lib/orm/Singleton.js +0 -73
- package/lib/orm/Typo/Adapter.d.ts +0 -5
- package/lib/orm/Typo/Adapter.js +0 -2
- package/lib/orm/Typo/DMLDriver.d.ts +0 -209
- package/lib/orm/Typo/DMLDriver.js +0 -2
- package/lib/orm/Typo/Db.d.ts +0 -35
- package/lib/orm/Typo/Db.js +0 -2
- package/lib/orm/Typo/Error.d.ts +0 -29
- package/lib/orm/Typo/Error.js +0 -2
- package/lib/orm/Typo/ORM.d.ts +0 -231
- package/lib/orm/Typo/ORM.js +0 -4
- package/lib/orm/Typo/Validators.d.ts +0 -31
- package/lib/orm/Typo/Validators.js +0 -3
- package/lib/orm/Typo/_common.d.ts +0 -37
- package/lib/orm/Typo/_common.js +0 -2
- package/lib/orm/Typo/assoc.d.ts +0 -221
- package/lib/orm/Typo/assoc.js +0 -2
- package/lib/orm/Typo/hook.d.ts +0 -42
- package/lib/orm/Typo/hook.js +0 -2
- package/lib/orm/Typo/instance.d.ts +0 -156
- package/lib/orm/Typo/instance.js +0 -2
- package/lib/orm/Typo/model.js +0 -7
- package/lib/orm/Typo/patch.d.ts +0 -31
- package/lib/orm/Typo/patch.js +0 -2
- package/lib/orm/Typo/property.d.ts +0 -57
- package/lib/orm/Typo/property.js +0 -2
- package/lib/orm/Typo/query.d.ts +0 -216
- package/lib/orm/Typo/query.js +0 -2
- package/lib/orm/Typo/settings.js +0 -6
- package/lib/orm/Typo/synchronous.js +0 -2
- package/lib/orm/Utilities.d.ts +0 -178
- package/lib/orm/Utilities.js +0 -975
- package/lib/orm/Validators.d.ts +0 -33
- package/lib/orm/Validators.js +0 -101
- 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 -67
- package/lib/orm/index.js +0 -158
- package/lib/orm-core/callback.d.ts +0 -12
- package/lib/orm-core/callback.js +0 -2
- package/lib/orm-core/dialect.js +0 -2
- package/lib/orm-core/error.d.ts +0 -16
- package/lib/orm-core/error.js +0 -29
- package/lib/orm-core/index.js +0 -7
- package/lib/orm-core/sync.d.ts +0 -12
- package/lib/orm-core/sync.js +0 -2
- package/lib/orm-core/utils.d.ts +0 -1
- package/lib/orm-core/utils.js +0 -6
- package/lib/orm-property/Property.d.ts +0 -78
- package/lib/orm-property/Property.js +0 -2
- 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 -23
- 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 -6
- package/lib/orm-property/transformers/mysql.d.ts +0 -101
- package/lib/orm-property/transformers/mysql.js +0 -262
- package/lib/orm-property/transformers/postgresql.d.ts +0 -54
- package/lib/orm-property/transformers/postgresql.js +0 -190
- package/lib/orm-property/transformers/sqlite.d.ts +0 -19
- package/lib/orm-property/transformers/sqlite.js +0 -172
- package/lib/sql-ddl-sync/Dialects/dm.d.ts +0 -39
- package/lib/sql-ddl-sync/Dialects/dm.js +0 -297
- package/lib/sql-ddl-sync/Dialects/index.d.ts +0 -6
- package/lib/sql-ddl-sync/Dialects/index.js +0 -8
- package/lib/sql-ddl-sync/Dialects/mysql.d.ts +0 -38
- package/lib/sql-ddl-sync/Dialects/mysql.js +0 -241
- package/lib/sql-ddl-sync/Dialects/postgresql.d.ts +0 -39
- package/lib/sql-ddl-sync/Dialects/postgresql.js +0 -287
- package/lib/sql-ddl-sync/Dialects/sqlite.d.ts +0 -43
- package/lib/sql-ddl-sync/Dialects/sqlite.js +0 -257
- 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 -2
- package/lib/sql-ddl-sync/Typo/DbIndex.d.ts +0 -13
- package/lib/sql-ddl-sync/Typo/DbIndex.js +0 -2
- package/lib/sql-ddl-sync/Typo/Dialect.js +0 -2
- package/lib/sql-ddl-sync/Typo/Driver.d.ts +0 -53
- package/lib/sql-ddl-sync/Typo/Driver.js +0 -2
- package/lib/sql-ddl-sync/Typo/Query.d.ts +0 -7
- package/lib/sql-ddl-sync/Typo/Query.js +0 -2
- package/lib/sql-ddl-sync/Typo/SQL.d.ts +0 -31
- package/lib/sql-ddl-sync/Typo/SQL.js +0 -2
- package/lib/sql-ddl-sync/Typo/_common.d.ts +0 -29
- package/lib/sql-ddl-sync/Typo/_common.js +0 -2
- package/lib/sql-ddl-sync/Utils.d.ts +0 -39
- 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 -372
- package/lib/sql-query/Comparators.d.ts +0 -3
- package/lib/sql-query/Comparators.js +0 -95
- package/lib/sql-query/Create.d.ts +0 -35
- package/lib/sql-query/Create.js +0 -78
- package/lib/sql-query/Dialects/dm.d.ts +0 -3
- package/lib/sql-query/Dialects/index.js +0 -13
- package/lib/sql-query/Dialects/mssql.d.ts +0 -3
- package/lib/sql-query/Dialects/mssql.js +0 -74
- package/lib/sql-query/Dialects/mysql.d.ts +0 -3
- package/lib/sql-query/Dialects/mysql.js +0 -101
- package/lib/sql-query/Dialects/postgresql.d.ts +0 -3
- package/lib/sql-query/Dialects/postgresql.js +0 -77
- package/lib/sql-query/Dialects/sqlite.d.ts +0 -3
- package/lib/sql-query/Dialects/sqlite.js +0 -62
- package/lib/sql-query/Helpers.d.ts +0 -37
- package/lib/sql-query/Helpers.js +0 -260
- package/lib/sql-query/Insert.d.ts +0 -12
- package/lib/sql-query/Insert.js +0 -34
- package/lib/sql-query/Query.d.ts +0 -28
- package/lib/sql-query/Query.js +0 -120
- package/lib/sql-query/Remove.d.ts +0 -16
- package/lib/sql-query/Remove.js +0 -94
- package/lib/sql-query/Select.d.ts +0 -62
- package/lib/sql-query/Select.js +0 -534
- 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 -2
- package/lib/sql-query/Typo/Comparators.d.ts +0 -140
- package/lib/sql-query/Typo/Comparators.js +0 -2
- package/lib/sql-query/Typo/Dialect.d.ts +0 -39
- package/lib/sql-query/Typo/Dialect.js +0 -2
- package/lib/sql-query/Typo/Field.d.ts +0 -8
- package/lib/sql-query/Typo/Field.js +0 -2
- package/lib/sql-query/Typo/Helper.d.ts +0 -4
- package/lib/sql-query/Typo/Helper.js +0 -2
- package/lib/sql-query/Typo/Query-ChainBuilder.d.ts +0 -80
- package/lib/sql-query/Typo/Query-ChainBuilder.js +0 -2
- package/lib/sql-query/Typo/Query.d.ts +0 -34
- package/lib/sql-query/Typo/Query.js +0 -17
- package/lib/sql-query/Typo/Sql.d.ts +0 -143
- package/lib/sql-query/Typo/Sql.js +0 -2
- package/lib/sql-query/Typo/SubQuery.d.ts +0 -39
- package/lib/sql-query/Typo/SubQuery.js +0 -2
- package/lib/sql-query/Typo/index.js +0 -2
- package/lib/sql-query/Update.d.ts +0 -15
- package/lib/sql-query/Update.js +0 -39
- 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
|
@@ -1,229 +1,308 @@
|
|
|
1
|
-
import type { FxOrmSqlDDLSync } from "../../sql-ddl-sync/index"
|
|
2
|
-
import { FxOrmAssociation } from "./assoc"
|
|
3
|
-
import { FxOrmInstance } from "./instance"
|
|
4
|
-
import { FxOrmProperty } from "./property"
|
|
5
|
-
import { FxOrmSettings } from "./settings"
|
|
6
|
-
import { FxOrmCommon } from "./_common"
|
|
7
|
-
import { FxOrmSynchronous } from "./synchronous"
|
|
8
|
-
import { FxOrmQuery } from "./query"
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import type {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import type { FxOrmSqlDDLSync } from "../../sql-ddl-sync/index"
|
|
2
|
+
import type { FxOrmAssociation } from "./assoc"
|
|
3
|
+
import type { FxOrmInstance } from "./instance"
|
|
4
|
+
import type { FxOrmProperty } from "./property"
|
|
5
|
+
import type { FxOrmSettings } from "./settings"
|
|
6
|
+
import type { FxOrmCommon } from "./_common"
|
|
7
|
+
import type { FxOrmSynchronous } from "./synchronous"
|
|
8
|
+
import type { FxOrmQuery } from "./query"
|
|
9
|
+
import type { FxOrmDMLDriver } from "./DMLDriver"
|
|
10
|
+
import type { FxOrmValidators } from "./Validators"
|
|
11
|
+
import type { FxOrmHook } from "./hook"
|
|
12
|
+
import type { FxOrmNS } from "./ORM"
|
|
13
|
+
|
|
14
|
+
import type {
|
|
15
|
+
FxSqlQuerySubQuery,
|
|
16
|
+
FxSqlQuerySql,
|
|
17
|
+
FxSqlQueryChainBuilder,
|
|
18
|
+
} from '../../sql-query/Query';
|
|
19
|
+
import type { FxOrmError } from "./Error"
|
|
20
|
+
|
|
21
|
+
export namespace FxOrmModel {
|
|
22
|
+
export type ModelInstanceConstructorOptions = (string | number | FxOrmInstance.InstanceDataPayload)[]
|
|
23
|
+
|
|
24
|
+
export type OrderListOrLimitOffer = number | string | string[]
|
|
25
|
+
|
|
26
|
+
export interface Model<
|
|
27
|
+
PropertyTypes extends Record<string, FxOrmInstance.FieldRuntimeType> = Record<string, FxOrmInstance.FieldRuntimeType>,
|
|
28
|
+
Methods extends Record<string, (...args: any) => any> = Record<string, (...args: any) => any>,
|
|
29
|
+
> extends ModelHooksModifier, FxOrmSynchronous.SynchronizedModel<PropertyTypes, Methods> {
|
|
18
30
|
(): FxOrmInstance.Instance<PropertyTypes, Methods>;
|
|
19
|
-
new
|
|
31
|
+
new(): FxOrmInstance.Instance<PropertyTypes, Methods>;
|
|
20
32
|
(...data: ModelInstanceConstructorOptions): FxOrmInstance.Instance<PropertyTypes, Methods>;
|
|
21
|
-
new
|
|
33
|
+
new(...data: ModelInstanceConstructorOptions): FxOrmInstance.Instance<PropertyTypes, Methods>;
|
|
34
|
+
|
|
22
35
|
name: string;
|
|
23
36
|
properties: Record<string, FxOrmProperty.NormalizedProperty>;
|
|
24
37
|
settings: FxOrmSettings.SettingInstance;
|
|
38
|
+
|
|
25
39
|
table: string;
|
|
26
40
|
id: string[];
|
|
41
|
+
/* @nonenum */
|
|
27
42
|
uid: string;
|
|
43
|
+
|
|
28
44
|
caches: import('fib-cache').LRU;
|
|
45
|
+
|
|
29
46
|
keys: string[];
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
47
|
+
|
|
48
|
+
allProperties: Record<string, FxOrmProperty.NormalizedProperty>
|
|
49
|
+
virtualProperties: Record<string, FxOrmProperty.NormalizedProperty>
|
|
50
|
+
|
|
51
|
+
/* property operation :start */
|
|
52
|
+
addProperty(
|
|
53
|
+
propIn: FxOrmProperty.NormalizedProperty,
|
|
54
|
+
options?: {
|
|
55
|
+
name?: string
|
|
56
|
+
klass?: FxOrmProperty.KlassType
|
|
57
|
+
} | false
|
|
58
|
+
): FxOrmProperty.NormalizedProperty
|
|
59
|
+
|
|
36
60
|
/** @internal */
|
|
37
|
-
readonly __propertiesByName: Record<string, FxOrmProperty.NormalizedProperty
|
|
61
|
+
readonly __propertiesByName: Record<string, FxOrmProperty.NormalizedProperty>
|
|
62
|
+
/* property operation :end */
|
|
63
|
+
|
|
38
64
|
sync(callback?: FxOrmCommon.GenericCallback<FxOrmSqlDDLSync.SyncResult>): Model;
|
|
39
65
|
drop(callback?: FxOrmCommon.VoidCallback): Model;
|
|
66
|
+
|
|
40
67
|
/**
|
|
41
68
|
* methods used to add associations
|
|
42
69
|
*/
|
|
70
|
+
/* association about api :start */
|
|
43
71
|
hasOne: {
|
|
44
|
-
(assoc_name: string, ext_model?: Model, assoc_options?: FxOrmAssociation.AssociationDefinitionOptions_HasOne): FxOrmModel.Model
|
|
45
|
-
}
|
|
72
|
+
(assoc_name: string, ext_model?: Model, assoc_options?: FxOrmAssociation.AssociationDefinitionOptions_HasOne): FxOrmModel.Model
|
|
73
|
+
}
|
|
46
74
|
hasMany: {
|
|
47
|
-
(assoc_name: string, ext_model: Model, assoc_options?: FxOrmAssociation.AssociationDefinitionOptions_HasMany): FxOrmModel.Model
|
|
48
|
-
(assoc_name: string, ext_model: Model, assoc_props: Record<string, ModelPropertyDefinition>, assoc_options?: FxOrmAssociation.AssociationDefinitionOptions_HasMany): FxOrmModel.Model
|
|
49
|
-
}
|
|
75
|
+
(assoc_name: string, ext_model: Model, assoc_options?: FxOrmAssociation.AssociationDefinitionOptions_HasMany): FxOrmModel.Model
|
|
76
|
+
(assoc_name: string, ext_model: Model, assoc_props: Record<string, ModelPropertyDefinition>, assoc_options?: FxOrmAssociation.AssociationDefinitionOptions_HasMany): FxOrmModel.Model
|
|
77
|
+
}
|
|
50
78
|
extendsTo: {
|
|
51
|
-
(name: string, properties: Record<string, ModelPropertyDefinition>, assoc_options?: FxOrmAssociation.AssociationDefinitionOptions_ExtendsTo): Model
|
|
79
|
+
(name: string, properties: Record<string, ModelPropertyDefinition>, assoc_options?: FxOrmAssociation.AssociationDefinitionOptions_ExtendsTo): Model
|
|
52
80
|
};
|
|
81
|
+
|
|
53
82
|
associations: {
|
|
54
83
|
[k: string]: {
|
|
55
|
-
type: 'hasOne'
|
|
56
|
-
association: FxOrmAssociation.InstanceAssociationItem_HasOne
|
|
84
|
+
type: 'hasOne'
|
|
85
|
+
association: FxOrmAssociation.InstanceAssociationItem_HasOne
|
|
57
86
|
} | {
|
|
58
|
-
type: 'hasMany'
|
|
59
|
-
association: FxOrmAssociation.InstanceAssociationItem_HasMany
|
|
87
|
+
type: 'hasMany'
|
|
88
|
+
association: FxOrmAssociation.InstanceAssociationItem_HasMany
|
|
60
89
|
} | {
|
|
61
|
-
type: 'extendsTo'
|
|
62
|
-
association: FxOrmAssociation.InstanceAssociationItem_ExtendTos
|
|
63
|
-
}
|
|
64
|
-
}
|
|
90
|
+
type: 'extendsTo'
|
|
91
|
+
association: FxOrmAssociation.InstanceAssociationItem_ExtendTos
|
|
92
|
+
}
|
|
93
|
+
}
|
|
65
94
|
findBy: {
|
|
66
|
-
<T = any>(
|
|
67
|
-
|
|
68
|
-
|
|
95
|
+
<T = any>(
|
|
96
|
+
association_name: ModelFindByDescriptorItem['association_name'],
|
|
97
|
+
conditions?: ModelFindByDescriptorItem['conditions'],
|
|
98
|
+
options?: ModelFindByDescriptorItem['options'],
|
|
99
|
+
cb?: FxOrmCommon.ExecutionCallback<T>
|
|
100
|
+
): FxOrmQuery.IChainFind
|
|
101
|
+
<T = any>(
|
|
102
|
+
list: ModelFindByDescriptorItem[],
|
|
103
|
+
self_conditions: FxOrmQuery.QueryConditions__Find,
|
|
104
|
+
options?: ModelFindByDescriptorItem['options'],
|
|
105
|
+
cb?: FxOrmCommon.ExecutionCallback<T>
|
|
106
|
+
): FxOrmQuery.IChainFind
|
|
107
|
+
}
|
|
108
|
+
/* association about api :end */
|
|
109
|
+
|
|
110
|
+
/* data operation api :start */
|
|
69
111
|
create: {
|
|
70
112
|
(data: FxOrmInstance.InstanceDataPayload, callback?: ModelMethodCallback__CreateItem): typeof data extends any[] ? FxOrmInstance.Instance<PropertyTypes, Methods>[] : FxOrmInstance.Instance<PropertyTypes, Methods>;
|
|
71
113
|
(data: FxOrmInstance.InstanceDataPayload, options?: ModelOptions__Create, callback?: ModelMethodCallback__CreateItem): typeof data extends any[] ? FxOrmInstance.Instance<PropertyTypes, Methods>[] : FxOrmInstance.Instance<PropertyTypes, Methods>;
|
|
72
|
-
}
|
|
73
|
-
clear(...args: any[]): this
|
|
74
|
-
get(...ids: any[]): this
|
|
114
|
+
}
|
|
115
|
+
clear(...args: any[]): this
|
|
116
|
+
get(...ids: any[]): this
|
|
117
|
+
|
|
75
118
|
chain: {
|
|
76
119
|
(conditions?: FxOrmQuery.QueryConditions__Find, ...args: (FxOrmModel.ModelOptions__Find | OrderListOrLimitOffer)[]): FxOrmQuery.IChainFind;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
find(
|
|
80
|
-
find(
|
|
81
|
-
find(conditions: FxOrmQuery.QueryConditions__Find,
|
|
82
|
-
|
|
83
|
-
find(conditions: FxOrmQuery.QueryConditions__Find,
|
|
84
|
-
find(conditions: FxOrmQuery.QueryConditions__Find,
|
|
85
|
-
find(conditions: FxOrmQuery.QueryConditions__Find, limit_order
|
|
86
|
-
|
|
87
|
-
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
find(conditions?: FxOrmQuery.QueryConditions__Find): FxOrmQuery.IChainFind<PropertyTypes, Methods>
|
|
123
|
+
find(callback: ModelMethodCallback__Find): FxOrmQuery.IChainFind<PropertyTypes, Methods>
|
|
124
|
+
find(conditions: FxOrmQuery.QueryConditions__Find, callback: ModelMethodCallback__Find): FxOrmQuery.IChainFind<PropertyTypes, Methods>
|
|
125
|
+
|
|
126
|
+
find(conditions: FxOrmQuery.QueryConditions__Find, options: ModelOptions__Find): FxOrmQuery.IChainFind<PropertyTypes, Methods>
|
|
127
|
+
find(conditions: FxOrmQuery.QueryConditions__Find, options: ModelOptions__Find, callback: ModelMethodCallback__Find): FxOrmQuery.IChainFind<PropertyTypes, Methods>
|
|
128
|
+
find(conditions: FxOrmQuery.QueryConditions__Find, limit_order?: OrderListOrLimitOffer, limit_order2?: OrderListOrLimitOffer): FxOrmQuery.IChainFind<PropertyTypes, Methods>
|
|
129
|
+
|
|
130
|
+
find(conditions: FxOrmQuery.QueryConditions__Find, limit_order: OrderListOrLimitOffer, callback: ModelMethodCallback__Find): FxOrmQuery.IChainFind<PropertyTypes, Methods>
|
|
131
|
+
find(conditions: FxOrmQuery.QueryConditions__Find, limit_order: OrderListOrLimitOffer, limit_order2: OrderListOrLimitOffer, callback: ModelMethodCallback__Find): FxOrmQuery.IChainFind<PropertyTypes, Methods>
|
|
132
|
+
|
|
133
|
+
all: this['find']
|
|
134
|
+
where: this['find']
|
|
135
|
+
|
|
88
136
|
/**
|
|
89
137
|
* not like other methods, you must provide callback to those methods
|
|
90
138
|
* - `one`
|
|
91
139
|
* - `count`
|
|
92
140
|
* - `exists`
|
|
93
|
-
*
|
|
141
|
+
*
|
|
94
142
|
* that's maybe due to their purpose: always return Model rather than IChainFind
|
|
95
143
|
*/
|
|
96
144
|
one: {
|
|
97
|
-
(callback: ModelMethodCallback__Get):
|
|
98
|
-
(conditions: FxOrmQuery.QueryConditions__Find, callback: ModelMethodCallback__Get):
|
|
99
|
-
(conditions: FxOrmQuery.QueryConditions__Find, options: ModelOptions__Find, callback: ModelMethodCallback__Get):
|
|
100
|
-
(conditions: FxOrmQuery.QueryConditions__Find, order: string[], callback: ModelMethodCallback__Get):
|
|
101
|
-
(conditions: FxOrmQuery.QueryConditions__Find, limit: number, callback: ModelMethodCallback__Get):
|
|
102
|
-
}
|
|
145
|
+
(callback: ModelMethodCallback__Get): FxOrmQuery.IChainFind<PropertyTypes, Methods>;
|
|
146
|
+
(conditions: FxOrmQuery.QueryConditions__Find, callback: ModelMethodCallback__Get): FxOrmQuery.IChainFind<PropertyTypes, Methods>;
|
|
147
|
+
(conditions: FxOrmQuery.QueryConditions__Find, options: ModelOptions__Find, callback: ModelMethodCallback__Get): FxOrmQuery.IChainFind<PropertyTypes, Methods>;
|
|
148
|
+
(conditions: FxOrmQuery.QueryConditions__Find, order: string[], callback: ModelMethodCallback__Get): FxOrmQuery.IChainFind<PropertyTypes, Methods>;
|
|
149
|
+
(conditions: FxOrmQuery.QueryConditions__Find, limit: number, callback: ModelMethodCallback__Get): FxOrmQuery.IChainFind<PropertyTypes, Methods>;
|
|
150
|
+
}
|
|
151
|
+
|
|
103
152
|
count: {
|
|
104
153
|
(callback: ModelMethodCallback__Count): Model;
|
|
105
154
|
(conditions: FxOrmQuery.QueryConditions__Find, callback: ModelMethodCallback__Count): Model;
|
|
106
|
-
}
|
|
155
|
+
}
|
|
156
|
+
|
|
107
157
|
exists: {
|
|
108
|
-
(...conditions: (FxOrmCommon.IdType | FxSqlQuerySubQuery.SubQueryConditions | FxOrmCommon.ExecutionCallback<boolean>)[]):
|
|
109
|
-
}
|
|
158
|
+
(...conditions: (FxOrmCommon.IdType | FxSqlQuerySubQuery.SubQueryConditions | FxOrmCommon.ExecutionCallback<boolean>)[]): Model
|
|
159
|
+
}
|
|
160
|
+
|
|
110
161
|
aggregate: {
|
|
111
162
|
(conditions: FxOrmQuery.QueryConditions__Find): FxOrmQuery.IAggregated;
|
|
112
163
|
(properties: string[]): FxOrmQuery.IAggregated;
|
|
113
164
|
(conditions: FxOrmQuery.QueryConditions__Find, properties: string[]): FxOrmQuery.IAggregated;
|
|
114
|
-
}
|
|
165
|
+
}
|
|
166
|
+
/* data operation api :end */
|
|
167
|
+
|
|
115
168
|
prependValidation: {
|
|
116
|
-
(key: string, validation: FibjsEnforce.IValidator): void
|
|
117
|
-
}
|
|
169
|
+
(key: string, validation: FibjsEnforce.IValidator): void
|
|
170
|
+
}
|
|
171
|
+
|
|
118
172
|
[property: string]: any;
|
|
119
173
|
}
|
|
120
|
-
|
|
174
|
+
|
|
175
|
+
export type GetInstanceTypeFrom<T> = T extends Model<infer U, infer S> ? FxOrmInstance.Instance<U, S> : never
|
|
176
|
+
|
|
121
177
|
export type FindByListStyleFunctionArgs<T = any> = [
|
|
122
178
|
FxOrmModel.ModelFindByDescriptorItem[],
|
|
123
179
|
FxOrmQuery.QueryConditions__Find,
|
|
124
180
|
FxOrmModel.ModelOptions__Find,
|
|
125
181
|
FxOrmCommon.ExecutionCallback<T>
|
|
126
|
-
]
|
|
182
|
+
]
|
|
183
|
+
|
|
127
184
|
export type FindByItemStyleFunctionArgs<T = any> = [
|
|
128
185
|
FxOrmModel.ModelFindByDescriptorItem['association_name'],
|
|
129
186
|
FxOrmModel.ModelFindByDescriptorItem['conditions'],
|
|
130
187
|
FxOrmModel.ModelFindByDescriptorItem['options'],
|
|
131
188
|
FxOrmCommon.ExecutionCallback<T>
|
|
132
|
-
]
|
|
189
|
+
]
|
|
190
|
+
|
|
133
191
|
export interface ModelFindByDescriptorItem {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
192
|
+
// association name
|
|
193
|
+
association_name: string,
|
|
194
|
+
// findby conditions
|
|
195
|
+
conditions?: FxOrmQuery.QueryConditions__Find,
|
|
196
|
+
// findby options
|
|
197
|
+
options?: FxOrmAssociation.ModelAssociationMethod__FindByOptions,
|
|
198
|
+
|
|
137
199
|
/**
|
|
138
200
|
* @deprecated extra where conditions fields for hasmany-assoc
|
|
139
201
|
* @internal
|
|
140
202
|
*/
|
|
141
|
-
|
|
142
|
-
|
|
203
|
+
join_where?: FxOrmAssociation.ModelAssociationMethod__FindOptions['join_where']
|
|
204
|
+
// extra select fields for hasmany-assoc
|
|
205
|
+
extra_select?: string[]
|
|
143
206
|
}
|
|
144
|
-
export interface ModelConstructorOptions<
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
207
|
+
export interface ModelConstructorOptions<
|
|
208
|
+
TProperties extends Record<string, FxOrmInstance.FieldRuntimeType> = Record<string, FxOrmInstance.FieldRuntimeType>
|
|
209
|
+
> {
|
|
210
|
+
name: string
|
|
211
|
+
uid: string
|
|
212
|
+
db: FxOrmNS.ORM
|
|
213
|
+
settings: FxOrmSettings.SettingInstance
|
|
214
|
+
driver_name: string
|
|
215
|
+
driver: FxOrmQuery.ChainFindOptions['driver']
|
|
216
|
+
table: FxOrmQuery.ChainFindOptions['table']
|
|
217
|
+
tableComment: string
|
|
218
|
+
generateSqlSelect?: FxOrmQuery.ChainFindOptions['generateSqlSelect']
|
|
219
|
+
properties: Record<keyof TProperties, FxOrmProperty.NormalizedProperty>
|
|
154
220
|
/** @internal */
|
|
155
|
-
__for_extension: boolean
|
|
221
|
+
__for_extension: boolean
|
|
156
222
|
/**
|
|
157
223
|
* @description if enabled, this model will be a virtual model,
|
|
158
224
|
* all Properties will be coerced to virtual property
|
|
159
225
|
*/
|
|
160
226
|
virtualView: {
|
|
161
|
-
disabled?: boolean
|
|
162
|
-
subQuery: `(${string})
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
227
|
+
disabled?: boolean
|
|
228
|
+
subQuery: `(${string})`
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
indexes: string[]
|
|
232
|
+
|
|
233
|
+
identityCache: boolean | number
|
|
234
|
+
instanceCacheSize: number
|
|
235
|
+
|
|
236
|
+
keys: FxOrmQuery.ChainFindOptions['keys']
|
|
237
|
+
autoSave: boolean
|
|
238
|
+
autoFetch: boolean
|
|
239
|
+
autoFetchLimit: number
|
|
240
|
+
cascadeRemove: boolean
|
|
241
|
+
hooks: Hooks<FxOrmInstance.Instance<TProperties>>
|
|
242
|
+
methods: Record<string, (this: FxOrmInstance.Instance<TProperties>, ...args: any) => any>
|
|
243
|
+
validations: FxOrmValidators.IValidatorHash
|
|
244
|
+
ievents: FxOrmInstance.InstanceConstructorOptions['events']
|
|
176
245
|
}
|
|
177
|
-
|
|
178
|
-
|
|
246
|
+
|
|
247
|
+
type __ItOrItsArray<T> = T | T[]
|
|
248
|
+
|
|
249
|
+
export interface ModelDefineOptions<
|
|
250
|
+
TProperties extends Record<string, FxOrmInstance.FieldRuntimeType> = Record<string, FxOrmInstance.FieldRuntimeType>
|
|
251
|
+
>{
|
|
179
252
|
/**
|
|
180
253
|
* pririoty: table > collection
|
|
181
254
|
*/
|
|
182
|
-
table?: ModelConstructorOptions<TProperties>['table']
|
|
255
|
+
table?: ModelConstructorOptions<TProperties>['table']
|
|
256
|
+
|
|
183
257
|
/**
|
|
184
258
|
* @advanced
|
|
185
259
|
* @description use to specify the query source on DMLDriver's `find` excution,
|
|
186
|
-
*
|
|
260
|
+
*
|
|
187
261
|
* if enable this, then:
|
|
188
262
|
* - `table` will be ignored on generate SQL select
|
|
189
263
|
* - all put-like operations will be disabled for this model
|
|
190
264
|
* - `generateSqlSelect` would be ignored
|
|
191
|
-
*
|
|
265
|
+
*
|
|
192
266
|
* @warning if use this option, you must ensure the `selectTableSource` is a valid
|
|
193
267
|
*/
|
|
194
268
|
customSelect?: __ItOrItsArray<{
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
269
|
+
// subQuery: FxSqlQuerySql.SqlTableInputType
|
|
270
|
+
from: __ItOrItsArray<FxSqlQuerySql.SqlTableInputType>
|
|
271
|
+
select?: FxSqlQuerySql.SqlSelectFieldsType[]
|
|
272
|
+
wheres?: string | Parameters<FxSqlQueryChainBuilder.ChainBuilder__Select['where']>[0] & object
|
|
273
|
+
}>
|
|
274
|
+
generateSqlSelect?: ModelConstructorOptions<TProperties>['generateSqlSelect']
|
|
275
|
+
virtualView?: false | string | FxSqlQuerySql.SqlFromTableInput
|
|
276
|
+
| ModelConstructorOptions<TProperties>['virtualView']
|
|
277
|
+
|
|
278
|
+
collection?: ModelConstructorOptions<TProperties>['table']
|
|
279
|
+
tableComment?: ModelConstructorOptions<TProperties>['tableComment']
|
|
203
280
|
/**
|
|
204
281
|
* @dirty would be deprecated
|
|
205
282
|
*/
|
|
206
|
-
__for_extension?: ModelConstructorOptions<TProperties>['__for_extension']
|
|
207
|
-
indexes?: ModelConstructorOptions<TProperties>['indexes']
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
283
|
+
__for_extension?: ModelConstructorOptions<TProperties>['__for_extension']
|
|
284
|
+
indexes?: ModelConstructorOptions<TProperties>['indexes']
|
|
285
|
+
// keys composition, it's array-like
|
|
286
|
+
id?: ModelConstructorOptions<TProperties>['keys']
|
|
287
|
+
autoSave?: ModelConstructorOptions<TProperties>['autoSave']
|
|
288
|
+
autoFetch?: ModelConstructorOptions<TProperties>['autoFetch']
|
|
289
|
+
autoFetchLimit?: ModelConstructorOptions<TProperties>['autoFetchLimit']
|
|
290
|
+
hooks?: ModelConstructorOptions<TProperties>['hooks']
|
|
291
|
+
validations?: ModelConstructorOptions<TProperties>['validations']
|
|
292
|
+
methods?: Record<string, (this: FxOrmInstance.Instance<TProperties>, ...args: any) => any>
|
|
293
|
+
identityCache?: ModelConstructorOptions<TProperties>['identityCache']
|
|
294
|
+
cascadeRemove?: ModelConstructorOptions<TProperties>['cascadeRemove']
|
|
295
|
+
ievents?: ModelConstructorOptions<TProperties>['ievents']
|
|
296
|
+
useSelfSettings?: boolean
|
|
219
297
|
[extensibleProperty: string]: any;
|
|
220
298
|
}
|
|
299
|
+
|
|
221
300
|
export interface Hooks<TThis = FxOrmInstance.Instance> {
|
|
222
301
|
beforeValidation?: FxOrmCommon.Arraible<FxOrmHook.HookActionCallback<TThis>>;
|
|
223
302
|
afterValidation?: FxOrmCommon.Arraible<FxOrmHook.HookRetPayloadCallback<TThis, {
|
|
224
|
-
errors: FxOrmError.ExtendedError[]
|
|
225
|
-
setErrors: (errors: FxOrmError.ExtendedError[]) => void
|
|
226
|
-
}
|
|
303
|
+
errors: FxOrmError.ExtendedError[],
|
|
304
|
+
setErrors: (errors: FxOrmError.ExtendedError[]) => void
|
|
305
|
+
}>>
|
|
227
306
|
beforeCreate?: FxOrmCommon.Arraible<FxOrmHook.HookActionCallback<TThis>>;
|
|
228
307
|
afterCreate?: FxOrmCommon.Arraible<FxOrmHook.HookResultCallback<TThis>>;
|
|
229
308
|
beforeSave?: FxOrmCommon.Arraible<FxOrmHook.HookActionCallback<TThis>>;
|
|
@@ -233,9 +312,12 @@ export declare namespace FxOrmModel {
|
|
|
233
312
|
beforeRemove?: FxOrmCommon.Arraible<FxOrmHook.HookActionCallback<TThis>>;
|
|
234
313
|
afterRemove?: FxOrmCommon.Arraible<FxOrmHook.HookResultCallback<TThis>>;
|
|
235
314
|
}
|
|
236
|
-
|
|
315
|
+
|
|
316
|
+
type __Item<T extends any> = T extends (infer U)[] ? U : T
|
|
317
|
+
|
|
237
318
|
export interface ModelHookPatchOptions extends FxOrmHook.HookPatchOptions {
|
|
238
319
|
}
|
|
320
|
+
|
|
239
321
|
export interface ModelHooksModifier {
|
|
240
322
|
beforeValidation?: (func: __Item<Hooks['beforeValidation']>, opts?: ModelHookPatchOptions) => any;
|
|
241
323
|
afterValidation?: (func: __Item<Hooks['afterValidation']>, opts?: ModelHookPatchOptions) => void;
|
|
@@ -248,64 +330,105 @@ export declare namespace FxOrmModel {
|
|
|
248
330
|
beforeRemove?: (func: __Item<Hooks['beforeRemove']>, opts?: ModelHookPatchOptions) => any;
|
|
249
331
|
afterRemove?: (func: __Item<Hooks['afterRemove']>, opts?: ModelHookPatchOptions) => any;
|
|
250
332
|
}
|
|
333
|
+
|
|
251
334
|
export interface ModelPropertyDefinition extends FxOrmProperty.DataStoreProperty {
|
|
252
|
-
key?: boolean
|
|
253
|
-
klass?: FxOrmProperty.KlassType
|
|
254
|
-
alwaysValidate?: boolean
|
|
255
|
-
enumerable?: boolean
|
|
256
|
-
lazyload
|
|
335
|
+
key?: boolean
|
|
336
|
+
klass?: FxOrmProperty.KlassType
|
|
337
|
+
alwaysValidate?: boolean
|
|
338
|
+
enumerable?: boolean
|
|
339
|
+
// whether lazyload property, if it is, it can be loaded only by its accessor
|
|
340
|
+
lazyload?: boolean
|
|
257
341
|
}
|
|
258
|
-
|
|
259
|
-
export type
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
342
|
+
|
|
343
|
+
export type PrimitiveConstructor =
|
|
344
|
+
| StringConstructor
|
|
345
|
+
| BooleanConstructor
|
|
346
|
+
| NumberConstructor
|
|
347
|
+
| DateConstructor
|
|
348
|
+
| ObjectConstructor
|
|
349
|
+
|
|
350
|
+
export type ComplexModelPropertyDefinition =
|
|
351
|
+
ModelPropertyDefinition
|
|
352
|
+
| (PrimitiveConstructor & {
|
|
353
|
+
name?: string
|
|
354
|
+
})
|
|
355
|
+
| [...(string | number)[]]
|
|
356
|
+
| (FxOrmProperty.NormalizedProperty['type'])
|
|
357
|
+
|
|
358
|
+
export type GetPrimitiveFromConstructor<T extends PrimitiveConstructor = PrimitiveConstructor> =
|
|
359
|
+
T extends StringConstructor ? string :
|
|
360
|
+
T extends NumberConstructor ? number :
|
|
361
|
+
T extends BooleanConstructor ? boolean :
|
|
362
|
+
T extends DateConstructor ? number | Date :
|
|
363
|
+
T extends ObjectConstructor | typeof Class_Buffer ? any : never
|
|
364
|
+
|
|
263
365
|
type GlobalModelType = FxOrmProperty.GlobalCustomModelType & {
|
|
264
|
-
[P in FxOrmProperty.PropertyType]: FxOrmProperty.GetPrimitiveFromOrmPropertyType<P
|
|
265
|
-
}
|
|
266
|
-
|
|
366
|
+
[P in FxOrmProperty.PropertyType]: FxOrmProperty.GetPrimitiveFromOrmPropertyType<P>
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export type GetPropertiesTypeFromDefinition<T extends ComplexModelPropertyDefinition> =
|
|
370
|
+
T extends keyof GlobalModelType ? GlobalModelType[T]:
|
|
371
|
+
T extends [...infer S] ? S[number] :
|
|
372
|
+
T extends ModelPropertyDefinition ?
|
|
373
|
+
T['type'] extends 'enum' ? Exclude<T['values'], void>[number] :
|
|
374
|
+
(T['type'] extends keyof GlobalModelType ? GlobalModelType[T['type']] : unknown) :
|
|
375
|
+
// T['type'] extends PrimitiveConstructor ? GetPrimitiveFromConstructor<T['type']> :
|
|
376
|
+
T extends PrimitiveConstructor ? GetPrimitiveFromConstructor<T>
|
|
377
|
+
: unknown
|
|
378
|
+
|
|
267
379
|
export type GetPropertiesType<T extends Record<string, ComplexModelPropertyDefinition>> = {
|
|
268
|
-
[K in keyof T]: FxOrmModel.GetPropertiesTypeFromDefinition<T[K]
|
|
269
|
-
}
|
|
270
|
-
|
|
380
|
+
[K in keyof T]: FxOrmModel.GetPropertiesTypeFromDefinition<T[K]>
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
export interface ModelOptions__Find {
|
|
271
384
|
only?: string[];
|
|
272
385
|
limit?: number;
|
|
273
|
-
order?: FxOrmQuery.OrderRawInput | FxOrmQuery.ChainFindOptions['order']
|
|
386
|
+
order?: FxOrmQuery.OrderRawInput | FxOrmQuery.ChainFindOptions['order']
|
|
274
387
|
offset?: number;
|
|
275
|
-
identityCache?: boolean
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
388
|
+
identityCache?: boolean | number
|
|
389
|
+
|
|
390
|
+
autoFetch?: boolean
|
|
391
|
+
cascadeRemove?: boolean
|
|
392
|
+
autoSave?: boolean
|
|
393
|
+
autoFetchLimit?: number
|
|
280
394
|
/** @internal */
|
|
281
|
-
__merge?: FxOrmQuery.ChainFindOptions['merge']
|
|
395
|
+
__merge?: FxOrmQuery.ChainFindOptions['merge']
|
|
282
396
|
/** @internal */
|
|
283
397
|
chainfind_linktable?: string;
|
|
284
398
|
/** @internal */
|
|
285
|
-
exists?: [FxOrmQuery.ChainWhereExistsInfo]
|
|
399
|
+
exists?: [FxOrmQuery.ChainWhereExistsInfo]
|
|
400
|
+
|
|
286
401
|
/**
|
|
287
402
|
* @description extra fields on find, e.g. from hasMany extra properties
|
|
288
403
|
*/
|
|
289
|
-
extra?: FxOrmAssociation.InstanceAssociationItem_HasMany['props']
|
|
290
|
-
|
|
404
|
+
extra?: FxOrmAssociation.InstanceAssociationItem_HasMany['props']
|
|
405
|
+
|
|
406
|
+
// access dynamic findby options
|
|
407
|
+
[k: string]: any
|
|
291
408
|
}
|
|
409
|
+
|
|
292
410
|
export interface ModelOptions__Findby extends ModelOptions__Find {
|
|
411
|
+
|
|
293
412
|
}
|
|
294
|
-
|
|
295
|
-
}
|
|
413
|
+
|
|
414
|
+
export interface ModelOptions__Get extends ModelOptions__Find {}
|
|
415
|
+
|
|
296
416
|
/** @deprecated use `FxOrmQuery.QueryConditions__Find` directly */
|
|
297
417
|
export type ModelQueryConditions__Find = FxOrmQuery.QueryConditions__Find;
|
|
298
|
-
|
|
299
|
-
export type
|
|
300
|
-
|
|
301
|
-
export type
|
|
302
|
-
export type
|
|
303
|
-
export type
|
|
304
|
-
export type
|
|
305
|
-
export type
|
|
306
|
-
export type
|
|
418
|
+
|
|
419
|
+
export type ModelMethodOptions_Find = FxOrmCommon.IdType | FxOrmQuery.QueryConditions__Find
|
|
420
|
+
|
|
421
|
+
export type ModelMethodCallback__Boolean = FxOrmCommon.ExecutionCallback<boolean>
|
|
422
|
+
export type ModelMethodCallback__Find = FxOrmCommon.GenericCallback<FxOrmInstance.Instance[]>
|
|
423
|
+
export type ModelMethodCallback__Get = FxOrmCommon.GenericCallback<FxOrmInstance.Instance>
|
|
424
|
+
export type ModelMethodCallback__CreateItem = FxOrmCommon.GenericCallback<FxOrmInstance.Instance>
|
|
425
|
+
export type ModelMethodCallback__UpdateItem = FxOrmCommon.GenericCallback<FxOrmInstance.Instance>
|
|
426
|
+
export type ModelMethodCallback__BatchCreate = FxOrmCommon.GenericCallback<FxOrmInstance.Instance[]>
|
|
427
|
+
export type ModelMethodCallback__BatchUpdate = FxOrmCommon.GenericCallback<FxOrmInstance.Instance[]>
|
|
428
|
+
|
|
429
|
+
export type ModelMethodCallback__Count = FxOrmCommon.GenericCallback<number>
|
|
430
|
+
|
|
307
431
|
export interface ModelOptions__Create {
|
|
308
|
-
parallel?: boolean
|
|
432
|
+
parallel?: boolean
|
|
309
433
|
}
|
|
310
|
-
|
|
311
|
-
}
|
|
434
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export namespace FxOrmPatch {
|
|
2
|
+
export interface PatchedSyncfiedModelOrInstance {
|
|
3
|
+
/**
|
|
4
|
+
* @important
|
|
5
|
+
*
|
|
6
|
+
* methods patchSyncfied by 'fib-orm'
|
|
7
|
+
*/
|
|
8
|
+
countSync: (...args: any[]) => any;
|
|
9
|
+
firstSync: (...args: any[]) => any;
|
|
10
|
+
lastSync: (...args: any[]) => any;
|
|
11
|
+
allSync: (...args: any[]) => any;
|
|
12
|
+
whereSync: (...args: any[]) => any;
|
|
13
|
+
findSync: (...args: any[]) => any;
|
|
14
|
+
removeSync: (...args: any[]) => any;
|
|
15
|
+
runSync: (...args: any[]) => any;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface PatchedSyncfiedInstanceWithDbWriteOperation extends PatchedSyncfiedModelOrInstance {
|
|
19
|
+
saveSync: (...args: any[]) => any;
|
|
20
|
+
removeSync: (...args: any[]) => any;
|
|
21
|
+
validateSync: (...args: any[]) => any;
|
|
22
|
+
modelSync: (...args: any[]) => any;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface PatchedSyncfiedInstanceWithAssociations {
|
|
26
|
+
/**
|
|
27
|
+
* generated by association, but you don't know what it is
|
|
28
|
+
*/
|
|
29
|
+
/* getXxx: (...args: any[]) => any; */
|
|
30
|
+
/* setXxx: (...args: any[]) => any; */
|
|
31
|
+
/* removeXxx: (...args: any[]) => any; */
|
|
32
|
+
|
|
33
|
+
/* findByXxx: (...args: any[]) => any; */
|
|
34
|
+
[associationFunc: string]: (...args: any[]) => any;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface PatchedSyncfiedInstantce extends FxOrmPatch.PatchedSyncfiedInstanceWithDbWriteOperation, FxOrmPatch.PatchedSyncfiedInstanceWithAssociations {
|
|
38
|
+
}
|
|
39
|
+
}
|