@contember/engine-content-api 1.3.0-alpha.1 → 1.3.0-alpha.13

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 (328) hide show
  1. package/dist/src/ExecutionContainer.d.ts +144 -0
  2. package/dist/src/ExecutionContainer.d.ts.map +1 -0
  3. package/dist/src/ExecutionContainer.js +85 -0
  4. package/dist/src/ExecutionContainer.js.map +1 -0
  5. package/dist/src/acl/PermissionFactory.d.ts +5 -4
  6. package/dist/src/acl/PermissionFactory.d.ts.map +1 -1
  7. package/dist/src/acl/PermissionFactory.js +10 -13
  8. package/dist/src/acl/PermissionFactory.js.map +1 -1
  9. package/dist/src/acl/index.d.ts +0 -1
  10. package/dist/src/acl/index.d.ts.map +1 -1
  11. package/dist/src/acl/index.js +0 -1
  12. package/dist/src/acl/index.js.map +1 -1
  13. package/dist/src/index.d.ts +2 -1
  14. package/dist/src/index.d.ts.map +1 -1
  15. package/dist/src/index.js +18 -2
  16. package/dist/src/index.js.map +1 -1
  17. package/dist/src/mapper/ColumnValue.d.ts +2 -2
  18. package/dist/src/mapper/ColumnValue.d.ts.map +1 -1
  19. package/dist/src/mapper/ErrorUtils.d.ts +3 -2
  20. package/dist/src/mapper/ErrorUtils.d.ts.map +1 -1
  21. package/dist/src/mapper/ErrorUtils.js +55 -35
  22. package/dist/src/mapper/ErrorUtils.js.map +1 -1
  23. package/dist/src/mapper/EventManager.d.ts +86 -0
  24. package/dist/src/mapper/EventManager.d.ts.map +1 -0
  25. package/dist/src/mapper/EventManager.js +118 -0
  26. package/dist/src/mapper/EventManager.js.map +1 -0
  27. package/dist/src/mapper/JunctionTableManager.d.ts +12 -11
  28. package/dist/src/mapper/JunctionTableManager.d.ts.map +1 -1
  29. package/dist/src/mapper/JunctionTableManager.js +20 -8
  30. package/dist/src/mapper/JunctionTableManager.js.map +1 -1
  31. package/dist/src/mapper/Mapper.d.ts +13 -6
  32. package/dist/src/mapper/Mapper.d.ts.map +1 -1
  33. package/dist/src/mapper/Mapper.js +41 -21
  34. package/dist/src/mapper/Mapper.js.map +1 -1
  35. package/dist/src/mapper/MapperFactory.d.ts +34 -0
  36. package/dist/src/mapper/MapperFactory.d.ts.map +1 -0
  37. package/dist/src/mapper/MapperFactory.js +41 -0
  38. package/dist/src/mapper/MapperFactory.js.map +1 -0
  39. package/dist/src/mapper/Result.d.ts +5 -3
  40. package/dist/src/mapper/Result.d.ts.map +1 -1
  41. package/dist/src/mapper/Result.js +4 -3
  42. package/dist/src/mapper/Result.js.map +1 -1
  43. package/dist/src/mapper/delete/DeleteExecutor.d.ts.map +1 -1
  44. package/dist/src/mapper/delete/DeleteExecutor.js +41 -1
  45. package/dist/src/mapper/delete/DeleteExecutor.js.map +1 -1
  46. package/dist/src/mapper/index.d.ts +3 -1
  47. package/dist/src/mapper/index.d.ts.map +1 -1
  48. package/dist/src/mapper/index.js +3 -1
  49. package/dist/src/mapper/index.js.map +1 -1
  50. package/dist/src/mapper/insert/InsertBuilder.d.ts +2 -2
  51. package/dist/src/mapper/insert/InsertBuilder.d.ts.map +1 -1
  52. package/dist/src/mapper/insert/InsertBuilder.js +8 -2
  53. package/dist/src/mapper/insert/InsertBuilder.js.map +1 -1
  54. package/dist/src/mapper/insert/Inserter.d.ts +3 -2
  55. package/dist/src/mapper/insert/Inserter.d.ts.map +1 -1
  56. package/dist/src/mapper/insert/Inserter.js +7 -6
  57. package/dist/src/mapper/insert/Inserter.js.map +1 -1
  58. package/dist/src/mapper/select/OrderByHelper.d.ts +1 -1
  59. package/dist/src/mapper/select/OrderByHelper.d.ts.map +1 -1
  60. package/dist/src/mapper/select/OrderByHelper.js +3 -1
  61. package/dist/src/mapper/select/OrderByHelper.js.map +1 -1
  62. package/dist/src/mapper/select/RelationFetcher.js +2 -2
  63. package/dist/src/mapper/select/RelationFetcher.js.map +1 -1
  64. package/dist/src/mapper/update/UpdateBuilder.d.ts +4 -4
  65. package/dist/src/mapper/update/UpdateBuilder.d.ts.map +1 -1
  66. package/dist/src/mapper/update/UpdateBuilder.js +26 -8
  67. package/dist/src/mapper/update/UpdateBuilder.js.map +1 -1
  68. package/dist/src/mapper/update/UpdateBuilderFactory.d.ts +1 -1
  69. package/dist/src/mapper/update/UpdateBuilderFactory.d.ts.map +1 -1
  70. package/dist/src/mapper/update/UpdateBuilderFactory.js +2 -2
  71. package/dist/src/mapper/update/UpdateBuilderFactory.js.map +1 -1
  72. package/dist/src/mapper/update/Updater.d.ts +3 -1
  73. package/dist/src/mapper/update/Updater.d.ts.map +1 -1
  74. package/dist/src/mapper/update/Updater.js +9 -12
  75. package/dist/src/mapper/update/Updater.js.map +1 -1
  76. package/dist/src/resolvers/GraphQlQueryAstFactory.d.ts +1 -3
  77. package/dist/src/resolvers/GraphQlQueryAstFactory.d.ts.map +1 -1
  78. package/dist/src/resolvers/GraphQlQueryAstFactory.js +1 -4
  79. package/dist/src/resolvers/GraphQlQueryAstFactory.js.map +1 -1
  80. package/dist/src/resolvers/MutationResolver.d.ts +3 -4
  81. package/dist/src/resolvers/MutationResolver.d.ts.map +1 -1
  82. package/dist/src/resolvers/MutationResolver.js +11 -12
  83. package/dist/src/resolvers/MutationResolver.js.map +1 -1
  84. package/dist/src/resolvers/ReadResolver.d.ts +1 -3
  85. package/dist/src/resolvers/ReadResolver.d.ts.map +1 -1
  86. package/dist/src/resolvers/ReadResolver.js +6 -10
  87. package/dist/src/resolvers/ReadResolver.js.map +1 -1
  88. package/dist/src/resolvers/ValidationResolver.d.ts +1 -3
  89. package/dist/src/resolvers/ValidationResolver.d.ts.map +1 -1
  90. package/dist/src/resolvers/ValidationResolver.js +3 -4
  91. package/dist/src/resolvers/ValidationResolver.js.map +1 -1
  92. package/dist/src/resolvers/index.d.ts +0 -1
  93. package/dist/src/resolvers/index.d.ts.map +1 -1
  94. package/dist/src/resolvers/index.js +0 -1
  95. package/dist/src/resolvers/index.js.map +1 -1
  96. package/dist/src/schema/CustomTypesProvider.d.ts.map +1 -1
  97. package/dist/src/schema/CustomTypesProvider.js +1 -23
  98. package/dist/src/schema/CustomTypesProvider.js.map +1 -1
  99. package/dist/src/schema/MutationProvider.js +4 -4
  100. package/dist/src/schema/MutationProvider.js.map +1 -1
  101. package/dist/src/schema/QueryProvider.js +3 -3
  102. package/dist/src/schema/QueryProvider.js.map +1 -1
  103. package/dist/src/tsconfig.tsbuildinfo +1 -1
  104. package/dist/src/types.d.ts +3 -4
  105. package/dist/src/types.d.ts.map +1 -1
  106. package/dist/src/utils/index.d.ts +0 -1
  107. package/dist/src/utils/index.d.ts.map +1 -1
  108. package/dist/src/utils/index.js +0 -1
  109. package/dist/src/utils/index.js.map +1 -1
  110. package/dist/src/utils/uniqueWhereFields.js +1 -1
  111. package/dist/src/utils/uniqueWhereFields.js.map +1 -1
  112. package/dist/tests/cases/bugs/bug-update-by-nested-unique.test.js +3 -5
  113. package/dist/tests/cases/bugs/bug-update-by-nested-unique.test.js.map +1 -1
  114. package/dist/tests/cases/integration/graphQlDb/insert/insertSequence.test.js +2 -2
  115. package/dist/tests/cases/integration/graphQlDb/insert/insertSequence.test.js.map +1 -1
  116. package/dist/tests/cases/integration/graphQlDb/update/bug-freeze-connect-missing-one.test.js +1 -1
  117. package/dist/tests/cases/integration/graphQlDb/update/bug-freeze-connect-missing-one.test.js.map +1 -1
  118. package/dist/tests/cases/integration/graphQlDb/update/deferedConstraints.test.js +45 -45
  119. package/dist/tests/cases/integration/graphQlDb/update/deferedConstraints.test.js.map +1 -1
  120. package/dist/tests/cases/integration/graphQlDb/update/failedDelete.test.js +5 -5
  121. package/dist/tests/cases/integration/graphQlDb/update/failedDelete.test.js.map +1 -1
  122. package/dist/tests/cases/integration/graphQlDb/update/invalidInput.test.js +2 -2
  123. package/dist/tests/cases/integration/graphQlDb/update/invalidInput.test.js.map +1 -1
  124. package/dist/tests/cases/integration/graphQlDb/update/nullChecksNotNull.test.js +7 -7
  125. package/dist/tests/cases/integration/graphQlDb/update/nullChecksNotNull.test.js.map +1 -1
  126. package/dist/tests/cases/integration/graphQlDb/update/nullChecksNullable.test.js +7 -7
  127. package/dist/tests/cases/integration/graphQlDb/update/nullChecksNullable.test.js.map +1 -1
  128. package/dist/tests/cases/integration/graphQlDb/update/uniqueConstraint.test.js +2 -2
  129. package/dist/tests/cases/integration/graphQlDb/update/uniqueConstraint.test.js.map +1 -1
  130. package/dist/tests/cases/integration/graphQlRequests/insert/oneHasMany/connect.test.js +3 -3
  131. package/dist/tests/cases/integration/graphQlRequests/insert/oneHasMany/connect.test.js.map +1 -1
  132. package/dist/tests/cases/integration/graphQlRequests/query/acl/isNullAcl.test.d.ts +2 -0
  133. package/dist/tests/cases/integration/graphQlRequests/query/acl/isNullAcl.test.d.ts.map +1 -0
  134. package/dist/tests/cases/integration/graphQlRequests/query/acl/isNullAcl.test.js +91 -0
  135. package/dist/tests/cases/integration/graphQlRequests/query/acl/isNullAcl.test.js.map +1 -0
  136. package/dist/tests/cases/integration/graphQlRequests/query/acl/rowPredicateSubset.test.js +1 -1
  137. package/dist/tests/cases/integration/graphQlRequests/query/acl/rowPredicateSubset.test.js.map +1 -1
  138. package/dist/tests/cases/integration/graphQlRequests/query/sorting/orderBy.test.d.ts +2 -0
  139. package/dist/tests/cases/integration/graphQlRequests/query/sorting/orderBy.test.d.ts.map +1 -0
  140. package/dist/tests/cases/integration/graphQlRequests/query/sorting/orderBy.test.js +67 -0
  141. package/dist/tests/cases/integration/graphQlRequests/query/sorting/orderBy.test.js.map +1 -0
  142. package/dist/tests/cases/integration/graphQlRequests/update/acl/aclUpdate.test.js +6 -18
  143. package/dist/tests/cases/integration/graphQlRequests/update/acl/aclUpdate.test.js.map +1 -1
  144. package/dist/tests/cases/integration/graphQlRequests/update/additionalFilter.test.js +3 -4
  145. package/dist/tests/cases/integration/graphQlRequests/update/additionalFilter.test.js.map +1 -1
  146. package/dist/tests/cases/integration/graphQlRequests/update/basic/columnUpdate.test.js +3 -8
  147. package/dist/tests/cases/integration/graphQlRequests/update/basic/columnUpdate.test.js.map +1 -1
  148. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/update.test.js +3 -9
  149. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/update.test.js.map +1 -1
  150. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/upsert.test.js +3 -9
  151. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/upsert.test.js.map +1 -1
  152. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/update.test.js +3 -9
  153. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/update.test.js.map +1 -1
  154. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/upsert.test.js +3 -9
  155. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/upsert.test.js.map +1 -1
  156. package/dist/tests/cases/integration/graphQlRequests/update/manyHasOne/connect.test.js +3 -10
  157. package/dist/tests/cases/integration/graphQlRequests/update/manyHasOne/connect.test.js.map +1 -1
  158. package/dist/tests/cases/integration/graphQlRequests/update/manyHasOne/create.test.js +3 -10
  159. package/dist/tests/cases/integration/graphQlRequests/update/manyHasOne/create.test.js.map +1 -1
  160. package/dist/tests/cases/integration/graphQlRequests/update/manyHasOne/disconnect.test.js +3 -9
  161. package/dist/tests/cases/integration/graphQlRequests/update/manyHasOne/disconnect.test.js.map +1 -1
  162. package/dist/tests/cases/integration/graphQlRequests/update/manyHasOne/update.test.js +3 -9
  163. package/dist/tests/cases/integration/graphQlRequests/update/manyHasOne/update.test.js.map +1 -1
  164. package/dist/tests/cases/integration/graphQlRequests/update/manyHasOne/upsert.test.js +6 -18
  165. package/dist/tests/cases/integration/graphQlRequests/update/manyHasOne/upsert.test.js.map +1 -1
  166. package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/connect.test.js +3 -11
  167. package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/connect.test.js.map +1 -1
  168. package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/disconnect.test.js +3 -8
  169. package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/disconnect.test.js.map +1 -1
  170. package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/update.test.js +3 -6
  171. package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/update.test.js.map +1 -1
  172. package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/upsert.test.js +3 -6
  173. package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/upsert.test.js.map +1 -1
  174. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/connect.test.js +15 -50
  175. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/connect.test.js.map +1 -1
  176. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/create.test.js +3 -10
  177. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/create.test.js.map +1 -1
  178. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/disconnect.test.js +3 -10
  179. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/disconnect.test.js.map +1 -1
  180. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/update.test.js +3 -6
  181. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/update.test.js.map +1 -1
  182. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/upsert.test.js +3 -7
  183. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/upsert.test.js.map +1 -1
  184. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/connect.test.js +12 -32
  185. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/connect.test.js.map +1 -1
  186. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/connectOrCreate.test.js +3 -3
  187. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/connectOrCreate.test.js.map +1 -1
  188. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/create.test.js +6 -20
  189. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/create.test.js.map +1 -1
  190. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/disconnect.test.js +3 -10
  191. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/disconnect.test.js.map +1 -1
  192. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/update.test.js +3 -9
  193. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/update.test.js.map +1 -1
  194. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/upsert.test.js +6 -19
  195. package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/upsert.test.js.map +1 -1
  196. package/dist/tests/cases/integration/graphQlRequests/update/queryPortal.test.js +6 -8
  197. package/dist/tests/cases/integration/graphQlRequests/update/queryPortal.test.js.map +1 -1
  198. package/dist/tests/cases/integration/graphQlRequests/update/transaction.test.js +9 -24
  199. package/dist/tests/cases/integration/graphQlRequests/update/transaction.test.js.map +1 -1
  200. package/dist/tests/cases/integration/graphQlRequests/upsert/basicUpsert.test.js +3 -7
  201. package/dist/tests/cases/integration/graphQlRequests/upsert/basicUpsert.test.js.map +1 -1
  202. package/dist/tests/cases/unit/orderbyHelper.test.js +13 -2
  203. package/dist/tests/cases/unit/orderbyHelper.test.js.map +1 -1
  204. package/dist/tests/cases/unit/permissionMerger.test.js +8 -3
  205. package/dist/tests/cases/unit/permissionMerger.test.js.map +1 -1
  206. package/dist/tests/cases/unit/predicatesInjector.test.js +1 -1
  207. package/dist/tests/cases/unit/predicatesInjector.test.js.map +1 -1
  208. package/dist/tests/src/test.d.ts +1 -0
  209. package/dist/tests/src/test.d.ts.map +1 -1
  210. package/dist/tests/src/test.js +35 -6
  211. package/dist/tests/src/test.js.map +1 -1
  212. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  213. package/package.json +16 -13
  214. package/src/ExecutionContainer.ts +208 -0
  215. package/src/acl/PermissionFactory.ts +15 -13
  216. package/src/acl/index.ts +0 -1
  217. package/src/index.ts +24 -1
  218. package/src/mapper/ColumnValue.ts +2 -2
  219. package/src/mapper/ErrorUtils.ts +66 -41
  220. package/src/mapper/EventManager.ts +158 -0
  221. package/src/mapper/JunctionTableManager.ts +50 -32
  222. package/src/mapper/Mapper.ts +48 -27
  223. package/src/mapper/MapperFactory.ts +69 -0
  224. package/src/mapper/Result.ts +5 -2
  225. package/src/mapper/delete/DeleteExecutor.ts +42 -1
  226. package/src/mapper/index.ts +3 -1
  227. package/src/mapper/insert/InsertBuilder.ts +12 -2
  228. package/src/mapper/insert/Inserter.ts +7 -7
  229. package/src/mapper/select/OrderByHelper.ts +2 -1
  230. package/src/mapper/select/RelationFetcher.ts +2 -2
  231. package/src/mapper/update/UpdateBuilder.ts +30 -7
  232. package/src/mapper/update/UpdateBuilderFactory.ts +2 -2
  233. package/src/mapper/update/Updater.ts +9 -13
  234. package/src/resolvers/GraphQlQueryAstFactory.ts +1 -2
  235. package/src/resolvers/MutationResolver.ts +15 -14
  236. package/src/resolvers/ReadResolver.ts +5 -9
  237. package/src/resolvers/ValidationResolver.ts +2 -4
  238. package/src/resolvers/index.ts +0 -1
  239. package/src/schema/CustomTypesProvider.ts +2 -27
  240. package/src/schema/MutationProvider.ts +4 -4
  241. package/src/schema/QueryProvider.ts +3 -3
  242. package/src/tsconfig.json +7 -21
  243. package/src/types.ts +3 -4
  244. package/src/utils/index.ts +0 -1
  245. package/src/utils/uniqueWhereFields.ts +1 -1
  246. package/tests/cases/bugs/bug-update-by-nested-unique.test.ts +3 -5
  247. package/tests/cases/integration/graphQlDb/insert/insertSequence.test.ts +2 -2
  248. package/tests/cases/integration/graphQlDb/update/bug-freeze-connect-missing-one.test.ts +1 -1
  249. package/tests/cases/integration/graphQlDb/update/deferedConstraints.test.ts +9 -9
  250. package/tests/cases/integration/graphQlDb/update/failedDelete.test.ts +3 -3
  251. package/tests/cases/integration/graphQlDb/update/invalidInput.test.ts +2 -2
  252. package/tests/cases/integration/graphQlDb/update/nullChecksNotNull.test.ts +7 -7
  253. package/tests/cases/integration/graphQlDb/update/nullChecksNullable.test.ts +7 -7
  254. package/tests/cases/integration/graphQlDb/update/uniqueConstraint.test.ts +2 -2
  255. package/tests/cases/integration/graphQlRequests/insert/oneHasMany/connect.test.ts +3 -3
  256. package/tests/cases/integration/graphQlRequests/query/acl/isNullAcl.test.ts +77 -0
  257. package/tests/cases/integration/graphQlRequests/query/acl/rowPredicateSubset.test.ts +1 -1
  258. package/tests/cases/integration/graphQlRequests/query/sorting/orderBy.test.ts +67 -0
  259. package/tests/cases/integration/graphQlRequests/update/acl/aclUpdate.test.ts +6 -18
  260. package/tests/cases/integration/graphQlRequests/update/additionalFilter.test.ts +3 -4
  261. package/tests/cases/integration/graphQlRequests/update/basic/columnUpdate.test.ts +3 -8
  262. package/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/update.test.ts +3 -9
  263. package/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/upsert.test.ts +3 -9
  264. package/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/update.test.ts +3 -9
  265. package/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/upsert.test.ts +3 -9
  266. package/tests/cases/integration/graphQlRequests/update/manyHasOne/connect.test.ts +3 -10
  267. package/tests/cases/integration/graphQlRequests/update/manyHasOne/create.test.ts +3 -10
  268. package/tests/cases/integration/graphQlRequests/update/manyHasOne/disconnect.test.ts +3 -9
  269. package/tests/cases/integration/graphQlRequests/update/manyHasOne/update.test.ts +3 -9
  270. package/tests/cases/integration/graphQlRequests/update/manyHasOne/upsert.test.ts +6 -18
  271. package/tests/cases/integration/graphQlRequests/update/oneHasMany/connect.test.ts +3 -11
  272. package/tests/cases/integration/graphQlRequests/update/oneHasMany/disconnect.test.ts +3 -8
  273. package/tests/cases/integration/graphQlRequests/update/oneHasMany/update.test.ts +3 -6
  274. package/tests/cases/integration/graphQlRequests/update/oneHasMany/upsert.test.ts +3 -6
  275. package/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/connect.test.ts +15 -50
  276. package/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/create.test.ts +3 -10
  277. package/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/disconnect.test.ts +3 -10
  278. package/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/update.test.ts +3 -6
  279. package/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/upsert.test.ts +3 -7
  280. package/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/connect.test.ts +12 -32
  281. package/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/connectOrCreate.test.ts +3 -3
  282. package/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/create.test.ts +6 -20
  283. package/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/disconnect.test.ts +3 -10
  284. package/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/update.test.ts +3 -9
  285. package/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/upsert.test.ts +6 -19
  286. package/tests/cases/integration/graphQlRequests/update/queryPortal.test.ts +6 -8
  287. package/tests/cases/integration/graphQlRequests/update/transaction.test.ts +9 -24
  288. package/tests/cases/integration/graphQlRequests/upsert/basicUpsert.test.ts +3 -7
  289. package/tests/cases/unit/orderbyHelper.test.ts +15 -2
  290. package/tests/cases/unit/permissionMerger.test.ts +9 -4
  291. package/tests/cases/unit/predicatesInjector.test.ts +1 -1
  292. package/tests/src/test.ts +40 -16
  293. package/tests/tsconfig.json +3 -9
  294. package/dist/src/acl/PermissionsByIdentityFactory.d.ts +0 -12
  295. package/dist/src/acl/PermissionsByIdentityFactory.d.ts.map +0 -1
  296. package/dist/src/acl/PermissionsByIdentityFactory.js +0 -15
  297. package/dist/src/acl/PermissionsByIdentityFactory.js.map +0 -1
  298. package/dist/src/mapper/MapperContainer.d.ts +0 -18
  299. package/dist/src/mapper/MapperContainer.d.ts.map +0 -1
  300. package/dist/src/mapper/MapperContainer.js +0 -55
  301. package/dist/src/mapper/MapperContainer.js.map +0 -1
  302. package/dist/src/resolvers/ExecutionContainerFactory.d.ts +0 -24
  303. package/dist/src/resolvers/ExecutionContainerFactory.d.ts.map +0 -1
  304. package/dist/src/resolvers/ExecutionContainerFactory.js +0 -45
  305. package/dist/src/resolvers/ExecutionContainerFactory.js.map +0 -1
  306. package/dist/src/utils/arrays.d.ts +0 -3
  307. package/dist/src/utils/arrays.d.ts.map +0 -1
  308. package/dist/src/utils/arrays.js +0 -22
  309. package/dist/src/utils/arrays.js.map +0 -1
  310. package/dist/tests/cases/integration/graphQlSchema/schema-acl-allowed.gql +0 -420
  311. package/dist/tests/cases/integration/graphQlSchema/schema-acl-create-only.gql +0 -229
  312. package/dist/tests/cases/integration/graphQlSchema/schema-acl-predicate.gql +0 -112
  313. package/dist/tests/cases/integration/graphQlSchema/schema-acl-predicate2.gql +0 -112
  314. package/dist/tests/cases/integration/graphQlSchema/schema-acl-restricted-create.gql +0 -309
  315. package/dist/tests/cases/integration/graphQlSchema/schema-acl-restricted-delete.gql +0 -402
  316. package/dist/tests/cases/integration/graphQlSchema/schema-acl-restricted-update.gql +0 -338
  317. package/dist/tests/cases/integration/graphQlSchema/schema-acl.gql +0 -221
  318. package/dist/tests/cases/integration/graphQlSchema/schema-aliased-type.gql +0 -226
  319. package/dist/tests/cases/integration/graphQlSchema/schema-basic.gql +0 -841
  320. package/dist/tests/cases/integration/graphQlSchema/schema-bug-66.gql +0 -540
  321. package/dist/tests/cases/integration/graphQlSchema/schema-custom-primary.gql +0 -851
  322. package/dist/tests/cases/integration/graphQlSchema/schema-has-many-reduction.gql +0 -453
  323. package/dist/tests/cases/integration/graphQlSchema/schema-new-builder.gql +0 -912
  324. package/dist/tests/cases/integration/graphQlSchema/schema-view-entity.gql +0 -112
  325. package/src/acl/PermissionsByIdentityFactory.ts +0 -21
  326. package/src/mapper/MapperContainer.ts +0 -142
  327. package/src/resolvers/ExecutionContainerFactory.ts +0 -74
  328. package/src/utils/arrays.ts +0 -19
