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
package/lib/orm/ORM.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import events = require("events");
|
|
2
|
-
import type { FxOrmNS } from "./Typo/ORM";
|
|
3
|
-
import type { FxOrmCommon } from "./Typo/_common";
|
|
4
|
-
import type { FxOrmDMLDriver } from "./Typo/DMLDriver";
|
|
5
|
-
import type { FxOrmCoreCallbackNS } from "../orm-core/index";
|
|
6
|
-
import type { FxOrmSettings } from "./Typo/settings";
|
|
7
|
-
export declare class ORM extends events.EventEmitter implements FxOrmNS.ORM {
|
|
8
|
-
validators: FxOrmNS.ORM['validators'];
|
|
9
|
-
enforce: FxOrmNS.ORM['enforce'];
|
|
10
|
-
settings: FxOrmNS.ORM['settings'];
|
|
11
|
-
driver_name: FxOrmNS.ORM['driver_name'];
|
|
12
|
-
driver: FxOrmNS.ORM['driver'];
|
|
13
|
-
comparators: FxOrmNS.ORM['comparators'];
|
|
14
|
-
models: FxOrmNS.ORM['models'];
|
|
15
|
-
plugins: FxOrmNS.ORM['plugins'];
|
|
16
|
-
customTypes: FxOrmNS.ORM['customTypes'];
|
|
17
|
-
constructor(driver_name: string, driver: FxOrmDMLDriver.DMLDriver, settings: FxOrmSettings.SettingInstance);
|
|
18
|
-
use(...[plugin_const, opts]: Parameters<FxOrmNS.ORM['use']>): this;
|
|
19
|
-
define(...[name, properties, opts]: Parameters<FxOrmNS.ORM['define']>): any;
|
|
20
|
-
defineType(...[name, opts]: Parameters<FxOrmNS.ORM['defineType']>): this;
|
|
21
|
-
pingSync(): void;
|
|
22
|
-
ping(...[cb]: Parameters<FxOrmNS.ORM['ping']>): this;
|
|
23
|
-
closeSync(): void;
|
|
24
|
-
close(...[cb]: Parameters<FxOrmNS.ORM['close']>): this;
|
|
25
|
-
load(): any;
|
|
26
|
-
syncSync(): void;
|
|
27
|
-
sync(...[cb]: Parameters<FxOrmNS.ORM['sync']>): this;
|
|
28
|
-
dropSync(): void;
|
|
29
|
-
drop(...[cb]: Parameters<FxOrmNS.ORM['drop']>): this;
|
|
30
|
-
queryParamCastserial(...chains: any[]): {
|
|
31
|
-
get: (cb: FxOrmCommon.GenericCallback<any[]>) => any;
|
|
32
|
-
};
|
|
33
|
-
begin(): void;
|
|
34
|
-
commit(): void;
|
|
35
|
-
rollback(): void;
|
|
36
|
-
trans<T>(func: FxOrmCoreCallbackNS.ExecutionCallback<T>): boolean;
|
|
37
|
-
}
|
package/lib/orm/ORM.js
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.ORM = void 0;
|
|
3
|
-
const util = require("util");
|
|
4
|
-
const events = require("events");
|
|
5
|
-
const uuid = require("uuid");
|
|
6
|
-
const SqlQuery = require("../sql-query/Query");
|
|
7
|
-
const plugin_1 = require("./Patch/plugin");
|
|
8
|
-
const Model_1 = require("./Model");
|
|
9
|
-
const Error_1 = require("./Error");
|
|
10
|
-
const Utilities = require("./Utilities");
|
|
11
|
-
const Enforces = require("@fibjs/enforce");
|
|
12
|
-
const validators = require("./Validators");
|
|
13
|
-
const Settings = require("./Settings");
|
|
14
|
-
class ORM extends events.EventEmitter {
|
|
15
|
-
constructor(driver_name, driver, settings) {
|
|
16
|
-
super();
|
|
17
|
-
this.validators = validators;
|
|
18
|
-
this.enforce = Enforces;
|
|
19
|
-
this.settings = settings;
|
|
20
|
-
this.driver_name = driver_name;
|
|
21
|
-
this.driver = driver;
|
|
22
|
-
this.driver.uid = uuid.node().hex();
|
|
23
|
-
this.comparators = Object.assign({}, SqlQuery.comparators);
|
|
24
|
-
this.models = {};
|
|
25
|
-
this.plugins = [];
|
|
26
|
-
this.customTypes = {};
|
|
27
|
-
events.EventEmitter.call(this);
|
|
28
|
-
var onError = (err) => {
|
|
29
|
-
if (this.settings.get("connection.reconnect")) {
|
|
30
|
-
if (typeof this.driver.reconnect === "undefined") {
|
|
31
|
-
return this.emit("error", new Error_1.default("Connection lost - driver does not support reconnection", 'CONNECTION_LOST'));
|
|
32
|
-
}
|
|
33
|
-
this.driver.reconnect(() => {
|
|
34
|
-
this.driver.on("error", onError);
|
|
35
|
-
});
|
|
36
|
-
if (this.listeners("error").length === 0) {
|
|
37
|
-
// since user want auto reconnect,
|
|
38
|
-
// don't emit without listeners or it will throw
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
this.emit("error", err);
|
|
43
|
-
};
|
|
44
|
-
driver.on("error", onError);
|
|
45
|
-
this.use(plugin_1.default);
|
|
46
|
-
}
|
|
47
|
-
use(...[plugin_const, opts]) {
|
|
48
|
-
if (typeof plugin_const === "string") {
|
|
49
|
-
try {
|
|
50
|
-
plugin_const = require(Utilities.getRealPath(plugin_const));
|
|
51
|
-
}
|
|
52
|
-
catch (e) {
|
|
53
|
-
throw e;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
var plugin = plugin_const(this, opts || {});
|
|
57
|
-
if (typeof plugin.define === "function") {
|
|
58
|
-
for (let k in this.models) {
|
|
59
|
-
plugin.define(this.models[k], this);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
this.plugins.push(plugin);
|
|
63
|
-
return this;
|
|
64
|
-
}
|
|
65
|
-
;
|
|
66
|
-
define(...[name, properties, opts]) {
|
|
67
|
-
properties = properties || {};
|
|
68
|
-
opts = opts || {};
|
|
69
|
-
for (let i = 0; i < this.plugins.length; i++) {
|
|
70
|
-
// TODO: only pass normalized properties to beforeDefine
|
|
71
|
-
if (typeof this.plugins[i].beforeDefine === "function") {
|
|
72
|
-
this.plugins[i].beforeDefine(name, properties, opts);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const m_settings = opts.useSelfSettings ? Settings.Container(this.settings.get('*')) : this.settings;
|
|
76
|
-
const virtualView = Utilities.normalizeVirtualViewOption(opts.virtualView, this.driver.knex);
|
|
77
|
-
const modelTable = opts.table || opts.collection || ((m_settings.get("model.namePrefix") || "") + name);
|
|
78
|
-
const generateSqlSelect = Utilities.__wrapTableSourceAsGneratingSqlSelect({
|
|
79
|
-
virtualView,
|
|
80
|
-
customSelect: opts.customSelect,
|
|
81
|
-
generateSqlSelect: opts.generateSqlSelect,
|
|
82
|
-
}, {
|
|
83
|
-
dialect: this.driver.query.Dialect,
|
|
84
|
-
modelTable,
|
|
85
|
-
});
|
|
86
|
-
this.models[name] = new Model_1.Model({
|
|
87
|
-
name: name,
|
|
88
|
-
db: this,
|
|
89
|
-
settings: m_settings,
|
|
90
|
-
driver_name: this.driver_name,
|
|
91
|
-
driver: this.driver,
|
|
92
|
-
table: opts.table || opts.collection || ((m_settings.get("model.namePrefix") || "") + name),
|
|
93
|
-
tableComment: opts.tableComment || '',
|
|
94
|
-
virtualView: virtualView,
|
|
95
|
-
generateSqlSelect,
|
|
96
|
-
// not standard Record<string, FxOrmProperty.NormalizedProperty> here, but we should pass it firstly
|
|
97
|
-
properties: properties,
|
|
98
|
-
__for_extension: opts.__for_extension || false,
|
|
99
|
-
indexes: opts.indexes || [],
|
|
100
|
-
identityCache: opts.hasOwnProperty("identityCache") ? opts.identityCache : m_settings.get("instance.identityCache"),
|
|
101
|
-
keys: opts.id,
|
|
102
|
-
autoSave: opts.hasOwnProperty("autoSave") ? opts.autoSave : m_settings.get("instance.autoSave"),
|
|
103
|
-
autoFetch: opts.hasOwnProperty("autoFetch") ? opts.autoFetch : m_settings.get("instance.autoFetch"),
|
|
104
|
-
autoFetchLimit: opts.autoFetchLimit || m_settings.get("instance.autoFetchLimit"),
|
|
105
|
-
cascadeRemove: opts.hasOwnProperty("cascadeRemove") ? opts.cascadeRemove : m_settings.get("instance.cascadeRemove"),
|
|
106
|
-
hooks: opts.hooks || {},
|
|
107
|
-
methods: opts.methods || {},
|
|
108
|
-
validations: opts.validations || {},
|
|
109
|
-
ievents: opts.ievents || {},
|
|
110
|
-
instanceCacheSize: opts.hasOwnProperty("instanceCacheSize") ? opts.instanceCacheSize : m_settings.get("instance.cacheSize"),
|
|
111
|
-
});
|
|
112
|
-
for (let i = 0; i < this.plugins.length; i++) {
|
|
113
|
-
if (typeof this.plugins[i].define === "function") {
|
|
114
|
-
this.plugins[i].define(this.models[name], this);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return this.models[name];
|
|
118
|
-
}
|
|
119
|
-
;
|
|
120
|
-
defineType(...[name, opts]) {
|
|
121
|
-
this.customTypes[name] = opts;
|
|
122
|
-
this.driver.customTypes[name] = opts;
|
|
123
|
-
return this;
|
|
124
|
-
}
|
|
125
|
-
;
|
|
126
|
-
pingSync() {
|
|
127
|
-
this.driver.ping();
|
|
128
|
-
}
|
|
129
|
-
;
|
|
130
|
-
ping(...[cb]) {
|
|
131
|
-
this.driver.ping(cb);
|
|
132
|
-
return this;
|
|
133
|
-
}
|
|
134
|
-
;
|
|
135
|
-
closeSync() {
|
|
136
|
-
this.driver.close();
|
|
137
|
-
}
|
|
138
|
-
close(...[cb]) {
|
|
139
|
-
const syncResponse = Utilities.catchBlocking(this.closeSync, [], { thisArg: this });
|
|
140
|
-
Utilities.takeAwayResult(syncResponse, { callback: cb });
|
|
141
|
-
return this;
|
|
142
|
-
}
|
|
143
|
-
;
|
|
144
|
-
load() {
|
|
145
|
-
var files = util.flatten(Array.prototype.slice.apply(arguments));
|
|
146
|
-
var cb = function (err) { };
|
|
147
|
-
if (typeof files[files.length - 1] == "function") {
|
|
148
|
-
cb = files.pop();
|
|
149
|
-
}
|
|
150
|
-
var loadNext = function () {
|
|
151
|
-
if (files.length === 0) {
|
|
152
|
-
return cb(null);
|
|
153
|
-
}
|
|
154
|
-
var file = files.shift();
|
|
155
|
-
try {
|
|
156
|
-
return require(Utilities.getRealPath(file, 4))(this, function (err) {
|
|
157
|
-
if (err)
|
|
158
|
-
return cb(err);
|
|
159
|
-
return loadNext();
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
catch (ex) {
|
|
163
|
-
return cb(ex);
|
|
164
|
-
}
|
|
165
|
-
}.bind(this);
|
|
166
|
-
return loadNext();
|
|
167
|
-
}
|
|
168
|
-
;
|
|
169
|
-
syncSync() {
|
|
170
|
-
var modelIds = Object.keys(this.models);
|
|
171
|
-
if (modelIds.length === 0)
|
|
172
|
-
return;
|
|
173
|
-
modelIds.forEach(modelId => {
|
|
174
|
-
this.models[modelId].syncSync();
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
;
|
|
178
|
-
sync(...[cb]) {
|
|
179
|
-
const syncResponse = Utilities.catchBlocking(this.syncSync, [], { thisArg: this });
|
|
180
|
-
Utilities.takeAwayResult(syncResponse, { no_throw: !!cb, callback: cb });
|
|
181
|
-
return this;
|
|
182
|
-
}
|
|
183
|
-
;
|
|
184
|
-
dropSync() {
|
|
185
|
-
var modelIds = Object.keys(this.models);
|
|
186
|
-
if (modelIds.length === 0)
|
|
187
|
-
return;
|
|
188
|
-
modelIds.forEach(modelId => {
|
|
189
|
-
this.models[modelId].dropSync();
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
;
|
|
193
|
-
drop(...[cb]) {
|
|
194
|
-
const syncResponse = Utilities.catchBlocking(this.dropSync, [], { thisArg: this });
|
|
195
|
-
Utilities.takeAwayResult(syncResponse, { no_throw: !!cb, callback: cb });
|
|
196
|
-
return this;
|
|
197
|
-
}
|
|
198
|
-
;
|
|
199
|
-
queryParamCastserial(...chains) {
|
|
200
|
-
return {
|
|
201
|
-
get: function (cb) {
|
|
202
|
-
var params = [];
|
|
203
|
-
var getNext = function () {
|
|
204
|
-
if (params.length === chains.length) {
|
|
205
|
-
params.unshift(null);
|
|
206
|
-
return cb.apply(null, params);
|
|
207
|
-
}
|
|
208
|
-
chains[params.length].run(function (err, instances) {
|
|
209
|
-
if (err) {
|
|
210
|
-
params.unshift(err);
|
|
211
|
-
return cb.apply(null, params);
|
|
212
|
-
}
|
|
213
|
-
params.push(instances);
|
|
214
|
-
return getNext();
|
|
215
|
-
});
|
|
216
|
-
};
|
|
217
|
-
getNext();
|
|
218
|
-
return this;
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
;
|
|
223
|
-
begin() {
|
|
224
|
-
return this.driver.db.connection.begin();
|
|
225
|
-
}
|
|
226
|
-
;
|
|
227
|
-
commit() {
|
|
228
|
-
return this.driver.db.connection.commit();
|
|
229
|
-
}
|
|
230
|
-
;
|
|
231
|
-
rollback() {
|
|
232
|
-
return this.driver.db.connection.rollback();
|
|
233
|
-
}
|
|
234
|
-
;
|
|
235
|
-
trans(func) {
|
|
236
|
-
const connection = this.driver.db.connection;
|
|
237
|
-
return connection.trans(func.bind(connection));
|
|
238
|
-
}
|
|
239
|
-
;
|
|
240
|
-
}
|
|
241
|
-
exports.ORM = ORM;
|
package/lib/orm/Patch/plugin.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
function default_1(orm, plugin_opts) {
|
|
3
|
-
function beforeDefine(name, properties, opts) {
|
|
4
|
-
opts.hooks = opts.hooks || {};
|
|
5
|
-
}
|
|
6
|
-
function define(m) {
|
|
7
|
-
}
|
|
8
|
-
return {
|
|
9
|
-
beforeDefine,
|
|
10
|
-
define
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
exports.default = default_1;
|
package/lib/orm/Property.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { FxOrmModel } from './Typo/model';
|
|
2
|
-
import { FxOrmNS } from './Typo/ORM';
|
|
3
|
-
import { FxOrmProperty } from './Typo/property';
|
|
4
|
-
export declare function normalize(opts: {
|
|
5
|
-
prop: FxOrmModel.ComplexModelPropertyDefinition;
|
|
6
|
-
name: string;
|
|
7
|
-
customTypes: FxOrmNS.ORM['customTypes'];
|
|
8
|
-
settings: FxOrmNS.ORM['settings'];
|
|
9
|
-
}): FxOrmProperty.NormalizedProperty;
|
package/lib/orm/Property.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.normalize = void 0;
|
|
3
|
-
const _cloneDeep = require("lodash.clonedeep");
|
|
4
|
-
const Error_1 = require("./Error");
|
|
5
|
-
const KNOWN_TYPES = [
|
|
6
|
-
"text", "number", "integer", "boolean", "date", "enum", "object",
|
|
7
|
-
"binary", "point", "serial"
|
|
8
|
-
];
|
|
9
|
-
function normalize(opts) {
|
|
10
|
-
const orig_prop = opts.prop;
|
|
11
|
-
let result_prop = orig_prop;
|
|
12
|
-
if (typeof opts.prop === "function") {
|
|
13
|
-
const primitiveProp = opts.prop;
|
|
14
|
-
switch (primitiveProp.name) {
|
|
15
|
-
case "String":
|
|
16
|
-
result_prop = { type: "text" };
|
|
17
|
-
break;
|
|
18
|
-
case "Number":
|
|
19
|
-
result_prop = { type: "number" };
|
|
20
|
-
break;
|
|
21
|
-
case "Boolean":
|
|
22
|
-
result_prop = { type: "boolean" };
|
|
23
|
-
break;
|
|
24
|
-
case "Date":
|
|
25
|
-
result_prop = { type: "date" };
|
|
26
|
-
break;
|
|
27
|
-
case "Object":
|
|
28
|
-
result_prop = { type: "object" };
|
|
29
|
-
break;
|
|
30
|
-
case "Buffer":
|
|
31
|
-
result_prop = { type: "binary" };
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
else if (typeof opts.prop === "string") {
|
|
36
|
-
result_prop = {
|
|
37
|
-
type: opts.prop
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
else if (Array.isArray(opts.prop)) {
|
|
41
|
-
result_prop = { type: "enum", values: opts.prop };
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
result_prop = _cloneDeep(orig_prop);
|
|
45
|
-
}
|
|
46
|
-
if (!KNOWN_TYPES.includes(result_prop.type) && !(result_prop.type in opts.customTypes)) {
|
|
47
|
-
throw new Error_1.default("Unknown property type: " + result_prop.type, 'NO_SUPPORT');
|
|
48
|
-
}
|
|
49
|
-
if (!result_prop.hasOwnProperty("required") && opts.settings.get("properties.required")) {
|
|
50
|
-
result_prop.required = true;
|
|
51
|
-
}
|
|
52
|
-
// Defaults to true. Setting to false hides properties from JSON.stringify(modelInstance).
|
|
53
|
-
if (!result_prop.hasOwnProperty("enumerable") || result_prop.enumerable === true) {
|
|
54
|
-
result_prop.enumerable = true;
|
|
55
|
-
}
|
|
56
|
-
// Defaults to true. Rational means floating point here.
|
|
57
|
-
if (result_prop.type == "number" && result_prop.rational === undefined) {
|
|
58
|
-
result_prop.rational = true;
|
|
59
|
-
}
|
|
60
|
-
if (!('mapsTo' in result_prop)) {
|
|
61
|
-
result_prop.mapsTo = opts.name;
|
|
62
|
-
}
|
|
63
|
-
if (result_prop.type == "number" && result_prop.rational === false) {
|
|
64
|
-
result_prop.type = "integer";
|
|
65
|
-
delete result_prop.rational;
|
|
66
|
-
}
|
|
67
|
-
result_prop.name = opts.name;
|
|
68
|
-
return result_prop;
|
|
69
|
-
}
|
|
70
|
-
exports.normalize = normalize;
|
|
71
|
-
;
|
package/lib/orm/Settings.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { FxOrmSettings } from './Typo/settings';
|
|
2
|
-
export declare const defaults: () => {
|
|
3
|
-
model: {
|
|
4
|
-
namePrefix: string;
|
|
5
|
-
repair_column: boolean;
|
|
6
|
-
/**
|
|
7
|
-
* @dangerous
|
|
8
|
-
*/
|
|
9
|
-
allow_drop_column: boolean;
|
|
10
|
-
};
|
|
11
|
-
properties: {
|
|
12
|
-
primary_key: string;
|
|
13
|
-
association_key: string;
|
|
14
|
-
required: boolean;
|
|
15
|
-
};
|
|
16
|
-
instance: {
|
|
17
|
-
defaultFindLimit: number;
|
|
18
|
-
defaultCacheSize: number;
|
|
19
|
-
identityCache: boolean;
|
|
20
|
-
identityCacheSaveCheck: boolean;
|
|
21
|
-
autoSave: boolean;
|
|
22
|
-
autoFetch: boolean;
|
|
23
|
-
autoFetchLimit: number;
|
|
24
|
-
cascadeRemove: boolean;
|
|
25
|
-
returnAllErrors: boolean;
|
|
26
|
-
saveAssociationsByDefault: boolean;
|
|
27
|
-
};
|
|
28
|
-
hasOne: {};
|
|
29
|
-
hasMany: {
|
|
30
|
-
key: boolean;
|
|
31
|
-
};
|
|
32
|
-
extendsTo: {
|
|
33
|
-
throwWhenNotFound: boolean;
|
|
34
|
-
};
|
|
35
|
-
connection: {
|
|
36
|
-
reconnect: boolean;
|
|
37
|
-
pool: boolean;
|
|
38
|
-
debug: boolean;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
export declare function Container(settings: object): FxOrmSettings.SettingInstance;
|
|
42
|
-
export declare const defaultSettingsInstance: FxOrmSettings.SettingInstance;
|
package/lib/orm/Settings.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.defaultSettingsInstance = exports.Container = exports.defaults = void 0;
|
|
3
|
-
const _cloneDeep = require("lodash.clonedeep");
|
|
4
|
-
const default_settings = {
|
|
5
|
-
model: {
|
|
6
|
-
namePrefix: '',
|
|
7
|
-
// TODO: add test about it
|
|
8
|
-
repair_column: false,
|
|
9
|
-
/**
|
|
10
|
-
* @dangerous
|
|
11
|
-
*/
|
|
12
|
-
allow_drop_column: false,
|
|
13
|
-
},
|
|
14
|
-
properties: {
|
|
15
|
-
primary_key: "id",
|
|
16
|
-
association_key: "{name}_{field}",
|
|
17
|
-
required: false
|
|
18
|
-
},
|
|
19
|
-
instance: {
|
|
20
|
-
defaultFindLimit: 1000,
|
|
21
|
-
defaultCacheSize: 1000,
|
|
22
|
-
identityCache: false,
|
|
23
|
-
identityCacheSaveCheck: true,
|
|
24
|
-
autoSave: false,
|
|
25
|
-
autoFetch: false,
|
|
26
|
-
autoFetchLimit: 1,
|
|
27
|
-
cascadeRemove: true,
|
|
28
|
-
returnAllErrors: false,
|
|
29
|
-
saveAssociationsByDefault: true
|
|
30
|
-
},
|
|
31
|
-
hasOne: {
|
|
32
|
-
// allowRemoveReverse : false,
|
|
33
|
-
},
|
|
34
|
-
hasMany: {
|
|
35
|
-
// Makes the foreign key fields a composite key
|
|
36
|
-
key: false
|
|
37
|
-
},
|
|
38
|
-
extendsTo: {
|
|
39
|
-
// would default as false in the future
|
|
40
|
-
throwWhenNotFound: true,
|
|
41
|
-
},
|
|
42
|
-
connection: {
|
|
43
|
-
reconnect: true,
|
|
44
|
-
pool: false,
|
|
45
|
-
debug: false
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
const defaults = function () {
|
|
49
|
-
return default_settings;
|
|
50
|
-
};
|
|
51
|
-
exports.defaults = defaults;
|
|
52
|
-
function Container(settings) {
|
|
53
|
-
return {
|
|
54
|
-
set: function (key, value) {
|
|
55
|
-
set(key, value, settings);
|
|
56
|
-
return this;
|
|
57
|
-
},
|
|
58
|
-
get: function (key, def) {
|
|
59
|
-
const v = get(key, def, settings);
|
|
60
|
-
if (v instanceof Function) {
|
|
61
|
-
return v;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
return _cloneDeep(v);
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
unset: function () {
|
|
68
|
-
for (let i = 0; i < arguments.length; i++) {
|
|
69
|
-
if (typeof arguments[i] === "string") {
|
|
70
|
-
unset(arguments[i], settings);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return this;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
exports.Container = Container;
|
|
78
|
-
function set(key, value, obj) {
|
|
79
|
-
const p = key.indexOf(".");
|
|
80
|
-
if (p === -1) {
|
|
81
|
-
return obj[key] = value;
|
|
82
|
-
}
|
|
83
|
-
if (!obj.hasOwnProperty(key.substr(0, p))) {
|
|
84
|
-
obj[key.substr(0, p)] = {};
|
|
85
|
-
}
|
|
86
|
-
return set(key.substr(p + 1), value, obj[key.substr(0, p)]);
|
|
87
|
-
}
|
|
88
|
-
function get(key, def, obj) {
|
|
89
|
-
const p = key.indexOf(".");
|
|
90
|
-
if (p === -1) {
|
|
91
|
-
if (key === '*') {
|
|
92
|
-
return obj;
|
|
93
|
-
}
|
|
94
|
-
return obj.hasOwnProperty(key) ? obj[key] : def;
|
|
95
|
-
}
|
|
96
|
-
if (!obj.hasOwnProperty(key.substr(0, p))) {
|
|
97
|
-
return def;
|
|
98
|
-
}
|
|
99
|
-
return get(key.substr(p + 1), def, obj[key.substr(0, p)]);
|
|
100
|
-
}
|
|
101
|
-
function unset(key, obj) {
|
|
102
|
-
const p = key.indexOf(".");
|
|
103
|
-
if (p === -1) {
|
|
104
|
-
if (key === '*') {
|
|
105
|
-
return 'reset';
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
delete obj[key];
|
|
109
|
-
}
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
if (!obj.hasOwnProperty(key.substr(0, p))) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
if (unset(key.substr(p + 1), obj[key.substr(0, p)]) === 'reset') {
|
|
116
|
-
obj[key.substr(0, p)] = {};
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
exports.defaultSettingsInstance = Container((0, exports.defaults)());
|
package/lib/orm/Singleton.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { FxOrmNS } from "./Typo/ORM";
|
|
2
|
-
export declare const clear: FxOrmNS.SingletonModule['clear'];
|
|
3
|
-
export declare const modelClear: FxOrmNS.SingletonModule['modelClear'];
|
|
4
|
-
export declare const get: FxOrmNS.SingletonModule['get'];
|
|
5
|
-
export declare const modelGet: FxOrmNS.SingletonModule['modelGet'];
|
package/lib/orm/Singleton.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.modelGet = exports.get = exports.modelClear = exports.clear = void 0;
|
|
3
|
-
const Helpers = require("./Helpers");
|
|
4
|
-
const coroutine = require("coroutine");
|
|
5
|
-
/**
|
|
6
|
-
* refactor this module with LRUCache
|
|
7
|
-
*/
|
|
8
|
-
const models = {};
|
|
9
|
-
const clear = function (key) {
|
|
10
|
-
let driver_table_uid2 = '';
|
|
11
|
-
if (key && typeof key === 'string')
|
|
12
|
-
driver_table_uid2 = Helpers.parseDriverUidAndTableNameFromUID(key).driver_table_uid;
|
|
13
|
-
Object.values(models).forEach(model => {
|
|
14
|
-
const { driver_table_uid: driver_table_uid1 } = Helpers.parseDriverUidAndTableNameFromUID(model.uid);
|
|
15
|
-
if (driver_table_uid2 && driver_table_uid2 !== driver_table_uid1)
|
|
16
|
-
return;
|
|
17
|
-
(0, exports.modelClear)(model, key);
|
|
18
|
-
});
|
|
19
|
-
return this;
|
|
20
|
-
};
|
|
21
|
-
exports.clear = clear;
|
|
22
|
-
const modelClear = function (model, key) {
|
|
23
|
-
if (key && typeof key === "string") {
|
|
24
|
-
model.caches.delete(key);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
model.caches.clear();
|
|
28
|
-
}
|
|
29
|
-
return this;
|
|
30
|
-
};
|
|
31
|
-
exports.modelClear = modelClear;
|
|
32
|
-
// synchronous get
|
|
33
|
-
const get = function (key, opts, reFetchSync) {
|
|
34
|
-
const { driver_table_uid } = Helpers.parseDriverUidAndTableNameFromUID(key);
|
|
35
|
-
return (0, exports.modelGet)(models[driver_table_uid], key, opts, reFetchSync);
|
|
36
|
-
};
|
|
37
|
-
exports.get = get;
|
|
38
|
-
const modelGet = function (model, key, opts, reFetchSync) {
|
|
39
|
-
if (opts.identityCache === false)
|
|
40
|
-
return reFetchSync();
|
|
41
|
-
var value = model.caches.get(key);
|
|
42
|
-
if (value !== undefined) {
|
|
43
|
-
if (opts && opts.saveCheck && typeof value.saved === "function" && !value.saved())
|
|
44
|
-
// if not saved, don't return it, fetch original from db
|
|
45
|
-
return reFetchSync();
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
value = reFetchSync();
|
|
49
|
-
model.caches.set(key, value);
|
|
50
|
-
}
|
|
51
|
-
const expected_expire = typeof opts.identityCache === "number" ? (opts.identityCache * 1000) : model.caches.ttl;
|
|
52
|
-
const expire_expection_delta = expected_expire - model.caches.ttl;
|
|
53
|
-
if (expire_expection_delta > 0) {
|
|
54
|
-
coroutine.start(() => {
|
|
55
|
-
while (true) {
|
|
56
|
-
// quit when cached key-value has not been here
|
|
57
|
-
if (!model.caches.has(key))
|
|
58
|
-
break;
|
|
59
|
-
model.caches.set(key, value);
|
|
60
|
-
if (expected_expire > Date.now()) {
|
|
61
|
-
model.caches.delete(key);
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
else if (expire_expection_delta < 0) {
|
|
68
|
-
setTimeout(() => model.caches.delete(key), expected_expire);
|
|
69
|
-
}
|
|
70
|
-
return value;
|
|
71
|
-
};
|
|
72
|
-
exports.modelGet = modelGet;
|
package/lib/orm/Typo/Adapter.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|