fib-orm 2.1.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -6
- package/index.d.ts +11 -0
- package/index.js +15 -0
- package/package.json +37 -34
- package/{lib/cli/commands/ddlFrom.js → src/cli/commands/ddlFrom.ts} +40 -27
- package/{lib/cli/commands/dumpModel.js → src/cli/commands/dumpModel.ts} +78 -32
- package/{lib/cli/commands/escape.js → src/cli/commands/escape.ts} +51 -29
- package/{lib/cli/commands/spinner.js → src/cli/commands/spinner.ts} +20 -11
- package/{lib/cli/commands/upgrade.js → src/cli/commands/upgrade.ts} +53 -34
- package/src/cli/helpers/ddl.ts +84 -0
- package/src/cli/helpers/package.ts +81 -0
- package/src/cli/index.ts +24 -0
- package/src/cli/wrapSubcommand.ts +66 -0
- package/src/db-driver/Typo.d.ts +141 -0
- package/src/db-driver/built-ins/base.class.ts +260 -0
- package/src/db-driver/built-ins/driver-dm.ts +62 -0
- package/src/db-driver/built-ins/driver-mssql.ts +67 -0
- package/src/db-driver/built-ins/driver-mysql.ts +44 -0
- package/src/db-driver/built-ins/driver-postgresql.ts +94 -0
- package/src/db-driver/built-ins/driver-redis.ts +45 -0
- package/src/db-driver/built-ins/driver-sqlite.ts +41 -0
- package/src/db-driver/index.ts +6 -0
- package/src/db-driver/parseQueryString.ts +76 -0
- package/src/db-driver/utils.ts +204 -0
- package/src/knex/deps/tarn/PendingOperation.ts +56 -0
- package/src/knex/deps/tarn/Pool.ts +610 -0
- package/src/knex/deps/tarn/PromiseInspection.ts +29 -0
- package/src/knex/deps/tarn/Resource.ts +22 -0
- package/src/knex/deps/tarn/TimeoutError.ts +1 -0
- package/src/knex/deps/tarn/tarn.ts +7 -0
- package/src/knex/deps/tarn/utils.ts +62 -0
- package/src/knex/knex.ts +11 -0
- package/src/knex/result.d.ts +27 -0
- package/src/knex/sandbox.ts +45 -0
- package/src/knex/tables.d.ts +4 -0
- package/src/knex/types.d.ts +3228 -0
- package/src/orm/Adapters.ts +53 -0
- package/src/orm/AggregateFunctions.ts +254 -0
- package/src/orm/Associations/Extend.ts +405 -0
- package/src/orm/Associations/Many.ts +784 -0
- package/src/orm/Associations/One.ts +494 -0
- package/src/orm/Associations/_utils.ts +72 -0
- package/src/orm/ChainFind.ts +427 -0
- package/src/orm/ChainInstance.ts +97 -0
- package/src/orm/Debug.ts +21 -0
- package/src/orm/Drivers/DB/base.ts +7 -0
- package/src/orm/Drivers/DB/dm.ts +35 -0
- package/src/orm/Drivers/DB/mssql.ts +35 -0
- package/src/orm/Drivers/DB/mysql.ts +35 -0
- package/src/orm/Drivers/DB/postgres.ts +35 -0
- package/src/orm/Drivers/DB/sqlite3.ts +60 -0
- package/src/orm/Drivers/DML/_ddl-sql.ts +85 -0
- package/src/orm/Drivers/DML/_dml-helpers.ts +66 -0
- package/src/orm/Drivers/DML/_shared.ts +61 -0
- package/src/orm/Drivers/DML/_utils.ts +112 -0
- package/{lib/orm/Drivers/DML/dm.js → src/orm/Drivers/DML/dm.ts} +178 -86
- package/src/orm/Drivers/DML/index.ts +10 -0
- package/src/orm/Drivers/DML/mssql.ts +366 -0
- package/src/orm/Drivers/DML/mysql.ts +347 -0
- package/src/orm/Drivers/DML/postgres.ts +382 -0
- package/src/orm/Drivers/DML/sqlite.ts +361 -0
- package/src/orm/Error.ts +49 -0
- package/src/orm/Helpers.ts +297 -0
- package/src/orm/Hook.ts +125 -0
- package/src/orm/Instance.ts +944 -0
- package/src/orm/LazyLoad.ts +117 -0
- package/src/orm/Model.ts +1235 -0
- package/src/orm/ORM.ts +301 -0
- package/src/orm/Patch/fib-cache.ts +7 -0
- package/src/orm/Patch/plugin.ts +25 -0
- package/src/orm/Property.ts +86 -0
- package/src/orm/Settings.ts +134 -0
- package/src/orm/Singleton.ts +97 -0
- package/src/orm/Typo/Adapter.d.ts +5 -0
- package/src/orm/Typo/DMLDriver.d.ts +260 -0
- package/src/orm/Typo/Db.d.ts +100 -0
- package/src/orm/Typo/Error.d.ts +36 -0
- package/src/orm/Typo/ORM.d.ts +315 -0
- package/src/orm/Typo/Validators.d.ts +39 -0
- package/src/orm/Typo/_common.d.ts +44 -0
- package/src/orm/Typo/assoc.d.ts +280 -0
- package/src/orm/Typo/hook.d.ts +68 -0
- package/src/orm/Typo/instance.d.ts +214 -0
- package/{lib → src}/orm/Typo/model.d.ts +297 -174
- package/src/orm/Typo/patch.d.ts +39 -0
- package/src/orm/Typo/property.d.ts +79 -0
- package/src/orm/Typo/query.d.ts +266 -0
- package/{lib → src}/orm/Typo/settings.d.ts +14 -7
- package/{lib → src}/orm/Typo/synchronous.d.ts +51 -26
- package/src/orm/Utilities.ts +1313 -0
- package/src/orm/Validators.ts +127 -0
- package/src/orm/Where/common.ts +8 -0
- package/src/orm/Where/filterDate.ts +74 -0
- package/src/orm/cloneDeep.ts +45 -0
- package/src/orm/index.ts +231 -0
- package/src/orm-core/callback.d.ts +15 -0
- package/{lib → src}/orm-core/dialect.d.ts +75 -52
- package/src/orm-core/error.ts +71 -0
- package/{lib/orm-core/index.d.ts → src/orm-core/index.ts} +8 -2
- package/src/orm-core/sync.d.ts +14 -0
- package/src/orm-core/utils.ts +4 -0
- package/src/orm-property/Property.ts +110 -0
- package/src/orm-property/Utils.ts +26 -0
- package/src/orm-property/customTypes.ts +13 -0
- package/src/orm-property/index.ts +34 -0
- package/src/orm-property/transformer.ts +16 -0
- package/{lib/orm-property/transformers/dm.js → src/orm-property/transformers/dm.ts} +128 -69
- package/src/orm-property/transformers/index.ts +10 -0
- package/src/orm-property/transformers/mssql.ts +285 -0
- package/src/orm-property/transformers/mysql.ts +395 -0
- package/src/orm-property/transformers/postgresql.ts +267 -0
- package/src/orm-property/transformers/sqlite.ts +217 -0
- package/src/plugins/orm-plugin-uacl/Typo.d.ts +173 -0
- package/src/plugins/orm-plugin-uacl/_utils.ts +237 -0
- package/src/plugins/orm-plugin-uacl/acl-tree.ts +440 -0
- package/src/plugins/orm-plugin-uacl/config-acl-tree.ts +592 -0
- package/src/plugins/orm-plugin-uacl/index.ts +180 -0
- package/src/plugins/orm-plugin-uacl/tree.ts +331 -0
- package/src/sql-ddl-sync/Dialects/dm.ts +493 -0
- package/{lib/sql-query/Dialects/index.d.ts → src/sql-ddl-sync/Dialects/index.ts} +3 -3
- package/src/sql-ddl-sync/Dialects/mssql.ts +441 -0
- package/src/sql-ddl-sync/Dialects/mysql.ts +414 -0
- package/src/sql-ddl-sync/Dialects/postgresql.ts +474 -0
- package/src/sql-ddl-sync/Dialects/sqlite.ts +439 -0
- package/src/sql-ddl-sync/SQL.ts +157 -0
- package/src/sql-ddl-sync/Typo/Collection.d.ts +19 -0
- package/src/sql-ddl-sync/Typo/DbIndex.d.ts +11 -0
- package/{lib → src}/sql-ddl-sync/Typo/Dialect.d.ts +67 -52
- package/src/sql-ddl-sync/Typo/Driver.d.ts +67 -0
- package/src/sql-ddl-sync/Typo/Query.d.ts +8 -0
- package/src/sql-ddl-sync/Typo/SQL.d.ts +45 -0
- package/src/sql-ddl-sync/Typo/_common.d.ts +59 -0
- package/src/sql-ddl-sync/Utils.ts +291 -0
- package/src/sql-ddl-sync/index.ts +599 -0
- package/src/sql-query/Comparators.ts +115 -0
- package/src/sql-query/Create.ts +87 -0
- package/{lib/sql-query/Dialects/dm.js → src/sql-query/Dialects/dm.ts} +42 -22
- package/src/sql-query/Dialects/index.ts +14 -0
- package/src/sql-query/Dialects/mssql.ts +91 -0
- package/src/sql-query/Dialects/mysql.ts +120 -0
- package/src/sql-query/Dialects/postgresql.ts +99 -0
- package/src/sql-query/Dialects/sqlite.ts +80 -0
- package/src/sql-query/Helpers.ts +303 -0
- package/src/sql-query/Insert.ts +41 -0
- package/src/sql-query/Query.ts +140 -0
- package/src/sql-query/Remove.ts +111 -0
- package/src/sql-query/Select.ts +719 -0
- package/src/sql-query/Set.ts +25 -0
- package/src/sql-query/Typo/Aggregation.d.ts +34 -0
- package/src/sql-query/Typo/Comparators.d.ts +156 -0
- package/src/sql-query/Typo/Dialect.d.ts +51 -0
- package/src/sql-query/Typo/Field.d.ts +10 -0
- package/src/sql-query/Typo/Helper.d.ts +4 -0
- package/src/sql-query/Typo/Query-ChainBuilder.d.ts +110 -0
- package/src/sql-query/Typo/Query.d.ts +65 -0
- package/src/sql-query/Typo/Sql.d.ts +192 -0
- package/src/sql-query/Typo/SubQuery.d.ts +52 -0
- package/{lib/sql-query/Typo/index.d.ts → src/sql-query/Typo/index.ts} +5 -2
- package/src/sql-query/Update.ts +50 -0
- package/src/sql-query/Where.ts +435 -0
- package/{lib/orm/Patch → src/typings}/fib-cache.d.ts +4 -2
- package/lib/cli/commands/ddlFrom.d.ts +0 -2
- package/lib/cli/commands/dumpModel.d.ts +0 -2
- package/lib/cli/commands/escape.d.ts +0 -2
- package/lib/cli/commands/spinner.d.ts +0 -2
- package/lib/cli/commands/upgrade.d.ts +0 -2
- package/lib/cli/helpers/ddl.d.ts +0 -17
- package/lib/cli/helpers/ddl.js +0 -55
- package/lib/cli/helpers/package.d.ts +0 -25
- package/lib/cli/helpers/package.js +0 -56
- package/lib/cli/index.d.ts +0 -2
- package/lib/cli/index.js +0 -19
- package/lib/db-driver/Typo.d.ts +0 -111
- package/lib/db-driver/Typo.js +0 -2
- package/lib/db-driver/built-ins/base.class.d.ts +0 -91
- package/lib/db-driver/built-ins/base.class.js +0 -187
- package/lib/db-driver/built-ins/driver-dm.d.ts +0 -17
- package/lib/db-driver/built-ins/driver-dm.js +0 -54
- package/lib/db-driver/built-ins/driver-mongodb.d.ts +0 -23
- package/lib/db-driver/built-ins/driver-mongodb.js +0 -47
- package/lib/db-driver/built-ins/driver-mysql.d.ts +0 -17
- package/lib/db-driver/built-ins/driver-mysql.js +0 -38
- package/lib/db-driver/built-ins/driver-postgresql.d.ts +0 -21
- package/lib/db-driver/built-ins/driver-postgresql.js +0 -77
- package/lib/db-driver/built-ins/driver-redis.d.ts +0 -11
- package/lib/db-driver/built-ins/driver-redis.js +0 -36
- package/lib/db-driver/built-ins/driver-sqlite.d.ts +0 -16
- package/lib/db-driver/built-ins/driver-sqlite.js +0 -35
- package/lib/db-driver/index.d.ts +0 -3
- package/lib/db-driver/index.js +0 -5
- package/lib/db-driver/utils.d.ts +0 -14
- package/lib/db-driver/utils.js +0 -187
- package/lib/knex/deps/tarn/dist/PendingOperation.d.ts +0 -12
- package/lib/knex/deps/tarn/dist/PendingOperation.js +0 -48
- package/lib/knex/deps/tarn/dist/Pool.d.ts +0 -97
- package/lib/knex/deps/tarn/dist/Pool.js +0 -516
- package/lib/knex/deps/tarn/dist/PromiseInspection.d.ts +0 -16
- package/lib/knex/deps/tarn/dist/PromiseInspection.js +0 -21
- package/lib/knex/deps/tarn/dist/Resource.d.ts +0 -9
- package/lib/knex/deps/tarn/dist/Resource.js +0 -19
- package/lib/knex/deps/tarn/dist/TimeoutError.d.ts +0 -2
- package/lib/knex/deps/tarn/dist/TimeoutError.js +0 -5
- package/lib/knex/deps/tarn/dist/tarn.d.ts +0 -3
- package/lib/knex/deps/tarn/dist/tarn.js +0 -10
- package/lib/knex/deps/tarn/dist/utils.d.ts +0 -14
- package/lib/knex/deps/tarn/dist/utils.js +0 -60
- package/lib/knex/knex.d.ts +0 -2
- package/lib/knex/knex.js +0 -4
- package/lib/knex/sandbox.d.ts +0 -4
- package/lib/knex/sandbox.js +0 -23
- package/lib/orm/Adapters.d.ts +0 -3
- package/lib/orm/Adapters.js +0 -44
- package/lib/orm/AggregateFunctions.d.ts +0 -3
- package/lib/orm/AggregateFunctions.js +0 -177
- package/lib/orm/Associations/Extend.d.ts +0 -22
- package/lib/orm/Associations/Extend.js +0 -274
- package/lib/orm/Associations/Many.d.ts +0 -16
- package/lib/orm/Associations/Many.js +0 -569
- package/lib/orm/Associations/One.d.ts +0 -16
- package/lib/orm/Associations/One.js +0 -310
- package/lib/orm/Associations/_utils.d.ts +0 -14
- package/lib/orm/Associations/_utils.js +0 -53
- package/lib/orm/ChainFind.d.ts +0 -3
- package/lib/orm/ChainFind.js +0 -328
- package/lib/orm/ChainInstance.d.ts +0 -6
- package/lib/orm/ChainInstance.js +0 -74
- package/lib/orm/Debug.d.ts +0 -2
- package/lib/orm/Debug.js +0 -17
- package/lib/orm/Drivers/DB/base.d.ts +0 -2
- package/lib/orm/Drivers/DB/base.js +0 -4
- package/lib/orm/Drivers/DB/dm.d.ts +0 -9
- package/lib/orm/Drivers/DB/dm.js +0 -24
- package/lib/orm/Drivers/DB/mysql.d.ts +0 -9
- package/lib/orm/Drivers/DB/mysql.js +0 -24
- package/lib/orm/Drivers/DB/postgres.d.ts +0 -9
- package/lib/orm/Drivers/DB/postgres.js +0 -23
- package/lib/orm/Drivers/DB/sqlite3.d.ts +0 -14
- package/lib/orm/Drivers/DB/sqlite3.js +0 -40
- package/lib/orm/Drivers/DML/_ddl-sql.d.ts +0 -3
- package/lib/orm/Drivers/DML/_ddl-sql.js +0 -52
- package/lib/orm/Drivers/DML/_dml-helpers.d.ts +0 -19
- package/lib/orm/Drivers/DML/_dml-helpers.js +0 -51
- package/lib/orm/Drivers/DML/_shared.d.ts +0 -9
- package/lib/orm/Drivers/DML/_shared.js +0 -39
- package/lib/orm/Drivers/DML/_utils.d.ts +0 -8
- package/lib/orm/Drivers/DML/_utils.js +0 -67
- package/lib/orm/Drivers/DML/constants.d.ts +0 -3
- package/lib/orm/Drivers/DML/constants.js +0 -3
- package/lib/orm/Drivers/DML/dm.d.ts +0 -2
- package/lib/orm/Drivers/DML/index.d.ts +0 -4
- package/lib/orm/Drivers/DML/index.js +0 -7
- package/lib/orm/Drivers/DML/mysql.d.ts +0 -2
- package/lib/orm/Drivers/DML/mysql.js +0 -252
- package/lib/orm/Drivers/DML/postgres.d.ts +0 -2
- package/lib/orm/Drivers/DML/postgres.js +0 -277
- package/lib/orm/Drivers/DML/sqlite.d.ts +0 -2
- package/lib/orm/Drivers/DML/sqlite.js +0 -267
- package/lib/orm/Error.d.ts +0 -11
- package/lib/orm/Error.js +0 -41
- package/lib/orm/Helpers.d.ts +0 -35
- package/lib/orm/Helpers.js +0 -234
- package/lib/orm/Hook.d.ts +0 -13
- package/lib/orm/Hook.js +0 -100
- package/lib/orm/Instance.d.ts +0 -2
- package/lib/orm/Instance.js +0 -698
- package/lib/orm/LazyLoad.d.ts +0 -4
- package/lib/orm/LazyLoad.js +0 -76
- package/lib/orm/Model.d.ts +0 -6
- package/lib/orm/Model.js +0 -974
- package/lib/orm/ORM.d.ts +0 -37
- package/lib/orm/ORM.js +0 -242
- package/lib/orm/Patch/fib-cache.js +0 -2
- package/lib/orm/Patch/plugin.d.ts +0 -4
- package/lib/orm/Patch/plugin.js +0 -14
- package/lib/orm/Property.d.ts +0 -9
- package/lib/orm/Property.js +0 -71
- package/lib/orm/Settings.d.ts +0 -42
- package/lib/orm/Settings.js +0 -120
- package/lib/orm/Singleton.d.ts +0 -5
- package/lib/orm/Singleton.js +0 -73
- package/lib/orm/Typo/Adapter.d.ts +0 -5
- package/lib/orm/Typo/Adapter.js +0 -2
- package/lib/orm/Typo/DMLDriver.d.ts +0 -209
- package/lib/orm/Typo/DMLDriver.js +0 -2
- package/lib/orm/Typo/Db.d.ts +0 -35
- package/lib/orm/Typo/Db.js +0 -2
- package/lib/orm/Typo/Error.d.ts +0 -29
- package/lib/orm/Typo/Error.js +0 -2
- package/lib/orm/Typo/ORM.d.ts +0 -231
- package/lib/orm/Typo/ORM.js +0 -4
- package/lib/orm/Typo/Validators.d.ts +0 -31
- package/lib/orm/Typo/Validators.js +0 -3
- package/lib/orm/Typo/_common.d.ts +0 -37
- package/lib/orm/Typo/_common.js +0 -2
- package/lib/orm/Typo/assoc.d.ts +0 -221
- package/lib/orm/Typo/assoc.js +0 -2
- package/lib/orm/Typo/hook.d.ts +0 -42
- package/lib/orm/Typo/hook.js +0 -2
- package/lib/orm/Typo/instance.d.ts +0 -156
- package/lib/orm/Typo/instance.js +0 -2
- package/lib/orm/Typo/model.js +0 -7
- package/lib/orm/Typo/patch.d.ts +0 -31
- package/lib/orm/Typo/patch.js +0 -2
- package/lib/orm/Typo/property.d.ts +0 -57
- package/lib/orm/Typo/property.js +0 -2
- package/lib/orm/Typo/query.d.ts +0 -216
- package/lib/orm/Typo/query.js +0 -2
- package/lib/orm/Typo/settings.js +0 -6
- package/lib/orm/Typo/synchronous.js +0 -2
- package/lib/orm/Utilities.d.ts +0 -178
- package/lib/orm/Utilities.js +0 -975
- package/lib/orm/Validators.d.ts +0 -33
- package/lib/orm/Validators.js +0 -101
- package/lib/orm/Where/common.d.ts +0 -1
- package/lib/orm/Where/common.js +0 -7
- package/lib/orm/Where/filterDate.d.ts +0 -11
- package/lib/orm/Where/filterDate.js +0 -58
- package/lib/orm/index.d.ts +0 -67
- package/lib/orm/index.js +0 -158
- package/lib/orm-core/callback.d.ts +0 -12
- package/lib/orm-core/callback.js +0 -2
- package/lib/orm-core/dialect.js +0 -2
- package/lib/orm-core/error.d.ts +0 -16
- package/lib/orm-core/error.js +0 -29
- package/lib/orm-core/index.js +0 -7
- package/lib/orm-core/sync.d.ts +0 -12
- package/lib/orm-core/sync.js +0 -2
- package/lib/orm-core/utils.d.ts +0 -1
- package/lib/orm-core/utils.js +0 -6
- package/lib/orm-property/Property.d.ts +0 -78
- package/lib/orm-property/Property.js +0 -2
- package/lib/orm-property/Utils.d.ts +0 -9
- package/lib/orm-property/Utils.js +0 -13
- package/lib/orm-property/customTypes.d.ts +0 -2
- package/lib/orm-property/customTypes.js +0 -13
- package/lib/orm-property/index.d.ts +0 -10
- package/lib/orm-property/index.js +0 -23
- package/lib/orm-property/transformer.d.ts +0 -5
- package/lib/orm-property/transformer.js +0 -10
- package/lib/orm-property/transformers/dm.d.ts +0 -29
- package/lib/orm-property/transformers/index.d.ts +0 -4
- package/lib/orm-property/transformers/index.js +0 -6
- package/lib/orm-property/transformers/mysql.d.ts +0 -101
- package/lib/orm-property/transformers/mysql.js +0 -262
- package/lib/orm-property/transformers/postgresql.d.ts +0 -54
- package/lib/orm-property/transformers/postgresql.js +0 -190
- package/lib/orm-property/transformers/sqlite.d.ts +0 -19
- package/lib/orm-property/transformers/sqlite.js +0 -172
- package/lib/sql-ddl-sync/Dialects/dm.d.ts +0 -39
- package/lib/sql-ddl-sync/Dialects/dm.js +0 -297
- package/lib/sql-ddl-sync/Dialects/index.d.ts +0 -6
- package/lib/sql-ddl-sync/Dialects/index.js +0 -8
- package/lib/sql-ddl-sync/Dialects/mysql.d.ts +0 -38
- package/lib/sql-ddl-sync/Dialects/mysql.js +0 -241
- package/lib/sql-ddl-sync/Dialects/postgresql.d.ts +0 -39
- package/lib/sql-ddl-sync/Dialects/postgresql.js +0 -287
- package/lib/sql-ddl-sync/Dialects/sqlite.d.ts +0 -43
- package/lib/sql-ddl-sync/Dialects/sqlite.js +0 -257
- package/lib/sql-ddl-sync/SQL.d.ts +0 -12
- package/lib/sql-ddl-sync/SQL.js +0 -108
- package/lib/sql-ddl-sync/Typo/Collection.d.ts +0 -13
- package/lib/sql-ddl-sync/Typo/Collection.js +0 -2
- package/lib/sql-ddl-sync/Typo/DbIndex.d.ts +0 -13
- package/lib/sql-ddl-sync/Typo/DbIndex.js +0 -2
- package/lib/sql-ddl-sync/Typo/Dialect.js +0 -2
- package/lib/sql-ddl-sync/Typo/Driver.d.ts +0 -53
- package/lib/sql-ddl-sync/Typo/Driver.js +0 -2
- package/lib/sql-ddl-sync/Typo/Query.d.ts +0 -7
- package/lib/sql-ddl-sync/Typo/Query.js +0 -2
- package/lib/sql-ddl-sync/Typo/SQL.d.ts +0 -31
- package/lib/sql-ddl-sync/Typo/SQL.js +0 -2
- package/lib/sql-ddl-sync/Typo/_common.d.ts +0 -29
- package/lib/sql-ddl-sync/Typo/_common.js +0 -2
- package/lib/sql-ddl-sync/Utils.d.ts +0 -39
- package/lib/sql-ddl-sync/Utils.js +0 -217
- package/lib/sql-ddl-sync/index.d.ts +0 -87
- package/lib/sql-ddl-sync/index.js +0 -372
- package/lib/sql-query/Comparators.d.ts +0 -3
- package/lib/sql-query/Comparators.js +0 -95
- package/lib/sql-query/Create.d.ts +0 -35
- package/lib/sql-query/Create.js +0 -78
- package/lib/sql-query/Dialects/dm.d.ts +0 -3
- package/lib/sql-query/Dialects/index.js +0 -13
- package/lib/sql-query/Dialects/mssql.d.ts +0 -3
- package/lib/sql-query/Dialects/mssql.js +0 -74
- package/lib/sql-query/Dialects/mysql.d.ts +0 -3
- package/lib/sql-query/Dialects/mysql.js +0 -101
- package/lib/sql-query/Dialects/postgresql.d.ts +0 -3
- package/lib/sql-query/Dialects/postgresql.js +0 -77
- package/lib/sql-query/Dialects/sqlite.d.ts +0 -3
- package/lib/sql-query/Dialects/sqlite.js +0 -62
- package/lib/sql-query/Helpers.d.ts +0 -37
- package/lib/sql-query/Helpers.js +0 -260
- package/lib/sql-query/Insert.d.ts +0 -12
- package/lib/sql-query/Insert.js +0 -34
- package/lib/sql-query/Query.d.ts +0 -28
- package/lib/sql-query/Query.js +0 -120
- package/lib/sql-query/Remove.d.ts +0 -16
- package/lib/sql-query/Remove.js +0 -94
- package/lib/sql-query/Select.d.ts +0 -62
- package/lib/sql-query/Select.js +0 -534
- package/lib/sql-query/Set.d.ts +0 -4
- package/lib/sql-query/Set.js +0 -16
- package/lib/sql-query/Typo/Aggregation.d.ts +0 -32
- package/lib/sql-query/Typo/Aggregation.js +0 -2
- package/lib/sql-query/Typo/Comparators.d.ts +0 -140
- package/lib/sql-query/Typo/Comparators.js +0 -2
- package/lib/sql-query/Typo/Dialect.d.ts +0 -39
- package/lib/sql-query/Typo/Dialect.js +0 -2
- package/lib/sql-query/Typo/Field.d.ts +0 -8
- package/lib/sql-query/Typo/Field.js +0 -2
- package/lib/sql-query/Typo/Helper.d.ts +0 -4
- package/lib/sql-query/Typo/Helper.js +0 -2
- package/lib/sql-query/Typo/Query-ChainBuilder.d.ts +0 -80
- package/lib/sql-query/Typo/Query-ChainBuilder.js +0 -2
- package/lib/sql-query/Typo/Query.d.ts +0 -34
- package/lib/sql-query/Typo/Query.js +0 -17
- package/lib/sql-query/Typo/Sql.d.ts +0 -143
- package/lib/sql-query/Typo/Sql.js +0 -2
- package/lib/sql-query/Typo/SubQuery.d.ts +0 -39
- package/lib/sql-query/Typo/SubQuery.js +0 -2
- package/lib/sql-query/Typo/index.js +0 -2
- package/lib/sql-query/Update.d.ts +0 -15
- package/lib/sql-query/Update.js +0 -39
- package/lib/sql-query/Where.d.ts +0 -4
- package/lib/sql-query/Where.js +0 -280
- /package/{lib → src}/codepoints-map.json +0 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import type { IPropTransformer, IProperty, __StringType } from "../Property";
|
|
2
|
+
import { COLUMN_NUMER_TYPE_IDX, filterPropertyDefaultValue } from "../Utils";
|
|
3
|
+
|
|
4
|
+
type AllNinable<T extends object> = {
|
|
5
|
+
[P in keyof T]: null | T[P]
|
|
6
|
+
}
|
|
7
|
+
type PostgreSQLTypeValueBool = 'NO' | 'YES';
|
|
8
|
+
// item in list from `SELECT * FROM information_schema.columns WHERE table_name = ?;`
|
|
9
|
+
export type ColumnInfoPostgreSQL = AllNinable<{
|
|
10
|
+
table_catalog: string
|
|
11
|
+
table_schema: string
|
|
12
|
+
table_name: string
|
|
13
|
+
column_name: string
|
|
14
|
+
ordinal_position: string
|
|
15
|
+
column_default: string
|
|
16
|
+
is_nullable: PostgreSQLTypeValueBool
|
|
17
|
+
data_type: __StringType<
|
|
18
|
+
| 'smallint'
|
|
19
|
+
| 'integer'
|
|
20
|
+
| 'bigint'
|
|
21
|
+
| 'real'
|
|
22
|
+
| 'double precision'
|
|
23
|
+
| 'boolean'
|
|
24
|
+
| 'timestamp with time zone'
|
|
25
|
+
| 'timestamp without time zone'
|
|
26
|
+
| 'date'
|
|
27
|
+
| 'bytea'
|
|
28
|
+
| 'text'
|
|
29
|
+
| 'character varying'
|
|
30
|
+
| 'user-defined'
|
|
31
|
+
>
|
|
32
|
+
character_maximum_length: number
|
|
33
|
+
character_octet_length: number
|
|
34
|
+
numeric_precision: string
|
|
35
|
+
numeric_precision_radix: string
|
|
36
|
+
numeric_scale: string
|
|
37
|
+
datetime_precision: string
|
|
38
|
+
interval_type: string
|
|
39
|
+
interval_precision: string
|
|
40
|
+
character_set_catalog: string
|
|
41
|
+
character_set_schema: string
|
|
42
|
+
character_set_name: string
|
|
43
|
+
collation_catalog: string
|
|
44
|
+
collation_schema: string
|
|
45
|
+
collation_name: string
|
|
46
|
+
domain_catalog: string
|
|
47
|
+
domain_schema: string
|
|
48
|
+
domain_name: string
|
|
49
|
+
udt_catalog: string
|
|
50
|
+
udt_schema: string
|
|
51
|
+
udt_name: string
|
|
52
|
+
scope_catalog: string
|
|
53
|
+
scope_schema: string
|
|
54
|
+
scope_name: string
|
|
55
|
+
maximum_cardinality: string
|
|
56
|
+
dtd_identifier: string
|
|
57
|
+
is_self_referencing: PostgreSQLTypeValueBool
|
|
58
|
+
is_identity: PostgreSQLTypeValueBool
|
|
59
|
+
identity_generation: string
|
|
60
|
+
identity_start: string
|
|
61
|
+
identity_increment: string
|
|
62
|
+
identity_maximum: string
|
|
63
|
+
identity_minimum: string
|
|
64
|
+
identity_cycle: string
|
|
65
|
+
is_generated: PostgreSQLTypeValueBool
|
|
66
|
+
generation_expression: string
|
|
67
|
+
is_updatable: PostgreSQLTypeValueBool
|
|
68
|
+
}>
|
|
69
|
+
|
|
70
|
+
function psqlGetEnumTypeName (
|
|
71
|
+
collection_name: string,
|
|
72
|
+
column_name: string
|
|
73
|
+
) {
|
|
74
|
+
return `${collection_name}_enum_${column_name.toLowerCase()}`
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const columnSizes = {
|
|
78
|
+
integer: {
|
|
79
|
+
[COLUMN_NUMER_TYPE_IDX.SHORT]: 'SMALLINT',
|
|
80
|
+
[COLUMN_NUMER_TYPE_IDX.INTEGER]: 'INTEGER',
|
|
81
|
+
[COLUMN_NUMER_TYPE_IDX.LONG]: 'BIGINT'
|
|
82
|
+
},
|
|
83
|
+
floating: {
|
|
84
|
+
[COLUMN_NUMER_TYPE_IDX.FLOAT]: 'REAL',
|
|
85
|
+
[COLUMN_NUMER_TYPE_IDX.DOUBLE]: 'DOUBLE PRECISION'
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const rawToProperty: IPropTransformer<ColumnInfoPostgreSQL>['rawToProperty'] = function (
|
|
90
|
+
dCol, ctx
|
|
91
|
+
) {
|
|
92
|
+
let property = {} as IProperty;
|
|
93
|
+
|
|
94
|
+
if (dCol.is_nullable!.toUpperCase() == "NO") {
|
|
95
|
+
property.required = true;
|
|
96
|
+
}
|
|
97
|
+
if (dCol.column_default !== null) {
|
|
98
|
+
let m = dCol.column_default.match(/^'(.+)'::/);
|
|
99
|
+
if (m) {
|
|
100
|
+
property.defaultValue = m[1];
|
|
101
|
+
} else {
|
|
102
|
+
property.defaultValue = dCol.column_default;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
switch (dCol.data_type!.toUpperCase()) {
|
|
107
|
+
case "SMALLINT":
|
|
108
|
+
case "INTEGER":
|
|
109
|
+
case "BIGINT":
|
|
110
|
+
if (typeof dCol.column_default == 'string' && dCol.column_default.indexOf('nextval(') == 0) {
|
|
111
|
+
property.type = "serial";
|
|
112
|
+
property.key = true;
|
|
113
|
+
property.serial = true;
|
|
114
|
+
} else {
|
|
115
|
+
property.type = "integer";
|
|
116
|
+
}
|
|
117
|
+
for (let k in columnSizes.integer) {
|
|
118
|
+
if ((columnSizes.integer as Record<string, string>)[k] == dCol.data_type!.toUpperCase()) {
|
|
119
|
+
property.size = k;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
break;
|
|
124
|
+
case "REAL":
|
|
125
|
+
case "DOUBLE PRECISION":
|
|
126
|
+
property.type = "number";
|
|
127
|
+
property.rational = true;
|
|
128
|
+
for (let k in columnSizes.floating) {
|
|
129
|
+
if ((columnSizes.floating as Record<string, string>)[k] == dCol.data_type!.toUpperCase()) {
|
|
130
|
+
property.size = k;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
break;
|
|
135
|
+
case "BOOLEAN":
|
|
136
|
+
property.type = "boolean";
|
|
137
|
+
break;
|
|
138
|
+
case "TIMESTAMP WITH TIME ZONE":
|
|
139
|
+
property.time = true;
|
|
140
|
+
property.type = "date";
|
|
141
|
+
break;
|
|
142
|
+
case "TIMESTAMP WITHOUT TIME ZONE":
|
|
143
|
+
property.time = false;
|
|
144
|
+
property.type = "date";
|
|
145
|
+
break;
|
|
146
|
+
case "DATE":
|
|
147
|
+
property.type = "date";
|
|
148
|
+
break;
|
|
149
|
+
case "BYTEA":
|
|
150
|
+
property.type = "binary";
|
|
151
|
+
break;
|
|
152
|
+
case "TEXT":
|
|
153
|
+
property.type = "text";
|
|
154
|
+
break;
|
|
155
|
+
case "CHARACTER VARYING":
|
|
156
|
+
property.type = "text";
|
|
157
|
+
if (dCol.character_maximum_length) {
|
|
158
|
+
property.size = dCol.character_maximum_length;
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
case "USER-DEFINED":
|
|
162
|
+
if (dCol.udt_name!.match(/_enum_/)) {
|
|
163
|
+
property.type = "enum";
|
|
164
|
+
property.values = ctx?.userOptions?.enumValues || [];
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
case "POINT":
|
|
168
|
+
property.type = "point";
|
|
169
|
+
break;
|
|
170
|
+
default:
|
|
171
|
+
throw new Error("Unknown column type '" + dCol.data_type! + "'");
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
property.mapsTo = dCol.column_name || undefined;
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
raw: dCol,
|
|
178
|
+
property
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export const toStorageType: IPropTransformer<ColumnInfoPostgreSQL>['toStorageType'] = function (
|
|
183
|
+
inputProperty, ctx
|
|
184
|
+
) {
|
|
185
|
+
const property = { ...inputProperty }
|
|
186
|
+
|
|
187
|
+
const result: ReturnType<IPropTransformer<ColumnInfoPostgreSQL>['toStorageType']> = {
|
|
188
|
+
isCustom: false,
|
|
189
|
+
property,
|
|
190
|
+
typeValue: '',
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (property.serial) {
|
|
194
|
+
result.typeValue = 'SERIAL';
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (property.type == 'number' && property.rational === false) {
|
|
199
|
+
property.type = 'integer';
|
|
200
|
+
delete property.rational;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
switch (property.type) {
|
|
204
|
+
case "text":
|
|
205
|
+
result.typeValue = "TEXT";
|
|
206
|
+
break;
|
|
207
|
+
case "integer":
|
|
208
|
+
result.typeValue = (columnSizes.integer as Record<string, string>)[property.size!] || columnSizes.integer[COLUMN_NUMER_TYPE_IDX.INTEGER];
|
|
209
|
+
break;
|
|
210
|
+
case "number":
|
|
211
|
+
result.typeValue = (columnSizes.floating as Record<string, string>)[property.size!] || columnSizes.floating[COLUMN_NUMER_TYPE_IDX.INTEGER];
|
|
212
|
+
break;
|
|
213
|
+
case "serial":
|
|
214
|
+
property.serial = true;
|
|
215
|
+
property.key = true;
|
|
216
|
+
result.typeValue = "SERIAL";
|
|
217
|
+
break;
|
|
218
|
+
case "boolean":
|
|
219
|
+
result.typeValue = "BOOLEAN";
|
|
220
|
+
break;
|
|
221
|
+
case "datetime":
|
|
222
|
+
property.type = "date";
|
|
223
|
+
property.time = true;
|
|
224
|
+
case "date":
|
|
225
|
+
if (!property.time) {
|
|
226
|
+
result.typeValue = "DATE";
|
|
227
|
+
} else {
|
|
228
|
+
result.typeValue = "TIMESTAMP WITHOUT TIME ZONE";
|
|
229
|
+
}
|
|
230
|
+
break;
|
|
231
|
+
case "binary":
|
|
232
|
+
case "object":
|
|
233
|
+
result.typeValue = "BYTEA";
|
|
234
|
+
break;
|
|
235
|
+
case "enum":
|
|
236
|
+
const collection = (ctx?.collection || '');
|
|
237
|
+
result.typeValue = psqlGetEnumTypeName(collection, property.mapsTo?.toLowerCase() || '');
|
|
238
|
+
break;
|
|
239
|
+
case "point":
|
|
240
|
+
result.typeValue = "POINT";
|
|
241
|
+
break;
|
|
242
|
+
default:
|
|
243
|
+
result.isCustom = true;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (!result.typeValue && !result.isCustom) return result;
|
|
248
|
+
|
|
249
|
+
if (property.required) {
|
|
250
|
+
result.typeValue += " NOT NULL";
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (result.isCustom) {
|
|
254
|
+
if (ctx.customTypes?.[property.type]) {
|
|
255
|
+
result.typeValue = ctx.customTypes?.[property.type].datastoreType(property, ctx)
|
|
256
|
+
}
|
|
257
|
+
} else if (property.hasOwnProperty("defaultValue") && property.defaultValue !== undefined) {
|
|
258
|
+
if (property.type === 'date' && property.defaultValue === Date.now){
|
|
259
|
+
result.typeValue += " DEFAULT now()";
|
|
260
|
+
} else {
|
|
261
|
+
const defaultValue = filterPropertyDefaultValue(property, ctx)
|
|
262
|
+
result.typeValue += " DEFAULT " + ctx.escapeVal(defaultValue);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return result;
|
|
267
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import type { IPropTransformer, IProperty, __StringType } from "../Property"
|
|
2
|
+
import { filterPropertyDefaultValue } from "../Utils"
|
|
3
|
+
|
|
4
|
+
// item in list from `PRAGMA table_info(??)`
|
|
5
|
+
export interface ColumnInfoSQLite {
|
|
6
|
+
cid: number
|
|
7
|
+
dflt_value: string
|
|
8
|
+
name: string
|
|
9
|
+
notnull: 1 | 0
|
|
10
|
+
pk: 1 | 0
|
|
11
|
+
type: ColumnType_SQLite
|
|
12
|
+
}
|
|
13
|
+
type ColumnType_SQLite =
|
|
14
|
+
__StringType<
|
|
15
|
+
'TEXT'
|
|
16
|
+
| 'INTEGER'
|
|
17
|
+
| 'REAL'
|
|
18
|
+
| 'SERIAL'
|
|
19
|
+
| 'INTEGER UNSIGNED'
|
|
20
|
+
| 'DATE'
|
|
21
|
+
| 'DATETIME'
|
|
22
|
+
| 'BLOB'
|
|
23
|
+
| 'ENUM'
|
|
24
|
+
| 'POINT'
|
|
25
|
+
>
|
|
26
|
+
|
|
27
|
+
export interface PropertySQLite extends IProperty {
|
|
28
|
+
key?: boolean
|
|
29
|
+
|
|
30
|
+
before?: string
|
|
31
|
+
after?: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type ITransformers = IPropTransformer<ColumnInfoSQLite>;
|
|
35
|
+
|
|
36
|
+
export const rawToProperty: ITransformers['rawToProperty'] = function (
|
|
37
|
+
dCol, ctx
|
|
38
|
+
) {
|
|
39
|
+
const prop = {} as PropertySQLite;
|
|
40
|
+
|
|
41
|
+
if (dCol.pk) {
|
|
42
|
+
prop.key = true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (dCol.notnull) {
|
|
46
|
+
prop.required = true;
|
|
47
|
+
}
|
|
48
|
+
if (dCol.dflt_value) {
|
|
49
|
+
const m = dCol.dflt_value.match(/^'(.*)'$/);
|
|
50
|
+
if (m) {
|
|
51
|
+
prop.defaultValue = m[1];
|
|
52
|
+
} else {
|
|
53
|
+
prop.defaultValue = null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
switch (dCol.type.toUpperCase()) {
|
|
58
|
+
case "INTEGER":
|
|
59
|
+
// In sqlite land, integer primary keys are autoincrement by default
|
|
60
|
+
// weather you asked for this behaviour or not.
|
|
61
|
+
// http://www.sqlite.org/faq.html#q1
|
|
62
|
+
if (dCol.pk == 1) {
|
|
63
|
+
prop.type = "serial";
|
|
64
|
+
prop.serial = true;
|
|
65
|
+
prop.key = true;
|
|
66
|
+
} else {
|
|
67
|
+
prop.type = "integer";
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
case "INTEGER UNSIGNED":
|
|
71
|
+
prop.type = "boolean";
|
|
72
|
+
break;
|
|
73
|
+
case "REAL":
|
|
74
|
+
prop.type = "number";
|
|
75
|
+
prop.rational = true;
|
|
76
|
+
break;
|
|
77
|
+
case "DATETIME":
|
|
78
|
+
prop.type = "date";
|
|
79
|
+
prop.time = true;
|
|
80
|
+
break;
|
|
81
|
+
case "BLOB":
|
|
82
|
+
prop.type = "binary";
|
|
83
|
+
prop.big = true;
|
|
84
|
+
break;
|
|
85
|
+
case "TEXT":
|
|
86
|
+
prop.type = "text";
|
|
87
|
+
break;
|
|
88
|
+
case "POINT":
|
|
89
|
+
prop.type = "point";
|
|
90
|
+
break;
|
|
91
|
+
default:
|
|
92
|
+
let [_, type, _before, field] = dCol.type.toUpperCase().match(/(.*)\s(AFTER|BEFORE)\s`(.*)`$/) || [] as any[]
|
|
93
|
+
|
|
94
|
+
if (_) {
|
|
95
|
+
switch (_before && field) {
|
|
96
|
+
case 'BEFORE':
|
|
97
|
+
prop.before = field
|
|
98
|
+
case 'AFTER':
|
|
99
|
+
prop.after = field
|
|
100
|
+
break
|
|
101
|
+
}
|
|
102
|
+
prop.type = type;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
throw new Error(`Unknown prop type '${dCol.type}'`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
prop.mapsTo = dCol.name;
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
raw: dCol,
|
|
113
|
+
property: prop
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export const toStorageType: ITransformers['toStorageType'] = function (
|
|
118
|
+
inputProperty, ctx
|
|
119
|
+
) {
|
|
120
|
+
const property = { ...inputProperty }
|
|
121
|
+
|
|
122
|
+
const result: ReturnType<ITransformers['toStorageType']> = {
|
|
123
|
+
isCustom: false,
|
|
124
|
+
property,
|
|
125
|
+
typeValue: '' as ColumnType_SQLite,
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (property.type == 'number' && property.rational === false) {
|
|
129
|
+
property.type = 'integer';
|
|
130
|
+
delete property.rational;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
switch (property.type) {
|
|
134
|
+
case "text":
|
|
135
|
+
result.typeValue = "TEXT";
|
|
136
|
+
break;
|
|
137
|
+
case "integer":
|
|
138
|
+
result.typeValue = "INTEGER";
|
|
139
|
+
break;
|
|
140
|
+
case "number":
|
|
141
|
+
result.typeValue = "REAL";
|
|
142
|
+
break;
|
|
143
|
+
case "serial":
|
|
144
|
+
property.serial = true;
|
|
145
|
+
property.key = true;
|
|
146
|
+
result.typeValue = "INTEGER";
|
|
147
|
+
break;
|
|
148
|
+
case "boolean":
|
|
149
|
+
result.typeValue = "INTEGER UNSIGNED";
|
|
150
|
+
break;
|
|
151
|
+
case "datetime":
|
|
152
|
+
property.type = "date";
|
|
153
|
+
property.time = true;
|
|
154
|
+
case "date":
|
|
155
|
+
result.typeValue = "DATETIME";
|
|
156
|
+
break;
|
|
157
|
+
case "binary":
|
|
158
|
+
case "object":
|
|
159
|
+
result.typeValue = "BLOB";
|
|
160
|
+
break;
|
|
161
|
+
case "enum":
|
|
162
|
+
result.typeValue = "INTEGER";
|
|
163
|
+
break;
|
|
164
|
+
case "point":
|
|
165
|
+
result.typeValue = "POINT";
|
|
166
|
+
break;
|
|
167
|
+
default:
|
|
168
|
+
result.isCustom = true;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (!result.typeValue && !result.isCustom) return result;
|
|
173
|
+
|
|
174
|
+
if (property.required) {
|
|
175
|
+
result.typeValue += " NOT NULL";
|
|
176
|
+
}
|
|
177
|
+
if (property.key) {
|
|
178
|
+
if (!property.required) {
|
|
179
|
+
// append if not set
|
|
180
|
+
result.typeValue += " NOT NULL";
|
|
181
|
+
}
|
|
182
|
+
if (property.serial) {
|
|
183
|
+
result.typeValue += " PRIMARY KEY";
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (property.serial) {
|
|
187
|
+
if (!property.key) {
|
|
188
|
+
result.typeValue += " PRIMARY KEY";
|
|
189
|
+
}
|
|
190
|
+
result.typeValue += " AUTOINCREMENT";
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (result.isCustom) {
|
|
194
|
+
if (ctx.customTypes?.[property.type]) {
|
|
195
|
+
result.typeValue = ctx.customTypes?.[property.type].datastoreType(property, ctx)
|
|
196
|
+
}
|
|
197
|
+
} else if (property.hasOwnProperty("defaultValue") && property.defaultValue !== undefined) {
|
|
198
|
+
let defaultValue = property.type === 'date' && property.defaultValue === Date.now
|
|
199
|
+
? ctx.escapeVal('CURRENT_TIMESTAMP')
|
|
200
|
+
: ctx.escapeVal(filterPropertyDefaultValue(property, ctx));
|
|
201
|
+
|
|
202
|
+
const { useDefaultValue = true } = ctx.userOptions || {};
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* @description
|
|
206
|
+
* sqlite doens't support alter column's datetime default value,
|
|
207
|
+
* you should alter table's schema to change `datetime` type column's default value
|
|
208
|
+
*
|
|
209
|
+
* @see https://stackoverflow.com/questions/2614483/how-to-create-a-datetime-column-with-default-value-in-sqlite3
|
|
210
|
+
* @see https://stackoverflow.com/questions/25911191/altering-a-sqlite-table-to-add-a-timestamp-column-with-default-value
|
|
211
|
+
*/
|
|
212
|
+
if (defaultValue && useDefaultValue)
|
|
213
|
+
result.typeValue += ` DEFAULT ${defaultValue} `;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return result;
|
|
217
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type surface for the optional UACL plugin. The plugin predates the
|
|
3
|
+
* TypeScript migration and is not part of the ORM core package entry points;
|
|
4
|
+
* these declarations keep it inside `fibjs --check` without leaking its
|
|
5
|
+
* internal namespaces into the core typings.
|
|
6
|
+
*/
|
|
7
|
+
declare namespace FxORMPluginUACLNS {
|
|
8
|
+
type ACLKeyType = string
|
|
9
|
+
|
|
10
|
+
interface Node<DTYPE = any, TREE = any> {
|
|
11
|
+
id: any
|
|
12
|
+
parent: Node | null
|
|
13
|
+
root: any
|
|
14
|
+
children: Node[]
|
|
15
|
+
|
|
16
|
+
leftEdge: number
|
|
17
|
+
rightEdge: number
|
|
18
|
+
data?: DTYPE
|
|
19
|
+
|
|
20
|
+
readonly _depth: number | null
|
|
21
|
+
readonly descendantCount: number
|
|
22
|
+
readonly layer: number
|
|
23
|
+
readonly isRoot: boolean
|
|
24
|
+
readonly hasRoot: any
|
|
25
|
+
readonly breadCrumbs: Node[]
|
|
26
|
+
|
|
27
|
+
addChildNode(node: Node): Node
|
|
28
|
+
removeChildNode(node: Node): boolean
|
|
29
|
+
remove(): boolean
|
|
30
|
+
toJSON(): JsonifiedNode
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface RootNode<TREE = any> extends Node<any, TREE> {
|
|
34
|
+
id: null
|
|
35
|
+
parent: any
|
|
36
|
+
tree: TREE
|
|
37
|
+
clear(): number
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface Tree<NTYPE = any> {
|
|
41
|
+
root: any
|
|
42
|
+
nodeSet: Set<NTYPE>
|
|
43
|
+
|
|
44
|
+
readonly nodeCount: number
|
|
45
|
+
readonly nodes: NTYPE[]
|
|
46
|
+
readonly nonRootNodes: NTYPE[]
|
|
47
|
+
|
|
48
|
+
hasNode(node: NTYPE): boolean
|
|
49
|
+
clear(): number
|
|
50
|
+
toJSON(): any
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface ACLNode extends Node<any, any> {
|
|
54
|
+
oacl: any
|
|
55
|
+
|
|
56
|
+
push(
|
|
57
|
+
target: {
|
|
58
|
+
type: FxORMPluginUACLInternal.ACLStorageItem['target']['type']
|
|
59
|
+
id: any
|
|
60
|
+
},
|
|
61
|
+
opts?: ACLNodePushOpts
|
|
62
|
+
): any
|
|
63
|
+
pull(opts?: ACLNodePullOpts): any
|
|
64
|
+
revoke(opts?: ACLNodeRevokeOpts): any
|
|
65
|
+
could(action: ACLKeyType, uaci: string, askedFields: any[]): any
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface ACLTree extends Tree<ACLNode> {
|
|
69
|
+
name: string
|
|
70
|
+
type: FxORMPluginUACLInternal.GRANT_TYPE
|
|
71
|
+
_tree_stores: any
|
|
72
|
+
routing: any
|
|
73
|
+
|
|
74
|
+
load(opts?: ACLTreePersistOptions): any
|
|
75
|
+
persist(opts?: ACLTreePersistOptions): any
|
|
76
|
+
revoke(opts?: ACLTreeRevokeOptions): any
|
|
77
|
+
can(action: ACLKeyType, uaci: string, askedFields: any[]): any
|
|
78
|
+
grant(uaci: string, oacl: any, opts?: { puaci?: string }): any
|
|
79
|
+
reset(): any
|
|
80
|
+
find(opts: { uaci: string }): ACLNode | null
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interface ACLNodeConstructorOptions {
|
|
84
|
+
id?: any
|
|
85
|
+
parent?: any
|
|
86
|
+
children?: any
|
|
87
|
+
data?: any
|
|
88
|
+
oacl?: any
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface ACLNodePullOpts {
|
|
92
|
+
sync?: boolean
|
|
93
|
+
[key: string]: any
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
interface ACLNodePushOpts {
|
|
97
|
+
sync?: boolean
|
|
98
|
+
[key: string]: any
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface ACLNodeRevokeOpts {
|
|
102
|
+
sync?: boolean
|
|
103
|
+
[key: string]: any
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
interface ACLTreePersistOptions {
|
|
107
|
+
uaci?: string
|
|
108
|
+
sync?: boolean
|
|
109
|
+
[key: string]: any
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
interface ACLTreeRevokeOptions {
|
|
113
|
+
uaci?: string
|
|
114
|
+
sync?: boolean
|
|
115
|
+
[key: string]: any
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
type ACLTreeStorageRoutingConfigurationGenerator = (opts?: any) => any
|
|
119
|
+
|
|
120
|
+
type JsonifiedNode = any
|
|
121
|
+
type NodeConstructorOptions = any
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare namespace FxORMPluginUACLInternal {
|
|
125
|
+
type GRANT_TYPE = string
|
|
126
|
+
|
|
127
|
+
interface ACLMessage {
|
|
128
|
+
payload?: any
|
|
129
|
+
[key: string]: any
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
interface ACLMessagePayload {
|
|
133
|
+
[key: string]: any
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
interface ACLMessagePayloadGrant {
|
|
137
|
+
verb?: string
|
|
138
|
+
uids?: string[]
|
|
139
|
+
roles?: string[]
|
|
140
|
+
uacis?: string[]
|
|
141
|
+
oacl?: any
|
|
142
|
+
[key: string]: any
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
interface ACLMessageResult<T = any> {
|
|
146
|
+
success?: any
|
|
147
|
+
error?: any
|
|
148
|
+
result?: T
|
|
149
|
+
[key: string]: any
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
interface ACLStorageItem {
|
|
153
|
+
target: {
|
|
154
|
+
type: string
|
|
155
|
+
id: any
|
|
156
|
+
}
|
|
157
|
+
[key: string]: any
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
interface FxOrmPluginUACLOptions {
|
|
162
|
+
defineUACLInMainORM?: boolean
|
|
163
|
+
orm?: any
|
|
164
|
+
[key: string]: any
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
type FxOrmPluginUACL = (orm: any, plugin_opts?: FxOrmPluginUACLOptions) => any
|
|
168
|
+
|
|
169
|
+
interface Class_LruCache {
|
|
170
|
+
has(key: any): boolean
|
|
171
|
+
get(key: any): any
|
|
172
|
+
set(key: any, value: any): any
|
|
173
|
+
}
|