@@ -31,11 +31,9 @@ test('Update by nested unique where', async () => {
31
31
  parameters: ['en'],
32
32
  },
33
33
  {
34
- sql: SQL`
35
- with "newData_" as
36
- (select ? :: text as "title", "root_"."id", "root_"."site_id" from "public"."front_page" as "root_" where "root_"."id" = ?)
37
- update "public"."front_page" set "title" = "newData_"."title" from "newData_" where "front_page"."id" = "newData_"."id"`,
38
- response: { rowCount: 1 },
34
+ sql: SQL`with "newData_" as (select ? :: text as "title", "root_"."title" as "title_old__", "root_"."id", "root_"."site_id" from "public"."front_page" as "root_" where "root_"."id" = ?)
35
+ update "public"."front_page" set "title" = "newData_"."title" from "newData_" where "front_page"."id" = "newData_"."id" returning "title_old__"`,
36
+ response: { rows: [{}] },
39
37
  parameters: ['Hello', testUuid(1)],
40
38
  },
41
39
  ]),
@@ -10,9 +10,9 @@ namespace SeqModel {
10
10
  }
11
11
 
12
12
  test('insert author with id', async () => {
13
- const schema = def.createModel(SeqModel)
13
+ const model = def.createModel(SeqModel)
14
14
  await executeDbTest({
15
- schema: schema,
15
+ schema: { model },
16
16
  query: GQL`
17
17
  mutation {
18
18
  createOrder(data: {}) {
@@ -18,7 +18,7 @@ namespace Model {
18
18
  }
19
19
  test('create redirect to non-existing target', async () => {
20
20
  await executeDbTest({
21
- schema: def.createModel(Model),
21
+ schema: { model: def.createModel(Model) },
22
22
  query: GQL`
23
23
  mutation {
24
24
  createRedirect(
@@ -6,7 +6,7 @@ import { executeDbTest } from '@contember/engine-api-tester'
6
6
 
7
7
  test('delete without deferring constraints', async () => {
8
8
  await executeDbTest({
9
- schema: new SchemaBuilder()
9
+ schema: { model: new SchemaBuilder()
10
10
  .entity('Post', entity =>
11
11
  entity
12
12
  .column('slug')
@@ -25,7 +25,7 @@ test('delete without deferring constraints', async () => {
25
25
  .manyHasOne('attachment', relation => relation.target('Attachment').inversedBy('refereces'))
26
26
  .unique(['slug']),
27
27
  )
28
- .buildSchema(),
28
+ .buildSchema() },
29
29
  seed: [
30
30
  {
31
31
  query: `mutation {
@@ -60,10 +60,10 @@ test('delete without deferring constraints', async () => {
60
60
  return: {
61
61
  transaction: {
62
62
  ok: false,
63
- errorMessage: 'Execution has failed:\nupdatePost.attachments.0: ForeignKeyConstraintViolation (Cannot delete 123e4567-e89b-12d3-a456-000000000002 row(s) of entity Attachment, because it is still referenced from 123e4567-e89b-12d3-a456-000000000003 row(s) of entity Reference in relation attachment. OnDelete behaviour of this relation is set to "restrict". You might consider changing it to "setNull" or "cascade".)',
63
+ errorMessage: 'Execution has failed:\nupdatePost.attachments.0: ForeignKeyConstraintViolation (Cannot delete 123e4567-e89b-12d3-a456-000000000004 row(s) of entity Attachment, because it is still referenced from 123e4567-e89b-12d3-a456-000000000006 row(s) of entity Reference in relation attachment. OnDelete behaviour of this relation is set to "restrict". You might consider changing it to "setNull" or "cascade".)',
64
64
  updatePost: {
65
65
  ok: false,
66
- errorMessage: 'Execution has failed:\nattachments.0: ForeignKeyConstraintViolation (Cannot delete 123e4567-e89b-12d3-a456-000000000002 row(s) of entity Attachment, because it is still referenced from 123e4567-e89b-12d3-a456-000000000003 row(s) of entity Reference in relation attachment. OnDelete behaviour of this relation is set to "restrict". You might consider changing it to "setNull" or "cascade".)',
66
+ errorMessage: 'Execution has failed:\nattachments.0: ForeignKeyConstraintViolation (Cannot delete 123e4567-e89b-12d3-a456-000000000004 row(s) of entity Attachment, because it is still referenced from 123e4567-e89b-12d3-a456-000000000006 row(s) of entity Reference in relation attachment. OnDelete behaviour of this relation is set to "restrict". You might consider changing it to "setNull" or "cascade".)',
67
67
  },
68
68
  },
69
69
  },
@@ -73,7 +73,7 @@ test('delete without deferring constraints', async () => {
73
73
 
74
74
  test('delete with successfully deferring constraints', async () => {
75
75
  await executeDbTest({
76
- schema: new SchemaBuilder()
76
+ schema: { model: new SchemaBuilder()
77
77
  .entity('Post', entity =>
78
78
  entity
79
79
  .column('slug')
@@ -92,7 +92,7 @@ test('delete with successfully deferring constraints', async () => {
92
92
  .manyHasOne('attachment', relation => relation.target('Attachment').inversedBy('refereces'))
93
93
  .unique(['slug']),
94
94
  )
95
- .buildSchema(),
95
+ .buildSchema() },
96
96
  seed: [
97
97
  {
98
98
  query: `mutation {
@@ -140,7 +140,7 @@ test('delete with successfully deferring constraints', async () => {
140
140
 
141
141
  test('delete with unsuccessfully deferring constraints', async () => {
142
142
  await executeDbTest({
143
- schema: new SchemaBuilder()
143
+ schema: { model: new SchemaBuilder()
144
144
  .entity('Post', entity =>
145
145
  entity
146
146
  .column('slug')
@@ -159,7 +159,7 @@ test('delete with unsuccessfully deferring constraints', async () => {
159
159
  .manyHasOne('attachment', relation => relation.target('Attachment').inversedBy('refereces'))
160
160
  .unique(['slug']),
161
161
  )
162
- .buildSchema(),
162
+ .buildSchema() },
163
163
  seed: [
164
164
  {
165
165
  query: `mutation {
@@ -194,7 +194,7 @@ test('delete with unsuccessfully deferring constraints', async () => {
194
194
  return: {
195
195
  transaction: {
196
196
  ok: false,
197
- errorMessage: 'Execution has failed:\nunknown field: ForeignKeyConstraintViolation (Cannot delete row 123e4567-e89b-12d3-a456-000000000002 of entity Attachment, because it is still referenced from Reference::attachment. This is possibly caused by ACL denial or by missing "on delete cascade")',
197
+ errorMessage: 'Execution has failed:\nunknown field: ForeignKeyConstraintViolation (Cannot delete row 123e4567-e89b-12d3-a456-000000000004 of entity Attachment, because it is still referenced from Reference::attachment. This is possibly caused by ACL denial or by missing "on delete cascade")',
198
198
  updatePost: {
199
199
  ok: false,
200
200
  errorMessage: null,
@@ -6,14 +6,14 @@ import { executeDbTest } from '@contember/engine-api-tester'
6
6
 
7
7
  test('fails when deleting entity without proper cascade', async () => {
8
8
  await executeDbTest({
9
- schema: new SchemaBuilder()
9
+ schema: { model: new SchemaBuilder()
10
10
  .entity('Post', entity =>
11
11
  entity.column('slug').unique(['slug']),
12
12
  )
13
13
  .entity('PostLocales', entity =>
14
14
  entity.manyHasOne('post', relation => relation.target('Post').inversedBy('locales')).column('title'),
15
15
  )
16
- .buildSchema(),
16
+ .buildSchema() },
17
17
  seed: [
18
18
  {
19
19
  query: `mutation {
@@ -37,7 +37,7 @@ test('fails when deleting entity without proper cascade', async () => {
37
37
  }`,
38
38
  return: {
39
39
  deletePost: {
40
- errorMessage: 'Execution has failed:\nunknown field: ForeignKeyConstraintViolation (Cannot delete 123e4567-e89b-12d3-a456-000000000001 row(s) of entity Post, because it is still referenced from 123e4567-e89b-12d3-a456-000000000002 row(s) of entity PostLocales in relation post. OnDelete behaviour of this relation is set to "restrict". You might consider changing it to "setNull" or "cascade".)',
40
+ errorMessage: 'Execution has failed:\nunknown field: ForeignKeyConstraintViolation (Cannot delete 123e4567-e89b-12d3-a456-000000000003 row(s) of entity Post, because it is still referenced from 123e4567-e89b-12d3-a456-000000000004 row(s) of entity PostLocales in relation post. OnDelete behaviour of this relation is set to "restrict". You might consider changing it to "setNull" or "cascade".)',
41
41
  node: null,
42
42
  },
43
43
  },
@@ -4,7 +4,7 @@ import { test, assert } from 'vitest'
4
4
  import { executeDbTest } from '@contember/engine-api-tester'
5
5
  import { GQL } from '../../../../src/tags'
6
6
 
7
- const schema = new SchemaBuilder()
7
+ const model = new SchemaBuilder()
8
8
  .entity('Post', e =>
9
9
  e
10
10
  .column('slug', c => c.type(Model.ColumnType.String).unique())
@@ -13,7 +13,7 @@ const schema = new SchemaBuilder()
13
13
  .buildSchema()
14
14
  test('returns error for invalid date input', async () => {
15
15
  await executeDbTest({
16
- schema,
16
+ schema: { model },
17
17
  seed: [
18
18
  {
19
19
  query: GQL`mutation {
@@ -5,7 +5,7 @@ import { executeDbTest } from '@contember/engine-api-tester'
5
5
  import { GQL } from '../../../../src/tags'
6
6
  import { testUuid } from '../../../../src/testUuid'
7
7
 
8
- const schema = new SchemaBuilder()
8
+ const model = new SchemaBuilder()
9
9
  .entity('Site', e =>
10
10
  e
11
11
  .column('slug', c => c.unique().type(Model.ColumnType.String))
@@ -17,7 +17,7 @@ const schema = new SchemaBuilder()
17
17
 
18
18
  test('update site & create contact page', async () => {
19
19
  await executeDbTest({
20
- schema,
20
+ schema: { model },
21
21
  seed: [
22
22
  {
23
23
  query: GQL`mutation {
@@ -38,15 +38,15 @@ test('update site & create contact page', async () => {
38
38
  },
39
39
  },
40
40
  expectDatabase: {
41
- site: [{ id: testUuid(1), slug: 'en', contact_page_id: testUuid(2) }],
42
- contact_page: [{ id: testUuid(2), title: 'Test' }],
41
+ site: [{ id: testUuid(3), slug: 'en', contact_page_id: testUuid(5) }],
42
+ contact_page: [{ id: testUuid(5), title: 'Test' }],
43
43
  },
44
44
  })
45
45
  })
46
46
 
47
47
  test('update site & try to create contact page which however exists', async () => {
48
48
  await executeDbTest({
49
- schema,
49
+ schema: { model },
50
50
  seed: [
51
51
  {
52
52
  query: GQL`mutation {
@@ -75,8 +75,8 @@ test('update site & try to create contact page which however exists', async () =
75
75
  },
76
76
  },
77
77
  expectDatabase: {
78
- site: [{ id: testUuid(1), slug: 'en', contact_page_id: testUuid(2) }],
79
- contact_page: [{ id: testUuid(2), title: 'Test' }],
78
+ site: [{ id: testUuid(3), slug: 'en', contact_page_id: testUuid(4) }],
79
+ contact_page: [{ id: testUuid(4), title: 'Test' }],
80
80
  },
81
81
  })
82
82
  })
@@ -5,7 +5,7 @@ import { executeDbTest } from '@contember/engine-api-tester'
5
5
  import { GQL } from '../../../../src/tags'
6
6
  import { testUuid } from '../../../../src/testUuid'
7
7
 
8
- const schema = new SchemaBuilder()
8
+ const model = new SchemaBuilder()
9
9
  .entity('Site', e => e.column('slug', c => c.unique().type(Model.ColumnType.String)))
10
10
  .entity('ContactPage', e =>
11
11
  e.column('title').oneHasOne('site', r => r.target('Site').inversedBy('contactPage').notNull()),
@@ -14,7 +14,7 @@ const schema = new SchemaBuilder()
14
14
 
15
15
  test('update site & create contact page', async () => {
16
16
  await executeDbTest({
17
- schema,
17
+ schema: { model },
18
18
  seed: [
19
19
  {
20
20
  query: GQL`mutation {
@@ -35,15 +35,15 @@ test('update site & create contact page', async () => {
35
35
  },
36
36
  },
37
37
  expectDatabase: {
38
- site: [{ id: testUuid(1), slug: 'en' }],
39
- contact_page: [{ site_id: testUuid(1), id: testUuid(2), title: 'Test' }],
38
+ site: [{ id: testUuid(3), slug: 'en' }],
39
+ contact_page: [{ site_id: testUuid(3), id: testUuid(5), title: 'Test' }],
40
40
  },
41
41
  })
42
42
  })
43
43
 
44
44
  test('update site & try to create contact page which however exists', async () => {
45
45
  await executeDbTest({
46
- schema,
46
+ schema: { model },
47
47
  seed: [
48
48
  {
49
49
  query: GQL`mutation {
@@ -72,8 +72,8 @@ test('update site & try to create contact page which however exists', async () =
72
72
  },
73
73
  },
74
74
  expectDatabase: {
75
- site: [{ id: testUuid(1), slug: 'en' }],
76
- contact_page: [{ site_id: testUuid(1), id: testUuid(2), title: 'Test' }],
75
+ site: [{ id: testUuid(3), slug: 'en' }],
76
+ contact_page: [{ site_id: testUuid(3), id: testUuid(4), title: 'Test' }],
77
77
  },
78
78
  })
79
79
  })
@@ -4,7 +4,7 @@ import { test } from 'vitest'
4
4
  import { executeDbTest } from '@contember/engine-api-tester'
5
5
  import { GQL } from '../../../../src/tags'
6
6
 
7
- const schema = new SchemaBuilder()
7
+ const model = new SchemaBuilder()
8
8
  .entity('Site', e =>
9
9
  e.column('slug', c => c.unique().type(Model.ColumnType.String)),
10
10
  )
@@ -12,7 +12,7 @@ const schema = new SchemaBuilder()
12
12
 
13
13
  test('fail when creating a non-unique site', async () => {
14
14
  await executeDbTest({
15
- schema,
15
+ schema: { model },
16
16
  seed: [
17
17
  {
18
18
  query: GQL`mutation {
@@ -41,11 +41,11 @@ test('insert category and connect existing post (one has many)', async () => {
41
41
  },
42
42
  },
43
43
  {
44
- sql: SQL`with "newdata_" as (select ? :: uuid as "category_id", "root_"."id", "root_"."name" from "public"."post" as "root_" where "root_"."id" = ?)
45
- update "public"."post" set "category_id" = "newdata_"."category_id" from "newdata_" where "post"."id" = "newdata_"."id"`,
44
+ sql: SQL`with "newData_" as (select ? :: uuid as "category_id", "root_"."category_id" as "category_id_old__", "root_"."id", "root_"."name" from "public"."post" as "root_" where "root_"."id" = ?)
45
+ update "public"."post" set "category_id" = "newData_"."category_id" from "newData_" where "post"."id" = "newData_"."id" returning "category_id_old__"`,
46
46
  parameters: [testUuid(1), testUuid(5)],
47
47
  response: {
48
- rowCount: 1,
48
+ rows: [{ category_id_old__: testUuid(99) }],
49
49
  },
50
50
  },
51
51
  {
@@ -0,0 +1,77 @@
1
+ import { AclDefinition as acl, createSchema, SchemaDefinition as def } from '@contember/schema-definition'
2
+ import { test } from 'vitest'
3
+ import { execute } from '../../../../../src/test'
4
+ import { GQL, SQL } from '../../../../../src/tags'
5
+ import { PermissionFactory } from '../../../../../../src'
6
+ import { testUuid } from '@contember/engine-api-tester'
7
+
8
+
9
+ namespace RowPredicateSubset {
10
+ export const ownerRole = acl.createRole('owner')
11
+ export const personIdVariable = acl.createPredefinedVariable('personId', 'personID', ownerRole)
12
+
13
+ @acl.allow(ownerRole, {
14
+ read: true,
15
+ when: { resource: acl.canRead('item') },
16
+ })
17
+ export class Item {
18
+ resource = def.oneHasOne(Resource, 'item')
19
+ }
20
+
21
+ @acl.allow(ownerRole, {
22
+ read: true,
23
+ when: { owner: acl.canRead('resources') },
24
+ })
25
+ export class Resource {
26
+ item = def.oneHasOneInverse(Item, 'resource')
27
+ owner = def.manyHasOne(Person, 'resources')
28
+ }
29
+
30
+ @acl.allow(ownerRole, {
31
+ read: true,
32
+ when: { personId: personIdVariable },
33
+ })
34
+ export class Person {
35
+ personId = def.uuidColumn().notNull()
36
+ resources = def.oneHasMany(Resource, 'owner')
37
+ }
38
+ }
39
+
40
+
41
+ test('owner predicate with isNull', async () => {
42
+ const schema = createSchema(RowPredicateSubset)
43
+
44
+ const permissions = new PermissionFactory().create(schema, ['owner'])
45
+
46
+ await execute({
47
+ schema: schema.model,
48
+ permissions: permissions,
49
+ variables: {
50
+ owner__personId: { eq: testUuid(0) },
51
+ },
52
+ query: GQL`
53
+ query {
54
+ listItem(filter: {resource: {id: {isNull: true}}}) {
55
+ id
56
+ }
57
+ }`,
58
+ executes: [
59
+ {
60
+ sql: SQL`select "root_"."id" as "root_id" from "public"."item" as "root_"
61
+ left join "public"."resource" as "root_resource" on "root_"."resource_id" = "root_resource"."id"
62
+ left join "public"."person" as "root_resource_owner" on "root_resource"."owner_id" = "root_resource_owner"."id"
63
+ where "root_resource"."id" is null and "root_resource_owner"."person_id" = ? and "root_resource_owner"."person_id" = ?`,
64
+ response: {
65
+ rows: [],
66
+ },
67
+ },
68
+ ],
69
+ return: {
70
+ data: {
71
+ listItem: [],
72
+ },
73
+ },
74
+ })
75
+ })
76
+
77
+
@@ -37,7 +37,7 @@ namespace RowPredicateSubset {
37
37
  test('row level predicate includes main predicate', async () => {
38
38
  const schema = createSchema(RowPredicateSubset)
39
39
 
40
- const permissions = new PermissionFactory(schema.model).create(schema.acl, ['reader'])
40
+ const permissions = new PermissionFactory().create(schema, ['reader'])
41
41
 
42
42
  await execute({
43
43
  schema: schema.model,
@@ -0,0 +1,67 @@
1
+ import { test } from 'vitest'
2
+ import { execute } from '../../../../../src/test'
3
+ import { SchemaBuilder } from '@contember/schema-definition'
4
+ import { Model } from '@contember/schema'
5
+ import { GQL, SQL } from '../../../../../src/tags'
6
+ import { testUuid } from '../../../../../src/testUuid'
7
+
8
+ test('Entity - explicit order by, default asc', async () => {
9
+ await execute({
10
+ schema: new SchemaBuilder()
11
+ .entity('Post', entity => entity.column('title', column => column.type(Model.ColumnType.String)).orderBy('title'))
12
+ .buildSchema(),
13
+ query: GQL`
14
+ query {
15
+ getPost(by: {id: "${testUuid(1)}"}, filter: {title: {eq: "Foo"}}) {
16
+ id
17
+ }
18
+ }`,
19
+ executes: [
20
+ {
21
+ sql: SQL`select "root_"."id" as "root_id"
22
+ from "public"."post" as "root_"
23
+ where "root_"."id" = ? and "root_"."title" = ? order by "root_"."title" asc, "root_"."id" asc`,
24
+ response: { rows: [{ root_id: testUuid(1) }] },
25
+ parameters: [testUuid(1), 'Foo'],
26
+ },
27
+ ],
28
+ return: {
29
+ data: {
30
+ getPost: {
31
+ id: testUuid(1),
32
+ },
33
+ },
34
+ },
35
+ })
36
+ })
37
+
38
+
39
+ test('Entity - explicit order by desc', async () => {
40
+ await execute({
41
+ schema: new SchemaBuilder()
42
+ .entity('Post', entity => entity.column('title', column => column.type(Model.ColumnType.String)).orderBy('title', Model.OrderDirection.desc))
43
+ .buildSchema(),
44
+ query: GQL`
45
+ query {
46
+ getPost(by: {id: "${testUuid(1)}"}, filter: {title: {eq: "Foo"}}) {
47
+ id
48
+ }
49
+ }`,
50
+ executes: [
51
+ {
52
+ sql: SQL`select "root_"."id" as "root_id"
53
+ from "public"."post" as "root_"
54
+ where "root_"."id" = ? and "root_"."title" = ? order by "root_"."title" desc, "root_"."id" asc`,
55
+ response: { rows: [{ root_id: testUuid(1) }] },
56
+ parameters: [testUuid(1), 'Foo'],
57
+ },
58
+ ],
59
+ return: {
60
+ data: {
61
+ getPost: {
62
+ id: testUuid(1),
63
+ },
64
+ },
65
+ },
66
+ })
67
+ })
@@ -45,16 +45,10 @@ test('update name', async () => {
45
45
  response: { rows: [{ id: testUuid(1) }] },
46
46
  },
47
47
  {
48
- sql: SQL`with "newData_" as
49
- (select
50
- ? :: text as "name",
51
- "root_"."id"
52
- from "public"."author" as "root_"
53
- where "root_"."id" = ? and "root_"."name" in (?, ?)) update "public"."author"
54
- set "name" = "newData_"."name" from "newData_"
55
- where "author"."id" = "newData_"."id" and "newData_"."name" in (?, ?)`,
48
+ sql: SQL`with "newData_" as (select ? :: text as "name", "root_"."name" as "name_old__", "root_"."id" from "public"."author" as "root_" where "root_"."id" = ? and "root_"."name" in (?, ?))
49
+ update "public"."author" set "name" = "newData_"."name" from "newData_" where "author"."id" = "newData_"."id" and "newData_"."name" in (?, ?) returning "name_old__"`,
56
50
  parameters: ['John', testUuid(1), 'John', 'Jack', 'John', 'Jack'],
57
- response: { rowCount: 1 },
51
+ response: { rows: [{ name_old__: 'John' }] },
58
52
  },
59
53
  ]),
60
54
  ],
@@ -108,16 +102,10 @@ test('update name - denied', async () => {
108
102
  response: { rows: [{ id: testUuid(1) }] },
109
103
  },
110
104
  {
111
- sql: SQL`with "newData_" as
112
- (select
113
- ? :: text as "name",
114
- "root_"."id"
115
- from "public"."author" as "root_"
116
- where false) update "public"."author"
117
- set "name" = "newData_"."name" from "newData_"
118
- where "author"."id" = "newData_"."id" and false`,
105
+ sql: SQL`with "newData_" as (select ? :: text as "name", "root_"."name" as "name_old__", "root_"."id" from "public"."author" as "root_" where false)
106
+ update "public"."author" set "name" = "newData_"."name" from "newData_" where "author"."id" = "newData_"."id" and false returning "name_old__"`,
119
107
  parameters: ['John'],
120
- response: 0,
108
+ response: { rows: [] },
121
109
  },
122
110
  ]),
123
111
  ],
@@ -30,11 +30,10 @@ test('applies a filter', async () => {
30
30
  response: { rows: [{ id: testUuid(1) }] },
31
31
  },
32
32
  {
33
- sql: SQL`with "newdata_" as
34
- (select ? :: text as "name", "root_"."id" from "public"."author" as "root_" where "root_"."id" = ? and "root_"."name" = ?)
35
- update "public"."author" set "name" = "newdata_"."name" from "newdata_" where "author"."id" = "newdata_"."id"`,
33
+ sql: SQL`with "newData_" as (select ? :: text as "name", "root_"."name" as "name_old__", "root_"."id" from "public"."author" as "root_" where "root_"."id" = ? and "root_"."name" = ?)
34
+ update "public"."author" set "name" = "newData_"."name" from "newData_" where "author"."id" = "newData_"."id" returning "name_old__"`,
36
35
  parameters: ['John', testUuid(1), 'Jack'],
37
- response: { rowCount: 1 },
36
+ response: { rows: [{ name_old__: 'Jack' }] },
38
37
  },
39
38
  {
40
39
  sql: SQL`select "root_"."id" as "root_id"
@@ -29,15 +29,10 @@ test('update name', async () => {
29
29
  response: { rows: [{ id: testUuid(1) }] },
30
30
  },
31
31
  {
32
- sql: SQL`with "newData_" as (select
33
- ? :: text as "name",
34
- "root_"."id"
35
- from "public"."author" as "root_"
36
- where "root_"."id" = ?) update "public"."author"
37
- set "name" = "newData_"."name" from "newData_"
38
- where "author"."id" = "newData_"."id"`,
32
+ sql: SQL`with "newData_" as (select ? :: text as "name", "root_"."name" as "name_old__", "root_"."id" from "public"."author" as "root_" where "root_"."id" = ?)
33
+ update "public"."author" set "name" = "newData_"."name" from "newData_" where "author"."id" = "newData_"."id" returning "name_old__"`,
39
34
  parameters: ['John', testUuid(1)],
40
- response: { rowCount: 1 },
35
+ response: { rows: [{ name_old__: 'John' }] },
41
36
  },
42
37
  {
43
38
  sql: SQL`select "root_"."id" as "root_id"
@@ -28,16 +28,10 @@ test('update', async () => {
28
28
  response: { rows: [{ id: testUuid(1) }] },
29
29
  },
30
30
  {
31
- sql: SQL`with "newData_" as
32
- (select
33
- ? :: text as "title",
34
- "root_"."id"
35
- from "public"."post" as "root_"
36
- where "root_"."id" = ?) update "public"."post"
37
- set "title" = "newData_"."title" from "newData_"
38
- where "post"."id" = "newData_"."id"`,
31
+ sql: SQL`with "newData_" as (select ? :: text as "title", "root_"."title" as "title_old__", "root_"."id" from "public"."post" as "root_" where "root_"."id" = ?)
32
+ update "public"."post" set "title" = "newData_"."title" from "newData_" where "post"."id" = "newData_"."id" returning "title_old__"`,
39
33
  parameters: ['Lorem', testUuid(1)],
40
- response: { rowCount: 1 },
34
+ response: { rows: [{ title_old__: 'Foo bar' }] },
41
35
  },
42
36
  {
43
37
  sql: SQL`insert into "public"."post_categories" ("post_id", "category_id")
@@ -28,16 +28,10 @@ test('upsert - exists', async () => {
28
28
  response: { rows: [{ id: testUuid(1) }] },
29
29
  },
30
30
  {
31
- sql: SQL`with "newData_" as
32
- (select
33
- ? :: text as "title",
34
- "root_"."id"
35
- from "public"."post" as "root_"
36
- where "root_"."id" = ?) update "public"."post"
37
- set "title" = "newData_"."title" from "newData_"
38
- where "post"."id" = "newData_"."id"`,
31
+ sql: SQL`with "newData_" as (select ? :: text as "title", "root_"."title" as "title_old__", "root_"."id" from "public"."post" as "root_" where "root_"."id" = ?)
32
+ update "public"."post" set "title" = "newData_"."title" from "newData_" where "post"."id" = "newData_"."id" returning "title_old__"`,
39
33
  parameters: ['Lorem', testUuid(1)],
40
- response: { rowCount: 1 },
34
+ response: { rows: [{ title_old__: 'Foo' }] },
41
35
  },
42
36
  {
43
37
  sql: SQL`insert into "public"."post_categories" ("post_id", "category_id")
@@ -28,16 +28,10 @@ test('update', async () => {
28
28
  response: { rows: [{ id: testUuid(1) }] },
29
29
  },
30
30
  {
31
- sql: SQL`with "newData_" as
32
- (select
33
- ? :: text as "name",
34
- "root_"."id"
35
- from "public"."category" as "root_"
36
- where "root_"."id" = ?) update "public"."category"
37
- set "name" = "newData_"."name" from "newData_"
38
- where "category"."id" = "newData_"."id"`,
31
+ sql: SQL`with "newData_" as (select ? :: text as "name", "root_"."name" as "name_old__", "root_"."id" from "public"."category" as "root_" where "root_"."id" = ?)
32
+ update "public"."category" set "name" = "newData_"."name" from "newData_" where "category"."id" = "newData_"."id" returning "name_old__"`,
39
33
  parameters: ['Lorem', testUuid(1)],
40
- response: { rowCount: 1 },
34
+ response: { rows: [{ name_old__: 'Foo' }] },
41
35
  },
42
36
  {
43
37
  sql: SQL`insert into "public"."post_categories" ("post_id", "category_id")
@@ -28,16 +28,10 @@ test('upsert - exists', async () => {
28
28
  response: { rows: [{ id: testUuid(1) }] },
29
29
  },
30
30
  {
31
- sql: SQL`with "newData_" as
32
- (select
33
- ? :: text as "name",
34
- "root_"."id"
35
- from "public"."category" as "root_"
36
- where "root_"."id" = ?) update "public"."category"
37
- set "name" = "newData_"."name" from "newData_"
38
- where "category"."id" = "newData_"."id"`,
31
+ sql: SQL`with "newData_" as (select ? :: text as "name", "root_"."name" as "name_old__", "root_"."id" from "public"."category" as "root_" where "root_"."id" = ?)
32
+ update "public"."category" set "name" = "newData_"."name" from "newData_" where "category"."id" = "newData_"."id" returning "name_old__"`,
39
33
  parameters: ['Lorem', testUuid(1)],
40
- response: { rowCount: 1 },
34
+ response: { rows: [{ name_old__: 'Foo' }] },
41
35
  },
42
36
  {
43
37
  sql: SQL`insert into "public"."post_categories" ("post_id", "category_id")
@@ -28,17 +28,10 @@ test('connect', async () => {
28
28
  response: { rows: [{ id: testUuid(1) }] },
29
29
  },
30
30
  {
31
- sql: SQL`with "newData_" as
32
- (select
33
- ? :: uuid as "author_id",
34
- "root_"."id",
35
- "root_"."title"
36
- from "public"."post" as "root_"
37
- where "root_"."id" = ?) update "public"."post"
38
- set "author_id" = "newData_"."author_id" from "newData_"
39
- where "post"."id" = "newData_"."id"`,
31
+ sql: SQL`with "newData_" as (select ? :: uuid as "author_id", "root_"."author_id" as "author_id_old__", "root_"."id", "root_"."title" from "public"."post" as "root_" where "root_"."id" = ?)
32
+ update "public"."post" set "author_id" = "newData_"."author_id" from "newData_" where "post"."id" = "newData_"."id" returning "author_id_old__"`,
40
33
  parameters: [testUuid(1), testUuid(2)],
41
- response: { rowCount: 1 },
34
+ response: { rows: [{ author_id_old__: testUuid(99) }] },
42
35
  },
43
36
  ]),
44
37
  ],