@contember/engine-content-api 2.0.0-alpha.36 → 2.0.0-alpha.37

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 (306) hide show
  1. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +31 -6
  2. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
  3. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +31 -6
  4. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
  5. package/dist/development/src/input-validation/ColumnValueResolver.cjs.map +1 -1
  6. package/dist/development/src/input-validation/ColumnValueResolver.js.map +1 -1
  7. package/dist/development/src/input-validation/preValidation/CreateInputPreValidationProcessor.cjs.map +1 -1
  8. package/dist/development/src/input-validation/preValidation/CreateInputPreValidationProcessor.js.map +1 -1
  9. package/dist/development/src/input-validation/preValidation/InputPreValidator.cjs.map +1 -1
  10. package/dist/development/src/input-validation/preValidation/InputPreValidator.js.map +1 -1
  11. package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs.map +1 -1
  12. package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map +1 -1
  13. package/dist/development/src/inputProcessing/CreateInputVisitor.cjs +6 -7
  14. package/dist/development/src/inputProcessing/CreateInputVisitor.cjs.map +1 -1
  15. package/dist/development/src/inputProcessing/CreateInputVisitor.js +6 -7
  16. package/dist/development/src/inputProcessing/CreateInputVisitor.js.map +1 -1
  17. package/dist/development/src/inputProcessing/UpdateInputVisitor.cjs +14 -15
  18. package/dist/development/src/inputProcessing/UpdateInputVisitor.cjs.map +1 -1
  19. package/dist/development/src/inputProcessing/UpdateInputVisitor.js +14 -15
  20. package/dist/development/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
  21. package/dist/development/src/mapper/ColumnValue.cjs +8 -18
  22. package/dist/development/src/mapper/ColumnValue.cjs.map +1 -1
  23. package/dist/development/src/mapper/ColumnValue.js +8 -18
  24. package/dist/development/src/mapper/ColumnValue.js.map +1 -1
  25. package/dist/development/src/mapper/EventManager.cjs +1 -1
  26. package/dist/development/src/mapper/EventManager.cjs.map +1 -1
  27. package/dist/development/src/mapper/EventManager.js +1 -1
  28. package/dist/development/src/mapper/EventManager.js.map +1 -1
  29. package/dist/development/src/mapper/Mapper.cjs +8 -28
  30. package/dist/development/src/mapper/Mapper.cjs.map +1 -1
  31. package/dist/development/src/mapper/Mapper.js +8 -28
  32. package/dist/development/src/mapper/Mapper.js.map +1 -1
  33. package/dist/development/src/mapper/Result.cjs.map +1 -1
  34. package/dist/development/src/mapper/Result.js.map +1 -1
  35. package/dist/development/src/mapper/delete/DeleteExecutor.cjs +4 -8
  36. package/dist/development/src/mapper/delete/DeleteExecutor.cjs.map +1 -1
  37. package/dist/development/src/mapper/delete/DeleteExecutor.js +5 -9
  38. package/dist/development/src/mapper/delete/DeleteExecutor.js.map +1 -1
  39. package/dist/development/src/mapper/insert/InsertBuilder.cjs +12 -8
  40. package/dist/development/src/mapper/insert/InsertBuilder.cjs.map +1 -1
  41. package/dist/development/src/mapper/insert/InsertBuilder.js +13 -9
  42. package/dist/development/src/mapper/insert/InsertBuilder.js.map +1 -1
  43. package/dist/development/src/mapper/insert/Inserter.cjs.map +1 -1
  44. package/dist/development/src/mapper/insert/Inserter.js.map +1 -1
  45. package/dist/development/src/mapper/insert/SqlCreateInputProcessor.cjs +1 -3
  46. package/dist/development/src/mapper/insert/SqlCreateInputProcessor.cjs.map +1 -1
  47. package/dist/development/src/mapper/insert/SqlCreateInputProcessor.js +1 -3
  48. package/dist/development/src/mapper/insert/SqlCreateInputProcessor.js.map +1 -1
  49. package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs +3 -5
  50. package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs.map +1 -1
  51. package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js +4 -6
  52. package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js.map +1 -1
  53. package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs +3 -5
  54. package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs.map +1 -1
  55. package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js +4 -6
  56. package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js.map +1 -1
  57. package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs +4 -3
  58. package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs.map +1 -1
  59. package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js +4 -3
  60. package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js.map +1 -1
  61. package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs +3 -5
  62. package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs.map +1 -1
  63. package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js +4 -6
  64. package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js.map +1 -1
  65. package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs +4 -6
  66. package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs.map +1 -1
  67. package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js +5 -7
  68. package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js.map +1 -1
  69. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
  70. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
  71. package/dist/development/src/mapper/update/UpdateBuilder.cjs +12 -5
  72. package/dist/development/src/mapper/update/UpdateBuilder.cjs.map +1 -1
  73. package/dist/development/src/mapper/update/UpdateBuilder.js +13 -6
  74. package/dist/development/src/mapper/update/UpdateBuilder.js.map +1 -1
  75. package/dist/development/src/mapper/update/Updater.cjs.map +1 -1
  76. package/dist/development/src/mapper/update/Updater.js.map +1 -1
  77. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs +11 -16
  78. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -1
  79. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js +12 -17
  80. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -1
  81. package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs +6 -7
  82. package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs.map +1 -1
  83. package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js +7 -8
  84. package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js.map +1 -1
  85. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs +5 -4
  86. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -1
  87. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js +5 -4
  88. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -1
  89. package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs +11 -12
  90. package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs.map +1 -1
  91. package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js +12 -13
  92. package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js.map +1 -1
  93. package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs +8 -12
  94. package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs.map +1 -1
  95. package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js +9 -13
  96. package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js.map +1 -1
  97. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +31 -6
  98. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
  99. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +31 -6
  100. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
  101. package/dist/production/src/input-validation/ColumnValueResolver.cjs.map +1 -1
  102. package/dist/production/src/input-validation/ColumnValueResolver.js.map +1 -1
  103. package/dist/production/src/input-validation/preValidation/CreateInputPreValidationProcessor.cjs.map +1 -1
  104. package/dist/production/src/input-validation/preValidation/CreateInputPreValidationProcessor.js.map +1 -1
  105. package/dist/production/src/input-validation/preValidation/InputPreValidator.cjs.map +1 -1
  106. package/dist/production/src/input-validation/preValidation/InputPreValidator.js.map +1 -1
  107. package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs.map +1 -1
  108. package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map +1 -1
  109. package/dist/production/src/inputProcessing/CreateInputVisitor.cjs +6 -7
  110. package/dist/production/src/inputProcessing/CreateInputVisitor.cjs.map +1 -1
  111. package/dist/production/src/inputProcessing/CreateInputVisitor.js +6 -7
  112. package/dist/production/src/inputProcessing/CreateInputVisitor.js.map +1 -1
  113. package/dist/production/src/inputProcessing/UpdateInputVisitor.cjs +14 -15
  114. package/dist/production/src/inputProcessing/UpdateInputVisitor.cjs.map +1 -1
  115. package/dist/production/src/inputProcessing/UpdateInputVisitor.js +14 -15
  116. package/dist/production/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
  117. package/dist/production/src/mapper/ColumnValue.cjs +8 -18
  118. package/dist/production/src/mapper/ColumnValue.cjs.map +1 -1
  119. package/dist/production/src/mapper/ColumnValue.js +8 -18
  120. package/dist/production/src/mapper/ColumnValue.js.map +1 -1
  121. package/dist/production/src/mapper/EventManager.cjs +1 -1
  122. package/dist/production/src/mapper/EventManager.cjs.map +1 -1
  123. package/dist/production/src/mapper/EventManager.js +1 -1
  124. package/dist/production/src/mapper/EventManager.js.map +1 -1
  125. package/dist/production/src/mapper/Mapper.cjs +8 -28
  126. package/dist/production/src/mapper/Mapper.cjs.map +1 -1
  127. package/dist/production/src/mapper/Mapper.js +8 -28
  128. package/dist/production/src/mapper/Mapper.js.map +1 -1
  129. package/dist/production/src/mapper/Result.cjs.map +1 -1
  130. package/dist/production/src/mapper/Result.js.map +1 -1
  131. package/dist/production/src/mapper/delete/DeleteExecutor.cjs +4 -8
  132. package/dist/production/src/mapper/delete/DeleteExecutor.cjs.map +1 -1
  133. package/dist/production/src/mapper/delete/DeleteExecutor.js +5 -9
  134. package/dist/production/src/mapper/delete/DeleteExecutor.js.map +1 -1
  135. package/dist/production/src/mapper/insert/InsertBuilder.cjs +12 -8
  136. package/dist/production/src/mapper/insert/InsertBuilder.cjs.map +1 -1
  137. package/dist/production/src/mapper/insert/InsertBuilder.js +13 -9
  138. package/dist/production/src/mapper/insert/InsertBuilder.js.map +1 -1
  139. package/dist/production/src/mapper/insert/Inserter.cjs.map +1 -1
  140. package/dist/production/src/mapper/insert/Inserter.js.map +1 -1
  141. package/dist/production/src/mapper/insert/SqlCreateInputProcessor.cjs +1 -3
  142. package/dist/production/src/mapper/insert/SqlCreateInputProcessor.cjs.map +1 -1
  143. package/dist/production/src/mapper/insert/SqlCreateInputProcessor.js +1 -3
  144. package/dist/production/src/mapper/insert/SqlCreateInputProcessor.js.map +1 -1
  145. package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs +3 -5
  146. package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs.map +1 -1
  147. package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js +4 -6
  148. package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js.map +1 -1
  149. package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs +3 -5
  150. package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs.map +1 -1
  151. package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js +4 -6
  152. package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js.map +1 -1
  153. package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs +4 -3
  154. package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs.map +1 -1
  155. package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js +4 -3
  156. package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js.map +1 -1
  157. package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs +3 -5
  158. package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs.map +1 -1
  159. package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js +4 -6
  160. package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js.map +1 -1
  161. package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs +4 -6
  162. package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs.map +1 -1
  163. package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js +5 -7
  164. package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js.map +1 -1
  165. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
  166. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
  167. package/dist/production/src/mapper/update/UpdateBuilder.cjs +12 -5
  168. package/dist/production/src/mapper/update/UpdateBuilder.cjs.map +1 -1
  169. package/dist/production/src/mapper/update/UpdateBuilder.js +13 -6
  170. package/dist/production/src/mapper/update/UpdateBuilder.js.map +1 -1
  171. package/dist/production/src/mapper/update/Updater.cjs.map +1 -1
  172. package/dist/production/src/mapper/update/Updater.js.map +1 -1
  173. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs +11 -16
  174. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -1
  175. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js +12 -17
  176. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -1
  177. package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs +6 -7
  178. package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs.map +1 -1
  179. package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js +7 -8
  180. package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js.map +1 -1
  181. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs +5 -4
  182. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -1
  183. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js +5 -4
  184. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -1
  185. package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs +11 -12
  186. package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs.map +1 -1
  187. package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js +12 -13
  188. package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js.map +1 -1
  189. package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs +8 -12
  190. package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs.map +1 -1
  191. package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js +9 -13
  192. package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js.map +1 -1
  193. package/dist/tests/cases/integration/graphQlRequests/insert/jsonInsert.test.d.ts +2 -0
  194. package/dist/tests/cases/integration/graphQlRequests/insert/jsonInsert.test.d.ts.map +1 -0
  195. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  196. package/dist/types/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.d.ts.map +1 -1
  197. package/dist/types/input-validation/ColumnValueResolver.d.ts +1 -1
  198. package/dist/types/input-validation/ColumnValueResolver.d.ts.map +1 -1
  199. package/dist/types/input-validation/ValidationDataSelector.d.ts +1 -1
  200. package/dist/types/input-validation/preValidation/CreateInputPreValidationProcessor.d.ts +3 -3
  201. package/dist/types/input-validation/preValidation/CreateInputPreValidationProcessor.d.ts.map +1 -1
  202. package/dist/types/input-validation/preValidation/InputPreValidator.d.ts +3 -3
  203. package/dist/types/input-validation/preValidation/InputPreValidator.d.ts.map +1 -1
  204. package/dist/types/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts +4 -4
  205. package/dist/types/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts.map +1 -1
  206. package/dist/types/inputProcessing/CreateInputProcessor.d.ts +8 -6
  207. package/dist/types/inputProcessing/CreateInputProcessor.d.ts.map +1 -1
  208. package/dist/types/inputProcessing/CreateInputVisitor.d.ts +3 -2
  209. package/dist/types/inputProcessing/CreateInputVisitor.d.ts.map +1 -1
  210. package/dist/types/inputProcessing/UpdateInputProcessor.d.ts +14 -12
  211. package/dist/types/inputProcessing/UpdateInputProcessor.d.ts.map +1 -1
  212. package/dist/types/inputProcessing/UpdateInputVisitor.d.ts +3 -2
  213. package/dist/types/inputProcessing/UpdateInputVisitor.d.ts.map +1 -1
  214. package/dist/types/mapper/ColumnValue.d.ts +4 -8
  215. package/dist/types/mapper/ColumnValue.d.ts.map +1 -1
  216. package/dist/types/mapper/EventManager.d.ts +9 -9
  217. package/dist/types/mapper/EventManager.d.ts.map +1 -1
  218. package/dist/types/mapper/Mapper.d.ts +6 -7
  219. package/dist/types/mapper/Mapper.d.ts.map +1 -1
  220. package/dist/types/mapper/Result.d.ts +5 -4
  221. package/dist/types/mapper/Result.d.ts.map +1 -1
  222. package/dist/types/mapper/delete/DeleteExecutor.d.ts.map +1 -1
  223. package/dist/types/mapper/insert/InsertBuilder.d.ts +3 -4
  224. package/dist/types/mapper/insert/InsertBuilder.d.ts.map +1 -1
  225. package/dist/types/mapper/insert/Inserter.d.ts +3 -2
  226. package/dist/types/mapper/insert/Inserter.d.ts.map +1 -1
  227. package/dist/types/mapper/insert/SqlCreateInputProcessor.d.ts.map +1 -1
  228. package/dist/types/mapper/insert/relations/ManyHasManyCreateInputProcessor.d.ts +5 -3
  229. package/dist/types/mapper/insert/relations/ManyHasManyCreateInputProcessor.d.ts.map +1 -1
  230. package/dist/types/mapper/insert/relations/ManyHasOneCreateInputProcessor.d.ts +5 -3
  231. package/dist/types/mapper/insert/relations/ManyHasOneCreateInputProcessor.d.ts.map +1 -1
  232. package/dist/types/mapper/insert/relations/OneHasManyCreateInputProcessor.d.ts +5 -3
  233. package/dist/types/mapper/insert/relations/OneHasManyCreateInputProcessor.d.ts.map +1 -1
  234. package/dist/types/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.d.ts +5 -3
  235. package/dist/types/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.d.ts.map +1 -1
  236. package/dist/types/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.d.ts +5 -3
  237. package/dist/types/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.d.ts.map +1 -1
  238. package/dist/types/mapper/types.d.ts +84 -1
  239. package/dist/types/mapper/types.d.ts.map +1 -1
  240. package/dist/types/mapper/update/SqlUpdateInputProcessor.d.ts +2 -1
  241. package/dist/types/mapper/update/SqlUpdateInputProcessor.d.ts.map +1 -1
  242. package/dist/types/mapper/update/UpdateBuilder.d.ts +3 -3
  243. package/dist/types/mapper/update/UpdateBuilder.d.ts.map +1 -1
  244. package/dist/types/mapper/update/Updater.d.ts +2 -1
  245. package/dist/types/mapper/update/Updater.d.ts.map +1 -1
  246. package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts +5 -3
  247. package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts.map +1 -1
  248. package/dist/types/mapper/update/relations/ManyHasOneUpdateInputProcessor.d.ts +6 -4
  249. package/dist/types/mapper/update/relations/ManyHasOneUpdateInputProcessor.d.ts.map +1 -1
  250. package/dist/types/mapper/update/relations/OneHasManyUpdateInputProcessor.d.ts +5 -3
  251. package/dist/types/mapper/update/relations/OneHasManyUpdateInputProcessor.d.ts.map +1 -1
  252. package/dist/types/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.d.ts +6 -4
  253. package/dist/types/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.d.ts.map +1 -1
  254. package/dist/types/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.d.ts +6 -4
  255. package/dist/types/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.d.ts.map +1 -1
  256. package/dist/types/tsconfig.tsbuildinfo +1 -1
  257. package/package.json +10 -10
  258. package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts +35 -2
  259. package/src/input-validation/ColumnValueResolver.ts +1 -1
  260. package/src/input-validation/preValidation/CreateInputPreValidationProcessor.ts +2 -2
  261. package/src/input-validation/preValidation/InputPreValidator.ts +7 -7
  262. package/src/input-validation/preValidation/UpdateInputPreValidationProcessor.ts +3 -3
  263. package/src/inputProcessing/CreateInputProcessor.ts +8 -6
  264. package/src/inputProcessing/CreateInputVisitor.ts +18 -19
  265. package/src/inputProcessing/UpdateInputProcessor.ts +13 -11
  266. package/src/inputProcessing/UpdateInputVisitor.ts +25 -24
  267. package/src/mapper/ColumnValue.ts +11 -25
  268. package/src/mapper/EventManager.ts +6 -6
  269. package/src/mapper/Mapper.ts +19 -37
  270. package/src/mapper/Result.ts +3 -2
  271. package/src/mapper/delete/DeleteExecutor.ts +4 -8
  272. package/src/mapper/insert/InsertBuilder.ts +20 -17
  273. package/src/mapper/insert/Inserter.ts +4 -3
  274. package/src/mapper/insert/SqlCreateInputProcessor.ts +1 -3
  275. package/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.ts +8 -8
  276. package/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.ts +8 -8
  277. package/src/mapper/insert/relations/OneHasManyCreateInputProcessor.ts +8 -6
  278. package/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.ts +8 -9
  279. package/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.ts +9 -9
  280. package/src/mapper/types.ts +115 -1
  281. package/src/mapper/update/SqlUpdateInputProcessor.ts +2 -1
  282. package/src/mapper/update/UpdateBuilder.ts +20 -12
  283. package/src/mapper/update/Updater.ts +3 -2
  284. package/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.ts +15 -19
  285. package/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.ts +11 -11
  286. package/src/mapper/update/relations/OneHasManyUpdateInputProcessor.ts +9 -7
  287. package/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.ts +18 -18
  288. package/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.ts +14 -17
  289. package/tests/cases/integration/graphQlRequests/insert/jsonInsert.test.ts +37 -0
  290. package/tests/cases/integration/graphQlRequests/query/misc/reducedHasMany.test.ts +69 -0
  291. package/tests/cases/integration/graphQlRequests/update/manyHasOne/update.test.ts +0 -5
  292. package/tests/cases/integration/graphQlRequests/update/manyHasOne/upsert.test.ts +0 -5
  293. package/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/upsert.test.ts +9 -0
  294. package/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/update.test.ts +0 -5
  295. package/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/upsert.test.ts +0 -5
  296. package/tests/cases/integration/graphQlSchema/schema-acl-allowed.gql +5 -0
  297. package/tests/cases/integration/graphQlSchema/schema-acl-restricted-create.gql +5 -0
  298. package/tests/cases/integration/graphQlSchema/schema-acl-restricted-delete.gql +5 -0
  299. package/tests/cases/integration/graphQlSchema/schema-acl-restricted-update.gql +5 -0
  300. package/tests/cases/integration/graphQlSchema/schema-basic.gql +11 -0
  301. package/tests/cases/integration/graphQlSchema/schema-bug-66.gql +6 -0
  302. package/tests/cases/integration/graphQlSchema/schema-custom-primary.gql +11 -0
  303. package/tests/cases/integration/graphQlSchema/schema-has-many-reduction.gql +6 -0
  304. package/tests/cases/integration/graphQlSchema/schema-new-builder.gql +12 -0
  305. package/tests/cases/unit/inputPreValidator.test.ts +1 -1
  306. package/tests/src/testGraphql.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  import { Model } from "@contember/schema";
2
- import { MutationEntryNotFoundError, MutationResultType, getInsertPrimary, MutationNothingToDo, NothingToDoReason, MutationConstraintViolationError, ConstraintType } from "../../Result.js";
2
+ import { MutationResultType, getInsertPrimary, MutationNothingToDo, NothingToDoReason, MutationConstraintViolationError, ConstraintType } from "../../Result.js";
3
3
  import { CheckedPrimary } from "../../CheckedPrimary.js";
