@contember/engine-content-api 2.0.0-alpha.20 → 2.0.0-alpha.22

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 (320) hide show
  1. package/dist/development/index.cjs +1 -1
  2. package/dist/development/index.js +1 -1
  3. package/dist/development/src/input-validation/preValidation/InputPreValidator.cjs +1 -1
  4. package/dist/development/src/input-validation/preValidation/InputPreValidator.cjs.map +1 -1
  5. package/dist/development/src/input-validation/preValidation/InputPreValidator.js +1 -1
  6. package/dist/development/src/input-validation/preValidation/InputPreValidator.js.map +1 -1
  7. package/dist/development/src/inputProcessing/CreateInputVisitor.cjs +10 -10
  8. package/dist/development/src/inputProcessing/CreateInputVisitor.cjs.map +1 -1
  9. package/dist/development/src/inputProcessing/CreateInputVisitor.js +10 -10
  10. package/dist/development/src/inputProcessing/CreateInputVisitor.js.map +1 -1
  11. package/dist/development/src/inputProcessing/UpdateInputVisitor.cjs +13 -13
  12. package/dist/development/src/inputProcessing/UpdateInputVisitor.cjs.map +1 -1
  13. package/dist/development/src/inputProcessing/UpdateInputVisitor.js +13 -13
  14. package/dist/development/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
  15. package/dist/development/src/mapper/MutationProcessorHelper.cjs +10 -2
  16. package/dist/development/src/mapper/MutationProcessorHelper.cjs.map +1 -1
  17. package/dist/development/src/mapper/MutationProcessorHelper.js +10 -2
  18. package/dist/development/src/mapper/MutationProcessorHelper.js.map +1 -1
  19. package/dist/development/src/mapper/Result.cjs +10 -27
  20. package/dist/development/src/mapper/Result.cjs.map +1 -1
  21. package/dist/development/src/mapper/Result.js +10 -27
  22. package/dist/development/src/mapper/Result.js.map +1 -1
  23. package/dist/development/src/mapper/insert/InsertBuilder.cjs +1 -13
  24. package/dist/development/src/mapper/insert/InsertBuilder.cjs.map +1 -1
  25. package/dist/development/src/mapper/insert/InsertBuilder.js +1 -13
  26. package/dist/development/src/mapper/insert/InsertBuilder.js.map +1 -1
  27. package/dist/development/src/mapper/insert/Inserter.cjs +43 -21
  28. package/dist/development/src/mapper/insert/Inserter.cjs.map +1 -1
  29. package/dist/development/src/mapper/insert/Inserter.js +45 -23
  30. package/dist/development/src/mapper/insert/Inserter.js.map +1 -1
  31. package/dist/development/src/mapper/insert/SqlCreateInputProcessor.cjs +22 -76
  32. package/dist/development/src/mapper/insert/SqlCreateInputProcessor.cjs.map +1 -1
  33. package/dist/development/src/mapper/insert/SqlCreateInputProcessor.js +22 -76
  34. package/dist/development/src/mapper/insert/SqlCreateInputProcessor.js.map +1 -1
  35. package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs +45 -0
  36. package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs.map +1 -0
  37. package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js +45 -0
  38. package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js.map +1 -0
  39. package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs +42 -0
  40. package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs.map +1 -0
  41. package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js +42 -0
  42. package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js.map +1 -0
  43. package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs +37 -0
  44. package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs.map +1 -0
  45. package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js +37 -0
  46. package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js.map +1 -0
  47. package/dist/development/src/mapper/{relations → insert/relations}/OneHasOneInverseCreateInputProcessor.cjs +25 -32
  48. package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs.map +1 -0
  49. package/dist/development/src/mapper/{relations → insert/relations}/OneHasOneInverseCreateInputProcessor.js +25 -32
  50. package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js.map +1 -0
  51. package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs +67 -0
  52. package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs.map +1 -0
  53. package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js +67 -0
  54. package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js.map +1 -0
  55. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.cjs +36 -36
  56. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
  57. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.js +36 -36
  58. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
  59. package/dist/development/src/mapper/update/UpdateBuilder.cjs +2 -14
  60. package/dist/development/src/mapper/update/UpdateBuilder.cjs.map +1 -1
  61. package/dist/development/src/mapper/update/UpdateBuilder.js +2 -14
  62. package/dist/development/src/mapper/update/UpdateBuilder.js.map +1 -1
  63. package/dist/development/src/mapper/update/Updater.cjs +45 -17
  64. package/dist/development/src/mapper/update/Updater.cjs.map +1 -1
  65. package/dist/development/src/mapper/update/Updater.js +47 -19
  66. package/dist/development/src/mapper/update/Updater.js.map +1 -1
  67. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs +89 -0
  68. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -0
  69. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js +89 -0
  70. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -0
  71. package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs +89 -0
  72. package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs.map +1 -0
  73. package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js +89 -0
  74. package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js.map +1 -0
  75. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs +86 -0
  76. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -0
  77. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js +86 -0
  78. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -0
  79. package/dist/development/src/mapper/{relations → update/relations}/OneHasOneInverseUpdateInputProcessor.cjs +83 -66
  80. package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs.map +1 -0
  81. package/dist/development/src/mapper/{relations → update/relations}/OneHasOneInverseUpdateInputProcessor.js +83 -66
  82. package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js.map +1 -0
  83. package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs +187 -0
  84. package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs.map +1 -0
  85. package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js +187 -0
  86. package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js.map +1 -0
  87. package/dist/development/src/resolvers/MutationResolver.cjs +1 -1
  88. package/dist/development/src/resolvers/MutationResolver.js +1 -1
  89. package/dist/production/index.cjs +1 -1
  90. package/dist/production/index.js +1 -1
  91. package/dist/production/src/input-validation/preValidation/InputPreValidator.cjs +1 -1
  92. package/dist/production/src/input-validation/preValidation/InputPreValidator.cjs.map +1 -1
  93. package/dist/production/src/input-validation/preValidation/InputPreValidator.js +1 -1
  94. package/dist/production/src/input-validation/preValidation/InputPreValidator.js.map +1 -1
  95. package/dist/production/src/inputProcessing/CreateInputVisitor.cjs +10 -10
  96. package/dist/production/src/inputProcessing/CreateInputVisitor.cjs.map +1 -1
  97. package/dist/production/src/inputProcessing/CreateInputVisitor.js +10 -10
  98. package/dist/production/src/inputProcessing/CreateInputVisitor.js.map +1 -1
  99. package/dist/production/src/inputProcessing/UpdateInputVisitor.cjs +13 -13
  100. package/dist/production/src/inputProcessing/UpdateInputVisitor.cjs.map +1 -1
  101. package/dist/production/src/inputProcessing/UpdateInputVisitor.js +13 -13
  102. package/dist/production/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
  103. package/dist/production/src/mapper/MutationProcessorHelper.cjs +10 -2
  104. package/dist/production/src/mapper/MutationProcessorHelper.cjs.map +1 -1
  105. package/dist/production/src/mapper/MutationProcessorHelper.js +10 -2
  106. package/dist/production/src/mapper/MutationProcessorHelper.js.map +1 -1
  107. package/dist/production/src/mapper/Result.cjs +10 -27
  108. package/dist/production/src/mapper/Result.cjs.map +1 -1
  109. package/dist/production/src/mapper/Result.js +10 -27
  110. package/dist/production/src/mapper/Result.js.map +1 -1
  111. package/dist/production/src/mapper/insert/InsertBuilder.cjs +1 -13
  112. package/dist/production/src/mapper/insert/InsertBuilder.cjs.map +1 -1
  113. package/dist/production/src/mapper/insert/InsertBuilder.js +1 -13
  114. package/dist/production/src/mapper/insert/InsertBuilder.js.map +1 -1
  115. package/dist/production/src/mapper/insert/Inserter.cjs +43 -21
  116. package/dist/production/src/mapper/insert/Inserter.cjs.map +1 -1
  117. package/dist/production/src/mapper/insert/Inserter.js +45 -23
  118. package/dist/production/src/mapper/insert/Inserter.js.map +1 -1
  119. package/dist/production/src/mapper/insert/SqlCreateInputProcessor.cjs +22 -76
  120. package/dist/production/src/mapper/insert/SqlCreateInputProcessor.cjs.map +1 -1
  121. package/dist/production/src/mapper/insert/SqlCreateInputProcessor.js +22 -76
  122. package/dist/production/src/mapper/insert/SqlCreateInputProcessor.js.map +1 -1
  123. package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs +45 -0
  124. package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs.map +1 -0
  125. package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js +45 -0
  126. package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js.map +1 -0
  127. package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs +42 -0
  128. package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs.map +1 -0
  129. package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js +42 -0
  130. package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js.map +1 -0
  131. package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs +37 -0
  132. package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs.map +1 -0
  133. package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js +37 -0
  134. package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js.map +1 -0
  135. package/dist/production/src/mapper/{relations → insert/relations}/OneHasOneInverseCreateInputProcessor.cjs +25 -32
  136. package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs.map +1 -0
  137. package/dist/production/src/mapper/{relations → insert/relations}/OneHasOneInverseCreateInputProcessor.js +25 -32
  138. package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js.map +1 -0
  139. package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs +67 -0
  140. package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs.map +1 -0
  141. package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js +67 -0
  142. package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js.map +1 -0
  143. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.cjs +36 -36
  144. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
  145. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.js +36 -36
  146. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
  147. package/dist/production/src/mapper/update/UpdateBuilder.cjs +2 -14
  148. package/dist/production/src/mapper/update/UpdateBuilder.cjs.map +1 -1
  149. package/dist/production/src/mapper/update/UpdateBuilder.js +2 -14
  150. package/dist/production/src/mapper/update/UpdateBuilder.js.map +1 -1
  151. package/dist/production/src/mapper/update/Updater.cjs +45 -17
  152. package/dist/production/src/mapper/update/Updater.cjs.map +1 -1
  153. package/dist/production/src/mapper/update/Updater.js +47 -19
  154. package/dist/production/src/mapper/update/Updater.js.map +1 -1
  155. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs +89 -0
  156. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -0
  157. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js +89 -0
  158. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -0
  159. package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs +89 -0
  160. package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs.map +1 -0
  161. package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js +89 -0
  162. package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js.map +1 -0
  163. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs +86 -0
  164. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -0
  165. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js +86 -0
  166. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -0
  167. package/dist/production/src/mapper/{relations → update/relations}/OneHasOneInverseUpdateInputProcessor.cjs +83 -66
  168. package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs.map +1 -0
  169. package/dist/production/src/mapper/{relations → update/relations}/OneHasOneInverseUpdateInputProcessor.js +83 -66
  170. package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js.map +1 -0
  171. package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs +187 -0
  172. package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs.map +1 -0
  173. package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js +187 -0
  174. package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js.map +1 -0
  175. package/dist/production/src/resolvers/MutationResolver.cjs +1 -1
  176. package/dist/production/src/resolvers/MutationResolver.js +1 -1
  177. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  178. package/dist/types/input-validation/preValidation/InputPreValidator.d.ts.map +1 -1
  179. package/dist/types/inputProcessing/CreateInputVisitor.d.ts +8 -8
  180. package/dist/types/inputProcessing/CreateInputVisitor.d.ts.map +1 -1
  181. package/dist/types/inputProcessing/UpdateInputVisitor.d.ts +8 -8
  182. package/dist/types/inputProcessing/UpdateInputVisitor.d.ts.map +1 -1
  183. package/dist/types/mapper/MutationProcessorHelper.d.ts +2 -2
  184. package/dist/types/mapper/MutationProcessorHelper.d.ts.map +1 -1
  185. package/dist/types/mapper/Result.d.ts +11 -5
  186. package/dist/types/mapper/Result.d.ts.map +1 -1
  187. package/dist/types/mapper/insert/InsertBuilder.d.ts +3 -7
  188. package/dist/types/mapper/insert/InsertBuilder.d.ts.map +1 -1
  189. package/dist/types/mapper/insert/Inserter.d.ts +0 -1
  190. package/dist/types/mapper/insert/Inserter.d.ts.map +1 -1
  191. package/dist/types/mapper/insert/SqlCreateInputProcessor.d.ts +11 -8
  192. package/dist/types/mapper/insert/SqlCreateInputProcessor.d.ts.map +1 -1
  193. package/dist/types/mapper/insert/relations/ManyHasManyCreateInputProcessor.d.ts +24 -0
  194. package/dist/types/mapper/insert/relations/ManyHasManyCreateInputProcessor.d.ts.map +1 -0
  195. package/dist/types/mapper/insert/relations/ManyHasOneCreateInputProcessor.d.ts +23 -0
  196. package/dist/types/mapper/insert/relations/ManyHasOneCreateInputProcessor.d.ts.map +1 -0
  197. package/dist/types/mapper/insert/relations/OneHasManyCreateInputProcessor.d.ts +26 -0
  198. package/dist/types/mapper/insert/relations/OneHasManyCreateInputProcessor.d.ts.map +1 -0
  199. package/dist/types/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.d.ts +29 -0
  200. package/dist/types/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.d.ts.map +1 -0
  201. package/dist/types/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.d.ts +24 -0
  202. package/dist/types/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.d.ts.map +1 -0
  203. package/dist/types/mapper/update/SqlUpdateInputProcessor.d.ts +10 -7
  204. package/dist/types/mapper/update/SqlUpdateInputProcessor.d.ts.map +1 -1
  205. package/dist/types/mapper/update/UpdateBuilder.d.ts +2 -6
  206. package/dist/types/mapper/update/UpdateBuilder.d.ts.map +1 -1
  207. package/dist/types/mapper/update/Updater.d.ts +0 -1
  208. package/dist/types/mapper/update/Updater.d.ts.map +1 -1
  209. package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts +46 -0
  210. package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts.map +1 -0
  211. package/dist/types/mapper/update/relations/ManyHasOneUpdateInputProcessor.d.ts +40 -0
  212. package/dist/types/mapper/update/relations/ManyHasOneUpdateInputProcessor.d.ts.map +1 -0
  213. package/dist/types/mapper/update/relations/OneHasManyUpdateInputProcessor.d.ts +46 -0
  214. package/dist/types/mapper/update/relations/OneHasManyUpdateInputProcessor.d.ts.map +1 -0
  215. package/dist/types/mapper/{relations → update/relations}/OneHasOneInverseUpdateInputProcessor.d.ts +17 -13
  216. package/dist/types/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.d.ts.map +1 -0
  217. package/dist/types/mapper/{relations → update/relations}/OneHasOneOwningUpdateInputProcessor.d.ts +19 -16
  218. package/dist/types/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.d.ts.map +1 -0
  219. package/dist/types/tsconfig.tsbuildinfo +1 -1
  220. package/package.json +10 -10
  221. package/src/input-validation/preValidation/InputPreValidator.ts +3 -5
  222. package/src/inputProcessing/CreateInputVisitor.ts +14 -14
  223. package/src/inputProcessing/UpdateInputVisitor.ts +17 -17
  224. package/src/mapper/MutationProcessorHelper.ts +16 -8
  225. package/src/mapper/Result.ts +11 -47
  226. package/src/mapper/insert/InsertBuilder.ts +8 -22
  227. package/src/mapper/insert/Inserter.ts +53 -40
  228. package/src/mapper/insert/SqlCreateInputProcessor.ts +35 -88
  229. package/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.ts +59 -0
  230. package/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.ts +57 -0
  231. package/src/mapper/insert/relations/OneHasManyCreateInputProcessor.ts +50 -0
  232. package/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.ts +91 -0
  233. package/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.ts +87 -0
  234. package/src/mapper/update/SqlUpdateInputProcessor.ts +48 -46
  235. package/src/mapper/update/UpdateBuilder.ts +9 -23
  236. package/src/mapper/update/Updater.ts +53 -34
  237. package/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.ts +116 -0
  238. package/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.ts +125 -0
  239. package/src/mapper/update/relations/OneHasManyUpdateInputProcessor.ts +111 -0
  240. package/src/mapper/{relations → update/relations}/OneHasOneInverseUpdateInputProcessor.ts +93 -73
  241. package/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.ts +243 -0
  242. package/tests/cases/integration/graphQlRequests/insert/oneHasMany/create.test.ts +8 -8
  243. package/tests/cases/integration/graphQlRequests/update/oneHasMany/connectOrCreate.test.ts +4 -4
  244. package/dist/development/src/mapper/DataManipulationBuilder.cjs +0 -5
  245. package/dist/development/src/mapper/DataManipulationBuilder.cjs.map +0 -1
  246. package/dist/development/src/mapper/DataManipulationBuilder.js +0 -5
  247. package/dist/development/src/mapper/DataManipulationBuilder.js.map +0 -1
  248. package/dist/development/src/mapper/relations/ManyHasManyInputProcessor.cjs +0 -75
  249. package/dist/development/src/mapper/relations/ManyHasManyInputProcessor.cjs.map +0 -1
  250. package/dist/development/src/mapper/relations/ManyHasManyInputProcessor.js +0 -75
  251. package/dist/development/src/mapper/relations/ManyHasManyInputProcessor.js.map +0 -1
  252. package/dist/development/src/mapper/relations/ManyHasOneInputProcessor.cjs +0 -114
  253. package/dist/development/src/mapper/relations/ManyHasOneInputProcessor.cjs.map +0 -1
  254. package/dist/development/src/mapper/relations/ManyHasOneInputProcessor.js +0 -114
  255. package/dist/development/src/mapper/relations/ManyHasOneInputProcessor.js.map +0 -1
  256. package/dist/development/src/mapper/relations/OneHasManyInputProcessor.cjs +0 -72
  257. package/dist/development/src/mapper/relations/OneHasManyInputProcessor.cjs.map +0 -1
  258. package/dist/development/src/mapper/relations/OneHasManyInputProcessor.js +0 -72
  259. package/dist/development/src/mapper/relations/OneHasManyInputProcessor.js.map +0 -1
  260. package/dist/development/src/mapper/relations/OneHasOneInverseCreateInputProcessor.cjs.map +0 -1
  261. package/dist/development/src/mapper/relations/OneHasOneInverseCreateInputProcessor.js.map +0 -1
  262. package/dist/development/src/mapper/relations/OneHasOneInverseUpdateInputProcessor.cjs.map +0 -1
  263. package/dist/development/src/mapper/relations/OneHasOneInverseUpdateInputProcessor.js.map +0 -1
  264. package/dist/development/src/mapper/relations/OneHasOneOwningCreateInputProcessor.cjs +0 -71
  265. package/dist/development/src/mapper/relations/OneHasOneOwningCreateInputProcessor.cjs.map +0 -1
  266. package/dist/development/src/mapper/relations/OneHasOneOwningCreateInputProcessor.js +0 -71
  267. package/dist/development/src/mapper/relations/OneHasOneOwningCreateInputProcessor.js.map +0 -1
  268. package/dist/development/src/mapper/relations/OneHasOneOwningUpdateInputProcessor.cjs +0 -200
  269. package/dist/development/src/mapper/relations/OneHasOneOwningUpdateInputProcessor.cjs.map +0 -1
  270. package/dist/development/src/mapper/relations/OneHasOneOwningUpdateInputProcessor.js +0 -200
  271. package/dist/development/src/mapper/relations/OneHasOneOwningUpdateInputProcessor.js.map +0 -1
  272. package/dist/production/src/mapper/DataManipulationBuilder.cjs +0 -5
  273. package/dist/production/src/mapper/DataManipulationBuilder.cjs.map +0 -1
  274. package/dist/production/src/mapper/DataManipulationBuilder.js +0 -5
  275. package/dist/production/src/mapper/DataManipulationBuilder.js.map +0 -1
  276. package/dist/production/src/mapper/relations/ManyHasManyInputProcessor.cjs +0 -75
  277. package/dist/production/src/mapper/relations/ManyHasManyInputProcessor.cjs.map +0 -1
  278. package/dist/production/src/mapper/relations/ManyHasManyInputProcessor.js +0 -75
  279. package/dist/production/src/mapper/relations/ManyHasManyInputProcessor.js.map +0 -1
  280. package/dist/production/src/mapper/relations/ManyHasOneInputProcessor.cjs +0 -114
  281. package/dist/production/src/mapper/relations/ManyHasOneInputProcessor.cjs.map +0 -1
  282. package/dist/production/src/mapper/relations/ManyHasOneInputProcessor.js +0 -114
  283. package/dist/production/src/mapper/relations/ManyHasOneInputProcessor.js.map +0 -1
  284. package/dist/production/src/mapper/relations/OneHasManyInputProcessor.cjs +0 -72
  285. package/dist/production/src/mapper/relations/OneHasManyInputProcessor.cjs.map +0 -1
  286. package/dist/production/src/mapper/relations/OneHasManyInputProcessor.js +0 -72
  287. package/dist/production/src/mapper/relations/OneHasManyInputProcessor.js.map +0 -1
  288. package/dist/production/src/mapper/relations/OneHasOneInverseCreateInputProcessor.cjs.map +0 -1
  289. package/dist/production/src/mapper/relations/OneHasOneInverseCreateInputProcessor.js.map +0 -1
  290. package/dist/production/src/mapper/relations/OneHasOneInverseUpdateInputProcessor.cjs.map +0 -1
  291. package/dist/production/src/mapper/relations/OneHasOneInverseUpdateInputProcessor.js.map +0 -1
  292. package/dist/production/src/mapper/relations/OneHasOneOwningCreateInputProcessor.cjs +0 -71
  293. package/dist/production/src/mapper/relations/OneHasOneOwningCreateInputProcessor.cjs.map +0 -1
  294. package/dist/production/src/mapper/relations/OneHasOneOwningCreateInputProcessor.js +0 -71
  295. package/dist/production/src/mapper/relations/OneHasOneOwningCreateInputProcessor.js.map +0 -1
  296. package/dist/production/src/mapper/relations/OneHasOneOwningUpdateInputProcessor.cjs +0 -200
  297. package/dist/production/src/mapper/relations/OneHasOneOwningUpdateInputProcessor.cjs.map +0 -1
  298. package/dist/production/src/mapper/relations/OneHasOneOwningUpdateInputProcessor.js +0 -200
  299. package/dist/production/src/mapper/relations/OneHasOneOwningUpdateInputProcessor.js.map +0 -1
  300. package/dist/types/mapper/DataManipulationBuilder.d.ts +0 -7
  301. package/dist/types/mapper/DataManipulationBuilder.d.ts.map +0 -1
  302. package/dist/types/mapper/relations/ManyHasManyInputProcessor.d.ts +0 -32
  303. package/dist/types/mapper/relations/ManyHasManyInputProcessor.d.ts.map +0 -1
  304. package/dist/types/mapper/relations/ManyHasOneInputProcessor.d.ts +0 -32
  305. package/dist/types/mapper/relations/ManyHasOneInputProcessor.d.ts.map +0 -1
  306. package/dist/types/mapper/relations/OneHasManyInputProcessor.d.ts +0 -29
  307. package/dist/types/mapper/relations/OneHasManyInputProcessor.d.ts.map +0 -1
  308. package/dist/types/mapper/relations/OneHasOneInverseCreateInputProcessor.d.ts +0 -21
  309. package/dist/types/mapper/relations/OneHasOneInverseCreateInputProcessor.d.ts.map +0 -1
  310. package/dist/types/mapper/relations/OneHasOneInverseUpdateInputProcessor.d.ts.map +0 -1
  311. package/dist/types/mapper/relations/OneHasOneOwningCreateInputProcessor.d.ts +0 -21
  312. package/dist/types/mapper/relations/OneHasOneOwningCreateInputProcessor.d.ts.map +0 -1
  313. package/dist/types/mapper/relations/OneHasOneOwningUpdateInputProcessor.d.ts.map +0 -1
  314. package/src/mapper/DataManipulationBuilder.ts +0 -12
  315. package/src/mapper/relations/ManyHasManyInputProcessor.ts +0 -108
  316. package/src/mapper/relations/ManyHasOneInputProcessor.ts +0 -158
  317. package/src/mapper/relations/OneHasManyInputProcessor.ts +0 -101
  318. package/src/mapper/relations/OneHasOneInverseCreateInputProcessor.ts +0 -99
  319. package/src/mapper/relations/OneHasOneOwningCreateInputProcessor.ts +0 -92
  320. package/src/mapper/relations/OneHasOneOwningUpdateInputProcessor.ts +0 -253
