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

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 +1 @@
1
- {"version":3,"file":"ManyHasOneCreateInputProcessor.js","sources":["../../../../../../../packages/engine-content-api/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { getInsertPrimary, MutationEntryNotFoundError } from '../../Result'\nimport { Mapper } from '../../Mapper'\nimport { CreateInputProcessor } from '../../../inputProcessing'\nimport { SqlCreateInputProcessorResult } from '../SqlCreateInputProcessor'\nimport { InsertBuilder } from '../InsertBuilder'\n\ntype Context = Model.ManyHasOneContext\n\nexport class ManyHasOneCreateInputProcessor implements CreateInputProcessor.HasManyRelationProcessor<Context, SqlCreateInputProcessorResult> {\n\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t\tprivate readonly insertBuilder: InsertBuilder,\n\t) {\n\t}\n\tpublic async connect(\n\t\t{ targetEntity, relation, input }: Context & { input: Input.UniqueWhere },\n\t) {\n\t\tconst value = await this.mapper.getPrimaryValue(targetEntity, input)\n\t\tif (!value) {\n\t\t\treturn [new MutationEntryNotFoundError([], input)]\n\t\t}\n\t\tthis.insertBuilder.addFieldValue(relation.name, value)\n\t\treturn []\n\t}\n\n\tpublic async create(\n\t\t{ relation, targetEntity, input }: Context & { input: Input.CreateDataInput },\n\t) {\n\t\tconst insertResult = await this.mapper.insert(targetEntity, input)\n\t\tconst value = getInsertPrimary(insertResult)\n\t\tif (!value) {\n\t\t\treturn insertResult\n\t\t}\n\t\tthis.insertBuilder.addFieldValue(relation.name, value)\n\t\treturn []\n\t}\n\n\tpublic async connectOrCreate(\n\t\t{ input: { connect, create }, relation, targetEntity }: Context & { input: Input.ConnectOrCreateInput },\n\t) {\n\t\tconst value = await this.mapper.getPrimaryValue(targetEntity, connect)\n\t\tif (value) {\n\t\t\tthis.insertBuilder.addFieldValue(relation.name, value)\n\t\t} else {\n\t\t\tconst insertResult = await this.mapper.insert(targetEntity, create)\n\t\t\tconst primary = getInsertPrimary(insertResult)\n\t\t\tif (!primary) {\n\t\t\t\treturn insertResult\n\t\t\t}\n\n\t\t\tthis.insertBuilder.addFieldValue(relation.name, primary)\n\t\t}\n\t\treturn []\n\t}\n}\n"],"names":[],"mappings":";AASO,MAAM,+BAAiI;AAAA,EAE7I,YACkB,QACA,eAChB;AAFgB,SAAA,SAAA;AACA,SAAA,gBAAA;AAAA,EAAA;AAAA,EAGlB,MAAa,QACZ,EAAE,cAAc,UAAU,SACzB;AACD,UAAM,QAAQ,MAAM,KAAK,OAAO,gBAAgB,cAAc,KAAK;AACnE,QAAI,CAAC,OAAO;AACX,aAAO,CAAC,IAAI,2BAA2B,CAAC,GAAG,KAAK,CAAC;AAAA,IAAA;AAElD,SAAK,cAAc,cAAc,SAAS,MAAM,KAAK;AACrD,WAAO,CAAC;AAAA,EAAA;AAAA,EAGT,MAAa,OACZ,EAAE,UAAU,cAAc,SACzB;AACD,UAAM,eAAe,MAAM,KAAK,OAAO,OAAO,cAAc,KAAK;AAC3D,UAAA,QAAQ,iBAAiB,YAAY;AAC3C,QAAI,CAAC,OAAO;AACJ,aAAA;AAAA,IAAA;AAER,SAAK,cAAc,cAAc,SAAS,MAAM,KAAK;AACrD,WAAO,CAAC;AAAA,EAAA;AAAA,EAGT,MAAa,gBACZ,EAAE,OAAO,EAAE,SAAS,UAAU,UAAU,gBACvC;AACD,UAAM,QAAQ,MAAM,KAAK,OAAO,gBAAgB,cAAc,OAAO;AACrE,QAAI,OAAO;AACV,WAAK,cAAc,cAAc,SAAS,MAAM,KAAK;AAAA,IAAA,OAC/C;AACN,YAAM,eAAe,MAAM,KAAK,OAAO,OAAO,cAAc,MAAM;AAC5D,YAAA,UAAU,iBAAiB,YAAY;AAC7C,UAAI,CAAC,SAAS;AACN,eAAA;AAAA,MAAA;AAGR,WAAK,cAAc,cAAc,SAAS,MAAM,OAAO;AAAA,IAAA;AAExD,WAAO,CAAC;AAAA,EAAA;AAEV;"}
1
+ {"version":3,"file":"ManyHasOneCreateInputProcessor.js","sources":["../../../../../../../packages/engine-content-api/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { getInsertPrimary, MutationEntryNotFoundError } from '../../Result'\nimport { Mapper } from '../../Mapper'\nimport { CreateInputProcessor } from '../../../inputProcessing'\nimport { SqlCreateInputProcessorResult } from '../SqlCreateInputProcessor'\nimport { InsertBuilder } from '../InsertBuilder'\nimport { CheckedPrimary } from '../../CheckedPrimary'\nimport { MapperInput } from '../../types'\n\ntype Context = Model.ManyHasOneContext\n\nexport class ManyHasOneCreateInputProcessor implements CreateInputProcessor.HasManyRelationProcessor<Context, SqlCreateInputProcessorResult> {\n\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t\tprivate readonly insertBuilder: InsertBuilder,\n\t) {\n\t}\n\tpublic async connect(\n\t\t{ targetEntity, relation, input }: Context & { input: Input.UniqueWhere | CheckedPrimary },\n\t) {\n\t\tconst [value, err] = await this.mapper.getPrimaryValue(targetEntity, input)\n\t\tif (err) return [err]\n\t\tthis.insertBuilder.addFieldValue(relation.name, value)\n\t\treturn []\n\t}\n\n\tpublic async create(\n\t\t{ relation, targetEntity, input }: Context & { input: MapperInput.CreateDataInput },\n\t) {\n\t\tconst insertResult = await this.mapper.insert(targetEntity, input)\n\t\tconst value = getInsertPrimary(insertResult)\n\t\tif (!value) {\n\t\t\treturn insertResult\n\t\t}\n\t\tthis.insertBuilder.addFieldValue(relation.name, value)\n\t\treturn []\n\t}\n\n\tpublic async connectOrCreate(\n\t\t{ input: { connect, create }, relation, targetEntity }: Context & { input: MapperInput.ConnectOrCreateInput },\n\t) {\n\t\tconst [value] = await this.mapper.getPrimaryValue(targetEntity, connect)\n\t\tif (value) {\n\t\t\tthis.insertBuilder.addFieldValue(relation.name, value)\n\t\t} else {\n\t\t\tconst insertResult = await this.mapper.insert(targetEntity, create)\n\t\t\tconst primary = getInsertPrimary(insertResult)\n\t\t\tif (!primary) {\n\t\t\t\treturn insertResult\n\t\t\t}\n\n\t\t\tthis.insertBuilder.addFieldValue(relation.name, primary)\n\t\t}\n\t\treturn []\n\t}\n}\n"],"names":[],"mappings":";AAWO,MAAM,+BAAiI;AAAA,EAE7I,YACkB,QACA,eAChB;AAFgB,SAAA,SAAA;AACA,SAAA,gBAAA;AAAA,EAAA;AAAA,EAGlB,MAAa,QACZ,EAAE,cAAc,UAAU,SACzB;AACK,UAAA,CAAC,OAAO,GAAG,IAAI,MAAM,KAAK,OAAO,gBAAgB,cAAc,KAAK;AACtE,QAAA,IAAY,QAAA,CAAC,GAAG;AACpB,SAAK,cAAc,cAAc,SAAS,MAAM,KAAK;AACrD,WAAO,CAAC;AAAA,EAAA;AAAA,EAGT,MAAa,OACZ,EAAE,UAAU,cAAc,SACzB;AACD,UAAM,eAAe,MAAM,KAAK,OAAO,OAAO,cAAc,KAAK;AAC3D,UAAA,QAAQ,iBAAiB,YAAY;AAC3C,QAAI,CAAC,OAAO;AACJ,aAAA;AAAA,IAAA;AAER,SAAK,cAAc,cAAc,SAAS,MAAM,KAAK;AACrD,WAAO,CAAC;AAAA,EAAA;AAAA,EAGT,MAAa,gBACZ,EAAE,OAAO,EAAE,SAAS,UAAU,UAAU,gBACvC;AACK,UAAA,CAAC,KAAK,IAAI,MAAM,KAAK,OAAO,gBAAgB,cAAc,OAAO;AACvE,QAAI,OAAO;AACV,WAAK,cAAc,cAAc,SAAS,MAAM,KAAK;AAAA,IAAA,OAC/C;AACN,YAAM,eAAe,MAAM,KAAK,OAAO,OAAO,cAAc,MAAM;AAC5D,YAAA,UAAU,iBAAiB,YAAY;AAC7C,UAAI,CAAC,SAAS;AACN,eAAA;AAAA,MAAA;AAGR,WAAK,cAAc,cAAc,SAAS,MAAM,OAAO;AAAA,IAAA;AAExD,WAAO,CAAC;AAAA,EAAA;AAEV;"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const CheckedPrimary = require("../../CheckedPrimary.cjs");
3
4
  class OneHasManyCreateInputProcessor {
4
5
  constructor(mapper) {
5
6
  this.mapper = mapper;
@@ -7,7 +8,7 @@ class OneHasManyCreateInputProcessor {
7
8
  async connect({ entity, targetEntity, targetRelation, input }) {
8
9
  return async ({ primary }) => {
9
10
  return await this.mapper.update(targetEntity, input, {
10
- [targetRelation.name]: { connect: { [entity.primary]: primary } }
11
+ [targetRelation.name]: { connect: new CheckedPrimary.CheckedPrimary(primary) }
11
12
  });
12
13
  };
13
14
  }
@@ -15,7 +16,7 @@ class OneHasManyCreateInputProcessor {
15
16
  return async ({ primary }) => {
16
17
  return await this.mapper.insert(targetEntity, {
17
18
  ...input,
18
- [targetRelation.name]: { connect: { [entity.primary]: primary } }
19
+ [targetRelation.name]: { connect: new CheckedPrimary.CheckedPrimary(primary) }
19
20
  });
20
21
  };
21
22
  }
@@ -23,7 +24,7 @@ class OneHasManyCreateInputProcessor {
23
24
  return async ({ primary }) => {
24
25
  const connectData = {
25
26
  [targetRelation.name]: {
26
- connect: { [entity.primary]: primary }
27
+ connect: new CheckedPrimary.CheckedPrimary(primary)
27
28
  }
28
29
  };
29
30
  return await this.mapper.upsert(targetEntity, connect, connectData, {
@@ -1 +1 @@
1
- {"version":3,"file":"OneHasManyCreateInputProcessor.cjs","sources":["../../../../../../../packages/engine-content-api/src/mapper/insert/relations/OneHasManyCreateInputProcessor.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { Mapper } from '../../Mapper'\nimport { CreateInputProcessor } from '../../../inputProcessing'\nimport { SqlCreateInputProcessorResult } from '../SqlCreateInputProcessor'\n\ntype Context = Model.OneHasManyContext\n\nexport class OneHasManyCreateInputProcessor implements CreateInputProcessor.HasManyRelationProcessor<Context, SqlCreateInputProcessorResult> {\n\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t) {\n\t}\n\tpublic async connect(\n\t\t{ entity, targetEntity, targetRelation, input }: Context & { input: Input.UniqueWhere },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.update(targetEntity, input, {\n\t\t\t\t[targetRelation.name]: { connect: { [entity.primary]: primary } },\n\t\t\t})\n\t\t}\n\t}\n\n\tpublic async create(\n\t\t{ entity, targetEntity, targetRelation, input }: Context & { input: Input.CreateDataInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.insert(targetEntity, {\n\t\t\t\t...input,\n\t\t\t\t[targetRelation.name]: { connect: { [entity.primary]: primary } },\n\t\t\t})\n\t\t}\n\t}\n\n\tpublic async connectOrCreate(\n\t\t{ entity, targetRelation, targetEntity, input: { connect, create } }: Context & { input: Input.ConnectOrCreateInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst connectData = {\n\t\t\t\t[targetRelation.name]: {\n\t\t\t\t\tconnect: { [entity.primary]: primary },\n\t\t\t\t},\n\t\t\t}\n\t\t\treturn await this.mapper.upsert(targetEntity, connect, connectData, {\n\t\t\t\t...create,\n\t\t\t\t...connectData,\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAOO,MAAM,+BAAgI;AAAA,EAE5I,YACkB,QAChB;AADgB,SAAA,SAAA;AAAA,EAAA;AAAA,EAGlB,MAAa,QACZ,EAAE,QAAQ,cAAc,gBAAgB,SACvC;AACM,WAAA,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc,OAAO;AAAA,QACpD,CAAC,eAAe,IAAI,GAAG,EAAE,SAAS,EAAE,CAAC,OAAO,OAAO,GAAG,QAAU,EAAA;AAAA,MAAA,CAChE;AAAA,IACF;AAAA,EAAA;AAAA,EAGD,MAAa,OACZ,EAAE,QAAQ,cAAc,gBAAgB,SACvC;AACM,WAAA,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc;AAAA,QAC7C,GAAG;AAAA,QACH,CAAC,eAAe,IAAI,GAAG,EAAE,SAAS,EAAE,CAAC,OAAO,OAAO,GAAG,QAAU,EAAA;AAAA,MAAA,CAChE;AAAA,IACF;AAAA,EAAA;AAAA,EAGD,MAAa,gBACZ,EAAE,QAAQ,gBAAgB,cAAc,OAAO,EAAE,SAAS,OAAO,KAChE;AACM,WAAA,OAAO,EAAE,cAA+C;AAC9D,YAAM,cAAc;AAAA,QACnB,CAAC,eAAe,IAAI,GAAG;AAAA,UACtB,SAAS,EAAE,CAAC,OAAO,OAAO,GAAG,QAAQ;AAAA,QAAA;AAAA,MAEvC;AACA,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc,SAAS,aAAa;AAAA,QACnE,GAAG;AAAA,QACH,GAAG;AAAA,MAAA,CACH;AAAA,IACF;AAAA,EAAA;AAEF;;"}
1
+ {"version":3,"file":"OneHasManyCreateInputProcessor.cjs","sources":["../../../../../../../packages/engine-content-api/src/mapper/insert/relations/OneHasManyCreateInputProcessor.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { Mapper } from '../../Mapper'\nimport { CreateInputProcessor } from '../../../inputProcessing'\nimport { SqlCreateInputProcessorResult } from '../SqlCreateInputProcessor'\nimport { CheckedPrimary } from '../../CheckedPrimary'\nimport { MapperInput } from '../../types'\n\ntype Context = Model.OneHasManyContext\n\nexport class OneHasManyCreateInputProcessor implements CreateInputProcessor.HasManyRelationProcessor<Context, SqlCreateInputProcessorResult> {\n\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t) {\n\t}\n\tpublic async connect(\n\t\t{ entity, targetEntity, targetRelation, input }: Context & { input: Input.UniqueWhere | CheckedPrimary },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.update(targetEntity, input, {\n\t\t\t\t[targetRelation.name]: { connect: new CheckedPrimary(primary) },\n\t\t\t})\n\t\t}\n\t}\n\n\tpublic async create(\n\t\t{ entity, targetEntity, targetRelation, input }: Context & { input: MapperInput.CreateDataInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.insert(targetEntity, {\n\t\t\t\t...input,\n\t\t\t\t[targetRelation.name]: { connect: new CheckedPrimary(primary) },\n\t\t\t})\n\t\t}\n\t}\n\n\tpublic async connectOrCreate(\n\t\t{ entity, targetRelation, targetEntity, input: { connect, create } }: Context & { input: MapperInput.ConnectOrCreateInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst connectData = {\n\t\t\t\t[targetRelation.name]: {\n\t\t\t\t\tconnect: new CheckedPrimary(primary),\n\t\t\t\t},\n\t\t\t}\n\t\t\treturn await this.mapper.upsert(targetEntity, connect, connectData, {\n\t\t\t\t...create,\n\t\t\t\t...connectData,\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":["CheckedPrimary"],"mappings":";;;AASO,MAAM,+BAAgI;AAAA,EAE5I,YACkB,QAChB;AADgB,SAAA,SAAA;AAAA,EAAA;AAAA,EAGlB,MAAa,QACZ,EAAE,QAAQ,cAAc,gBAAgB,SACvC;AACM,WAAA,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc,OAAO;AAAA,QACpD,CAAC,eAAe,IAAI,GAAG,EAAE,SAAS,IAAIA,eAAAA,eAAe,OAAO,EAAE;AAAA,MAAA,CAC9D;AAAA,IACF;AAAA,EAAA;AAAA,EAGD,MAAa,OACZ,EAAE,QAAQ,cAAc,gBAAgB,SACvC;AACM,WAAA,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc;AAAA,QAC7C,GAAG;AAAA,QACH,CAAC,eAAe,IAAI,GAAG,EAAE,SAAS,IAAIA,eAAAA,eAAe,OAAO,EAAE;AAAA,MAAA,CAC9D;AAAA,IACF;AAAA,EAAA;AAAA,EAGD,MAAa,gBACZ,EAAE,QAAQ,gBAAgB,cAAc,OAAO,EAAE,SAAS,OAAO,KAChE;AACM,WAAA,OAAO,EAAE,cAA+C;AAC9D,YAAM,cAAc;AAAA,QACnB,CAAC,eAAe,IAAI,GAAG;AAAA,UACtB,SAAS,IAAIA,eAAAA,eAAe,OAAO;AAAA,QAAA;AAAA,MAErC;AACA,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc,SAAS,aAAa;AAAA,QACnE,GAAG;AAAA,QACH,GAAG;AAAA,MAAA,CACH;AAAA,IACF;AAAA,EAAA;AAEF;;"}
@@ -1,3 +1,4 @@
1
+ import { CheckedPrimary } from "../../CheckedPrimary.js";
1
2
  class OneHasManyCreateInputProcessor {
2
3
  constructor(mapper) {
3
4
  this.mapper = mapper;
@@ -5,7 +6,7 @@ class OneHasManyCreateInputProcessor {
5
6
  async connect({ entity, targetEntity, targetRelation, input }) {
6
7
  return async ({ primary }) => {
7
8
  return await this.mapper.update(targetEntity, input, {
8
- [targetRelation.name]: { connect: { [entity.primary]: primary } }
9
+ [targetRelation.name]: { connect: new CheckedPrimary(primary) }
9
10
  });
10
11
  };
11
12
  }
@@ -13,7 +14,7 @@ class OneHasManyCreateInputProcessor {
13
14
  return async ({ primary }) => {
14
15
  return await this.mapper.insert(targetEntity, {
15
16
  ...input,
16
- [targetRelation.name]: { connect: { [entity.primary]: primary } }
17
+ [targetRelation.name]: { connect: new CheckedPrimary(primary) }
17
18
  });
18
19
  };
19
20
  }
@@ -21,7 +22,7 @@ class OneHasManyCreateInputProcessor {
21
22
  return async ({ primary }) => {
22
23
  const connectData = {
23
24
  [targetRelation.name]: {
24
- connect: { [entity.primary]: primary }
25
+ connect: new CheckedPrimary(primary)
25
26
  }
26
27
  };
27
28
  return await this.mapper.upsert(targetEntity, connect, connectData, {
@@ -1 +1 @@
1
- {"version":3,"file":"OneHasManyCreateInputProcessor.js","sources":["../../../../../../../packages/engine-content-api/src/mapper/insert/relations/OneHasManyCreateInputProcessor.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { Mapper } from '../../Mapper'\nimport { CreateInputProcessor } from '../../../inputProcessing'\nimport { SqlCreateInputProcessorResult } from '../SqlCreateInputProcessor'\n\ntype Context = Model.OneHasManyContext\n\nexport class OneHasManyCreateInputProcessor implements CreateInputProcessor.HasManyRelationProcessor<Context, SqlCreateInputProcessorResult> {\n\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t) {\n\t}\n\tpublic async connect(\n\t\t{ entity, targetEntity, targetRelation, input }: Context & { input: Input.UniqueWhere },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.update(targetEntity, input, {\n\t\t\t\t[targetRelation.name]: { connect: { [entity.primary]: primary } },\n\t\t\t})\n\t\t}\n\t}\n\n\tpublic async create(\n\t\t{ entity, targetEntity, targetRelation, input }: Context & { input: Input.CreateDataInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.insert(targetEntity, {\n\t\t\t\t...input,\n\t\t\t\t[targetRelation.name]: { connect: { [entity.primary]: primary } },\n\t\t\t})\n\t\t}\n\t}\n\n\tpublic async connectOrCreate(\n\t\t{ entity, targetRelation, targetEntity, input: { connect, create } }: Context & { input: Input.ConnectOrCreateInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst connectData = {\n\t\t\t\t[targetRelation.name]: {\n\t\t\t\t\tconnect: { [entity.primary]: primary },\n\t\t\t\t},\n\t\t\t}\n\t\t\treturn await this.mapper.upsert(targetEntity, connect, connectData, {\n\t\t\t\t...create,\n\t\t\t\t...connectData,\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":[],"mappings":"AAOO,MAAM,+BAAgI;AAAA,EAE5I,YACkB,QAChB;AADgB,SAAA,SAAA;AAAA,EAAA;AAAA,EAGlB,MAAa,QACZ,EAAE,QAAQ,cAAc,gBAAgB,SACvC;AACM,WAAA,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc,OAAO;AAAA,QACpD,CAAC,eAAe,IAAI,GAAG,EAAE,SAAS,EAAE,CAAC,OAAO,OAAO,GAAG,QAAU,EAAA;AAAA,MAAA,CAChE;AAAA,IACF;AAAA,EAAA;AAAA,EAGD,MAAa,OACZ,EAAE,QAAQ,cAAc,gBAAgB,SACvC;AACM,WAAA,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc;AAAA,QAC7C,GAAG;AAAA,QACH,CAAC,eAAe,IAAI,GAAG,EAAE,SAAS,EAAE,CAAC,OAAO,OAAO,GAAG,QAAU,EAAA;AAAA,MAAA,CAChE;AAAA,IACF;AAAA,EAAA;AAAA,EAGD,MAAa,gBACZ,EAAE,QAAQ,gBAAgB,cAAc,OAAO,EAAE,SAAS,OAAO,KAChE;AACM,WAAA,OAAO,EAAE,cAA+C;AAC9D,YAAM,cAAc;AAAA,QACnB,CAAC,eAAe,IAAI,GAAG;AAAA,UACtB,SAAS,EAAE,CAAC,OAAO,OAAO,GAAG,QAAQ;AAAA,QAAA;AAAA,MAEvC;AACA,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc,SAAS,aAAa;AAAA,QACnE,GAAG;AAAA,QACH,GAAG;AAAA,MAAA,CACH;AAAA,IACF;AAAA,EAAA;AAEF;"}
1
+ {"version":3,"file":"OneHasManyCreateInputProcessor.js","sources":["../../../../../../../packages/engine-content-api/src/mapper/insert/relations/OneHasManyCreateInputProcessor.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { Mapper } from '../../Mapper'\nimport { CreateInputProcessor } from '../../../inputProcessing'\nimport { SqlCreateInputProcessorResult } from '../SqlCreateInputProcessor'\nimport { CheckedPrimary } from '../../CheckedPrimary'\nimport { MapperInput } from '../../types'\n\ntype Context = Model.OneHasManyContext\n\nexport class OneHasManyCreateInputProcessor implements CreateInputProcessor.HasManyRelationProcessor<Context, SqlCreateInputProcessorResult> {\n\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t) {\n\t}\n\tpublic async connect(\n\t\t{ entity, targetEntity, targetRelation, input }: Context & { input: Input.UniqueWhere | CheckedPrimary },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.update(targetEntity, input, {\n\t\t\t\t[targetRelation.name]: { connect: new CheckedPrimary(primary) },\n\t\t\t})\n\t\t}\n\t}\n\n\tpublic async create(\n\t\t{ entity, targetEntity, targetRelation, input }: Context & { input: MapperInput.CreateDataInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.insert(targetEntity, {\n\t\t\t\t...input,\n\t\t\t\t[targetRelation.name]: { connect: new CheckedPrimary(primary) },\n\t\t\t})\n\t\t}\n\t}\n\n\tpublic async connectOrCreate(\n\t\t{ entity, targetRelation, targetEntity, input: { connect, create } }: Context & { input: MapperInput.ConnectOrCreateInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst connectData = {\n\t\t\t\t[targetRelation.name]: {\n\t\t\t\t\tconnect: new CheckedPrimary(primary),\n\t\t\t\t},\n\t\t\t}\n\t\t\treturn await this.mapper.upsert(targetEntity, connect, connectData, {\n\t\t\t\t...create,\n\t\t\t\t...connectData,\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";AASO,MAAM,+BAAgI;AAAA,EAE5I,YACkB,QAChB;AADgB,SAAA,SAAA;AAAA,EAAA;AAAA,EAGlB,MAAa,QACZ,EAAE,QAAQ,cAAc,gBAAgB,SACvC;AACM,WAAA,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc,OAAO;AAAA,QACpD,CAAC,eAAe,IAAI,GAAG,EAAE,SAAS,IAAI,eAAe,OAAO,EAAE;AAAA,MAAA,CAC9D;AAAA,IACF;AAAA,EAAA;AAAA,EAGD,MAAa,OACZ,EAAE,QAAQ,cAAc,gBAAgB,SACvC;AACM,WAAA,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc;AAAA,QAC7C,GAAG;AAAA,QACH,CAAC,eAAe,IAAI,GAAG,EAAE,SAAS,IAAI,eAAe,OAAO,EAAE;AAAA,MAAA,CAC9D;AAAA,IACF;AAAA,EAAA;AAAA,EAGD,MAAa,gBACZ,EAAE,QAAQ,gBAAgB,cAAc,OAAO,EAAE,SAAS,OAAO,KAChE;AACM,WAAA,OAAO,EAAE,cAA+C;AAC9D,YAAM,cAAc;AAAA,QACnB,CAAC,eAAe,IAAI,GAAG;AAAA,UACtB,SAAS,IAAI,eAAe,OAAO;AAAA,QAAA;AAAA,MAErC;AACA,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc,SAAS,aAAa;AAAA,QACnE,GAAG;AAAA,QACH,GAAG;AAAA,MAAA,CACH;AAAA,IACF;AAAA,EAAA;AAEF;"}
@@ -9,10 +9,8 @@ class OneHasOneInverseCreateInputProcessor {
9
9
  async connect(context) {
10
10
  return async ({ primary }) => {
11
11
  const { targetEntity, input } = context;
12
- const owner = await this.mapper.getPrimaryValue(targetEntity, input);
13
- if (!owner) {
14
- return [new Result.MutationEntryNotFoundError([], input)];
15
- }
12
+ const [owner, err] = await this.mapper.getPrimaryValue(targetEntity, input);
13
+ if (err) return [err];
16
14
  return await this.connectInternal({ ...context, input: new CheckedPrimary.CheckedPrimary(owner) }, primary);
17
15
  };
18
16
  }
@@ -26,7 +24,7 @@ class OneHasOneInverseCreateInputProcessor {
26
24
  }
27
25
  async connectOrCreate({ input, ...context }) {
28
26
  return async ({ primary }) => {
29
- const owner = await this.mapper.getPrimaryValue(context.targetEntity, input.connect);
27
+ const [owner] = await this.mapper.getPrimaryValue(context.targetEntity, input.connect);
30
28
  if (owner) {
31
29
  return await this.connectInternal({ ...context, input: new CheckedPrimary.CheckedPrimary(owner) }, primary);
32
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"OneHasOneInverseCreateInputProcessor.cjs","sources":["../../../../../../../packages/engine-content-api/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.ts"],"sourcesContent":["import { Mapper } from '../../Mapper'\nimport { ConstraintType, MutationConstraintViolationError, MutationEntryNotFoundError, MutationResultList } from '../../Result'\nimport { CheckedPrimary } from '../../CheckedPrimary'\nimport { Input, Model } from '@contember/schema'\nimport { CreateInputProcessor } from '../../../inputProcessing'\nimport { SqlCreateInputProcessorResult } from '../SqlCreateInputProcessor'\n\ntype Context = Model.OneHasOneInverseContext\n\nexport class OneHasOneInverseCreateInputProcessor implements CreateInputProcessor.HasOneRelationProcessor<Context, SqlCreateInputProcessorResult> {\n\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t) {\n\t}\n\n\tpublic async connect(context: Context & { input: Input.UniqueWhere }) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst { targetEntity, input } = context\n\t\t\tconst owner = await this.mapper.getPrimaryValue(targetEntity, input)\n\t\t\tif (!owner) {\n\t\t\t\treturn [new MutationEntryNotFoundError([], input)]\n\t\t\t}\n\n\t\t\treturn await this.connectInternal({ ...context, input: new CheckedPrimary(owner) }, primary)\n\t\t}\n\t}\n\n\n\tpublic async create(\n\t\t{ input, targetRelation, targetEntity }: Context & { input: Input.CreateDataInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.insert(targetEntity, input, builder => {\n\t\t\t\tbuilder.addPredicates([targetRelation.name])\n\t\t\t\tbuilder.addFieldValue(targetRelation.name, primary)\n\t\t\t})\n\t\t}\n\t}\n\n\tpublic async connectOrCreate(\n\t\t{ input, ...context }: Context & { input: Input.ConnectOrCreateInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst owner = await this.mapper.getPrimaryValue(context.targetEntity, input.connect)\n\t\t\tif (owner) {\n\t\t\t\treturn await this.connectInternal({ ...context, input: new CheckedPrimary(owner) }, primary)\n\t\t\t}\n\n\t\t\treturn await this.createInternal({ input: input.create, ...context }, primary)\n\t\t}\n\t}\n\n\tprivate async connectInternal(\n\t\t{ entity, targetEntity, targetRelation, relation, input }: Context & { input: CheckedPrimary },\n\t\tprimary: Input.PrimaryValue,\n\t) {\n\n\t\tconst currentInverseSideOfOwner = await this.mapper.selectField(targetEntity, input, targetRelation.name)\n\t\tconst orphanResult: MutationResultList = []\n\t\tif (currentInverseSideOfOwner) {\n\t\t\tif (targetRelation.orphanRemoval) {\n\t\t\t\tconst orphanUnique = { [entity.primary]: currentInverseSideOfOwner }\n\t\t\t\tconst orphanDelete = await this.mapper.delete(entity, orphanUnique)\n\t\t\t\torphanResult.push(...orphanDelete)\n\t\t\t} else if (!relation.nullable) {\n\t\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t\t}\n\t\t}\n\n\t\tconst connectResult = await this.mapper.updateInternal(targetEntity, input, update => {\n\t\t\tupdate.addPredicates([targetRelation.name])\n\t\t\tupdate.addFieldValue(targetRelation.name, primary)\n\t\t})\n\n\t\treturn [\n\t\t\t...connectResult,\n\t\t\t...orphanResult,\n\t\t]\n\t}\n\n\tprivate async createInternal(\n\t\tcontext: Context & { input: Input.CreateDataInput },\n\t\tprimary: Input.PrimaryValue,\n\t) {\n\t\treturn await this.mapper.insert(context.targetEntity, context.input, builder => {\n\t\t\tbuilder.addPredicates([context.targetRelation.name])\n\t\t\tbuilder.addFieldValue(context.targetRelation.name, primary)\n\t\t})\n\t}\n}\n"],"names":["MutationEntryNotFoundError","CheckedPrimary","MutationConstraintViolationError","ConstraintType"],"mappings":";;;;AASO,MAAM,qCAAsI;AAAA,EAElJ,YACkB,QAChB;AADgB,SAAA,SAAA;AAAA,EAAA;AAAA,EAIlB,MAAa,QAAQ,SAAiD;AAC9D,WAAA,OAAO,EAAE,cAA+C;AACxD,YAAA,EAAE,cAAc,MAAA,IAAU;AAChC,YAAM,QAAQ,MAAM,KAAK,OAAO,gBAAgB,cAAc,KAAK;AACnE,UAAI,CAAC,OAAO;AACX,eAAO,CAAC,IAAIA,OAAAA,2BAA2B,CAAC,GAAG,KAAK,CAAC;AAAA,MAAA;AAGlD,aAAO,MAAM,KAAK,gBAAgB,EAAE,GAAG,SAAS,OAAO,IAAIC,8BAAe,KAAK,EAAE,GAAG,OAAO;AAAA,IAC5F;AAAA,EAAA;AAAA,EAID,MAAa,OACZ,EAAE,OAAO,gBAAgB,gBACxB;AACM,WAAA,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc,OAAO,CAAW,YAAA;AAC/D,gBAAQ,cAAc,CAAC,eAAe,IAAI,CAAC;AACnC,gBAAA,cAAc,eAAe,MAAM,OAAO;AAAA,MAAA,CAClD;AAAA,IACF;AAAA,EAAA;AAAA,EAGD,MAAa,gBACZ,EAAE,OAAO,GAAG,WACX;AACM,WAAA,OAAO,EAAE,cAA+C;AACxD,YAAA,QAAQ,MAAM,KAAK,OAAO,gBAAgB,QAAQ,cAAc,MAAM,OAAO;AACnF,UAAI,OAAO;AACV,eAAO,MAAM,KAAK,gBAAgB,EAAE,GAAG,SAAS,OAAO,IAAIA,8BAAe,KAAK,EAAE,GAAG,OAAO;AAAA,MAAA;AAGrF,aAAA,MAAM,KAAK,eAAe,EAAE,OAAO,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO;AAAA,IAC9E;AAAA,EAAA;AAAA,EAGD,MAAc,gBACb,EAAE,QAAQ,cAAc,gBAAgB,UAAU,MAAM,GACxD,SACC;AAEK,UAAA,4BAA4B,MAAM,KAAK,OAAO,YAAY,cAAc,OAAO,eAAe,IAAI;AACxG,UAAM,eAAmC,CAAC;AAC1C,QAAI,2BAA2B;AAC9B,UAAI,eAAe,eAAe;AACjC,cAAM,eAAe,EAAE,CAAC,OAAO,OAAO,GAAG,0BAA0B;AACnE,cAAM,eAAe,MAAM,KAAK,OAAO,OAAO,QAAQ,YAAY;AACrD,qBAAA,KAAK,GAAG,YAAY;AAAA,MAAA,WACvB,CAAC,SAAS,UAAU;AAC9B,eAAO,CAAC,IAAIC,OAAA,iCAAiC,CAAI,GAAAC,OAAA,eAAe,OAAO,CAAC;AAAA,MAAA;AAAA,IACzE;AAGD,UAAM,gBAAgB,MAAM,KAAK,OAAO,eAAe,cAAc,OAAO,CAAU,WAAA;AACrF,aAAO,cAAc,CAAC,eAAe,IAAI,CAAC;AACnC,aAAA,cAAc,eAAe,MAAM,OAAO;AAAA,IAAA,CACjD;AAEM,WAAA;AAAA,MACN,GAAG;AAAA,MACH,GAAG;AAAA,IACJ;AAAA,EAAA;AAAA,EAGD,MAAc,eACb,SACA,SACC;AACM,WAAA,MAAM,KAAK,OAAO,OAAO,QAAQ,cAAc,QAAQ,OAAO,CAAW,YAAA;AAC/E,cAAQ,cAAc,CAAC,QAAQ,eAAe,IAAI,CAAC;AACnD,cAAQ,cAAc,QAAQ,eAAe,MAAM,OAAO;AAAA,IAAA,CAC1D;AAAA,EAAA;AAEH;;"}
1
+ {"version":3,"file":"OneHasOneInverseCreateInputProcessor.cjs","sources":["../../../../../../../packages/engine-content-api/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.ts"],"sourcesContent":["import { Mapper } from '../../Mapper'\nimport { ConstraintType, MutationConstraintViolationError, MutationEntryNotFoundError, MutationResultList } from '../../Result'\nimport { CheckedPrimary } from '../../CheckedPrimary'\nimport { Input, Model } from '@contember/schema'\nimport { CreateInputProcessor } from '../../../inputProcessing'\nimport { SqlCreateInputProcessorResult } from '../SqlCreateInputProcessor'\nimport { MapperInput } from '../../types'\n\ntype Context = Model.OneHasOneInverseContext\n\nexport class OneHasOneInverseCreateInputProcessor implements CreateInputProcessor.HasOneRelationProcessor<Context, SqlCreateInputProcessorResult> {\n\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t) {\n\t}\n\n\tpublic async connect(context: Context & { input: Input.UniqueWhere | CheckedPrimary }) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst { targetEntity, input } = context\n\t\t\tconst [owner, err] = await this.mapper.getPrimaryValue(targetEntity, input)\n\t\t\tif (err) return [err]\n\n\t\t\treturn await this.connectInternal({ ...context, input: new CheckedPrimary(owner) }, primary)\n\t\t}\n\t}\n\n\n\tpublic async create(\n\t\t{ input, targetRelation, targetEntity }: Context & { input: MapperInput.CreateDataInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.insert(targetEntity, input, builder => {\n\t\t\t\tbuilder.addPredicates([targetRelation.name])\n\t\t\t\tbuilder.addFieldValue(targetRelation.name, primary)\n\t\t\t})\n\t\t}\n\t}\n\n\tpublic async connectOrCreate(\n\t\t{ input, ...context }: Context & { input: MapperInput.ConnectOrCreateInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst [owner] = await this.mapper.getPrimaryValue(context.targetEntity, input.connect)\n\t\t\tif (owner) {\n\t\t\t\treturn await this.connectInternal({ ...context, input: new CheckedPrimary(owner) }, primary)\n\t\t\t}\n\n\t\t\treturn await this.createInternal({ input: input.create, ...context }, primary)\n\t\t}\n\t}\n\n\tprivate async connectInternal(\n\t\t{ entity, targetEntity, targetRelation, relation, input }: Context & { input: CheckedPrimary },\n\t\tprimary: Input.PrimaryValue,\n\t) {\n\n\t\tconst currentInverseSideOfOwner = await this.mapper.selectField(targetEntity, input, targetRelation.name)\n\t\tconst orphanResult: MutationResultList = []\n\t\tif (currentInverseSideOfOwner) {\n\t\t\tif (targetRelation.orphanRemoval) {\n\t\t\t\tconst orphanUnique = { [entity.primary]: currentInverseSideOfOwner }\n\t\t\t\tconst orphanDelete = await this.mapper.delete(entity, orphanUnique)\n\t\t\t\torphanResult.push(...orphanDelete)\n\t\t\t} else if (!relation.nullable) {\n\t\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t\t}\n\t\t}\n\n\t\tconst connectResult = await this.mapper.updateInternal(targetEntity, input, update => {\n\t\t\tupdate.addPredicates([targetRelation.name])\n\t\t\tupdate.addFieldValue(targetRelation.name, primary)\n\t\t})\n\n\t\treturn [\n\t\t\t...connectResult,\n\t\t\t...orphanResult,\n\t\t]\n\t}\n\n\tprivate async createInternal(\n\t\tcontext: Context & { input: MapperInput.CreateDataInput },\n\t\tprimary: Input.PrimaryValue,\n\t) {\n\t\treturn await this.mapper.insert(context.targetEntity, context.input, builder => {\n\t\t\tbuilder.addPredicates([context.targetRelation.name])\n\t\t\tbuilder.addFieldValue(context.targetRelation.name, primary)\n\t\t})\n\t}\n}\n"],"names":["CheckedPrimary","MutationConstraintViolationError","ConstraintType"],"mappings":";;;;AAUO,MAAM,qCAAsI;AAAA,EAElJ,YACkB,QAChB;AADgB,SAAA,SAAA;AAAA,EAAA;AAAA,EAIlB,MAAa,QAAQ,SAAkE;AAC/E,WAAA,OAAO,EAAE,cAA+C;AACxD,YAAA,EAAE,cAAc,MAAA,IAAU;AAC1B,YAAA,CAAC,OAAO,GAAG,IAAI,MAAM,KAAK,OAAO,gBAAgB,cAAc,KAAK;AACtE,UAAA,IAAY,QAAA,CAAC,GAAG;AAEpB,aAAO,MAAM,KAAK,gBAAgB,EAAE,GAAG,SAAS,OAAO,IAA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B,MAAM,KAAK,OAAO,eAAe,cAAc,OAAO,CAAU,WAAA;AACrF,aAAO,cAAc,CAAC,eAAe,IAAI,CAAC;AACnC,aAAA,cAAc,eAAe,MAAM,OAAO;AAAA,IAAA,CACjD;AAEM,WAAA;AAAA,MACN,GAAG;AAAA,MACH,GAAG;AAAA,IACJ;AAAA,EAAA;AAAA,EAGD,MAAc,eACb,SACA,SACC;AACM,WAAA,MAAM,KAAK,OAAO,OAAO,QAAQ,cAAc,QAAQ,OAAO,CAAW,YAAA;AAC/E,cAAQ,cAAc,CAAC,QAAQ,eAAe,IAAI,CAAC;AACnD,cAAQ,cAAc,QAAQ,eAAe,MAAM,OAAO;AAAA,IAAA,CAC1D;AAAA,EAAA;AAEH;;"}
@@ -1,4 +1,4 @@
1
- import { MutationEntryNotFoundError, MutationConstraintViolationError, ConstraintType } from "../../Result.js";
1
+ import { MutationConstraintViolationError, ConstraintType } from "../../Result.js";
2
2
  import { CheckedPrimary } from "../../CheckedPrimary.js";
3
3
  class OneHasOneInverseCreateInputProcessor {
4
4
  constructor(mapper) {
@@ -7,10 +7,8 @@ class OneHasOneInverseCreateInputProcessor {
7
7
  async connect(context) {
8
8
  return async ({ primary }) => {
9
9
  const { targetEntity, input } = context;
10
- const owner = await this.mapper.getPrimaryValue(targetEntity, input);
11
- if (!owner) {
12
- return [new MutationEntryNotFoundError([], input)];
13
- }
10
+ const [owner, err] = await this.mapper.getPrimaryValue(targetEntity, input);
11
+ if (err) return [err];
14
12
  return await this.connectInternal({ ...context, input: new CheckedPrimary(owner) }, primary);
15
13
  };
16
14
  }
@@ -24,7 +22,7 @@ class OneHasOneInverseCreateInputProcessor {
24
22
  }
25
23
  async connectOrCreate({ input, ...context }) {
26
24
  return async ({ primary }) => {
27
- const owner = await this.mapper.getPrimaryValue(context.targetEntity, input.connect);
25
+ const [owner] = await this.mapper.getPrimaryValue(context.targetEntity, input.connect);
28
26
  if (owner) {
29
27
  return await this.connectInternal({ ...context, input: new CheckedPrimary(owner) }, primary);
30
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"OneHasOneInverseCreateInputProcessor.js","sources":["../../../../../../../packages/engine-content-api/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.ts"],"sourcesContent":["import { Mapper } from '../../Mapper'\nimport { ConstraintType, MutationConstraintViolationError, MutationEntryNotFoundError, MutationResultList } from '../../Result'\nimport { CheckedPrimary } from '../../CheckedPrimary'\nimport { Input, Model } from '@contember/schema'\nimport { CreateInputProcessor } from '../../../inputProcessing'\nimport { SqlCreateInputProcessorResult } from '../SqlCreateInputProcessor'\n\ntype Context = Model.OneHasOneInverseContext\n\nexport class OneHasOneInverseCreateInputProcessor implements CreateInputProcessor.HasOneRelationProcessor<Context, SqlCreateInputProcessorResult> {\n\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t) {\n\t}\n\n\tpublic async connect(context: Context & { input: Input.UniqueWhere }) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst { targetEntity, input } = context\n\t\t\tconst owner = await this.mapper.getPrimaryValue(targetEntity, input)\n\t\t\tif (!owner) {\n\t\t\t\treturn [new MutationEntryNotFoundError([], input)]\n\t\t\t}\n\n\t\t\treturn await this.connectInternal({ ...context, input: new CheckedPrimary(owner) }, primary)\n\t\t}\n\t}\n\n\n\tpublic async create(\n\t\t{ input, targetRelation, targetEntity }: Context & { input: Input.CreateDataInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.insert(targetEntity, input, builder => {\n\t\t\t\tbuilder.addPredicates([targetRelation.name])\n\t\t\t\tbuilder.addFieldValue(targetRelation.name, primary)\n\t\t\t})\n\t\t}\n\t}\n\n\tpublic async connectOrCreate(\n\t\t{ input, ...context }: Context & { input: Input.ConnectOrCreateInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst owner = await this.mapper.getPrimaryValue(context.targetEntity, input.connect)\n\t\t\tif (owner) {\n\t\t\t\treturn await this.connectInternal({ ...context, input: new CheckedPrimary(owner) }, primary)\n\t\t\t}\n\n\t\t\treturn await this.createInternal({ input: input.create, ...context }, primary)\n\t\t}\n\t}\n\n\tprivate async connectInternal(\n\t\t{ entity, targetEntity, targetRelation, relation, input }: Context & { input: CheckedPrimary },\n\t\tprimary: Input.PrimaryValue,\n\t) {\n\n\t\tconst currentInverseSideOfOwner = await this.mapper.selectField(targetEntity, input, targetRelation.name)\n\t\tconst orphanResult: MutationResultList = []\n\t\tif (currentInverseSideOfOwner) {\n\t\t\tif (targetRelation.orphanRemoval) {\n\t\t\t\tconst orphanUnique = { [entity.primary]: currentInverseSideOfOwner }\n\t\t\t\tconst orphanDelete = await this.mapper.delete(entity, orphanUnique)\n\t\t\t\torphanResult.push(...orphanDelete)\n\t\t\t} else if (!relation.nullable) {\n\t\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t\t}\n\t\t}\n\n\t\tconst connectResult = await this.mapper.updateInternal(targetEntity, input, update => {\n\t\t\tupdate.addPredicates([targetRelation.name])\n\t\t\tupdate.addFieldValue(targetRelation.name, primary)\n\t\t})\n\n\t\treturn [\n\t\t\t...connectResult,\n\t\t\t...orphanResult,\n\t\t]\n\t}\n\n\tprivate async createInternal(\n\t\tcontext: Context & { input: Input.CreateDataInput },\n\t\tprimary: Input.PrimaryValue,\n\t) {\n\t\treturn await this.mapper.insert(context.targetEntity, context.input, builder => {\n\t\t\tbuilder.addPredicates([context.targetRelation.name])\n\t\t\tbuilder.addFieldValue(context.targetRelation.name, primary)\n\t\t})\n\t}\n}\n"],"names":[],"mappings":";;AASO,MAAM,qCAAsI;AAAA,EAElJ,YACkB,QAChB;AADgB,SAAA,SAAA;AAAA,EAAA;AAAA,EAIlB,MAAa,QAAQ,SAAiD;AAC9D,WAAA,OAAO,EAAE,cAA+C;AACxD,YAAA,EAAE,cAAc,MAAA,IAAU;AAChC,YAAM,QAAQ,MAAM,KAAK,O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YAAY;AAAA,MAAA,WACvB,CAAC,SAAS,UAAU;AAC9B,eAAO,CAAC,IAAI,iCAAiC,CAAI,GAAA,eAAe,OAAO,CAAC;AAAA,MAAA;AAAA,IACzE;AAGD,UAAM,gBAAgB,MAAM,KAAK,OAAO,eAAe,cAAc,OAAO,CAAU,WAAA;AACrF,aAAO,cAAc,CAAC,eAAe,IAAI,CAAC;AACnC,aAAA,cAAc,eAAe,MAAM,OAAO;AAAA,IAAA,CACjD;AAEM,WAAA;AAAA,MACN,GAAG;AAAA,MACH,GAAG;AAAA,IACJ;AAAA,EAAA;AAAA,EAGD,MAAc,eACb,SACA,SACC;AACM,WAAA,MAAM,KAAK,OAAO,OAAO,QAAQ,cAAc,QAAQ,OAAO,CAAW,YAAA;AAC/E,cAAQ,cAAc,CAAC,QAAQ,eAAe,IAAI,CAAC;AACnD,cAAQ,cAAc,QAAQ,eAAe,MAAM,OAAO;AAAA,IAAA,CAC1D;AAAA,EAAA;AAEH;"}
1
+ {"version":3,"file":"OneHasOneInverseCreateInputProcessor.js","sources":["../../../../../../../packages/engine-content-api/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.ts"],"sourcesContent":["import { Mapper } from '../../Mapper'\nimport { ConstraintType, MutationConstraintViolationError, MutationEntryNotFoundError, MutationResultList } from '../../Result'\nimport { CheckedPrimary } from '../../CheckedPrimary'\nimport { Input, Model } from '@contember/schema'\nimport { CreateInputProcessor } from '../../../inputProcessing'\nimport { SqlCreateInputProcessorResult } from '../SqlCreateInputProcessor'\nimport { MapperInput } from '../../types'\n\ntype Context = Model.OneHasOneInverseContext\n\nexport class OneHasOneInverseCreateInputProcessor implements CreateInputProcessor.HasOneRelationProcessor<Context, SqlCreateInputProcessorResult> {\n\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t) {\n\t}\n\n\tpublic async connect(context: Context & { input: Input.UniqueWhere | CheckedPrimary }) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst { targetEntity, input } = context\n\t\t\tconst [owner, err] = await this.mapper.getPrimaryValue(targetEntity, input)\n\t\t\tif (err) return [err]\n\n\t\t\treturn await this.connectInternal({ ...context, input: new CheckedPrimary(owner) }, primary)\n\t\t}\n\t}\n\n\n\tpublic async create(\n\t\t{ input, targetRelation, targetEntity }: Context & { input: MapperInput.CreateDataInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.insert(targetEntity, input, builder => {\n\t\t\t\tbuilder.addPredicates([targetRelation.name])\n\t\t\t\tbuilder.addFieldValue(targetRelation.name, primary)\n\t\t\t})\n\t\t}\n\t}\n\n\tpublic async connectOrCreate(\n\t\t{ input, ...context }: Context & { input: MapperInput.ConnectOrCreateInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst [owner] = await this.mapper.getPrimaryValue(context.targetEntity, input.connect)\n\t\t\tif (owner) {\n\t\t\t\treturn await this.connectInternal({ ...context, input: new CheckedPrimary(owner) }, primary)\n\t\t\t}\n\n\t\t\treturn await this.createInternal({ input: input.create, ...context }, primary)\n\t\t}\n\t}\n\n\tprivate async connectInternal(\n\t\t{ entity, targetEntity, targetRelation, relation, input }: Context & { input: CheckedPrimary },\n\t\tprimary: Input.PrimaryValue,\n\t) {\n\n\t\tconst currentInverseSideOfOwner = await this.mapper.selectField(targetEntity, input, targetRelation.name)\n\t\tconst orphanResult: MutationResultList = []\n\t\tif (currentInverseSideOfOwner) {\n\t\t\tif (targetRelation.orphanRemoval) {\n\t\t\t\tconst orphanUnique = { [entity.primary]: currentInverseSideOfOwner }\n\t\t\t\tconst orphanDelete = await this.mapper.delete(entity, orphanUnique)\n\t\t\t\torphanResult.push(...orphanDelete)\n\t\t\t} else if (!relation.nullable) {\n\t\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t\t}\n\t\t}\n\n\t\tconst connectResult = await this.mapper.updateInternal(targetEntity, input, update => {\n\t\t\tupdate.addPredicates([targetRelation.name])\n\t\t\tupdate.addFieldValue(targetRelation.name, primary)\n\t\t})\n\n\t\treturn [\n\t\t\t...connectResult,\n\t\t\t...orphanResult,\n\t\t]\n\t}\n\n\tprivate async createInternal(\n\t\tcontext: Context & { input: MapperInput.CreateDataInput },\n\t\tprimary: Input.PrimaryValue,\n\t) {\n\t\treturn await this.mapper.insert(context.targetEntity, context.input, builder => {\n\t\t\tbuilder.addPredicates([context.targetRelation.name])\n\t\t\tbuilder.addFieldValue(context.targetRelation.name, primary)\n\t\t})\n\t}\n}\n"],"names":[],"mappings":";;AAUO,MAAM,qCAAsI;AAAA,EAElJ,YACkB,QAChB;AADgB,SAAA,SAAA;AAAA,EAAA;AAAA,EAIlB,MAAa,QAAQ,SAAkE;AAC/E,WAAA,OAAO,EAAE,cAA+C;AACxD,YAAA,EAAE,cAAc,MAAA,IAAU;AAC1B,YAAA,CAAC,OAAO,GAAG,IAAI,MAAM,KAAK,OAAO,gBAAgB,cAAc,KAAK;AACtE,UAAA,IAAY,QAAA,CAAC,GAAG;AAEpB,aAAO,MAAM,KAAK,gBAAgB,EAAE,GAAG,SAAS,OAAO,IAAI,eAAe,KAAK,EAAE,GAAG,OAAO;AAAA,IAC5F;AAAA,EAAA;AAAA,EAID,MAAa,OACZ,EAAE,OAAO,gBAAgB,gBACxB;AACM,WAAA,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc,OAAO,CAAW,YAAA;AAC/D,gBAAQ,cAAc,CAAC,eAAe,IAAI,CAAC;AACnC,gBAAA,cAAc,eAAe,MAAM,OAAO;AAAA,MAAA,CAClD;AAAA,IACF;AAAA,EAAA;AAAA,EAGD,MAAa,gBACZ,EAAE,OAAO,GAAG,WACX;AACM,WAAA,OAAO,EAAE,cAA+C;AACxD,YAAA,CAAC,KAAK,IAAI,MAAM,KAAK,OAAO,gBAAgB,QAAQ,cAAc,MAAM,OAAO;AACrF,UAAI,OAAO;AACV,eAAO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10
  const { input, relation, targetEntity } = context;
11
- const inverseSide = await this.mapper.getPrimaryValue(targetEntity, input);
12
- if (!inverseSide) {
13
- return [new Result.MutationEntryNotFoundError([], input)];
14
- }
11
+ const [inverseSide, err] = await this.mapper.getPrimaryValue(targetEntity, input);
12
+ if (err) return [err];
15
13
  const disconnectResult = await this.disconnectCurrentOwner({ ...context, input: inverseSide });
16
14
  if (disconnectResult.some((it) => it.error)) {
17
15
  return disconnectResult;
@@ -29,7 +27,7 @@ class OneHasOneOwningCreateInputProcessor {
29
27
  return [];
30
28
  }
31
29
  async connectOrCreate({ input, ...context }) {
32
- const inverseSide = await this.mapper.getPrimaryValue(context.targetEntity, input.connect);
30
+ const [inverseSide] = await this.mapper.getPrimaryValue(context.targetEntity, input.connect);
33
31
  if (inverseSide) {
34
32
  this.insertBuilder.addFieldValue(context.relation.name, inverseSide);
35
33
  const disconnectResult = await this.disconnectCurrentOwner({ ...context, input: inverseSide });
@@ -47,7 +45,7 @@ class OneHasOneOwningCreateInputProcessor {
47
45
  }
48
46
  }
49
47
  async disconnectCurrentOwner({ entity, relation, targetEntity, input }) {
50
- const currentOwnerOfInverseSide = await this.mapper.getPrimaryValue(entity, {
48
+ const [currentOwnerOfInverseSide] = await this.mapper.getPrimaryValue(entity, {
51
49
  [relation.name]: { [targetEntity.primary]: input }
52
50
  });
53
51
  if (!currentOwnerOfInverseSide) {
@@ -1 +1 @@
1
- {"version":3,"file":"OneHasOneOwningCreateInputProcessor.cjs","sources":["../../../../../../../packages/engine-content-api/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.ts"],"sourcesContent":["import {\n\tConstraintType,\n\tgetInsertPrimary,\n\tMutationConstraintViolationError,\n\tMutationEntryNotFoundError,\n\tMutationResultList,\n} from '../../Result'\nimport { InsertBuilder } from '../../insert'\nimport { Mapper } from '../../Mapper'\nimport { Input, Model } from '@contember/schema'\nimport { CreateInputProcessor } from '../../../inputProcessing'\nimport { SqlCreateInputProcessorResult } from '../SqlCreateInputProcessor'\n\ntype Context = Model.OneHasOneOwningContext\n\nexport class OneHasOneOwningCreateInputProcessor implements CreateInputProcessor.HasOneRelationProcessor<Context, SqlCreateInputProcessorResult>{\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t\tprivate readonly insertBuilder: InsertBuilder,\n\t) {\n\t}\n\n\tpublic async connect(context: Context & { input: Input.UniqueWhere }) {\n\t\tconst { input, relation, targetEntity } = context\n\t\tconst inverseSide = await this.mapper.getPrimaryValue(targetEntity, input)\n\t\tif (!inverseSide) {\n\t\t\treturn [new MutationEntryNotFoundError([], input)]\n\t\t}\n\t\tconst disconnectResult = await this.disconnectCurrentOwner({ ...context, input: inverseSide })\n\t\tif (disconnectResult.some(it => it.error)) {\n\t\t\treturn disconnectResult\n\t\t}\n\t\tthis.insertBuilder.addFieldValue(relation.name, inverseSide)\n\t\treturn disconnectResult\n\t}\n\n\tpublic async create(context: Context & { input: Input.CreateDataInput }) {\n\t\tconst insertResult = await this.mapper.insert(context.targetEntity, context.input)\n\t\tconst primary = getInsertPrimary(insertResult)\n\t\tif (!primary) {\n\t\t\treturn insertResult\n\t\t}\n\t\tthis.insertBuilder.addFieldValue(context.relation.name, primary)\n\t\treturn []\n\t}\n\n\tpublic async connectOrCreate({ input, ...context }: Context & { input: Input.ConnectOrCreateInput }) {\n\t\tconst inverseSide = await this.mapper.getPrimaryValue(context.targetEntity, input.connect)\n\t\tif (inverseSide) {\n\t\t\tthis.insertBuilder.addFieldValue(context.relation.name, inverseSide)\n\t\t\tconst disconnectResult = await this.disconnectCurrentOwner({ ...context, input: inverseSide })\n\t\t\tif (disconnectResult.some(it => it.error)) {\n\t\t\t\treturn disconnectResult\n\t\t\t}\n\t\t\treturn []\n\n\t\t} else {\n\t\t\tconst insertResult = await this.mapper.insert(context.targetEntity, input.create)\n\t\t\tconst primary = getInsertPrimary(insertResult)\n\t\t\tif (primary) {\n\t\t\t\tthis.insertBuilder.addFieldValue(context.relation.name, primary)\n\t\t\t}\n\t\t\treturn insertResult\n\t\t}\n\t}\n\n\tprivate async disconnectCurrentOwner(\n\t\t{ entity, relation, targetEntity, input }: Context & { input: Input.PrimaryValue },\n\t): Promise<MutationResultList> {\n\t\tconst currentOwnerOfInverseSide = await this.mapper.getPrimaryValue(entity, {\n\t\t\t[relation.name]: { [targetEntity.primary]: input },\n\t\t})\n\t\tif (!currentOwnerOfInverseSide) {\n\t\t\treturn []\n\t\t}\n\n\t\tif (!relation.nullable) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\tconst currentOwnerUnique = { [entity.primary]: currentOwnerOfInverseSide }\n\t\treturn await this.mapper.updateInternal(entity, currentOwnerUnique, builder => {\n\t\t\tbuilder.addPredicates([relation.name])\n\t\t\tbuilder.addFieldValue(relation.name, null)\n\t\t})\n\t}\n}\n"],"names":["MutationEntryNotFoundError","getInsertPrimary","MutationConstraintViolationError","ConstraintType"],"mappings":";;;AAeO,MAAM,oCAAmI;AAAA,EAC/I,YACkB,QACA,eAChB;AAFgB,SAAA,SAAA;AACA,SAAA,gBAAA;AAAA,EAAA;AAAA,EAIlB,MAAa,QAAQ,SAAiD;AACrE,UAAM,EAAE,OAAO,UAAU,aAAiB,IAAA;AAC1C,UAAM,cAAc,MAAM,KAAK,OAAO,gBAAgB,cAAc,KAAK;AACzE,QAAI,CAAC,aAAa;AACjB,aAAO,CAAC,IAAIA,OAAAA,2BAA2B,CAAC,GAAG,KAAK,CAAC;AAAA,IAAA;AAE5C,UAAA,mBAAmB,MAAM,KAAK,uBAAuB,EAAE,GAAG,SAAS,OAAO,aAAa;AAC7F,QAAI,iBAAiB,KAAK,CAAM,OAAA,GAAG,KAAK,GAAG;AACnC,aAAA;AAAA,IAAA;AAER,SAAK,cAAc,cAAc,SAAS,MAAM,WAAW;AACpD,WAAA;AAAA,EAAA;AAAA,EAGR,MAAa,OAAO,SAAqD;AAClE,UAAA,eAAe,MAAM,KAAK,OAAO,OAAO,QAAQ,cAAc,QAAQ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AO,eAAe,QAAQ,oBAAoB,CAAW,YAAA;AAC9E,cAAQ,cAAc,CAAC,SAAS,IAAI,CAAC;AAC7B,cAAA,cAAc,SAAS,MAAM,IAAI;AAAA,IAAA,CACzC;AAAA,EAAA;AAEH;;"}
1
+ {"version":3,"file":"OneHasOneOwningCreateInputProcessor.cjs","sources":["../../../../../../../packages/engine-content-api/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.ts"],"sourcesContent":["import {\n\tConstraintType,\n\tgetInsertPrimary,\n\tMutationConstraintViolationError,\n\tMutationEntryNotFoundError,\n\tMutationResultList,\n} from '../../Result'\nimport { InsertBuilder } from '../../insert'\nimport { Mapper } from '../../Mapper'\nimport { Input, Model } from '@contember/schema'\nimport { CreateInputProcessor } from '../../../inputProcessing'\nimport { SqlCreateInputProcessorResult } from '../SqlCreateInputProcessor'\nimport { CheckedPrimary } from '../../CheckedPrimary'\nimport { MapperInput } from '../../types'\n\ntype Context = Model.OneHasOneOwningContext\n\nexport class OneHasOneOwningCreateInputProcessor implements CreateInputProcessor.HasOneRelationProcessor<Context, SqlCreateInputProcessorResult>{\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t\tprivate readonly insertBuilder: InsertBuilder,\n\t) {\n\t}\n\n\tpublic async connect(context: Context & { input: Input.UniqueWhere | CheckedPrimary }) {\n\t\tconst { input, relation, targetEntity } = context\n\t\tconst [inverseSide, err] = await this.mapper.getPrimaryValue(targetEntity, input)\n\t\tif (err) return [err]\n\t\tconst disconnectResult = await this.disconnectCurrentOwner({ ...context, input: inverseSide })\n\t\tif (disconnectResult.some(it => it.error)) {\n\t\t\treturn disconnectResult\n\t\t}\n\t\tthis.insertBuilder.addFieldValue(relation.name, inverseSide)\n\t\treturn disconnectResult\n\t}\n\n\tpublic async create(context: Context & { input: MapperInput.CreateDataInput }) {\n\t\tconst insertResult = await this.mapper.insert(context.targetEntity, context.input)\n\t\tconst primary = getInsertPrimary(insertResult)\n\t\tif (!primary) {\n\t\t\treturn insertResult\n\t\t}\n\t\tthis.insertBuilder.addFieldValue(context.relation.name, primary)\n\t\treturn []\n\t}\n\n\tpublic async connectOrCreate({ input, ...context }: Context & { input: MapperInput.ConnectOrCreateInput }) {\n\t\tconst [inverseSide] = await this.mapper.getPrimaryValue(context.targetEntity, input.connect)\n\t\tif (inverseSide) {\n\t\t\tthis.insertBuilder.addFieldValue(context.relation.name, inverseSide)\n\t\t\tconst disconnectResult = await this.disconnectCurrentOwner({ ...context, input: inverseSide })\n\t\t\tif (disconnectResult.some(it => it.error)) {\n\t\t\t\treturn disconnectResult\n\t\t\t}\n\t\t\treturn []\n\n\t\t} else {\n\t\t\tconst insertResult = await this.mapper.insert(context.targetEntity, input.create)\n\t\t\tconst primary = getInsertPrimary(insertResult)\n\t\t\tif (primary) {\n\t\t\t\tthis.insertBuilder.addFieldValue(context.relation.name, primary)\n\t\t\t}\n\t\t\treturn insertResult\n\t\t}\n\t}\n\n\tprivate async disconnectCurrentOwner(\n\t\t{ entity, relation, targetEntity, input }: Context & { input: Input.PrimaryValue },\n\t): Promise<MutationResultList> {\n\t\tconst [currentOwnerOfInverseSide] = await this.mapper.getPrimaryValue(entity, {\n\t\t\t[relation.name]: { [targetEntity.primary]: input },\n\t\t})\n\t\tif (!currentOwnerOfInverseSide) {\n\t\t\treturn []\n\t\t}\n\n\t\tif (!relation.nullable) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\tconst currentOwnerUnique = { [entity.primary]: currentOwnerOfInverseSide }\n\t\treturn await this.mapper.updateInternal(entity, currentOwnerUnique, builder => {\n\t\t\tbuilder.addPredicates([relation.name])\n\t\t\tbuilder.addFieldValue(relation.name, null)\n\t\t})\n\t}\n}\n"],"names":["getInsertPrimary","MutationConstraintViolationError","ConstraintType"],"mappings":";;;AAiBO,MAAM,oCAAmI;AAAA,EAC/I,YACkB,QACA,eAChB;AAFgB,SAAA,SAAA;AACA,SAAA,gBAAA;AAAA,EAAA;AAAA,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A;AAEzD,aAAA;AAAA,IAAA;AAAA,EACR;AAAA,EAGD,MAAc,uBACb,EAAE,QAAQ,UAAU,cAAc,SACJ;AAC9B,UAAM,CAAC,yBAAyB,IAAI,MAAM,KAAK,OAAO,gBAAgB,QAAQ;AAAA,MAC7E,CAAC,SAAS,IAAI,GAAG,EAAE,CAAC,aAAa,OAAO,GAAG,MAAM;AAAA,IAAA,CACjD;AACD,QAAI,CAAC,2BAA2B;AAC/B,aAAO,CAAC;AAAA,IAAA;AAGL,QAAA,CAAC,SAAS,UAAU;AACvB,aAAO,CAAC,IAAIC,OAAA,iCAAiC,CAAI,GAAAC,OAAA,eAAe,OAAO,CAAC;AAAA,IAAA;AAGzE,UAAM,qBAAqB,EAAE,CAAC,OAAO,OAAO,GAAG,0BAA0B;AACzE,WAAO,MAAM,KAAK,OAAO,eAAe,QAAQ,oBAAoB,CAAW,YAAA;AAC9E,cAAQ,cAAc,CAAC,SAAS,IAAI,CAAC;AAC7B,cAAA,cAAc,SAAS,MAAM,IAAI;AAAA,IAAA,CACzC;AAAA,EAAA;AAEH;;"}
@@ -1,4 +1,4 @@
1
- import { MutationEntryNotFoundError, getInsertPrimary, MutationConstraintViolationError, ConstraintType } from "../../Result.js";
1
+ import { getInsertPrimary, MutationConstraintViolationError, ConstraintType } from "../../Result.js";
2
2
  class OneHasOneOwningCreateInputProcessor {
3
3
  constructor(mapper, insertBuilder) {
4
4
  this.mapper = mapper;
@@ -6,10 +6,8 @@ class OneHasOneOwningCreateInputProcessor {
6
6
  }
7
7
  async connect(context) {
8
8
  const { input, relation, targetEntity } = context;
9
- const inverseSide = await this.mapper.getPrimaryValue(targetEntity, input);
10
- if (!inverseSide) {
11
- return [new MutationEntryNotFoundError([], input)];
12
- }
9
+ const [inverseSide, err] = await this.mapper.getPrimaryValue(targetEntity, input);
10
+ if (err) return [err];
13
11
  const disconnectResult = await this.disconnectCurrentOwner({ ...context, input: inverseSide });
14
12
  if (disconnectResult.some((it) => it.error)) {
15
13
  return disconnectResult;
@@ -27,7 +25,7 @@ class OneHasOneOwningCreateInputProcessor {
27
25
  return [];
28
26
  }
29
27
  async connectOrCreate({ input, ...context }) {
30
- const inverseSide = await this.mapper.getPrimaryValue(context.targetEntity, input.connect);
28
+ const [inverseSide] = await this.mapper.getPrimaryValue(context.targetEntity, input.connect);
31
29
  if (inverseSide) {
32
30
  this.insertBuilder.addFieldValue(context.relation.name, inverseSide);
33
31
  const disconnectResult = await this.disconnectCurrentOwner({ ...context, input: inverseSide });
@@ -45,7 +43,7 @@ class OneHasOneOwningCreateInputProcessor {
45
43
  }
46
44
  }
47
45
  async disconnectCurrentOwner({ entity, relation, targetEntity, input }) {
48
- const currentOwnerOfInverseSide = await this.mapper.getPrimaryValue(entity, {
46
+ const [currentOwnerOfInverseSide] = await this.mapper.getPrimaryValue(entity, {
49
47
  [relation.name]: { [targetEntity.primary]: input }
50
48
  });
51
49
  if (!currentOwnerOfInverseSide) {
@@ -1 +1 @@
1
- {"version":3,"file":"OneHasOneOwningCreateInputProcessor.js","sources":["../../../../../../../packages/engine-content-api/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.ts"],"sourcesContent":["import {\n\tConstraintType,\n\tgetInsertPrimary,\n\tMutationConstraintViolationError,\n\tMutationEntryNotFoundError,\n\tMutationResultList,\n} from '../../Result'\nimport { InsertBuilder } from '../../insert'\nimport { Mapper } from '../../Mapper'\nimport { Input, Model } from '@contember/schema'\nimport { CreateInputProcessor } from '../../../inputProcessing'\nimport { SqlCreateInputProcessorResult } from '../SqlCreateInputProcessor'\n\ntype Context = Model.OneHasOneOwningContext\n\nexport class OneHasOneOwningCreateInputProcessor implements CreateInputProcessor.HasOneRelationProcessor<Context, SqlCreateInputProcessorResult>{\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t\tprivate readonly insertBuilder: InsertBuilder,\n\t) {\n\t}\n\n\tpublic async connect(context: Context & { input: Input.UniqueWhere }) {\n\t\tconst { input, relation, targetEntity } = context\n\t\tconst inverseSide = await this.mapper.getPrimaryValue(targetEntity, input)\n\t\tif (!inverseSide) {\n\t\t\treturn [new MutationEntryNotFoundError([], input)]\n\t\t}\n\t\tconst disconnectResult = await this.disconnectCurrentOwner({ ...context, input: inverseSide })\n\t\tif (disconnectResult.some(it => it.error)) {\n\t\t\treturn disconnectResult\n\t\t}\n\t\tthis.insertBuilder.addFieldValue(relation.name, inverseSide)\n\t\treturn disconnectResult\n\t}\n\n\tpublic async create(context: Context & { input: Input.CreateDataInput }) {\n\t\tconst insertResult = await this.mapper.insert(context.targetEntity, context.input)\n\t\tconst primary = getInsertPrimary(insertResult)\n\t\tif (!primary) {\n\t\t\treturn insertResult\n\t\t}\n\t\tthis.insertBuilder.addFieldValue(context.relation.name, primary)\n\t\treturn []\n\t}\n\n\tpublic async connectOrCreate({ input, ...context }: Context & { input: Input.ConnectOrCreateInput }) {\n\t\tconst inverseSide = await this.mapper.getPrimaryValue(context.targetEntity, input.connect)\n\t\tif (inverseSide) {\n\t\t\tthis.insertBuilder.addFieldValue(context.relation.name, inverseSide)\n\t\t\tconst disconnectResult = await this.disconnectCurrentOwner({ ...context, input: inverseSide })\n\t\t\tif (disconnectResult.some(it => it.error)) {\n\t\t\t\treturn disconnectResult\n\t\t\t}\n\t\t\treturn []\n\n\t\t} else {\n\t\t\tconst insertResult = await this.mapper.insert(context.targetEntity, input.create)\n\t\t\tconst primary = getInsertPrimary(insertResult)\n\t\t\tif (primary) {\n\t\t\t\tthis.insertBuilder.addFieldValue(context.relation.name, primary)\n\t\t\t}\n\t\t\treturn insertResult\n\t\t}\n\t}\n\n\tprivate async disconnectCurrentOwner(\n\t\t{ entity, relation, targetEntity, input }: Context & { input: Input.PrimaryValue },\n\t): Promise<MutationResultList> {\n\t\tconst currentOwnerOfInverseSide = await this.mapper.getPrimaryValue(entity, {\n\t\t\t[relation.name]: { [targetEntity.primary]: input },\n\t\t})\n\t\tif (!currentOwnerOfInverseSide) {\n\t\t\treturn []\n\t\t}\n\n\t\tif (!relation.nullable) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\tconst currentOwnerUnique = { [entity.primary]: currentOwnerOfInverseSide }\n\t\treturn await this.mapper.updateInternal(entity, currentOwnerUnique, builder => {\n\t\t\tbuilder.addPredicates([relation.name])\n\t\t\tbuilder.addFieldValue(relation.name, null)\n\t\t})\n\t}\n}\n"],"names":[],"mappings":";AAeO,MAAM,oCAAmI;AAAA,EAC/I,YACkB,QACA,eAChB;AAFgB,SAAA,SAAA;AACA,SAAA,gBAAA;AAAA,EAAA;AAAA,EAIlB,MAAa,QAAQ,SAAiD;AACrE,UAAM,EAAE,OAAO,UAAU,aAAiB,IAAA;AAC1C,UAAM,cAAc,MAAM,KAAK,OAAO,gBAAgB,cAAc,KAAK;AACzE,QAAI,CAAC,aAAa;AACjB,aAAO,CAAC,IAAI,2BAA2B,CAAC,GAAG,KAAK,CAAC;AAAA,IAAA;AAE5C,UAAA,mBAAmB,MAAM,KAAK,uBAAuB,EAAE,GAAG,SAAS,OAAO,aAAa;AAC7F,QAAI,iBAAiB,KAAK,CAAM,OAAA,GAAG,KAAK,GAAG;AACnC,aAAA;AAAA,IAAA;AAER,SAAK,cAAc,cAAc,SAAS,MAAM,WAAW;AACpD,WAAA;AAAA,EAAA;AAAA,EAGR,MAAa,OAAO,SAAqD;AAClE,UAAA,eAAe,MAAM,KAAK,OAAO,OAAO,QAAQ,cAAc,QAAQ,KAAK;AAC3E,UAAA,UAAU,iBAAiB,YAAY;AAC7C,QAAI,CAAC,SAAS;AACN,aAAA;AAAA,IAAA;AAER,SAAK,cAAc,cAAc,QAAQ,SAAS,MAAM,OAAO;AAC/D,WAAO,CAAC;AAAA,EAAA;AAAA,EAGT,MAAa,gBAAgB,EAAE,OAAO,GAAG,WAA4D;AAC9F,UAAA,cAAc,MAAM,KAAK,OAAO,gBAAgB,QAAQ,cAAc,MAAM,OAAO;AACzF,QAAI,aAAa;AAChB,WAAK,cAAc,cAAc,QAAQ,SAAS,MAAM,WAAW;AAC7D,YAAA,mBAAmB,MAAM,KAAK,uBAAuB,EAAE,GAAG,SAAS,OAAO,aAAa;AAC7F,UAAI,iBAAiB,KAAK,CAAM,OAAA,GAAG,KAAK,GAAG;AACnC,eAAA;AAAA,MAAA;AAER,aAAO,CAAC;AAAA,IAAA,OAEF;AACA,YAAA,eAAe,MAAM,KAAK,OAAO,OAAO,QAAQ,cAAc,MAAM,MAAM;AAC1E,YAAA,UAAU,iBAAiB,YAAY;AAC7C,UAAI,SAAS;AACZ,aAAK,cAAc,cAAc,QAAQ,SAAS,MAAM,OAAO;AAAA,MAAA;AAEzD,aAAA;AAAA,IAAA;AAAA,EACR;AAAA,EAGD,MAAc,uBACb,EAAE,QAAQ,UAAU,cAAc,SACJ;AAC9B,UAAM,4BAA4B,MAAM,KAAK,OAAO,gBAAgB,QAAQ;AAAA,MAC3E,CAAC,SAAS,IAAI,GAAG,EAAE,CAAC,aAAa,OAAO,GAAG,MAAM;AAAA,IAAA,CACjD;AACD,QAAI,CAAC,2BAA2B;AAC/B,aAAO,CAAC;AAAA,IAAA;AAGL,QAAA,CAAC,SAAS,UAAU;AACvB,aAAO,CAAC,IAAI,iCAAiC,CAAI,GAAA,eAAe,OAAO,CAAC;AAAA,IAAA;AAGzE,UAAM,qBAAqB,EAAE,CAAC,OAAO,OAAO,GAAG,0BAA0B;AACzE,WAAO,MAAM,KAAK,OAAO,eAAe,QAAQ,oBAAoB,CAAW,YAAA;AAC9E,cAAQ,cAAc,CAAC,SAAS,IAAI,CAAC;AAC7B,cAAA,cAAc,SAAS,MAAM,IAAI;AAAA,IAAA,CACzC;AAAA,EAAA;AAEH;"}
1
+ {"version":3,"file":"OneHasOneOwningCreateInputProcessor.js","sources":["../../../../../../../packages/engine-content-api/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.ts"],"sourcesContent":["import {\n\tConstraintType,\n\tgetInsertPrimary,\n\tMutationConstraintViolationError,\n\tMutationEntryNotFoundError,\n\tMutationResultList,\n} from '../../Result'\nimport { InsertBuilder } from '../../insert'\nimport { Mapper } from '../../Mapper'\nimport { Input, Model } from '@contember/schema'\nimport { CreateInputProcessor } from '../../../inputProcessing'\nimport { SqlCreateInputProcessorResult } from '../SqlCreateInputProcessor'\nimport { CheckedPrimary } from '../../CheckedPrimary'\nimport { MapperInput } from '../../types'\n\ntype Context = Model.OneHasOneOwningContext\n\nexport class OneHasOneOwningCreateInputProcessor implements CreateInputProcessor.HasOneRelationProcessor<Context, SqlCreateInputProcessorResult>{\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t\tprivate readonly insertBuilder: InsertBuilder,\n\t) {\n\t}\n\n\tpublic async connect(context: Context & { input: Input.UniqueWhere | CheckedPrimary }) {\n\t\tconst { input, relation, targetEntity } = context\n\t\tconst [inverseSide, err] = await this.mapper.getPrimaryValue(targetEntity, input)\n\t\tif (err) return [err]\n\t\tconst disconnectResult = await this.disconnectCurrentOwner({ ...context, input: inverseSide })\n\t\tif (disconnectResult.some(it => it.error)) {\n\t\t\treturn disconnectResult\n\t\t}\n\t\tthis.insertBuilder.addFieldValue(relation.name, inverseSide)\n\t\treturn disconnectResult\n\t}\n\n\tpublic async create(context: Context & { input: MapperInput.CreateDataInput }) {\n\t\tconst insertResult = await this.mapper.insert(context.targetEntity, context.input)\n\t\tconst primary = getInsertPrimary(insertResult)\n\t\tif (!primary) {\n\t\t\treturn insertResult\n\t\t}\n\t\tthis.insertBuilder.addFieldValue(context.relation.name, primary)\n\t\treturn []\n\t}\n\n\tpublic async connectOrCreate({ input, ...context }: Context & { input: MapperInput.ConnectOrCreateInput }) {\n\t\tconst [inverseSide] = await this.mapper.getPrimaryValue(context.targetEntity, input.connect)\n\t\tif (inverseSide) {\n\t\t\tthis.insertBuilder.addFieldValue(context.relation.name, inverseSide)\n\t\t\tconst disconnectResult = await this.disconnectCurrentOwner({ ...context, input: inverseSide })\n\t\t\tif (disconnectResult.some(it => it.error)) {\n\t\t\t\treturn disconnectResult\n\t\t\t}\n\t\t\treturn []\n\n\t\t} else {\n\t\t\tconst insertResult = await this.mapper.insert(context.targetEntity, input.create)\n\t\t\tconst primary = getInsertPrimary(insertResult)\n\t\t\tif (primary) {\n\t\t\t\tthis.insertBuilder.addFieldValue(context.relation.name, primary)\n\t\t\t}\n\t\t\treturn insertResult\n\t\t}\n\t}\n\n\tprivate async disconnectCurrentOwner(\n\t\t{ entity, relation, targetEntity, input }: Context & { input: Input.PrimaryValue },\n\t): Promise<MutationResultList> {\n\t\tconst [currentOwnerOfInverseSide] = await this.mapper.getPrimaryValue(entity, {\n\t\t\t[relation.name]: { [targetEntity.primary]: input },\n\t\t})\n\t\tif (!currentOwnerOfInverseSide) {\n\t\t\treturn []\n\t\t}\n\n\t\tif (!relation.nullable) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\tconst currentOwnerUnique = { [entity.primary]: currentOwnerOfInverseSide }\n\t\treturn await this.mapper.updateInternal(entity, currentOwnerUnique, builder => {\n\t\t\tbuilder.addPredicates([relation.name])\n\t\t\tbuilder.addFieldValue(relation.name, null)\n\t\t})\n\t}\n}\n"],"names":[],"mappings":";AAiBO,MAAM,oCAAmI;AAAA,EAC/I,YACkB,QACA,eAChB;AAFgB,SAAA,SAAA;AACA,SAAA,gBAAA;AAAA,EAAA;AAAA,EAIlB,MAAa,QAAQ,SAAkE;AACtF,UAAM,EAAE,OAAO,UAAU,aAAiB,IAAA;AACpC,UAAA,CAAC,aAAa,GAAG,IAAI,MAAM,KAAK,OAAO,gBAAgB,cAAc,KAAK;AAC5E,QAAA,IAAY,QAAA,CAAC,GAAG;AACd,UAAA,mBAAmB,MAAM,KAAK,uBAAuB,EAAE,GAAG,SAAS,OAAO,aAAa;AAC7F,QAAI,iBAAiB,KAAK,CAAM,OAAA,GAAG,KAAK,GAAG;AACnC,aAAA;AAAA,IAAA;AAER,SAAK,cAAc,cAAc,SAAS,MAAM,WAAW;AACpD,WAAA;AAAA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,CAAC;AAAA,IAAA;AAGzE,UAAM,qBAAqB,EAAE,CAAC,OAAO,OAAO,GAAG,0BAA0B;AACzE,WAAO,MAAM,KAAK,OAAO,eAAe,QAAQ,oBAAoB,CAAW,YAAA;AAC9E,cAAQ,cAAc,CAAC,SAAS,IAAI,CAAC;AAC7B,cAAA,cAAc,SAAS,MAAM,IAAI;AAAA,IAAA,CACzC;AAAA,EAAA;AAEH;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SqlUpdateInputProcessor.cjs","sources":["../../../../../../packages/engine-content-api/src/mapper/update/SqlUpdateInputProcessor.ts"],"sourcesContent":["import { Input, Model, Value } from '@contember/schema'\nimport { Mapper } from '../Mapper'\nimport { UpdateBuilder } from './UpdateBuilder'\nimport { hasManyProcessor, hasOneProcessor } from '../MutationProcessorHelper'\nimport { OneHasOneInverseUpdateInputProcessor } from './relations/OneHasOneInverseUpdateInputProcessor'\nimport { OneHasOneOwningUpdateInputProcessor } from './relations/OneHasOneOwningUpdateInputProcessor'\nimport { OneHasManyUpdateInputProcessor } from './relations/OneHasManyUpdateInputProcessor'\nimport { ManyHasManyUpdateInputProcessor } from './relations/ManyHasManyUpdateInputProcessor'\nimport { UpdateInputProcessor } from '../../inputProcessing'\nimport { MutationResultList } from '../Result'\nimport { ManyHasOneUpdateInputProcessor } from './relations/ManyHasOneUpdateInputProcessor'\n\nexport type SqlUpdateInputProcessorResult = MutationResultList | ((ctx: { primary: Input.PrimaryValue}) => Promise<MutationResultList>)\n\nexport class SqlUpdateInputProcessor implements UpdateInputProcessor<SqlUpdateInputProcessorResult> {\n\tprivate oneHasOneInverseUpdateInputProcessor: OneHasOneInverseUpdateInputProcessor\n\tprivate oneHasOneOwningUpdateInputProcessor: OneHasOneOwningUpdateInputProcessor\n\tprivate oneHasManyUpdateInputProcessor: OneHasManyUpdateInputProcessor\n\tprivate manyHasOneUpdateInputProcessor: ManyHasOneUpdateInputProcessor\n\tprivate manyHasManyUpdateInputProcessor: ManyHasManyUpdateInputProcessor\n\n\tconstructor(\n\t\tprivate readonly primaryValue: Input.PrimaryValue,\n\t\tprivate readonly data: Input.UpdateDataInput,\n\t\tprivate readonly updateBuilder: UpdateBuilder,\n\t\tprivate readonly mapper: Mapper,\n\t) {\n\t\tthis.oneHasOneInverseUpdateInputProcessor = new OneHasOneInverseUpdateInputProcessor(this.primaryValue, this.mapper)\n\t\tthis.oneHasOneOwningUpdateInputProcessor = new OneHasOneOwningUpdateInputProcessor(this.primaryValue, this.mapper, this.updateBuilder)\n\t\tthis.oneHasManyUpdateInputProcessor = new OneHasManyUpdateInputProcessor(this.mapper)\n\t\tthis.manyHasOneUpdateInputProcessor = new ManyHasOneUpdateInputProcessor(this.mapper, this.updateBuilder, this.primaryValue)\n\t\tthis.manyHasManyUpdateInputProcessor = new ManyHasManyUpdateInputProcessor(this.mapper)\n\t}\n\n\tpublic column({ entity, column }: Model.ColumnContext) {\n\t\tif (this.data[column.name] !== undefined) {\n\t\t\tthis.updateBuilder.addFieldValue(column.name, this.data[column.name] as Value.AtomicValue)\n\t\t}\n\t\treturn Promise.resolve([])\n\t}\n\n\tmanyHasManyInverse: UpdateInputProcessor<SqlUpdateInputProcessorResult>['manyHasManyInverse'] = {\n\t\tconnect: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\tmanyHasManyOwning: UpdateInputProcessor<SqlUpdateInputProcessorResult>['manyHasManyOwning'] = {\n\t\tconnect: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\tmanyHasOne: UpdateInputProcessor<SqlUpdateInputProcessorResult>['manyHasOne'] = {\n\t\tconnect: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\toneHasMany: UpdateInputProcessor<SqlUpdateInputProcessorResult>['oneHasMany'] = {\n\t\tconnect: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\toneHasOneInverse: UpdateInputProcessor<SqlUpdateInputProcessorResult>['oneHasOneInverse'] = {\n\t\tconnect: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\toneHasOneOwning: UpdateInputProcessor<SqlUpdateInputProcessorResult>['oneHasOneOwning'] = {\n\t\tconnect: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.disconnect(ctx)),\n\t}\n}\n"],"names":["hasManyProcessor","hasOneProcessor","OneHasOneInverseUpdateInputProcessor","OneHasOneOwningUpdateInputProcessor","OneHasManyUpdateInputProcessor","ManyHasOneUpdateInputProcessor","ManyHasManyUpdateInputProcessor"],"mappings":";;;;;;;;;;;AAcO,MAAM,wBAAuF;AAAA,EAOnG,YACkB,cACA,MACA,eACA,QAChB;AAJgB,SAAA,eAAA;AACA,SAAA,OAAA;AACA,SAAA,gBAAA;AACA,SAAA,SAAA;AAVV,kBAAA,MAAA,sCAAA;AACA,kBAAA,MAAA,qCAAA;AACA,kBAAA,MAAA,gCAAA;AACA,kBAAA,MAAA,gCAAA;AACA,kBAAA,MAAA,iCAAA;AAsBwF,kBAAA,MAAA,sBAAA;AAAA,MAC/F,SAASA,wBAAiB,iBAAA,CAAA,QAAO,KAAK,gCAAgC,QAAQ,GAAG,CAAC;AAAA,MAClF,QAAQA,wBAAiB,iBAAA,CAAA,QAAO,KAAK,gCAAgC,OAAO,GAAG,CAAC;AAAA,MAChF,iBAAiBA,wBAAiB,iBAAA,CAAA,QAAO,KAAK,gCAAgC,gBAAgB,GAAG,CAAC;AAAA,MAClG,QAAQA,wBAAiB,iBAAA,CAAA,QAAO,KAAK,gCAAgC,OAAO,GAAG,CAAC;AAAA,MAChF,QAAQA,wBAAiB,iBAAA,CAAA,QAAO,KAAK,gCAAgC,OAAO,GAAG,CAAC;AAAA,MAChF,QAAQA,wBAAiB,iBAAA,CAAA,QAAO,KAAK,gCAAgC,OAAO,GAAG,CAAC;AAAA,MAChF,YAAYA,wBAAiB,iBAAA,CAAA,QAAO,KAAK,gCAAgC,WAAW,GAAG,CAAC;AAAA,IAAA,CACzF;AAE8F,kBAAA,MAAA,qBAAA;AAAA,MAC7F,SAASA,wBAAiB,iBAAA,CAAA,QAAO,KAAK,gCAAgC,QAAQ,GAAG,CAAC;A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gBAAA,CAAA,QAAO,KAAK,oCAAoC,OAAO,GAAG,CAAC;AAAA,MACnF,iBAAiBA,wBAAgB,gBAAA,CAAA,QAAO,KAAK,oCAAoC,gBAAgB,GAAG,CAAC;AAAA,MACrG,QAAQA,wBAAgB,gBAAA,CAAA,QAAO,KAAK,oCAAoC,OAAO,GAAG,CAAC;AAAA,MACnF,QAAQA,wBAAgB,gBAAA,CAAA,QAAO,KAAK,oCAAoC,OAAO,GAAG,CAAC;AAAA,MACnF,QAAQA,wBAAgB,gBAAA,CAAA,QAAO,KAAK,oCAAoC,OAAO,GAAG,CAAC;AAAA,MACnF,YAAYA,wBAAgB,gBAAA,CAAA,QAAO,KAAK,oCAAoC,WAAW,GAAG,CAAC;AAAA,IAAA,CAC5F;AAxEC,SAAK,uCAAuC,IAAIC,qCAAA,qCAAqC,KAAK,cAAc,KAAK,MAAM;AAC9G,SAAA,sCAAsC,IAAIC,oCAAAA,oCAAoC,KAAK,cAAc,KAAK,QAAQ,KAAK,aAAa;AACrI,SAAK,iCAAiC,IAAIC,8DAA+B,KAAK,MAAM;AAC/E,SAAA,iCAAiC,IAAIC,+BAAAA,+BAA+B,KAAK,QAAQ,KAAK,eAAe,KAAK,YAAY;AAC3H,SAAK,kCAAkC,IAAIC,gEAAgC,KAAK,MAAM;AAAA,EAAA;AAAA,EAGhF,OAAO,EAAE,QAAQ,UAA+B;AACtD,QAAI,KAAK,KAAK,OAAO,IAAI,MAAM,QAAW;AACpC,WAAA,cAAc,cAAc,OAAO,MAAM,KAAK,KAAK,OAAO,IAAI,CAAsB;AAAA,IAAA;AAEnF,WAAA,QAAQ,QAAQ,EAAE;AAAA,EAAA;AA8D3B;;"}
1
+ {"version":3,"file":"SqlUpdateInputProcessor.cjs","sources":["../../../../../../packages/engine-content-api/src/mapper/update/SqlUpdateInputProcessor.ts"],"sourcesContent":["import { Input, Model, Value } from '@contember/schema'\nimport { Mapper } from '../Mapper'\nimport { UpdateBuilder } from './UpdateBuilder'\nimport { hasManyProcessor, hasOneProcessor } from '../MutationProcessorHelper'\nimport { OneHasOneInverseUpdateInputProcessor } from './relations/OneHasOneInverseUpdateInputProcessor'\nimport { OneHasOneOwningUpdateInputProcessor } from './relations/OneHasOneOwningUpdateInputProcessor'\nimport { OneHasManyUpdateInputProcessor } from './relations/OneHasManyUpdateInputProcessor'\nimport { ManyHasManyUpdateInputProcessor } from './relations/ManyHasManyUpdateInputProcessor'\nimport { UpdateInputProcessor } from '../../inputProcessing'\nimport { MutationResultList } from '../Result'\nimport { ManyHasOneUpdateInputProcessor } from './relations/ManyHasOneUpdateInputProcessor'\nimport { MapperInput } from '../types'\n\nexport type SqlUpdateInputProcessorResult = MutationResultList | ((ctx: { primary: Input.PrimaryValue}) => Promise<MutationResultList>)\n\nexport class SqlUpdateInputProcessor implements UpdateInputProcessor<SqlUpdateInputProcessorResult> {\n\tprivate oneHasOneInverseUpdateInputProcessor: OneHasOneInverseUpdateInputProcessor\n\tprivate oneHasOneOwningUpdateInputProcessor: OneHasOneOwningUpdateInputProcessor\n\tprivate oneHasManyUpdateInputProcessor: OneHasManyUpdateInputProcessor\n\tprivate manyHasOneUpdateInputProcessor: ManyHasOneUpdateInputProcessor\n\tprivate manyHasManyUpdateInputProcessor: ManyHasManyUpdateInputProcessor\n\n\tconstructor(\n\t\tprivate readonly primaryValue: Input.PrimaryValue,\n\t\tprivate readonly data: MapperInput.UpdateDataInput,\n\t\tprivate readonly updateBuilder: UpdateBuilder,\n\t\tprivate readonly mapper: Mapper,\n\t) {\n\t\tthis.oneHasOneInverseUpdateInputProcessor = new OneHasOneInverseUpdateInputProcessor(this.primaryValue, this.mapper)\n\t\tthis.oneHasOneOwningUpdateInputProcessor = new OneHasOneOwningUpdateInputProcessor(this.primaryValue, this.mapper, this.updateBuilder)\n\t\tthis.oneHasManyUpdateInputProcessor = new OneHasManyUpdateInputProcessor(this.mapper)\n\t\tthis.manyHasOneUpdateInputProcessor = new ManyHasOneUpdateInputProcessor(this.mapper, this.updateBuilder, this.primaryValue)\n\t\tthis.manyHasManyUpdateInputProcessor = new ManyHasManyUpdateInputProcessor(this.mapper)\n\t}\n\n\tpublic column({ entity, column }: Model.ColumnContext) {\n\t\tif (this.data[column.name] !== undefined) {\n\t\t\tthis.updateBuilder.addFieldValue(column.name, this.data[column.name] as Value.AtomicValue)\n\t\t}\n\t\treturn Promise.resolve([])\n\t}\n\n\tmanyHasManyInverse: UpdateInputProcessor<SqlUpdateInputProcessorResult>['manyHasManyInverse'] = {\n\t\tconnect: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\tmanyHasManyOwning: UpdateInputProcessor<SqlUpdateInputProcessorResult>['manyHasManyOwning'] = {\n\t\tconnect: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\tmanyHasOne: UpdateInputProcessor<SqlUpdateInputProcessorResult>['manyHasOne'] = {\n\t\tconnect: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\toneHasMany: UpdateInputProcessor<SqlUpdateInputProcessorResult>['oneHasMany'] = {\n\t\tconnect: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\toneHasOneInverse: UpdateInputProcessor<SqlUpdateInputProcessorResult>['oneHasOneInverse'] = {\n\t\tconnect: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\toneHasOneOwning: UpdateInputProcessor<SqlUpdateInputProcessorResult>['oneHasOneOwning'] = {\n\t\tconnect: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.disconnect(ctx)),\n\t}\n}\n"],"names":["hasManyProcessor","hasOneProcessor","OneHasOneInverseUpdateInputProcessor","OneHasOneOwningUpdateInputProcessor","OneHasManyUpdateInputProcessor","ManyHasOneUpdateInputProcessor","ManyHasManyUpdateInputProcessor"],"mappings":";;;;;;;;;;;AAeO,MAAM,wBAAuF;AAAA,EAOnG,YACkB,cACA,MACA,eACA,QAChB;AAJgB,SAAA,eAAA;AACA,SAAA,OAAA;AACA,SAAA,gBAAA;AACA,SAAA,SAAA;AAVV,kBAAA,MAAA,sCAAA;AACA,kBAAA,MAAA,qCAAA;AACA,k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AG,CAAC;AAAA,IAAA,CAC5F;AAxEC,SAAK,uCAAuC,IAAIC,qCAAA,qCAAqC,KAAK,cAAc,KAAK,MAAM;AAC9G,SAAA,sCAAsC,IAAIC,oCAAAA,oCAAoC,KAAK,cAAc,KAAK,QAAQ,KAAK,aAAa;AACrI,SAAK,iCAAiC,IAAIC,8DAA+B,KAAK,MAAM;AAC/E,SAAA,iCAAiC,IAAIC,+BAAAA,+BAA+B,KAAK,QAAQ,KAAK,eAAe,KAAK,YAAY;AAC3H,SAAK,kCAAkC,IAAIC,gEAAgC,KAAK,MAAM;AAAA,EAAA;AAAA,EAGhF,OAAO,EAAE,QAAQ,UAA+B;AACtD,QAAI,KAAK,KAAK,OAAO,IAAI,MAAM,QAAW;AACpC,WAAA,cAAc,cAAc,OAAO,MAAM,KAAK,KAAK,OAAO,IAAI,CAAsB;AAAA,IAAA;AAEnF,WAAA,QAAQ,QAAQ,EAAE;AAAA,EAAA;AA8D3B;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SqlUpdateInputProcessor.js","sources":["../../../../../../packages/engine-content-api/src/mapper/update/SqlUpdateInputProcessor.ts"],"sourcesContent":["import { Input, Model, Value } from '@contember/schema'\nimport { Mapper } from '../Mapper'\nimport { UpdateBuilder } from './UpdateBuilder'\nimport { hasManyProcessor, hasOneProcessor } from '../MutationProcessorHelper'\nimport { OneHasOneInverseUpdateInputProcessor } from './relations/OneHasOneInverseUpdateInputProcessor'\nimport { OneHasOneOwningUpdateInputProcessor } from './relations/OneHasOneOwningUpdateInputProcessor'\nimport { OneHasManyUpdateInputProcessor } from './relations/OneHasManyUpdateInputProcessor'\nimport { ManyHasManyUpdateInputProcessor } from './relations/ManyHasManyUpdateInputProcessor'\nimport { UpdateInputProcessor } from '../../inputProcessing'\nimport { MutationResultList } from '../Result'\nimport { ManyHasOneUpdateInputProcessor } from './relations/ManyHasOneUpdateInputProcessor'\n\nexport type SqlUpdateInputProcessorResult = MutationResultList | ((ctx: { primary: Input.PrimaryValue}) => Promise<MutationResultList>)\n\nexport class SqlUpdateInputProcessor implements UpdateInputProcessor<SqlUpdateInputProcessorResult> {\n\tprivate oneHasOneInverseUpdateInputProcessor: OneHasOneInverseUpdateInputProcessor\n\tprivate oneHasOneOwningUpdateInputProcessor: OneHasOneOwningUpdateInputProcessor\n\tprivate oneHasManyUpdateInputProcessor: OneHasManyUpdateInputProcessor\n\tprivate manyHasOneUpdateInputProcessor: ManyHasOneUpdateInputProcessor\n\tprivate manyHasManyUpdateInputProcessor: ManyHasManyUpdateInputProcessor\n\n\tconstructor(\n\t\tprivate readonly primaryValue: Input.PrimaryValue,\n\t\tprivate readonly data: Input.UpdateDataInput,\n\t\tprivate readonly updateBuilder: UpdateBuilder,\n\t\tprivate readonly mapper: Mapper,\n\t) {\n\t\tthis.oneHasOneInverseUpdateInputProcessor = new OneHasOneInverseUpdateInputProcessor(this.primaryValue, this.mapper)\n\t\tthis.oneHasOneOwningUpdateInputProcessor = new OneHasOneOwningUpdateInputProcessor(this.primaryValue, this.mapper, this.updateBuilder)\n\t\tthis.oneHasManyUpdateInputProcessor = new OneHasManyUpdateInputProcessor(this.mapper)\n\t\tthis.manyHasOneUpdateInputProcessor = new ManyHasOneUpdateInputProcessor(this.mapper, this.updateBuilder, this.primaryValue)\n\t\tthis.manyHasManyUpdateInputProcessor = new ManyHasManyUpdateInputProcessor(this.mapper)\n\t}\n\n\tpublic column({ entity, column }: Model.ColumnContext) {\n\t\tif (this.data[column.name] !== undefined) {\n\t\t\tthis.updateBuilder.addFieldValue(column.name, this.data[column.name] as Value.AtomicValue)\n\t\t}\n\t\treturn Promise.resolve([])\n\t}\n\n\tmanyHasManyInverse: UpdateInputProcessor<SqlUpdateInputProcessorResult>['manyHasManyInverse'] = {\n\t\tconnect: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\tmanyHasManyOwning: UpdateInputProcessor<SqlUpdateInputProcessorResult>['manyHasManyOwning'] = {\n\t\tconnect: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\tmanyHasOne: UpdateInputProcessor<SqlUpdateInputProcessorResult>['manyHasOne'] = {\n\t\tconnect: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\toneHasMany: UpdateInputProcessor<SqlUpdateInputProcessorResult>['oneHasMany'] = {\n\t\tconnect: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\toneHasOneInverse: UpdateInputProcessor<SqlUpdateInputProcessorResult>['oneHasOneInverse'] = {\n\t\tconnect: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\toneHasOneOwning: UpdateInputProcessor<SqlUpdateInputProcessorResult>['oneHasOneOwning'] = {\n\t\tconnect: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.disconnect(ctx)),\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;AAcO,MAAM,wBAAuF;AAAA,EAOnG,YACkB,cACA,MACA,eACA,QAChB;AAJgB,SAAA,eAAA;AACA,SAAA,OAAA;AACA,SAAA,gBAAA;AACA,SAAA,SAAA;AAVV,kBAAA,MAAA,sCAAA;AACA,kBAAA,MAAA,qCAAA;AACA,kBAAA,MAAA,gCAAA;AACA,kBAAA,MAAA,gCAAA;AACA,kBAAA,MAAA,iCAAA;AAsBwF,kBAAA,MAAA,sBAAA;AAAA,MAC/F,SAAS,iBAAiB,CAAA,QAAO,KAAK,gCAAgC,QAAQ,GAAG,CAAC;AAAA,MAClF,QAAQ,iBAAiB,CAAA,QAAO,KAAK,gCAAgC,OAAO,GAAG,CAAC;AAAA,MAChF,iBAAiB,iBAAiB,CAAA,QAAO,KAAK,gCAAgC,gBAAgB,GAAG,CAAC;AAAA,MAClG,QAAQ,iBAAiB,CAAA,QAAO,KAAK,gCAAgC,OAAO,GAAG,CAAC;AAAA,MAChF,QAAQ,iBAAiB,CAAA,QAAO,KAAK,gCAAgC,OAAO,GAAG,CAAC;AAAA,MAChF,QAAQ,iBAAiB,CAAA,QAAO,KAAK,gCAAgC,OAAO,GAAG,CAAC;AAAA,MAChF,YAAY,iBAAiB,CAAA,QAAO,KAAK,gCAAgC,WA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AA,QAAO,KAAK,oCAAoC,gBAAgB,GAAG,CAAC;AAAA,MACrG,QAAQ,gBAAgB,CAAA,QAAO,KAAK,oCAAoC,OAAO,GAAG,CAAC;AAAA,MACnF,QAAQ,gBAAgB,CAAA,QAAO,KAAK,oCAAoC,OAAO,GAAG,CAAC;AAAA,MACnF,QAAQ,gBAAgB,CAAA,QAAO,KAAK,oCAAoC,OAAO,GAAG,CAAC;AAAA,MACnF,YAAY,gBAAgB,CAAA,QAAO,KAAK,oCAAoC,WAAW,GAAG,CAAC;AAAA,IAAA,CAC5F;AAxEC,SAAK,uCAAuC,IAAI,qCAAqC,KAAK,cAAc,KAAK,MAAM;AAC9G,SAAA,sCAAsC,IAAI,oCAAoC,KAAK,cAAc,KAAK,QAAQ,KAAK,aAAa;AACrI,SAAK,iCAAiC,IAAI,+BAA+B,KAAK,MAAM;AAC/E,SAAA,iCAAiC,IAAI,+BAA+B,KAAK,QAAQ,KAAK,eAAe,KAAK,YAAY;AAC3H,SAAK,kCAAkC,IAAI,gCAAgC,KAAK,MAAM;AAAA,EAAA;AAAA,EAGhF,OAAO,EAAE,QAAQ,UAA+B;AACtD,QAAI,KAAK,KAAK,OAAO,IAAI,MAAM,QAAW;AACpC,WAAA,cAAc,cAAc,OAAO,MAAM,KAAK,KAAK,OAAO,IAAI,CAAsB;AAAA,IAAA;AAEnF,WAAA,QAAQ,QAAQ,EAAE;AAAA,EAAA;AA8D3B;"}
1
+ {"version":3,"file":"SqlUpdateInputProcessor.js","sources":["../../../../../../packages/engine-content-api/src/mapper/update/SqlUpdateInputProcessor.ts"],"sourcesContent":["import { Input, Model, Value } from '@contember/schema'\nimport { Mapper } from '../Mapper'\nimport { UpdateBuilder } from './UpdateBuilder'\nimport { hasManyProcessor, hasOneProcessor } from '../MutationProcessorHelper'\nimport { OneHasOneInverseUpdateInputProcessor } from './relations/OneHasOneInverseUpdateInputProcessor'\nimport { OneHasOneOwningUpdateInputProcessor } from './relations/OneHasOneOwningUpdateInputProcessor'\nimport { OneHasManyUpdateInputProcessor } from './relations/OneHasManyUpdateInputProcessor'\nimport { ManyHasManyUpdateInputProcessor } from './relations/ManyHasManyUpdateInputProcessor'\nimport { UpdateInputProcessor } from '../../inputProcessing'\nimport { MutationResultList } from '../Result'\nimport { ManyHasOneUpdateInputProcessor } from './relations/ManyHasOneUpdateInputProcessor'\nimport { MapperInput } from '../types'\n\nexport type SqlUpdateInputProcessorResult = MutationResultList | ((ctx: { primary: Input.PrimaryValue}) => Promise<MutationResultList>)\n\nexport class SqlUpdateInputProcessor implements UpdateInputProcessor<SqlUpdateInputProcessorResult> {\n\tprivate oneHasOneInverseUpdateInputProcessor: OneHasOneInverseUpdateInputProcessor\n\tprivate oneHasOneOwningUpdateInputProcessor: OneHasOneOwningUpdateInputProcessor\n\tprivate oneHasManyUpdateInputProcessor: OneHasManyUpdateInputProcessor\n\tprivate manyHasOneUpdateInputProcessor: ManyHasOneUpdateInputProcessor\n\tprivate manyHasManyUpdateInputProcessor: ManyHasManyUpdateInputProcessor\n\n\tconstructor(\n\t\tprivate readonly primaryValue: Input.PrimaryValue,\n\t\tprivate readonly data: MapperInput.UpdateDataInput,\n\t\tprivate readonly updateBuilder: UpdateBuilder,\n\t\tprivate readonly mapper: Mapper,\n\t) {\n\t\tthis.oneHasOneInverseUpdateInputProcessor = new OneHasOneInverseUpdateInputProcessor(this.primaryValue, this.mapper)\n\t\tthis.oneHasOneOwningUpdateInputProcessor = new OneHasOneOwningUpdateInputProcessor(this.primaryValue, this.mapper, this.updateBuilder)\n\t\tthis.oneHasManyUpdateInputProcessor = new OneHasManyUpdateInputProcessor(this.mapper)\n\t\tthis.manyHasOneUpdateInputProcessor = new ManyHasOneUpdateInputProcessor(this.mapper, this.updateBuilder, this.primaryValue)\n\t\tthis.manyHasManyUpdateInputProcessor = new ManyHasManyUpdateInputProcessor(this.mapper)\n\t}\n\n\tpublic column({ entity, column }: Model.ColumnContext) {\n\t\tif (this.data[column.name] !== undefined) {\n\t\t\tthis.updateBuilder.addFieldValue(column.name, this.data[column.name] as Value.AtomicValue)\n\t\t}\n\t\treturn Promise.resolve([])\n\t}\n\n\tmanyHasManyInverse: UpdateInputProcessor<SqlUpdateInputProcessorResult>['manyHasManyInverse'] = {\n\t\tconnect: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\tmanyHasManyOwning: UpdateInputProcessor<SqlUpdateInputProcessorResult>['manyHasManyOwning'] = {\n\t\tconnect: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasManyProcessor(ctx => this.manyHasManyUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\tmanyHasOne: UpdateInputProcessor<SqlUpdateInputProcessorResult>['manyHasOne'] = {\n\t\tconnect: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasOneProcessor(ctx => this.manyHasOneUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\toneHasMany: UpdateInputProcessor<SqlUpdateInputProcessorResult>['oneHasMany'] = {\n\t\tconnect: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasManyProcessor(ctx => this.oneHasManyUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\toneHasOneInverse: UpdateInputProcessor<SqlUpdateInputProcessorResult>['oneHasOneInverse'] = {\n\t\tconnect: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasOneProcessor(ctx => this.oneHasOneInverseUpdateInputProcessor.disconnect(ctx)),\n\t}\n\n\toneHasOneOwning: UpdateInputProcessor<SqlUpdateInputProcessorResult>['oneHasOneOwning'] = {\n\t\tconnect: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.connect(ctx)),\n\t\tcreate: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.create(ctx)),\n\t\tconnectOrCreate: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.connectOrCreate(ctx)),\n\t\tupdate: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.update(ctx)),\n\t\tupsert: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.upsert(ctx)),\n\t\tdelete: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.delete(ctx)),\n\t\tdisconnect: hasOneProcessor(ctx => this.oneHasOneOwningUpdateInputProcessor.disconnect(ctx)),\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;AAeO,MAAM,wBAAuF;AAAA,EAOnG,YACkB,cACA,MACA,eACA,QAChB;AAJgB,SAAA,eAAA;AACA,SAAA,OAAA;AACA,SAAA,gBAAA;AACA,SAAA,SAAA;AAVV,kBAAA,MAAA,sCAAA;AACA,kBAAA,MAAA,qCAAA;AACA,kBAAA,MAAA,gCAAA;AACA,kBAAA,MAAA,gCAAA;AACA,kBAAA,MAAA,iCAAA;AAsBwF,kBAAA,MAAA,sBAAA;AAAA,MAC/F,SAAS,iBAAiB,CAAA,QAAO,KAAK,gCAAgC,QAAQ,GAAG,CAAC;AAAA,MAClF,QAAQ,iBAAiB,CAAA,QAAO,KAAK,gCAAgC,OAAO,GAAG,CAAC;AAAA,MAChF,iBAAiB,iBAAiB,CAAA,QAAO,KAAK,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icField(this, "oldWhere", { and: [] });
23
23
  }
24
24
  addFieldValue(fieldName, value) {
25
+ if (value === void 0) {
26
+ return;
27
+ }
25
28
  const columnName = schemaUtils.getColumnName(this.schema, this.entity, fieldName);
26
29
  const columnType = schemaUtils.getColumnType(this.schema, this.entity, fieldName);
27
- const resolvedValue = ColumnValue.resolveGenericValue(value);
28
- this.rowData.set(columnName, { columnName, value: resolvedValue, columnType, fieldName });
29
- return resolvedValue;
30
+ this.rowData.set(columnName, { columnName, value, columnType, fieldName });
30
31
  }
31
32
  addNewWhere(where) {
32
33
  this.newWhere.and.push(where);
@@ -41,14 +42,20 @@ class UpdateBuilder {
41
42
  }
42
43
  async execute(mapper) {
43
44
  try {
44
- const resolvedData = await ColumnValue.resolveRowData([...this.rowData.values()]);
45
+ const resolvedData = [...this.rowData.values()];
45
46
  if (Object.keys(resolvedData).length === 0) {
46
47
  return { values: [], affectedRows: null, executed: false };
47
48
  }
48
49
  const oldColSuffix = "_old__";
49
50
  const qb = Database.UpdateBuilder.create().with("newData_", (qb2) => {
50
51
  qb2 = resolvedData.reduce(
51
- (qb3, value) => qb3.select((expr) => expr.selectValue(value.resolvedValue, value.columnType), value.columnName).select(["root_", value.columnName], value.columnName + oldColSuffix),
52
+ (qb3, value) => qb3.select(
53
+ (expr) => expr.selectValue(
54
+ ColumnValue.normalizeDbValue(value.value, value.columnType),
55
+ value.columnType
56
+ ),
57
+ value.columnName
58
+ ).select(["root_", value.columnName], value.columnName + oldColSuffix),
52
59
  qb2
53
60
  );
54
61
  const columns = new Set(resolvedData.map((it) => it.columnName));
@@ -1 +1 @@
1
- {"version":3,"file":"UpdateBuilder.cjs","sources":["../../../../../../packages/engine-content-api/src/mapper/update/UpdateBuilder.ts"],"sourcesContent":["import { tuple } from '../../utils'\nimport { Acl, Input, Model, Value } from '@contember/schema'\nimport { acceptEveryFieldVisitor, getColumnName, getColumnType } from '@contember/schema-utils'\nimport { Operator, QueryBuilder, UpdateBuilder as DbUpdateBuilder, Value as DbValue } from '@contember/database'\nimport { PathFactory, WhereBuilder } from '../select'\nimport { ColumnValue, ResolvedColumnValue, resolveGenericValue, resolveRowData } from '../ColumnValue'\nimport { PredicateFactory } from '../../acl'\nimport { AfterUpdateEvent, BeforeUpdateEvent } from '../EventManager'\nimport { Mapper } from '../Mapper'\n\nexport interface UpdateResult {\n\tvalues: ResolvedColumnValue[]\n\texecuted: boolean\n\taffectedRows: number | null\n}\n\nexport class UpdateBuilder {\n\tprivate rowData: Map<string, ColumnValue> = new Map()\n\n\tprivate newWhere: { and: Input.OptionalWhere[] } = { and: [] }\n\tprivate oldWhere: { and: Input.OptionalWhere[] } = { and: [] }\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly entity: Model.Entity,\n\t\tprivate readonly whereBuilder: WhereBuilder,\n\t\tprivate readonly primary: Input.PrimaryValue,\n\t\tprivate readonly pathFactory: PathFactory,\n\t\tprivate readonly predicateFactory: PredicateFactory,\n\t) {}\n\n\tpublic addFieldValue(\n\t\tfieldName: string,\n\t\tvalue: Value.GenericValueLike<Value.AtomicValue<undefined>>,\n\t): Promise<Value.AtomicValue<undefined>> {\n\t\tconst columnName = getColumnName(this.schema, this.entity, fieldName)\n\t\tconst columnType = getColumnType(this.schema, this.entity, fieldName)\n\t\tconst resolvedValue = resolveGenericValue(value)\n\t\tthis.rowData.set(columnName, { columnName, value: resolvedValue, columnType, fieldName })\n\t\treturn resolvedValue\n\t}\n\n\tpublic addNewWhere(where: Input.OptionalWhere): void {\n\t\tthis.newWhere.and.push(where)\n\t}\n\n\tpublic addOldWhere(where: Input.OptionalWhere): void {\n\t\tthis.oldWhere.and.push(where)\n\t}\n\n\tpublic addPredicates(fields: string[]): void {\n\t\tconst predicate = this.predicateFactory.create(this.entity, Acl.Operation.update, fields)\n\t\tthis.addNewWhere(predicate)\n\t\tthis.addOldWhere(predicate)\n\t}\n\n\tpublic async execute(mapper: Mapper): Promise<UpdateResult> {\n\t\ttry {\n\t\t\tconst resolvedData = await resolveRowData([...this.rowData.values()])\n\t\t\tif (Object.keys(resolvedData).length === 0) {\n\t\t\t\treturn { values: [], affectedRows: null, executed: false }\n\t\t\t}\n\t\t\tconst oldColSuffix = '_old__'\n\n\t\t\tconst qb = DbUpdateBuilder.create()\n\t\t\t\t.with('newData_', qb => {\n\t\t\t\t\tqb = resolvedData.reduce(\n\t\t\t\t\t\t(qb, value) =>\n\t\t\t\t\t\t\tqb\n\t\t\t\t\t\t\t\t.select(expr => expr.selectValue(value.resolvedValue as DbValue, value.columnType), value.columnName)\n\t\t\t\t\t\t\t\t.select(['root_', value.columnName], value.columnName + oldColSuffix),\n\t\t\t\t\t\tqb,\n\t\t\t\t\t)\n\t\t\t\t\tconst columns = new Set(resolvedData.map(it => it.columnName))\n\t\t\t\t\tconst allColumns: string[] = Object.values(\n\t\t\t\t\t\tacceptEveryFieldVisitor(this.schema, this.entity, {\n\t\t\t\t\t\t\tvisitColumn: ({ column }) => column.columnName,\n\t\t\t\t\t\t\tvisitManyHasOne: ({ relation }) => relation.joiningColumn.columnName,\n\t\t\t\t\t\t\tvisitOneHasOneOwning: ({ relation }) => relation.joiningColumn.columnName,\n\t\t\t\t\t\t\tvisitManyHasManyInverse: () => null,\n\t\t\t\t\t\t\tvisitManyHasManyOwning: () => null,\n\t\t\t\t\t\t\tvisitOneHasOneInverse: () => null,\n\t\t\t\t\t\t\tvisitOneHasMany: () => null,\n\t\t\t\t\t\t}),\n\t\t\t\t\t).filter((it): it is string => it !== null)\n\n\t\t\t\t\tconst remainingColumns = allColumns.filter(it => !columns.has(it))\n\t\t\t\t\tqb = qb.from(this.entity.tableName, 'root_')\n\n\t\t\t\t\tqb = remainingColumns.reduce((qb, columnName) => qb.select(['root_', columnName]), qb)\n\n\t\t\t\t\tqb = this.whereBuilder.build(qb, this.entity, this.pathFactory.create([]), {\n\t\t\t\t\t\tand: [{\n\t\t\t\t\t\t\t[this.entity.primary]: { eq: this.primary },\n\t\t\t\t\t\t}, this.oldWhere],\n\t\t\t\t\t})\n\n\t\t\t\t\treturn qb\n\t\t\t\t})\n\t\t\t\t.table(this.entity.tableName)\n\t\t\t\t.values(\n\t\t\t\t\tresolvedData.reduce<QueryBuilder.ColumnExpressionMap>(\n\t\t\t\t\t\t(result: object, item) => ({\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\t[item.columnName]: expr => expr.select(['newData_', item.columnName]),\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{},\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t\t.returning(...resolvedData.map(it => it.columnName + oldColSuffix))\n\t\t\t\t.from(qb => {\n\t\t\t\t\tqb = qb.from('newData_')\n\t\t\t\t\tconst col1 = tuple(this.entity.tableName, this.entity.primaryColumn)\n\t\t\t\t\tconst col2 = tuple('newData_', this.entity.primaryColumn)\n\t\t\t\t\tqb = qb.where(expr => expr.compareColumns(col1, Operator.eq, col2))\n\t\t\t\t\tqb = this.whereBuilder.build(qb, this.entity, this.pathFactory.create([], 'newData_'), this.newWhere)\n\t\t\t\t\treturn qb\n\t\t\t\t})\n\n\n\t\t\tconst beforeEvent = new BeforeUpdateEvent(this.entity, resolvedData as ResolvedColumnValue[], this.primary)\n\t\t\tawait mapper.eventManager.fire(beforeEvent)\n\n\t\t\tconst result = await qb.execute(mapper.db)\n\n\t\t\tif (result.length === 1) {\n\t\t\t\tconst eventData = (resolvedData as ResolvedColumnValue[]).map(it => ({\n\t\t\t\t\t...it,\n\t\t\t\t\told: result[0][it.columnName + oldColSuffix],\n\t\t\t\t}))\n\t\t\t\tconst afterUpdateEvent = new AfterUpdateEvent(this.entity, eventData, this.primary)\n\t\t\t\tbeforeEvent.afterEvent = afterUpdateEvent\n\t\t\t\tawait mapper.eventManager.fire(afterUpdateEvent)\n\t\t\t}\n\n\t\t\treturn { values: resolvedData as ResolvedColumnValue[], affectedRows: result.length, executed: true }\n\t\t} catch (e) {\n\t\t\tthrow e\n\t\t}\n\t}\n}\n"],"names":["schema","getColumnName","getColumnType","resolveGenericValue","Acl","resolveRowData","DbUpdateBuilder","qb","acceptEveryFieldVisitor","result","tuple","Operator","BeforeUpdateEvent","AfterUpdateEvent"],"mappings":";;;;;;;;;;;AAgBO,MAAM,cAAc;AAAA,EAM1B,YACkBA,SACA,QACA,cACA,SACA,aACA,kBAChB;AANgB,SAAA,SAAAA;AACA,SAAA,SAAA;AACA,SAAA,eAAA;AACA,SAAA,UAAA;AACA,SAAA,cAAA;AACA,SAAA,mBAAA;AAXV,kBAAA,MAAA,+BAAwC,IAAI,CAAA;AAEpD,kBAAA,MAAQ,YAA2C,EAAE,KAAK,CAAG,EAAA,CAAA;AAC7D,kBAAA,MAAQ,YAA2C,EAAE,KAAK,CAAG,EAAA,CAAA;AAAA,EAAA;AAAA,EAWtD,cACN,WACA,OACwC;AACxC,UAAM,aAAaC,YAAAA,cAAc,KAAK,QAAQ,KAAK,QAAQ,SAAS;AACpE,UAAM,aAAaC,YAAAA,cAAc,KAAK,QAAQ,KAAK,QAAQ,SAAS;AAC9D,UAAA,gBAAgBC,gCAAoB,KAAK;AAC1C,SAAA,QAAQ,IAAI,YAAY,EAAE,YAAY,OAAO,eAAe,YAAY,WAAW;AACjF,WAAA;AAAA,EAAA;AAAA,EAGD,YAAY,OAAkC;AAC/C,SAAA,SAAS,IAAI,KAAK,KAAK;AAAA,EAAA;AAAA,EAGtB,YAAY,OAAkC;AAC/C,SAAA,SAAS,IAAI,KAAK,KAAK;AAAA,EAAA;AAAA,EAGtB,cAAc,QAAwB;AACtC,UAAA,YAAY,KAAK,iBAAiB,OAAO,KAAK,QAAQC,WAAI,UAAU,QAAQ,MAAM;AACxF,SAAK,YAAY,SAAS;AAC1B,SAAK,YAAY,SAAS;AAAA,EAAA;AAAA,EAG3B,MAAa,QAAQ,QAAuC;AACvD,QAAA;AACG,YAAA,eAAe,MAAMC,2BAAe,CAAC,GAAG,KAAK,QAAQ,OAAO,CAAC,CAAC;AACpE,UAAI,OAAO,KAAK,YAAY,EAAE,W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ClF,oBAAY,aAAa;AACnB,cAAA,OAAO,aAAa,KAAK,gBAAgB;AAAA,MAAA;AAGhD,aAAO,EAAE,QAAQ,cAAuC,cAAc,OAAO,QAAQ,UAAU,KAAK;AAAA,aAC5F,GAAG;AACL,YAAA;AAAA,IAAA;AAAA,EACP;AAEF;;"}
1
+ {"version":3,"file":"UpdateBuilder.cjs","sources":["../../../../../../packages/engine-content-api/src/mapper/update/UpdateBuilder.ts"],"sourcesContent":["import { tuple } from '../../utils'\nimport { Acl, Input, Model, Value } from '@contember/schema'\nimport { acceptEveryFieldVisitor, getColumnName, getColumnType } from '@contember/schema-utils'\nimport { Operator, QueryBuilder, UpdateBuilder as DbUpdateBuilder, Value as DbValue } from '@contember/database'\nimport { PathFactory, WhereBuilder } from '../select'\nimport { ColumnValue, normalizeDbValue } from '../ColumnValue'\nimport { PredicateFactory } from '../../acl'\nimport { AfterUpdateEvent, BeforeUpdateEvent } from '../EventManager'\nimport { Mapper } from '../Mapper'\n\nexport interface UpdateResult {\n\tvalues: ColumnValue[]\n\texecuted: boolean\n\taffectedRows: number | null\n}\n\nexport class UpdateBuilder {\n\tprivate rowData: Map<string, ColumnValue> = new Map()\n\n\tprivate newWhere: { and: Input.OptionalWhere[] } = { and: [] }\n\tprivate oldWhere: { and: Input.OptionalWhere[] } = { and: [] }\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly entity: Model.Entity,\n\t\tprivate readonly whereBuilder: WhereBuilder,\n\t\tprivate readonly primary: Input.PrimaryValue,\n\t\tprivate readonly pathFactory: PathFactory,\n\t\tprivate readonly predicateFactory: PredicateFactory,\n\t) {}\n\n\tpublic addFieldValue(\n\t\tfieldName: string,\n\t\tvalue: Value.FieldValue | undefined,\n\t): void {\n\t\tif (value === undefined) {\n\t\t\treturn\n\t\t}\n\t\tconst columnName = getColumnName(this.schema, this.entity, fieldName)\n\t\tconst columnType = getColumnType(this.schema, this.entity, fieldName)\n\n\t\tthis.rowData.set(columnName, { columnName, value, columnType, fieldName })\n\t}\n\n\tpublic addNewWhere(where: Input.OptionalWhere): void {\n\t\tthis.newWhere.and.push(where)\n\t}\n\n\tpublic addOldWhere(where: Input.OptionalWhere): void {\n\t\tthis.oldWhere.and.push(where)\n\t}\n\n\tpublic addPredicates(fields: string[]): void {\n\t\tconst predicate = this.predicateFactory.create(this.entity, Acl.Operation.update, fields)\n\t\tthis.addNewWhere(predicate)\n\t\tthis.addOldWhere(predicate)\n\t}\n\n\tpublic async execute(mapper: Mapper): Promise<UpdateResult> {\n\t\ttry {\n\t\t\tconst resolvedData = [...this.rowData.values()]\n\t\t\tif (Object.keys(resolvedData).length === 0) {\n\t\t\t\treturn { values: [], affectedRows: null, executed: false }\n\t\t\t}\n\t\t\tconst oldColSuffix = '_old__'\n\n\t\t\tconst qb = DbUpdateBuilder.create()\n\t\t\t\t.with('newData_', qb => {\n\t\t\t\t\tqb = resolvedData.reduce(\n\t\t\t\t\t\t(qb, value) =>\n\t\t\t\t\t\t\tqb\n\t\t\t\t\t\t\t\t.select(\n\t\t\t\t\t\t\t\t\texpr => expr.selectValue(\n\t\t\t\t\t\t\t\t\t\tnormalizeDbValue(value.value, value.columnType),\n\t\t\t\t\t\t\t\t\t\tvalue.columnType,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tvalue.columnName,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.select(['root_', value.columnName], value.columnName + oldColSuffix),\n\t\t\t\t\t\tqb,\n\t\t\t\t\t)\n\t\t\t\t\tconst columns = new Set(resolvedData.map(it => it.columnName))\n\t\t\t\t\tconst allColumns: string[] = Object.values(\n\t\t\t\t\t\tacceptEveryFieldVisitor(this.schema, this.entity, {\n\t\t\t\t\t\t\tvisitColumn: ({ column }) => column.columnName,\n\t\t\t\t\t\t\tvisitManyHasOne: ({ relation }) => relation.joiningColumn.columnName,\n\t\t\t\t\t\t\tvisitOneHasOneOwning: ({ relation }) => relation.joiningColumn.columnName,\n\t\t\t\t\t\t\tvisitManyHasManyInverse: () => null,\n\t\t\t\t\t\t\tvisitManyHasManyOwning: () => null,\n\t\t\t\t\t\t\tvisitOneHasOneInverse: () => null,\n\t\t\t\t\t\t\tvisitOneHasMany: () => null,\n\t\t\t\t\t\t}),\n\t\t\t\t\t).filter((it): it is string => it !== null)\n\n\t\t\t\t\tconst remainingColumns = allColumns.filter(it => !columns.has(it))\n\t\t\t\t\tqb = qb.from(this.entity.tableName, 'root_')\n\n\t\t\t\t\tqb = remainingColumns.reduce((qb, columnName) => qb.select(['root_', columnName]), qb)\n\n\t\t\t\t\tqb = this.whereBuilder.build(qb, this.entity, this.pathFactory.create([]), {\n\t\t\t\t\t\tand: [{\n\t\t\t\t\t\t\t[this.entity.primary]: { eq: this.primary },\n\t\t\t\t\t\t}, this.oldWhere],\n\t\t\t\t\t})\n\n\t\t\t\t\treturn qb\n\t\t\t\t})\n\t\t\t\t.table(this.entity.tableName)\n\t\t\t\t.values(\n\t\t\t\t\tresolvedData.reduce<QueryBuilder.ColumnExpressionMap>(\n\t\t\t\t\t\t(result: object, item) => ({\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\t[item.columnName]: expr => expr.select(['newData_', item.columnName]),\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{},\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t\t.returning(...resolvedData.map(it => it.columnName + oldColSuffix))\n\t\t\t\t.from(qb => {\n\t\t\t\t\tqb = qb.from('newData_')\n\t\t\t\t\tconst col1 = tuple(this.entity.tableName, this.entity.primaryColumn)\n\t\t\t\t\tconst col2 = tuple('newData_', this.entity.primaryColumn)\n\t\t\t\t\tqb = qb.where(expr => expr.compareColumns(col1, Operator.eq, col2))\n\t\t\t\t\tqb = this.whereBuilder.build(qb, this.entity, this.pathFactory.create([], 'newData_'), this.newWhere)\n\t\t\t\t\treturn qb\n\t\t\t\t})\n\n\n\t\t\tconst beforeEvent = new BeforeUpdateEvent(this.entity, resolvedData, this.primary)\n\t\t\tawait mapper.eventManager.fire(beforeEvent)\n\n\t\t\tconst result = await qb.execute(mapper.db)\n\n\t\t\tif (result.length === 1) {\n\t\t\t\tconst eventData = (resolvedData).map(it => ({\n\t\t\t\t\t...it,\n\t\t\t\t\told: result[0][it.columnName + oldColSuffix],\n\t\t\t\t}))\n\t\t\t\tconst afterUpdateEvent = new AfterUpdateEvent(this.entity, eventData, this.primary)\n\t\t\t\tbeforeEvent.afterEvent = afterUpdateEvent\n\t\t\t\tawait mapper.eventManager.fire(afterUpdateEvent)\n\t\t\t}\n\n\t\t\treturn { values: resolvedData, affectedRows: result.length, executed: true }\n\t\t} catch (e) {\n\t\t\tthrow e\n\t\t}\n\t}\n}\n"],"names":["schema","getColumnName","getColumnType","Acl","DbUpdateBuilder","qb","normalizeDbValue","acceptEveryFieldVisitor","result","tuple","Operator","BeforeUpdateEvent","AfterUpdateEvent"],"mappings":";;;;;;;;;;;AAgBO,MAAM,cAAc;AAAA,EAM1B,YACkBA,SACA,QACA,cACA,SACA,aACA,kBAChB;AANgB,SAAA,SAAAA;AACA,SAAA,SAAA;AACA,SAAA,eAAA;AACA,SAAA,UAAA;AACA,SAAA,cAAA;AACA,SAAA,mBAAA;AAXV,kBAAA,MAAA,+BAAwC,IAAI,CAAA;AAEpD,kBAAA,MAAQ,YAA2C,EAAE,KAAK,CAAG,EAAA,CAAA;AAC7D,kBAAA,MAAQ,YAA2C,EAAE,KAAK,CAAG,EAAA,CAAA;AAAA,EAAA;AAAA,EAWtD,cACN,WACA,OACO;AACP,QAAI,UAAU,QAAW;AACxB;AAAA,IAAA;AAED,UAAM,aAAaC,YAAAA,cAAc,KAAK,QAAQ,KAAK,QAAQ,SAAS;AACpE,UAAM,aAAaC,YAAAA,cAAc,KAAK,QAAQ,KAAK,QAAQ,SAAS;AAE/D,SAAA,QAAQ,IAAI,YAAY,EAAE,YAAY,OAAO,YAAY,WAAW;AAAA,EAAA;AAAA,EAGnE,YAAY,OAAkC;AAC/C,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