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,315 @@
|
|
|
1
|
+
/// <reference types="@fibjs/enforce" />
|
|
2
|
+
|
|
3
|
+
import type { FxOrmModel } from "./model"
|
|
4
|
+
import type { FxOrmInstance } from "./instance";
|
|
5
|
+
import type { FxOrmQuery } from "./query";
|
|
6
|
+
import type { FxOrmDMLDriver } from "./DMLDriver";
|
|
7
|
+
import type { FxOrmValidators } from "./Validators";
|
|
8
|
+
import type { FxOrmSettings } from "./settings";
|
|
9
|
+
import type { FxOrmPatch } from "./patch";
|
|
10
|
+
import type { FxOrmAssociation } from "./assoc";
|
|
11
|
+
import type { FxOrmSynchronous } from "./synchronous";
|
|
12
|
+
import type { FxOrmProperty } from "./property";
|
|
13
|
+
import type { FxOrmCommon } from "./_common";
|
|
14
|
+
import type { FxDbDriverNS } from "../../db-driver/index";
|
|
15
|
+
|
|
16
|
+
import type {
|
|
17
|
+
FxSqlQueryComparator,
|
|
18
|
+
FxSqlQueryChainBuilder
|
|
19
|
+
} from '../../sql-query/Query';
|
|
20
|
+
|
|
21
|
+
export type {
|
|
22
|
+
FxSqlAggregation,
|
|
23
|
+
FxSqlQueryComparator,
|
|
24
|
+
FxSqlQueryComparatorFunction,
|
|
25
|
+
FxSqlQueryDialect,
|
|
26
|
+
FxSqlQueryColumns,
|
|
27
|
+
FxSqlQueryHelpler,
|
|
28
|
+
FxSqlQueryChainBuilder,
|
|
29
|
+
FxSqlQuery,
|
|
30
|
+
FxSqlQuerySql,
|
|
31
|
+
FxSqlQuerySubQuery,
|
|
32
|
+
} from '../../sql-query/Query';
|
|
33
|
+
|
|
34
|
+
export namespace FxOrmNS {
|
|
35
|
+
/* compatible :start */
|
|
36
|
+
export type Arraible<T> = FxOrmCommon.Arraible<T>
|
|
37
|
+
export type Model = FxOrmModel.Model
|
|
38
|
+
export type IChainFind = FxOrmQuery.IChainFind
|
|
39
|
+
|
|
40
|
+
export type Instance = FxOrmInstance.Instance
|
|
41
|
+
export type Hooks = FxOrmModel.Hooks
|
|
42
|
+
|
|
43
|
+
export type ModelOptions = FxOrmModel.ModelDefineOptions
|
|
44
|
+
|
|
45
|
+
export type ComplexModelPropertyDefinition = FxOrmModel.ComplexModelPropertyDefinition
|
|
46
|
+
|
|
47
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
48
|
+
export type PatchedSyncfiedModelOrInstance = FxOrmPatch.PatchedSyncfiedModelOrInstance
|
|
49
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
50
|
+
export type PatchedSyncfiedInstanceWithDbWriteOperation = FxOrmPatch.PatchedSyncfiedInstanceWithDbWriteOperation
|
|
51
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
52
|
+
export type PatchedSyncfiedInstanceWithAssociations = FxOrmPatch.PatchedSyncfiedInstanceWithAssociations
|
|
53
|
+
|
|
54
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
55
|
+
export type SettingInstance = FxOrmSettings.SettingInstance
|
|
56
|
+
|
|
57
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
58
|
+
export type ModelOptions__Find = FxOrmModel.ModelOptions__Find
|
|
59
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
60
|
+
export type ModelQueryConditions__Find = FxOrmModel.ModelQueryConditions__Find
|
|
61
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
62
|
+
export type ModelMethodCallback__Find = FxOrmModel.ModelMethodCallback__Find
|
|
63
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
64
|
+
export type ModelMethodCallback__Count = FxOrmModel.ModelMethodCallback__Count
|
|
65
|
+
|
|
66
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
67
|
+
export type InstanceDataPayload = FxOrmInstance.InstanceDataPayload
|
|
68
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
69
|
+
export type InstanceAssociationItem_HasMany = FxOrmAssociation.InstanceAssociationItem_HasMany
|
|
70
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
71
|
+
export type InstanceAssociationItem_HasOne = FxOrmAssociation.InstanceAssociationItem_HasOne
|
|
72
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
73
|
+
export type InstanceAssociationItem_ExtendTos = FxOrmAssociation.InstanceAssociationItem_ExtendTos
|
|
74
|
+
|
|
75
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
76
|
+
export type QueryConditionInTypeType = FxOrmQuery.QueryConditionInTypeType
|
|
77
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
78
|
+
export type QueryCondition_SimpleEq = FxOrmQuery.QueryCondition_SimpleEq
|
|
79
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
80
|
+
export type QueryCondition_eq = FxOrmQuery.QueryCondition_eq
|
|
81
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
82
|
+
export type QueryCondition_ne = FxOrmQuery.QueryCondition_ne
|
|
83
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
84
|
+
export type QueryCondition_gt = FxOrmQuery.QueryCondition_gt
|
|
85
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
86
|
+
export type QueryCondition_gte = FxOrmQuery.QueryCondition_gte
|
|
87
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
88
|
+
export type QueryCondition_lt = FxOrmQuery.QueryCondition_lt
|
|
89
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
90
|
+
export type QueryCondition_lte = FxOrmQuery.QueryCondition_lte
|
|
91
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
92
|
+
export type QueryCondition_like = FxOrmQuery.QueryCondition_like
|
|
93
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
94
|
+
export type QueryCondition_not_like = FxOrmQuery.QueryCondition_not_like
|
|
95
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
96
|
+
export type QueryCondition_between = FxOrmQuery.QueryCondition_between
|
|
97
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
98
|
+
export type QueryCondition_not_between = FxOrmQuery.QueryCondition_not_between
|
|
99
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
100
|
+
export type QueryCondition_in = FxOrmQuery.QueryCondition_in
|
|
101
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
102
|
+
export type QueryCondition_not_in = FxOrmQuery.QueryCondition_not_in
|
|
103
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
104
|
+
export type QueryConditionAtomicType = FxOrmQuery.QueryConditionAtomicType
|
|
105
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
106
|
+
export type QueryConditions = FxOrmQuery.QueryConditions
|
|
107
|
+
/* compatible :end */
|
|
108
|
+
|
|
109
|
+
export interface ExtensibleError extends Error {
|
|
110
|
+
[extensibleProperty: string]: any
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface FibORMIConnectionOptions extends FxDbDriverNS.ConnectionInputArgs {
|
|
114
|
+
timezone: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** @deprecated would be deprecated >= 1.16.x */
|
|
118
|
+
export type OrigAggreteGenerator = (...args: any[]) => FxOrmQuery.IAggregated
|
|
119
|
+
|
|
120
|
+
export interface FibOrmFindLikeQueryObject {
|
|
121
|
+
[key: string]: any;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface FibOrmFixedModelInstanceFn {
|
|
125
|
+
(model: FxOrmModel.Model, opts: object): FxOrmInstance.Instance
|
|
126
|
+
new (model: FxOrmModel.Model, opts: object): FxOrmInstance.Instance
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface FibOrmPatchedSyncfiedInstantce extends FxOrmPatch.PatchedSyncfiedInstanceWithDbWriteOperation, FxOrmPatch.PatchedSyncfiedInstanceWithAssociations {
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface IChainFibORMFind extends FxOrmPatch.PatchedSyncfiedModelOrInstance, FxSqlQueryChainBuilder.ChainBuilder__Select {
|
|
133
|
+
only(args: string | string[]): IChainFibORMFind;
|
|
134
|
+
only(...args: string[]): IChainFibORMFind;
|
|
135
|
+
// order(...order: string[]): IChainFibORMFind;
|
|
136
|
+
}
|
|
137
|
+
/* Orm About Patch :end */
|
|
138
|
+
|
|
139
|
+
/* instance/model computation/transform about :start */
|
|
140
|
+
export interface ModelAutoFetchOptions {
|
|
141
|
+
autoFetchLimit?: number
|
|
142
|
+
autoFetch?: boolean
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface InstanceAutoFetchOptions extends ModelAutoFetchOptions {}
|
|
146
|
+
export interface ModelExtendOptions {}
|
|
147
|
+
export interface InstanceExtendOptions extends ModelExtendOptions {}
|
|
148
|
+
/* instance/model computation/transform about :end */
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Parameter Type Interfaces
|
|
152
|
+
**/
|
|
153
|
+
// just for compatible
|
|
154
|
+
export type FibOrmFixedModel = FxOrmModel.Model
|
|
155
|
+
// patch the missing field defined in orm/lib/Instance.js (such as defined by Object.defineProperty)
|
|
156
|
+
export type FibOrmFixedModelInstance = FxOrmInstance.Instance
|
|
157
|
+
|
|
158
|
+
export interface PluginOptions {
|
|
159
|
+
[key: string]: any
|
|
160
|
+
}
|
|
161
|
+
// export interface PluginConstructor {
|
|
162
|
+
// new (orm?: ORM, opts?: PluginOptions): Plugin
|
|
163
|
+
// prototype: Plugin
|
|
164
|
+
// }
|
|
165
|
+
export type PluginConstructFn<T2 = PluginOptions, T1 extends ORM = ORM> = (orm: T1, opts: T2) => Plugin
|
|
166
|
+
export interface Plugin {
|
|
167
|
+
beforeDefine?: {
|
|
168
|
+
(name?: string, properties?: Record<string, ComplexModelPropertyDefinition>, opts?: FxOrmModel.ModelDefineOptions): void
|
|
169
|
+
}
|
|
170
|
+
define?: {
|
|
171
|
+
(model?: FxOrmModel.Model, orm?: ORM): void
|
|
172
|
+
}
|
|
173
|
+
beforeHasOne?: {
|
|
174
|
+
(
|
|
175
|
+
model?: FxOrmModel.Model,
|
|
176
|
+
opts?: {
|
|
177
|
+
association_name?: string,
|
|
178
|
+
ext_model?: Model,
|
|
179
|
+
assoc_options?: FxOrmAssociation.AssociationDefinitionOptions_HasOne
|
|
180
|
+
}
|
|
181
|
+
): void
|
|
182
|
+
}
|
|
183
|
+
beforeHasMany?: {
|
|
184
|
+
(
|
|
185
|
+
model?: FxOrmModel.Model,
|
|
186
|
+
opts?: {
|
|
187
|
+
association_name?: string,
|
|
188
|
+
ext_model?: Model,
|
|
189
|
+
assoc_props?: Record<string, FxOrmModel.ModelPropertyDefinition>,
|
|
190
|
+
assoc_options?: FxOrmAssociation.AssociationDefinitionOptions_HasMany
|
|
191
|
+
}
|
|
192
|
+
): void
|
|
193
|
+
}
|
|
194
|
+
beforeExtendsTo?: {
|
|
195
|
+
(
|
|
196
|
+
model?: FxOrmModel.Model,
|
|
197
|
+
opts?: {
|
|
198
|
+
association_name?: string,
|
|
199
|
+
properties?: Record<string, FxOrmModel.ModelPropertyDefinition>,
|
|
200
|
+
assoc_options?: FxOrmAssociation.AssociationDefinitionOptions_ExtendsTo
|
|
201
|
+
}
|
|
202
|
+
): void
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @description leave here for augmention on consumer of this package,
|
|
208
|
+
*
|
|
209
|
+
* all models declared here would be considered as memebers of `orm.models`, e.g.
|
|
210
|
+
*
|
|
211
|
+
* ```ts
|
|
212
|
+
* const User = orm.define('user', { ... });
|
|
213
|
+
*
|
|
214
|
+
* declare module '../index' {
|
|
215
|
+
* export namespace FxOrmNS {
|
|
216
|
+
* export GlobalModels {
|
|
217
|
+
* users: typeof User
|
|
218
|
+
* }
|
|
219
|
+
* }
|
|
220
|
+
* }
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
export interface GlobalModels {
|
|
224
|
+
[key: string]: FxOrmModel.Model
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export interface ORMLike extends Class_EventEmitter {
|
|
228
|
+
use: {
|
|
229
|
+
(plugin: PluginConstructFn, options?: PluginOptions): ThisType<ORMLike>;
|
|
230
|
+
}
|
|
231
|
+
define: <
|
|
232
|
+
T extends Record<string, FxOrmModel.ComplexModelPropertyDefinition>,
|
|
233
|
+
U extends FxOrmModel.ModelDefineOptions<FxOrmModel.GetPropertiesType<T>>
|
|
234
|
+
>(
|
|
235
|
+
name: string,
|
|
236
|
+
properties: T,
|
|
237
|
+
opts?: U
|
|
238
|
+
) => FxOrmModel.Model<FxOrmModel.GetPropertiesType<T>, Exclude<U['methods'], void>>;
|
|
239
|
+
sync(callback: FxOrmCommon.VoidCallback): this;
|
|
240
|
+
syncSync(): void;
|
|
241
|
+
load(file: string, callback: FxOrmCommon.VoidCallback): any;
|
|
242
|
+
|
|
243
|
+
driver?: FxOrmDMLDriver.DMLDriver
|
|
244
|
+
models: GlobalModels;
|
|
245
|
+
|
|
246
|
+
[k: string]: any
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface ORM extends ORMLike, FxOrmSynchronous.SynchronizedORMInstance {
|
|
250
|
+
validators: FxOrmValidators.ValidatorModules;
|
|
251
|
+
enforce: FibjsEnforce.ExportModule;
|
|
252
|
+
settings: FxOrmSettings.SettingInstance;
|
|
253
|
+
driver_name: string;
|
|
254
|
+
driver: FxOrmDMLDriver.DMLDriver;
|
|
255
|
+
comparators: FxSqlQueryComparator.ComparatorHash;
|
|
256
|
+
plugins: Plugin[];
|
|
257
|
+
customTypes: { [key: string]: FxOrmProperty.CustomPropertyType };
|
|
258
|
+
|
|
259
|
+
defineType(name: string, type: FxOrmProperty.CustomPropertyType): this;
|
|
260
|
+
|
|
261
|
+
load(file: string, callback: FxOrmCommon.VoidCallback): any;
|
|
262
|
+
|
|
263
|
+
ping(callback: FxOrmCommon.VoidCallback): this;
|
|
264
|
+
close(callback: FxOrmCommon.VoidCallback): this;
|
|
265
|
+
sync(callback: FxOrmCommon.VoidCallback): this;
|
|
266
|
+
drop(callback: FxOrmCommon.VoidCallback): this;
|
|
267
|
+
|
|
268
|
+
begin: FxDbDriverNS.SQLDriver['begin'];
|
|
269
|
+
commit: FxDbDriverNS.SQLDriver['commit'];
|
|
270
|
+
rollback: FxDbDriverNS.SQLDriver['rollback'];
|
|
271
|
+
trans: FxDbDriverNS.SQLDriver['trans'];
|
|
272
|
+
|
|
273
|
+
[extraMember: string]: any;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export interface SingletonOptions {
|
|
277
|
+
identityCache?: boolean | number;
|
|
278
|
+
saveCheck?: boolean;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export interface IUseOptions {
|
|
282
|
+
query?: {
|
|
283
|
+
/**
|
|
284
|
+
* debug key from connection options or connction url's querystring
|
|
285
|
+
* @example query.debug: 'false'
|
|
286
|
+
* @example mysql://127.0.0.1:3306/schema?debug=true
|
|
287
|
+
*/
|
|
288
|
+
debug?: string
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export interface SingletonModule {
|
|
293
|
+
modelClear: {
|
|
294
|
+
(model: FxOrmModel.Model, key?: string): SingletonModule
|
|
295
|
+
}
|
|
296
|
+
clear: {
|
|
297
|
+
(key?: string): SingletonModule
|
|
298
|
+
};
|
|
299
|
+
modelGet: {
|
|
300
|
+
<T = any>(
|
|
301
|
+
model: FxOrmModel.Model,
|
|
302
|
+
key: string,
|
|
303
|
+
opts: SingletonOptions,
|
|
304
|
+
reFetchSync: () => FxOrmInstance.Instance
|
|
305
|
+
): FxOrmInstance.Instance
|
|
306
|
+
};
|
|
307
|
+
get: {
|
|
308
|
+
<T = any>(
|
|
309
|
+
key: string,
|
|
310
|
+
opts: SingletonOptions,
|
|
311
|
+
reFetchSync: () => FxOrmInstance.Instance
|
|
312
|
+
): FxOrmInstance.Instance
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/// <reference types="@fibjs/enforce" />
|
|
2
|
+
|
|
3
|
+
import type { FxOrmCommon } from "./_common";
|
|
4
|
+
import type { FxOrmNS } from "./ORM";
|
|
5
|
+
import type { FxOrmInstance } from "./instance";
|
|
6
|
+
import type { FxOrmModel } from "./model";
|
|
7
|
+
|
|
8
|
+
export namespace FxOrmValidators {
|
|
9
|
+
export interface ValidatorModules {
|
|
10
|
+
required: FibjsEnforce.enforcementValidation
|
|
11
|
+
notEmptyString: FibjsEnforce.enforcementValidation
|
|
12
|
+
rangeNumber: FibjsEnforce.enforcementValidation
|
|
13
|
+
rangeLength: FibjsEnforce.enforcementValidation
|
|
14
|
+
insideList: FibjsEnforce.enforcementValidation
|
|
15
|
+
outsideList: FibjsEnforce.enforcementValidation
|
|
16
|
+
password: FibjsEnforce.enforcementValidation
|
|
17
|
+
|
|
18
|
+
patterns: FibjsEnforce.enforcementsContainer
|
|
19
|
+
|
|
20
|
+
/* extra validators: start */
|
|
21
|
+
equalToProperty(name: string, message?: string): FibjsEnforce.ValidationCallback;
|
|
22
|
+
unique(opts?: { ignoreCase: boolean }, message?: string): FibjsEnforce.ValidationCallback;
|
|
23
|
+
/* extra validators: end */
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface IValidatorHash {
|
|
27
|
+
[validation: string]: FibjsEnforce.IValidator | FibjsEnforce.IValidator[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ValidationCallback<T_THIS = any> extends FibjsEnforce.ValidationCallback {
|
|
31
|
+
(value: any, next: FxOrmCommon.NextCallback, thisArg?: T_THIS, contexts?: ValidatorContext): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ValidatorContext extends FibjsEnforce.ContextMap {
|
|
35
|
+
driver: FxOrmNS.ORM['driver']
|
|
36
|
+
instance: FxOrmInstance.Instance
|
|
37
|
+
model: FxOrmModel.Model
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { FxOrmCoreError } from "../../orm-core/index"
|
|
2
|
+
import type { FxOrmCoreCallbackNS } from "../../orm-core/callback"
|
|
3
|
+
|
|
4
|
+
import type { FxOrmError } from "./Error";
|
|
5
|
+
|
|
6
|
+
export namespace FxOrmCommon {
|
|
7
|
+
export type IdType = string | number
|
|
8
|
+
export type Arraible<T> = T | T[]
|
|
9
|
+
|
|
10
|
+
export type VoidCallback<T_RESULT = any, T_THIS = any> = FxOrmCoreCallbackNS.VoidCallback<T_RESULT, T_THIS>
|
|
11
|
+
|
|
12
|
+
export type ExecutionCallback<T, T_RESULT = any, T_THIS = any> = FxOrmCoreCallbackNS.ExecutionCallback<T, T_RESULT, T_THIS>
|
|
13
|
+
|
|
14
|
+
export type GenericCallback<T, T_RESULT = any, T_THIS = any> = FxOrmCoreCallbackNS.GenericCallback<T, T_RESULT, T_THIS>
|
|
15
|
+
|
|
16
|
+
export interface NextCallback<ERR_T = string, T_RESULT = any, T_THIS = any> {
|
|
17
|
+
(this: T_THIS, err?: ERR_T): T_RESULT
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface SuccessCallback<T> {
|
|
21
|
+
(result?: T): any
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ValidatorCallback {
|
|
25
|
+
(errors: Error[]): void
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type Nilable<T> = null | T
|
|
29
|
+
|
|
30
|
+
export interface ExposedResult<T = any> {
|
|
31
|
+
error: FxOrmError.ExtendedError,
|
|
32
|
+
result?: T
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface SyncCallbackInputArags<T = any> {
|
|
36
|
+
callback?: ExecutionCallback<T>,
|
|
37
|
+
is_sync?: boolean
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ValueWaitor<T = any> {
|
|
41
|
+
evt?: Class_Event,
|
|
42
|
+
value: T
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import type { FxOrmHook } from "./hook"
|
|
2
|
+
import type { FxOrmModel } from "./model"
|
|
3
|
+
import type { FxOrmProperty } from "./property"
|
|
4
|
+
import type { FxOrmCommon } from "./_common"
|
|
5
|
+
import type { FxOrmInstance } from "./instance"
|
|
6
|
+
import type { FxOrmQuery } from "./query"
|
|
7
|
+
|
|
8
|
+
export namespace FxOrmAssociation {
|
|
9
|
+
export type AssociationType = 'extendsTo' | 'hasOne' | 'hasMany'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @type.function: (model_name: string, idkey: string) => string
|
|
13
|
+
*
|
|
14
|
+
* @string.default: `{model_name}_${idkey}`
|
|
15
|
+
*/
|
|
16
|
+
export type AssociationKeyComputation = ((model_name: string, idkey: string) => string) | string
|
|
17
|
+
export interface AssociationDefinitionOptions {
|
|
18
|
+
/**
|
|
19
|
+
* it's also accessor base for `extendsTo`, `hasOne`, `hasMany`,
|
|
20
|
+
*
|
|
21
|
+
* @notice fallback from `acessor` for `hasOne`, `hasMany`
|
|
22
|
+
*/
|
|
23
|
+
name?: string;
|
|
24
|
+
model?: FxOrmModel.Model;
|
|
25
|
+
field?: string/* | string[] */ | Record<string, FxOrmProperty.NormalizedProperty>
|
|
26
|
+
|
|
27
|
+
// is the association is for extendsTo
|
|
28
|
+
__for_extension?: boolean;
|
|
29
|
+
required?: boolean;
|
|
30
|
+
reversed?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* accessor base for `hasOne`, `hasMany`
|
|
33
|
+
*/
|
|
34
|
+
accessor?: string;
|
|
35
|
+
/**
|
|
36
|
+
* accessor base for `hasOne`
|
|
37
|
+
*/
|
|
38
|
+
reverseAccessor?: string;
|
|
39
|
+
autoFetch?: boolean;
|
|
40
|
+
autoFetchLimit?: number;
|
|
41
|
+
|
|
42
|
+
getAccessor?: string;
|
|
43
|
+
setAccessor?: string;
|
|
44
|
+
hasAccessor?: string;
|
|
45
|
+
delAccessor?: string;
|
|
46
|
+
addAccessor?: string;
|
|
47
|
+
|
|
48
|
+
modelFindByAccessor?: string;
|
|
49
|
+
|
|
50
|
+
hooks?: InstanceAssociationItem['hooks']
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface AssociationDefinitionOptions_ExtendsTo extends AssociationDefinitionOptions {
|
|
54
|
+
table?: string;
|
|
55
|
+
|
|
56
|
+
reverse?: string;
|
|
57
|
+
reverseHooks?: InstanceAssociationItem_HasOne['hooks'];
|
|
58
|
+
}
|
|
59
|
+
export interface AssociationDefinitionOptions_HasOne extends AssociationDefinitionOptions {
|
|
60
|
+
reverse?: string;
|
|
61
|
+
reverseHooks?: InstanceAssociationItem_HasOne['hooks'];
|
|
62
|
+
}
|
|
63
|
+
export interface AssociationDefinitionOptions_HasMany extends AssociationDefinitionOptions {
|
|
64
|
+
reverse?: string;
|
|
65
|
+
reverseHooks?: AssociationDefinitionOptions_HasMany['hooks']
|
|
66
|
+
// is association property a primary key
|
|
67
|
+
key?: boolean
|
|
68
|
+
mergeId?: string | Record<string, FxOrmModel.ModelPropertyDefinition>
|
|
69
|
+
mergeAssocId?: string | Record<string, FxOrmModel.ModelPropertyDefinition>
|
|
70
|
+
reverseAssociation?: string
|
|
71
|
+
|
|
72
|
+
hooks?: InstanceAssociationItem['hooks'] & {
|
|
73
|
+
beforeAdd?: FxOrmHook.HookActionWithCtxCallback<FxOrmInstance.Instance, __AssocHooksCtx>
|
|
74
|
+
afterAdd?: FxOrmHook.HookRetOnlyPayloadCallback<FxOrmInstance.Instance, __AssocHooksCtx>
|
|
75
|
+
/** @deprecated */
|
|
76
|
+
beforeSave?: {
|
|
77
|
+
(next?: FxOrmHook.HookActionNextor): void;
|
|
78
|
+
(extra: any, next?: FxOrmHook.HookActionNextor): void;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
mergeTable?: string
|
|
82
|
+
|
|
83
|
+
association?: string
|
|
84
|
+
|
|
85
|
+
getAccessor?: string;
|
|
86
|
+
setAccessor?: string;
|
|
87
|
+
hasAccessor?: string;
|
|
88
|
+
delAccessor?: string;
|
|
89
|
+
addAccessor?: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface InstanceAssociationItemHooks {
|
|
93
|
+
beforeSet?: {
|
|
94
|
+
(func: FxOrmHook.HookActionCallback, opts?: FxOrmHook.HookPatchOptions & Record<string, any>): any
|
|
95
|
+
}
|
|
96
|
+
afterSet?: {
|
|
97
|
+
(func: FxOrmHook.HookResultCallback, opts?: FxOrmHook.HookPatchOptions & Record<string, any>): any
|
|
98
|
+
}
|
|
99
|
+
beforeRemove?: {
|
|
100
|
+
(func: FxOrmHook.HookActionCallback, opts?: FxOrmHook.HookPatchOptions & Record<string, any>): any
|
|
101
|
+
}
|
|
102
|
+
afterRemove?: {
|
|
103
|
+
(func: FxOrmHook.HookResultCallback, opts?: FxOrmHook.HookPatchOptions & Record<string, any>): any
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
beforeAdd?: {
|
|
107
|
+
(func: FxOrmHook.HookActionCallback, opts?: FxOrmHook.HookPatchOptions & Record<string, any>): any
|
|
108
|
+
}
|
|
109
|
+
afterAdd?: {
|
|
110
|
+
(func: FxOrmHook.HookResultCallback, opts?: FxOrmHook.HookPatchOptions & Record<string, any>): any
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** @internal */
|
|
115
|
+
export type __AssocHooksCtx = {
|
|
116
|
+
instance?: FxOrmInstance.Instance
|
|
117
|
+
association?: FxOrmInstance.Instance
|
|
118
|
+
associations?: (FxOrmInstance.Instance)[]
|
|
119
|
+
association_ids?: any[]
|
|
120
|
+
removeConditions?: Record<string, any>
|
|
121
|
+
useChannel?: () => FxOrmHook.HookChannelResults<Function>
|
|
122
|
+
$ref?: {
|
|
123
|
+
instance?: __AssocHooksCtx['instance']
|
|
124
|
+
association?: __AssocHooksCtx['association']
|
|
125
|
+
associations?: __AssocHooksCtx['associations']
|
|
126
|
+
association_ids?: __AssocHooksCtx['association_ids']
|
|
127
|
+
removeConditions?: __AssocHooksCtx['removeConditions']
|
|
128
|
+
useChannel?: __AssocHooksCtx['useChannel']
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface InstanceAssociationItem extends InstanceAssociationItemHooks {
|
|
133
|
+
name: string
|
|
134
|
+
model: FxOrmModel.Model
|
|
135
|
+
field: string /* | string[] */ | Record<string, FxOrmProperty.NormalizedProperty>
|
|
136
|
+
hooks: {
|
|
137
|
+
beforeSet?: FxOrmCommon.Arraible<FxOrmHook.HookActionWithCtxCallback<FxOrmInstance.Instance, __AssocHooksCtx>>
|
|
138
|
+
afterSet?: FxOrmCommon.Arraible<FxOrmHook.HookRetOnlyPayloadCallback<FxOrmInstance.Instance, __AssocHooksCtx>>
|
|
139
|
+
beforeRemove?: FxOrmCommon.Arraible<FxOrmHook.HookActionWithCtxCallback<FxOrmInstance.Instance, __AssocHooksCtx>>
|
|
140
|
+
afterRemove?: FxOrmCommon.Arraible<FxOrmHook.HookRetOnlyPayloadCallback<FxOrmInstance.Instance, __AssocHooksCtx>>
|
|
141
|
+
|
|
142
|
+
[k: string]: any
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// is the association is extendsTo
|
|
146
|
+
__for_extension?: boolean
|
|
147
|
+
|
|
148
|
+
getAccessor: string
|
|
149
|
+
getSyncAccessor: string
|
|
150
|
+
setAccessor: string
|
|
151
|
+
setSyncAccessor: string
|
|
152
|
+
hasAccessor: string
|
|
153
|
+
hasSyncAccessor: string
|
|
154
|
+
delAccessor: string
|
|
155
|
+
delSyncAccessor: string
|
|
156
|
+
|
|
157
|
+
addAccessor?: string
|
|
158
|
+
addSyncAccessor?: string
|
|
159
|
+
|
|
160
|
+
modelFindByAccessor?: string
|
|
161
|
+
modelFindBySyncAccessor?: string
|
|
162
|
+
|
|
163
|
+
// if the association is reversed association from other,
|
|
164
|
+
// such as `hasOne` from host's `extendsTo`, or `hasMany` from host's `hasMany`
|
|
165
|
+
reversed?: boolean
|
|
166
|
+
autoFetch: boolean
|
|
167
|
+
autoFetchLimit: number
|
|
168
|
+
|
|
169
|
+
mapsTo?: FxOrmModel.ModelPropertyDefinition['mapsTo']
|
|
170
|
+
|
|
171
|
+
// *Accessor functions
|
|
172
|
+
[k: string]: any
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export type InstanceAssociatedInstance = FxOrmInstance.Instance;
|
|
176
|
+
|
|
177
|
+
export interface InstanceAssociationItem_ExtendTos extends InstanceAssociationItem {
|
|
178
|
+
table: string;
|
|
179
|
+
reverse?: string;
|
|
180
|
+
modelFindByAccessor: string
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface InstanceAssociationItem_HasOne extends InstanceAssociationItem {
|
|
184
|
+
field: Record<string, FxOrmProperty.NormalizedProperty>
|
|
185
|
+
|
|
186
|
+
reverse?: string;
|
|
187
|
+
reverseHooks?: InstanceAssociationItem_HasOne['hooks'];
|
|
188
|
+
// template name
|
|
189
|
+
accessor?: string;
|
|
190
|
+
reverseAccessor?: string;
|
|
191
|
+
|
|
192
|
+
// addAccessor?: string;
|
|
193
|
+
|
|
194
|
+
modelFindByAccessor: string
|
|
195
|
+
|
|
196
|
+
required?: boolean;
|
|
197
|
+
__for_extension?: boolean;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* @description information collected from code like:
|
|
202
|
+
*
|
|
203
|
+
* ```js
|
|
204
|
+
* Host.hasMany(Other, {
|
|
205
|
+
* mergeTable: 'merge_table',
|
|
206
|
+
* mergeId: ['host_id'], // optional,
|
|
207
|
+
* mergeAssocId: ['other_id']
|
|
208
|
+
* })
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
export interface InstanceAssociationItem_HasMany extends InstanceAssociationItem {
|
|
212
|
+
props: Record<string, FxOrmProperty.NormalizedProperty>
|
|
213
|
+
// hooks: HasManyHooks
|
|
214
|
+
|
|
215
|
+
mergeTable: string
|
|
216
|
+
/**
|
|
217
|
+
* @description associated properties linked to Host on merge table
|
|
218
|
+
*/
|
|
219
|
+
mergeId: Record<string, FxOrmProperty.NormalizedProperty>
|
|
220
|
+
/**
|
|
221
|
+
* @description associated properties linked to Other on merge table
|
|
222
|
+
*/
|
|
223
|
+
mergeAssocId: Record<string, FxOrmProperty.NormalizedProperty>
|
|
224
|
+
|
|
225
|
+
getAccessor: string
|
|
226
|
+
setAccessor: string
|
|
227
|
+
hasAccessor: string
|
|
228
|
+
delAccessor: string
|
|
229
|
+
addAccessor: string
|
|
230
|
+
|
|
231
|
+
modelFindByAccessor?: string
|
|
232
|
+
|
|
233
|
+
hooks: InstanceAssociationItem['hooks'] & {
|
|
234
|
+
beforeAdd?: FxOrmHook.HookActionWithCtxCallback<FxOrmInstance.Instance, __AssocHooksCtx>
|
|
235
|
+
afterAdd?: FxOrmHook.HookRetOnlyPayloadCallback<FxOrmInstance.Instance, __AssocHooksCtx>
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export interface InstanceAssociationItemInformation {
|
|
240
|
+
changed: boolean
|
|
241
|
+
value?: InstanceAssociatedInstance
|
|
242
|
+
data?: InstanceAssociationItem
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface ModelAssociationMethod__Options {
|
|
246
|
+
// only valid for hasMany assoc :start
|
|
247
|
+
/** @deprecated use `extra_where` directly */
|
|
248
|
+
join_where?: FxOrmModel.ModelQueryConditions__Find
|
|
249
|
+
/** @internal */
|
|
250
|
+
extra?: FxOrmModel.ModelOptions__Find['extra']
|
|
251
|
+
/** @internal */
|
|
252
|
+
extra_info?: {
|
|
253
|
+
table: string
|
|
254
|
+
id: FxOrmModel.Model['id']
|
|
255
|
+
id_prop: string[]
|
|
256
|
+
assoc_prop: string[]
|
|
257
|
+
}
|
|
258
|
+
// only valid for hasMany assoc :start
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export interface ModelAssociationMethod__FindOptions extends FxOrmModel.ModelOptions__Find, ModelAssociationMethod__Options {
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export interface ModelAssociationMethod__GetOptions extends FxOrmModel.ModelOptions__Find, ModelAssociationMethod__Options {
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export interface ModelAssociationMethod__FindByOptions extends FxOrmModel.ModelOptions__Findby, ModelAssociationMethod__Options {
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface AccessorOptions_has {
|
|
271
|
+
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export type AccessorOptions_get = FxOrmCommon.IdType | FxOrmModel.ModelQueryConditions__Find
|
|
275
|
+
|
|
276
|
+
export interface AutoFetchInstanceOptions {
|
|
277
|
+
autoFetch?: boolean
|
|
278
|
+
autoFetchLimit?: number
|
|
279
|
+
}
|
|
280
|
+
}
|