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.
Files changed (427) hide show
  1. package/README.md +42 -6
  2. package/index.d.ts +11 -0
  3. package/index.js +15 -0
  4. package/package.json +36 -34
  5. package/{lib/cli/commands/ddlFrom.js → src/cli/commands/ddlFrom.ts} +40 -26
  6. package/{lib/cli/commands/dumpModel.js → src/cli/commands/dumpModel.ts} +78 -31
  7. package/{lib/cli/commands/escape.js → src/cli/commands/escape.ts} +51 -28
  8. package/{lib/cli/commands/spinner.js → src/cli/commands/spinner.ts} +20 -10
  9. package/{lib/cli/commands/upgrade.js → src/cli/commands/upgrade.ts} +53 -33
  10. package/src/cli/helpers/ddl.ts +84 -0
  11. package/src/cli/helpers/package.ts +81 -0
  12. package/src/cli/index.ts +24 -0
  13. package/src/cli/wrapSubcommand.ts +66 -0
  14. package/src/db-driver/Typo.d.ts +141 -0
  15. package/src/db-driver/built-ins/base.class.ts +260 -0
  16. package/src/db-driver/built-ins/driver-dm.ts +62 -0
  17. package/src/db-driver/built-ins/driver-mssql.ts +67 -0
  18. package/src/db-driver/built-ins/driver-mysql.ts +44 -0
  19. package/src/db-driver/built-ins/driver-postgresql.ts +94 -0
  20. package/src/db-driver/built-ins/driver-redis.ts +45 -0
  21. package/src/db-driver/built-ins/driver-sqlite.ts +41 -0
  22. package/src/db-driver/index.ts +6 -0
  23. package/src/db-driver/parseQueryString.ts +76 -0
  24. package/src/db-driver/utils.ts +204 -0
  25. package/src/knex/deps/tarn/PendingOperation.ts +56 -0
  26. package/src/knex/deps/tarn/Pool.ts +610 -0
  27. package/src/knex/deps/tarn/PromiseInspection.ts +29 -0
  28. package/src/knex/deps/tarn/Resource.ts +22 -0
  29. package/src/knex/deps/tarn/TimeoutError.ts +1 -0
  30. package/src/knex/deps/tarn/tarn.ts +7 -0
  31. package/src/knex/deps/tarn/utils.ts +62 -0
  32. package/src/knex/knex.ts +11 -0
  33. package/src/knex/result.d.ts +27 -0
  34. package/src/knex/sandbox.ts +45 -0
  35. package/src/knex/tables.d.ts +4 -0
  36. package/src/knex/types.d.ts +3228 -0
  37. package/src/orm/Adapters.ts +53 -0
  38. package/src/orm/AggregateFunctions.ts +254 -0
  39. package/src/orm/Associations/Extend.ts +405 -0
  40. package/src/orm/Associations/Many.ts +784 -0
  41. package/src/orm/Associations/One.ts +494 -0
  42. package/src/orm/Associations/_utils.ts +72 -0
  43. package/src/orm/ChainFind.ts +427 -0
  44. package/src/orm/ChainInstance.ts +97 -0
  45. package/src/orm/Debug.ts +21 -0
  46. package/src/orm/Drivers/DB/base.ts +7 -0
  47. package/src/orm/Drivers/DB/dm.ts +35 -0
  48. package/src/orm/Drivers/DB/mssql.ts +35 -0
  49. package/src/orm/Drivers/DB/mysql.ts +35 -0
  50. package/src/orm/Drivers/DB/postgres.ts +35 -0
  51. package/src/orm/Drivers/DB/sqlite3.ts +60 -0
  52. package/src/orm/Drivers/DML/_ddl-sql.ts +85 -0
  53. package/src/orm/Drivers/DML/_dml-helpers.ts +66 -0
  54. package/src/orm/Drivers/DML/_shared.ts +61 -0
  55. package/src/orm/Drivers/DML/_utils.ts +112 -0
  56. package/{lib/orm/Drivers/DML/dm.js → src/orm/Drivers/DML/dm.ts} +178 -85
  57. package/src/orm/Drivers/DML/index.ts +10 -0
  58. package/src/orm/Drivers/DML/mssql.ts +366 -0
  59. package/src/orm/Drivers/DML/mysql.ts +347 -0
  60. package/src/orm/Drivers/DML/postgres.ts +382 -0
  61. package/src/orm/Drivers/DML/sqlite.ts +361 -0
  62. package/src/orm/Error.ts +49 -0
  63. package/src/orm/Helpers.ts +297 -0
  64. package/src/orm/Hook.ts +125 -0
  65. package/src/orm/Instance.ts +944 -0
  66. package/src/orm/LazyLoad.ts +117 -0
  67. package/src/orm/Model.ts +1235 -0
  68. package/src/orm/ORM.ts +301 -0
  69. package/src/orm/Patch/fib-cache.ts +7 -0
  70. package/src/orm/Patch/plugin.ts +25 -0
  71. package/src/orm/Property.ts +86 -0
  72. package/src/orm/Settings.ts +134 -0
  73. package/src/orm/Singleton.ts +97 -0
  74. package/src/orm/Typo/Adapter.d.ts +5 -0
  75. package/src/orm/Typo/DMLDriver.d.ts +260 -0
  76. package/src/orm/Typo/Db.d.ts +100 -0
  77. package/src/orm/Typo/Error.d.ts +36 -0
  78. package/src/orm/Typo/ORM.d.ts +315 -0
  79. package/src/orm/Typo/Validators.d.ts +39 -0
  80. package/src/orm/Typo/_common.d.ts +44 -0
  81. package/src/orm/Typo/assoc.d.ts +280 -0
  82. package/src/orm/Typo/hook.d.ts +68 -0
  83. package/src/orm/Typo/instance.d.ts +214 -0
  84. package/{lib → src}/orm/Typo/model.d.ts +297 -176
  85. package/src/orm/Typo/patch.d.ts +39 -0
  86. package/src/orm/Typo/property.d.ts +79 -0
  87. package/src/orm/Typo/query.d.ts +266 -0
  88. package/{lib → src}/orm/Typo/settings.d.ts +14 -7
  89. package/{lib → src}/orm/Typo/synchronous.d.ts +51 -26
  90. package/src/orm/Utilities.ts +1313 -0
  91. package/src/orm/Validators.ts +127 -0
  92. package/src/orm/Where/common.ts +8 -0
  93. package/src/orm/Where/filterDate.ts +74 -0
  94. package/src/orm/cloneDeep.ts +45 -0
  95. package/src/orm/index.ts +231 -0
  96. package/src/orm-core/callback.d.ts +15 -0
  97. package/{lib → src}/orm-core/dialect.d.ts +75 -52
  98. package/src/orm-core/error.ts +71 -0
  99. package/{lib/orm-core/index.d.ts → src/orm-core/index.ts} +8 -2
  100. package/src/orm-core/sync.d.ts +14 -0
  101. package/src/orm-core/utils.ts +4 -0
  102. package/src/orm-property/Property.ts +110 -0
  103. package/src/orm-property/Utils.ts +26 -0
  104. package/src/orm-property/customTypes.ts +13 -0
  105. package/src/orm-property/index.ts +34 -0
  106. package/src/orm-property/transformer.ts +16 -0
  107. package/{lib/orm-property/transformers/dm.js → src/orm-property/transformers/dm.ts} +128 -68
  108. package/src/orm-property/transformers/index.ts +10 -0
  109. package/src/orm-property/transformers/mssql.ts +285 -0
  110. package/src/orm-property/transformers/mysql.ts +395 -0
  111. package/src/orm-property/transformers/postgresql.ts +267 -0
  112. package/src/orm-property/transformers/sqlite.ts +217 -0
  113. package/src/plugins/orm-plugin-uacl/Typo.d.ts +173 -0
  114. package/src/plugins/orm-plugin-uacl/_utils.ts +237 -0
  115. package/src/plugins/orm-plugin-uacl/acl-tree.ts +440 -0
  116. package/src/plugins/orm-plugin-uacl/config-acl-tree.ts +592 -0
  117. package/src/plugins/orm-plugin-uacl/index.ts +180 -0
  118. package/src/plugins/orm-plugin-uacl/tree.ts +331 -0
  119. package/src/sql-ddl-sync/Dialects/dm.ts +493 -0
  120. package/{lib/sql-query/Dialects/index.d.ts → src/sql-ddl-sync/Dialects/index.ts} +3 -3
  121. package/src/sql-ddl-sync/Dialects/mssql.ts +441 -0
  122. package/src/sql-ddl-sync/Dialects/mysql.ts +414 -0
  123. package/src/sql-ddl-sync/Dialects/postgresql.ts +474 -0
  124. package/src/sql-ddl-sync/Dialects/sqlite.ts +439 -0
  125. package/src/sql-ddl-sync/SQL.ts +157 -0
  126. package/src/sql-ddl-sync/Typo/Collection.d.ts +19 -0
  127. package/src/sql-ddl-sync/Typo/DbIndex.d.ts +11 -0
  128. package/{lib → src}/sql-ddl-sync/Typo/Dialect.d.ts +67 -52
  129. package/src/sql-ddl-sync/Typo/Driver.d.ts +67 -0
  130. package/src/sql-ddl-sync/Typo/Query.d.ts +8 -0
  131. package/src/sql-ddl-sync/Typo/SQL.d.ts +45 -0
  132. package/src/sql-ddl-sync/Typo/_common.d.ts +59 -0
  133. package/src/sql-ddl-sync/Utils.ts +291 -0
  134. package/src/sql-ddl-sync/index.ts +599 -0
  135. package/src/sql-query/Comparators.ts +115 -0
  136. package/src/sql-query/Create.ts +87 -0
  137. package/{lib/sql-query/Dialects/dm.js → src/sql-query/Dialects/dm.ts} +42 -21
  138. package/src/sql-query/Dialects/index.ts +14 -0
  139. package/src/sql-query/Dialects/mssql.ts +91 -0
  140. package/src/sql-query/Dialects/mysql.ts +120 -0
  141. package/src/sql-query/Dialects/postgresql.ts +99 -0
  142. package/src/sql-query/Dialects/sqlite.ts +80 -0
  143. package/src/sql-query/Helpers.ts +303 -0
  144. package/src/sql-query/Insert.ts +41 -0
  145. package/src/sql-query/Query.ts +140 -0
  146. package/src/sql-query/Remove.ts +111 -0
  147. package/src/sql-query/Select.ts +719 -0
  148. package/src/sql-query/Set.ts +25 -0
  149. package/src/sql-query/Typo/Aggregation.d.ts +34 -0
  150. package/src/sql-query/Typo/Comparators.d.ts +156 -0
  151. package/src/sql-query/Typo/Dialect.d.ts +51 -0
  152. package/src/sql-query/Typo/Field.d.ts +10 -0
  153. package/src/sql-query/Typo/Helper.d.ts +4 -0
  154. package/src/sql-query/Typo/Query-ChainBuilder.d.ts +110 -0
  155. package/src/sql-query/Typo/Query.d.ts +65 -0
  156. package/src/sql-query/Typo/Sql.d.ts +192 -0
  157. package/src/sql-query/Typo/SubQuery.d.ts +52 -0
  158. package/{lib/sql-query/Typo/index.d.ts → src/sql-query/Typo/index.ts} +5 -2
  159. package/src/sql-query/Update.ts +50 -0
  160. package/src/sql-query/Where.ts +435 -0
  161. package/{lib/orm/Patch → src/typings}/fib-cache.d.ts +4 -3
  162. package/lib/cli/commands/ddlFrom.d.ts +0 -2
  163. package/lib/cli/commands/dumpModel.d.ts +0 -2
  164. package/lib/cli/commands/escape.d.ts +0 -2
  165. package/lib/cli/commands/spinner.d.ts +0 -2
  166. package/lib/cli/commands/upgrade.d.ts +0 -2
  167. package/lib/cli/helpers/ddl.d.ts +0 -17
  168. package/lib/cli/helpers/ddl.js +0 -55
  169. package/lib/cli/helpers/package.d.ts +0 -26
  170. package/lib/cli/helpers/package.js +0 -56
  171. package/lib/cli/index.d.ts +0 -2
  172. package/lib/cli/index.js +0 -18
  173. package/lib/db-driver/Typo.d.ts +0 -112
  174. package/lib/db-driver/Typo.js +0 -1
  175. package/lib/db-driver/built-ins/base.class.d.ts +0 -96
  176. package/lib/db-driver/built-ins/base.class.js +0 -186
  177. package/lib/db-driver/built-ins/driver-dm.d.ts +0 -18
  178. package/lib/db-driver/built-ins/driver-dm.js +0 -53
  179. package/lib/db-driver/built-ins/driver-mongodb.d.ts +0 -24
  180. package/lib/db-driver/built-ins/driver-mongodb.js +0 -46
  181. package/lib/db-driver/built-ins/driver-mysql.d.ts +0 -18
  182. package/lib/db-driver/built-ins/driver-mysql.js +0 -37
  183. package/lib/db-driver/built-ins/driver-postgresql.d.ts +0 -22
  184. package/lib/db-driver/built-ins/driver-postgresql.js +0 -76
  185. package/lib/db-driver/built-ins/driver-redis.d.ts +0 -12
  186. package/lib/db-driver/built-ins/driver-redis.js +0 -35
  187. package/lib/db-driver/built-ins/driver-sqlite.d.ts +0 -17
  188. package/lib/db-driver/built-ins/driver-sqlite.js +0 -34
  189. package/lib/db-driver/index.d.ts +0 -3
  190. package/lib/db-driver/index.js +0 -4
  191. package/lib/db-driver/utils.d.ts +0 -14
  192. package/lib/db-driver/utils.js +0 -187
  193. package/lib/knex/deps/tarn/dist/PendingOperation.d.ts +0 -12
  194. package/lib/knex/deps/tarn/dist/PendingOperation.js +0 -48
  195. package/lib/knex/deps/tarn/dist/Pool.d.ts +0 -97
  196. package/lib/knex/deps/tarn/dist/Pool.js +0 -516
  197. package/lib/knex/deps/tarn/dist/PromiseInspection.d.ts +0 -16
  198. package/lib/knex/deps/tarn/dist/PromiseInspection.js +0 -21
  199. package/lib/knex/deps/tarn/dist/Resource.d.ts +0 -9
  200. package/lib/knex/deps/tarn/dist/Resource.js +0 -19
  201. package/lib/knex/deps/tarn/dist/TimeoutError.d.ts +0 -2
  202. package/lib/knex/deps/tarn/dist/TimeoutError.js +0 -5
  203. package/lib/knex/deps/tarn/dist/tarn.d.ts +0 -3
  204. package/lib/knex/deps/tarn/dist/tarn.js +0 -10
  205. package/lib/knex/deps/tarn/dist/utils.d.ts +0 -14
  206. package/lib/knex/deps/tarn/dist/utils.js +0 -60
  207. package/lib/knex/knex.d.ts +0 -2
  208. package/lib/knex/knex.js +0 -3
  209. package/lib/knex/sandbox.d.ts +0 -4
  210. package/lib/knex/sandbox.js +0 -22
  211. package/lib/orm/Adapters.d.ts +0 -3
  212. package/lib/orm/Adapters.js +0 -44
  213. package/lib/orm/AggregateFunctions.d.ts +0 -3
  214. package/lib/orm/AggregateFunctions.js +0 -176
  215. package/lib/orm/Associations/Extend.d.ts +0 -22
  216. package/lib/orm/Associations/Extend.js +0 -274
  217. package/lib/orm/Associations/Many.d.ts +0 -17
  218. package/lib/orm/Associations/Many.js +0 -569
  219. package/lib/orm/Associations/One.d.ts +0 -16
  220. package/lib/orm/Associations/One.js +0 -310
  221. package/lib/orm/Associations/_utils.d.ts +0 -15
  222. package/lib/orm/Associations/_utils.js +0 -52
  223. package/lib/orm/ChainFind.d.ts +0 -3
  224. package/lib/orm/ChainFind.js +0 -327
  225. package/lib/orm/ChainInstance.d.ts +0 -6
  226. package/lib/orm/ChainInstance.js +0 -73
  227. package/lib/orm/Debug.d.ts +0 -2
  228. package/lib/orm/Debug.js +0 -17
  229. package/lib/orm/Drivers/DB/base.d.ts +0 -3
  230. package/lib/orm/Drivers/DB/base.js +0 -3
  231. package/lib/orm/Drivers/DB/dm.d.ts +0 -11
  232. package/lib/orm/Drivers/DB/dm.js +0 -23
  233. package/lib/orm/Drivers/DB/mysql.d.ts +0 -11
  234. package/lib/orm/Drivers/DB/mysql.js +0 -23
  235. package/lib/orm/Drivers/DB/postgres.d.ts +0 -11
  236. package/lib/orm/Drivers/DB/postgres.js +0 -22
  237. package/lib/orm/Drivers/DB/sqlite3.d.ts +0 -16
  238. package/lib/orm/Drivers/DB/sqlite3.js +0 -39
  239. package/lib/orm/Drivers/DML/_ddl-sql.d.ts +0 -3
  240. package/lib/orm/Drivers/DML/_ddl-sql.js +0 -51
  241. package/lib/orm/Drivers/DML/_dml-helpers.d.ts +0 -19
  242. package/lib/orm/Drivers/DML/_dml-helpers.js +0 -51
  243. package/lib/orm/Drivers/DML/_shared.d.ts +0 -9
  244. package/lib/orm/Drivers/DML/_shared.js +0 -38
  245. package/lib/orm/Drivers/DML/_utils.d.ts +0 -8
  246. package/lib/orm/Drivers/DML/_utils.js +0 -67
  247. package/lib/orm/Drivers/DML/constants.d.ts +0 -3
  248. package/lib/orm/Drivers/DML/constants.js +0 -2
  249. package/lib/orm/Drivers/DML/dm.d.ts +0 -2
  250. package/lib/orm/Drivers/DML/index.d.ts +0 -4
  251. package/lib/orm/Drivers/DML/index.js +0 -6
  252. package/lib/orm/Drivers/DML/mysql.d.ts +0 -2
  253. package/lib/orm/Drivers/DML/mysql.js +0 -251
  254. package/lib/orm/Drivers/DML/postgres.d.ts +0 -3
  255. package/lib/orm/Drivers/DML/postgres.js +0 -276
  256. package/lib/orm/Drivers/DML/sqlite.d.ts +0 -2
  257. package/lib/orm/Drivers/DML/sqlite.js +0 -266
  258. package/lib/orm/Error.d.ts +0 -11
  259. package/lib/orm/Error.js +0 -40
  260. package/lib/orm/Helpers.d.ts +0 -35
  261. package/lib/orm/Helpers.js +0 -233
  262. package/lib/orm/Hook.d.ts +0 -13
  263. package/lib/orm/Hook.js +0 -99
  264. package/lib/orm/Instance.d.ts +0 -2
  265. package/lib/orm/Instance.js +0 -697
  266. package/lib/orm/LazyLoad.d.ts +0 -4
  267. package/lib/orm/LazyLoad.js +0 -76
  268. package/lib/orm/Model.d.ts +0 -7
  269. package/lib/orm/Model.js +0 -971
  270. package/lib/orm/ORM.d.ts +0 -37
  271. package/lib/orm/ORM.js +0 -241
  272. package/lib/orm/Patch/fib-cache.js +0 -2
  273. package/lib/orm/Patch/plugin.d.ts +0 -4
  274. package/lib/orm/Patch/plugin.js +0 -13
  275. package/lib/orm/Property.d.ts +0 -9
  276. package/lib/orm/Property.js +0 -71
  277. package/lib/orm/Settings.d.ts +0 -42
  278. package/lib/orm/Settings.js +0 -119
  279. package/lib/orm/Singleton.d.ts +0 -5
  280. package/lib/orm/Singleton.js +0 -72
  281. package/lib/orm/Typo/Adapter.d.ts +0 -5
  282. package/lib/orm/Typo/Adapter.js +0 -1
  283. package/lib/orm/Typo/DMLDriver.d.ts +0 -210
  284. package/lib/orm/Typo/DMLDriver.js +0 -1
  285. package/lib/orm/Typo/Db.d.ts +0 -38
  286. package/lib/orm/Typo/Db.js +0 -1
  287. package/lib/orm/Typo/Error.d.ts +0 -31
  288. package/lib/orm/Typo/Error.js +0 -1
  289. package/lib/orm/Typo/ORM.d.ts +0 -233
  290. package/lib/orm/Typo/ORM.js +0 -3
  291. package/lib/orm/Typo/Validators.d.ts +0 -32
  292. package/lib/orm/Typo/Validators.js +0 -2
  293. package/lib/orm/Typo/_common.d.ts +0 -38
  294. package/lib/orm/Typo/_common.js +0 -1
  295. package/lib/orm/Typo/assoc.d.ts +0 -221
  296. package/lib/orm/Typo/assoc.js +0 -1
  297. package/lib/orm/Typo/hook.d.ts +0 -42
  298. package/lib/orm/Typo/hook.js +0 -1
  299. package/lib/orm/Typo/instance.d.ts +0 -157
  300. package/lib/orm/Typo/instance.js +0 -1
  301. package/lib/orm/Typo/model.js +0 -6
  302. package/lib/orm/Typo/patch.d.ts +0 -31
  303. package/lib/orm/Typo/patch.js +0 -1
  304. package/lib/orm/Typo/property.d.ts +0 -57
  305. package/lib/orm/Typo/property.js +0 -1
  306. package/lib/orm/Typo/query.d.ts +0 -216
  307. package/lib/orm/Typo/query.js +0 -1
  308. package/lib/orm/Typo/settings.js +0 -5
  309. package/lib/orm/Typo/synchronous.js +0 -1
  310. package/lib/orm/Utilities.d.ts +0 -179
  311. package/lib/orm/Utilities.js +0 -975
  312. package/lib/orm/Validators.d.ts +0 -34
  313. package/lib/orm/Validators.js +0 -100
  314. package/lib/orm/Where/common.d.ts +0 -1
  315. package/lib/orm/Where/common.js +0 -7
  316. package/lib/orm/Where/filterDate.d.ts +0 -11
  317. package/lib/orm/Where/filterDate.js +0 -58
  318. package/lib/orm/index.d.ts +0 -68
  319. package/lib/orm/index.js +0 -157
  320. package/lib/orm-core/callback.d.ts +0 -12
  321. package/lib/orm-core/callback.js +0 -1
  322. package/lib/orm-core/dialect.js +0 -1
  323. package/lib/orm-core/error.d.ts +0 -16
  324. package/lib/orm-core/error.js +0 -29
  325. package/lib/orm-core/index.js +0 -6
  326. package/lib/orm-core/sync.d.ts +0 -12
  327. package/lib/orm-core/sync.js +0 -1
  328. package/lib/orm-core/utils.d.ts +0 -1
  329. package/lib/orm-core/utils.js +0 -5
  330. package/lib/orm-property/Property.d.ts +0 -78
  331. package/lib/orm-property/Property.js +0 -1
  332. package/lib/orm-property/Utils.d.ts +0 -9
  333. package/lib/orm-property/Utils.js +0 -13
  334. package/lib/orm-property/customTypes.d.ts +0 -2
  335. package/lib/orm-property/customTypes.js +0 -13
  336. package/lib/orm-property/index.d.ts +0 -10
  337. package/lib/orm-property/index.js +0 -22
  338. package/lib/orm-property/transformer.d.ts +0 -5
  339. package/lib/orm-property/transformer.js +0 -10
  340. package/lib/orm-property/transformers/dm.d.ts +0 -29
  341. package/lib/orm-property/transformers/index.d.ts +0 -4
  342. package/lib/orm-property/transformers/index.js +0 -5
  343. package/lib/orm-property/transformers/mysql.d.ts +0 -102
  344. package/lib/orm-property/transformers/mysql.js +0 -261
  345. package/lib/orm-property/transformers/postgresql.d.ts +0 -54
  346. package/lib/orm-property/transformers/postgresql.js +0 -189
  347. package/lib/orm-property/transformers/sqlite.d.ts +0 -19
  348. package/lib/orm-property/transformers/sqlite.js +0 -171
  349. package/lib/sql-ddl-sync/Dialects/dm.d.ts +0 -40
  350. package/lib/sql-ddl-sync/Dialects/dm.js +0 -296
  351. package/lib/sql-ddl-sync/Dialects/index.d.ts +0 -7
  352. package/lib/sql-ddl-sync/Dialects/index.js +0 -7
  353. package/lib/sql-ddl-sync/Dialects/mysql.d.ts +0 -39
  354. package/lib/sql-ddl-sync/Dialects/mysql.js +0 -240
  355. package/lib/sql-ddl-sync/Dialects/postgresql.d.ts +0 -40
  356. package/lib/sql-ddl-sync/Dialects/postgresql.js +0 -286
  357. package/lib/sql-ddl-sync/Dialects/sqlite.d.ts +0 -44
  358. package/lib/sql-ddl-sync/Dialects/sqlite.js +0 -256
  359. package/lib/sql-ddl-sync/SQL.d.ts +0 -12
  360. package/lib/sql-ddl-sync/SQL.js +0 -108
  361. package/lib/sql-ddl-sync/Typo/Collection.d.ts +0 -13
  362. package/lib/sql-ddl-sync/Typo/Collection.js +0 -1
  363. package/lib/sql-ddl-sync/Typo/DbIndex.d.ts +0 -13
  364. package/lib/sql-ddl-sync/Typo/DbIndex.js +0 -1
  365. package/lib/sql-ddl-sync/Typo/Dialect.js +0 -1
  366. package/lib/sql-ddl-sync/Typo/Driver.d.ts +0 -53
  367. package/lib/sql-ddl-sync/Typo/Driver.js +0 -1
  368. package/lib/sql-ddl-sync/Typo/Query.d.ts +0 -7
  369. package/lib/sql-ddl-sync/Typo/Query.js +0 -1
  370. package/lib/sql-ddl-sync/Typo/SQL.d.ts +0 -31
  371. package/lib/sql-ddl-sync/Typo/SQL.js +0 -1
  372. package/lib/sql-ddl-sync/Typo/_common.d.ts +0 -29
  373. package/lib/sql-ddl-sync/Typo/_common.js +0 -1
  374. package/lib/sql-ddl-sync/Utils.d.ts +0 -40
  375. package/lib/sql-ddl-sync/Utils.js +0 -217
  376. package/lib/sql-ddl-sync/index.d.ts +0 -87
  377. package/lib/sql-ddl-sync/index.js +0 -371
  378. package/lib/sql-query/Comparators.d.ts +0 -3
  379. package/lib/sql-query/Comparators.js +0 -94
  380. package/lib/sql-query/Create.d.ts +0 -35
  381. package/lib/sql-query/Create.js +0 -77
  382. package/lib/sql-query/Dialects/dm.d.ts +0 -3
  383. package/lib/sql-query/Dialects/index.js +0 -12
  384. package/lib/sql-query/Dialects/mssql.d.ts +0 -3
  385. package/lib/sql-query/Dialects/mssql.js +0 -73
  386. package/lib/sql-query/Dialects/mysql.d.ts +0 -3
  387. package/lib/sql-query/Dialects/mysql.js +0 -100
  388. package/lib/sql-query/Dialects/postgresql.d.ts +0 -3
  389. package/lib/sql-query/Dialects/postgresql.js +0 -76
  390. package/lib/sql-query/Dialects/sqlite.d.ts +0 -3
  391. package/lib/sql-query/Dialects/sqlite.js +0 -61
  392. package/lib/sql-query/Helpers.d.ts +0 -38
  393. package/lib/sql-query/Helpers.js +0 -259
  394. package/lib/sql-query/Insert.d.ts +0 -12
  395. package/lib/sql-query/Insert.js +0 -33
  396. package/lib/sql-query/Query.d.ts +0 -29
  397. package/lib/sql-query/Query.js +0 -119
  398. package/lib/sql-query/Remove.d.ts +0 -16
  399. package/lib/sql-query/Remove.js +0 -93
  400. package/lib/sql-query/Select.d.ts +0 -62
  401. package/lib/sql-query/Select.js +0 -533
  402. package/lib/sql-query/Set.d.ts +0 -4
  403. package/lib/sql-query/Set.js +0 -16
  404. package/lib/sql-query/Typo/Aggregation.d.ts +0 -32
  405. package/lib/sql-query/Typo/Aggregation.js +0 -1
  406. package/lib/sql-query/Typo/Comparators.d.ts +0 -140
  407. package/lib/sql-query/Typo/Comparators.js +0 -1
  408. package/lib/sql-query/Typo/Dialect.d.ts +0 -39
  409. package/lib/sql-query/Typo/Dialect.js +0 -1
  410. package/lib/sql-query/Typo/Field.d.ts +0 -8
  411. package/lib/sql-query/Typo/Field.js +0 -1
  412. package/lib/sql-query/Typo/Helper.d.ts +0 -4
  413. package/lib/sql-query/Typo/Helper.js +0 -1
  414. package/lib/sql-query/Typo/Query-ChainBuilder.d.ts +0 -80
  415. package/lib/sql-query/Typo/Query-ChainBuilder.js +0 -1
  416. package/lib/sql-query/Typo/Query.d.ts +0 -34
  417. package/lib/sql-query/Typo/Query.js +0 -16
  418. package/lib/sql-query/Typo/Sql.d.ts +0 -143
  419. package/lib/sql-query/Typo/Sql.js +0 -1
  420. package/lib/sql-query/Typo/SubQuery.d.ts +0 -39
  421. package/lib/sql-query/Typo/SubQuery.js +0 -1
  422. package/lib/sql-query/Typo/index.js +0 -1
  423. package/lib/sql-query/Update.d.ts +0 -15
  424. package/lib/sql-query/Update.js +0 -38
  425. package/lib/sql-query/Where.d.ts +0 -4
  426. package/lib/sql-query/Where.js +0 -280
  427. /package/{lib → src}/codepoints-map.json +0 -0
