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.
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 +37 -34
  5. package/{lib/cli/commands/ddlFrom.js → src/cli/commands/ddlFrom.ts} +40 -27
  6. package/{lib/cli/commands/dumpModel.js → src/cli/commands/dumpModel.ts} +78 -32
  7. package/{lib/cli/commands/escape.js → src/cli/commands/escape.ts} +51 -29
  8. package/{lib/cli/commands/spinner.js → src/cli/commands/spinner.ts} +20 -11
  9. package/{lib/cli/commands/upgrade.js → src/cli/commands/upgrade.ts} +53 -34
  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 -86
  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 -174
  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 -69
  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 -22
  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 -2
  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 -25
  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 -19
  173. package/lib/db-driver/Typo.d.ts +0 -111
  174. package/lib/db-driver/Typo.js +0 -2
  175. package/lib/db-driver/built-ins/base.class.d.ts +0 -91
  176. package/lib/db-driver/built-ins/base.class.js +0 -187
  177. package/lib/db-driver/built-ins/driver-dm.d.ts +0 -17
  178. package/lib/db-driver/built-ins/driver-dm.js +0 -54
  179. package/lib/db-driver/built-ins/driver-mongodb.d.ts +0 -23
  180. package/lib/db-driver/built-ins/driver-mongodb.js +0 -47
  181. package/lib/db-driver/built-ins/driver-mysql.d.ts +0 -17
  182. package/lib/db-driver/built-ins/driver-mysql.js +0 -38
  183. package/lib/db-driver/built-ins/driver-postgresql.d.ts +0 -21
  184. package/lib/db-driver/built-ins/driver-postgresql.js +0 -77
  185. package/lib/db-driver/built-ins/driver-redis.d.ts +0 -11
  186. package/lib/db-driver/built-ins/driver-redis.js +0 -36
  187. package/lib/db-driver/built-ins/driver-sqlite.d.ts +0 -16
  188. package/lib/db-driver/built-ins/driver-sqlite.js +0 -35
  189. package/lib/db-driver/index.d.ts +0 -3
  190. package/lib/db-driver/index.js +0 -5
  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 -4
  209. package/lib/knex/sandbox.d.ts +0 -4
  210. package/lib/knex/sandbox.js +0 -23
  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 -177
  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 -16
  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 -14
  222. package/lib/orm/Associations/_utils.js +0 -53
  223. package/lib/orm/ChainFind.d.ts +0 -3
  224. package/lib/orm/ChainFind.js +0 -328
  225. package/lib/orm/ChainInstance.d.ts +0 -6
  226. package/lib/orm/ChainInstance.js +0 -74
  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 -2
  230. package/lib/orm/Drivers/DB/base.js +0 -4
  231. package/lib/orm/Drivers/DB/dm.d.ts +0 -9
  232. package/lib/orm/Drivers/DB/dm.js +0 -24
  233. package/lib/orm/Drivers/DB/mysql.d.ts +0 -9
  234. package/lib/orm/Drivers/DB/mysql.js +0 -24
  235. package/lib/orm/Drivers/DB/postgres.d.ts +0 -9
  236. package/lib/orm/Drivers/DB/postgres.js +0 -23
  237. package/lib/orm/Drivers/DB/sqlite3.d.ts +0 -14
  238. package/lib/orm/Drivers/DB/sqlite3.js +0 -40
  239. package/lib/orm/Drivers/DML/_ddl-sql.d.ts +0 -3
  240. package/lib/orm/Drivers/DML/_ddl-sql.js +0 -52
  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 -39
  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 -3
  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 -7
  252. package/lib/orm/Drivers/DML/mysql.d.ts +0 -2
  253. package/lib/orm/Drivers/DML/mysql.js +0 -252
  254. package/lib/orm/Drivers/DML/postgres.d.ts +0 -2
  255. package/lib/orm/Drivers/DML/postgres.js +0 -277
  256. package/lib/orm/Drivers/DML/sqlite.d.ts +0 -2
  257. package/lib/orm/Drivers/DML/sqlite.js +0 -267
  258. package/lib/orm/Error.d.ts +0 -11
  259. package/lib/orm/Error.js +0 -41
  260. package/lib/orm/Helpers.d.ts +0 -35
  261. package/lib/orm/Helpers.js +0 -234
  262. package/lib/orm/Hook.d.ts +0 -13
  263. package/lib/orm/Hook.js +0 -100
  264. package/lib/orm/Instance.d.ts +0 -2
  265. package/lib/orm/Instance.js +0 -698
  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 -6
  269. package/lib/orm/Model.js +0 -974
  270. package/lib/orm/ORM.d.ts +0 -37
  271. package/lib/orm/ORM.js +0 -242
  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 -14
  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 -120
  279. package/lib/orm/Singleton.d.ts +0 -5
  280. package/lib/orm/Singleton.js +0 -73
  281. package/lib/orm/Typo/Adapter.d.ts +0 -5
  282. package/lib/orm/Typo/Adapter.js +0 -2
  283. package/lib/orm/Typo/DMLDriver.d.ts +0 -209
  284. package/lib/orm/Typo/DMLDriver.js +0 -2
  285. package/lib/orm/Typo/Db.d.ts +0 -35
  286. package/lib/orm/Typo/Db.js +0 -2
  287. package/lib/orm/Typo/Error.d.ts +0 -29
  288. package/lib/orm/Typo/Error.js +0 -2
  289. package/lib/orm/Typo/ORM.d.ts +0 -231
  290. package/lib/orm/Typo/ORM.js +0 -4
  291. package/lib/orm/Typo/Validators.d.ts +0 -31
  292. package/lib/orm/Typo/Validators.js +0 -3
  293. package/lib/orm/Typo/_common.d.ts +0 -37
  294. package/lib/orm/Typo/_common.js +0 -2
  295. package/lib/orm/Typo/assoc.d.ts +0 -221
  296. package/lib/orm/Typo/assoc.js +0 -2
  297. package/lib/orm/Typo/hook.d.ts +0 -42
  298. package/lib/orm/Typo/hook.js +0 -2
  299. package/lib/orm/Typo/instance.d.ts +0 -156
  300. package/lib/orm/Typo/instance.js +0 -2
  301. package/lib/orm/Typo/model.js +0 -7
  302. package/lib/orm/Typo/patch.d.ts +0 -31
  303. package/lib/orm/Typo/patch.js +0 -2
  304. package/lib/orm/Typo/property.d.ts +0 -57
  305. package/lib/orm/Typo/property.js +0 -2
  306. package/lib/orm/Typo/query.d.ts +0 -216
  307. package/lib/orm/Typo/query.js +0 -2
  308. package/lib/orm/Typo/settings.js +0 -6
  309. package/lib/orm/Typo/synchronous.js +0 -2
  310. package/lib/orm/Utilities.d.ts +0 -178
  311. package/lib/orm/Utilities.js +0 -975
  312. package/lib/orm/Validators.d.ts +0 -33
  313. package/lib/orm/Validators.js +0 -101
  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 -67
  319. package/lib/orm/index.js +0 -158
  320. package/lib/orm-core/callback.d.ts +0 -12
  321. package/lib/orm-core/callback.js +0 -2
  322. package/lib/orm-core/dialect.js +0 -2
  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 -7
  326. package/lib/orm-core/sync.d.ts +0 -12
  327. package/lib/orm-core/sync.js +0 -2
  328. package/lib/orm-core/utils.d.ts +0 -1
  329. package/lib/orm-core/utils.js +0 -6
  330. package/lib/orm-property/Property.d.ts +0 -78
  331. package/lib/orm-property/Property.js +0 -2
  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 -23
  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 -6
  343. package/lib/orm-property/transformers/mysql.d.ts +0 -101
  344. package/lib/orm-property/transformers/mysql.js +0 -262
  345. package/lib/orm-property/transformers/postgresql.d.ts +0 -54
  346. package/lib/orm-property/transformers/postgresql.js +0 -190
  347. package/lib/orm-property/transformers/sqlite.d.ts +0 -19
  348. package/lib/orm-property/transformers/sqlite.js +0 -172
  349. package/lib/sql-ddl-sync/Dialects/dm.d.ts +0 -39
  350. package/lib/sql-ddl-sync/Dialects/dm.js +0 -297
  351. package/lib/sql-ddl-sync/Dialects/index.d.ts +0 -6
  352. package/lib/sql-ddl-sync/Dialects/index.js +0 -8
  353. package/lib/sql-ddl-sync/Dialects/mysql.d.ts +0 -38
  354. package/lib/sql-ddl-sync/Dialects/mysql.js +0 -241
  355. package/lib/sql-ddl-sync/Dialects/postgresql.d.ts +0 -39
  356. package/lib/sql-ddl-sync/Dialects/postgresql.js +0 -287
  357. package/lib/sql-ddl-sync/Dialects/sqlite.d.ts +0 -43
  358. package/lib/sql-ddl-sync/Dialects/sqlite.js +0 -257
  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 -2
  363. package/lib/sql-ddl-sync/Typo/DbIndex.d.ts +0 -13
  364. package/lib/sql-ddl-sync/Typo/DbIndex.js +0 -2
  365. package/lib/sql-ddl-sync/Typo/Dialect.js +0 -2
  366. package/lib/sql-ddl-sync/Typo/Driver.d.ts +0 -53
  367. package/lib/sql-ddl-sync/Typo/Driver.js +0 -2
  368. package/lib/sql-ddl-sync/Typo/Query.d.ts +0 -7
  369. package/lib/sql-ddl-sync/Typo/Query.js +0 -2
  370. package/lib/sql-ddl-sync/Typo/SQL.d.ts +0 -31
  371. package/lib/sql-ddl-sync/Typo/SQL.js +0 -2
  372. package/lib/sql-ddl-sync/Typo/_common.d.ts +0 -29
  373. package/lib/sql-ddl-sync/Typo/_common.js +0 -2
  374. package/lib/sql-ddl-sync/Utils.d.ts +0 -39
  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 -372
  378. package/lib/sql-query/Comparators.d.ts +0 -3
  379. package/lib/sql-query/Comparators.js +0 -95
  380. package/lib/sql-query/Create.d.ts +0 -35
  381. package/lib/sql-query/Create.js +0 -78
  382. package/lib/sql-query/Dialects/dm.d.ts +0 -3
  383. package/lib/sql-query/Dialects/index.js +0 -13
  384. package/lib/sql-query/Dialects/mssql.d.ts +0 -3
  385. package/lib/sql-query/Dialects/mssql.js +0 -74
  386. package/lib/sql-query/Dialects/mysql.d.ts +0 -3
  387. package/lib/sql-query/Dialects/mysql.js +0 -101
  388. package/lib/sql-query/Dialects/postgresql.d.ts +0 -3
  389. package/lib/sql-query/Dialects/postgresql.js +0 -77
  390. package/lib/sql-query/Dialects/sqlite.d.ts +0 -3
  391. package/lib/sql-query/Dialects/sqlite.js +0 -62
  392. package/lib/sql-query/Helpers.d.ts +0 -37
  393. package/lib/sql-query/Helpers.js +0 -260
  394. package/lib/sql-query/Insert.d.ts +0 -12
  395. package/lib/sql-query/Insert.js +0 -34
  396. package/lib/sql-query/Query.d.ts +0 -28
  397. package/lib/sql-query/Query.js +0 -120
  398. package/lib/sql-query/Remove.d.ts +0 -16
  399. package/lib/sql-query/Remove.js +0 -94
  400. package/lib/sql-query/Select.d.ts +0 -62
  401. package/lib/sql-query/Select.js +0 -534
  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 -2
  406. package/lib/sql-query/Typo/Comparators.d.ts +0 -140
  407. package/lib/sql-query/Typo/Comparators.js +0 -2
  408. package/lib/sql-query/Typo/Dialect.d.ts +0 -39
  409. package/lib/sql-query/Typo/Dialect.js +0 -2
  410. package/lib/sql-query/Typo/Field.d.ts +0 -8
  411. package/lib/sql-query/Typo/Field.js +0 -2
  412. package/lib/sql-query/Typo/Helper.d.ts +0 -4
  413. package/lib/sql-query/Typo/Helper.js +0 -2
  414. package/lib/sql-query/Typo/Query-ChainBuilder.d.ts +0 -80
  415. package/lib/sql-query/Typo/Query-ChainBuilder.js +0 -2
  416. package/lib/sql-query/Typo/Query.d.ts +0 -34
  417. package/lib/sql-query/Typo/Query.js +0 -17
  418. package/lib/sql-query/Typo/Sql.d.ts +0 -143
  419. package/lib/sql-query/Typo/Sql.js +0 -2
  420. package/lib/sql-query/Typo/SubQuery.d.ts +0 -39
  421. package/lib/sql-query/Typo/SubQuery.js +0 -2
  422. package/lib/sql-query/Typo/index.js +0 -2
  423. package/lib/sql-query/Update.d.ts +0 -15
  424. package/lib/sql-query/Update.js +0 -39
  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
