taon-type-sql 21.0.68 → 21.0.69

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 (249) hide show
  1. package/VERIFIED-BUILD-DATA.jsonc +3 -3
  2. package/browser/package.json +1 -1
  3. package/browser-prod/package.json +1 -1
  4. package/full-dts/build-info._auto-generated_.d.ts +1 -1
  5. package/lib/build-info._auto-generated_.d.ts +1 -1
  6. package/lib/build-info._auto-generated_.js +1 -1
  7. package/lib/package.json +1 -1
  8. package/lib-esm/lib/build-info._auto-generated_.d.ts +1 -1
  9. package/lib-esm/lib/build-info._auto-generated_.js +1 -1
  10. package/lib-prod/build-info._auto-generated_.d.ts +1 -1
  11. package/lib-prod/build-info._auto-generated_.js +1 -1
  12. package/lib-prod/package.json +1 -1
  13. package/package.json +1 -1
  14. package/ts-source/browser-code/build-info._auto-generated_.ts +13 -0
  15. package/ts-source/browser-code/builder/column/basic-column.ts +19 -0
  16. package/ts-source/browser-code/builder/column/boolean-column.ts +20 -0
  17. package/ts-source/browser-code/builder/column/comparable-column.ts +47 -0
  18. package/ts-source/browser-code/builder/column/date-column.ts +20 -0
  19. package/ts-source/browser-code/builder/column/number-column.ts +25 -0
  20. package/ts-source/browser-code/builder/column/query-column.ts +28 -0
  21. package/ts-source/browser-code/builder/column/string-column.ts +42 -0
  22. package/ts-source/browser-code/builder/column/value-column.ts +39 -0
  23. package/ts-source/browser-code/builder/condition/query-column-condition.ts +29 -0
  24. package/ts-source/browser-code/builder/condition/query-condition-chain.ts +39 -0
  25. package/ts-source/browser-code/builder/condition/query-condition.ts +14 -0
  26. package/ts-source/browser-code/builder/condition/query-join-condition.ts +28 -0
  27. package/ts-source/browser-code/builder/helpers/generics-helper.ts +9 -0
  28. package/ts-source/browser-code/builder/helpers/internal-types.ts +22 -0
  29. package/ts-source/browser-code/builder/join/joined-tables-chain.ts +17 -0
  30. package/ts-source/browser-code/builder/join/joined-tables.ts +25 -0
  31. package/ts-source/browser-code/builder/other/query-ordering.ts +26 -0
  32. package/ts-source/browser-code/builder/query/select-query.ts +60 -0
  33. package/ts-source/browser-code/builder/query/table-condition-query.ts +31 -0
  34. package/ts-source/browser-code/builder/query/table-query.ts +63 -0
  35. package/ts-source/browser-code/builder/query-source.ts +29 -0
  36. package/ts-source/browser-code/builder/query-table.ts +29 -0
  37. package/ts-source/browser-code/client/mysql.ts +14 -0
  38. package/ts-source/browser-code/client/pg.ts +14 -0
  39. package/ts-source/browser-code/client/query-processor.ts +60 -0
  40. package/ts-source/browser-code/converter/param-converter.ts +31 -0
  41. package/ts-source/browser-code/converter/parameterized-converter.ts +22 -0
  42. package/ts-source/browser-code/converter/query-converter.ts +287 -0
  43. package/ts-source/browser-code/converter/result-converter.ts +93 -0
  44. package/ts-source/browser-code/converter/sql-converter.ts +13 -0
  45. package/ts-source/browser-code/converter/type-converter.ts +43 -0
  46. package/ts-source/browser-code/converter/types.ts +12 -0
  47. package/ts-source/browser-code/index._auto-generated_.ts +7 -0
  48. package/ts-source/browser-code/index.scss +6 -0
  49. package/ts-source/browser-code/index.ts +32 -0
  50. package/ts-source/browser-code/lib-info.md +8 -0
  51. package/ts-source/browser-code/migrations/index.ts +8 -0
  52. package/ts-source/browser-code/migrations/migrations-info.md +6 -0
  53. package/ts-source/browser-code/migrations/migrations_index._auto-generated_.ts +7 -0
  54. package/ts-source/browser-code-prod/build-info._auto-generated_.split-namespaces.json +4 -0
  55. package/ts-source/browser-code-prod/build-info._auto-generated_.ts +13 -0
  56. package/ts-source/browser-code-prod/builder/column/basic-column.split-namespaces.json +4 -0
  57. package/ts-source/browser-code-prod/builder/column/basic-column.ts +19 -0
  58. package/ts-source/browser-code-prod/builder/column/boolean-column.split-namespaces.json +4 -0
  59. package/ts-source/browser-code-prod/builder/column/boolean-column.ts +20 -0
  60. package/ts-source/browser-code-prod/builder/column/comparable-column.split-namespaces.json +4 -0
  61. package/ts-source/browser-code-prod/builder/column/comparable-column.ts +47 -0
  62. package/ts-source/browser-code-prod/builder/column/date-column.split-namespaces.json +4 -0
  63. package/ts-source/browser-code-prod/builder/column/date-column.ts +20 -0
  64. package/ts-source/browser-code-prod/builder/column/number-column.split-namespaces.json +4 -0
  65. package/ts-source/browser-code-prod/builder/column/number-column.ts +25 -0
  66. package/ts-source/browser-code-prod/builder/column/query-column.split-namespaces.json +4 -0
  67. package/ts-source/browser-code-prod/builder/column/query-column.ts +28 -0
  68. package/ts-source/browser-code-prod/builder/column/string-column.split-namespaces.json +4 -0
  69. package/ts-source/browser-code-prod/builder/column/string-column.ts +42 -0
  70. package/ts-source/browser-code-prod/builder/column/value-column.split-namespaces.json +4 -0
  71. package/ts-source/browser-code-prod/builder/column/value-column.ts +39 -0
  72. package/ts-source/browser-code-prod/builder/condition/query-column-condition.split-namespaces.json +4 -0
  73. package/ts-source/browser-code-prod/builder/condition/query-column-condition.ts +29 -0
  74. package/ts-source/browser-code-prod/builder/condition/query-condition-chain.split-namespaces.json +4 -0
  75. package/ts-source/browser-code-prod/builder/condition/query-condition-chain.ts +39 -0
  76. package/ts-source/browser-code-prod/builder/condition/query-condition.split-namespaces.json +4 -0
  77. package/ts-source/browser-code-prod/builder/condition/query-condition.ts +14 -0
  78. package/ts-source/browser-code-prod/builder/condition/query-join-condition.split-namespaces.json +4 -0
  79. package/ts-source/browser-code-prod/builder/condition/query-join-condition.ts +28 -0
  80. package/ts-source/browser-code-prod/builder/helpers/generics-helper.split-namespaces.json +4 -0
  81. package/ts-source/browser-code-prod/builder/helpers/generics-helper.ts +9 -0
  82. package/ts-source/browser-code-prod/builder/helpers/internal-types.split-namespaces.json +4 -0
  83. package/ts-source/browser-code-prod/builder/helpers/internal-types.ts +22 -0
  84. package/ts-source/browser-code-prod/builder/join/joined-tables-chain.split-namespaces.json +4 -0
  85. package/ts-source/browser-code-prod/builder/join/joined-tables-chain.ts +17 -0
  86. package/ts-source/browser-code-prod/builder/join/joined-tables.split-namespaces.json +4 -0
  87. package/ts-source/browser-code-prod/builder/join/joined-tables.ts +25 -0
  88. package/ts-source/browser-code-prod/builder/other/query-ordering.split-namespaces.json +4 -0
  89. package/ts-source/browser-code-prod/builder/other/query-ordering.ts +26 -0
  90. package/ts-source/browser-code-prod/builder/query/select-query.split-namespaces.json +4 -0
  91. package/ts-source/browser-code-prod/builder/query/select-query.ts +60 -0
  92. package/ts-source/browser-code-prod/builder/query/table-condition-query.split-namespaces.json +4 -0
  93. package/ts-source/browser-code-prod/builder/query/table-condition-query.ts +31 -0
  94. package/ts-source/browser-code-prod/builder/query/table-query.split-namespaces.json +4 -0
  95. package/ts-source/browser-code-prod/builder/query/table-query.ts +63 -0
  96. package/ts-source/browser-code-prod/builder/query-source.split-namespaces.json +4 -0
  97. package/ts-source/browser-code-prod/builder/query-source.ts +29 -0
  98. package/ts-source/browser-code-prod/builder/query-table.split-namespaces.json +4 -0
  99. package/ts-source/browser-code-prod/builder/query-table.ts +29 -0
  100. package/ts-source/browser-code-prod/client/mysql.split-namespaces.json +4 -0
  101. package/ts-source/browser-code-prod/client/mysql.ts +14 -0
  102. package/ts-source/browser-code-prod/client/pg.split-namespaces.json +4 -0
  103. package/ts-source/browser-code-prod/client/pg.ts +14 -0
  104. package/ts-source/browser-code-prod/client/query-processor.split-namespaces.json +4 -0
  105. package/ts-source/browser-code-prod/client/query-processor.ts +60 -0
  106. package/ts-source/browser-code-prod/converter/param-converter.split-namespaces.json +4 -0
  107. package/ts-source/browser-code-prod/converter/param-converter.ts +31 -0
  108. package/ts-source/browser-code-prod/converter/parameterized-converter.split-namespaces.json +4 -0
  109. package/ts-source/browser-code-prod/converter/parameterized-converter.ts +22 -0
  110. package/ts-source/browser-code-prod/converter/query-converter.split-namespaces.json +4 -0
  111. package/ts-source/browser-code-prod/converter/query-converter.ts +287 -0
  112. package/ts-source/browser-code-prod/converter/result-converter.split-namespaces.json +4 -0
  113. package/ts-source/browser-code-prod/converter/result-converter.ts +93 -0
  114. package/ts-source/browser-code-prod/converter/sql-converter.split-namespaces.json +4 -0
  115. package/ts-source/browser-code-prod/converter/sql-converter.ts +13 -0
  116. package/ts-source/browser-code-prod/converter/type-converter.split-namespaces.json +4 -0
  117. package/ts-source/browser-code-prod/converter/type-converter.ts +43 -0
  118. package/ts-source/browser-code-prod/converter/types.split-namespaces.json +4 -0
  119. package/ts-source/browser-code-prod/converter/types.ts +12 -0
  120. package/ts-source/browser-code-prod/index._auto-generated_.split-namespaces.json +4 -0
  121. package/ts-source/browser-code-prod/index._auto-generated_.ts +7 -0
  122. package/ts-source/browser-code-prod/index.scss +6 -0
  123. package/ts-source/browser-code-prod/index.split-namespaces.json +4 -0
  124. package/ts-source/browser-code-prod/index.ts +32 -0
  125. package/ts-source/browser-code-prod/lib-info.md +8 -0
  126. package/ts-source/browser-code-prod/migrations/index.split-namespaces.json +4 -0
  127. package/ts-source/browser-code-prod/migrations/index.ts +8 -0
  128. package/ts-source/browser-code-prod/migrations/migrations-info.md +6 -0
  129. package/ts-source/browser-code-prod/migrations/migrations_index._auto-generated_.split-namespaces.json +4 -0
  130. package/ts-source/browser-code-prod/migrations/migrations_index._auto-generated_.ts +7 -0
  131. package/ts-source/websql-code/build-info._auto-generated_.ts +13 -0
  132. package/ts-source/websql-code/builder/column/basic-column.ts +19 -0
  133. package/ts-source/websql-code/builder/column/boolean-column.ts +20 -0
  134. package/ts-source/websql-code/builder/column/comparable-column.ts +47 -0
  135. package/ts-source/websql-code/builder/column/date-column.ts +20 -0
  136. package/ts-source/websql-code/builder/column/number-column.ts +25 -0
  137. package/ts-source/websql-code/builder/column/query-column.ts +28 -0
  138. package/ts-source/websql-code/builder/column/string-column.ts +42 -0
  139. package/ts-source/websql-code/builder/column/value-column.ts +39 -0
  140. package/ts-source/websql-code/builder/condition/query-column-condition.ts +29 -0
  141. package/ts-source/websql-code/builder/condition/query-condition-chain.ts +39 -0
  142. package/ts-source/websql-code/builder/condition/query-condition.ts +14 -0
  143. package/ts-source/websql-code/builder/condition/query-join-condition.ts +28 -0
  144. package/ts-source/websql-code/builder/helpers/generics-helper.ts +9 -0
  145. package/ts-source/websql-code/builder/helpers/internal-types.ts +22 -0
  146. package/ts-source/websql-code/builder/join/joined-tables-chain.ts +17 -0
  147. package/ts-source/websql-code/builder/join/joined-tables.ts +25 -0
  148. package/ts-source/websql-code/builder/other/query-ordering.ts +26 -0
  149. package/ts-source/websql-code/builder/query/select-query.ts +60 -0
  150. package/ts-source/websql-code/builder/query/table-condition-query.ts +31 -0
  151. package/ts-source/websql-code/builder/query/table-query.ts +63 -0
  152. package/ts-source/websql-code/builder/query-source.ts +29 -0
  153. package/ts-source/websql-code/builder/query-table.ts +29 -0
  154. package/ts-source/websql-code/client/mysql.ts +14 -0
  155. package/ts-source/websql-code/client/pg.ts +14 -0
  156. package/ts-source/websql-code/client/query-processor.ts +60 -0
  157. package/ts-source/websql-code/converter/param-converter.ts +31 -0
  158. package/ts-source/websql-code/converter/parameterized-converter.ts +22 -0
  159. package/ts-source/websql-code/converter/query-converter.ts +287 -0
  160. package/ts-source/websql-code/converter/result-converter.ts +93 -0
  161. package/ts-source/websql-code/converter/sql-converter.ts +13 -0
  162. package/ts-source/websql-code/converter/type-converter.ts +43 -0
  163. package/ts-source/websql-code/converter/types.ts +12 -0
  164. package/ts-source/websql-code/index._auto-generated_.ts +7 -0
  165. package/ts-source/websql-code/index.scss +6 -0
  166. package/ts-source/websql-code/index.ts +32 -0
  167. package/ts-source/websql-code/lib-info.md +8 -0
  168. package/ts-source/websql-code/migrations/index.ts +8 -0
  169. package/ts-source/websql-code/migrations/migrations-info.md +6 -0
  170. package/ts-source/websql-code/migrations/migrations_index._auto-generated_.ts +7 -0
  171. package/ts-source/websql-code-prod/build-info._auto-generated_.split-namespaces.json +4 -0
  172. package/ts-source/websql-code-prod/build-info._auto-generated_.ts +13 -0
  173. package/ts-source/websql-code-prod/builder/column/basic-column.split-namespaces.json +4 -0
  174. package/ts-source/websql-code-prod/builder/column/basic-column.ts +19 -0
  175. package/ts-source/websql-code-prod/builder/column/boolean-column.split-namespaces.json +4 -0
  176. package/ts-source/websql-code-prod/builder/column/boolean-column.ts +20 -0
  177. package/ts-source/websql-code-prod/builder/column/comparable-column.split-namespaces.json +4 -0
  178. package/ts-source/websql-code-prod/builder/column/comparable-column.ts +47 -0
  179. package/ts-source/websql-code-prod/builder/column/date-column.split-namespaces.json +4 -0
  180. package/ts-source/websql-code-prod/builder/column/date-column.ts +20 -0
  181. package/ts-source/websql-code-prod/builder/column/number-column.split-namespaces.json +4 -0
  182. package/ts-source/websql-code-prod/builder/column/number-column.ts +25 -0
  183. package/ts-source/websql-code-prod/builder/column/query-column.split-namespaces.json +4 -0
  184. package/ts-source/websql-code-prod/builder/column/query-column.ts +28 -0
  185. package/ts-source/websql-code-prod/builder/column/string-column.split-namespaces.json +4 -0
  186. package/ts-source/websql-code-prod/builder/column/string-column.ts +42 -0
  187. package/ts-source/websql-code-prod/builder/column/value-column.split-namespaces.json +4 -0
  188. package/ts-source/websql-code-prod/builder/column/value-column.ts +39 -0
  189. package/ts-source/websql-code-prod/builder/condition/query-column-condition.split-namespaces.json +4 -0
  190. package/ts-source/websql-code-prod/builder/condition/query-column-condition.ts +29 -0
  191. package/ts-source/websql-code-prod/builder/condition/query-condition-chain.split-namespaces.json +4 -0
  192. package/ts-source/websql-code-prod/builder/condition/query-condition-chain.ts +39 -0
  193. package/ts-source/websql-code-prod/builder/condition/query-condition.split-namespaces.json +4 -0
  194. package/ts-source/websql-code-prod/builder/condition/query-condition.ts +14 -0
  195. package/ts-source/websql-code-prod/builder/condition/query-join-condition.split-namespaces.json +4 -0
  196. package/ts-source/websql-code-prod/builder/condition/query-join-condition.ts +28 -0
  197. package/ts-source/websql-code-prod/builder/helpers/generics-helper.split-namespaces.json +4 -0
  198. package/ts-source/websql-code-prod/builder/helpers/generics-helper.ts +9 -0
  199. package/ts-source/websql-code-prod/builder/helpers/internal-types.split-namespaces.json +4 -0
  200. package/ts-source/websql-code-prod/builder/helpers/internal-types.ts +22 -0
  201. package/ts-source/websql-code-prod/builder/join/joined-tables-chain.split-namespaces.json +4 -0
  202. package/ts-source/websql-code-prod/builder/join/joined-tables-chain.ts +17 -0
  203. package/ts-source/websql-code-prod/builder/join/joined-tables.split-namespaces.json +4 -0
  204. package/ts-source/websql-code-prod/builder/join/joined-tables.ts +25 -0
  205. package/ts-source/websql-code-prod/builder/other/query-ordering.split-namespaces.json +4 -0
  206. package/ts-source/websql-code-prod/builder/other/query-ordering.ts +26 -0
  207. package/ts-source/websql-code-prod/builder/query/select-query.split-namespaces.json +4 -0
  208. package/ts-source/websql-code-prod/builder/query/select-query.ts +60 -0
  209. package/ts-source/websql-code-prod/builder/query/table-condition-query.split-namespaces.json +4 -0
  210. package/ts-source/websql-code-prod/builder/query/table-condition-query.ts +31 -0
  211. package/ts-source/websql-code-prod/builder/query/table-query.split-namespaces.json +4 -0
  212. package/ts-source/websql-code-prod/builder/query/table-query.ts +63 -0
  213. package/ts-source/websql-code-prod/builder/query-source.split-namespaces.json +4 -0
  214. package/ts-source/websql-code-prod/builder/query-source.ts +29 -0
  215. package/ts-source/websql-code-prod/builder/query-table.split-namespaces.json +4 -0
  216. package/ts-source/websql-code-prod/builder/query-table.ts +29 -0
  217. package/ts-source/websql-code-prod/client/mysql.split-namespaces.json +4 -0
  218. package/ts-source/websql-code-prod/client/mysql.ts +14 -0
  219. package/ts-source/websql-code-prod/client/pg.split-namespaces.json +4 -0
  220. package/ts-source/websql-code-prod/client/pg.ts +14 -0
  221. package/ts-source/websql-code-prod/client/query-processor.split-namespaces.json +4 -0
  222. package/ts-source/websql-code-prod/client/query-processor.ts +60 -0
  223. package/ts-source/websql-code-prod/converter/param-converter.split-namespaces.json +4 -0
  224. package/ts-source/websql-code-prod/converter/param-converter.ts +31 -0
  225. package/ts-source/websql-code-prod/converter/parameterized-converter.split-namespaces.json +4 -0
  226. package/ts-source/websql-code-prod/converter/parameterized-converter.ts +22 -0
  227. package/ts-source/websql-code-prod/converter/query-converter.split-namespaces.json +4 -0
  228. package/ts-source/websql-code-prod/converter/query-converter.ts +287 -0
  229. package/ts-source/websql-code-prod/converter/result-converter.split-namespaces.json +4 -0
  230. package/ts-source/websql-code-prod/converter/result-converter.ts +93 -0
  231. package/ts-source/websql-code-prod/converter/sql-converter.split-namespaces.json +4 -0
  232. package/ts-source/websql-code-prod/converter/sql-converter.ts +13 -0
  233. package/ts-source/websql-code-prod/converter/type-converter.split-namespaces.json +4 -0
  234. package/ts-source/websql-code-prod/converter/type-converter.ts +43 -0
  235. package/ts-source/websql-code-prod/converter/types.split-namespaces.json +4 -0
  236. package/ts-source/websql-code-prod/converter/types.ts +12 -0
  237. package/ts-source/websql-code-prod/index._auto-generated_.split-namespaces.json +4 -0
  238. package/ts-source/websql-code-prod/index._auto-generated_.ts +7 -0
  239. package/ts-source/websql-code-prod/index.scss +6 -0
  240. package/ts-source/websql-code-prod/index.split-namespaces.json +4 -0
  241. package/ts-source/websql-code-prod/index.ts +32 -0
  242. package/ts-source/websql-code-prod/lib-info.md +8 -0
  243. package/ts-source/websql-code-prod/migrations/index.split-namespaces.json +4 -0
  244. package/ts-source/websql-code-prod/migrations/index.ts +8 -0
  245. package/ts-source/websql-code-prod/migrations/migrations-info.md +6 -0
  246. package/ts-source/websql-code-prod/migrations/migrations_index._auto-generated_.split-namespaces.json +4 -0
  247. package/ts-source/websql-code-prod/migrations/migrations_index._auto-generated_.ts +7 -0
  248. package/websql/package.json +1 -1
  249. package/websql-prod/package.json +1 -1