@@ -1,310 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.autoFetch = exports.extend = exports.prepare = void 0;
3
- const util = require("util");
4
- const Hook = require("../Hook");
5
- const Utilities = require("../Utilities");
6
- const Error_1 = require("../Error");
7
- const _utils_1 = require("./_utils");
8
- const Model_1 = require("../Model");
9
- const Helpers = require("../Helpers");
10
- function noOperation(...args) { }
11
- ;
12
- function prepare(Model, assocs, opts) {
13
- const { one_associations } = assocs;
14
- const { db } = opts;
15
- Model.hasOne = function (assoc_name, ext_model, assoc_options) {
16
- Utilities.disAllowOpForVModel(Model, 'model.hasOne');
17
- if (arguments[1] && !arguments[1].table) {
18
- assoc_options = arguments[1];
19
- ext_model = arguments[1] = null;
20
- }
21
- ext_model = ext_model || Model;
22
- assoc_name = assoc_name || ext_model.table;
23
- assoc_options = Object.assign({}, assoc_options);
24
- if (!assoc_name) {
25
- throw new Error(`[hasOne] association's name is required!`);
26
- }
27
- else if (typeof assoc_name !== 'string') {
28
- throw new Error(`[hasOne] association's name must be string!`);
29
- }
30
- Utilities.disAllowOpForVModel(ext_model, 'associated by model.hasOne');
31
- for (let i = 0; i < db.plugins.length; i++) {
32
- if (typeof db.plugins[i].beforeHasOne === "function") {
33
- db.plugins[i].beforeHasOne(Model, {
34
- association_name: assoc_name,
35
- ext_model: ext_model,
36
- assoc_options
37
- });
38
- }
39
- }
40
- const associationSemanticNameCore = Utilities.formatNameFor("assoc:hasOne", assoc_name);
41
- const association = Object.assign(Object.assign({ name: assoc_name, model: ext_model, field: null, reversed: false, __for_extension: false, autoFetch: false, autoFetchLimit: 2, required: false, setAccessor: _utils_1.ACCESSOR_KEYS.set + associationSemanticNameCore, getAccessor: _utils_1.ACCESSOR_KEYS.get + associationSemanticNameCore, hasAccessor: _utils_1.ACCESSOR_KEYS.has + associationSemanticNameCore, delAccessor: null, modelFindByAccessor: assoc_options.modelFindByAccessor || (_utils_1.ACCESSOR_KEYS.modelFindBy + associationSemanticNameCore) }, assoc_options), { hooks: Object.assign({}, assoc_options.hooks) });
42
- if (!association.reversed)
43
- association.delAccessor = _utils_1.ACCESSOR_KEYS['del'] + associationSemanticNameCore;
44
- Utilities.fillSyncVersionAccessorForAssociation(association);
45
- Utilities.addHookPatchHelperForAssociation(association);
46
- if (!association.field) {
47
- association.field = Utilities.formatAssociatedField(association.model, association.name, association.required, association.reversed);
48
- }
49
- else if (!association.__for_extension) {
50
- association.field = Utilities.wrapFieldObject({
51
- field: association.field, model: Model, altName: Model.table,
52
- mapsTo: association.mapsTo
53
- });
54
- }
55
- const normalizedField = association.field;
56
- Utilities.convertPropToJoinKeyProp(normalizedField, { makeKey: false, required: association.required });
57
- one_associations.push(association);
58
- for (let k in normalizedField) {
59
- if (!normalizedField.hasOwnProperty(k)) {
60
- continue;
61
- }
62
- if (!association.reversed && !association.__for_extension) {
63
- Model.addProperty(util.extend({}, normalizedField[k], { klass: 'hasOne' }), false);
64
- }
65
- }
66
- if (association.reverse) {
67
- association.model.hasOne(association.reverse, Model, {
68
- reversed: true,
69
- accessor: association.reverseAccessor,
70
- reverseAccessor: undefined,
71
- field: normalizedField,
72
- autoFetch: association.autoFetch,
73
- autoFetchLimit: association.autoFetchLimit,
74
- hooks: assoc_options.reverseHooks
75
- });
76
- }
77
- const findByAccessorChainOrRunSync = function (is_sync = false) {
78
- return function () {
79
- var cb = null, conditions = null, options = {};
80
- Helpers.selectArgs(arguments, (arg_type, arg) => {
81
- switch (arg_type) {
82
- case "function":
83
- cb = arg;
84
- break;
85
- case "object":
86
- if (conditions === null) {
87
- conditions = arg;
88
- }
89
- else {
90
- options = arg;
91
- }
92
- break;
93
- }
94
- });
95
- if (conditions === null) {
96
- throw new Error_1.default(`.${association.modelFindByAccessor}() is missing a conditions object`, 'PARAM_MISMATCH');
97
- }
98
- return (0, Model_1.listFindByChainOrRunSync)(Model, {}, [
99
- {
100
- association_name: association.name,
101
- conditions: conditions
102
- },
103
- ], options, { callback: cb, is_sync });
104
- };
105
- };
106
- Model[association.modelFindByAccessor] = findByAccessorChainOrRunSync();
107
- Model[association.modelFindBySyncAccessor] = findByAccessorChainOrRunSync(true);
108
- (0, _utils_1.addAssociationInfoToModel)(Model, assoc_name, {
109
- type: 'hasOne',
110
- association
111
- });
112
- return this;
113
- };
114
- }
115
- exports.prepare = prepare;
116
- ;
117
- function extend(Model, Instance, Driver,
118
- // extend target
119
- associations, cfg) {
120
- for (let i = 0; i < associations.length; i++) {
121
- extendInstance(Model, Instance, Driver, associations[i], cfg);
122
- }
123
- }
124
- exports.extend = extend;
125
- ;
126
- function autoFetch(Instance, associations, opts, parallel) {
127
- if (associations.length === 0)
128
- return;
129
- Utilities.parallelQueryIfPossible(parallel, associations, (item) => autoFetchInstance(Instance, item, opts));
130
- }
131
- exports.autoFetch = autoFetch;
132
- ;
133
- function extendInstance(Model, Instance, Driver,
134
- // extend target
135
- association, cfg) {
136
- Utilities.addHiddenUnwritableMethodToInstance(Instance, association.hasSyncAccessor, function (_has_opts) {
137
- if (!Utilities.hasValues(Instance, Object.keys(association.field)))
138
- return false;
139
- try {
140
- const instance = association.model.getSync(Utilities.values(Instance, Object.keys(association.field)), _has_opts);
141
- return !!instance;
142
- }
143
- catch (error) {
144
- return false;
145
- }
146
- });
147
- Utilities.addHiddenUnwritableMethodToInstance(Instance, association.hasAccessor, function (_has_opts, cb) {
148
- if (typeof _has_opts === "function") {
149
- cb = _has_opts;
150
- _has_opts = {};
151
- }
152
- process.nextTick(() => {
153
- const syncResponse = Utilities.catchBlocking(Instance[association.hasSyncAccessor], [_has_opts]);
154
- Utilities.takeAwayResult(syncResponse, { no_throw: true, callback: cb });
155
- });
156
- return this;
157
- });
158
- const getAccessorChainOrRunSync = function (opts = {}, withOutCallbackWhenNonSync) {
159
- const saveAndReturn = function (Assoc) {
160
- Instance[association.name] = Assoc;
161
- return Assoc;
162
- };
163
- let result;
164
- // process get reversed instance's original instance
165
- if (association.reversed) {
166
- let reverseHostInstances = null;
167
- if (Utilities.hasValues(Instance, Model.id)) {
168
- const query_conds = Utilities.getConditions(Model, Object.keys(association.field), Instance);
169
- if (withOutCallbackWhenNonSync) {
170
- return association.model.find.call(association.model, query_conds, opts);
171
- }
172
- reverseHostInstances = association.model.findSync(query_conds, opts);
173
- result = saveAndReturn(reverseHostInstances);
174
- }
175
- return result;
176
- }
177
- let assocInstance = null;
178
- if (Instance.isShell()) {
179
- Instance = Model.getSync(Utilities.values(Instance, Model.id));
180
- if (!Utilities.hasValues(Instance, Object.keys(association.field)))
181
- return;
182
- assocInstance = association.model.getSync(Utilities.values(Instance, Object.keys(association.field)), opts);
183
- return saveAndReturn(assocInstance);
184
- }
185
- if (Utilities.hasValues(Instance, Object.keys(association.field))) {
186
- assocInstance = association.model.getSync(Utilities.values(Instance, Object.keys(association.field)), opts);
187
- return saveAndReturn(assocInstance);
188
- }
189
- };
190
- Utilities.addHiddenUnwritableMethodToInstance(Instance, association.getSyncAccessor, function (opts = {}) {
191
- return getAccessorChainOrRunSync(opts, false);
192
- });
193
- Utilities.addHiddenUnwritableMethodToInstance(Instance, association.getAccessor, function (opts, cb) {
194
- if (typeof opts === "function") {
195
- cb = opts;
196
- opts = {};
197
- }
198
- const withCallback = typeof cb === 'function';
199
- if (withCallback) {
200
- process.nextTick(() => {
201
- const syncResponse = Utilities.catchBlocking(getAccessorChainOrRunSync, [opts, !withCallback]);
202
- Utilities.takeAwayResult(syncResponse, { no_throw: true, callback: cb });
203
- });
204
- return this;
205
- }
206
- return getAccessorChainOrRunSync(opts, !withCallback);
207
- });
208
- Utilities.addHiddenUnwritableMethodToInstance(Instance, association.setSyncAccessor, function (OtherInstance) {
209
- const inst_arr = Array.isArray(OtherInstance) ? Array.from(OtherInstance) : [OtherInstance];
210
- let results = [];
211
- let hookHandlr = null;
212
- const $ref = {
213
- instance: Instance,
214
- association: association.reversed ? null : OtherInstance,
215
- associations: association.reversed ? inst_arr : null,
216
- useChannel: Utilities.reusableChannelGenerator()
217
- };
218
- if (association.reversed) {
219
- hookHandlr = Utilities.makeHandlerDecorator({ thisArg: Instance }, () => {
220
- Instance.saveSync();
221
- const runReversed = function (other) {
222
- Instance.$emit(`before:set:${association.name}`, other);
223
- Utilities.populateModelIdKeysConditions(Model, Object.keys(association.field), Instance, other, true);
224
- // link
225
- other.saveSync({}, { saveAssociations: false });
226
- Instance.$emit(`after:set:${association.name}`, other);
227
- return other;
228
- };
229
- results = Utilities.parallelQueryIfPossible(false, $ref.associations, runReversed);
230
- });
231
- }
232
- else {
233
- hookHandlr = Utilities.makeHandlerDecorator({ thisArg: Instance }, () => {
234
- const runNonReversed = function (oinst) {
235
- Instance.$emit(`before:set:${association.name}`, oinst);
236
- oinst.saveSync({}, { saveAssociations: false });
237
- Instance[association.name] = oinst;
238
- // TODO: on pre normalize stage, record linked associated key property name on build association
239
- // const idInHostSide = Object.keys(association.field)[0];
240
- // const idInOtherSide = association.model.keys[0];
241
- // Instance[idInHostSide] = oinst[idInOtherSide];
242
- Utilities.populateModelIdKeysConditions(association.model, Object.keys(association.field), oinst, Instance);
243
- Instance.$emit(`after:set:${association.name}`, oinst);
244
- return oinst;
245
- };
246
- results = runNonReversed($ref.association);
247
- // link
248
- Instance.saveSync({}, { saveAssociations: false });
249
- });
250
- }
251
- Hook.wait(Instance, association.hooks[`beforeSet`], hookHandlr, Utilities.buildAssocHooksContext('beforeSet', { $ref }));
252
- Hook.trigger(Instance, association.hooks['afterSet'], Utilities.buildAssocHooksContext('afterSet', { $ref }));
253
- return results;
254
- });
255
- Utilities.addHiddenUnwritableMethodToInstance(Instance, association.setAccessor, function (OtherInstance, cb) {
256
- process.nextTick(() => {
257
- const syncResponse = Utilities.catchBlocking(Instance[association.setSyncAccessor], [OtherInstance]);
258
- Utilities.takeAwayResult(syncResponse, { no_throw: true, callback: cb });
259
- });
260
- return this;
261
- });
262
- // only non-reversed could delete associated instance
263
- if (!association.reversed && !association.__for_extension) {
264
- Utilities.addHiddenUnwritableMethodToInstance(Instance, association.delSyncAccessor, function () {
265
- const $ref = {
266
- instance: Instance,
267
- useChannel: Utilities.reusableChannelGenerator()
268
- };
269
- Hook.wait(Instance, association.hooks[`beforeRemove`], Utilities.makeHandlerDecorator({ thisArg: Instance }, () => {
270
- Instance.$emit(`before:del:${association.name}`);
271
- for (let k in association.field) {
272
- if (association.field.hasOwnProperty(k)) {
273
- Instance[k] = null;
274
- }
275
- }
276
- Instance.saveSync({}, { saveAssociations: false });
277
- delete Instance[association.name];
278
- Instance.$emit(`after:del:${association.name}`);
279
- }), Utilities.buildAssocHooksContext('beforeRemove', { $ref }));
280
- Hook.trigger(Instance, association.hooks['afterRemove'], Utilities.buildAssocHooksContext('afterRemove', { $ref }));
281
- return this;
282
- }, {});
283
- Utilities.addHiddenUnwritableMethodToInstance(Instance, association.delAccessor, function (cb) {
284
- process.nextTick(() => {
285
- const syncResponse = Utilities.catchBlocking(Instance[association.delSyncAccessor]);
286
- Utilities.takeAwayResult(syncResponse, { no_throw: true, callback: cb });
287
- });
288
- return this;
289
- });
290
- }
291
- }
292
- function autoFetchInstance(Instance, association, opts) {
293
- if (!Instance.saved())
294
- return;
295
- if (!opts.hasOwnProperty("autoFetchLimit") || typeof opts.autoFetchLimit === "undefined") {
296
- opts.autoFetchLimit = association.autoFetchLimit;
297
- }
298
- if (opts.autoFetchLimit === 0 || (!opts.autoFetch && !association.autoFetch))
299
- return;
300
- /**
301
- * When we have a new non persisted instance for which the association field (eg owner_id)
302
- * is set, we don't want to auto fetch anything, since `new Model(owner_id: 12)` takes no
303
- * callback, and hence this lookup would complete at an arbitrary point in the future.
304
- * The associated entity should probably be fetched when the instance is persisted.
305
- */
306
- if (Instance.isPersisted()) {
307
- Instance[association.getSyncAccessor]({ autoFetchLimit: opts.autoFetchLimit - 1 });
308
- }
309
- return;
310
- }
@@ -1,15 +0,0 @@
1
- /// <reference lib="es6" />
2
- import type { FxOrmAssociation } from "../Typo/assoc";
3
- import type { FxOrmModel } from "../Typo/model";
4
- import type { FxOrmProperty } from "../Typo/property";
5
- export declare function defineDefaultExtendsToTableName(modelTableName: string, assocName: string): string;
6
- type ACCESSOR_PREFIX = 'add' | 'get' | 'set' | 'has' | 'remove' | 'findBy';
7
- export declare function defineAssociationAccessorMethodName(prefixer: ACCESSOR_PREFIX, assocName: string): string;
8
- export declare const ACCESSOR_KEYS: {
9
- [k: string]: ACCESSOR_PREFIX;
10
- };
11
- export declare function getMapsToFromProperty(property: FxOrmProperty.NormalizedProperty, k: string): string;
12
- export declare function getMapsToFromPropertyHash(hash: Record<string, FxOrmProperty.NormalizedProperty>): string[];
13
- export declare function cutOffAssociatedModelFindOptions(findby_options: FxOrmAssociation.ModelAssociationMethod__FindByOptions, association_name: string): any;
14
- export declare function addAssociationInfoToModel(Model: FxOrmModel.Model, association_name: string, opts: FxOrmModel.Model['associations'][any]): FxOrmModel.Model['associations'][string];
15
- export {};
@@ -1,52 +0,0 @@
1
- /// <reference lib="es6" />
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addAssociationInfoToModel = exports.cutOffAssociatedModelFindOptions = exports.getMapsToFromPropertyHash = exports.getMapsToFromProperty = exports.ACCESSOR_KEYS = exports.defineAssociationAccessorMethodName = exports.defineDefaultExtendsToTableName = void 0;
4
- function defineDefaultExtendsToTableName(modelTableName, assocName) {
5
- return `${modelTableName}_${assocName}`;
6
- }
7
- exports.defineDefaultExtendsToTableName = defineDefaultExtendsToTableName;
8
- function defineAssociationAccessorMethodName(prefixer, assocName) {
9
- return `${prefixer}${assocName}`;
10
- }
11
- exports.defineAssociationAccessorMethodName = defineAssociationAccessorMethodName;
12
- exports.ACCESSOR_KEYS = {
13
- /* common :start */
14
- "get": "get",
15
- "set": "set",
16
- "has": "has",
17
- "del": "remove",
18
- "modelFindBy": "findBy",
19
- /* common :end */
20
- // useful for association `hasMany`
21
- "add": "add",
22
- };
23
- function getMapsToFromProperty(property, k) {
24
- return property.mapsTo || k;
25
- }
26
- exports.getMapsToFromProperty = getMapsToFromProperty;
27
- function getMapsToFromPropertyHash(hash) {
28
- return Object.keys(hash).map(k => {
29
- const item = hash[k];
30
- return item.mapsTo || k;
31
- });
32
- }
33
- exports.getMapsToFromPropertyHash = getMapsToFromPropertyHash;
34
- function cutOffAssociatedModelFindOptions(findby_options, association_name) {
35
- let opts = null;
36
- const k = `find_options:${association_name}`;
37
- if (findby_options.hasOwnProperty(k)) {
38
- opts = findby_options[k];
39
- delete findby_options[k];
40
- }
41
- return;
42
- return opts;
43
- }
44
- exports.cutOffAssociatedModelFindOptions = cutOffAssociatedModelFindOptions;
45
- function addAssociationInfoToModel(Model, association_name, opts) {
46
- Model.associations[association_name] = {
47
- type: opts.type,
48
- association: opts.association
49
- };
50
- return Model.associations[association_name];
51
- }
52
- exports.addAssociationInfoToModel = addAssociationInfoToModel;
@@ -1,3 +0,0 @@
1
- import type { FxOrmQuery } from './Typo/query';
2
- declare const ChainFind: FxOrmQuery.ChainFindGenerator;
3
- export = ChainFind;