4
4
  class OneHasOneOwningUpdateInputProcessor {
5
5
  constructor(primaryValue, mapper, updateBuilder) {
@@ -9,10 +9,8 @@ class OneHasOneOwningUpdateInputProcessor {
9
9
  }
10
10
  async connect(context) {
11
11
  const { entity, relation, targetEntity, targetRelation, input } = context;
12
- const newInverseSide = await this.mapper.getPrimaryValue(targetEntity, input);
13
- if (!newInverseSide) {
14
- return [new MutationEntryNotFoundError([], input)];
15
- }
12
+ const [newInverseSide, err] = await this.mapper.getPrimaryValue(targetEntity, input);
13
+ if (err) return [err];
16
14
  const currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity);
17
15
  const currentOwnerResult = await this.handleStateBeforeConnect(context, currentInverseSide, newInverseSide);
18
16
  if (currentOwnerResult.some((it) => it.error) || currentOwnerResult.length === 1 && currentOwnerResult[0].result === MutationResultType.nothingToDo) {
@@ -45,7 +43,7 @@ class OneHasOneOwningUpdateInputProcessor {
45
43
  async connectOrCreate({ input: { connect, create }, ...context }) {
46
44
  const { relation, targetRelation, targetEntity, entity } = context;
47
45
  const currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity);
48
- const newInverseSide = await this.mapper.getPrimaryValue(targetEntity, connect);
46
+ const [newInverseSide] = await this.mapper.getPrimaryValue(targetEntity, connect);
49
47
  if (newInverseSide) {
50
48
  const currentOwnerResult = await this.handleStateBeforeConnect(context, currentInverseSide, newInverseSide);
51
49
  if (currentOwnerResult.some((it) => it.error) || currentOwnerResult.length === 1 && currentOwnerResult[0].result === MutationResultType.nothingToDo) {
@@ -82,7 +80,7 @@ class OneHasOneOwningUpdateInputProcessor {
82
80
  if (!inversePrimary) {
83
81
  return [new MutationNothingToDo([], NothingToDoReason.emptyRelation)];
84
82
  }
85
- return await this.mapper.update(targetEntity, { [targetEntity.primary]: inversePrimary }, input);
83
+ return await this.mapper.update(targetEntity, new CheckedPrimary(inversePrimary), input);
86
84
  };
87
85
  }
88
86
  async upsert({ entity, relation, targetEntity, input: { create, update } }) {
@@ -97,7 +95,7 @@ class OneHasOneOwningUpdateInputProcessor {
97
95
  return [];
98
96
  }
99
97
  return async () => {
100
- return await this.mapper.update(targetEntity, { [targetEntity.primary]: primary }, update);
98
+ return await this.mapper.update(targetEntity, new CheckedPrimary(primary), update);
101
99
  };
102
100
  }
103
101
  async disconnect({ entity, targetEntity, relation, targetRelation }) {
@@ -111,7 +109,7 @@ class OneHasOneOwningUpdateInputProcessor {
111
109
  this.updateBuilder.addFieldValue(relation.name, null);
112
110
  if (relation.orphanRemoval && inversePrimary) {
113
111
  return async () => {
114
- return await this.mapper.delete(targetEntity, { [targetEntity.primary]: inversePrimary });
112
+ return await this.mapper.delete(targetEntity, new CheckedPrimary(inversePrimary));
115
113
  };
116
114
  }
117
115
  return [];
@@ -154,7 +152,7 @@ class OneHasOneOwningUpdateInputProcessor {
154
152
  if (currentInverseSide === newInverseSide) {
155
153
  return [new MutationNothingToDo([], NothingToDoReason.alreadyExists)];
156
154
  }
157
- const currentOwnerOfNewInverseSide = await this.mapper.getPrimaryValue(entity, {
155
+ const [currentOwnerOfNewInverseSide] = await this.mapper.getPrimaryValue(entity, {
158
156
  [relation.name]: { [targetEntity.primary]: newInverseSide }
159
157
  });
160
158
  if (currentOwnerOfNewInverseSide === this.primaryValue) {
@@ -169,9 +167,7 @@ class OneHasOneOwningUpdateInputProcessor {
169
167
  }
170
168
  return await this.mapper.updateInternal(
171
169
  entity,
172
- {
173
- [entity.primary]: currentOwnerOfNewInverseSide
174
- },
170
+ new CheckedPrimary(currentOwnerOfNewInverseSide),
175
171
  (builder) => {
176
172
  builder.addPredicates([relation.name]);
177
173
  builder.addFieldValue(relation.name, null);
@@ -1 +1 @@
1
- {"version":3,"file":"OneHasOneOwningUpdateInputProcessor.js","sources":["../../../../../../../packages/engine-content-api/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.ts"],"sourcesContent":["import { UpdateInputProcessor } from '../../../inputProcessing'\nimport { Input, Model } from '@contember/schema'\nimport {\n\tConstraintType,\n\tgetInsertPrimary,\n\tMutationConstraintViolationError,\n\tMutationEntryNotFoundError,\n\tMutationNothingToDo,\n\tMutationResultList,\n\tMutationResultType,\n\tNothingToDoReason,\n} from '../../Result'\nimport { Mapper } from '../../Mapper'\nimport { UpdateBuilder } from '../../update/UpdateBuilder'\nimport { CheckedPrimary } from '../../CheckedPrimary'\nimport { SqlUpdateInputProcessorResult } from '../SqlUpdateInputProcessor'\n\ntype Context = Model.OneHasOneOwningContext\n\nexport class OneHasOneOwningUpdateInputProcessor implements UpdateInputProcessor.HasOneRelationInputProcessor<Context, SqlUpdateInputProcessorResult>{\n\tconstructor(\n\t\tprivate readonly primaryValue: Input.PrimaryValue,\n\t\tprivate readonly mapper: Mapper,\n\t\tprivate readonly updateBuilder: UpdateBuilder,\n\t) {\n\t}\n\n\tpublic async connect(context: Model.OneHasOneOwningContext & { input: Input.UniqueWhere }) {\n\t\tconst { entity, relation, targetEntity, targetRelation, input } = context\n\t\tconst newInverseSide = await this.mapper.getPrimaryValue(targetEntity, input)\n\t\tif (!newInverseSide) {\n\t\t\treturn [new MutationEntryNotFoundError([], input)]\n\t\t}\n\t\tconst currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity)\n\t\tconst currentOwnerResult = await this.handleStateBeforeConnect(context, currentInverseSide, newInverseSide)\n\t\tif (currentOwnerResult.some(it => it.error)\n\t\t\t|| (currentOwnerResult.length === 1 && currentOwnerResult[0].result === MutationResultType.nothingToDo)\n\t\t) {\n\t\t\treturn currentOwnerResult\n\t\t}\n\n\t\tthis.updateBuilder.addFieldValue(relation.name, newInverseSide)\n\n\t\treturn async () => {\n\t\t\treturn [\n\t\t\t\t...currentOwnerResult,\n\t\t\t\t...(await this.cleanupOrphan(relation, targetEntity, currentInverseSide)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async create(context: Model.OneHasOneOwningContext & { input: Input.CreateDataInput }) {\n\t\tconst { entity, relation, targetEntity, targetRelation } = context\n\t\tconst currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity)\n\t\tconst createResult = await this.createInternal(context, currentInverseSide)\n\t\tconst newInverseSide = getInsertPrimary(createResult)\n\t\tif (!newInverseSide) {\n\t\t\treturn createResult\n\t\t}\n\t\tthis.updateBuilder.addFieldValue(relation.name, newInverseSide)\n\n\t\treturn async () => {\n\t\t\treturn [\n\t\t\t\t...createResult,\n\t\t\t\t...(await this.cleanupOrphan(relation, targetEntity, currentInverseSide)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async connectOrCreate({ input: { connect, create }, ...context }: Model.OneHasOneOwningContext & { input: Input.ConnectOrCreateInput }) {\n\t\tconst { relation, targetRelation, targetEntity, entity } = context\n\t\tconst currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity)\n\t\tconst newInverseSide = await this.mapper.getPrimaryValue(targetEntity, connect)\n\n\t\tif (newInverseSide) {\n\t\t\tconst currentOwnerResult = await this.handleStateBeforeConnect(context, currentInverseSide, newInverseSide)\n\t\t\tif (currentOwnerResult.some(it => it.error)\n\t\t\t\t|| (currentOwnerResult.length === 1 && currentOwnerResult[0].result === MutationResultType.nothingToDo)\n\t\t\t) {\n\t\t\t\treturn currentOwnerResult\n\t\t\t}\n\t\t\tthis.updateBuilder.addFieldValue(relation.name, newInverseSide)\n\t\t\treturn async () => {\n\t\t\t\treturn [\n\t\t\t\t\t...currentOwnerResult,\n\t\t\t\t\t...(await this.cleanupOrphan(relation, targetEntity, currentInverseSide)),\n\t\t\t\t]\n\t\t\t}\n\n\t\t}\n\n\t\tconst createResult = await this.createInternal({ ...context, input: create }, currentInverseSide)\n\t\tconst newInverseSideCreate = getInsertPrimary(createResult)\n\t\tif (!newInverseSideCreate) {\n\t\t\treturn createResult\n\t\t}\n\t\tthis.updateBuilder.addFieldValue(relation.name, newInverseSideCreate)\n\t\treturn async () => {\n\t\t\treturn [\n\t\t\t\t...createResult,\n\t\t\t\t...(await this.cleanupOrphan(relation, targetEntity, currentInverseSide)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async update({ entity, relation, targetEntity, input }: Model.OneHasOneOwningContext & { input: Input.UpdateDataInput }) {\n\t\treturn async () => {\n\t\t\tconst inversePrimary = await this.mapper.selectField(\n\t\t\t\tentity,\n\t\t\t\t{ [entity.primary]: this.primaryValue },\n\t\t\t\trelation.name,\n\t\t\t)\n\t\t\tif (!inversePrimary) {\n\t\t\t\treturn [new MutationNothingToDo([], NothingToDoReason.emptyRelation)]\n\t\t\t}\n\t\t\treturn await this.mapper.update(targetEntity, { [targetEntity.primary]: inversePrimary }, input)\n\t\t}\n\t}\n\n\tpublic async upsert({ entity, relation, targetEntity, input: { create, update } }: Model.OneHasOneOwningContext & { input: UpdateInputProcessor.UpsertInput }) {\n\t\tconst primary = await this.mapper.selectField(entity, { [entity.primary]: this.primaryValue }, relation.name)\n\t\tif (!primary) {\n\t\t\tconst insertResult = await this.mapper.insert(targetEntity, create)\n\t\t\tconst insertPrimary = getInsertPrimary(insertResult)\n\t\t\tif (!insertPrimary) {\n\t\t\t\treturn insertResult\n\t\t\t}\n\t\t\tthis.updateBuilder.addFieldValue(relation.name, insertPrimary)\n\t\t\treturn []\n\t\t}\n\n\t\treturn async () => {\n\t\t\treturn await this.mapper.update(targetEntity, { [targetEntity.primary]: primary }, update)\n\t\t}\n\t}\n\n\tpublic async disconnect({ entity, targetEntity, relation, targetRelation }: Model.OneHasOneOwningContext & { input: undefined }) {\n\t\tif (!relation.nullable) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\tconst inversePrimary = (targetRelation && !targetRelation.nullable) || relation.orphanRemoval\n\t\t\t? await this.mapper.selectField(entity, { [entity.primary]: this.primaryValue }, relation.name)\n\t\t\t: undefined\n\t\tif (inversePrimary && targetRelation && !targetRelation.nullable && !relation.orphanRemoval) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\t\tthis.updateBuilder.addFieldValue(relation.name, null)\n\n\t\tif (relation.orphanRemoval && inversePrimary) {\n\t\t\treturn async () => {\n\t\t\t\treturn await this.mapper.delete(targetEntity, { [targetEntity.primary]: inversePrimary })\n\t\t\t}\n\t\t}\n\n\t\treturn []\n\t}\n\n\tpublic async delete({ entity, targetEntity, relation, targetRelation }: Model.OneHasOneOwningContext & { input: undefined }) {\n\t\tif (!relation.nullable && relation.joiningColumn.onDelete !== Model.OnDelete.cascade) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\treturn async () => {\n\t\t\tconst targetPrimary = await this.mapper.selectField(\n\t\t\t\tentity,\n\t\t\t\t{ [entity.primary]: this.primaryValue },\n\t\t\t\trelation.name,\n\t\t\t)\n\t\t\tif (!targetPrimary) {\n\t\t\t\treturn [new MutationNothingToDo([], NothingToDoReason.emptyRelation)]\n\t\t\t}\n\t\t\treturn await this.mapper.delete(targetEntity, new CheckedPrimary(targetPrimary))\n\t\t}\n\t}\n\n\tprivate async createInternal(\n\t\t{ targetEntity, targetRelation, relation, input }: Model.OneHasOneOwningContext & { input: Input.CreateDataInput },\n\t\tcurrentInverseSide: Input.PrimaryValue | undefined,\n\t): Promise<MutationResultList> {\n\t\tif (targetRelation && !targetRelation.nullable && !relation.orphanRemoval && currentInverseSide) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\treturn await this.mapper.insert(targetEntity, input)\n\t}\n\n\tprivate async getCurrentInverseSide(targetRelation: Model.OneHasOneInverseRelation | null, relation: Model.OneHasOneOwningRelation, entity: Model.Entity) {\n\t\tif ((targetRelation && !targetRelation.nullable) || relation.orphanRemoval) {\n\t\t\treturn this.mapper.selectField(entity, { [entity.primary]: this.primaryValue }, relation.name)\n\t\t}\n\t\treturn undefined\n\t}\n\n\tprivate async cleanupOrphan(relation: Model.OneHasOneOwningRelation, targetEntity: Model.Entity, currentInverseSide: Input.PrimaryValue | undefined) {\n\t\tif (relation.orphanRemoval && currentInverseSide) {\n\t\t\treturn await this.mapper.delete(targetEntity, { [targetEntity.primary]: currentInverseSide })\n\t\t}\n\t\treturn []\n\t}\n\n\tprivate async handleStateBeforeConnect(\n\t\t{ targetEntity, targetRelation, relation, entity }: Model.OneHasOneOwningContext,\n\t\tcurrentInverseSide: Input.PrimaryValue | undefined,\n\t\tnewInverseSide: Input.PrimaryValue,\n\t): Promise<MutationResultList> {\n\n\t\tif (currentInverseSide === newInverseSide) {\n\t\t\treturn [new MutationNothingToDo([], NothingToDoReason.alreadyExists)]\n\t\t}\n\n\t\tconst currentOwnerOfNewInverseSide = await this.mapper.getPrimaryValue(entity, {\n\t\t\t[relation.name]: { [targetEntity.primary]: newInverseSide },\n\t\t})\n\n\t\tif (currentOwnerOfNewInverseSide === this.primaryValue) {\n\t\t\treturn [new MutationNothingToDo([], NothingToDoReason.alreadyExists)]\n\t\t}\n\n\t\t// orphan removal handled bellow\n\t\tif (targetRelation && !targetRelation.nullable && !relation.orphanRemoval && currentInverseSide) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\tif (currentOwnerOfNewInverseSide) {\n\t\t\tif (!relation.nullable) {\n\t\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t\t}\n\n\t\t\treturn await this.mapper.updateInternal(\n\t\t\t\tentity,\n\t\t\t\t{\n\t\t\t\t\t[entity.primary]: currentOwnerOfNewInverseSide,\n\t\t\t\t},\n\t\t\t\tbuilder => {\n\t\t\t\t\tbuilder.addPredicates([relation.name])\n\t\t\t\t\tbuilder.addFieldValue(relation.name, null)\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\treturn []\n\t}\n}\n"],"names":[],"mappings":";;;AAmBO,MAAM,oCAAwI;AAAA,EACpJ,YACkB,cACA,QACA,eAChB;AAHgB,SAAA,eAAA;AACA,SAAA,SAAA;AACA,SAAA,gBAAA;AAAA,EAAA;AAAA,EAIlB,MAAa,QAAQ,SAAsE;AAC1F,UAAM,EAAE,QAAQ,UAAU,cAAc,gBAAgB,UAAU;AAClE,UAAM,iBAAiB,MAAM,KAAK,OAAO,gBAAgB,cAAc,KAAK;AAC5E,QAAI,CAAC,gBAAgB;AACpB,aAAO,CAAC,IAAI,2BAA2B,CAAC,GAAG,KAAK,CAAC;AAAA,IAAA;AAElD,UAAM,qBAAqB,MAAM,KAAK,sBAAsB,gBAAgB,UAAU,MAAM;AAC5F,UAAM,qBAAqB,MAAM,KAAK,yBAAyB,SAAS,oBAAoB,cAAc;AAC1G,QAAI,mBAAmB,KAAK,CAAM,OAAA,GAAG,KAAK,KACrC,mBAAmB,WAAW,KAAK,mBAAmB,CAAC,EAAE,WAAW,mBAAmB,aAC1F;AACM,aAAA;AAAA,IAAA;AAGR,SAAK,cAAc,cAAc,SAAS,MAAM,cAAc;AAE9D,WAA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I,GAAA,kBAAkB,aAAa,CAAC;AAAA,IAAA;AAIrE,QAAI,kBAAkB,CAAC,eAAe,YAAY,CAAC,SAAS,iBAAiB,oBAAoB;AAChG,aAAO,CAAC,IAAI,iCAAiC,CAAI,GAAA,eAAe,OAAO,CAAC;AAAA,IAAA;AAGzE,QAAI,8BAA8B;AAC7B,UAAA,CAAC,SAAS,UAAU;AACvB,eAAO,CAAC,IAAI,iCAAiC,CAAI,GAAA,eAAe,OAAO,CAAC;AAAA,MAAA;AAGlE,aAAA,MAAM,KAAK,OAAO;AAAA,QACxB;AAAA,QACA;AAAA,UACC,CAAC,OAAO,OAAO,GAAG;AAAA,QACnB;AAAA,QACA,CAAW,YAAA;AACV,kBAAQ,cAAc,CAAC,SAAS,IAAI,CAAC;AAC7B,kBAAA,cAAc,SAAS,MAAM,IAAI;AAAA,QAAA;AAAA,MAE3C;AAAA,IAAA;AAED,WAAO,CAAC;AAAA,EAAA;AAEV;"}
1
+ {"version":3,"file":"OneHasOneOwningUpdateInputProcessor.js","sources":["../../../../../../../packages/engine-content-api/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.ts"],"sourcesContent":["import { UpdateInputProcessor } from '../../../inputProcessing'\nimport { Input, Model } from '@contember/schema'\nimport {\n\tConstraintType,\n\tgetInsertPrimary,\n\tMutationConstraintViolationError,\n\tMutationEntryNotFoundError,\n\tMutationNothingToDo,\n\tMutationResultList,\n\tMutationResultType,\n\tNothingToDoReason,\n} from '../../Result'\nimport { Mapper } from '../../Mapper'\nimport { UpdateBuilder } from '../../update/UpdateBuilder'\nimport { CheckedPrimary } from '../../CheckedPrimary'\nimport { SqlUpdateInputProcessorResult } from '../SqlUpdateInputProcessor'\nimport { MapperInput } from '../../types'\n\ntype Context = Model.OneHasOneOwningContext\n\nexport class OneHasOneOwningUpdateInputProcessor implements UpdateInputProcessor.HasOneRelationInputProcessor<Context, SqlUpdateInputProcessorResult>{\n\tconstructor(\n\t\tprivate readonly primaryValue: Input.PrimaryValue,\n\t\tprivate readonly mapper: Mapper,\n\t\tprivate readonly updateBuilder: UpdateBuilder,\n\t) {\n\t}\n\n\tpublic async connect(context: Model.OneHasOneOwningContext & { input: Input.UniqueWhere | CheckedPrimary }) {\n\t\tconst { entity, relation, targetEntity, targetRelation, input } = context\n\t\tconst [newInverseSide, err] = await this.mapper.getPrimaryValue(targetEntity, input)\n\t\tif (err) return [err]\n\t\tconst currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity)\n\t\tconst currentOwnerResult = await this.handleStateBeforeConnect(context, currentInverseSide, newInverseSide)\n\t\tif (currentOwnerResult.some(it => it.error)\n\t\t\t|| (currentOwnerResult.length === 1 && currentOwnerResult[0].result === MutationResultType.nothingToDo)\n\t\t) {\n\t\t\treturn currentOwnerResult\n\t\t}\n\n\t\tthis.updateBuilder.addFieldValue(relation.name, newInverseSide)\n\n\t\treturn async () => {\n\t\t\treturn [\n\t\t\t\t...currentOwnerResult,\n\t\t\t\t...(await this.cleanupOrphan(relation, targetEntity, currentInverseSide)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async create(context: Model.OneHasOneOwningContext & { input: MapperInput.CreateDataInput }) {\n\t\tconst { entity, relation, targetEntity, targetRelation } = context\n\t\tconst currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity)\n\t\tconst createResult = await this.createInternal(context, currentInverseSide)\n\t\tconst newInverseSide = getInsertPrimary(createResult)\n\t\tif (!newInverseSide) {\n\t\t\treturn createResult\n\t\t}\n\t\tthis.updateBuilder.addFieldValue(relation.name, newInverseSide)\n\n\t\treturn async () => {\n\t\t\treturn [\n\t\t\t\t...createResult,\n\t\t\t\t...(await this.cleanupOrphan(relation, targetEntity, currentInverseSide)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async connectOrCreate({ input: { connect, create }, ...context }: Model.OneHasOneOwningContext & { input: MapperInput.ConnectOrCreateInput }) {\n\t\tconst { relation, targetRelation, targetEntity, entity } = context\n\t\tconst currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity)\n\t\tconst [newInverseSide] = await this.mapper.getPrimaryValue(targetEntity, connect)\n\n\t\tif (newInverseSide) {\n\t\t\tconst currentOwnerResult = await this.handleStateBeforeConnect(context, currentInverseSide, newInverseSide)\n\t\t\tif (currentOwnerResult.some(it => it.error)\n\t\t\t\t|| (currentOwnerResult.length === 1 && currentOwnerResult[0].result === MutationResultType.nothingToDo)\n\t\t\t) {\n\t\t\t\treturn currentOwnerResult\n\t\t\t}\n\t\t\tthis.updateBuilder.addFieldValue(relation.name, newInverseSide)\n\t\t\treturn async () => {\n\t\t\t\treturn [\n\t\t\t\t\t...currentOwnerResult,\n\t\t\t\t\t...(await this.cleanupOrphan(relation, targetEntity, currentInverseSide)),\n\t\t\t\t]\n\t\t\t}\n\n\t\t}\n\n\t\tconst createResult = await this.createInternal({ ...context, input: create }, currentInverseSide)\n\t\tconst newInverseSideCreate = getInsertPrimary(createResult)\n\t\tif (!newInverseSideCreate) {\n\t\t\treturn createResult\n\t\t}\n\t\tthis.updateBuilder.addFieldValue(relation.name, newInverseSideCreate)\n\t\treturn async () => {\n\t\t\treturn [\n\t\t\t\t...createResult,\n\t\t\t\t...(await this.cleanupOrphan(relation, targetEntity, currentInverseSide)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async update({ entity, relation, targetEntity, input }: Model.OneHasOneOwningContext & { input: MapperInput.UpdateDataInput }) {\n\t\treturn async () => {\n\t\t\tconst inversePrimary = await this.mapper.selectField(\n\t\t\t\tentity,\n\t\t\t\t{ [entity.primary]: this.primaryValue },\n\t\t\t\trelation.name,\n\t\t\t)\n\t\t\tif (!inversePrimary) {\n\t\t\t\treturn [new MutationNothingToDo([], NothingToDoReason.emptyRelation)]\n\t\t\t}\n\t\t\treturn await this.mapper.update(targetEntity, new CheckedPrimary(inversePrimary), input)\n\t\t}\n\t}\n\n\tpublic async upsert({ entity, relation, targetEntity, input: { create, update } }: Model.OneHasOneOwningContext & { input: UpdateInputProcessor.UpsertInput }) {\n\t\tconst primary = await this.mapper.selectField(entity, { [entity.primary]: this.primaryValue }, relation.name)\n\t\tif (!primary) {\n\t\t\tconst insertResult = await this.mapper.insert(targetEntity, create)\n\t\t\tconst insertPrimary = getInsertPrimary(insertResult)\n\t\t\tif (!insertPrimary) {\n\t\t\t\treturn insertResult\n\t\t\t}\n\t\t\tthis.updateBuilder.addFieldValue(relation.name, insertPrimary)\n\t\t\treturn []\n\t\t}\n\n\t\treturn async () => {\n\t\t\treturn await this.mapper.update(targetEntity, new CheckedPrimary(primary), update)\n\t\t}\n\t}\n\n\tpublic async disconnect({ entity, targetEntity, relation, targetRelation }: Model.OneHasOneOwningContext & { input: undefined }) {\n\t\tif (!relation.nullable) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\tconst inversePrimary = (targetRelation && !targetRelation.nullable) || relation.orphanRemoval\n\t\t\t? await this.mapper.selectField(entity, { [entity.primary]: this.primaryValue }, relation.name)\n\t\t\t: undefined\n\t\tif (inversePrimary && targetRelation && !targetRelation.nullable && !relation.orphanRemoval) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\t\tthis.updateBuilder.addFieldValue(relation.name, null)\n\n\t\tif (relation.orphanRemoval && inversePrimary) {\n\t\t\treturn async () => {\n\t\t\t\treturn await this.mapper.delete(targetEntity, new CheckedPrimary(inversePrimary))\n\t\t\t}\n\t\t}\n\n\t\treturn []\n\t}\n\n\tpublic async delete({ entity, targetEntity, relation, targetRelation }: Model.OneHasOneOwningContext & { input: undefined }) {\n\t\tif (!relation.nullable && relation.joiningColumn.onDelete !== Model.OnDelete.cascade) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\treturn async () => {\n\t\t\tconst targetPrimary = await this.mapper.selectField(\n\t\t\t\tentity,\n\t\t\t\t{ [entity.primary]: this.primaryValue },\n\t\t\t\trelation.name,\n\t\t\t)\n\t\t\tif (!targetPrimary) {\n\t\t\t\treturn [new MutationNothingToDo([], NothingToDoReason.emptyRelation)]\n\t\t\t}\n\t\t\treturn await this.mapper.delete(targetEntity, new CheckedPrimary(targetPrimary))\n\t\t}\n\t}\n\n\tprivate async createInternal(\n\t\t{ targetEntity, targetRelation, relation, input }: Model.OneHasOneOwningContext & { input: MapperInput.CreateDataInput },\n\t\tcurrentInverseSide: Input.PrimaryValue | undefined,\n\t): Promise<MutationResultList> {\n\t\tif (targetRelation && !targetRelation.nullable && !relation.orphanRemoval && currentInverseSide) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\treturn await this.mapper.insert(targetEntity, input)\n\t}\n\n\tprivate async getCurrentInverseSide(targetRelation: Model.OneHasOneInverseRelation | null, relation: Model.OneHasOneOwningRelation, entity: Model.Entity) {\n\t\tif ((targetRelation && !targetRelation.nullable) || relation.orphanRemoval) {\n\t\t\treturn this.mapper.selectField(entity, { [entity.primary]: this.primaryValue }, relation.name)\n\t\t}\n\t\treturn undefined\n\t}\n\n\tprivate async cleanupOrphan(relation: Model.OneHasOneOwningRelation, targetEntity: Model.Entity, currentInverseSide: Input.PrimaryValue | undefined) {\n\t\tif (relation.orphanRemoval && currentInverseSide) {\n\t\t\treturn await this.mapper.delete(targetEntity, { [targetEntity.primary]: currentInverseSide })\n\t\t}\n\t\treturn []\n\t}\n\n\tprivate async handleStateBeforeConnect(\n\t\t{ targetEntity, targetRelation, relation, entity }: Model.OneHasOneOwningContext,\n\t\tcurrentInverseSide: Input.PrimaryValue | undefined,\n\t\tnewInverseSide: Input.PrimaryValue,\n\t): Promise<MutationResultList> {\n\n\t\tif (currentInverseSide === newInverseSide) {\n\t\t\treturn [new MutationNothingToDo([], NothingToDoReason.alreadyExists)]\n\t\t}\n\n\t\tconst [currentOwnerOfNewInverseSide] = await this.mapper.getPrimaryValue(entity, {\n\t\t\t[relation.name]: { [targetEntity.primary]: newInverseSide },\n\t\t})\n\n\t\tif (currentOwnerOfNewInverseSide === this.primaryValue) {\n\t\t\treturn [new MutationNothingToDo([], NothingToDoReason.alreadyExists)]\n\t\t}\n\n\t\t// orphan removal handled bellow\n\t\tif (targetRelation && !targetRelation.nullable && !relation.orphanRemoval && currentInverseSide) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\tif (currentOwnerOfNewInverseSide) {\n\t\t\tif (!relation.nullable) {\n\t\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t\t}\n\n\t\t\treturn await this.mapper.updateInternal(\n\t\t\t\tentity,\n\t\t\t\tnew CheckedPrimary(currentOwnerOfNewInverseSide),\n\t\t\t\tbuilder => {\n\t\t\t\t\tbuilder.addPredicates([relation.name])\n\t\t\t\t\tbuilder.addFieldValue(relation.name, null)\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\treturn []\n\t}\n}\n"],"names":[],"mappings":";;;AAoBO,MAAM,oCAAwI;AAAA,EACpJ,YACkB,cACA,QACA,eAChB;AAHgB,SAAA,eAAA;AACA,SAAA,SAAA;AACA,SAAA,gBAAA;AAAA,EAAA;AAAA,EAIlB,MAAa,QAAQ,SAAuF;AAC3G,UAAM,EAAE,QAAQ,UAAU,cAAc,gBAAgB,UAAU;AAC5D,UAAA,CAAC,gBAAgB,GAAG,IAAI,MAAM,KAAK,OAAO,gBAAgB,cAAc,KAAK;AAC/E,QAAA,IAAY,QAAA,CAAC,GAAG;AACpB,UAAM,qBAAqB,MAAM,KAAK,sBAAsB,gBAAgB,UAAU,MAAM;AAC5F,UAAM,qBAAqB,MAAM,KAAK,yBAAyB,SAAS,oBAAoB,cAAc;AAC1G,QAAI,mBAAmB,KAAK,CAAM,OAAA,GAAG,KAAK,KACrC,mBAAmB,WAAW,KAAK,mBAAmB,CAAC,EAAE,WAAW,mBAAmB,aAC1F;AACM,aAAA;AAAA,IAAA;AAGR,SAAK,cAAc,cAAc,SAAS,MAAM,cAAc;AAE9D,WAAO,YAAY;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rE,QAAI,kBAAkB,CAAC,eAAe,YAAY,CAAC,SAAS,iBAAiB,oBAAoB;AAChG,aAAO,CAAC,IAAI,iCAAiC,CAAI,GAAA,eAAe,OAAO,CAAC;AAAA,IAAA;AAGzE,QAAI,8BAA8B;AAC7B,UAAA,CAAC,SAAS,UAAU;AACvB,eAAO,CAAC,IAAI,iCAAiC,CAAI,GAAA,eAAe,OAAO,CAAC;AAAA,MAAA;AAGlE,aAAA,MAAM,KAAK,OAAO;AAAA,QACxB;AAAA,QACA,IAAI,eAAe,4BAA4B;AAAA,QAC/C,CAAW,YAAA;AACV,kBAAQ,cAAc,CAAC,SAAS,IAAI,CAAC;AAC7B,kBAAA,cAAc,SAAS,MAAM,IAAI;AAAA,QAAA;AAAA,MAE3C;AAAA,IAAA;AAED,WAAO,CAAC;AAAA,EAAA;AAEV;"}
@@ -40,6 +40,32 @@ class HasManyToHasOneRelationReducerFieldVisitor {
40
40
  return [];
41
41
  }
42
42
  const uniqueConstraints = uniqueWhereFields.getFieldsForUniqueWhere(this.schema, targetEntity);
43
+ const uniqueKeys = uniqueConstraints.map((it) => it.filter((it2) => it2 !== targetRelation.name)).filter((it) => it.length > 0).filter((uniqueKey) => uniqueKey.every(
44
+ (it) => schemaUtils.acceptFieldVisitor(this.schema, targetEntity.name, it, new FieldAccessVisitor.FieldAccessVisitor(schema.Acl.Operation.read, this.authorizator))
45
+ ));
46
+ const graphQlName = relation.name + utils.GqlTypeName`By`;
47
+ const uniqueWhere = new graphql.GraphQLInputObjectType({
48
+ name: utils.GqlTypeName`${entity.name}${relation.name}UniqueWhere`,
49
+ fields: () => {
50
+ return this.whereTypeProvider.getUniqueWhereFields(targetEntity, uniqueKeys);
51
+ }
52
+ });
53
+ const entityType = this.entityTypeProvider.getEntity(targetEntity.name);
54
+ const universalUnique = graphQlName in entity.fields ? null : [
55
+ graphQlName,
56
+ {
57
+ type: entityType,
58
+ extensions: {
59
+ relationName: relation.name,
60
+ extensionKey: HasManyToHasOneReducer.HasManyToHasOneReducer.extensionName
61
+ },
62
+ args: {
63
+ by: { type: new graphql.GraphQLNonNull(uniqueWhere) },
64
+ filter: { type: this.whereTypeProvider.getEntityWhereType(targetEntity.name) }
65
+ },
66
+ resolve: utils.aliasAwareResolver
67
+ }
68
+ ];
43
69
  const composedUnique = uniqueConstraints.filter((fields) => fields.length === 2).filter((fields) => fields.includes(targetRelation.name)).map((fields) => fields.filter((it) => it !== targetRelation.name)).map((fields) => fields[0]);
44
70
  const singleUnique = uniqueConstraints.filter((fields) => fields.length === 1 && fields[0] !== targetEntity.primary).map((fields) => fields[0]).filter((it) => it !== targetRelation.name);
45
71
  const existing = /* @__PURE__ */ new Set();
@@ -55,17 +81,16 @@ class HasManyToHasOneRelationReducerFieldVisitor {
55
81
  return null;
56
82
  }
57
83
  existing.add(fieldName);
58
- const graphQlName = relation.name + utils.GqlTypeName`By${fieldName}`;
59
- const uniqueWhere = new graphql.GraphQLInputObjectType({
84
+ const graphQlName2 = relation.name + utils.GqlTypeName`By${fieldName}`;
85
+ const uniqueWhere2 = new graphql.GraphQLInputObjectType({
60
86
  //todo this can be simplified to ${targetEntity.name}By${fieldName}, but singleton must be used
61
87
  name: utils.GqlTypeName`${entity.name}${relation.name}By${fieldName}UniqueWhere`,
62
88
  fields: () => {
63
89
  return this.whereTypeProvider.getUniqueWhereFields(targetEntity, [[fieldName]]);
64
90
  }
65
91
  });
66
- const entityType = this.entityTypeProvider.getEntity(targetEntity.name);
67
92
  return [
68
- graphQlName,
93
+ graphQlName2,
69
94
  {
70
95
  type: entityType,
71
96
  extensions: {
@@ -73,13 +98,13 @@ class HasManyToHasOneRelationReducerFieldVisitor {
73
98
  extensionKey: HasManyToHasOneReducer.HasManyToHasOneReducer.extensionName
74
99
  },
75
100
  args: {
76
- by: { type: new graphql.GraphQLNonNull(uniqueWhere) },
101
+ by: { type: new graphql.GraphQLNonNull(uniqueWhere2) },
77
102
  filter: { type: this.whereTypeProvider.getEntityWhereType(targetEntity.name) }
78
103
  },
79
104
  resolve: utils.aliasAwareResolver
80
105
  }
81
106
  ];
82
- }).filter((it) => it !== null);
107
+ }).concat([universalUnique]).filter((it) => it !== null);
83
108
  }
84
109
  }
85
110
  exports.HasManyToHasOneRelationReducerFieldVisitor = HasManyToHasOneRelationReducerFieldVisitor;
@@ -1 +1 @@
1
- {"version":3,"file":"HasManyToHasOneRelationReducerVisitor.cjs","sources":["../../../../../../packages/engine-content-api/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts"],"sourcesContent":["import { GraphQLInputObjectType, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { aliasAwareResolver, EntityTypeProvider, FieldAccessVisitor, GqlTypeName, WhereTypeProvider } from '../../schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { Authorizator } from '../../acl'\nimport { getFieldsForUniqueWhere } from '../../utils'\nimport { HasManyToHasOneReducer, HasManyToHasOneReducerExtension } from './HasManyToHasOneReducer'\nimport { GraphQLFieldConfig } from 'graphql'\n\ntype Result = [\n\tstring,\n\tGraphQLFieldConfig<any, any> & {\n\t\textensions: HasManyToHasOneReducerExtension\n\t}\n]\n\nexport class HasManyToHasOneRelationReducerFieldVisitor implements\n\tModel.ColumnVisitor<Result[]>,\n\tModel.RelationByTypeVisitor<Result[]> {\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t) {}\n\n\tpublic visitColumn() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasOneOwning() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasOneInverse() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasOne() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasManyInverse() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasManyOwning() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasMany({ entity, targetEntity, targetRelation, relation }: Model.OneHasManyContext) {\n\t\tif (!targetRelation) {\n\t\t\treturn []\n\t\t}\n\t\tconst uniqueConstraints = getFieldsForUniqueWhere(this.schema, targetEntity)\n\t\tconst composedUnique = uniqueConstraints\n\t\t\t.filter(fields => fields.length === 2) //todo support all uniques\n\t\t\t.filter(fields => fields.includes(targetRelation.name))\n\t\t\t.map(fields => fields.filter(it => it !== targetRelation.name))\n\t\t\t.map(fields => fields[0])\n\t\tconst singleUnique = uniqueConstraints\n\t\t\t.filter(fields => fields.length === 1 && fields[0] !== targetEntity.primary)\n\t\t\t.map(fields => fields[0])\n\t\t\t.filter(it => it !== targetRelation.name)\n\n\n\t\tconst existing = new Set<string>()\n\t\treturn [...composedUnique, ...singleUnique]\n\t\t\t.filter(field =>\n\t\t\t\tacceptFieldVisitor(\n\t\t\t\t\tthis.schema,\n\t\t\t\t\ttargetEntity.name,\n\t\t\t\t\tfield,\n\t\t\t\t\tnew FieldAccessVisitor(Acl.Operation.read, this.authorizator),\n\t\t\t\t),\n\t\t\t)\n\t\t\t.map<Result | null>(fieldName => {\n\t\t\t\tif (existing.has(fieldName)) {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\texisting.add(fieldName)\n\t\t\t\tconst graphQlName = relation.name + GqlTypeName`By${fieldName}`\n\t\t\t\tconst uniqueWhere: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\t\t\t//todo this can be simplified to ${targetEntity.name}By${fieldName}, but singleton must be used\n\t\t\t\t\tname: GqlTypeName`${entity.name}${relation.name}By${fieldName}UniqueWhere`,\n\t\t\t\t\tfields: () => {\n\t\t\t\t\t\treturn this.whereTypeProvider.getUniqueWhereFields(targetEntity, [[fieldName]])\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tconst entityType = this.entityTypeProvider.getEntity(targetEntity.name)\n\n\t\t\t\treturn [\n\t\t\t\t\tgraphQlName,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: entityType,\n\t\t\t\t\t\textensions: {\n\t\t\t\t\t\t\trelationName: relation.name,\n\t\t\t\t\t\t\textensionKey: HasManyToHasOneReducer.extensionName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\targs: {\n\t\t\t\t\t\t\tby: { type: new GraphQLNonNull(uniqueWhere) },\n\t\t\t\t\t\t\tfilter: { type: this.whereTypeProvider.getEntityWhereType(targetEntity.name) },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t})\n\t\t\t.filter((it): it is Result => it !== null)\n\t}\n}\n"],"names":["schema","getFieldsForUniqueWhere","acceptFieldVisitor","FieldAccessVisitor","Acl","GqlTypeName","GraphQLInputObjectType","HasManyToHasOneReducer","GraphQLNonNull","aliasAwareResolver"],"mappings":";;;;;;;;;;;;AAgBO,MAAM,2CAE0B;AAAA,EAEtC,YACkBA,SACA,cACA,oBACA,mBAChB;AAJgB,SAAA,SAAAA;AACA,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,oBAAA;AAAA,EAAA;AAAA,EAGX,cAAc;AACpB,WAAO,CAAC;AAAA,EAAA;AAAA,EAGF,uBAAuB;AAC7B,WAAO,CAAC;AAAA,EAAA;AAAA,EAGF,wBAAwB;AAC9B,WAAO,CAAC;AAAA,EAAA;AAAA,EAGF,kBAAkB;AACxB,WAAO,CAAC;AAAA,EAAA;AAAA,EAGF,0BAA0B;AAChC,WAAO,CAAC;AAAA,EAAA;AAAA,EAGF,yBAAyB;AAC/B,WAAO,CAAC;AAAA,EAAA;AAAA,EAGF,gBAAgB,EAAE,QAAQ,cAAc,gBAAgB,YAAqC;AACnG,QAAI,CAAC,gBAAgB;AACpB,aAAO,CAAC;AAAA,IAAA;AAET,UAAM,oBAAoBC,kBAAA,wBAAwB,KAAK,QAAQ,YAAY;AAC3E,UAAM,iBAAiB,kBACrB,OAAO,CAAA,WAAU,OAAO,WAAW,CAAC,EACpC,O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IC,QAAA,eAAe,WAAW,EAAE;AAAA,YAC5C,QAAQ,EAAE,MAAM,KAAK,kBAAkB,mBAAmB,aAAa,IAAI,EAAE;AAAA,UAC9E;AAAA,UACA,SAASC,MAAAA;AAAAA,QAAA;AAAA,MAEX;AAAA,IACA,CAAA,EACA,OAAO,CAAC,OAAqB,OAAO,IAAI;AAAA,EAAA;AAE5C;;"}
1
+ {"version":3,"file":"HasManyToHasOneRelationReducerVisitor.cjs","sources":["../../../../../../packages/engine-content-api/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts"],"sourcesContent":["import { GraphQLInputObjectType, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { aliasAwareResolver, EntityTypeProvider, FieldAccessVisitor, GqlTypeName, WhereTypeProvider } from '../../schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { Authorizator } from '../../acl'\nimport { getFieldsForUniqueWhere } from '../../utils'\nimport { HasManyToHasOneReducer, HasManyToHasOneReducerExtension } from './HasManyToHasOneReducer'\nimport { GraphQLFieldConfig } from 'graphql'\n\ntype Result = [\n\tstring,\n\tGraphQLFieldConfig<any, any> & {\n\t\textensions: HasManyToHasOneReducerExtension\n\t}\n]\n\nexport class HasManyToHasOneRelationReducerFieldVisitor implements\n\tModel.ColumnVisitor<Result[]>,\n\tModel.RelationByTypeVisitor<Result[]> {\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t) {}\n\n\tpublic visitColumn() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasOneOwning() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasOneInverse() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasOne() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasManyInverse() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasManyOwning() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasMany({ entity, targetEntity, targetRelation, relation }: Model.OneHasManyContext) {\n\t\tif (!targetRelation) {\n\t\t\treturn []\n\t\t}\n\t\tconst uniqueConstraints = getFieldsForUniqueWhere(this.schema, targetEntity)\n\n\t\tconst uniqueKeys: (readonly string[])[] = uniqueConstraints\n\t\t\t.map(it => it.filter(it => it !== targetRelation.name))\n\t\t\t.filter(it => it.length > 0)\n\t\t\t.filter(uniqueKey => uniqueKey\n\t\t\t\t.every(it =>\n\t\t\t\t\tacceptFieldVisitor(this.schema, targetEntity.name, it, new FieldAccessVisitor(Acl.Operation.read, this.authorizator)),\n\t\t\t\t))\n\n\t\tconst graphQlName = relation.name + GqlTypeName`By`\n\t\tconst uniqueWhere: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entity.name}${relation.name}UniqueWhere`,\n\t\t\tfields: () => {\n\t\t\t\treturn this.whereTypeProvider.getUniqueWhereFields(targetEntity, uniqueKeys)\n\t\t\t},\n\t\t})\n\n\t\tconst entityType = this.entityTypeProvider.getEntity(targetEntity.name)\n\t\tconst universalUnique: Result | null = graphQlName in entity.fields ? null : [\n\t\t\tgraphQlName,\n\t\t\t{\n\t\t\t\ttype: entityType,\n\t\t\t\textensions: {\n\t\t\t\t\trelationName: relation.name,\n\t\t\t\t\textensionKey: HasManyToHasOneReducer.extensionName,\n\t\t\t\t},\n\t\t\t\targs: {\n\t\t\t\t\tby: { type: new GraphQLNonNull(uniqueWhere) },\n\t\t\t\t\tfilter: { type: this.whereTypeProvider.getEntityWhereType(targetEntity.name) },\n\t\t\t\t},\n\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t},\n\t\t]\n\n\t\tconst composedUnique = uniqueConstraints\n\t\t\t.filter(fields => fields.length === 2) //todo support all uniques\n\t\t\t.filter(fields => fields.includes(targetRelation.name))\n\t\t\t.map(fields => fields.filter(it => it !== targetRelation.name))\n\t\t\t.map(fields => fields[0])\n\t\tconst singleUnique = uniqueConstraints\n\t\t\t.filter(fields => fields.length === 1 && fields[0] !== targetEntity.primary)\n\t\t\t.map(fields => fields[0])\n\t\t\t.filter(it => it !== targetRelation.name)\n\n\n\t\tconst existing = new Set<string>()\n\t\treturn [...composedUnique, ...singleUnique]\n\t\t\t.filter(field =>\n\t\t\t\tacceptFieldVisitor(\n\t\t\t\t\tthis.schema,\n\t\t\t\t\ttargetEntity.name,\n\t\t\t\t\tfield,\n\t\t\t\t\tnew FieldAccessVisitor(Acl.Operation.read, this.authorizator),\n\t\t\t\t),\n\t\t\t)\n\t\t\t.map<Result | null>(fieldName => {\n\t\t\t\tif (existing.has(fieldName)) {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\texisting.add(fieldName)\n\t\t\t\tconst graphQlName = relation.name + GqlTypeName`By${fieldName}`\n\t\t\t\tconst uniqueWhere: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\t\t\t//todo this can be simplified to ${targetEntity.name}By${fieldName}, but singleton must be used\n\t\t\t\t\tname: GqlTypeName`${entity.name}${relation.name}By${fieldName}UniqueWhere`,\n\t\t\t\t\tfields: () => {\n\t\t\t\t\t\treturn this.whereTypeProvider.getUniqueWhereFields(targetEntity, [[fieldName]])\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\treturn [\n\t\t\t\t\tgraphQlName,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: entityType,\n\t\t\t\t\t\textensions: {\n\t\t\t\t\t\t\trelationName: relation.name,\n\t\t\t\t\t\t\textensionKey: HasManyToHasOneReducer.extensionName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\targs: {\n\t\t\t\t\t\t\tby: { type: new GraphQLNonNull(uniqueWhere) },\n\t\t\t\t\t\t\tfilter: { type: this.whereTypeProvider.getEntityWhereType(targetEntity.name) },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t})\n\t\t\t.concat([universalUnique])\n\t\t\t.filter((it): it is Result => it !== null)\n\t}\n}\n"],"names":["schema","getFieldsForUniqueWhere","it","acceptFieldVisitor","FieldAccessVisitor","Acl","GqlTypeName","GraphQLInputObjectType","HasManyToHasOneReducer","GraphQLNonNull","aliasAwareResolver","graphQlName","uniqueWhere"],"mappings":";;;;;;;;;;;;AAgBO,MAAM,2CAE0B;AAAA,EAEtC,YACkBA,SACA,cACA,oBACA,mBAChB;AAJgB,SAAA,SAAAA;AACA,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,oBAAA;AAAA,EAAA;AAAA,EAGX,cAAc;AACpB,WAAO,CAAC;AAAA,EAAA;AAAA,EAGF,uBAAuB;AAC7B,WAAO,CAAC;AAAA,EAAA;AAAA,EAGF,wBAAwB;AAC9B,WAAO,CAAC;AAAA,EAAA;AAAA,EAGF,kBAAkB;AACxB,WAAO,CAAC;AAAA,EAAA;AAAA,EAGF,0BAA0B;AAChC,WAAO,CAAC;AAAA,EAAA;AAAA,EAGF,yBAAyB;AAC/B,WAAO,CAAC;AAAA,EAAA;AAAA,EAGF,gBAAgB,EAAE,QAAQ,cAAc,gBAAgB,YAAqC;AACnG,QAAI,CAAC,gBAAgB;AACpB,aAAO,CAAC;AAAA,IAAA;AAET,UAAM,oBAAoBC,kBAAA,wBAAwB,KAAK,QAAQ,YAAY;AAErE,UAAA,aAAoC,kBACxC,IAAI,CAAA,OAAM,GAAG,OAAO,CAAAC,QAAMA,QAAO,eAAe,IAAI,CAAC,EACrD,OAAO,CAAM,OAAA,GAAG,SAAS,CAAC,EAC1B,OAAO,CAAA,cAAa,UACnB;AAAA,MAAM,CACN,OAAAC,YAAA,mBAAmB,KAAK,QAAQ,aAAa,MAAM,IAAI,IAAIC,mBAAAA,mBAAmBC,OAAAA,IAAI,UAAU,MAAM,KAAK,YAAY,CAAC;AAAA,IAAA,CACpH;AAEG,UAAA,cAAc,SAAS,OAAOC,MAAAA;AAC9B,UAAA,cA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U,MAAM,KAAK,YAAY;AAAA,MAAA;AAAA,IAC7D,EAEA,IAAmB,CAAa,cAAA;AAC5B,UAAA,SAAS,IAAI,SAAS,GAAG;AACrB,eAAA;AAAA,MAAA;AAER,eAAS,IAAI,SAAS;AACtB,YAAMM,eAAc,SAAS,OAAOL,MAAAA,gBAAgB,SAAS;AACvDM,YAAAA,eAAsC,IAAIL,+BAAuB;AAAA;AAAA,QAEtE,MAAMD,MAAAA,cAAc,OAAO,IAAI,GAAG,SAAS,IAAI,KAAK,SAAS;AAAA,QAC7D,QAAQ,MAAM;AACN,iBAAA,KAAK,kBAAkB,qBAAqB,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC;AAAA,QAAA;AAAA,MAC/E,CACA;AAEM,aAAA;AAAA,QACNK;AAAAA,QACA;AAAA,UACC,MAAM;AAAA,UACN,YAAY;AAAA,YACX,cAAc,SAAS;AAAA,YACvB,cAAcH,uBAAAA,uBAAuB;AAAA,UACtC;AAAA,UACA,MAAM;AAAA,YACL,IAAI,EAAE,MAAM,IAAIC,QAAA,eAAeG,YAAW,EAAE;AAAA,YAC5C,QAAQ,EAAE,MAAM,KAAK,kBAAkB,mBAAmB,aAAa,IAAI,EAAE;AAAA,UAC9E;AAAA,UACA,SAASF,MAAAA;AAAAA,QAAA;AAAA,MAEX;AAAA,IAAA,CACA,EACA,OAAO,CAAC,eAAe,CAAC,EACxB,OAAO,CAAC,OAAqB,OAAO,IAAI;AAAA,EAAA;AAE5C;;"}
@@ -38,6 +38,32 @@ class HasManyToHasOneRelationReducerFieldVisitor {
38
38
  return [];
39
39
  }
40
40
  const uniqueConstraints = getFieldsForUniqueWhere(this.schema, targetEntity);
41
+ const uniqueKeys = uniqueConstraints.map((it) => it.filter((it2) => it2 !== targetRelation.name)).filter((it) => it.length > 0).filter((uniqueKey) => uniqueKey.every(
42
+ (it) => acceptFieldVisitor(this.schema, targetEntity.name, it, new FieldAccessVisitor(Acl.Operation.read, this.authorizator))
43
+ ));
44
+ const graphQlName = relation.name + GqlTypeName`By`;
45
+ const uniqueWhere = new GraphQLInputObjectType({
46
+ name: GqlTypeName`${entity.name}${relation.name}UniqueWhere`,
47
+ fields: () => {
48
+ return this.whereTypeProvider.getUniqueWhereFields(targetEntity, uniqueKeys);
49
+ }
50
+ });
51
+ const entityType = this.entityTypeProvider.getEntity(targetEntity.name);
52
+ const universalUnique = graphQlName in entity.fields ? null : [
53
+ graphQlName,
54
+ {
55
+ type: entityType,
56
+ extensions: {
57
+ relationName: relation.name,
58
+ extensionKey: HasManyToHasOneReducer.extensionName
59
+ },
60
+ args: {
61
+ by: { type: new GraphQLNonNull(uniqueWhere) },
62
+ filter: { type: this.whereTypeProvider.getEntityWhereType(targetEntity.name) }
63
+ },
64
+ resolve: aliasAwareResolver
65
+ }
66
+ ];
41
67
  const composedUnique = uniqueConstraints.filter((fields) => fields.length === 2).filter((fields) => fields.includes(targetRelation.name)).map((fields) => fields.filter((it) => it !== targetRelation.name)).map((fields) => fields[0]);
42
68
  const singleUnique = uniqueConstraints.filter((fields) => fields.length === 1 && fields[0] !== targetEntity.primary).map((fields) => fields[0]).filter((it) => it !== targetRelation.name);
43
69
  const existing = /* @__PURE__ */ new Set();
@@ -53,17 +79,16 @@ class HasManyToHasOneRelationReducerFieldVisitor {
53
79
  return null;
54
80
  }
55
81
  existing.add(fieldName);
56
- const graphQlName = relation.name + GqlTypeName`By${fieldName}`;
57
- const uniqueWhere = new GraphQLInputObjectType({
82
+ const graphQlName2 = relation.name + GqlTypeName`By${fieldName}`;
83
+ const uniqueWhere2 = new GraphQLInputObjectType({
58
84
  //todo this can be simplified to ${targetEntity.name}By${fieldName}, but singleton must be used
59
85
  name: GqlTypeName`${entity.name}${relation.name}By${fieldName}UniqueWhere`,
60
86
  fields: () => {
61
87
  return this.whereTypeProvider.getUniqueWhereFields(targetEntity, [[fieldName]]);
62
88
  }
63
89
  });
64
- const entityType = this.entityTypeProvider.getEntity(targetEntity.name);
65
90
  return [
66
- graphQlName,
91
+ graphQlName2,
67
92
  {
68
93
  type: entityType,
69
94
  extensions: {
@@ -71,13 +96,13 @@ class HasManyToHasOneRelationReducerFieldVisitor {
71
96
  extensionKey: HasManyToHasOneReducer.extensionName
72
97
  },
73
98
  args: {
74
- by: { type: new GraphQLNonNull(uniqueWhere) },
99
+ by: { type: new GraphQLNonNull(uniqueWhere2) },
75
100
  filter: { type: this.whereTypeProvider.getEntityWhereType(targetEntity.name) }
76
101
  },
77
102
  resolve: aliasAwareResolver
78
103
  }
79
104
  ];
80
- }).filter((it) => it !== null);
105
+ }).concat([universalUnique]).filter((it) => it !== null);
81
106
  }
82
107
  }
83
108
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"HasManyToHasOneRelationReducerVisitor.js","sources":["../../../../../../packages/engine-content-api/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts"],"sourcesContent":["import { GraphQLInputObjectType, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { aliasAwareResolver, EntityTypeProvider, FieldAccessVisitor, GqlTypeName, WhereTypeProvider } from '../../schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { Authorizator } from '../../acl'\nimport { getFieldsForUniqueWhere } from '../../utils'\nimport { HasManyToHasOneReducer, HasManyToHasOneReducerExtension } from './HasManyToHasOneReducer'\nimport { GraphQLFieldConfig } from 'graphql'\n\ntype Result = [\n\tstring,\n\tGraphQLFieldConfig<any, any> & {\n\t\textensions: HasManyToHasOneReducerExtension\n\t}\n]\n\nexport class HasManyToHasOneRelationReducerFieldVisitor implements\n\tModel.ColumnVisitor<Result[]>,\n\tModel.RelationByTypeVisitor<Result[]> {\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t) {}\n\n\tpublic visitColumn() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasOneOwning() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasOneInverse() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasOne() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasManyInverse() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasManyOwning() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasMany({ entity, targetEntity, targetRelation, relation }: Model.OneHasManyContext) {\n\t\tif (!targetRelation) {\n\t\t\treturn []\n\t\t}\n\t\tconst uniqueConstraints = getFieldsForUniqueWhere(this.schema, targetEntity)\n\t\tconst composedUnique = uniqueConstraints\n\t\t\t.filter(fields => fields.length === 2) //todo support all uniques\n\t\t\t.filter(fields => fields.includes(targetRelation.name))\n\t\t\t.map(fields => fields.filter(it => it !== targetRelation.name))\n\t\t\t.map(fields => fields[0])\n\t\tconst singleUnique = uniqueConstraints\n\t\t\t.filter(fields => fields.length === 1 && fields[0] !== targetEntity.primary)\n\t\t\t.map(fields => fields[0])\n\t\t\t.filter(it => it !== targetRelation.name)\n\n\n\t\tconst existing = new Set<string>()\n\t\treturn [...composedUnique, ...singleUnique]\n\t\t\t.filter(field =>\n\t\t\t\tacceptFieldVisitor(\n\t\t\t\t\tthis.schema,\n\t\t\t\t\ttargetEntity.name,\n\t\t\t\t\tfield,\n\t\t\t\t\tnew FieldAccessVisitor(Acl.Operation.read, this.authorizator),\n\t\t\t\t),\n\t\t\t)\n\t\t\t.map<Result | null>(fieldName => {\n\t\t\t\tif (existing.has(fieldName)) {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\texisting.add(fieldName)\n\t\t\t\tconst graphQlName = relation.name + GqlTypeName`By${fieldName}`\n\t\t\t\tconst uniqueWhere: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\t\t\t//todo this can be simplified to ${targetEntity.name}By${fieldName}, but singleton must be used\n\t\t\t\t\tname: GqlTypeName`${entity.name}${relation.name}By${fieldName}UniqueWhere`,\n\t\t\t\t\tfields: () => {\n\t\t\t\t\t\treturn this.whereTypeProvider.getUniqueWhereFields(targetEntity, [[fieldName]])\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tconst entityType = this.entityTypeProvider.getEntity(targetEntity.name)\n\n\t\t\t\treturn [\n\t\t\t\t\tgraphQlName,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: entityType,\n\t\t\t\t\t\textensions: {\n\t\t\t\t\t\t\trelationName: relation.name,\n\t\t\t\t\t\t\textensionKey: HasManyToHasOneReducer.extensionName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\targs: {\n\t\t\t\t\t\t\tby: { type: new GraphQLNonNull(uniqueWhere) },\n\t\t\t\t\t\t\tfilter: { type: this.whereTypeProvider.getEntityWhereType(targetEntity.name) },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t})\n\t\t\t.filter((it): it is Result => it !== null)\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;AAgBO,MAAM,2CAE0B;AAAA,EAEtC,YACkB,QACA,cACA,oBACA,mBAChB;AAJgB,SAAA,SAAA;AACA,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,oBAAA;AAAA,EAAA;AAAA,EAGX,cAAc;AACpB,WAAO,CAAC;AAAA,EAAA;AAAA,EAGF,uBAAuB;AAC7B,WAAO,CAAC;AAAA,EAAA;AAAA,EAGF,wBAAwB;AAC9B,WAAO,CAAC;AAAA,EAAA;AAAA,EAGF,kBAAkB;AACxB,WAAO,CAAC;AAAA,EAAA;AAAA,EAGF,0BAA0B;AAChC,WAAO,CAAC;AAAA,EAAA;AAAA,EAGF,yBAAyB;AAC/B,WAAO,CAAC;AAAA,EAAA;AAAA,EAGF,gBAAgB,EAAE,QAAQ,cAAc,gBAAgB,YAAqC;AACnG,QAAI,CAAC,gBAAgB;AACpB,aAAO,CAAC;AAAA,IAAA;AAET,UAAM,oBAAoB,wBAAwB,KAAK,QA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AAAA,YACL,IAAI,EAAE,MAAM,IAAI,eAAe,WAAW,EAAE;AAAA,YAC5C,QAAQ,EAAE,MAAM,KAAK,kBAAkB,mBAAmB,aAAa,IAAI,EAAE;AAAA,UAC9E;AAAA,UACA,SAAS;AAAA,QAAA;AAAA,MAEX;AAAA,IACA,CAAA,EACA,OAAO,CAAC,OAAqB,OAAO,IAAI;AAAA,EAAA;AAE5C;"}
1
+ {"version":3,"file":"HasManyToHasOneRelationReducerVisitor.js","sources":["../../../../../../packages/engine-content-api/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts"],"sourcesContent":["import { GraphQLInputObjectType, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { aliasAwareResolver, EntityTypeProvider, FieldAccessVisitor, GqlTypeName, WhereTypeProvider } from '../../schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { Authorizator } from '../../acl'\nimport { getFieldsForUniqueWhere } from '../../utils'\nimport { HasManyToHasOneReducer, HasManyToHasOneReducerExtension } from './HasManyToHasOneReducer'\nimport { GraphQLFieldConfig } from 'graphql'\n\ntype Result = [\n\tstring,\n\tGraphQLFieldConfig<any, any> & {\n\t\textensions: HasManyToHasOneReducerExtension\n\t}\n]\n\nexport class HasManyToHasOneRelationReducerFieldVisitor implements\n\tModel.ColumnVisitor<Result[]>,\n\tModel.RelationByTypeVisitor<Result[]> {\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t) {}\n\n\tpublic visitColumn() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasOneOwning() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasOneInverse() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasOne() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasManyInverse() {\n\t\treturn []\n\t}\n\n\tpublic visitManyHasManyOwning() {\n\t\treturn []\n\t}\n\n\tpublic visitOneHasMany({ entity, targetEntity, targetRelation, relation }: Model.OneHasManyContext) {\n\t\tif (!targetRelation) {\n\t\t\treturn []\n\t\t}\n\t\tconst uniqueConstraints = getFieldsForUniqueWhere(this.schema, targetEntity)\n\n\t\tconst uniqueKeys: (readonly string[])[] = uniqueConstraints\n\t\t\t.map(it => it.filter(it => it !== targetRelation.name))\n\t\t\t.filter(it => it.length > 0)\n\t\t\t.filter(uniqueKey => uniqueKey\n\t\t\t\t.every(it =>\n\t\t\t\t\tacceptFieldVisitor(this.schema, targetEntity.name, it, new FieldAccessVisitor(Acl.Operation.read, this.authorizator)),\n\t\t\t\t))\n\n\t\tconst graphQlName = relation.name + GqlTypeName`By`\n\t\tconst uniqueWhere: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entity.name}${relation.name}UniqueWhere`,\n\t\t\tfields: () => {\n\t\t\t\treturn this.whereTypeProvider.getUniqueWhereFields(targetEntity, uniqueKeys)\n\t\t\t},\n\t\t})\n\n\t\tconst entityType = this.entityTypeProvider.getEntity(targetEntity.name)\n\t\tconst universalUnique: Result | null = graphQlName in entity.fields ? null : [\n\t\t\tgraphQlName,\n\t\t\t{\n\t\t\t\ttype: entityType,\n\t\t\t\textensions: {\n\t\t\t\t\trelationName: relation.name,\n\t\t\t\t\textensionKey: HasManyToHasOneReducer.extensionName,\n\t\t\t\t},\n\t\t\t\targs: {\n\t\t\t\t\tby: { type: new GraphQLNonNull(uniqueWhere) },\n\t\t\t\t\tfilter: { type: this.whereTypeProvider.getEntityWhereType(targetEntity.name) },\n\t\t\t\t},\n\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t},\n\t\t]\n\n\t\tconst composedUnique = uniqueConstraints\n\t\t\t.filter(fields => fields.length === 2) //todo support all uniques\n\t\t\t.filter(fields => fields.includes(targetRelation.name))\n\t\t\t.map(fields => fields.filter(it => it !== targetRelation.name))\n\t\t\t.map(fields => fields[0])\n\t\tconst singleUnique = uniqueConstraints\n\t\t\t.filter(fields => fields.length === 1 && fields[0] !== targetEntity.primary)\n\t\t\t.map(fields => fields[0])\n\t\t\t.filter(it => it !== targetRelation.name)\n\n\n\t\tconst existing = new Set<string>()\n\t\treturn [...composedUnique, ...singleUnique]\n\t\t\t.filter(field =>\n\t\t\t\tacceptFieldVisitor(\n\t\t\t\t\tthis.schema,\n\t\t\t\t\ttargetEntity.name,\n\t\t\t\t\tfield,\n\t\t\t\t\tnew FieldAccessVisitor(Acl.Operation.read, this.authorizator),\n\t\t\t\t),\n\t\t\t)\n\t\t\t.map<Result | null>(fieldName => {\n\t\t\t\tif (existing.has(fieldName)) {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\texisting.add(fieldName)\n\t\t\t\tconst graphQlName = relation.name + GqlTypeName`By${fieldName}`\n\t\t\t\tconst uniqueWhere: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\t\t\t//todo this can be simplified to ${targetEntity.name}By${fieldName}, but singleton must be used\n\t\t\t\t\tname: GqlTypeName`${entity.name}${relation.name}By${fieldName}UniqueWhere`,\n\t\t\t\t\tfields: () => {\n\t\t\t\t\t\treturn this.whereTypeProvider.getUniqueWhereFields(targetEntity, [[fieldName]])\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\treturn [\n\t\t\t\t\tgraphQlName,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: entityType,\n\t\t\t\t\t\textensions: {\n\t\t\t\t\t\t\trelationName: relation.name,\n\t\t\t\t\t\t\textensionKey: HasManyToHasOneReducer.extensionName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\targs: {\n\t\t\t\t\t\t\tby: { type: new GraphQLNonNull(uniqueWhere) },\n\t\t\t\t\t\t\tfilter: { type: this.whereTypeProvider.getEntityWhereType(targetEntity.name) },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t\t\t},\n\t\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C,YAAAA,eAAsC,IAAI,uBAAuB;AAAA;AAAA,QAEtE,MAAM,cAAc,OAAO,IAAI,GAAG,SAAS,IAAI,KAAK,SAAS;AAAA,QAC7D,QAAQ,MAAM;AACN,iBAAA,KAAK,kBAAkB,qBAAqB,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC;AAAA,QAAA;AAAA,MAC/E,CACA;AAEM,aAAA;AAAA,QACND;AAAAA,QACA;AAAA,UACC,MAAM;AAAA,UACN,YAAY;AAAA,YACX,cAAc,SAAS;AAAA,YACvB,cAAc,uBAAuB;AAAA,UACtC;AAAA,UACA,MAAM;AAAA,YACL,IAAI,EAAE,MAAM,IAAI,eAAeC,YAAW,EAAE;AAAA,YAC5C,QAAQ,EAAE,MAAM,KAAK,kBAAkB,mBAAmB,aAAa,IAAI,EAAE;AAAA,UAC9E;AAAA,UACA,SAAS;AAAA,QAAA;AAAA,MAEX;AAAA,IAAA,CACA,EACA,OAAO,CAAC,eAAe,CAAC,EACxB,OAAO,CAAC,OAAqB,OAAO,IAAI;AAAA,EAAA;AAE5C;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ColumnValueResolver.cjs","sources":["../../../../../packages/engine-content-api/src/input-validation/ColumnValueResolver.ts"],"sourcesContent":["import { NoDataError, Providers, resolveColumnValue } from '@contember/schema-utils'\nimport { Model, Value } from '@contember/schema'\n\nexport class ColumnValueResolver {\n\tconstructor(private readonly providers: Providers) {}\n\n\tgetDefaultValidationValue(context: Model.ColumnContext & { input: Value.FieldValue | undefined }): Value.AtomicValue | undefined {\n\t\tif (context.column.name === context.entity.primary) {\n\t\t\treturn '00000000-0000-0000-0000-000000000000'\n\t\t}\n\t\ttry {\n\t\t\treturn resolveColumnValue(context, this.providers)\n\t\t} catch (e) {\n\t\t\tif (e instanceof NoDataError) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\t}\n}\n"],"names":["resolveColumnValue","NoDataError"],"mappings":";;;AAGO,MAAM,oBAAoB;AAAA,EAChC,YAA6B,WAAsB;AAAtB,SAAA,YAAA;AAAA,EAAA;AAAA,EAE7B,0BAA0B,SAAuG;AAChI,QAAI,QAAQ,OAAO,SAAS,QAAQ,OAAO,SAAS;AAC5C,aAAA;AAAA,IAAA;AAEJ,QAAA;AACI,aAAAA,+BAAmB,SAAS,KAAK,SAAS;AAAA,aACzC,GAAG;AACX,UAAI,aAAaC,YAAAA,aAAa;AACtB,eAAA;AAAA,MAAA;AAEF,YAAA;AAAA,IAAA;AAAA,EACP;AAEF;;"}
1
+ {"version":3,"file":"ColumnValueResolver.cjs","sources":["../../../../../packages/engine-content-api/src/input-validation/ColumnValueResolver.ts"],"sourcesContent":["import { NoDataError, Providers, resolveColumnValue } from '@contember/schema-utils'\nimport { Model, Value } from '@contember/schema'\n\nexport class ColumnValueResolver {\n\tconstructor(private readonly providers: Providers) {}\n\n\tgetDefaultValidationValue(context: Model.ColumnContext & { input: Value.FieldValue | undefined }): Value.FieldValue | undefined {\n\t\tif (context.column.name === context.entity.primary) {\n\t\t\treturn '00000000-0000-0000-0000-000000000000'\n\t\t}\n\t\ttry {\n\t\t\treturn resolveColumnValue(context, this.providers)\n\t\t} catch (e) {\n\t\t\tif (e instanceof NoDataError) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\t}\n}\n"],"names":["resolveColumnValue","NoDataError"],"mappings":";;;AAGO,MAAM,oBAAoB;AAAA,EAChC,YAA6B,WAAsB;AAAtB,SAAA,YAAA;AAAA,EAAA;AAAA,EAE7B,0BAA0B,SAAsG;AAC/H,QAAI,QAAQ,OAAO,SAAS,QAAQ,OAAO,SAAS;AAC5C,aAAA;AAAA,IAAA;AAEJ,QAAA;AACI,aAAAA,+BAAmB,SAAS,KAAK,SAAS;AAAA,aACzC,GAAG;AACX,UAAI,aAAaC,YAAAA,aAAa;AACtB,eAAA;AAAA,MAAA;AAEF,YAAA;AAAA,IAAA;AAAA,EACP;AAEF;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ColumnValueResolver.js","sources":["../../../../../packages/engine-content-api/src/input-validation/ColumnValueResolver.ts"],"sourcesContent":["import { NoDataError, Providers, resolveColumnValue } from '@contember/schema-utils'\nimport { Model, Value } from '@contember/schema'\n\nexport class ColumnValueResolver {\n\tconstructor(private readonly providers: Providers) {}\n\n\tgetDefaultValidationValue(context: Model.ColumnContext & { input: Value.FieldValue | undefined }): Value.AtomicValue | undefined {\n\t\tif (context.column.name === context.entity.primary) {\n\t\t\treturn '00000000-0000-0000-0000-000000000000'\n\t\t}\n\t\ttry {\n\t\t\treturn resolveColumnValue(context, this.providers)\n\t\t} catch (e) {\n\t\t\tif (e instanceof NoDataError) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";AAGO,MAAM,oBAAoB;AAAA,EAChC,YAA6B,WAAsB;AAAtB,SAAA,YAAA;AAAA,EAAA;AAAA,EAE7B,0BAA0B,SAAuG;AAChI,QAAI,QAAQ,OAAO,SAAS,QAAQ,OAAO,SAAS;AAC5C,aAAA;AAAA,IAAA;AAEJ,QAAA;AACI,aAAA,mBAAmB,SAAS,KAAK,SAAS;AAAA,aACzC,GAAG;AACX,UAAI,aAAa,aAAa;AACtB,eAAA;AAAA,MAAA;AAEF,YAAA;AAAA,IAAA;AAAA,EACP;AAEF;"}
1
+ {"version":3,"file":"ColumnValueResolver.js","sources":["../../../../../packages/engine-content-api/src/input-validation/ColumnValueResolver.ts"],"sourcesContent":["import { NoDataError, Providers, resolveColumnValue } from '@contember/schema-utils'\nimport { Model, Value } from '@contember/schema'\n\nexport class ColumnValueResolver {\n\tconstructor(private readonly providers: Providers) {}\n\n\tgetDefaultValidationValue(context: Model.ColumnContext & { input: Value.FieldValue | undefined }): Value.FieldValue | undefined {\n\t\tif (context.column.name === context.entity.primary) {\n\t\t\treturn '00000000-0000-0000-0000-000000000000'\n\t\t}\n\t\ttry {\n\t\t\treturn resolveColumnValue(context, this.providers)\n\t\t} catch (e) {\n\t\t\tif (e instanceof NoDataError) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";AAGO,MAAM,oBAAoB;AAAA,EAChC,YAA6B,WAAsB;AAAtB,SAAA,YAAA;AAAA,EAAA;AAAA,EAE7B,0BAA0B,SAAsG;AAC/H,QAAI,QAAQ,OAAO,SAAS,QAAQ,OAAO,SAAS;AAC5C,aAAA;AAAA,IAAA;AAEJ,QAAA;AACI,aAAA,mBAAmB,SAAS,KAAK,SAAS;AAAA,aACzC,GAAG;AACX,UAAI,aAAa,aAAa;AACtB,eAAA;AAAA,MAAA;AAEF,YAAA;AAAA,IAAA;AAAA,EACP;AAEF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"CreateInputPreValidationProcessor.cjs","sources":["../../../../../../packages/engine-content-api/src/input-validation/preValidation/CreateInputPreValidationProcessor.ts"],"sourcesContent":["import { CreateInputProcessor } from '../../inputProcessing'\nimport { Input, Model } from '@contember/schema'\nimport { appendRelationToPath, ValidationPath } from '../ValidationPath'\nimport { Mapper } from '../../mapper'\nimport { InputPreValidator } from './InputPreValidator'\n\ntype Result = any\nconst NoResult = () => Promise.resolve([])\n\nexport class CreateInputPreValidationProcessor implements CreateInputProcessor<Result> {\n\tconstructor(\n\t\tprivate readonly inputValidator: InputPreValidator,\n\t\tprivate readonly path: ValidationPath,\n\t\tprivate readonly mapper: Mapper,\n\t) {}\n\n\tmanyHasManyInverse: CreateInputProcessor.HasManyRelationProcessor<Model.ManyHasManyInverseContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\n\tmanyHasManyOwning: CreateInputProcessor.HasManyRelationProcessor<Model.ManyHasManyOwningContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\n\tmanyHasOne: CreateInputProcessor.HasOneRelationProcessor<Model.ManyHasOneContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\n\toneHasMany: CreateInputProcessor.HasManyRelationProcessor<Model.OneHasManyContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\toneHasOneInverse: CreateInputProcessor.HasOneRelationProcessor<Model.OneHasOneInverseContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\toneHasOneOwning: CreateInputProcessor.HasOneRelationProcessor<Model.OneHasOneOwningContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\n\tasync validateCreate(context: {\n\t\ttargetEntity: Model.Entity\n\t\trelation: Model.AnyRelation\n\t\tinput: Input.CreateDataInput\n\t\ttargetRelation: Model.AnyRelation | null\n\t\tindex?: number\n\t\talias?: string\n\t}) {\n\t\tconst newPath = appendRelationToPath(this.path, context.relation.name, context)\n\t\treturn this.inputValidator.validateCreate({\n\t\t\tmapper: this.mapper,\n\t\t\tentity: context.targetEntity,\n\t\t\tdata: context.input,\n\t\t\tpath: newPath,\n\t\t\toverRelation: context.targetRelation,\n\t\t})\n\t}\n\n\tasync column(context: Model.ColumnContext): Promise<Result> {\n\t\treturn []\n\t}\n}\n"],"names":["appendRelationToPath"],"mappings":";;;;;;AAOA,MAAM,WAAW,MAAM,QAAQ,QAAQ,EAAE;AAElC,MAAM,kCAA0E;AAAA,EACtF,YACkB,gBACA,MACA,QAChB;AAHgB,SAAA,iBAAA;AACA,SAAA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O,QAAQ,MAAM,OAAQ,CAAA;AAAA,IAAA,CAC5F;AAAA,EAAA;AAAA,EAEA,MAAM,eAAe,SAOlB;AACF,UAAM,UAAUA,eAAqB,qBAAA,KAAK,MAAM,QAAQ,SAAS,MAAM,OAAO;AACvE,WAAA,KAAK,eAAe,eAAe;AAAA,MACzC,QAAQ,KAAK;AAAA,MACb,QAAQ,QAAQ;AAAA,MAChB,MAAM,QAAQ;AAAA,MACd,MAAM;AAAA,MACN,cAAc,QAAQ;AAAA,IAAA,CACtB;AAAA,EAAA;AAAA,EAGF,MAAM,OAAO,SAA+C;AAC3D,WAAO,CAAC;AAAA,EAAA;AAEV;;"}
1
+ {"version":3,"file":"CreateInputPreValidationProcessor.cjs","sources":["../../../../../../packages/engine-content-api/src/input-validation/preValidation/CreateInputPreValidationProcessor.ts"],"sourcesContent":["import { CreateInputProcessor } from '../../inputProcessing'\nimport { Input, Model } from '@contember/schema'\nimport { appendRelationToPath, ValidationPath } from '../ValidationPath'\nimport { Mapper, MapperInput } from '../../mapper'\nimport { InputPreValidator } from './InputPreValidator'\n\ntype Result = any\nconst NoResult = () => Promise.resolve([])\n\nexport class CreateInputPreValidationProcessor implements CreateInputProcessor<Result> {\n\tconstructor(\n\t\tprivate readonly inputValidator: InputPreValidator,\n\t\tprivate readonly path: ValidationPath,\n\t\tprivate readonly mapper: Mapper,\n\t) {}\n\n\tmanyHasManyInverse: CreateInputProcessor.HasManyRelationProcessor<Model.ManyHasManyInverseContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\n\tmanyHasManyOwning: CreateInputProcessor.HasManyRelationProcessor<Model.ManyHasManyOwningContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\n\tmanyHasOne: CreateInputProcessor.HasOneRelationProcessor<Model.ManyHasOneContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\n\toneHasMany: CreateInputProcessor.HasManyRelationProcessor<Model.OneHasManyContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\toneHasOneInverse: CreateInputProcessor.HasOneRelationProcessor<Model.OneHasOneInverseContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\toneHasOneOwning: CreateInputProcessor.HasOneRelationProcessor<Model.OneHasOneOwningContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\n\tasync validateCreate(context: {\n\t\ttargetEntity: Model.Entity\n\t\trelation: Model.AnyRelation\n\t\tinput: MapperInput.CreateDataInput\n\t\ttargetRelation: Model.AnyRelation | null\n\t\tindex?: number\n\t\talias?: string\n\t}) {\n\t\tconst newPath = appendRelationToPath(this.path, context.relation.name, context)\n\t\treturn this.inputValidator.validateCreate({\n\t\t\tmapper: this.mapper,\n\t\t\tentity: context.targetEntity,\n\t\t\tdata: context.input,\n\t\t\tpath: newPath,\n\t\t\toverRelation: context.targetRelation,\n\t\t})\n\t}\n\n\tasync column(context: Model.ColumnContext): Promise<Result> {\n\t\treturn []\n\t}\n}\n"],"names":["appendRelationToPath"],"mappings":";;;;;;AAOA,MAAM,WAAW,MAAM,QAAQ,QAAQ,EAAE;AAElC,MAAM,kCAA0E;AAAA,EACtF,YACkB,gBACA,MACA,QAChB;AAHgB,SAAA,iBAAA;AACA,SAAA,OAAA;AACA,SAAA,SAAA;AAG2F,kBAAA,MAAA,sBAAA;AAAA,MAC5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AA,EAEA,MAAM,eAAe,SAOlB;AACF,UAAM,UAAUA,eAAqB,qBAAA,KAAK,MAAM,QAAQ,SAAS,MAAM,OAAO;AACvE,WAAA,KAAK,eAAe,eAAe;AAAA,MACzC,QAAQ,KAAK;AAAA,MACb,QAAQ,QAAQ;AAAA,MAChB,MAAM,QAAQ;AAAA,MACd,MAAM;AAAA,MACN,cAAc,QAAQ;AAAA,IAAA,CACtB;AAAA,EAAA;AAAA,EAGF,MAAM,OAAO,SAA+C;AAC3D,WAAO,CAAC;AAAA,EAAA;AAEV;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"CreateInputPreValidationProcessor.js","sources":["../../../../../../packages/engine-content-api/src/input-validation/preValidation/CreateInputPreValidationProcessor.ts"],"sourcesContent":["import { CreateInputProcessor } from '../../inputProcessing'\nimport { Input, Model } from '@contember/schema'\nimport { appendRelationToPath, ValidationPath } from '../ValidationPath'\nimport { Mapper } from '../../mapper'\nimport { InputPreValidator } from './InputPreValidator'\n\ntype Result = any\nconst NoResult = () => Promise.resolve([])\n\nexport class CreateInputPreValidationProcessor implements CreateInputProcessor<Result> {\n\tconstructor(\n\t\tprivate readonly inputValidator: InputPreValidator,\n\t\tprivate readonly path: ValidationPath,\n\t\tprivate readonly mapper: Mapper,\n\t) {}\n\n\tmanyHasManyInverse: CreateInputProcessor.HasManyRelationProcessor<Model.ManyHasManyInverseContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\n\tmanyHasManyOwning: CreateInputProcessor.HasManyRelationProcessor<Model.ManyHasManyOwningContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\n\tmanyHasOne: CreateInputProcessor.HasOneRelationProcessor<Model.ManyHasOneContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\n\toneHasMany: CreateInputProcessor.HasManyRelationProcessor<Model.OneHasManyContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\toneHasOneInverse: CreateInputProcessor.HasOneRelationProcessor<Model.OneHasOneInverseContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\toneHasOneOwning: CreateInputProcessor.HasOneRelationProcessor<Model.OneHasOneOwningContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\n\tasync validateCreate(context: {\n\t\ttargetEntity: Model.Entity\n\t\trelation: Model.AnyRelation\n\t\tinput: Input.CreateDataInput\n\t\ttargetRelation: Model.AnyRelation | null\n\t\tindex?: number\n\t\talias?: string\n\t}) {\n\t\tconst newPath = appendRelationToPath(this.path, context.relation.name, context)\n\t\treturn this.inputValidator.validateCreate({\n\t\t\tmapper: this.mapper,\n\t\t\tentity: context.targetEntity,\n\t\t\tdata: context.input,\n\t\t\tpath: newPath,\n\t\t\toverRelation: context.targetRelation,\n\t\t})\n\t}\n\n\tasync column(context: Model.ColumnContext): Promise<Result> {\n\t\treturn []\n\t}\n}\n"],"names":[],"mappings":";;;;AAOA,MAAM,WAAW,MAAM,QAAQ,QAAQ,EAAE;AAElC,MAAM,kCAA0E;AAAA,EACtF,YACkB,gBACA,MACA,QAChB;AAHgB,SAAA,iBAAA;AACA,SAAA,OAAA;AACA,SAAA,SAAA;AAG2F,kBAAA,MAAA,sBAAA;AAAA,MAC5G,SAAS;AAAA,MACT,QAAQ,CAAA,YAAW,KAAK,eAAe,OAAO;AAAA,MAC9C,iBAAi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AS,MAAM,OAAO;AACvE,WAAA,KAAK,eAAe,eAAe;AAAA,MACzC,QAAQ,KAAK;AAAA,MACb,QAAQ,QAAQ;AAAA,MAChB,MAAM,QAAQ;AAAA,MACd,MAAM;AAAA,MACN,cAAc,QAAQ;AAAA,IAAA,CACtB;AAAA,EAAA;AAAA,EAGF,MAAM,OAAO,SAA+C;AAC3D,WAAO,CAAC;AAAA,EAAA;AAEV;"}
1
+ {"version":3,"file":"CreateInputPreValidationProcessor.js","sources":["../../../../../../packages/engine-content-api/src/input-validation/preValidation/CreateInputPreValidationProcessor.ts"],"sourcesContent":["import { CreateInputProcessor } from '../../inputProcessing'\nimport { Input, Model } from '@contember/schema'\nimport { appendRelationToPath, ValidationPath } from '../ValidationPath'\nimport { Mapper, MapperInput } from '../../mapper'\nimport { InputPreValidator } from './InputPreValidator'\n\ntype Result = any\nconst NoResult = () => Promise.resolve([])\n\nexport class CreateInputPreValidationProcessor implements CreateInputProcessor<Result> {\n\tconstructor(\n\t\tprivate readonly inputValidator: InputPreValidator,\n\t\tprivate readonly path: ValidationPath,\n\t\tprivate readonly mapper: Mapper,\n\t) {}\n\n\tmanyHasManyInverse: CreateInputProcessor.HasManyRelationProcessor<Model.ManyHasManyInverseContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\n\tmanyHasManyOwning: CreateInputProcessor.HasManyRelationProcessor<Model.ManyHasManyOwningContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\n\tmanyHasOne: CreateInputProcessor.HasOneRelationProcessor<Model.ManyHasOneContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\n\toneHasMany: CreateInputProcessor.HasManyRelationProcessor<Model.OneHasManyContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\toneHasOneInverse: CreateInputProcessor.HasOneRelationProcessor<Model.OneHasOneInverseContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\toneHasOneOwning: CreateInputProcessor.HasOneRelationProcessor<Model.OneHasOneOwningContext, Result> = {\n\t\tconnect: NoResult,\n\t\tcreate: context => this.validateCreate(context),\n\t\tconnectOrCreate: context => this.validateCreate({ ...context, input: context.input.create }),\n\t}\n\n\tasync validateCreate(context: {\n\t\ttargetEntity: Model.Entity\n\t\trelation: Model.AnyRelation\n\t\tinput: MapperInput.CreateDataInput\n\t\ttargetRelation: Model.AnyRelation | null\n\t\tindex?: number\n\t\talias?: string\n\t}) {\n\t\tconst newPath = appendRelationToPath(this.path, context.relation.name, context)\n\t\treturn this.inputValidator.validateCreate({\n\t\t\tmapper: this.mapper,\n\t\t\tentity: context.targetEntity,\n\t\t\tdata: context.input,\n\t\t\tpath: newPath,\n\t\t\toverRelation: context.targetRelation,\n\t\t})\n\t}\n\n\tasync column(context: Model.ColumnContext): Promise<Result> {\n\t\treturn []\n\t}\n}\n"],"names":[],"mappings":";;;;AAOA,MAAM,WAAW,MAAM,QAAQ,QAAQ,EAAE;AAElC,MAAM,kCAA0E;AAAA,EACtF,YACkB,gBACA,MACA,QAChB;AAHgB,SAAA,iBAAA;AACA,SAAA,OAAA;AACA,SAAA,SAAA;AAG2F,kBAAA,MAAA,sBAAA;AAAA,MAC5G,SAAS;AAAA,MACT,QAAQ,CAAA,YAAW,KAAK,eAAe,OAAO;AAAA,MAC9C,iBAAiB,CAAW,YAAA,KAAK,eAAe,EAAE,GAAG,SAAS,OAAO,QAAQ,MAAM,OAAQ,CAAA;AAAA,IAA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,QAAQ;AAAA,MAChB,MAAM,QAAQ;AAAA,MACd,MAAM;AAAA,MACN,cAAc,QAAQ;AAAA,IAAA,CACtB;AAAA,EAAA;AAAA,EAGF,MAAM,OAAO,SAA+C;AAC3D,WAAO,CAAC;AAAA,EAAA;AAEV;"}
@@ -1 +1 @@
1
- {"version":3,"file":"InputPreValidator.cjs","sources":["../../../../../../packages/engine-content-api/src/input-validation/preValidation/InputPreValidator.ts"],"sourcesContent":["import { acceptEveryFieldVisitor } from '@contember/schema-utils'\nimport { isIt, tuple } from '../../utils'\nimport { Input, Model, Validation, Value } from '@contember/schema'\nimport { InputValidation } from '@contember/schema-definition'\nimport { CreateInputVisitor, UpdateInputVisitor } from '../../inputProcessing'\nimport { CreateInputPreValidationProcessor } from './CreateInputPreValidationProcessor'\nimport { ValidationContext } from '../ValidationContext'\nimport { evaluateValidation } from '../ValidationEvaluation'\nimport { ValidationPath } from '../ValidationPath'\nimport { EntityRulesResolver } from '../EntityRulesResolver'\nimport { FieldValidationResult, ValidationResult } from '../InputValidator'\nimport { UpdateInputPreValidationProcessor } from './UpdateInputPreValidationProcessor'\nimport { ColumnValueResolver } from '../ColumnValueResolver'\nimport { Mapper } from '../../mapper'\nimport { Dependencies, DependencyCollector } from '../dependencies'\nimport { DependencyMerger } from '../dependencies'\nimport { NotSupportedError } from '../exceptions'\nimport { ValidationDataSelector } from '../ValidationDataSelector'\n\nexport interface CreateValidationArgs {\n\tmapper: Mapper\n\tentity: Model.Entity\n\tdata: Input.CreateDataInput\n\tpath: ValidationPath\n\toverRelation: Model.AnyRelation | null\n}\n\nexport interface UpdateValidationArgs {\n\tmapper: Mapper\n\tentity: Model.Entity\n\twhere: Input.UniqueWhere\n\tdata: Input.UpdateDataInput\n\tpath: ValidationPath\n}\n\nexport class InputPreValidator {\n\tconstructor(\n\t\tprivate readonly model: Model.Schema,\n\t\tprivate readonly entityRulesResolver: EntityRulesResolver,\n\t\tprivate readonly columnValueResolver: ColumnValueResolver,\n\t\tprivate readonly dataSelector: ValidationDataSelector,\n\t) {}\n\n\tasync validateCreate({ entity, data, path, mapper, overRelation }: CreateValidationArgs): Promise<ValidationResult> {\n\t\tconst rules = this.entityRulesResolver.getSimpleRules(entity.name)\n\n\t\tconst dataWithRelation = overRelation\n\t\t\t? {\n\t\t\t\t...data,\n\t\t\t\t[overRelation.name]: { create: {} },\n\t\t\t }\n\t\t\t: data\n\t\tconst context = this.createContextForCreate(entity, dataWithRelation)\n\n\t\tconst fieldsResult = this.validateFields(rules, context, path)\n\n\t\tconst processor = new CreateInputPreValidationProcessor(this, path, mapper)\n\t\tconst visitor = new CreateInputVisitor(processor, this.model, data)\n\t\tconst relationResult = await this.validateRelations(entity, visitor)\n\n\t\treturn [...fieldsResult, ...relationResult]\n\t}\n\n\tasync validateUpdate({ entity, data, path, mapper, where }: UpdateValidationArgs): Promise<ValidationResult> {\n\t\tconst simpleRules = this.entityRulesResolver.getSimpleRules(entity.name)\n\t\tconst rules = this.getApplicableRules(Object.keys(data), simpleRules)\n\t\tconst dependencies = this.buildDependencies(rules)\n\n\t\tconst context = await this.createContextForUpdate(mapper, entity, where, data, dependencies)\n\t\tconst fieldsResult: ValidationResult = this.validateFields(rules, context, path)\n\n\t\tconst processor = new UpdateInputPreValidationProcessor(this, path, mapper)\n\t\tconst visitor = new UpdateInputVisitor(processor, this.model, data)\n\t\tconst relationResult = await this.validateRelations(entity, visitor)\n\n\t\treturn [...fieldsResult, ...relationResult]\n\t}\n\n\tprivate createContextForCreate(entity: Model.Entity, data: Input.CreateDataInput): ValidationContext.NodeContext {\n\t\tconst nodeData = acceptEveryFieldVisitor(this.model, entity, {\n\t\t\tvisitColumn: ({ entity, column }) => {\n\t\t\t\tconst value = data[column.name] as Input.ColumnValue | undefined\n\t\t\t\tconst validationValue = this.columnValueResolver.getDefaultValidationValue({ entity, column, input: value })\n\t\t\t\treturn validationValue === undefined ? null : validationValue\n\t\t\t},\n\t\t\tvisitHasOne: ({ relation }) => {\n\t\t\t\tconst value = data[relation.name] as Input.CreateOneRelationInput | undefined\n\t\t\t\treturn value ? true : null\n\t\t\t},\n\t\t\t// more complex validation on relations are not possible in pre-validation phase\n\t\t\tvisitHasMany: () => null,\n\t\t})\n\n\t\treturn ValidationContext.createRootContext(nodeData)\n\t}\n\tprivate async createContextForUpdate(\n\t\tmapper: Mapper,\n\t\tentity: Model.Entity,\n\t\twhere: Input.UniqueWhere,\n\t\tdata: Input.UpdateDataInput,\n\t\tdependencies: Dependencies,\n\t): Promise<ValidationContext.NodeContext> {\n\t\tconst inputNodeData = acceptEveryFieldVisitor(this.model, entity, {\n\t\t\tvisitColumn: ({ column }) => {\n\t\t\t\treturn data[column.name] as Input.ColumnValue | undefined\n\t\t\t},\n\t\t\tvisitHasOne: ({ relation }) => {\n\t\t\t\tconst value = data[relation.name] as Input.CreateOneRelationInput | Input.UpdateOneRelationInput | undefined | null\n\t\t\t\tif (value === undefined || value === null) {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\tif ('disconnect' in value) {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\tif ('delete' in value) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tisIt<Model.JoiningColumnRelation>(relation, 'joiningColumn') &&\n\t\t\t\t\t\trelation.joiningColumn.onDelete === Model.OnDelete.cascade\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn true\n\t\t\t\t\t}\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\treturn true\n\t\t\t},\n\t\t\t// more complex validation on relations are not possible in pre-validation phase\n\t\t\tvisitHasMany: () => null,\n\t\t})\n\n\t\tconst missingDependencies = Object.keys(dependencies).filter(it => inputNodeData[it] === undefined)\n\t\tmissingDependencies.forEach(it => {\n\t\t\tif (Object.keys(dependencies[it]).length !== 0) {\n\t\t\t\tthrow new NotSupportedError()\n\t\t\t}\n\t\t})\n\n\t\tconst dbData = await this.dataSelector.select(\n\t\t\tmapper,\n\t\t\tentity,\n\t\t\twhere,\n\t\t\tmissingDependencies.reduce((acc, field) => ({ ...acc, [field]: {} }), {}),\n\t\t)\n\n\t\treturn ValidationContext.createRootContext({ ...(inputNodeData as Value.Object), ...(dbData || {}) })\n\t}\n\n\tprivate validateFields(rules: Validation.EntityRules, context: ValidationContext.NodeContext, path: ValidationPath) {\n\t\treturn Object.entries(rules)\n\t\t\t.map(([field, fieldRules]) =>\n\t\t\t\ttuple(\n\t\t\t\t\tfield,\n\t\t\t\t\tfieldRules.find(it => evaluateValidation(context, InputValidation.rules.on(field, it.validator)) === false),\n\t\t\t\t),\n\t\t\t)\n\t\t\t.filter((arg): arg is [string, Validation.ValidationRule] => !!arg[1])\n\t\t\t.map(([field, { message }]) => ({ path: [...path, { field }], message }))\n\t}\n\n\tprivate async validateRelations(\n\t\tentity: Model.Entity,\n\t\tvisitor: Model.FieldVisitor<Promise<ValidationResult[]>>,\n\t): Promise<ValidationResult> {\n\t\tconst validateRelationsResult = acceptEveryFieldVisitor(this.model, entity, visitor)\n\n\t\treturn (await Promise.all(Object.values(validateRelationsResult)))\n\t\t\t.flatMap(it => it.flat())\n\t}\n\n\tprivate getApplicableRules(changedFields: string[], entityRules: Validation.EntityRules): Validation.EntityRules {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(entityRules)\n\t\t\t\t.map(([field, fieldRules]) => {\n\t\t\t\t\treturn tuple(\n\t\t\t\t\t\tfield,\n\t\t\t\t\t\tchangedFields.includes(field)\n\t\t\t\t\t\t\t? fieldRules\n\t\t\t\t\t\t\t: fieldRules.filter(rule =>\n\t\t\t\t\t\t\t\tObject.keys(DependencyCollector.collect(rule.validator)).find(it => changedFields.includes(it)),\n\t\t\t\t\t\t\t ),\n\t\t\t\t\t)\n\t\t\t\t})\n\t\t\t\t.filter(([, it]) => it.length > 0),\n\t\t)\n\t}\n\n\tprivate buildDependencies(rules: Validation.EntityRules): Dependencies {\n\t\tconst baseFieldsAsDeps = Object.keys(rules).reduce((acc, field) => ({ ...acc, [field]: {} }), {})\n\n\t\treturn Object.values(rules)\n\t\t\t.flatMap(it => it)\n\t\t\t.map(it => DependencyCollector.collect(it.validator))\n\t\t\t.concat(baseFieldsAsDeps)\n\t\t\t.reduce((acc, dependecy) => DependencyMerger.merge(acc, dependecy), {})\n\t}\n}\n"],"names":["CreateInputPreValidationProcessor","CreateInputVisitor","UpdateInputPreValidationProcessor","UpdateInputVisitor","acceptEveryFieldVisitor","entity","ValidationContext","isIt","Model","NotSupportedError","tuple","evaluateValidation","InputValidation","DependencyCollector","DependencyMerger"],"mappings":";;;;;;;;;;;;;;;;AAmCO,MAAM,kBAAkB;AAAA,EAC9B,YACkB,OACA,qBACA,qBACA,cAChB;AAJgB,SAAA,QAAA;AACA,SAAA,sBAAA;AACA,SAAA,sBAAA;AACA,SAAA,eAAA;AAAA,EAAA;AAAA,EAGlB,MAAM,eAAe,EAAE,QAAQ,MAAM,MAAM,QAAQ,gBAAiE;AACnH,UAAM,QAAQ,KAAK,oBAAoB,eAAe,OAAO,IAAI;AAEjE,UAAM,mBAAmB,eACtB;AAAA,MACD,GAAG;AAAA,MACH,CAAC,aAAa,IAAI,GAAG,EAAE,QAAQ,CAAG,EAAA;AAAA,IAAA,IAEjC;AACH,UAAM,UAAU,KAAK,uBAAuB,QAAQ,gBAAgB;AAEpE,UAAM,eAAe,KAAK,eAAe,OAAO,SAAS,IAAI;AAE7D,UAAM,YAAY,IAAIA,kCAAAA,kCAAkC,MAAM,MAAM,MAAM;AAC1E,UAAM,UAAU,IAAIC,mBAAA,mBAAmB,WAAW,KAAK,OAAO,IAAI;AAClE,UAAM,iBAAiB,MAAM,KAAK,kBAAkB,QAAQ,OAAO;AAEnE,WAAO,CAAC,GAAG,cAAc,GAAG,cAAc;AAAA,EAAA;AAAA,EAG3C,MAAM,eAAe,EAAE,QAAQ,MAAM,MAAM,QAAQ,SAA0D;AAC5G,UAAM,cAAc,KAAK,oBAAoB,eAAe,OAAO,IAAI;AACvE,UAAM,QAAQ,KAAK,mBAAmB,OAAO,KA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putPreValidator.ts"],"sourcesContent":["import { acceptEveryFieldVisitor } from '@contember/schema-utils'\nimport { isIt, tuple } from '../../utils'\nimport { Input, Model, Validation, Value } from '@contember/schema'\nimport { InputValidation } from '@contember/schema-definition'\nimport { CreateInputVisitor, UpdateInputVisitor } from '../../inputProcessing'\nimport { CreateInputPreValidationProcessor } from './CreateInputPreValidationProcessor'\nimport { ValidationContext } from '../ValidationContext'\nimport { evaluateValidation } from '../ValidationEvaluation'\nimport { ValidationPath } from '../ValidationPath'\nimport { EntityRulesResolver } from '../EntityRulesResolver'\nimport { FieldValidationResult, ValidationResult } from '../InputValidator'\nimport { UpdateInputPreValidationProcessor } from './UpdateInputPreValidationProcessor'\nimport { ColumnValueResolver } from '../ColumnValueResolver'\nimport { Mapper, MapperInput } from '../../mapper'\nimport { Dependencies, DependencyCollector } from '../dependencies'\nimport { DependencyMerger } from '../dependencies'\nimport { NotSupportedError } from '../exceptions'\nimport { ValidationDataSelector } from '../ValidationDataSelector'\n\nexport interface CreateValidationArgs {\n\tmapper: Mapper\n\tentity: Model.Entity\n\tdata: MapperInput.CreateDataInput\n\tpath: ValidationPath\n\toverRelation: Model.AnyRelation | null\n}\n\nexport interface UpdateValidationArgs {\n\tmapper: Mapper\n\tentity: Model.Entity\n\twhere: Input.UniqueWhere\n\tdata: MapperInput.UpdateDataInput\n\tpath: ValidationPath\n}\n\nexport class InputPreValidator {\n\tconstructor(\n\t\tprivate readonly model: Model.Schema,\n\t\tprivate readonly entityRulesResolver: EntityRulesResolver,\n\t\tprivate readonly columnValueResolver: ColumnValueResolver,\n\t\tprivate readonly dataSelector: ValidationDataSelector,\n\t) {}\n\n\tasync validateCreate({ entity, data, path, mapper, overRelation }: CreateValidationArgs): Promise<ValidationResult> {\n\t\tconst rules = this.entityRulesResolver.getSimpleRules(entity.name)\n\n\t\tconst dataWithRelation = overRelation\n\t\t\t? {\n\t\t\t\t...data,\n\t\t\t\t[overRelation.name]: { create: {} },\n\t\t\t }\n\t\t\t: data\n\t\tconst context = this.createContextForCreate(entity, dataWithRelation)\n\n\t\tconst fieldsResult = this.validateFields(rules, context, path)\n\n\t\tconst processor = new CreateInputPreValidationProcessor(this, path, mapper)\n\t\tconst visitor = new CreateInputVisitor(processor, this.model, data)\n\t\tconst relationResult = await this.validateRelations(entity, visitor)\n\n\t\treturn [...fieldsResult, ...relationResult]\n\t}\n\n\tasync validateUpdate({ entity, data, path, mapper, where }: UpdateValidationArgs): Promise<ValidationResult> {\n\t\tconst simpleRules = this.entityRulesResolver.getSimpleRules(entity.name)\n\t\tconst rules = this.getApplicableRules(Object.keys(data), simpleRules)\n\t\tconst dependencies = this.buildDependencies(rules)\n\n\t\tconst context = await this.createContextForUpdate(mapper, entity, where, data, dependencies)\n\t\tconst fieldsResult: ValidationResult = this.validateFields(rules, context, path)\n\n\t\tconst processor = new UpdateInputPreValidationProcessor(this, path, mapper)\n\t\tconst visitor = new UpdateInputVisitor(processor, this.model, data)\n\t\tconst relationResult = await this.validateRelations(entity, visitor)\n\n\t\treturn [...fieldsResult, ...relationResult]\n\t}\n\n\tprivate createContextForCreate(entity: Model.Entity, data: MapperInput.CreateDataInput): ValidationContext.NodeContext {\n\t\tconst nodeData = acceptEveryFieldVisitor(this.model, entity, {\n\t\t\tvisitColumn: ({ entity, column }) => {\n\t\t\t\tconst value = data[column.name] as Input.ColumnValue | undefined\n\t\t\t\tconst validationValue = this.columnValueResolver.getDefaultValidationValue({ entity, column, input: value })\n\t\t\t\treturn validationValue === undefined ? null : validationValue\n\t\t\t},\n\t\t\tvisitHasOne: ({ relation }) => {\n\t\t\t\tconst value = data[relation.name] as MapperInput.CreateOneRelationInput | undefined\n\t\t\t\treturn value ? true : null\n\t\t\t},\n\t\t\t// more complex validation on relations are not possible in pre-validation phase\n\t\t\tvisitHasMany: () => null,\n\t\t})\n\n\t\treturn ValidationContext.createRootContext(nodeData)\n\t}\n\tprivate async createContextForUpdate(\n\t\tmapper: Mapper,\n\t\tentity: Model.Entity,\n\t\twhere: Input.UniqueWhere,\n\t\tdata: MapperInput.UpdateDataInput,\n\t\tdependencies: Dependencies,\n\t): Promise<ValidationContext.NodeContext> {\n\t\tconst inputNodeData = acceptEveryFieldVisitor(this.model, entity, {\n\t\t\tvisitColumn: ({ column }) => {\n\t\t\t\treturn data[column.name] as Input.ColumnValue | undefined\n\t\t\t},\n\t\t\tvisitHasOne: ({ relation }) => {\n\t\t\t\tconst value = data[relation.name] as MapperInput.CreateOneRelationInput | MapperInput.UpdateOneRelationInput | undefined | null\n\t\t\t\tif (value === undefined || value === null) {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\tif ('disconnect' in value) {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\tif ('delete' in value) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tisIt<Model.JoiningColumnRelation>(relation, 'joiningColumn') &&\n\t\t\t\t\t\trelation.joiningColumn.onDelete === Model.OnDelete.cascade\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn true\n\t\t\t\t\t}\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\treturn true\n\t\t\t},\n\t\t\t// more complex validation on relations are not possible in pre-validation phase\n\t\t\tvisitHasMany: () => null,\n\t\t})\n\n\t\tconst missingDependencies = Object.keys(dependencies).filter(it => inputNodeData[it] === undefined)\n\t\tmissingDependencies.forEach(it => {\n\t\t\tif (Object.keys(dependencies[it]).length !== 0) {\n\t\t\t\tthrow new NotSupportedError()\n\t\t\t}\n\t\t})\n\n\t\tconst dbData = await this.dataSelector.select(\n\t\t\tmapper,\n\t\t\tentity,\n\t\t\twhere,\n\t\t\tmissingDependencies.reduce((acc, field) => ({ ...acc, [field]: {} }), {}),\n\t\t)\n\n\t\treturn ValidationContext.createRootContext({ ...(inputNodeData as Value.Object), ...(dbData || {}) })\n\t}\n\n\tprivate validateFields(rules: Validation.EntityRules, context: ValidationContext.NodeContext, path: ValidationPath) {\n\t\treturn Object.entries(rules)\n\t\t\t.map(([field, fieldRules]) =>\n\t\t\t\ttuple(\n\t\t\t\t\tfield,\n\t\t\t\t\tfieldRules.find(it => evaluateValidation(context, InputValidation.rules.on(field, it.validator)) === false),\n\t\t\t\t),\n\t\t\t)\n\t\t\t.filter((arg): arg is [string, Validation.ValidationRule] => !!arg[1])\n\t\t\t.map(([field, { message }]) => ({ path: [...path, { field }], message }))\n\t}\n\n\tprivate async validateRelations(\n\t\tentity: Model.Entity,\n\t\tvisitor: Model.FieldVisitor<Promise<ValidationResult[]>>,\n\t): Promise<ValidationResult> {\n\t\tconst validateRelationsResult = acceptEveryFieldVisitor(this.model, entity, visitor)\n\n\t\treturn (await Promise.all(Object.values(validateRelationsResult)))\n\t\t\t.flatMap(it => it.flat())\n\t}\n\n\tprivate getApplicableRules(changedFields: string[], entityRules: Validation.EntityRules): Validation.EntityRules {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(entityRules)\n\t\t\t\t.map(([field, fieldRules]) => {\n\t\t\t\t\treturn tuple(\n\t\t\t\t\t\tfield,\n\t\t\t\t\t\tchangedFields.includes(field)\n\t\t\t\t\t\t\t? fieldRules\n\t\t\t\t\t\t\t: fieldRules.filter(rule =>\n\t\t\t\t\t\t\t\tObject.keys(DependencyCollector.collect(rule.validator)).find(it => changedFields.includes(it)),\n\t\t\t\t\t\t\t ),\n\t\t\t\t\t)\n\t\t\t\t})\n\t\t\t\t.filter(([, it]) => it.length > 0),\n\t\t)\n\t}\n\n\tprivate buildDependencies(rules: Validation.EntityRules): Dependencies {\n\t\tconst baseFieldsAsDeps = Object.keys(rules).reduce((acc, field) => ({ ...acc, [field]: {} }), {})\n\n\t\treturn Object.values(rules)\n\t\t\t.flatMap(it => it)\n\t\t\t.map(it => DependencyCollector.collect(it.validator))\n\t\t\t.concat(baseFieldsAsDeps)\n\t\t\t.reduce((acc, dependecy) => DependencyMerger.merge(acc, dependecy), {})\n\t}\n}\n"],"names":["CreateInputPreValidationProcessor","CreateInputVisitor","UpdateInputPreValidationProcessor","UpdateInputVisitor","acceptEveryFieldVisitor","entity","ValidationContext","isIt","Model","NotSupportedError","tuple","evaluateValidation","InputValidation","DependencyCollector","DependencyMerger"],"mappings":";;;;;;;;;;;;;;;;AAmCO,MAAM,kBAAkB;AAAA,EAC9B,YACkB,OACA,qBACA,qBACA,cAChB;AAJgB,SAAA,QAAA;AACA,SAAA,sBAAA;AACA,SAAA,sBAAA;AACA,SAAA,eAAA;AAAA,EAAA;AAAA,EAGlB,MAAM,eAAe,EAAE,QAAQ,MAAM,MAAM,QAAQ,gBAAiE;AACnH,UAAM,QAAQ,KAAK,oBAAoB,eAAe,OAAO,IAAI;AAEjE,UAAM,mBAAmB,eACtB;AAAA,MACD,GAAG;AAAA,MACH,CAAC,aAAa,IAAI,GAAG,EAAE,QAAQ,CAAG,EAAA;AAAA,IAAA,IAEjC;AACH,UAAM,UAAU,KAAK,uBAAuB,QAAQ,gBAAgB;AAEpE,UAAM,eAAe,KAAK,eAAe,OAAO,SAAS,IAAI;AAE7D,UAAM,YAAY,IAAIA,kCAAAA,kCAAkC,MAAM,MAAM,MAAM;AAC1E,UAAM,UAAU,IAAIC,mBAAA,mBAAmB,WAAW,KAAK,OAAO,IAAI;AAClE,UAAM,iBAAiB,MAAM,KAAK,kBAAkB,QAAQ,OAAO;AAEnE,WAAO,CAAC,GAAG,cAAc,GAAG,cAAc;AAAA,EAAA;AAAA,EAG3C,MAAM,eAAe,EAAE,QAAQ,MAAM,MAAM,QAAQ,SAA0D;AAC5G,UAAM,cAAc,KAAK,oBAAoB,eAAe,OAAO,IAAI;AACvE,UAAM,QAAQ,KAAK,mBAAmB,OAAO,KAAK,IAAI,GAAG,WAAW;AAC9D,UAAA,eAAe,KAAK,kBAAkB,KAAK;AAE3C,UAAA,UAAU,MAAM,KAAK,uBAAuB,QAAQ,QAAQ,OAAO,MAAM,YAAY;AAC3F,UAAM,eAAiC,KAAK,eAAe,OAAO,SAAS,IAAI;AAE/E,UAAM,YAAY,IAAIC,kCAAAA,kCAAkC,MA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,CAAC,GAC9D,QAAQ,CAAA,OAAM,GAAG,KAAA,CAAM;AAAA,EAAA;AAAA,EAGlB,mBAAmB,eAAyB,aAA6D;AAChH,WAAO,OAAO;AAAA,MACb,OAAO,QAAQ,WAAW,EACxB,IAAI,CAAC,CAAC,OAAO,UAAU,MAAM;AACtB,eAAAM,MAAA;AAAA,UACN;AAAA,UACA,cAAc,SAAS,KAAK,IACzB,aACA,WAAW;AAAA,YAAO,CACnB,SAAA,OAAO,KAAKG,oBAAA,oBAAoB,QAAQ,KAAK,SAAS,CAAC,EAAE,KAAK,CAAA,OAAM,cAAc,SAAS,EAAE,CAAC;AAAA,UAAA;AAAA,QAEjG;AAAA,MAAA,CACA,EACA,OAAO,CAAC,CAAA,EAAG,EAAE,MAAM,GAAG,SAAS,CAAC;AAAA,IACnC;AAAA,EAAA;AAAA,EAGO,kBAAkB,OAA6C;AACtE,UAAM,mBAAmB,OAAO,KAAK,KAAK,EAAE,OAAO,CAAC,KAAK,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,GAAG,CAAG,EAAA,IAAI,EAAE;AAEhG,WAAO,OAAO,OAAO,KAAK,EACxB,QAAQ,CAAA,OAAM,EAAE,EAChB,IAAI,CAAA,OAAMA,oBAAAA,oBAAoB,QAAQ,GAAG,SAAS,CAAC,EACnD,OAAO,gBAAgB,EACvB,OAAO,CAAC,KAAK,cAAcC,iBAAA,iBAAiB,MAAM,KAAK,SAAS,GAAG,CAAA,CAAE;AAAA,EAAA;AAEzE;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"InputPreValidator.js","sources":["../../../../../../packages/engine-content-api/src/input-validation/preValidation/InputPreValidator.ts"],"sourcesContent":["import { acceptEveryFieldVisitor } from '@contember/schema-utils'\nimport { isIt, tuple } from '../../utils'\nimport { Input, Model, Validation, Value } from '@contember/schema'\nimport { InputValidation } from '@contember/schema-definition'\nimport { CreateInputVisitor, UpdateInputVisitor } from '../../inputProcessing'\nimport { CreateInputPreValidationProcessor } from './CreateInputPreValidationProcessor'\nimport { ValidationContext } from '../ValidationContext'\nimport { evaluateValidation } from '../ValidationEvaluation'\nimport { ValidationPath } from '../ValidationPath'\nimport { EntityRulesResolver } from '../EntityRulesResolver'\nimport { FieldValidationResult, ValidationResult } from '../InputValidator'\nimport { UpdateInputPreValidationProcessor } from './UpdateInputPreValidationProcessor'\nimport { ColumnValueResolver } from '../ColumnValueResolver'\nimport { Mapper } from '../../mapper'\nimport { Dependencies, DependencyCollector } from '../dependencies'\nimport { DependencyMerger } from '../dependencies'\nimport { NotSupportedError } from '../exceptions'\nimport { ValidationDataSelector } from '../ValidationDataSelector'\n\nexport interface CreateValidationArgs {\n\tmapper: Mapper\n\tentity: Model.Entity\n\tdata: Input.CreateDataInput\n\tpath: ValidationPath\n\toverRelation: Model.AnyRelation | null\n}\n\nexport interface UpdateValidationArgs {\n\tmapper: Mapper\n\tentity: Model.Entity\n\twhere: Input.UniqueWhere\n\tdata: Input.UpdateDataInput\n\tpath: ValidationPath\n}\n\nexport class InputPreValidator {\n\tconstructor(\n\t\tprivate readonly model: Model.Schema,\n\t\tprivate readonly entityRulesResolver: EntityRulesResolver,\n\t\tprivate readonly columnValueResolver: ColumnValueResolver,\n\t\tprivate readonly dataSelector: ValidationDataSelector,\n\t) {}\n\n\tasync validateCreate({ entity, data, path, mapper, overRelation }: CreateValidationArgs): Promise<ValidationResult> {\n\t\tconst rules = this.entityRulesResolver.getSimpleRules(entity.name)\n\n\t\tconst dataWithRelation = overRelation\n\t\t\t? {\n\t\t\t\t...data,\n\t\t\t\t[overRelation.name]: { create: {} },\n\t\t\t }\n\t\t\t: data\n\t\tconst context = this.createContextForCreate(entity, dataWithRelation)\n\n\t\tconst fieldsResult = this.validateFields(rules, context, path)\n\n\t\tconst processor = new CreateInputPreValidationProcessor(this, path, mapper)\n\t\tconst visitor = new CreateInputVisitor(processor, this.model, data)\n\t\tconst relationResult = await this.validateRelations(entity, visitor)\n\n\t\treturn [...fieldsResult, ...relationResult]\n\t}\n\n\tasync validateUpdate({ entity, data, path, mapper, where }: UpdateValidationArgs): Promise<ValidationResult> {\n\t\tconst simpleRules = this.entityRulesResolver.getSimpleRules(entity.name)\n\t\tconst rules = this.getApplicableRules(Object.keys(data), simpleRules)\n\t\tconst dependencies = this.buildDependencies(rules)\n\n\t\tconst context = await this.createContextForUpdate(mapper, entity, where, data, dependencies)\n\t\tconst fieldsResult: ValidationResult = this.validateFields(rules, context, path)\n\n\t\tconst processor = new UpdateInputPreValidationProcessor(this, path, mapper)\n\t\tconst visitor = new UpdateInputVisitor(processor, this.model, data)\n\t\tconst relationResult = await this.validateRelations(entity, visitor)\n\n\t\treturn [...fieldsResult, ...relationResult]\n\t}\n\n\tprivate createContextForCreate(entity: Model.Entity, data: Input.CreateDataInput): ValidationContext.NodeContext {\n\t\tconst nodeData = acceptEveryFieldVisitor(this.model, entity, {\n\t\t\tvisitColumn: ({ entity, column }) => {\n\t\t\t\tconst value = data[column.name] as Input.ColumnValue | undefined\n\t\t\t\tconst validationValue = this.columnValueResolver.getDefaultValidationValue({ entity, column, input: value })\n\t\t\t\treturn validationValue === undefined ? null : validationValue\n\t\t\t},\n\t\t\tvisitHasOne: ({ relation }) => {\n\t\t\t\tconst value = data[relation.name] as Input.CreateOneRelationInput | undefined\n\t\t\t\treturn value ? true : null\n\t\t\t},\n\t\t\t// more complex validation on relations are not possible in pre-validation phase\n\t\t\tvisitHasMany: () => null,\n\t\t})\n\n\t\treturn ValidationContext.createRootContext(nodeData)\n\t}\n\tprivate async createContextForUpdate(\n\t\tmapper: Mapper,\n\t\tentity: Model.Entity,\n\t\twhere: Input.UniqueWhere,\n\t\tdata: Input.UpdateDataInput,\n\t\tdependencies: Dependencies,\n\t): Promise<ValidationContext.NodeContext> {\n\t\tconst inputNodeData = acceptEveryFieldVisitor(this.model, entity, {\n\t\t\tvisitColumn: ({ column }) => {\n\t\t\t\treturn data[column.name] as Input.ColumnValue | undefined\n\t\t\t},\n\t\t\tvisitHasOne: ({ relation }) => {\n\t\t\t\tconst value = data[relation.name] as Input.CreateOneRelationInput | Input.UpdateOneRelationInput | undefined | null\n\t\t\t\tif (value === undefined || value === null) {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\tif ('disconnect' in value) {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\tif ('delete' in value) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tisIt<Model.JoiningColumnRelation>(relation, 'joiningColumn') &&\n\t\t\t\t\t\trelation.joiningColumn.onDelete === Model.OnDelete.cascade\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn true\n\t\t\t\t\t}\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\treturn true\n\t\t\t},\n\t\t\t// more complex validation on relations are not possible in pre-validation phase\n\t\t\tvisitHasMany: () => null,\n\t\t})\n\n\t\tconst missingDependencies = Object.keys(dependencies).filter(it => inputNodeData[it] === undefined)\n\t\tmissingDependencies.forEach(it => {\n\t\t\tif (Object.keys(dependencies[it]).length !== 0) {\n\t\t\t\tthrow new NotSupportedError()\n\t\t\t}\n\t\t})\n\n\t\tconst dbData = await this.dataSelector.select(\n\t\t\tmapper,\n\t\t\tentity,\n\t\t\twhere,\n\t\t\tmissingDependencies.reduce((acc, field) => ({ ...acc, [field]: {} }), {}),\n\t\t)\n\n\t\treturn ValidationContext.createRootContext({ ...(inputNodeData as Value.Object), ...(dbData || {}) })\n\t}\n\n\tprivate validateFields(rules: Validation.EntityRules, context: ValidationContext.NodeContext, path: ValidationPath) {\n\t\treturn Object.entries(rules)\n\t\t\t.map(([field, fieldRules]) =>\n\t\t\t\ttuple(\n\t\t\t\t\tfield,\n\t\t\t\t\tfieldRules.find(it => evaluateValidation(context, InputValidation.rules.on(field, it.validator)) === false),\n\t\t\t\t),\n\t\t\t)\n\t\t\t.filter((arg): arg is [string, Validation.ValidationRule] => !!arg[1])\n\t\t\t.map(([field, { message }]) => ({ path: [...path, { field }], message }))\n\t}\n\n\tprivate async validateRelations(\n\t\tentity: Model.Entity,\n\t\tvisitor: Model.FieldVisitor<Promise<ValidationResult[]>>,\n\t): Promise<ValidationResult> {\n\t\tconst validateRelationsResult = acceptEveryFieldVisitor(this.model, entity, visitor)\n\n\t\treturn (await Promise.all(Object.values(validateRelationsResult)))\n\t\t\t.flatMap(it => it.flat())\n\t}\n\n\tprivate getApplicableRules(changedFields: string[], entityRules: Validation.EntityRules): Validation.EntityRules {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(entityRules)\n\t\t\t\t.map(([field, fieldRules]) => {\n\t\t\t\t\treturn tuple(\n\t\t\t\t\t\tfield,\n\t\t\t\t\t\tchangedFields.includes(field)\n\t\t\t\t\t\t\t? fieldRules\n\t\t\t\t\t\t\t: fieldRules.filter(rule =>\n\t\t\t\t\t\t\t\tObject.keys(DependencyCollector.collect(rule.validator)).find(it => changedFields.includes(it)),\n\t\t\t\t\t\t\t ),\n\t\t\t\t\t)\n\t\t\t\t})\n\t\t\t\t.filter(([, it]) => it.length > 0),\n\t\t)\n\t}\n\n\tprivate buildDependencies(rules: Validation.EntityRules): Dependencies {\n\t\tconst baseFieldsAsDeps = Object.keys(rules).reduce((acc, field) => ({ ...acc, [field]: {} }), {})\n\n\t\treturn Object.values(rules)\n\t\t\t.flatMap(it => it)\n\t\t\t.map(it => DependencyCollector.collect(it.validator))\n\t\t\t.concat(baseFieldsAsDeps)\n\t\t\t.reduce((acc, dependecy) => DependencyMerger.merge(acc, dependecy), {})\n\t}\n}\n"],"names":["entity"],"mappings":";;;;;;;;;;;;;;AAmCO,MAAM,kBAAkB;AAAA,EAC9B,YACkB,OACA,qBACA,qBACA,cAChB;AAJgB,SAAA,QAAA;AACA,SAAA,sBAAA;AACA,SAAA,sBAAA;AACA,SAAA,eAAA;AAAA,EAAA;AAAA,EAGlB,MAAM,eAAe,EAAE,QAAQ,MAAM,MAAM,QAAQ,gBAAiE;AACnH,UAAM,QAAQ,KAAK,oBAAoB,eAAe,OAAO,IAAI;AAEjE,UAAM,m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C;AACtE,UAAM,mBAAmB,OAAO,KAAK,KAAK,EAAE,OAAO,CAAC,KAAK,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,GAAG,CAAG,EAAA,IAAI,EAAE;AAEhG,WAAO,OAAO,OAAO,KAAK,EACxB,QAAQ,CAAA,OAAM,EAAE,EAChB,IAAI,CAAA,OAAM,oBAAoB,QAAQ,GAAG,SAAS,CAAC,EACnD,OAAO,gBAAgB,EACvB,OAAO,CAAC,KAAK,cAAc,iBAAiB,MAAM,KAAK,SAAS,GAAG,CAAA,CAAE;AAAA,EAAA;AAEzE;"}
1
+ {"version":3,"file":"InputPreValidator.js","sources":["../../../../../../packages/engine-content-api/src/input-validation/preValidation/InputPreValidator.ts"],"sourcesContent":["import { acceptEveryFieldVisitor } from '@contember/schema-utils'\nimport { isIt, tuple } from '../../utils'\nimport { Input, Model, Validation, Value } from '@contember/schema'\nimport { InputValidation } from '@contember/schema-definition'\nimport { CreateInputVisitor, UpdateInputVisitor } from '../../inputProcessing'\nimport { CreateInputPreValidationProcessor } from './CreateInputPreValidationProcessor'\nimport { ValidationContext } from '../ValidationContext'\nimport { evaluateValidation } from '../ValidationEvaluation'\nimport { ValidationPath } from '../ValidationPath'\nimport { EntityRulesResolver } from '../EntityRulesResolver'\nimport { FieldValidationResult, ValidationResult } from '../InputValidator'\nimport { UpdateInputPreValidationProcessor } from './UpdateInputPreValidationProcessor'\nimport { ColumnValueResolver } from '../ColumnValueResolver'\nimport { Mapper, MapperInput } from '../../mapper'\nimport { Dependencies, DependencyCollector } from '../dependencies'\nimport { DependencyMerger } from '../dependencies'\nimport { NotSupportedError } from '../exceptions'\nimport { ValidationDataSelector } from '../ValidationDataSelector'\n\nexport interface CreateValidationArgs {\n\tmapper: Mapper\n\tentity: Model.Entity\n\tdata: MapperInput.CreateDataInput\n\tpath: ValidationPath\n\toverRelation: Model.AnyRelation | null\n}\n\nexport interface UpdateValidationArgs {\n\tmapper: Mapper\n\tentity: Model.Entity\n\twhere: Input.UniqueWhere\n\tdata: MapperInput.UpdateDataInput\n\tpath: ValidationPath\n}\n\nexport class InputPreValidator {\n\tconstructor(\n\t\tprivate readonly model: Model.Schema,\n\t\tprivate readonly entityRulesResolver: EntityRulesResolver,\n\t\tprivate readonly columnValueResolver: ColumnValueResolver,\n\t\tprivate readonly dataSelector: ValidationDataSelector,\n\t) {}\n\n\tasync validateCreate({ entity, data, path, mapper, overRelation }: CreateValidationArgs): Promise<ValidationResult> {\n\t\tconst rules = this.entityRulesResolver.getSimpleRules(entity.name)\n\n\t\tconst dataWithRelation = overRelation\n\t\t\t? {\n\t\t\t\t...data,\n\t\t\t\t[overRelation.name]: { create: {} },\n\t\t\t }\n\t\t\t: data\n\t\tconst context = this.createContextForCreate(entity, dataWithRelation)\n\n\t\tconst fieldsResult = this.validateFields(rules, context, path)\n\n\t\tconst processor = new CreateInputPreValidationProcessor(this, path, mapper)\n\t\tconst visitor = new CreateInputVisitor(processor, this.model, data)\n\t\tconst relationResult = await this.validateRelations(entity, visitor)\n\n\t\treturn [...fieldsResult, ...relationResult]\n\t}\n\n\tasync validateUpdate({ entity, data, path, mapper, where }: UpdateValidationArgs): Promise<ValidationResult> {\n\t\tconst simpleRules = this.entityRulesResolver.getSimpleRules(entity.name)\n\t\tconst rules = this.getApplicableRules(Object.keys(data), simpleRules)\n\t\tconst dependencies = this.buildDependencies(rules)\n\n\t\tconst context = await this.createContextForUpdate(mapper, entity, where, data, dependencies)\n\t\tconst fieldsResult: ValidationResult = this.validateFields(rules, context, path)\n\n\t\tconst processor = new UpdateInputPreValidationProcessor(this, path, mapper)\n\t\tconst visitor = new UpdateInputVisitor(processor, this.model, data)\n\t\tconst relationResult = await this.validateRelations(entity, visitor)\n\n\t\treturn [...fieldsResult, ...relationResult]\n\t}\n\n\tprivate createContextForCreate(entity: Model.Entity, data: MapperInput.CreateDataInput): ValidationContext.NodeContext {\n\t\tconst nodeData = acceptEveryFieldVisitor(this.model, entity, {\n\t\t\tvisitColumn: ({ entity, column }) => {\n\t\t\t\tconst value = data[column.name] as Input.ColumnValue | undefined\n\t\t\t\tconst validationValue = this.columnValueResolver.getDefaultValidationValue({ entity, column, input: value })\n\t\t\t\treturn validationValue === undefined ? null : validationValue\n\t\t\t},\n\t\t\tvisitHasOne: ({ relation }) => {\n\t\t\t\tconst value = data[relation.name] as MapperInput.CreateOneRelationInput | undefined\n\t\t\t\treturn value ? true : null\n\t\t\t},\n\t\t\t// more complex validation on relations are not possible in pre-validation phase\n\t\t\tvisitHasMany: () => null,\n\t\t})\n\n\t\treturn ValidationContext.createRootContext(nodeData)\n\t}\n\tprivate async createContextForUpdate(\n\t\tmapper: Mapper,\n\t\tentity: Model.Entity,\n\t\twhere: Input.UniqueWhere,\n\t\tdata: MapperInput.UpdateDataInput,\n\t\tdependencies: Dependencies,\n\t): Promise<ValidationContext.NodeContext> {\n\t\tconst inputNodeData = acceptEveryFieldVisitor(this.model, entity, {\n\t\t\tvisitColumn: ({ column }) => {\n\t\t\t\treturn data[column.name] as Input.ColumnValue | undefined\n\t\t\t},\n\t\t\tvisitHasOne: ({ relation }) => {\n\t\t\t\tconst value = data[relation.name] as MapperInput.CreateOneRelationInput | MapperInput.UpdateOneRelationInput | undefined | null\n\t\t\t\tif (value === undefined || value === null) {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\tif ('disconnect' in value) {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\tif ('delete' in value) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tisIt<Model.JoiningColumnRelation>(relation, 'joiningColumn') &&\n\t\t\t\t\t\trelation.joiningColumn.onDelete === Model.OnDelete.cascade\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn true\n\t\t\t\t\t}\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\treturn true\n\t\t\t},\n\t\t\t// more complex validation on relations are not possible in pre-validation phase\n\t\t\tvisitHasMany: () => null,\n\t\t})\n\n\t\tconst missingDependencies = Object.keys(dependencies).filter(it => inputNodeData[it] === undefined)\n\t\tmissingDependencies.forEach(it => {\n\t\t\tif (Object.keys(dependencies[it]).length !== 0) {\n\t\t\t\tthrow new NotSupportedError()\n\t\t\t}\n\t\t})\n\n\t\tconst dbData = await this.dataSelector.select(\n\t\t\tmapper,\n\t\t\tentity,\n\t\t\twhere,\n\t\t\tmissingDependencies.reduce((acc, field) => ({ ...acc, [field]: {} }), {}),\n\t\t)\n\n\t\treturn ValidationContext.createRootContext({ ...(inputNodeData as Value.Object), ...(dbData || {}) })\n\t}\n\n\tprivate validateFields(rules: Validation.EntityRules, context: ValidationContext.NodeContext, path: ValidationPath) {\n\t\treturn Object.entries(rules)\n\t\t\t.map(([field, fieldRules]) =>\n\t\t\t\ttuple(\n\t\t\t\t\tfield,\n\t\t\t\t\tfieldRules.find(it => evaluateValidation(context, InputValidation.rules.on(field, it.validator)) === false),\n\t\t\t\t),\n\t\t\t)\n\t\t\t.filter((arg): arg is [string, Validation.ValidationRule] => !!arg[1])\n\t\t\t.map(([field, { message }]) => ({ path: [...path, { field }], message }))\n\t}\n\n\tprivate async validateRelations(\n\t\tentity: Model.Entity,\n\t\tvisitor: Model.FieldVisitor<Promise<ValidationResult[]>>,\n\t): Promise<ValidationResult> {\n\t\tconst validateRelationsResult = acceptEveryFieldVisitor(this.model, entity, visitor)\n\n\t\treturn (await Promise.all(Object.values(validateRelationsResult)))\n\t\t\t.flatMap(it => it.flat())\n\t}\n\n\tprivate getApplicableRules(changedFields: string[], entityRules: Validation.EntityRules): Validation.EntityRules {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(entityRules)\n\t\t\t\t.map(([field, fieldRules]) => {\n\t\t\t\t\treturn tuple(\n\t\t\t\t\t\tfield,\n\t\t\t\t\t\tchangedFields.includes(field)\n\t\t\t\t\t\t\t? fieldRules\n\t\t\t\t\t\t\t: fieldRules.filter(rule =>\n\t\t\t\t\t\t\t\tObject.keys(DependencyCollector.collect(rule.validator)).find(it => changedFields.includes(it)),\n\t\t\t\t\t\t\t ),\n\t\t\t\t\t)\n\t\t\t\t})\n\t\t\t\t.filter(([, it]) => it.length > 0),\n\t\t)\n\t}\n\n\tprivate buildDependencies(rules: Validation.EntityRules): Dependencies {\n\t\tconst baseFieldsAsDeps = Object.keys(rules).reduce((acc, field) => ({ ...acc, [field]: {} }), {})\n\n\t\treturn Object.values(rules)\n\t\t\t.flatMap(it => it)\n\t\t\t.map(it => DependencyCollector.collect(it.validator))\n\t\t\t.concat(baseFieldsAsDeps)\n\t\t\t.reduce((acc, dependecy) => DependencyMerger.merge(acc, dependecy), {})\n\t}\n}\n"],"names":["entity"],"mappings":";;;;;;;;;;;;;;AAmCO,MAAM,kBAAkB;AAAA,EAC9B,YACkB,OACA,qBACA,qBACA,cAChB;AAJgB,SAAA,QAAA;AACA,SAAA,sBAAA;AACA,SAAA,sBAAA;AACA,SAAA,eAAA;AAAA,EAAA;AAAA,EAGlB,MAAM,eAAe,EAAE,QAAQ,MAAM,MAAM,QAAQ,gBAAiE;AACnH,UAAM,QAAQ,KAAK,oBAAoB,eAAe,OAAO,IAAI;AAEjE,UAAM,mBAAmB,eACtB;AAAA,MACD,GAAG;AAAA,MACH,CAAC,aAAa,IAAI,GAAG,EAAE,QAAQ,CAAG,EAAA;AAAA,IAAA,IAEjC;AACH,UAAM,UAAU,KAAK,uBAAuB,QAAQ,gBAAgB;AAEpE,UAAM,eAAe,KAAK,eAAe,OAAO,SAAS,IAAI;AAE7D,UAAM,YAAY,IAAI,kCAAkC,MAAM,MAAM,MAAM;AAC1E,UAAM,UAAU,IAAI,mBAAmB,WAAW,KAAK,OAAO,IAAI;AAClE,UAAM,iBAAiB,MAAM,KAAK,kBAAkB,QAAQ,OAAO;AAEnE,WAAO,CAAC,GAAG,cAAc,GAAG,cAAc;AAAA,EAAA;AAAA,EAG3C,MAAM,eAAe,EAAE,QAAQ,MAAM,MAAM,QAAQ,SAA0D;AAC5G,UAAM,cAAc,KAAK,oBAAoB,eAAe,OAAO,IAAI;A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AAU;AAAA,EAAA;AAAA,EAG1E,MAAc,kBACb,QACA,SAC4B;AAC5B,UAAM,0BAA0B,wBAAwB,KAAK,OAAO,QAAQ,OAAO;AAEnF,YAAQ,MAAM,QAAQ,IAAI,OAAO,OAAO,uBAAuB,CAAC,GAC9D,QAAQ,CAAA,OAAM,GAAG,KAAA,CAAM;AAAA,EAAA;AAAA,EAGlB,mBAAmB,eAAyB,aAA6D;AAChH,WAAO,OAAO;AAAA,MACb,OAAO,QAAQ,WAAW,EACxB,IAAI,CAAC,CAAC,OAAO,UAAU,MAAM;AACtB,eAAA;AAAA,UACN;AAAA,UACA,cAAc,SAAS,KAAK,IACzB,aACA,WAAW;AAAA,YAAO,CACnB,SAAA,OAAO,KAAK,oBAAoB,QAAQ,KAAK,SAAS,CAAC,EAAE,KAAK,CAAA,OAAM,cAAc,SAAS,EAAE,CAAC;AAAA,UAAA;AAAA,QAEjG;AAAA,MAAA,CACA,EACA,OAAO,CAAC,CAAA,EAAG,EAAE,MAAM,GAAG,SAAS,CAAC;AAAA,IACnC;AAAA,EAAA;AAAA,EAGO,kBAAkB,OAA6C;AACtE,UAAM,mBAAmB,OAAO,KAAK,KAAK,EAAE,OAAO,CAAC,KAAK,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,GAAG,CAAG,EAAA,IAAI,EAAE;AAEhG,WAAO,OAAO,OAAO,KAAK,EACxB,QAAQ,CAAA,OAAM,EAAE,EAChB,IAAI,CAAA,OAAM,oBAAoB,QAAQ,GAAG,SAAS,CAAC,EACnD,OAAO,gBAAgB,EACvB,OAAO,CAAC,KAAK,cAAc,iBAAiB,MAAM,KAAK,SAAS,GAAG,CAAA,CAAE;AAAA,EAAA;AAEzE;"}
@@ -1 +1 @@
1
- {"version":3,"file":"UpdateInputPreValidationProcessor.cjs","sources":["../../../../../../packages/engine-content-api/src/input-validation/preValidation/UpdateInputPreValidationProcessor.ts"],"sourcesContent":["import { UpdateInputProcessor } from '../../inputProcessing'\nimport { Input, Model } from '@contember/schema'\nimport { appendRelationToPath, ValidationPath } from '../ValidationPath'\nimport { Mapper } from '../../mapper'\nimport { InputPreValidator } from './InputPreValidator'\n\ntype Result = any\n\nconst NoResult = () => Promise.resolve([])\n\nexport class UpdateInputPreValidationProcessor implements UpdateInputProcessor<Result> {\n\tconstructor(\n\t\tprivate readonly inputValidator: InputPreValidator,\n\t\tprivate readonly path: ValidationPath,\n\t\tprivate readonly mapper: Mapper,\n\t) {}\n\n\tasync column(context: Model.ColumnContext): Promise<Result> {\n\t\treturn []\n\t}\n\n\tmanyHasManyInverse: UpdateInputProcessor.HasManyRelationInputProcessor<Model.ManyHasManyInverseContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate({ ...ctx, input: ctx.input.data }),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\tmanyHasManyOwning: UpdateInputProcessor.HasManyRelationInputProcessor<Model.ManyHasManyOwningContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate({ ...ctx, input: ctx.input.data }),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\tmanyHasOne: UpdateInputProcessor.HasOneRelationInputProcessor<Model.ManyHasOneContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate(ctx),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\toneHasMany: UpdateInputProcessor.HasManyRelationInputProcessor<Model.OneHasManyContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate({ ...ctx, input: ctx.input.data }),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\toneHasOneInverse: UpdateInputProcessor.HasOneRelationInputProcessor<Model.OneHasOneInverseContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate(ctx),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\n\toneHasOneOwning: UpdateInputProcessor.HasOneRelationInputProcessor<Model.OneHasOneOwningContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate(ctx),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\n\tasync processCreate(context: {\n\t\ttargetEntity: Model.Entity\n\t\trelation: Model.AnyRelation\n\t\ttargetRelation: Model.AnyRelation | null\n\t\tinput: Input.CreateDataInput\n\t\tindex?: number\n\t\talias?: string\n\t}) {\n\t\tconst newPath = appendRelationToPath(this.path, context.relation.name, context)\n\n\t\treturn this.inputValidator.validateCreate({\n\t\t\tentity: context.targetEntity,\n\t\t\tmapper: this.mapper,\n\t\t\tdata: context.input,\n\t\t\tpath: newPath,\n\t\t\toverRelation: context.targetRelation,\n\t\t})\n\t}\n\n\tasync processUpsert(context: {\n\t\ttargetEntity: Model.Entity\n\t\ttargetRelation: Model.AnyRelation | null\n\t\trelation: Model.AnyRelation\n\t\tinput: UpdateInputProcessor.UpsertInput\n\t\tindex?: number\n\t\talias?: string\n\t}) {\n\t\tconst newPath = appendRelationToPath(this.path, context.relation.name, context)\n\t\treturn [\n\t\t\t...(await this.inputValidator.validateUpdate({\n\t\t\t\tentity: context.targetEntity,\n\t\t\t\tmapper: this.mapper,\n\t\t\t\tdata: context.input.update,\n\t\t\t\tpath: newPath,\n\t\t\t\twhere: {}, // todo\n\t\t\t})),\n\t\t\t...(await this.inputValidator.validateCreate({\n\t\t\t\tentity: context.targetEntity,\n\t\t\t\tmapper: this.mapper,\n\t\t\t\tdata: context.input.create,\n\t\t\t\tpath: newPath,\n\t\t\t\toverRelation: context.targetRelation,\n\t\t\t})),\n\t\t]\n\t}\n\n\tasync processUpdate(context: {\n\t\ttargetEntity: Model.Entity\n\t\trelation: Model.AnyRelation\n\t\tinput: Input.UpdateDataInput\n\t\ttargetRelation: Model.AnyRelation | null\n\t\tindex?: number\n\t\talias?: string\n\t}) {\n\t\tconst newPath = appendRelationToPath(this.path, context.relation.name, context)\n\t\treturn this.inputValidator.validateUpdate({\n\t\t\tentity: context.targetEntity,\n\t\t\tmapper: this.mapper,\n\t\t\tdata: context.input,\n\t\t\tpath: newPath,\n\t\t\twhere: {}, // todo,\n\t\t})\n\t}\n}\n"],"names":["appendRelationToPath"],"mappings":";;;;;;AAQA,MAAM,WAAW,MAAM,QAAQ,QAAQ,EAAE;AAElC,MAAM,kCAA0E;AAAA,EACtF,YACkB,gBACA,MACA,QAChB;AAHgB,SAAA,iBAAA;AACA,SAAA,OAAA;AACA,SAAA,SAAA;AAOgG,kBAAA,MAAA,sBAAA;AAAA,MACjH,QAAQ,CAAA,QAAO,KAAK,cAAc,GAAG;AAAA,MACrC,QAAQ,CAAO,QAAA,KAAK,cAAc,EAAE,GAAG,KAAK,OAAO,IAAI,MAAM,KAAA,CAAM;AAAA,MACnE,QAAQ,CAAA,QAAO,KAAK,cAAc,GAAG;AAA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SAAS,MAAM,OAAO;AACvE,WAAA;AAAA,MACN,GAAI,MAAM,KAAK,eAAe,eAAe;AAAA,QAC5C,QAAQ,QAAQ;AAAA,QAChB,QAAQ,KAAK;AAAA,QACb,MAAM,QAAQ,MAAM;AAAA,QACpB,MAAM;AAAA,QACN,OAAO,CAAA;AAAA;AAAA,MAAC,CACR;AAAA,MACD,GAAI,MAAM,KAAK,eAAe,eAAe;AAAA,QAC5C,QAAQ,QAAQ;AAAA,QAChB,QAAQ,KAAK;AAAA,QACb,MAAM,QAAQ,MAAM;AAAA,QACpB,MAAM;AAAA,QACN,cAAc,QAAQ;AAAA,MACtB,CAAA;AAAA,IACF;AAAA,EAAA;AAAA,EAGD,MAAM,cAAc,SAOjB;AACF,UAAM,UAAUA,eAAqB,qBAAA,KAAK,MAAM,QAAQ,SAAS,MAAM,OAAO;AACvE,WAAA,KAAK,eAAe,eAAe;AAAA,MACzC,QAAQ,QAAQ;AAAA,MAChB,QAAQ,KAAK;AAAA,MACb,MAAM,QAAQ;AAAA,MACd,MAAM;AAAA,MACN,OAAO,CAAA;AAAA;AAAA,IAAC,CACR;AAAA,EAAA;AAEH;;"}
1
+ {"version":3,"file":"UpdateInputPreValidationProcessor.cjs","sources":["../../../../../../packages/engine-content-api/src/input-validation/preValidation/UpdateInputPreValidationProcessor.ts"],"sourcesContent":["import { UpdateInputProcessor } from '../../inputProcessing'\nimport { Input, Model } from '@contember/schema'\nimport { appendRelationToPath, ValidationPath } from '../ValidationPath'\nimport { Mapper, MapperInput } from '../../mapper'\nimport { InputPreValidator } from './InputPreValidator'\n\ntype Result = any\n\nconst NoResult = () => Promise.resolve([])\n\nexport class UpdateInputPreValidationProcessor implements UpdateInputProcessor<Result> {\n\tconstructor(\n\t\tprivate readonly inputValidator: InputPreValidator,\n\t\tprivate readonly path: ValidationPath,\n\t\tprivate readonly mapper: Mapper,\n\t) {}\n\n\tasync column(context: Model.ColumnContext): Promise<Result> {\n\t\treturn []\n\t}\n\n\tmanyHasManyInverse: UpdateInputProcessor.HasManyRelationInputProcessor<Model.ManyHasManyInverseContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate({ ...ctx, input: ctx.input.data }),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\tmanyHasManyOwning: UpdateInputProcessor.HasManyRelationInputProcessor<Model.ManyHasManyOwningContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate({ ...ctx, input: ctx.input.data }),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\tmanyHasOne: UpdateInputProcessor.HasOneRelationInputProcessor<Model.ManyHasOneContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate(ctx),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\toneHasMany: UpdateInputProcessor.HasManyRelationInputProcessor<Model.OneHasManyContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate({ ...ctx, input: ctx.input.data }),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\toneHasOneInverse: UpdateInputProcessor.HasOneRelationInputProcessor<Model.OneHasOneInverseContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate(ctx),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\n\toneHasOneOwning: UpdateInputProcessor.HasOneRelationInputProcessor<Model.OneHasOneOwningContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate(ctx),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\n\tasync processCreate(context: {\n\t\ttargetEntity: Model.Entity\n\t\trelation: Model.AnyRelation\n\t\ttargetRelation: Model.AnyRelation | null\n\t\tinput: MapperInput.CreateDataInput\n\t\tindex?: number\n\t\talias?: string\n\t}) {\n\t\tconst newPath = appendRelationToPath(this.path, context.relation.name, context)\n\n\t\treturn this.inputValidator.validateCreate({\n\t\t\tentity: context.targetEntity,\n\t\t\tmapper: this.mapper,\n\t\t\tdata: context.input,\n\t\t\tpath: newPath,\n\t\t\toverRelation: context.targetRelation,\n\t\t})\n\t}\n\n\tasync processUpsert(context: {\n\t\ttargetEntity: Model.Entity\n\t\ttargetRelation: Model.AnyRelation | null\n\t\trelation: Model.AnyRelation\n\t\tinput: UpdateInputProcessor.UpsertInput\n\t\tindex?: number\n\t\talias?: string\n\t}) {\n\t\tconst newPath = appendRelationToPath(this.path, context.relation.name, context)\n\t\treturn [\n\t\t\t...(await this.inputValidator.validateUpdate({\n\t\t\t\tentity: context.targetEntity,\n\t\t\t\tmapper: this.mapper,\n\t\t\t\tdata: context.input.update,\n\t\t\t\tpath: newPath,\n\t\t\t\twhere: {}, // todo\n\t\t\t})),\n\t\t\t...(await this.inputValidator.validateCreate({\n\t\t\t\tentity: context.targetEntity,\n\t\t\t\tmapper: this.mapper,\n\t\t\t\tdata: context.input.create,\n\t\t\t\tpath: newPath,\n\t\t\t\toverRelation: context.targetRelation,\n\t\t\t})),\n\t\t]\n\t}\n\n\tasync processUpdate(context: {\n\t\ttargetEntity: Model.Entity\n\t\trelation: Model.AnyRelation\n\t\tinput: MapperInput.UpdateDataInput\n\t\ttargetRelation: Model.AnyRelation | null\n\t\tindex?: number\n\t\talias?: string\n\t}) {\n\t\tconst newPath = appendRelationToPath(this.path, context.relation.name, context)\n\t\treturn this.inputValidator.validateUpdate({\n\t\t\tentity: context.targetEntity,\n\t\t\tmapper: this.mapper,\n\t\t\tdata: context.input,\n\t\t\tpath: newPath,\n\t\t\twhere: {}, // todo,\n\t\t})\n\t}\n}\n"],"names":["appendRelationToPath"],"mappings":";;;;;;AAQA,MAAM,WAAW,MAAM,QAAQ,QAAQ,EAAE;AAElC,MAAM,kCAA0E;AAAA,EACtF,YACkB,gBACA,MACA,QAChB;AAHgB,SAAA,iBAAA;AACA,SAAA,OAAA;AACA,SAAA,SAAA;AAOgG,kBAAA,MAAA,sBAAA;AAAA,MACjH,QAAQ,CAAA,QAAO,KAAK,cAAc,GAAG;AAAA,MACrC,QAAQ,CAAO,QAAA,KAAK,cAAc,EAAE,GAAG,KAAK,OAAO,IAAI,MAAM,KAAA,CAAM;AAAA,MACnE,QAAQ,CAAA,QAAO,KAAK,cAAc,GAAG;AAAA,MACrC,iBAAiB,CAAO,QAAA,KAAK,cAAc,EAAE,GAAG,KAAK,OAAO,IAAI,MAAM,OAAA,CAAQ;AAAA,MAC9E,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,CAAC,QAAQ,GAAG;AAAA,IAAA,CACb;AACgH,kBAAA,MAAA,qBAAA;AAAA,MAC/G,QAAQ,CAAA,QAAO,KAAK,cAAc,GAAG;AAAA,MACrC,QAAQ,CAAO,QAAA,KAAK,cAAc,EAAE,GAAG,KAAK,OAAO,IAAI,MAAM,KAAA,CAA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