@@ -1,22 +1,93 @@
1
- import { MutationEntryNotFoundError, MutationNothingToDo, NothingToDoReason, MutationConstraintViolationError, ConstraintType, MutationResultType } from "../Result.js";
1
+ import { MutationEntryNotFoundError, MutationResultType, MutationConstraintViolationError, ConstraintType, MutationNothingToDo, NothingToDoReason } from "../../Result.js";
2
2
  class OneHasOneInverseUpdateInputProcessor {
3
3
  constructor(primaryValue, mapper) {
4
4
  this.primaryValue = primaryValue;
5
5
  this.mapper = mapper;
6
6
  }
7
7
  async connect({ input, ...ctx }) {
8
- const newOwner = await this.mapper.getPrimaryValue(ctx.targetEntity, input);
9
- if (!newOwner) {
10
- return [new MutationEntryNotFoundError([], input)];
11
- }
12
- return await this.connectInternal(ctx, newOwner);
8
+ return async () => {
9
+ const newOwner = await this.mapper.getPrimaryValue(ctx.targetEntity, input);
10
+ if (!newOwner) {
11
+ return [new MutationEntryNotFoundError([], input)];
12
+ }
13
+ return await this.connectInternal(ctx, newOwner);
14
+ };
13
15
  }
14
16
  async connectOrCreate({ input, ...ctx }) {
15
- const newOwner = await this.mapper.getPrimaryValue(ctx.targetEntity, input.connect);
16
- if (newOwner) {
17
- return await this.connectInternal(ctx, newOwner);
18
- }
19
- return await this.create({ ...ctx, input: input.create });
17
+ return async () => {
18
+ const newOwner = await this.mapper.getPrimaryValue(ctx.targetEntity, input.connect);
19
+ if (newOwner) {
20
+ return await this.connectInternal(ctx, newOwner);
21
+ }
22
+ return await this.createInternal({ ...ctx, input: input.create });
23
+ };
24
+ }
25
+ async create(ctx) {
26
+ return async () => {
27
+ return await this.createInternal(ctx);
28
+ };
29
+ }
30
+ async update({ entity, targetEntity, targetRelation, input }) {
31
+ return async () => {
32
+ return await this.mapper.update(
33
+ targetEntity,
34
+ { [targetRelation.name]: { [entity.primary]: this.primaryValue } },
35
+ input
36
+ );
37
+ };
38
+ }
39
+ async upsert(context) {
40
+ return async () => {
41
+ const { targetEntity, targetRelation, entity, input: { update, create } } = context;
42
+ const result = await this.mapper.update(
43
+ targetEntity,
44
+ { [targetRelation.name]: { [entity.primary]: this.primaryValue } },
45
+ update
46
+ );
47
+ if (result[0].result === MutationResultType.notFoundError) {
48
+ return await this.createInternal({
49
+ ...context,
50
+ input: create
51
+ });
52
+ }
53
+ return result;
54
+ };
55
+ }
56
+ async disconnect({ entity, targetEntity, relation, targetRelation }) {
57
+ return async () => {
58
+ if (!relation.nullable && !targetRelation.orphanRemoval) {
59
+ return [new MutationConstraintViolationError([], ConstraintType.notNull)];
60
+ }
61
+ const currentOwner = await this.mapper.getPrimaryValue(targetEntity, {
62
+ [targetRelation.name]: { [entity.primary]: this.primaryValue }
63
+ });
64
+ if (!currentOwner) {
65
+ return [new MutationNothingToDo([], NothingToDoReason.emptyRelation)];
66
+ }
67
+ if (currentOwner && !targetRelation.nullable) {
68
+ return [new MutationConstraintViolationError([], ConstraintType.notNull)];
69
+ }
70
+ const result = await this.mapper.updateInternal(
71
+ targetEntity,
72
+ { [targetEntity.primary]: currentOwner },
73
+ (builder) => {
74
+ builder.addPredicates([targetRelation.name]);
75
+ builder.addFieldValue(targetRelation.name, null);
76
+ }
77
+ );
78
+ if (targetRelation.orphanRemoval) {
79
+ result.push(...await this.mapper.delete(entity, { [entity.primary]: this.primaryValue }));
80
+ }
81
+ return result;
82
+ };
83
+ }
84
+ async delete({ entity, targetEntity, relation, targetRelation }) {
85
+ return async () => {
86
+ if (!relation.nullable && !targetRelation.orphanRemoval) {
87
+ return [new MutationConstraintViolationError([], ConstraintType.notNull)];
88
+ }
89
+ return await this.mapper.delete(targetEntity, { [targetRelation.name]: { [entity.primary]: this.primaryValue } });
90
+ };
20
91
  }
21
92
  async connectInternal({ entity, targetEntity, targetRelation }, newOwner) {
22
93
  const currentOwner = await this.mapper.getPrimaryValue(targetEntity, {
@@ -48,7 +119,7 @@ class OneHasOneInverseUpdateInputProcessor {
48
119
  }
49
120
  return result;
50
121
  }
51
- async create({ entity, targetEntity, targetRelation, input }) {
122
+ async createInternal({ entity, targetEntity, targetRelation, input }) {
52
123
  const currentOwner = await this.mapper.getPrimaryValue(targetEntity, {
53
124
  [targetRelation.name]: { [entity.primary]: this.primaryValue }
54
125
  });
@@ -70,60 +141,6 @@ class OneHasOneInverseUpdateInputProcessor {
70
141
  result.push(...connectToNewlyCreatedOwner);
71
142
  return result;
72
143
  }
73
- async update({ entity, targetEntity, targetRelation, input }) {
74
- return await this.mapper.update(
75
- targetEntity,
76
- { [targetRelation.name]: { [entity.primary]: this.primaryValue } },
77
- input
78
- );
79
- }
80
- async upsert(context) {
81
- const { targetEntity, targetRelation, entity, input: { update, create } } = context;
82
- const result = await this.mapper.update(
83
- targetEntity,
84
- { [targetRelation.name]: { [entity.primary]: this.primaryValue } },
85
- update
86
- );
87
- if (result[0].result === MutationResultType.notFoundError) {
88
- return await this.create({
89
- ...context,
90
- input: create
91
- });
92
- }
93
- return result;
94
- }
95
- async disconnect({ entity, targetEntity, relation, targetRelation }) {
96
- if (!relation.nullable && !targetRelation.orphanRemoval) {
97
- return [new MutationConstraintViolationError([], ConstraintType.notNull)];
98
- }
99
- const currentOwner = await this.mapper.getPrimaryValue(targetEntity, {
100
- [targetRelation.name]: { [entity.primary]: this.primaryValue }
101
- });
102
- if (!currentOwner) {
103
- return [new MutationNothingToDo([], NothingToDoReason.emptyRelation)];
104
- }
105
- if (currentOwner && !targetRelation.nullable) {
106
- return [new MutationConstraintViolationError([], ConstraintType.notNull)];
107
- }
108
- const result = await this.mapper.updateInternal(
109
- targetEntity,
110
- { [targetEntity.primary]: currentOwner },
111
- (builder) => {
112
- builder.addPredicates([targetRelation.name]);
113
- builder.addFieldValue(targetRelation.name, null);
114
- }
115
- );
116
- if (targetRelation.orphanRemoval) {
117
- result.push(...await this.mapper.delete(entity, { [entity.primary]: this.primaryValue }));
118
- }
119
- return result;
120
- }
121
- async delete({ entity, targetEntity, relation, targetRelation }) {
122
- if (!relation.nullable && !targetRelation.orphanRemoval) {
123
- return [new MutationConstraintViolationError([], ConstraintType.notNull)];
124
- }
125
- return await this.mapper.delete(targetEntity, { [targetRelation.name]: { [entity.primary]: this.primaryValue } });
126
- }
127
144
  }
128
145
  export {
129
146
  OneHasOneInverseUpdateInputProcessor
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OneHasOneInverseUpdateInputProcessor.js","sources":["../../../../../../../packages/engine-content-api/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.ts"],"sourcesContent":["import {\n\tConstraintType,\n\tMutationConstraintViolationError,\n\tMutationEntryNotFoundError,\n\tMutationNothingToDo,\n\tMutationResultList,\n\tMutationResultType,\n\tNothingToDoReason,\n} from '../../Result'\nimport { UpdateInputProcessor } from '../../../inputProcessing'\nimport { Input, Model } from '@contember/schema'\nimport { Mapper } from '../../Mapper'\nimport { SqlUpdateInputProcessorResult } from '../SqlUpdateInputProcessor'\n\ntype Context = Model.OneHasOneInverseContext\n\nexport class OneHasOneInverseUpdateInputProcessor implements UpdateInputProcessor.HasOneRelationInputProcessor<Context, SqlUpdateInputProcessorResult>{\n\tconstructor(\n\t\tprivate readonly primaryValue: Input.PrimaryValue,\n\t\tprivate readonly mapper: Mapper,\n\t) {\n\t}\n\n\tpublic async connect({ input, ...ctx }: Model.OneHasOneInverseContext & { input: Input.UniqueWhere }) {\n\t\treturn async () => {\n\t\t\tconst newOwner = await this.mapper.getPrimaryValue(ctx.targetEntity, input)\n\t\t\tif (!newOwner) {\n\t\t\t\treturn [new MutationEntryNotFoundError([], input)]\n\t\t\t}\n\t\t\treturn await this.connectInternal(ctx, newOwner)\n\t\t}\n\t}\n\n\tpublic async connectOrCreate(\n\t\t{ input, ...ctx }: Model.OneHasOneInverseContext & { input: Input.ConnectOrCreateInput },\n\t) {\n\t\treturn async () => {\n\t\t\tconst newOwner = await this.mapper.getPrimaryValue(ctx.targetEntity, input.connect)\n\t\t\tif (newOwner) {\n\t\t\t\treturn await this.connectInternal(ctx, newOwner)\n\t\t\t}\n\t\t\treturn await this.createInternal({ ...ctx, input: input.create })\n\t\t}\n\t}\n\n\n\tpublic async create(ctx: Model.OneHasOneInverseContext & { input: Input.CreateDataInput }) {\n\t\treturn async () => {\n\t\t\treturn await this.createInternal(ctx)\n\t\t}\n\t}\n\n\tpublic async update({ entity, targetEntity, targetRelation, input }: Model.OneHasOneInverseContext & { input: Input.UpdateDataInput }) {\n\t\treturn async () => {\n\t\t\treturn await this.mapper.update(\n\t\t\t\ttargetEntity,\n\t\t\t\t{ [targetRelation.name]: { [entity.primary]: this.primaryValue } },\n\t\t\t\tinput,\n\t\t\t)\n\t\t}\n\t}\n\tpublic async upsert(context: Model.OneHasOneInverseContext & { input: UpdateInputProcessor.UpsertInput }) {\n\t\treturn async () => {\n\t\t\tconst { targetEntity, targetRelation, entity, input: { update, create } } = context\n\t\t\tconst result = await this.mapper.update(\n\t\t\t\ttargetEntity,\n\t\t\t\t{ [targetRelation.name]: { [entity.primary]: this.primaryValue } },\n\t\t\t\tupdate,\n\t\t\t)\n\t\t\tif (result[0].result === MutationResultType.notFoundError) {\n\t\t\t\treturn await this.createInternal({\n\t\t\t\t\t...context,\n\t\t\t\t\tinput: create,\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn result\n\t\t}\n\t}\n\n\tpublic async disconnect({ entity, targetEntity, relation, targetRelation }: Model.OneHasOneInverseContext & { input: undefined }) {\n\t\treturn async () => {\n\t\t\tif (!relation.nullable && !targetRelation.orphanRemoval) {\n\t\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t\t}\n\t\t\tconst currentOwner = await this.mapper.getPrimaryValue(targetEntity, {\n\t\t\t\t[targetRelation.name]: { [entity.primary]: this.primaryValue },\n\t\t\t})\n\t\t\tif (!currentOwner) {\n\t\t\t\treturn [new MutationNothingToDo([], NothingToDoReason.emptyRelation)]\n\t\t\t}\n\t\t\tif (currentOwner && !targetRelation.nullable) {\n\t\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t\t}\n\n\t\t\tconst result = await this.mapper.updateInternal(\n\t\t\t\ttargetEntity,\n\t\t\t\t{ [targetEntity.primary]: currentOwner },\n\t\t\t\tbuilder => {\n\t\t\t\t\tbuilder.addPredicates([targetRelation.name])\n\t\t\t\t\tbuilder.addFieldValue(targetRelation.name, null)\n\t\t\t\t},\n\t\t\t)\n\t\t\tif (targetRelation.orphanRemoval) {\n\t\t\t\tresult.push(...(await this.mapper.delete(entity, { [entity.primary]: this.primaryValue })))\n\t\t\t}\n\t\t\treturn result\n\t\t}\n\t}\n\n\tpublic async delete({ entity, targetEntity, relation, targetRelation }: Model.OneHasOneInverseContext & { input: undefined }) {\n\t\treturn async () => {\n\t\t\tif (!relation.nullable && !targetRelation.orphanRemoval) {\n\t\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t\t}\n\t\t\t// orphan removal is handled in mapper.delete\n\t\t\treturn await this.mapper.delete(targetEntity, { [targetRelation.name]: { [entity.primary]: this.primaryValue } })\n\t\t}\n\t}\n\n\tprivate async connectInternal(\n\t\t{ entity, targetEntity, targetRelation }: Model.OneHasOneInverseContext,\n\t\tnewOwner: Input.PrimaryValue,\n\t) {\n\t\tconst currentOwner = await this.mapper.getPrimaryValue(targetEntity, {\n\t\t\t[targetRelation.name]: { [entity.primary]: this.primaryValue },\n\t\t})\n\t\tif (newOwner === currentOwner) {\n\t\t\treturn [new MutationNothingToDo([], NothingToDoReason.alreadyExists)]\n\t\t}\n\t\tconst result: MutationResultList = []\n\t\tif (currentOwner) {\n\t\t\tif (!targetRelation.nullable) {\n\t\t\t\t// todo cascade delete support?\n\t\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t\t}\n\t\t\tconst disconnectFromCurrentOwner = await this.mapper.updateInternal(targetEntity, { [targetEntity.primary]: currentOwner }, builder => {\n\t\t\t\tbuilder.addPredicates([targetRelation.name])\n\t\t\t\tbuilder.addFieldValue(targetRelation.name, null)\n\t\t\t})\n\t\t\tresult.push(...disconnectFromCurrentOwner)\n\t\t}\n\t\tconst orphanedInverseSide = targetRelation.orphanRemoval\n\t\t\t? await this.mapper.selectField(targetEntity, { [targetEntity.primary]: newOwner }, targetRelation.name)\n\t\t\t: null\n\n\t\tconst connectToNewOwner = await this.mapper.updateInternal(targetEntity, { [targetEntity.primary]: newOwner }, builder => {\n\t\t\tbuilder.addPredicates([targetRelation.name])\n\t\t\tbuilder.addFieldValue(targetRelation.name, this.primaryValue)\n\t\t})\n\t\tresult.push(...connectToNewOwner)\n\n\t\tif (orphanedInverseSide) {\n\t\t\tconst deleteOrphanedInverseSide = await this.mapper.delete(entity, { [entity.primary]: orphanedInverseSide })\n\t\t\tresult.push(...deleteOrphanedInverseSide)\n\t\t}\n\t\treturn result\n\t}\n\n\tprivate async createInternal({ entity, targetEntity, targetRelation, input }: Model.OneHasOneInverseContext & { input: Input.CreateDataInput }) {\n\t\tconst currentOwner = await this.mapper.getPrimaryValue(targetEntity, {\n\t\t\t[targetRelation.name]: { [entity.primary]: this.primaryValue },\n\t\t})\n\t\tif (currentOwner && !targetRelation.nullable) {\n\t\t\t// todo cascade delete support?\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\t\tconst result: MutationResultList = []\n\t\tif (currentOwner) {\n\t\t\tconst disconnectFromCurrentOwner = await this.mapper.updateInternal(targetEntity, { [targetEntity.primary]: currentOwner }, builder => {\n\t\t\t\tbuilder.addPredicates([targetRelation.name])\n\t\t\t\tbuilder.addFieldValue(targetRelation.name, null)\n\t\t\t})\n\t\t\tresult.push(...disconnectFromCurrentOwner)\n\t\t}\n\n\t\tconst connectToNewlyCreatedOwner = await this.mapper.insert(targetEntity, input, builder => {\n\t\t\tbuilder.addFieldValue(targetRelation.name, this.primaryValue)\n\t\t\tbuilder.addPredicates([targetRelation.name])\n\t\t})\n\t\tresult.push(...connectToNewlyC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A;AAAA,EACR;AACD;"}
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const schema = require("@contember/schema");
4
+ const Result = require("../../Result.cjs");
5
+ const CheckedPrimary = require("../../CheckedPrimary.cjs");
6
+ class OneHasOneOwningUpdateInputProcessor {
7
+ constructor(primaryValue, mapper, updateBuilder) {
8
+ this.primaryValue = primaryValue;
9
+ this.mapper = mapper;
10
+ this.updateBuilder = updateBuilder;
11
+ }
12
+ async connect(context) {
13
+ const { entity, relation, targetEntity, targetRelation, input } = context;
14
+ const newInverseSide = await this.mapper.getPrimaryValue(targetEntity, input);
15
+ if (!newInverseSide) {
16
+ return [new Result.MutationEntryNotFoundError([], input)];
17
+ }
18
+ const currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity);
19
+ const currentOwnerResult = await this.handleStateBeforeConnect(context, currentInverseSide, newInverseSide);
20
+ if (currentOwnerResult.some((it) => it.error) || currentOwnerResult.length === 1 && currentOwnerResult[0].result === Result.MutationResultType.nothingToDo) {
21
+ return currentOwnerResult;
22
+ }
23
+ this.updateBuilder.addFieldValue(relation.name, newInverseSide);
24
+ return async () => {
25
+ return [
26
+ ...currentOwnerResult,
27
+ ...await this.cleanupOrphan(relation, targetEntity, currentInverseSide)
28
+ ];
29
+ };
30
+ }
31
+ async create(context) {
32
+ const { entity, relation, targetEntity, targetRelation } = context;
33
+ const currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity);
34
+ const createResult = await this.createInternal(context, currentInverseSide);
35
+ const newInverseSide = Result.getInsertPrimary(createResult);
36
+ if (!newInverseSide) {
37
+ return createResult;
38
+ }
39
+ this.updateBuilder.addFieldValue(relation.name, newInverseSide);
40
+ return async () => {
41
+ return [
42
+ ...createResult,
43
+ ...await this.cleanupOrphan(relation, targetEntity, currentInverseSide)
44
+ ];
45
+ };
46
+ }
47
+ async connectOrCreate({ input: { connect, create }, ...context }) {
48
+ const { relation, targetRelation, targetEntity, entity } = context;
49
+ const currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity);
50
+ const newInverseSide = await this.mapper.getPrimaryValue(targetEntity, connect);
51
+ if (newInverseSide) {
52
+ const currentOwnerResult = await this.handleStateBeforeConnect(context, currentInverseSide, newInverseSide);
53
+ if (currentOwnerResult.some((it) => it.error) || currentOwnerResult.length === 1 && currentOwnerResult[0].result === Result.MutationResultType.nothingToDo) {
54
+ return currentOwnerResult;
55
+ }
56
+ this.updateBuilder.addFieldValue(relation.name, newInverseSide);
57
+ return async () => {
58
+ return [
59
+ ...currentOwnerResult,
60
+ ...await this.cleanupOrphan(relation, targetEntity, currentInverseSide)
61
+ ];
62
+ };
63
+ }
64
+ const createResult = await this.createInternal({ ...context, input: create }, currentInverseSide);
65
+ const newInverseSideCreate = Result.getInsertPrimary(createResult);
66
+ if (!newInverseSideCreate) {
67
+ return createResult;
68
+ }
69
+ this.updateBuilder.addFieldValue(relation.name, newInverseSideCreate);
70
+ return async () => {
71
+ return [
72
+ ...createResult,
73
+ ...await this.cleanupOrphan(relation, targetEntity, currentInverseSide)
74
+ ];
75
+ };
76
+ }
77
+ async update({ entity, relation, targetEntity, input }) {
78
+ return async () => {
79
+ const inversePrimary = await this.mapper.selectField(
80
+ entity,
81
+ { [entity.primary]: this.primaryValue },
82
+ relation.name
83
+ );
84
+ if (!inversePrimary) {
85
+ return [new Result.MutationNothingToDo([], Result.NothingToDoReason.emptyRelation)];
86
+ }
87
+ return await this.mapper.update(targetEntity, { [targetEntity.primary]: inversePrimary }, input);
88
+ };
89
+ }
90
+ async upsert({ entity, relation, targetEntity, input: { create, update } }) {
91
+ const primary = await this.mapper.selectField(entity, { [entity.primary]: this.primaryValue }, relation.name);
92
+ if (!primary) {
93
+ const insertResult = await this.mapper.insert(targetEntity, create);
94
+ const insertPrimary = Result.getInsertPrimary(insertResult);
95
+ if (!insertPrimary) {
96
+ return insertResult;
97
+ }
98
+ this.updateBuilder.addFieldValue(relation.name, insertPrimary);
99
+ return [];
100
+ }
101
+ return async () => {
102
+ return await this.mapper.update(targetEntity, { [targetEntity.primary]: primary }, update);
103
+ };
104
+ }
105
+ async disconnect({ entity, targetEntity, relation, targetRelation }) {
106
+ if (!relation.nullable) {
107
+ return [new Result.MutationConstraintViolationError([], Result.ConstraintType.notNull)];
108
+ }
109
+ const inversePrimary = targetRelation && !targetRelation.nullable || relation.orphanRemoval ? await this.mapper.selectField(entity, { [entity.primary]: this.primaryValue }, relation.name) : void 0;
110
+ if (inversePrimary && targetRelation && !targetRelation.nullable && !relation.orphanRemoval) {
111
+ return [new Result.MutationConstraintViolationError([], Result.ConstraintType.notNull)];
112
+ }
113
+ this.updateBuilder.addFieldValue(relation.name, null);
114
+ if (relation.orphanRemoval && inversePrimary) {
115
+ return async () => {
116
+ return await this.mapper.delete(targetEntity, { [targetEntity.primary]: inversePrimary });
117
+ };
118
+ }
119
+ return [];
120
+ }
121
+ async delete({ entity, targetEntity, relation, targetRelation }) {
122
+ if (!relation.nullable && relation.joiningColumn.onDelete !== schema.Model.OnDelete.cascade) {
123
+ return [new Result.MutationConstraintViolationError([], Result.ConstraintType.notNull)];
124
+ }
125
+ return async () => {
126
+ const targetPrimary = await this.mapper.selectField(
127
+ entity,
128
+ { [entity.primary]: this.primaryValue },
129
+ relation.name
130
+ );
131
+ if (!targetPrimary) {
132
+ return [new Result.MutationNothingToDo([], Result.NothingToDoReason.emptyRelation)];
133
+ }
134
+ return await this.mapper.delete(targetEntity, new CheckedPrimary.CheckedPrimary(targetPrimary));
135
+ };
136
+ }
137
+ async createInternal({ targetEntity, targetRelation, relation, input }, currentInverseSide) {
138
+ if (targetRelation && !targetRelation.nullable && !relation.orphanRemoval && currentInverseSide) {
139
+ return [new Result.MutationConstraintViolationError([], Result.ConstraintType.notNull)];
140
+ }
141
+ return await this.mapper.insert(targetEntity, input);
142
+ }
143
+ async getCurrentInverseSide(targetRelation, relation, entity) {
144
+ if (targetRelation && !targetRelation.nullable || relation.orphanRemoval) {
145
+ return this.mapper.selectField(entity, { [entity.primary]: this.primaryValue }, relation.name);
146
+ }
147
+ return void 0;
148
+ }
149
+ async cleanupOrphan(relation, targetEntity, currentInverseSide) {
150
+ if (relation.orphanRemoval && currentInverseSide) {
151
+ return await this.mapper.delete(targetEntity, { [targetEntity.primary]: currentInverseSide });
152
+ }
153
+ return [];
154
+ }
155
+ async handleStateBeforeConnect({ targetEntity, targetRelation, relation, entity }, currentInverseSide, newInverseSide) {
156
+ if (currentInverseSide === newInverseSide) {
157
+ return [new Result.MutationNothingToDo([], Result.NothingToDoReason.alreadyExists)];
158
+ }
159
+ const currentOwnerOfNewInverseSide = await this.mapper.getPrimaryValue(entity, {
160
+ [relation.name]: { [targetEntity.primary]: newInverseSide }
161
+ });
162
+ if (currentOwnerOfNewInverseSide === this.primaryValue) {
163
+ return [new Result.MutationNothingToDo([], Result.NothingToDoReason.alreadyExists)];
164
+ }
165
+ if (targetRelation && !targetRelation.nullable && !relation.orphanRemoval && currentInverseSide) {
166
+ return [new Result.MutationConstraintViolationError([], Result.ConstraintType.notNull)];
167
+ }
168
+ if (currentOwnerOfNewInverseSide) {
169
+ if (!relation.nullable) {
170
+ return [new Result.MutationConstraintViolationError([], Result.ConstraintType.notNull)];
171
+ }
172
+ return await this.mapper.updateInternal(
173
+ entity,
174
+ {
175
+ [entity.primary]: currentOwnerOfNewInverseSide
176
+ },
177
+ (builder) => {
178
+ builder.addPredicates([relation.name]);
179
+ builder.addFieldValue(relation.name, null);
180
+ }
181
+ );
182
+ }
183
+ return [];
184
+ }
185
+ }
186
+ exports.OneHasOneOwningUpdateInputProcessor = OneHasOneOwningUpdateInputProcessor;
187
+ //# sourceMappingURL=OneHasOneOwningUpdateInputProcessor.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OneHasOneOwningUpdateInputProcessor.cjs","sources":["../../../../../../../packages/engine-content-api/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.ts"],"sourcesContent":["import { UpdateInputProcessor } from '../../../inputProcessing'\nimport { Input, Model } from '@contember/schema'\nimport {\n\tConstraintType,\n\tgetInsertPrimary,\n\tMutationConstraintViolationError,\n\tMutationEntryNotFoundError,\n\tMutationNothingToDo,\n\tMutationResultList,\n\tMutationResultType,\n\tNothingToDoReason,\n} from '../../Result'\nimport { Mapper } from '../../Mapper'\nimport { UpdateBuilder } from '../../update/UpdateBuilder'\nimport { CheckedPrimary } from '../../CheckedPrimary'\nimport { SqlUpdateInputProcessorResult } from '../SqlUpdateInputProcessor'\n\ntype Context = Model.OneHasOneOwningContext\n\nexport class OneHasOneOwningUpdateInputProcessor implements UpdateInputProcessor.HasOneRelationInputProcessor<Context, SqlUpdateInputProcessorResult>{\n\tconstructor(\n\t\tprivate readonly primaryValue: Input.PrimaryValue,\n\t\tprivate readonly mapper: Mapper,\n\t\tprivate readonly updateBuilder: UpdateBuilder,\n\t) {\n\t}\n\n\tpublic async connect(context: Model.OneHasOneOwningContext & { input: Input.UniqueWhere }) {\n\t\tconst { entity, relation, targetEntity, targetRelation, input } = context\n\t\tconst newInverseSide = await this.mapper.getPrimaryValue(targetEntity, input)\n\t\tif (!newInverseSide) {\n\t\t\treturn [new MutationEntryNotFoundError([], input)]\n\t\t}\n\t\tconst currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity)\n\t\tconst currentOwnerResult = await this.handleStateBeforeConnect(context, currentInverseSide, newInverseSide)\n\t\tif (currentOwnerResult.some(it => it.error)\n\t\t\t|| (currentOwnerResult.length === 1 && currentOwnerResult[0].result === MutationResultType.nothingToDo)\n\t\t) {\n\t\t\treturn currentOwnerResult\n\t\t}\n\n\t\tthis.updateBuilder.addFieldValue(relation.name, newInverseSide)\n\n\t\treturn async () => {\n\t\t\treturn [\n\t\t\t\t...currentOwnerResult,\n\t\t\t\t...(await this.cleanupOrphan(relation, targetEntity, currentInverseSide)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async create(context: Model.OneHasOneOwningContext & { input: Input.CreateDataInput }) {\n\t\tconst { entity, relation, targetEntity, targetRelation } = context\n\t\tconst currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity)\n\t\tconst createResult = await this.createInternal(context, currentInverseSide)\n\t\tconst newInverseSide = getInsertPrimary(createResult)\n\t\tif (!newInverseSide) {\n\t\t\treturn createResult\n\t\t}\n\t\tthis.updateBuilder.addFieldValue(relation.name, newInverseSide)\n\n\t\treturn async () => {\n\t\t\treturn [\n\t\t\t\t...createResult,\n\t\t\t\t...(await this.cleanupOrphan(relation, targetEntity, currentInverseSide)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async connectOrCreate({ input: { connect, create }, ...context }: Model.OneHasOneOwningContext & { input: Input.ConnectOrCreateInput }) {\n\t\tconst { relation, targetRelation, targetEntity, entity } = context\n\t\tconst currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity)\n\t\tconst newInverseSide = await this.mapper.getPrimaryValue(targetEntity, connect)\n\n\t\tif (newInverseSide) {\n\t\t\tconst currentOwnerResult = await this.handleStateBeforeConnect(context, currentInverseSide, newInverseSide)\n\t\t\tif (currentOwnerResult.some(it => it.error)\n\t\t\t\t|| (currentOwnerResult.length === 1 && currentOwnerResult[0].result === MutationResultType.nothingToDo)\n\t\t\t) {\n\t\t\t\treturn currentOwnerResult\n\t\t\t}\n\t\t\tthis.updateBuilder.addFieldValue(relation.name, newInverseSide)\n\t\t\treturn async () => {\n\t\t\t\treturn [\n\t\t\t\t\t...currentOwnerResult,\n\t\t\t\t\t...(await this.cleanupOrphan(relation, targetEntity, currentInverseSide)),\n\t\t\t\t]\n\t\t\t}\n\n\t\t}\n\n\t\tconst createResult = await this.createInternal({ ...context, input: create }, currentInverseSide)\n\t\tconst newInverseSideCreate = getInsertPrimary(createResult)\n\t\tif (!newInverseSideCreate) {\n\t\t\treturn createResult\n\t\t}\n\t\tthis.updateBuilder.addFieldValue(relation.name, newInverseSideCreate)\n\t\treturn async () => {\n\t\t\treturn [\n\t\t\t\t...createResult,\n\t\t\t\t...(await this.cleanupOrphan(relation, targetEntity, currentInverseSide)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async update({ entity, relation, targetEntity, input }: Model.OneHasOneOwningContext & { input: Input.UpdateDataInput }) {\n\t\treturn async () => {\n\t\t\tconst inversePrimary = await this.mapper.selectField(\n\t\t\t\tentity,\n\t\t\t\t{ [entity.primary]: this.primaryValue },\n\t\t\t\trelation.name,\n\t\t\t)\n\t\t\tif (!inversePrimary) {\n\t\t\t\treturn [new MutationNothingToDo([], NothingToDoReason.emptyRelation)]\n\t\t\t}\n\t\t\treturn await this.mapper.update(targetEntity, { [targetEntity.primary]: inversePrimary }, input)\n\t\t}\n\t}\n\n\tpublic async upsert({ entity, relation, targetEntity, input: { create, update } }: Model.OneHasOneOwningContext & { input: UpdateInputProcessor.UpsertInput }) {\n\t\tconst primary = await this.mapper.selectField(entity, { [entity.primary]: this.primaryValue }, relation.name)\n\t\tif (!primary) {\n\t\t\tconst insertResult = await this.mapper.insert(targetEntity, create)\n\t\t\tconst insertPrimary = getInsertPrimary(insertResult)\n\t\t\tif (!insertPrimary) {\n\t\t\t\treturn insertResult\n\t\t\t}\n\t\t\tthis.updateBuilder.addFieldValue(relation.name, insertPrimary)\n\t\t\treturn []\n\t\t}\n\n\t\treturn async () => {\n\t\t\treturn await this.mapper.update(targetEntity, { [targetEntity.primary]: primary }, update)\n\t\t}\n\t}\n\n\tpublic async disconnect({ entity, targetEntity, relation, targetRelation }: Model.OneHasOneOwningContext & { input: undefined }) {\n\t\tif (!relation.nullable) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\tconst inversePrimary = (targetRelation && !targetRelation.nullable) || relation.orphanRemoval\n\t\t\t? await this.mapper.selectField(entity, { [entity.primary]: this.primaryValue }, relation.name)\n\t\t\t: undefined\n\t\tif (inversePrimary && targetRelation && !targetRelation.nullable && !relation.orphanRemoval) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\t\tthis.updateBuilder.addFieldValue(relation.name, null)\n\n\t\tif (relation.orphanRemoval && inversePrimary) {\n\t\t\treturn async () => {\n\t\t\t\treturn await this.mapper.delete(targetEntity, { [targetEntity.primary]: inversePrimary })\n\t\t\t}\n\t\t}\n\n\t\treturn []\n\t}\n\n\tpublic async delete({ entity, targetEntity, relation, targetRelation }: Model.OneHasOneOwningContext & { input: undefined }) {\n\t\tif (!relation.nullable && relation.joiningColumn.onDelete !== Model.OnDelete.cascade) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\treturn async () => {\n\t\t\tconst targetPrimary = await this.mapper.selectField(\n\t\t\t\tentity,\n\t\t\t\t{ [entity.primary]: this.primaryValue },\n\t\t\t\trelation.name,\n\t\t\t)\n\t\t\tif (!targetPrimary) {\n\t\t\t\treturn [new MutationNothingToDo([], NothingToDoReason.emptyRelation)]\n\t\t\t}\n\t\t\treturn await this.mapper.delete(targetEntity, new CheckedPrimary(targetPrimary))\n\t\t}\n\t}\n\n\tprivate async createInternal(\n\t\t{ targetEntity, targetRelation, relation, input }: Model.OneHasOneOwningContext & { input: Input.CreateDataInput },\n\t\tcurrentInverseSide: Input.PrimaryValue | undefined,\n\t): Promise<MutationResultList> {\n\t\tif (targetRelation && !targetRelation.nullable && !relation.orphanRemoval && currentInverseSide) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\treturn await this.mapper.insert(targetEntity, input)\n\t}\n\n\tprivate async getCurrentInverseSide(targetRelation: Model.OneHasOneInverseRelation | null, relation: Model.OneHasOneOwningRelation, entity: Model.Entity) {\n\t\tif ((targetRelation && !targetRelation.nullable) || relation.orphanRemoval) {\n\t\t\treturn this.mapper.selectField(entity, { [entity.primary]: this.primaryValue }, relation.name)\n\t\t}\n\t\treturn undefined\n\t}\n\n\tprivate async cleanupOrphan(relation: Model.OneHasOneOwningRelation, targetEntity: Model.Entity, currentInverseSide: Input.PrimaryValue | undefined) {\n\t\tif (relation.orphanRemoval && currentInverseSide) {\n\t\t\treturn await this.mapper.delete(targetEntity, { [targetEntity.primary]: currentInverseSide })\n\t\t}\n\t\treturn []\n\t}\n\n\tprivate async handleStateBeforeConnect(\n\t\t{ targetEntity, targetRelation, relation, entity }: Model.OneHasOneOwningContext,\n\t\tcurrentInverseSide: Input.PrimaryValue | undefined,\n\t\tnewInverseSide: Input.PrimaryValue,\n\t): Promise<MutationResultList> {\n\n\t\tif (currentInverseSide === newInverseSide) {\n\t\t\treturn [new MutationNothingToDo([], NothingToDoReason.alreadyExists)]\n\t\t}\n\n\t\tconst currentOwnerOfNewInverseSide = await this.mapper.getPrimaryValue(entity, {\n\t\t\t[relation.name]: { [targetEntity.primary]: newInverseSide },\n\t\t})\n\n\t\tif (currentOwnerOfNewInverseSide === this.primaryValue) {\n\t\t\treturn [new MutationNothingToDo([], NothingToDoReason.alreadyExists)]\n\t\t}\n\n\t\t// orphan removal handled bellow\n\t\tif (targetRelation && !targetRelation.nullable && !relation.orphanRemoval && currentInverseSide) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\tif (currentOwnerOfNewInverseSide) {\n\t\t\tif (!relation.nullable) {\n\t\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t\t}\n\n\t\t\treturn await this.mapper.updateInternal(\n\t\t\t\tentity,\n\t\t\t\t{\n\t\t\t\t\t[entity.primary]: currentOwnerOfNewInverseSide,\n\t\t\t\t},\n\t\t\t\tbuilder => {\n\t\t\t\t\tbuilder.addPredicates([relation.name])\n\t\t\t\t\tbuilder.addFieldValue(relation.name, null)\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\treturn []\n\t}\n}\n"],"names":["MutationEntryNotFoundError","MutationResultType","getInsertPrimary","MutationNothingToDo","NothingToDoReason","MutationConstraintViolationError","ConstraintType","Model","CheckedPrimary"],"mappings":";;;;;AAmBO,MAAM,oCAAwI;AAAA,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,kBAAQ,cAAc,CAAC,SAAS,IAAI,CAAC;AAC7B,kBAAA,cAAc,SAAS,MAAM,IAAI;AAAA,QAC1C;AAAA,MAAA;AAAA,IAEF;AACA,WAAO;EACR;AACD;;"}
@@ -0,0 +1,187 @@
1
+ import { Model } from "@contember/schema";
2
+ import { MutationEntryNotFoundError, MutationResultType, getInsertPrimary, MutationNothingToDo, NothingToDoReason, MutationConstraintViolationError, ConstraintType } from "../../Result.js";
3
+ import { CheckedPrimary } from "../../CheckedPrimary.js";
4
+ class OneHasOneOwningUpdateInputProcessor {
5
+ constructor(primaryValue, mapper, updateBuilder) {
6
+ this.primaryValue = primaryValue;
7
+ this.mapper = mapper;
8
+ this.updateBuilder = updateBuilder;
9
+ }
10
+ async connect(context) {
11
+ const { entity, relation, targetEntity, targetRelation, input } = context;
12
+ const newInverseSide = await this.mapper.getPrimaryValue(targetEntity, input);
13
+ if (!newInverseSide) {
14
+ return [new MutationEntryNotFoundError([], input)];
15
+ }
16
+ const currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity);
17
+ const currentOwnerResult = await this.handleStateBeforeConnect(context, currentInverseSide, newInverseSide);
18
+ if (currentOwnerResult.some((it) => it.error) || currentOwnerResult.length === 1 && currentOwnerResult[0].result === MutationResultType.nothingToDo) {
19
+ return currentOwnerResult;
20
+ }
21
+ this.updateBuilder.addFieldValue(relation.name, newInverseSide);
22
+ return async () => {
23
+ return [
24
+ ...currentOwnerResult,
25
+ ...await this.cleanupOrphan(relation, targetEntity, currentInverseSide)
26
+ ];
27
+ };
28
+ }
29
+ async create(context) {
30
+ const { entity, relation, targetEntity, targetRelation } = context;
31
+ const currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity);
32
+ const createResult = await this.createInternal(context, currentInverseSide);
33
+ const newInverseSide = getInsertPrimary(createResult);
34
+ if (!newInverseSide) {
35
+ return createResult;
36
+ }
37
+ this.updateBuilder.addFieldValue(relation.name, newInverseSide);
38
+ return async () => {
39
+ return [
40
+ ...createResult,
41
+ ...await this.cleanupOrphan(relation, targetEntity, currentInverseSide)
42
+ ];
43
+ };
44
+ }
45
+ async connectOrCreate({ input: { connect, create }, ...context }) {
46
+ const { relation, targetRelation, targetEntity, entity } = context;
47
+ const currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity);
48
+ const newInverseSide = await this.mapper.getPrimaryValue(targetEntity, connect);
49
+ if (newInverseSide) {
50
+ const currentOwnerResult = await this.handleStateBeforeConnect(context, currentInverseSide, newInverseSide);
51
+ if (currentOwnerResult.some((it) => it.error) || currentOwnerResult.length === 1 && currentOwnerResult[0].result === MutationResultType.nothingToDo) {
52
+ return currentOwnerResult;
53
+ }
54
+ this.updateBuilder.addFieldValue(relation.name, newInverseSide);
55
+ return async () => {
56
+ return [
57
+ ...currentOwnerResult,
58
+ ...await this.cleanupOrphan(relation, targetEntity, currentInverseSide)
59
+ ];
60
+ };
61
+ }
62
+ const createResult = await this.createInternal({ ...context, input: create }, currentInverseSide);
63
+ const newInverseSideCreate = getInsertPrimary(createResult);
64
+ if (!newInverseSideCreate) {
65
+ return createResult;
66
+ }
67
+ this.updateBuilder.addFieldValue(relation.name, newInverseSideCreate);
68
+ return async () => {
69
+ return [
70
+ ...createResult,
71
+ ...await this.cleanupOrphan(relation, targetEntity, currentInverseSide)
72
+ ];
73
+ };
74
+ }
75
+ async update({ entity, relation, targetEntity, input }) {
76
+ return async () => {
77
+ const inversePrimary = await this.mapper.selectField(
78
+ entity,
79
+ { [entity.primary]: this.primaryValue },
80
+ relation.name
81
+ );
82
+ if (!inversePrimary) {
83
+ return [new MutationNothingToDo([], NothingToDoReason.emptyRelation)];
84
+ }
85
+ return await this.mapper.update(targetEntity, { [targetEntity.primary]: inversePrimary }, input);
86
+ };
87
+ }
88
+ async upsert({ entity, relation, targetEntity, input: { create, update } }) {
89
+ const primary = await this.mapper.selectField(entity, { [entity.primary]: this.primaryValue }, relation.name);
90
+ if (!primary) {
91
+ const insertResult = await this.mapper.insert(targetEntity, create);
92
+ const insertPrimary = getInsertPrimary(insertResult);
93
+ if (!insertPrimary) {
94
+ return insertResult;
95
+ }
96
+ this.updateBuilder.addFieldValue(relation.name, insertPrimary);
97
+ return [];
98
+ }
99
+ return async () => {
100
+ return await this.mapper.update(targetEntity, { [targetEntity.primary]: primary }, update);
101
+ };
102
+ }
103
+ async disconnect({ entity, targetEntity, relation, targetRelation }) {
104
+ if (!relation.nullable) {
105
+ return [new MutationConstraintViolationError([], ConstraintType.notNull)];
106
+ }
107
+ const inversePrimary = targetRelation && !targetRelation.nullable || relation.orphanRemoval ? await this.mapper.selectField(entity, { [entity.primary]: this.primaryValue }, relation.name) : void 0;
108
+ if (inversePrimary && targetRelation && !targetRelation.nullable && !relation.orphanRemoval) {
109
+ return [new MutationConstraintViolationError([], ConstraintType.notNull)];
110
+ }
111
+ this.updateBuilder.addFieldValue(relation.name, null);
112
+ if (relation.orphanRemoval && inversePrimary) {
113
+ return async () => {
114
+ return await this.mapper.delete(targetEntity, { [targetEntity.primary]: inversePrimary });
115
+ };
116
+ }
117
+ return [];
118
+ }
119
+ async delete({ entity, targetEntity, relation, targetRelation }) {
120
+ if (!relation.nullable && relation.joiningColumn.onDelete !== Model.OnDelete.cascade) {
121
+ return [new MutationConstraintViolationError([], ConstraintType.notNull)];
122
+ }
123
+ return async () => {
124
+ const targetPrimary = await this.mapper.selectField(
125
+ entity,
126
+ { [entity.primary]: this.primaryValue },
127
+ relation.name
128
+ );
129
+ if (!targetPrimary) {
130
+ return [new MutationNothingToDo([], NothingToDoReason.emptyRelation)];
131
+ }
132
+ return await this.mapper.delete(targetEntity, new CheckedPrimary(targetPrimary));
133
+ };
134
+ }
135
+ async createInternal({ targetEntity, targetRelation, relation, input }, currentInverseSide) {
136
+ if (targetRelation && !targetRelation.nullable && !relation.orphanRemoval && currentInverseSide) {
137
+ return [new MutationConstraintViolationError([], ConstraintType.notNull)];
138
+ }
139
+ return await this.mapper.insert(targetEntity, input);
140
+ }
141
+ async getCurrentInverseSide(targetRelation, relation, entity) {
142
+ if (targetRelation && !targetRelation.nullable || relation.orphanRemoval) {
143
+ return this.mapper.selectField(entity, { [entity.primary]: this.primaryValue }, relation.name);
144
+ }
145
+ return void 0;
146
+ }
147
+ async cleanupOrphan(relation, targetEntity, currentInverseSide) {
148
+ if (relation.orphanRemoval && currentInverseSide) {
149
+ return await this.mapper.delete(targetEntity, { [targetEntity.primary]: currentInverseSide });
150
+ }
151
+ return [];
152
+ }
153
+ async handleStateBeforeConnect({ targetEntity, targetRelation, relation, entity }, currentInverseSide, newInverseSide) {
154
+ if (currentInverseSide === newInverseSide) {
155
+ return [new MutationNothingToDo([], NothingToDoReason.alreadyExists)];
156
+ }
157
+ const currentOwnerOfNewInverseSide = await this.mapper.getPrimaryValue(entity, {
158
+ [relation.name]: { [targetEntity.primary]: newInverseSide }
159
+ });
160
+ if (currentOwnerOfNewInverseSide === this.primaryValue) {
161
+ return [new MutationNothingToDo([], NothingToDoReason.alreadyExists)];
162
+ }
163
+ if (targetRelation && !targetRelation.nullable && !relation.orphanRemoval && currentInverseSide) {
164
+ return [new MutationConstraintViolationError([], ConstraintType.notNull)];
165
+ }
166
+ if (currentOwnerOfNewInverseSide) {
167
+ if (!relation.nullable) {
168
+ return [new MutationConstraintViolationError([], ConstraintType.notNull)];
169
+ }
170
+ return await this.mapper.updateInternal(
171
+ entity,
172
+ {
173
+ [entity.primary]: currentOwnerOfNewInverseSide
174
+ },
175
+ (builder) => {
176
+ builder.addPredicates([relation.name]);
177
+ builder.addFieldValue(relation.name, null);
178
+ }
179
+ );
180
+ }
181
+ return [];
182
+ }
183
+ }
184
+ export {
185
+ OneHasOneOwningUpdateInputProcessor
186
+ };
187
+ //# sourceMappingURL=OneHasOneOwningUpdateInputProcessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OneHasOneOwningUpdateInputProcessor.js","sources":["../../../../../../../packages/engine-content-api/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.ts"],"sourcesContent":["import { UpdateInputProcessor } from '../../../inputProcessing'\nimport { Input, Model } from '@contember/schema'\nimport {\n\tConstraintType,\n\tgetInsertPrimary,\n\tMutationConstraintViolationError,\n\tMutationEntryNotFoundError,\n\tMutationNothingToDo,\n\tMutationResultList,\n\tMutationResultType,\n\tNothingToDoReason,\n} from '../../Result'\nimport { Mapper } from '../../Mapper'\nimport { UpdateBuilder } from '../../update/UpdateBuilder'\nimport { CheckedPrimary } from '../../CheckedPrimary'\nimport { SqlUpdateInputProcessorResult } from '../SqlUpdateInputProcessor'\n\ntype Context = Model.OneHasOneOwningContext\n\nexport class OneHasOneOwningUpdateInputProcessor implements UpdateInputProcessor.HasOneRelationInputProcessor<Context, SqlUpdateInputProcessorResult>{\n\tconstructor(\n\t\tprivate readonly primaryValue: Input.PrimaryValue,\n\t\tprivate readonly mapper: Mapper,\n\t\tprivate readonly updateBuilder: UpdateBuilder,\n\t) {\n\t}\n\n\tpublic async connect(context: Model.OneHasOneOwningContext & { input: Input.UniqueWhere }) {\n\t\tconst { entity, relation, targetEntity, targetRelation, input } = context\n\t\tconst newInverseSide = await this.mapper.getPrimaryValue(targetEntity, input)\n\t\tif (!newInverseSide) {\n\t\t\treturn [new MutationEntryNotFoundError([], input)]\n\t\t}\n\t\tconst currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity)\n\t\tconst currentOwnerResult = await this.handleStateBeforeConnect(context, currentInverseSide, newInverseSide)\n\t\tif (currentOwnerResult.some(it => it.error)\n\t\t\t|| (currentOwnerResult.length === 1 && currentOwnerResult[0].result === MutationResultType.nothingToDo)\n\t\t) {\n\t\t\treturn currentOwnerResult\n\t\t}\n\n\t\tthis.updateBuilder.addFieldValue(relation.name, newInverseSide)\n\n\t\treturn async () => {\n\t\t\treturn [\n\t\t\t\t...currentOwnerResult,\n\t\t\t\t...(await this.cleanupOrphan(relation, targetEntity, currentInverseSide)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async create(context: Model.OneHasOneOwningContext & { input: Input.CreateDataInput }) {\n\t\tconst { entity, relation, targetEntity, targetRelation } = context\n\t\tconst currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity)\n\t\tconst createResult = await this.createInternal(context, currentInverseSide)\n\t\tconst newInverseSide = getInsertPrimary(createResult)\n\t\tif (!newInverseSide) {\n\t\t\treturn createResult\n\t\t}\n\t\tthis.updateBuilder.addFieldValue(relation.name, newInverseSide)\n\n\t\treturn async () => {\n\t\t\treturn [\n\t\t\t\t...createResult,\n\t\t\t\t...(await this.cleanupOrphan(relation, targetEntity, currentInverseSide)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async connectOrCreate({ input: { connect, create }, ...context }: Model.OneHasOneOwningContext & { input: Input.ConnectOrCreateInput }) {\n\t\tconst { relation, targetRelation, targetEntity, entity } = context\n\t\tconst currentInverseSide = await this.getCurrentInverseSide(targetRelation, relation, entity)\n\t\tconst newInverseSide = await this.mapper.getPrimaryValue(targetEntity, connect)\n\n\t\tif (newInverseSide) {\n\t\t\tconst currentOwnerResult = await this.handleStateBeforeConnect(context, currentInverseSide, newInverseSide)\n\t\t\tif (currentOwnerResult.some(it => it.error)\n\t\t\t\t|| (currentOwnerResult.length === 1 && currentOwnerResult[0].result === MutationResultType.nothingToDo)\n\t\t\t) {\n\t\t\t\treturn currentOwnerResult\n\t\t\t}\n\t\t\tthis.updateBuilder.addFieldValue(relation.name, newInverseSide)\n\t\t\treturn async () => {\n\t\t\t\treturn [\n\t\t\t\t\t...currentOwnerResult,\n\t\t\t\t\t...(await this.cleanupOrphan(relation, targetEntity, currentInverseSide)),\n\t\t\t\t]\n\t\t\t}\n\n\t\t}\n\n\t\tconst createResult = await this.createInternal({ ...context, input: create }, currentInverseSide)\n\t\tconst newInverseSideCreate = getInsertPrimary(createResult)\n\t\tif (!newInverseSideCreate) {\n\t\t\treturn createResult\n\t\t}\n\t\tthis.updateBuilder.addFieldValue(relation.name, newInverseSideCreate)\n\t\treturn async () => {\n\t\t\treturn [\n\t\t\t\t...createResult,\n\t\t\t\t...(await this.cleanupOrphan(relation, targetEntity, currentInverseSide)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async update({ entity, relation, targetEntity, input }: Model.OneHasOneOwningContext & { input: Input.UpdateDataInput }) {\n\t\treturn async () => {\n\t\t\tconst inversePrimary = await this.mapper.selectField(\n\t\t\t\tentity,\n\t\t\t\t{ [entity.primary]: this.primaryValue },\n\t\t\t\trelation.name,\n\t\t\t)\n\t\t\tif (!inversePrimary) {\n\t\t\t\treturn [new MutationNothingToDo([], NothingToDoReason.emptyRelation)]\n\t\t\t}\n\t\t\treturn await this.mapper.update(targetEntity, { [targetEntity.primary]: inversePrimary }, input)\n\t\t}\n\t}\n\n\tpublic async upsert({ entity, relation, targetEntity, input: { create, update } }: Model.OneHasOneOwningContext & { input: UpdateInputProcessor.UpsertInput }) {\n\t\tconst primary = await this.mapper.selectField(entity, { [entity.primary]: this.primaryValue }, relation.name)\n\t\tif (!primary) {\n\t\t\tconst insertResult = await this.mapper.insert(targetEntity, create)\n\t\t\tconst insertPrimary = getInsertPrimary(insertResult)\n\t\t\tif (!insertPrimary) {\n\t\t\t\treturn insertResult\n\t\t\t}\n\t\t\tthis.updateBuilder.addFieldValue(relation.name, insertPrimary)\n\t\t\treturn []\n\t\t}\n\n\t\treturn async () => {\n\t\t\treturn await this.mapper.update(targetEntity, { [targetEntity.primary]: primary }, update)\n\t\t}\n\t}\n\n\tpublic async disconnect({ entity, targetEntity, relation, targetRelation }: Model.OneHasOneOwningContext & { input: undefined }) {\n\t\tif (!relation.nullable) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\tconst inversePrimary = (targetRelation && !targetRelation.nullable) || relation.orphanRemoval\n\t\t\t? await this.mapper.selectField(entity, { [entity.primary]: this.primaryValue }, relation.name)\n\t\t\t: undefined\n\t\tif (inversePrimary && targetRelation && !targetRelation.nullable && !relation.orphanRemoval) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\t\tthis.updateBuilder.addFieldValue(relation.name, null)\n\n\t\tif (relation.orphanRemoval && inversePrimary) {\n\t\t\treturn async () => {\n\t\t\t\treturn await this.mapper.delete(targetEntity, { [targetEntity.primary]: inversePrimary })\n\t\t\t}\n\t\t}\n\n\t\treturn []\n\t}\n\n\tpublic async delete({ entity, targetEntity, relation, targetRelation }: Model.OneHasOneOwningContext & { input: undefined }) {\n\t\tif (!relation.nullable && relation.joiningColumn.onDelete !== Model.OnDelete.cascade) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\treturn async () => {\n\t\t\tconst targetPrimary = await this.mapper.selectField(\n\t\t\t\tentity,\n\t\t\t\t{ [entity.primary]: this.primaryValue },\n\t\t\t\trelation.name,\n\t\t\t)\n\t\t\tif (!targetPrimary) {\n\t\t\t\treturn [new MutationNothingToDo([], NothingToDoReason.emptyRelation)]\n\t\t\t}\n\t\t\treturn await this.mapper.delete(targetEntity, new CheckedPrimary(targetPrimary))\n\t\t}\n\t}\n\n\tprivate async createInternal(\n\t\t{ targetEntity, targetRelation, relation, input }: Model.OneHasOneOwningContext & { input: Input.CreateDataInput },\n\t\tcurrentInverseSide: Input.PrimaryValue | undefined,\n\t): Promise<MutationResultList> {\n\t\tif (targetRelation && !targetRelation.nullable && !relation.orphanRemoval && currentInverseSide) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\treturn await this.mapper.insert(targetEntity, input)\n\t}\n\n\tprivate async getCurrentInverseSide(targetRelation: Model.OneHasOneInverseRelation | null, relation: Model.OneHasOneOwningRelation, entity: Model.Entity) {\n\t\tif ((targetRelation && !targetRelation.nullable) || relation.orphanRemoval) {\n\t\t\treturn this.mapper.selectField(entity, { [entity.primary]: this.primaryValue }, relation.name)\n\t\t}\n\t\treturn undefined\n\t}\n\n\tprivate async cleanupOrphan(relation: Model.OneHasOneOwningRelation, targetEntity: Model.Entity, currentInverseSide: Input.PrimaryValue | undefined) {\n\t\tif (relation.orphanRemoval && currentInverseSide) {\n\t\t\treturn await this.mapper.delete(targetEntity, { [targetEntity.primary]: currentInverseSide })\n\t\t}\n\t\treturn []\n\t}\n\n\tprivate async handleStateBeforeConnect(\n\t\t{ targetEntity, targetRelation, relation, entity }: Model.OneHasOneOwningContext,\n\t\tcurrentInverseSide: Input.PrimaryValue | undefined,\n\t\tnewInverseSide: Input.PrimaryValue,\n\t): Promise<MutationResultList> {\n\n\t\tif (currentInverseSide === newInverseSide) {\n\t\t\treturn [new MutationNothingToDo([], NothingToDoReason.alreadyExists)]\n\t\t}\n\n\t\tconst currentOwnerOfNewInverseSide = await this.mapper.getPrimaryValue(entity, {\n\t\t\t[relation.name]: { [targetEntity.primary]: newInverseSide },\n\t\t})\n\n\t\tif (currentOwnerOfNewInverseSide === this.primaryValue) {\n\t\t\treturn [new MutationNothingToDo([], NothingToDoReason.alreadyExists)]\n\t\t}\n\n\t\t// orphan removal handled bellow\n\t\tif (targetRelation && !targetRelation.nullable && !relation.orphanRemoval && currentInverseSide) {\n\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t}\n\n\t\tif (currentOwnerOfNewInverseSide) {\n\t\t\tif (!relation.nullable) {\n\t\t\t\treturn [new MutationConstraintViolationError([], ConstraintType.notNull)]\n\t\t\t}\n\n\t\t\treturn await this.mapper.updateInternal(\n\t\t\t\tentity,\n\t\t\t\t{\n\t\t\t\t\t[entity.primary]: currentOwnerOfNewInverseSide,\n\t\t\t\t},\n\t\t\t\tbuilder => {\n\t\t\t\t\tbuilder.addPredicates([relation.name])\n\t\t\t\t\tbuilder.addFieldValue(relation.name, null)\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\treturn []\n\t}\n}\n"],"names":[],"mappings":";;;AAmBO,MAAM,oCAAwI;AAAA,EACpJ,YACkB,cACA,QACA,eAChB;AAHgB,SAAA,eAAA;AACA,SAAA,SAAA;AACA,SAAA,gBAAA;A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;AAC1C,aAAA,MAAM,KAAK,OAAO,OAAO,cAAc,EAAE,CAAC,aAAa,OAAO,GAAG,mBAAA,CAAoB;AAAA,IAC7F;AACA,WAAO;EACR;AAAA,EAEA,MAAc,yBACb,EAAE,cAAc,gBAAgB,UAAU,OAC1C,GAAA,oBACA,gBAC8B;AAE9B,QAAI,uBAAuB,gBAAgB;AAC1C,aAAO,CAAC,IAAI,oBAAoB,CAAA,GAAI,kBAAkB,aAAa,CAAC;AAAA,IACrE;AAEA,UAAM,+BAA+B,MAAM,KAAK,OAAO,gBAAgB,QAAQ;AAAA,MAC9E,CAAC,SAAS,IAAI,GAAG,EAAE,CAAC,aAAa,OAAO,GAAG,eAAe;AAAA,IAAA,CAC1D;AAEG,QAAA,iCAAiC,KAAK,cAAc;AACvD,aAAO,CAAC,IAAI,oBAAoB,CAAA,GAAI,kBAAkB,aAAa,CAAC;AAAA,IACrE;AAGA,QAAI,kBAAkB,CAAC,eAAe,YAAY,CAAC,SAAS,iBAAiB,oBAAoB;AAChG,aAAO,CAAC,IAAI,iCAAiC,CAAA,GAAI,eAAe,OAAO,CAAC;AAAA,IACzE;AAEA,QAAI,8BAA8B;AAC7B,UAAA,CAAC,SAAS,UAAU;AACvB,eAAO,CAAC,IAAI,iCAAiC,CAAA,GAAI,eAAe,OAAO,CAAC;AAAA,MACzE;AAEO,aAAA,MAAM,KAAK,OAAO;AAAA,QACxB;AAAA,QACA;AAAA,UACC,CAAC,OAAO,OAAO,GAAG;AAAA,QACnB;AAAA,QACA,CAAW,YAAA;AACV,kBAAQ,cAAc,CAAC,SAAS,IAAI,CAAC;AAC7B,kBAAA,cAAc,SAAS,MAAM,IAAI;AAAA,QAC1C;AAAA,MAAA;AAAA,IAEF;AACA,WAAO;EACR;AACD;"}
@@ -8,8 +8,8 @@ const Database = require("@contember/database");
8
8
  const Result = require("../mapper/Result.cjs");
9
9
  const EventManager = require("../mapper/EventManager.cjs");
10
10
  const ObjectNode = require("../inputProcessing/ObjectNode.cjs");
11
- const ErrorUtils = require("../mapper/ErrorUtils.cjs");
12
11
  const logger = require("@contember/logger");
12
+ const ErrorUtils = require("../mapper/ErrorUtils.cjs");
13
13
  require("fast-deep-equal");
14
14
  require("../extensions/hasManyToHasOneReducer/HasManyToHasOneReducer.cjs");
15
15
  require("graphql");