@@ -0,0 +1,25 @@
1
+ import { escapeValForKnex } from './Helpers';
2
+ import type { FxSqlQueryDialect } from './Typo/Dialect';
3
+ import type { FxSqlQueryChainBuilder } from './Typo/Query-ChainBuilder';
4
+ import type { FxSqlQuerySql } from './Typo/Sql';
5
+
6
+ export function build (
7
+ knexQueryBuilder: import("../knex/types").Knex.QueryBuilder,
8
+ Dialect: FxSqlQueryDialect.Dialect,
9
+ set: FxSqlQuerySql.DataToSet,
10
+ opts: FxSqlQueryChainBuilder.ChainBuilderOptions
11
+ ): void {
12
+ opts = opts || {};
13
+
14
+ if (!set || set.length === 0) {
15
+ return ;
16
+ }
17
+
18
+ const safeSet: typeof set = {};
19
+
20
+ for (let k in set) {
21
+ safeSet[k] = escapeValForKnex(set[k], Dialect, opts)
22
+ }
23
+
24
+ knexQueryBuilder.update(safeSet);
25
+ };
@@ -0,0 +1,34 @@
1
+ export namespace FxSqlAggregation {
2
+ export type AggregationFunction = (...args: any[]) => any
3
+
4
+ export interface SupportedAggregationsMixin {
5
+ abs: AggregationFunction
6
+ ceil: AggregationFunction
7
+ floor: AggregationFunction
8
+ round: AggregationFunction
9
+ avg: AggregationFunction
10
+ min: AggregationFunction
11
+ max: AggregationFunction
12
+ log: AggregationFunction
13
+ log2: AggregationFunction
14
+ log10: AggregationFunction
15
+ exp: AggregationFunction
16
+ power: AggregationFunction
17
+ acos: AggregationFunction
18
+ asin: AggregationFunction
19
+ atan: AggregationFunction
20
+ cos: AggregationFunction
21
+ sin: AggregationFunction
22
+ tan: AggregationFunction
23
+ conv: AggregationFunction
24
+ random: AggregationFunction
25
+ rand: AggregationFunction
26
+ radians: AggregationFunction
27
+ degrees: AggregationFunction
28
+ sum: AggregationFunction
29
+ count: AggregationFunction
30
+ distinct: AggregationFunction
31
+ }
32
+
33
+ export type SupportedAggregationFunction = keyof SupportedAggregationsMixin
34
+ }
@@ -0,0 +1,156 @@
1
+ export namespace FxSqlQueryComparator {
2
+ export type IdType = string | number
3
+ export type SimpleEqValueType = string | number | boolean | Date
4
+ export type NormalizedInOperator = 'in' | 'not_in' | 'IN' | 'NOT_IN'
5
+
6
+ export type InputValue_eq = { "eq": SimpleEqValueType }
7
+ export type InputValue_ne = { "ne": SimpleEqValueType }
8
+ export type InputValue_gt = { "gt": number }
9
+ export type InputValue_gte = { "gte": number }
10
+ export type InputValue_lt = { "lt": number }
11
+ export type InputValue_lte = { "lte": number }
12
+ export type InputValue_like = { "like": string }
13
+ export type InputValue_not_like = { "not_like": string }
14
+ export type InputValue_between = { "between": [number, number] }
15
+ export type InputValue_not_between = { "not_between": [number, number] }
16
+
17
+ export type InputValue_in = { "in": IdType[] }
18
+ export type InputValue_not_in = { "not_in": IdType[] }
19
+
20
+ export type InputComparatorObjectValue =
21
+ InputValue_eq
22
+ | InputValue_ne
23
+ | InputValue_gt
24
+ | InputValue_gte
25
+ | InputValue_lt
26
+ | InputValue_lte
27
+ | InputValue_like
28
+ | InputValue_not_like
29
+ | InputValue_between
30
+ | InputValue_not_between
31
+ | InputValue_in
32
+ | InputValue_not_in
33
+
34
+ export type InputValueType =
35
+ SimpleEqValueType | InputComparatorObjectValue
36
+
37
+ export interface SubQueryComparatorInput {
38
+ [k: string]: FxSqlQueryComparator.QueryComparatorObject
39
+ }
40
+
41
+ // compatible
42
+ export interface SubQuerySimpleEqInput {
43
+ [k: string]: SimpleEqValueType
44
+ }
45
+
46
+ export interface SubQueryInput {
47
+ [k: string]: FxSqlQueryComparator.QueryComparatorObject | SimpleEqValueType
48
+ }
49
+
50
+ export interface Input {
51
+ [key: string]: InputValueType
52
+ }
53
+
54
+ export type QueryComparatorExprType = string
55
+ export type QueryComparatorObject<T = any> = {
56
+ sql_comparator (): ComparatorNames
57
+ // value
58
+ val?: T
59
+ // WIP: if use value as identifier
60
+ asIdentifier?: boolean
61
+ // expression regular
62
+ expr?: QueryComparatorExprType
63
+ // from field
64
+ from?: string
65
+ // to field
66
+ to?: string
67
+ }
68
+ export type SimpleQueryConjunctionWord_NonNegetive = "or" | "and"
69
+ export type SimpleQueryConjunctionWord = SimpleQueryConjunctionWord_NonNegetive | "not"
70
+ export type QueryConjunctionWord = SimpleQueryConjunctionWord | "not_or" | "not_and"
71
+
72
+ export interface QueryComparatorLiteralObject {
73
+ between: any | any[]
74
+ not_between: any | any[]
75
+ like: any | any[]
76
+ not_like: any | any[]
77
+ eq: any | any[]
78
+ ne: any | any[]
79
+ gt: any | any[]
80
+ gte: any | any[]
81
+ lt: any | any[]
82
+ lte: any | any[]
83
+ in: any | any[]
84
+ not_in: any | any[]
85
+
86
+ modifiers?: {
87
+ is_date?: boolean
88
+ // timezone?: FxSqlQuery.FxSqlQueryTimezone
89
+
90
+ [modifier_name: string]: any
91
+ }
92
+ }
93
+
94
+ export type ComparatorHash = {
95
+ between: FxSqlQueryComparatorFunction.between
96
+ not_between: FxSqlQueryComparatorFunction.not_between
97
+ like: FxSqlQueryComparatorFunction.like
98
+ not_like: FxSqlQueryComparatorFunction.not_like
99
+ eq: FxSqlQueryComparatorFunction.eq
100
+ ne: FxSqlQueryComparatorFunction.ne
101
+ gt: FxSqlQueryComparatorFunction.gt
102
+ gte: FxSqlQueryComparatorFunction.gte
103
+ lt: FxSqlQueryComparatorFunction.lt
104
+ lte: FxSqlQueryComparatorFunction.lte
105
+ in: FxSqlQueryComparatorFunction.not_in
106
+ not_in: FxSqlQueryComparatorFunction.not_in
107
+ }
108
+
109
+ export type ComparatorNameType = keyof ComparatorHash
110
+ // just compatible
111
+ export type ComparatorNames = ComparatorNameType
112
+
113
+ export type QueryComparatorType =
114
+ ComparatorNameType
115
+ | 'sql'
116
+ }
117
+
118
+ export namespace FxSqlQueryComparatorFunction {
119
+ export interface between {
120
+ (a: string, b: string, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
121
+ }
122
+ export interface not_between {
123
+ (a: string, b: string, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
124
+ }
125
+ export interface like {
126
+ (expr: FxSqlQueryComparator.QueryComparatorExprType, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
127
+ }
128
+ export interface not_like {
129
+ (expr: FxSqlQueryComparator.QueryComparatorExprType, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
130
+ }
131
+ export interface eq {
132
+ (v: any, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
133
+ }
134
+ export interface ne {
135
+ (v: any, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
136
+ }
137
+ export interface gt {
138
+ (v: any, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
139
+ }
140
+ export interface gte {
141
+ (v: any, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
142
+ }
143
+ export interface lt {
144
+ (v: any, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
145
+ }
146
+ export interface lte {
147
+ (v: any, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
148
+ }
149
+ export interface not_in {
150
+ (v: any, options?: __Options): FxSqlQueryComparator.QueryComparatorObject
151
+ }
152
+
153
+ export type __Options = {
154
+ asIdentifier?: boolean
155
+ }
156
+ }
@@ -0,0 +1,51 @@
1
+ import type { FxSqlQuery } from "./Query"
2
+ import type { FxSqlQuerySql } from "./Sql"
3
+
4
+ export namespace FxSqlQueryDialect {
5
+ export type DialectType = 'mysql' | 'mssql' | 'sqlite' | 'postgresql' | 'dm'
6
+
7
+ export interface DataTypesDescriptorBase {
8
+ id: string
9
+ int: string
10
+ float: string
11
+ bool: string
12
+ text: string
13
+ }
14
+
15
+ export type DialectFieldType = keyof DataTypesDescriptorBase
16
+
17
+ export interface DataTypesDescriptor extends DataTypesDescriptorBase {
18
+ isSQLITE?: boolean
19
+ }
20
+
21
+ export interface Dialect<T extends DialectType = DialectType> {
22
+ DataTypes: DataTypesDescriptor
23
+ type: T
24
+
25
+ escape: {
26
+ (
27
+ query: FxSqlQuerySql.SqlFragmentStr,
28
+ args: FxSqlQuerySql.SqlAssignmentValues
29
+ ): string
30
+ }
31
+ escapeId: {
32
+ (...els: (FxSqlQuerySql.SqlEscapeArgIdType | {str: string, escapes: string[]})[]): string
33
+ }
34
+ escapeVal: {
35
+ (val: FxSqlQuerySql.SqlEscapeArgType, timezone?: FxSqlQuery.FxSqlQueryTimezone): string
36
+ (vals: FxSqlQuerySql.DetailedQueryWhereCondition__InStyle['val'], timezone?: FxSqlQuery.FxSqlQueryTimezone): string
37
+ }
38
+
39
+ limitAsTop: boolean
40
+
41
+ /* @internal */
42
+ readonly knex: import('../../knex/types').Knex
43
+
44
+ // only postgresql has it
45
+ defaultValuesStmt?: T extends 'postgresql' ? string : never
46
+ }
47
+
48
+ export type fn_escape = Dialect['escape']
49
+ export type fn_escapeId = Dialect['escapeId']
50
+ export type fn_escapeVal = Dialect['escapeVal']
51
+ }
@@ -0,0 +1,10 @@
1
+ import type { FxSqlQueryDialect } from './Dialect'
2
+ import type { FxSqlQuerySql } from './Sql'
3
+
4
+ export namespace FxSqlQueryColumns {
5
+ export type SelectInputArgType = string | FxSqlQuerySql.SqlSelectFieldItemDescriptor
6
+
7
+ export interface FieldItemTypeMap {
8
+ [key: string]: FxSqlQueryDialect.DialectFieldType
9
+ }
10
+ }
@@ -0,0 +1,4 @@
1
+ export namespace FxSqlQueryHelpler {
2
+ export type Arraiable<T> = T | T[]
3
+ export type BinaryTuple<T1, T2=T1> = [T1, T2]
4
+ }
@@ -0,0 +1,110 @@
1
+ import type { FxSqlQuery } from "./Query"
2
+ import type { FxSqlQuerySql } from "./Sql"
3
+ import type { FxSqlAggregation } from "./Aggregation"
4
+ import type { FxSqlQueryDialect } from "./Dialect"
5
+ import type { FxSqlQueryColumns } from "./Field"
6
+ import type { FxSqlQuerySubQuery } from "./SubQuery"
7
+ import type { FxSqlQueryHelpler } from "./Helper"
8
+
9
+ export namespace FxSqlQueryChainBuilder {
10
+ export type QueryWhereConditionPayloadUnit = FxSqlQuerySql.DetailedQueryWhereCondition | string | null
11
+
12
+ export interface ChainBuilderOptions extends FxSqlQuery.QueryOptions {}
13
+
14
+ export interface ChainBuilder {
15
+ readonly knex: FxSqlQuery.Class_Query['knex']
16
+ build(): string
17
+ }
18
+
19
+ export interface ChainBuilderPaginationMixin {
20
+ offset(offset: number): this
21
+ limit(limit: number|string): this
22
+ }
23
+
24
+ export interface ChainBuilderSortMixin {
25
+ /**
26
+ *
27
+ * @param column
28
+ * @param dir
29
+ *
30
+ * @sample
31
+ * .order('col1', 'Z')
32
+ * .order(['table1', 'col1'], 'A')
33
+ * .order('ID DESC')
34
+ * .order('?? DESC', ['ID'])
35
+ */
36
+ order(column: FxSqlQuery.OrderNormalizedResult[0], dir?: FxSqlQuery.OrderNormalizedResult[1]): this
37
+ }
38
+
39
+ export type ChainBuilder__SelectAggregationFunColumnArg = (string | string[])[]
40
+ export interface ChainBuilder__Select
41
+ extends ChainBuilder, FxSqlAggregation.SupportedAggregationsMixin, ChainBuilderPaginationMixin, ChainBuilderSortMixin
42
+ {
43
+ Dialect: FxSqlQueryDialect.Dialect
44
+
45
+ select: (fields: FxSqlQueryColumns.SelectInputArgType[]) => this
46
+ /**
47
+ * .where('table1', {t1_col1: 'v1'}, 'table2', {t1_col2: 'v2'}, ...)
48
+ * .where({__sql: 'xxx'})
49
+ * .where({col1: 'v1', col1: 'v1'})
50
+ * .where(not: [ { col: 2 }, { col: 3 } ])
51
+ */
52
+ where: (...whereConditions: (FxSqlQuerySubQuery.SubQueryBuildDescriptor['wheres'] | FxSqlQuerySubQuery.WhereExistsTuple_Flatten[0])[]) => this
53
+ whereExists: (
54
+ table: string,
55
+ table_link: string | FxSqlQuerySql.SqlFromTableInput,
56
+ link: FxSqlQuerySql.WhereExistsLinkTuple,
57
+ cond: FxSqlQuerySubQuery.SubQueryBuildDescriptor['wheres']
58
+ ) => this
59
+ groupBy: (...args: FxSqlQuerySql.SqlGroupByType[]) => this
60
+ fun: (fun: string, column?: FxSqlQuerySql.SqlColumnType, _as?: string) => this
61
+ from: {
62
+ /**
63
+ * @warning can be only used in first call!
64
+ */
65
+ (table: FxSqlQuerySql.SqlTableInputType): ChainBuilder__Select
66
+ (
67
+ table: FxSqlQuerySql.SqlTableInputType,
68
+ from_id: FxSqlQueryHelpler.Arraiable<string>,
69
+ to_id: FxSqlQueryHelpler.Arraiable<string>
70
+ ): ChainBuilder__Select
71
+ (
72
+ table: FxSqlQuerySql.SqlTableInputType,
73
+ from_id: FxSqlQueryHelpler.Arraiable<string>,
74
+ to_table: string,
75
+ to_id: FxSqlQueryHelpler.Arraiable<string>,
76
+ fromOpts?: FxSqlQuerySql.QueryFromDescriptorOpts
77
+ ): ChainBuilder__Select
78
+ }
79
+
80
+ [extra: string]: any
81
+ }
82
+ export interface ChainBuilder__Insert extends ChainBuilder {
83
+ into(table: string): this | ChainBuilder__Insert
84
+ set(values: FxSqlQuerySql.DataToSet): this | ChainBuilder__Insert
85
+ }
86
+
87
+ export interface ChainBuilder__Create extends ChainBuilder {
88
+ table(table: string): this | ChainBuilder__Create
89
+ field(table: string, type: FxSqlQueryDialect.DialectFieldType): this | ChainBuilder__Create
90
+
91
+ fields: {
92
+ (): FxSqlQueryColumns.FieldItemTypeMap
93
+ (fields: FxSqlQueryColumns.FieldItemTypeMap): ChainBuilder__Create
94
+ }
95
+ }
96
+
97
+ export interface ChainBuilder__Update extends ChainBuilder {
98
+ where: (...whereConditions: FxSqlQuerySubQuery.SubQueryBuildDescriptor['wheres'][]) => ChainBuilder__Update
99
+ into(table: string): this | ChainBuilder__Update
100
+ set(values: FxSqlQuerySql.DataToSet): this | ChainBuilder__Update
101
+ }
102
+
103
+ export interface ChainBuilder__Remove
104
+ extends ChainBuilder, ChainBuilderPaginationMixin
105
+ {
106
+ order(column: string, dir: FxSqlQuery.QueryOrderDirection): this
107
+ where: (...whereConditions: FxSqlQuerySubQuery.SubQueryBuildDescriptor['wheres'][]) => this
108
+ from(table: string): this
109
+ }
110
+ }
@@ -0,0 +1,65 @@
1
+ import type { FxSqlQueryDialect } from "./Dialect"
2
+ import type { FxSqlQueryChainBuilder } from "./Query-ChainBuilder"
3
+ import type { FxSqlQuerySql } from './Sql'
4
+
5
+ export namespace FxSqlQuery {
6
+ export type OrderNormalizedTuple = [string|string[], "Z" | "A"]
7
+ export type OrderSqlStyleTuple = [FxSqlQuerySql.SqlFragmentStr, FxSqlQuerySql.SqlAssignmentValues?]
8
+ export type OrderNormalizedResult = OrderNormalizedTuple | OrderSqlStyleTuple
9
+
10
+ export interface QueryOptions {
11
+ dialect?: FxSqlQueryDialect.DialectType /* | string */
12
+ timezone?: FxSqlQueryTimezone
13
+ }
14
+
15
+ export type QueryOrderDirection =
16
+ // Z means 'z->a'
17
+ 'Z'
18
+ // other string means 'a->z'
19
+ | 'A'
20
+ | string
21
+
22
+ export type FxSqlQueryTimezone =
23
+ 'Z'
24
+ | 'local'
25
+ | string
26
+
27
+ export interface TypedQueryObject<T = 'text' | string, TD = any> {
28
+ data: TD
29
+ type(): T
30
+ }
31
+ export interface TypedQueryObjectWrapper<T = 'text' | string, TD = any> {
32
+ (data: TD): FxSqlQuery.TypedQueryObject<T, TD>
33
+ }
34
+
35
+ export class Class_Query {
36
+ constructor (_opts?: string | FxSqlQuery.QueryOptions);
37
+
38
+ /* @internal */
39
+ readonly knex: FxSqlQueryDialect.Dialect['knex']
40
+ readonly Dialect: FxSqlQueryDialect.Dialect
41
+
42
+ escape: FxSqlQueryDialect.Dialect['escape']
43
+ escapeId: FxSqlQueryDialect.Dialect['escapeId']
44
+ escapeVal: FxSqlQueryDialect.Dialect['escapeVal']
45
+
46
+ create (): FxSqlQueryChainBuilder.ChainBuilder__Create
47
+ select (): FxSqlQueryChainBuilder.ChainBuilder__Select
48
+ insert (): FxSqlQueryChainBuilder.ChainBuilder__Insert
49
+ update (): FxSqlQueryChainBuilder.ChainBuilder__Update
50
+ remove (): FxSqlQueryChainBuilder.ChainBuilder__Remove
51
+ }
52
+
53
+ // interface ExportModule {
54
+ // comparators: FxSqlQueryComparator.ComparatorHash
55
+ // Text: FxSqlQuery.TypedQueryObjectWrapper<'text'>
56
+ // Helpers: FxSqlQueryHelpler.HelperModule
57
+
58
+ // Dialects: {
59
+ // mysql: FxSqlQueryDialect.Dialect
60
+ // sqlite: FxSqlQueryDialect.Dialect
61
+ // mssql: FxSqlQueryDialect.Dialect
62
+ // }
63
+ // Query: typeof FxSqlQuery.Class_Query
64
+ // }
65
+ }
@@ -0,0 +1,192 @@
1
+ import type { FxSqlAggregation } from "./Aggregation"
2
+ import type { FxSqlQueryComparator } from "./Comparators"
3
+ import type { FxSqlQueryDialect } from "./Dialect"
4
+ import type { FxSqlQueryHelpler } from "./Helper"
5
+ import type { FxSqlQuerySubQuery } from "./SubQuery"
6
+ import type { FxSqlQuery } from './Query'
7
+
8
+ export namespace FxSqlQuerySql {
9
+ // type ValueToSet = (string|number)
10
+ export type DataToSet = {
11
+ [key: string]: any
12
+ }
13
+
14
+ export type SqlResultStr = string
15
+ export type SqlFragmentStr = string
16
+ export type SqlQueryStr = string
17
+
18
+ export type SqlEscapeArgType = string | number | boolean | Date | String | Number | RegExp | Symbol
19
+ export type SqlEscapeArgIdType = string | number
20
+
21
+ export type SqlAssignmentValues = SqlEscapeArgType[]
22
+ export type SqlAssignmentTuple = [FxSqlQuerySql.SqlFragmentStr, [...SqlAssignmentValues]?]
23
+
24
+ export type SqlFromTableInput = import('../../knex/types').Knex.Raw | import('../../knex/types').Knex.QueryBuilder
25
+ export type SqlTableTuple = [table: string | `(${string})`| SqlFromTableInput, alis: string]
26
+ export type SqlTableInputType = string | SqlFromTableInput | SqlTableTuple
27
+
28
+ export type WhereObj = {
29
+ str: string
30
+ escapes: any[]
31
+ }
32
+
33
+ // ['f1', 'f2'] ---> (`t1.f1` = `t2.f2`)
34
+ export type WhereExistsLinkTuple_L1 = FxSqlQueryHelpler.BinaryTuple<string>
35
+ // [['f1', 'f2'[, ...]], ['ff1', 'ff2'[, ...]]] ---> (`t1.f1` = `t2.f2`) AND (`t1.ff1` = `t2.ff2`) [...]
36
+ export type WhereExistsLinkTuple_L2 = FxSqlQueryHelpler.BinaryTuple<string[]>
37
+ export type WhereExistsLinkTuple = WhereExistsLinkTuple_L1 | WhereExistsLinkTuple_L2
38
+
39
+ export interface DetailedQueryWhereCondition<T = any> extends FxSqlQueryComparator.QueryComparatorObject<T> {
40
+ // from table name
41
+ from: string
42
+ // target table name
43
+ to: string
44
+ expr: FxSqlQueryComparator.QueryComparatorExprType
45
+ val: T
46
+ where: WhereObj
47
+ }
48
+ export type DetailedQueryWhereCondition__InStyle = DetailedQueryWhereCondition<
49
+ FxSqlQueryComparator.InputValue_in['in'] | FxSqlQueryComparator.InputValue_not_in['not_in']
50
+ >
51
+
52
+ export interface QueryWhereConjunctionHash {
53
+ or?: FxSqlQueryComparator.Input[]
54
+ and?: FxSqlQueryComparator.Input[]
55
+ not_or?: FxSqlQueryComparator.Input[]
56
+ not_and?: FxSqlQueryComparator.Input[]
57
+ not?: FxSqlQueryComparator.Input[]
58
+ }
59
+
60
+ export interface QueryWhereExtendItem {
61
+ // table
62
+ table: string
63
+ // link
64
+ link_info: FxSqlQueryHelpler.Arraiable<any>
65
+ // table linked
66
+ table_linked: string
67
+ }
68
+
69
+ export type SqlColumnDescriptorDataType = any
70
+ export interface SqlColumnDescriptor {
71
+ data: SqlColumnDescriptorDataType,
72
+ type? (): string
73
+ }
74
+
75
+ export type NormalizedSimpleSqlColumnType = string | '*'
76
+ export type SqlColumnType = (SqlColumnDescriptor|string)[] | NormalizedSimpleSqlColumnType
77
+
78
+ // item to describe what columns to select
79
+ export interface SqlSelectFieldItemDescriptor {
80
+ /**
81
+ * @description fun name
82
+ */
83
+ func_name?: string
84
+ /**
85
+ * @description column name
86
+ * expect NO table prefix
87
+ *
88
+ * ```
89
+ * recommended: `col`
90
+ * ```
91
+ *
92
+ * but this allowed also
93
+ *
94
+ * ```
95
+ * allowed also: `table.col`
96
+ * ````
97
+ *
98
+ */
99
+ column_name?: SqlColumnType
100
+ /**
101
+ * @description column as
102
+ */
103
+ as?: FxSqlQuerySql.NormalizedSimpleSqlColumnType,
104
+ a?: SqlSelectFieldItemDescriptor['as'],
105
+ /**
106
+ * @description fun_stack
107
+ */
108
+ func_stack?: FxSqlAggregation.SupportedAggregationFunction[]
109
+ /**
110
+ * @description pure sql
111
+ */
112
+ sql?: string
113
+
114
+ /**
115
+ * @description GUESS: useful when this object refer to one complex descriptor?
116
+ */
117
+ select?: string
118
+ /**
119
+ * @description having sub query statement
120
+ */
121
+ having?: string
122
+ }
123
+
124
+ export interface SqlSelectFieldsGenerator {
125
+ (dialect: FxSqlQueryDialect.Dialect): string
126
+ }
127
+ export type SqlSelectFieldsType = SqlFragmentStr | SqlSelectFieldItemDescriptor | SqlSelectFieldsGenerator
128
+
129
+ export interface QueryFromDescriptorOpts {
130
+ joinType: string
131
+ }
132
+
133
+ export interface QueryFromDescriptor {
134
+ // table
135
+ table: string | import('../../knex/types').Knex.Raw | import('../../knex/types').Knex.QueryBuilder
136
+ // table alias
137
+ alias: string, a?: string
138
+ // ?
139
+ joins?: QueryFromJoinTupleDescriptor[]
140
+ // selected fields
141
+ select?: SqlSelectFieldsType[]
142
+ // from opts
143
+ opts?: QueryFromDescriptorOpts
144
+ }
145
+
146
+ export type QueryFromJoinTupleDescriptor = [
147
+ // from id column name
148
+ string,
149
+ // to table alias name
150
+ string,
151
+ // to id column name
152
+ string,
153
+ ]
154
+
155
+ export type SqlTableOrderTuple = [
156
+ // table(alias) name
157
+ string,
158
+ // column name
159
+ string
160
+ ]
161
+ export interface SqlOrderDescriptor {
162
+ // column name or SqlTableOrderTuple
163
+ c: string | SqlTableOrderTuple
164
+ // order
165
+ d: 'DESC' | 'ASC'
166
+ }
167
+ export type SqlOrderPayloadType = SqlOrderDescriptor | FxSqlQuery.OrderSqlStyleTuple[0]
168
+
169
+ export type SqlGroupByType = string
170
+
171
+ export interface SqlFoundRowItem {
172
+ [k: string]: any
173
+ }
174
+
175
+ // type SqlQueryDescriptorWhereItem = SqlWhereDescriptor | string
176
+
177
+ export interface SqlQueryChainDescriptor {
178
+ from?: QueryFromDescriptor[]
179
+ table?: string
180
+ // values to set in UPDATE like command
181
+ set?: DataToSet
182
+ where?: FxSqlQuerySubQuery.SubQueryBuildDescriptor[]
183
+ order?: SqlOrderPayloadType[]
184
+ offset?: number
185
+ limit?: number
186
+
187
+ found_rows?: SqlFoundRowItem[] | boolean
188
+ group_by?: SqlGroupByType[]
189
+
190
+ where_exists?: boolean
191
+ }
192
+ }