@@ -0,0 +1,287 @@
1
+ // @ts-nocheck
2
+ /* ============================================================================
3
+ * TAON READONLY SOURCE
4
+ * DO NOT MODIFY THIS FILE.
5
+ * Changes may be overwritten.
6
+ * ========================================================================== */
7
+
8
+ import { string, number, date, boolean } from './type-converter';
9
+ import { QueryEngine, ConverterOptions } from "./types";
10
+ export function createQueryConverter(paramConverter: (param: any) => string, options: ConverterOptions, engine: QueryEngine) {
11
+ return convertQuery;
12
+ function convertQuery(query: any): string {
13
+ if (query._action === 'select')
14
+ return convertSelectQuery(query);
15
+ if (query._action === 'delete')
16
+ return convertDeleteQuery(query);
17
+ if (query._action === 'update')
18
+ return convertUpdateQuery(query);
19
+ if (query._action === 'insert')
20
+ return convertInsertQuery(query);
21
+ throw new Error('Unknown query type:' + query._action);
22
+ }
23
+ function convertDeleteQuery(query: any): string {
24
+ let s = 'DELETE FROM ' + convertTable(query._table);
25
+ s += convertConditions(query._conditions);
26
+ return s;
27
+ }
28
+ function convertUpdateQuery(query: any): string {
29
+ let s = 'UPDATE ' + convertTable(query._table) + ' SET ';
30
+ s += convertUpdateSetters(query._table, query._entity);
31
+ s += convertConditions(query._conditions);
32
+ return s;
33
+ }
34
+ function convertUpdateSetters(table: any, entity: any): string {
35
+ return Object.keys(entity).sort().map(key => {
36
+ let value = entity[key];
37
+ let column = table[key];
38
+ return convertColumnName(column) + ' = ' + convertParam(column, value);
39
+ }).join(', ');
40
+ }
41
+ function convertInsertQuery(query: any): string {
42
+ let items: any[] = Array.isArray(query._entity) ? query._entity : [query._entity];
43
+ let keySet: Set<string> = items.reduce((set: Set<string>, item) => {
44
+ Object.keys(item).forEach(key => set.add(key));
45
+ return set;
46
+ }, new Set<string>());
47
+ let keys = Array.from(keySet).sort();
48
+ let s = 'INSERT INTO ' + convertTable(query._table) + ' ';
49
+ s += '(' + keys.map(key => convertColumnName(query._table[key])).join(', ') + ')';
50
+ s += options.lineBreak + 'VALUES ';
51
+ s += items.map(item => convertInsertItem(query._table, item, keys))
52
+ .map((row: string) => '(' + row + ')').join(', ');
53
+ s += getPgInsertReturningIfNeeded(query);
54
+ return s;
55
+ }
56
+ function getPgInsertReturningIfNeeded(query: any): string {
57
+ if (engine === 'pg' && query._action === 'insert' && !Array.isArray(query._entity) &&
58
+ query._table.$id && query._table.$id._table && query._table.$id._name) {
59
+ return ' RETURNING ' + convertColumnName(query._table.$id);
60
+ }
61
+ return '';
62
+ }
63
+ function convertInsertItem(table: any, entity: any, keys: string[]): string {
64
+ return keys.map(key => {
65
+ let value = entity[key];
66
+ let column = table[key];
67
+ return convertParam(column, value);
68
+ }).join(', ');
69
+ }
70
+ function convertSelectQuery(query: any): string {
71
+ let s = 'SELECT ';
72
+ if (query._distinct) {
73
+ s += 'DISTINCT ';
74
+ }
75
+ if (query._columns == null || query._columns.length === 0) {
76
+ s += '*';
77
+ }
78
+ else {
79
+ s += query._columns.map((column: any) => convertColumn(column)).join(', ');
80
+ }
81
+ s += options.lineBreak + 'FROM ';
82
+ if (query._tables) {
83
+ s += query._tables.map((table: any) => table._parent ? convertJoin(table) : convertTable(table)).join(', ');
84
+ }
85
+ else {
86
+ s += convertTable(query._table);
87
+ }
88
+ s += convertConditions(query._conditions);
89
+ if (query._groupBy && query._groupBy.length > 0) {
90
+ s += options.lineBreak + 'GROUP BY ';
91
+ s += query._groupBy.map((column: any) => convertColumn(column)).join(', ');
92
+ }
93
+ s += convertConditions(query._having, 'HAVING');
94
+ if (query._orderings && query._orderings.length > 0) {
95
+ s += options.lineBreak + 'ORDER BY ';
96
+ s += query._orderings.map((ordering: any) => convertOrdering(ordering)).join(', ');
97
+ }
98
+ if (query._limit != null) {
99
+ s += options.lineBreak + 'LIMIT ' + number(query._limit);
100
+ }
101
+ if (query._offset != null) {
102
+ s += options.lineBreak + 'OFFSET ' + number(query._offset);
103
+ }
104
+ return s;
105
+ }
106
+ function convertConditions(conditions: any[], keyword = 'WHERE'): string {
107
+ let s = '';
108
+ if (conditions && conditions.length > 0) {
109
+ s += options.lineBreak + keyword + ' ';
110
+ preprocessConditions(conditions);
111
+ s += conditions.map(condition => convertCondition(condition, true)).join(' AND ');
112
+ }
113
+ return s;
114
+ }
115
+ function convertJoin(joinChain: any): string {
116
+ let items: any[] = [];
117
+ while (joinChain) {
118
+ items.push(joinChain);
119
+ joinChain = joinChain._parent;
120
+ }
121
+ let root = items[items.length - 1];
122
+ let s = convertTable(root);
123
+ for (let i = items.length - 2; i >= 0; i -= 2) {
124
+ let table = items[i]._table;
125
+ let modifier = items[i]._modifier;
126
+ let condition = items[i - 1]._condition;
127
+ let param = convertColumn(condition._otherColumn);
128
+ s += ' ' + modifier.toUpperCase() + ' JOIN ' + convertTable(table) + ' ON ' +
129
+ convertColumnCondition(condition, param);
130
+ }
131
+ return s;
132
+ }
133
+ function convertOrdering(ordering: any): string {
134
+ if (ordering._column) {
135
+ let s = convertColumn(ordering._column);
136
+ if (ordering._nullsPosition != null) {
137
+ s += ' IS NULL ' + (ordering._nullsPosition === 'FIRST' ? 'DESC' : 'ASC') + ', ' + s;
138
+ }
139
+ if (ordering._direction === 'ASC')
140
+ s += ' ASC';
141
+ if (ordering._direction === 'DESC')
142
+ s += ' DESC';
143
+ return s;
144
+ }
145
+ else {
146
+ return convertColumn(ordering);
147
+ }
148
+ }
149
+ function convertTable(table: any): string {
150
+ return options.nameEscape + table._$name + options.nameEscape;
151
+ }
152
+ function convertColumn(column: any): string {
153
+ let s = '';
154
+ if (!(column._name === '*' && column._modifiers.length > 0 && column._modifiers[0].name === 'count')) {
155
+ s += convertTable(column._table) + '.';
156
+ }
157
+ s += convertColumnName(column);
158
+ return convertColumnModifiers(s, column);
159
+ }
160
+ function convertColumnModifiers(s: string, column: any): string {
161
+ if (column._modifiers) {
162
+ column._modifiers.forEach((modifier: any) => {
163
+ let name = modifier.name;
164
+ if (name === 'lower')
165
+ s = 'LOWER(' + s + ')';
166
+ else if (name === 'upper')
167
+ s = 'UPPER(' + s + ')';
168
+ else if (name === 'count')
169
+ s = 'COUNT(' + s + ')';
170
+ else if (name === 'sum')
171
+ s = 'SUM(' + s + ')';
172
+ else if (name === 'avg')
173
+ s = 'AVG(' + s + ')';
174
+ else if (name === 'min')
175
+ s = 'MIN(' + s + ')';
176
+ else if (name === 'max')
177
+ s = 'MAX(' + s + ')';
178
+ else if (name === 'as')
179
+ s = s + ' AS ' + options.nameEscape + modifier.params + options.nameEscape;
180
+ });
181
+ }
182
+ return s + '';
183
+ }
184
+ function convertColumnName(column: any): string {
185
+ if (column._name === '*')
186
+ return column._name;
187
+ let name = typeof column._name === 'string' ? column._name : column._name.name;
188
+ return options.nameEscape + name + options.nameEscape;
189
+ }
190
+ function preprocessConditions(conditions: any[]): void {
191
+ conditions.forEach(condition => {
192
+ if (conditions.length > 1 && condition._sibling) {
193
+ condition._parenthesis = true;
194
+ }
195
+ preprocessParams(condition);
196
+ });
197
+ }
198
+ function preprocessParams(condition: any): void {
199
+ if (condition._sibling) {
200
+ preprocessParams(condition._sibling);
201
+ }
202
+ if (!condition._sibling && !condition._child) {
203
+ condition.__param = getConditionParam(condition);
204
+ }
205
+ if (condition._child) {
206
+ preprocessParams(condition._child);
207
+ }
208
+ }
209
+ function convertCondition(condition: any, root = false): string {
210
+ if (!condition._sibling && !condition._child) {
211
+ return convertColumnCondition(condition, condition.__param);
212
+ }
213
+ let s = '';
214
+ if (condition._child) {
215
+ s += convertCondition(condition._child);
216
+ }
217
+ if (condition._sibling) {
218
+ s = convertCondition(condition._sibling, root) + ' ' + condition._chainType.toUpperCase() + ' ' + s;
219
+ }
220
+ if (condition._parenthesis || ((!root || condition._negation) && condition._child)) {
221
+ s = '( ' + s + ' )';
222
+ }
223
+ if (condition._negation) {
224
+ s = 'NOT ' + s;
225
+ }
226
+ return s;
227
+ }
228
+ function convertColumnCondition(condition: any, param: string): string {
229
+ let s = convertColumn(condition._column);
230
+ s += getConditionString(condition, param);
231
+ return s;
232
+ }
233
+ function getConditionString(condition: any, param: string): string {
234
+ switch (condition._type) {
235
+ case 'eq': return ' = ' + param;
236
+ case 'ne': return ' <> ' + param;
237
+ case 'lt': return ' < ' + param;
238
+ case 'gt': return ' > ' + param;
239
+ case 'lte': return ' <= ' + param;
240
+ case 'gte': return ' >= ' + param;
241
+ case 'is-null': return ' IS NULL';
242
+ case 'is-not-null': return ' IS NOT NULL';
243
+ case 'like': return ' LIKE ' + param;
244
+ case 'not-like': return ' NOT LIKE ' + param;
245
+ case 'in': return ' IN (' + param + ')';
246
+ case 'not-in': return ' NOT IN (' + param + ')';
247
+ case 'between': return ' BETWEEN ' + param;
248
+ case 'not-between': return ' NOT BETWEEN ' + param;
249
+ default: return '';
250
+ }
251
+ }
252
+ function getConditionParam(condition: any): string {
253
+ let param = '';
254
+ if (condition._otherColumn) {
255
+ param = convertColumn(condition._otherColumn);
256
+ }
257
+ else {
258
+ let _convertParam = (param: any) => convertParam(condition._column, param);
259
+ if (condition._type === 'in' || condition._type === 'not-in') {
260
+ param = condition._values.map((value: any) => _convertParam(value)).join(', ');
261
+ }
262
+ else if (condition._type === 'between' || condition._type === 'not-between') {
263
+ param = _convertParam(condition._values[0]) + ' AND ' + _convertParam(condition._values[1]);
264
+ }
265
+ else if (condition._type !== 'is-null' && condition._type !== 'is-not-null') {
266
+ param = _convertParam(condition._values[0]);
267
+ }
268
+ }
269
+ return param;
270
+ }
271
+ function convertParam(column: any, param: any): string {
272
+ if (param == null)
273
+ return 'NULL';
274
+ return paramConverter(getTypedParam(column._type, param));
275
+ }
276
+ function getTypedParam(type: string, param: any): any {
277
+ if (type === 'number')
278
+ return number(param);
279
+ else if (type === 'boolean')
280
+ return boolean(param);
281
+ else if (type === 'date')
282
+ return date(param);
283
+ else if (type === 'string')
284
+ return string(param);
285
+ return param;
286
+ }
287
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "namespacesMapObj": {},
3
+ "namespacesReplace": {}
4
+ }
@@ -0,0 +1,93 @@
1
+ // @ts-nocheck
2
+ /* ============================================================================
3
+ * TAON READONLY SOURCE
4
+ * DO NOT MODIFY THIS FILE.
5
+ * Changes may be overwritten.
6
+ * ========================================================================== */
7
+
8
+ import { QueryEngine } from "./types";
9
+ export function convertResult(query: any, result: any, engine: QueryEngine): any {
10
+ let rows = engine === 'pg' ? result.rows : result;
11
+ let rowCount = engine === 'pg' ? result.rowCount : result.affectedRows || result.changedRows;
12
+ if (query._action === 'select')
13
+ return convertSelectResult(query, rows);
14
+ if (query._action === 'delete')
15
+ return rowCount;
16
+ if (query._action === 'update')
17
+ return rowCount;
18
+ if (query._action === 'insert')
19
+ return convertInsertResult(result, engine);
20
+ throw new Error('Unknown query type:' + query._action);
21
+ }
22
+ function convertInsertResult(result: any, engine: QueryEngine): any {
23
+ if (engine === 'mysql')
24
+ return result.insertId > 0 ? result.insertId : undefined;
25
+ if (engine === 'pg' && result.rows && result.rows.length === 1) {
26
+ let columnName = Object.keys(result.rows[0])[0];
27
+ return result.rows[0][columnName];
28
+ }
29
+ }
30
+ function convertSelectResult(query: any, rows: any[]): any {
31
+ if (query._columns && query._columns.length === 1 &&
32
+ !(query._columns[0]._name === '*' && query._columns[0]._modifiers.length === 0)) {
33
+ if (rows.length == 0)
34
+ return [];
35
+ let columnName = Object.keys(rows[0])[0];
36
+ let values = rows.map((row: any) => row[columnName]);
37
+ if (query._columns[0]._name === '*' && query._columns[0]._modifiers.some((m: any) => m.name === 'count')) {
38
+ return values.map((value: any) => Number(value));
39
+ }
40
+ return values;
41
+ }
42
+ else {
43
+ convertAliasFields(query, rows);
44
+ return rows;
45
+ }
46
+ }
47
+ function convertAliasFields(query: any, rows: any[]): void {
48
+ let aliasByName = getColumnAliasesByName(query);
49
+ if (Object.keys(aliasByName).length === 0)
50
+ return;
51
+ rows.forEach((row: any) => {
52
+ Object.keys(row).forEach((name: string) => {
53
+ if (aliasByName[name]) {
54
+ row[aliasByName[name]] = row[name];
55
+ delete row[name];
56
+ }
57
+ });
58
+ });
59
+ }
60
+ function getColumnAliasesByName(query: any): any {
61
+ let aliasByName = {} as any;
62
+ if (query._columns && query._columns.length > 0) {
63
+ query._columns.forEach((column: any) => {
64
+ if (column._name && column._name.alias && column._modifiers.length === 0) {
65
+ aliasByName[column._name.name] = column._name.alias;
66
+ }
67
+ else if (column._name === '*' && column._modifiers.length === 0) {
68
+ getAliasColumnsOfTable(column._table).forEach((column: any) => {
69
+ aliasByName[column._name.name] = column._name.alias;
70
+ });
71
+ }
72
+ });
73
+ }
74
+ else {
75
+ let tables = query._table ? [query._table] : query._tables;
76
+ tables.forEach((table: any) => {
77
+ getAliasColumnsOfTable(table).forEach((column: any) => {
78
+ aliasByName[column._name.name] = column._name.alias;
79
+ });
80
+ let joinTable = table._parent;
81
+ while (joinTable) {
82
+ getAliasColumnsOfTable(joinTable).forEach((column: any) => {
83
+ aliasByName[column._name.name] = column._name.alias;
84
+ });
85
+ joinTable = joinTable._parent;
86
+ }
87
+ });
88
+ }
89
+ return aliasByName;
90
+ }
91
+ function getAliasColumnsOfTable(table: any): any[] {
92
+ return Object.keys(table).map(key => table[key]).filter((column: any) => column && column._name && column._name.alias);
93
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "namespacesMapObj": {},
3
+ "namespacesReplace": {}
4
+ }
@@ -0,0 +1,13 @@
1
+ // @ts-nocheck
2
+ /* ============================================================================
3
+ * TAON READONLY SOURCE
4
+ * DO NOT MODIFY THIS FILE.
5
+ * Changes may be overwritten.
6
+ * ========================================================================== */
7
+
8
+ import { createQueryConverter } from "./query-converter";
9
+ import { convertSubstitutionParam } from './param-converter';
10
+ import { QueryEngine, ConverterOptions } from "./types";
11
+ export function convertQueryToSQL(query: any, options: ConverterOptions, engine: QueryEngine): string {
12
+ return createQueryConverter((param: any) => convertSubstitutionParam(param), options, engine)(query);
13
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "namespacesMapObj": {},
3
+ "namespacesReplace": {}
4
+ }
@@ -0,0 +1,43 @@
1
+ // @ts-nocheck
2
+ /* ============================================================================
3
+ * TAON READONLY SOURCE
4
+ * DO NOT MODIFY THIS FILE.
5
+ * Changes may be overwritten.
6
+ * ========================================================================== */
7
+
8
+ export function number(param: any): number {
9
+ let result = Number(param);
10
+ if (Number.isNaN(result))
11
+ throw new Error('Invalid number parameter in SQL query: ' + param);
12
+ return result;
13
+ }
14
+ export function boolean(param: any): boolean {
15
+ if (typeof param === 'boolean')
16
+ return param;
17
+ if (param instanceof Boolean)
18
+ return param.valueOf();
19
+ if (param === 'true')
20
+ return true;
21
+ if (param === 'false')
22
+ return false;
23
+ throw new Error('Invalid boolean parameter in SQL query: ' + param);
24
+ }
25
+ export function date(param: any): Date {
26
+ if (param instanceof Date)
27
+ return param;
28
+ if (typeof param === 'number' || param instanceof Number)
29
+ return new Date(param);
30
+ if (typeof param === 'string' || param instanceof String) {
31
+ if (Number.isNaN(Date.parse(String(param))))
32
+ throw new Error('Invalid date parameter in SQL query: ' + param);
33
+ return new Date(param);
34
+ }
35
+ throw new Error('Invalid date parameter in SQL query: ' + param);
36
+ }
37
+ export function string(param: any): string {
38
+ if (typeof param === 'string')
39
+ return param;
40
+ if (param instanceof String)
41
+ return param.valueOf();
42
+ throw new Error('Invalid string parameter in SQL query: ' + param);
43
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "namespacesMapObj": {},
3
+ "namespacesReplace": {}
4
+ }
@@ -0,0 +1,12 @@
1
+ // @ts-nocheck
2
+ /* ============================================================================
3
+ * TAON READONLY SOURCE
4
+ * DO NOT MODIFY THIS FILE.
5
+ * Changes may be overwritten.
6
+ * ========================================================================== */
7
+
8
+ export type QueryEngine = 'pg' | 'mysql';
9
+ export interface ConverterOptions {
10
+ lineBreak: string;
11
+ nameEscape: string;
12
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "namespacesMapObj": {},
3
+ "namespacesReplace": {}
4
+ }
@@ -0,0 +1,7 @@
1
+ // @ts-nocheck
2
+ /* ============================================================================
3
+ * TAON READONLY SOURCE
4
+ * DO NOT MODIFY THIS FILE.
5
+ * Changes may be overwritten.
6
+ * ========================================================================== */
7
+
@@ -0,0 +1,6 @@
1
+ /* ============================================================================
2
+ * TAON READONLY SOURCE
3
+ * DO NOT MODIFY THIS FILE.
4
+ * Changes may be overwritten.
5
+ * ========================================================================== */
6
+
@@ -0,0 +1,4 @@
1
+ {
2
+ "namespacesMapObj": {},
3
+ "namespacesReplace": {}
4
+ }
@@ -0,0 +1,32 @@
1
+ // @ts-nocheck
2
+ /* ============================================================================
3
+ * TAON READONLY SOURCE
4
+ * DO NOT MODIFY THIS FILE.
5
+ * Changes may be overwritten.
6
+ * ========================================================================== */
7
+
8
+ export { default as BasicColumn } from './builder/column/basic-column';
9
+ export { default as BooleanColumn } from './builder/column/boolean-column';
10
+ export { default as ComparableColumn } from './builder/column/comparable-column';
11
+ export { default as DateColumn } from './builder/column/date-column';
12
+ export { default as NumberColumn } from './builder/column/number-column';
13
+ export { default as QueryColumn } from './builder/column/query-column';
14
+ export { default as StringColumn } from './builder/column/string-column';
15
+ export { default as ValueColumn } from './builder/column/value-column';
16
+ export { default as QueryColumnCondition } from './builder/condition/query-column-condition';
17
+ export { default as QueryCondition } from './builder/condition/query-condition';
18
+ export { default as QueryConditionChain } from './builder/condition/query-condition-chain';
19
+ export { default as QueryJoinCondition } from './builder/condition/query-join-condition';
20
+ export { default as JoinedTables } from './builder/join/joined-tables';
21
+ export { default as JoinedTablesChain } from './builder/join/joined-tables-chain';
22
+ export { default as QueryOrdering } from './builder/other/query-ordering';
23
+ export { default as SelectQuery } from './builder/query/select-query';
24
+ export { default as TableQuery } from './builder/query/table-query';
25
+ export { default as TableConditionQuery } from './builder/query/table-condition-query';
26
+ export { default as QuerySource } from './builder/query-source';
27
+ export { default as QueryTable } from './builder/query-table';
28
+ export { default as MySqlQuerySource } from './client/mysql';
29
+ export { QueryProcessorOptions } from './client/query-processor';
30
+ export type PropsEntitySQL<IEntityType> = {
31
+ [prop in keyof Required<IEntityType>]: any;
32
+ };
@@ -0,0 +1,8 @@
1
+ THIS FILE IS GENERATED - DO NOT MODIFY
2
+
3
+ This folder is an entry point for npm Angular/NodeJS library
4
+
5
+ DON'T USE STUFF FROM PARENT FOLDER app.* FILES HERE (except src/migrations/** files).
6
+
7
+ THIS FILE IS GENERATED - DO NOT MODIFY
8
+
@@ -0,0 +1,4 @@
1
+ {
2
+ "namespacesMapObj": {},
3
+ "namespacesReplace": {}
4
+ }
@@ -0,0 +1,8 @@
1
+ // @ts-nocheck
2
+ /* ============================================================================
3
+ * TAON READONLY SOURCE
4
+ * DO NOT MODIFY THIS FILE.
5
+ * Changes may be overwritten.
6
+ * ========================================================================== */
7
+
8
+ export * from './migrations_index._auto-generated_';
@@ -0,0 +1,6 @@
1
+ THIS FILE IS GENERATED - DO NOT MODIFY
2
+
3
+ This folder is only for storing migration files with auto-generated names.
4
+
5
+ THIS FILE IS GENERATED - DO NOT MODIFY
6
+
@@ -0,0 +1,4 @@
1
+ {
2
+ "namespacesMapObj": {},
3
+ "namespacesReplace": {}
4
+ }
@@ -0,0 +1,7 @@
1
+ // @ts-nocheck
2
+ /* ============================================================================
3
+ * TAON READONLY SOURCE
4
+ * DO NOT MODIFY THIS FILE.
5
+ * Changes may be overwritten.
6
+ * ========================================================================== */
7
+
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taon-type-sql/websql",
3
- "version": "21.0.68",
3
+ "version": "21.0.69",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^21.0.0",
6
6
  "@angular/core": "^21.0.0"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taon-type-sql/websql-prod",
3
- "version": "21.0.68",
3
+ "version": "21.0.69",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^21.0.0",
6
6
  "@angular/core": "^21.0.0"