@contember/engine-content-api 2.2.0-alpha.18 → 2.2.0-alpha.19

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 (385) hide show
  1. package/dist/development/index.cjs +3 -0
  2. package/dist/development/index.cjs.map +1 -1
  3. package/dist/development/index.js +4 -1
  4. package/dist/development/index.js.map +1 -1
  5. package/dist/development/src/ExecutionContainer.cjs +1 -0
  6. package/dist/development/src/ExecutionContainer.cjs.map +1 -1
  7. package/dist/development/src/ExecutionContainer.js +1 -0
  8. package/dist/development/src/ExecutionContainer.js.map +1 -1
  9. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs +2 -1
  10. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs.map +1 -1
  11. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js +2 -1
  12. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js.map +1 -1
  13. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +5 -1
  14. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
  15. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +5 -1
  16. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
  17. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs +2 -1
  18. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs.map +1 -1
  19. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js +2 -1
  20. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js.map +1 -1
  21. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs +4 -1
  22. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs.map +1 -1
  23. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +4 -1
  24. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js.map +1 -1
  25. package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs +24 -3
  26. package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs.map +1 -1
  27. package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js +24 -3
  28. package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map +1 -1
  29. package/dist/development/src/inputProcessing/UpdateInputVisitor.cjs +52 -2
  30. package/dist/development/src/inputProcessing/UpdateInputVisitor.cjs.map +1 -1
  31. package/dist/development/src/inputProcessing/UpdateInputVisitor.js +52 -2
  32. package/dist/development/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
  33. package/dist/development/src/mapper/ErrorUtils.cjs +10 -0
  34. package/dist/development/src/mapper/ErrorUtils.cjs.map +1 -1
  35. package/dist/development/src/mapper/ErrorUtils.js +10 -0
  36. package/dist/development/src/mapper/ErrorUtils.js.map +1 -1
  37. package/dist/development/src/mapper/Mapper.cjs +37 -1
  38. package/dist/development/src/mapper/Mapper.cjs.map +1 -1
  39. package/dist/development/src/mapper/Mapper.js +38 -2
  40. package/dist/development/src/mapper/Mapper.js.map +1 -1
  41. package/dist/development/src/mapper/MutationProcessorHelper.cjs +12 -0
  42. package/dist/development/src/mapper/MutationProcessorHelper.cjs.map +1 -1
  43. package/dist/development/src/mapper/MutationProcessorHelper.js +13 -1
  44. package/dist/development/src/mapper/MutationProcessorHelper.js.map +1 -1
  45. package/dist/development/src/mapper/Result.cjs +1 -0
  46. package/dist/development/src/mapper/Result.cjs.map +1 -1
  47. package/dist/development/src/mapper/Result.js +1 -0
  48. package/dist/development/src/mapper/Result.js.map +1 -1
  49. package/dist/development/src/mapper/delete/DeleteExecutor.cjs +1 -1
  50. package/dist/development/src/mapper/delete/DeleteExecutor.js +1 -1
  51. package/dist/development/src/mapper/select/handlers/MetaHandler.cjs +1 -1
  52. package/dist/development/src/mapper/select/handlers/MetaHandler.js +1 -1
  53. package/dist/development/src/mapper/select/optimizer/WhereOptimizer.cjs +2 -2
  54. package/dist/development/src/mapper/select/optimizer/WhereOptimizer.cjs.map +1 -1
  55. package/dist/development/src/mapper/select/optimizer/WhereOptimizer.js +1 -1
  56. package/dist/development/src/mapper/select/optimizer/WhereOptimizer.js.map +1 -1
  57. package/dist/development/src/mapper/select/optimizer/WhereReplacer.cjs +3 -3
  58. package/dist/development/src/mapper/select/optimizer/WhereReplacer.cjs.map +1 -1
  59. package/dist/development/src/mapper/select/optimizer/WhereReplacer.js +1 -1
  60. package/dist/development/src/mapper/select/optimizer/WhereReplacer.js.map +1 -1
  61. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.cjs +6 -3
  62. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
  63. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.js +7 -4
  64. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
  65. package/dist/development/src/mapper/update/Updater.cjs +1 -1
  66. package/dist/development/src/mapper/update/Updater.js +1 -1
  67. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs +6 -0
  68. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -1
  69. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js +6 -0
  70. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -1
  71. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs +6 -0
  72. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -1
  73. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js +6 -0
  74. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -1
  75. package/dist/development/src/mapper/update/relations/SetManyRelationHelper.cjs +123 -0
  76. package/dist/development/src/mapper/update/relations/SetManyRelationHelper.cjs.map +1 -0
  77. package/dist/development/src/mapper/update/relations/SetManyRelationHelper.js +123 -0
  78. package/dist/development/src/mapper/update/relations/SetManyRelationHelper.js.map +1 -0
  79. package/dist/development/src/resolvers/MutationResolver.cjs +4 -1
  80. package/dist/development/src/resolvers/MutationResolver.cjs.map +1 -1
  81. package/dist/development/src/resolvers/MutationResolver.js +4 -1
  82. package/dist/development/src/resolvers/MutationResolver.js.map +1 -1
  83. package/dist/development/src/resolvers/ReadHelpers.cjs +2 -1
  84. package/dist/development/src/resolvers/ReadHelpers.cjs.map +1 -1
  85. package/dist/development/src/resolvers/ReadHelpers.js +2 -1
  86. package/dist/development/src/resolvers/ReadHelpers.js.map +1 -1
  87. package/dist/development/src/schema/CustomTypesProvider.cjs +35 -14
  88. package/dist/development/src/schema/CustomTypesProvider.cjs.map +1 -1
  89. package/dist/development/src/schema/CustomTypesProvider.js +36 -15
  90. package/dist/development/src/schema/CustomTypesProvider.js.map +1 -1
  91. package/dist/development/src/schema/EntityTypeProvider.cjs +8 -5
  92. package/dist/development/src/schema/EntityTypeProvider.cjs.map +1 -1
  93. package/dist/development/src/schema/EntityTypeProvider.js +8 -5
  94. package/dist/development/src/schema/EntityTypeProvider.js.map +1 -1
  95. package/dist/development/src/schema/GraphQlSchemaBuilderFactory.cjs +1 -1
  96. package/dist/development/src/schema/GraphQlSchemaBuilderFactory.js +1 -1
  97. package/dist/development/src/schema/MutationProvider.cjs +4 -0
  98. package/dist/development/src/schema/MutationProvider.cjs.map +1 -1
  99. package/dist/development/src/schema/MutationProvider.js +4 -0
  100. package/dist/development/src/schema/MutationProvider.js.map +1 -1
  101. package/dist/development/src/schema/OrderByTypeProvider.cjs +8 -2
  102. package/dist/development/src/schema/OrderByTypeProvider.cjs.map +1 -1
  103. package/dist/development/src/schema/OrderByTypeProvider.js +9 -3
  104. package/dist/development/src/schema/OrderByTypeProvider.js.map +1 -1
  105. package/dist/development/src/schema/QueryProvider.cjs +3 -0
  106. package/dist/development/src/schema/QueryProvider.cjs.map +1 -1
  107. package/dist/development/src/schema/QueryProvider.js +3 -0
  108. package/dist/development/src/schema/QueryProvider.js.map +1 -1
  109. package/dist/development/src/schema/ValidationQueriesProvider.cjs +2 -0
  110. package/dist/development/src/schema/ValidationQueriesProvider.cjs.map +1 -1
  111. package/dist/development/src/schema/ValidationQueriesProvider.js +2 -0
  112. package/dist/development/src/schema/ValidationQueriesProvider.js.map +1 -1
  113. package/dist/development/src/schema/WhereTypeProvider.cjs +17 -5
  114. package/dist/development/src/schema/WhereTypeProvider.cjs.map +1 -1
  115. package/dist/development/src/schema/WhereTypeProvider.js +18 -6
  116. package/dist/development/src/schema/WhereTypeProvider.js.map +1 -1
  117. package/dist/development/src/schema/calendarDate.cjs +21 -0
  118. package/dist/development/src/schema/calendarDate.cjs.map +1 -0
  119. package/dist/development/src/schema/calendarDate.js +21 -0
  120. package/dist/development/src/schema/calendarDate.js.map +1 -0
  121. package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.cjs +11 -3
  122. package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.cjs.map +1 -1
  123. package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.js +11 -3
  124. package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.js.map +1 -1
  125. package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs +11 -3
  126. package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs.map +1 -1
  127. package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.js +11 -3
  128. package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.js.map +1 -1
  129. package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs +39 -2
  130. package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs.map +1 -1
  131. package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js +40 -3
  132. package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js.map +1 -1
  133. package/dist/development/src/schema/utils.cjs +10 -0
  134. package/dist/development/src/schema/utils.cjs.map +1 -1
  135. package/dist/development/src/schema/utils.js +11 -1
  136. package/dist/development/src/schema/utils.js.map +1 -1
  137. package/dist/production/index.cjs +3 -0
  138. package/dist/production/index.cjs.map +1 -1
  139. package/dist/production/index.js +4 -1
  140. package/dist/production/index.js.map +1 -1
  141. package/dist/production/src/ExecutionContainer.cjs +1 -0
  142. package/dist/production/src/ExecutionContainer.cjs.map +1 -1
  143. package/dist/production/src/ExecutionContainer.js +1 -0
  144. package/dist/production/src/ExecutionContainer.js.map +1 -1
  145. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs +2 -1
  146. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs.map +1 -1
  147. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js +2 -1
  148. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js.map +1 -1
  149. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +5 -1
  150. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
  151. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +5 -1
  152. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
  153. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs +2 -1
  154. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs.map +1 -1
  155. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js +2 -1
  156. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js.map +1 -1
  157. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs +4 -1
  158. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs.map +1 -1
  159. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +4 -1
  160. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js.map +1 -1
  161. package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs +24 -3
  162. package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs.map +1 -1
  163. package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js +24 -3
  164. package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map +1 -1
  165. package/dist/production/src/inputProcessing/UpdateInputVisitor.cjs +52 -2
  166. package/dist/production/src/inputProcessing/UpdateInputVisitor.cjs.map +1 -1
  167. package/dist/production/src/inputProcessing/UpdateInputVisitor.js +52 -2
  168. package/dist/production/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
  169. package/dist/production/src/mapper/ErrorUtils.cjs +10 -0
  170. package/dist/production/src/mapper/ErrorUtils.cjs.map +1 -1
  171. package/dist/production/src/mapper/ErrorUtils.js +10 -0
  172. package/dist/production/src/mapper/ErrorUtils.js.map +1 -1
  173. package/dist/production/src/mapper/Mapper.cjs +37 -1
  174. package/dist/production/src/mapper/Mapper.cjs.map +1 -1
  175. package/dist/production/src/mapper/Mapper.js +38 -2
  176. package/dist/production/src/mapper/Mapper.js.map +1 -1
  177. package/dist/production/src/mapper/MutationProcessorHelper.cjs +12 -0
  178. package/dist/production/src/mapper/MutationProcessorHelper.cjs.map +1 -1
  179. package/dist/production/src/mapper/MutationProcessorHelper.js +13 -1
  180. package/dist/production/src/mapper/MutationProcessorHelper.js.map +1 -1
  181. package/dist/production/src/mapper/Result.cjs +1 -0
  182. package/dist/production/src/mapper/Result.cjs.map +1 -1
  183. package/dist/production/src/mapper/Result.js +1 -0
  184. package/dist/production/src/mapper/Result.js.map +1 -1
  185. package/dist/production/src/mapper/delete/DeleteExecutor.cjs +1 -1
  186. package/dist/production/src/mapper/delete/DeleteExecutor.js +1 -1
  187. package/dist/production/src/mapper/select/handlers/MetaHandler.cjs +1 -1
  188. package/dist/production/src/mapper/select/handlers/MetaHandler.js +1 -1
  189. package/dist/production/src/mapper/select/optimizer/WhereOptimizer.cjs +2 -2
  190. package/dist/production/src/mapper/select/optimizer/WhereOptimizer.cjs.map +1 -1
  191. package/dist/production/src/mapper/select/optimizer/WhereOptimizer.js +1 -1
  192. package/dist/production/src/mapper/select/optimizer/WhereOptimizer.js.map +1 -1
  193. package/dist/production/src/mapper/select/optimizer/WhereReplacer.cjs +3 -3
  194. package/dist/production/src/mapper/select/optimizer/WhereReplacer.cjs.map +1 -1
  195. package/dist/production/src/mapper/select/optimizer/WhereReplacer.js +1 -1
  196. package/dist/production/src/mapper/select/optimizer/WhereReplacer.js.map +1 -1
  197. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.cjs +6 -3
  198. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
  199. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.js +7 -4
  200. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
  201. package/dist/production/src/mapper/update/Updater.cjs +1 -1
  202. package/dist/production/src/mapper/update/Updater.js +1 -1
  203. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs +6 -0
  204. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -1
  205. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js +6 -0
  206. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -1
  207. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs +6 -0
  208. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -1
  209. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js +6 -0
  210. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -1
  211. package/dist/production/src/mapper/update/relations/SetManyRelationHelper.cjs +123 -0
  212. package/dist/production/src/mapper/update/relations/SetManyRelationHelper.cjs.map +1 -0
  213. package/dist/production/src/mapper/update/relations/SetManyRelationHelper.js +123 -0
  214. package/dist/production/src/mapper/update/relations/SetManyRelationHelper.js.map +1 -0
  215. package/dist/production/src/resolvers/MutationResolver.cjs +4 -1
  216. package/dist/production/src/resolvers/MutationResolver.cjs.map +1 -1
  217. package/dist/production/src/resolvers/MutationResolver.js +4 -1
  218. package/dist/production/src/resolvers/MutationResolver.js.map +1 -1
  219. package/dist/production/src/resolvers/ReadHelpers.cjs +2 -1
  220. package/dist/production/src/resolvers/ReadHelpers.cjs.map +1 -1
  221. package/dist/production/src/resolvers/ReadHelpers.js +2 -1
  222. package/dist/production/src/resolvers/ReadHelpers.js.map +1 -1
  223. package/dist/production/src/schema/CustomTypesProvider.cjs +35 -14
  224. package/dist/production/src/schema/CustomTypesProvider.cjs.map +1 -1
  225. package/dist/production/src/schema/CustomTypesProvider.js +36 -15
  226. package/dist/production/src/schema/CustomTypesProvider.js.map +1 -1
  227. package/dist/production/src/schema/EntityTypeProvider.cjs +8 -5
  228. package/dist/production/src/schema/EntityTypeProvider.cjs.map +1 -1
  229. package/dist/production/src/schema/EntityTypeProvider.js +8 -5
  230. package/dist/production/src/schema/EntityTypeProvider.js.map +1 -1
  231. package/dist/production/src/schema/GraphQlSchemaBuilderFactory.cjs +1 -1
  232. package/dist/production/src/schema/GraphQlSchemaBuilderFactory.js +1 -1
  233. package/dist/production/src/schema/MutationProvider.cjs +4 -0
  234. package/dist/production/src/schema/MutationProvider.cjs.map +1 -1
  235. package/dist/production/src/schema/MutationProvider.js +4 -0
  236. package/dist/production/src/schema/MutationProvider.js.map +1 -1
  237. package/dist/production/src/schema/OrderByTypeProvider.cjs +8 -2
  238. package/dist/production/src/schema/OrderByTypeProvider.cjs.map +1 -1
  239. package/dist/production/src/schema/OrderByTypeProvider.js +9 -3
  240. package/dist/production/src/schema/OrderByTypeProvider.js.map +1 -1
  241. package/dist/production/src/schema/QueryProvider.cjs +3 -0
  242. package/dist/production/src/schema/QueryProvider.cjs.map +1 -1
  243. package/dist/production/src/schema/QueryProvider.js +3 -0
  244. package/dist/production/src/schema/QueryProvider.js.map +1 -1
  245. package/dist/production/src/schema/ValidationQueriesProvider.cjs +2 -0
  246. package/dist/production/src/schema/ValidationQueriesProvider.cjs.map +1 -1
  247. package/dist/production/src/schema/ValidationQueriesProvider.js +2 -0
  248. package/dist/production/src/schema/ValidationQueriesProvider.js.map +1 -1
  249. package/dist/production/src/schema/WhereTypeProvider.cjs +17 -5
  250. package/dist/production/src/schema/WhereTypeProvider.cjs.map +1 -1
  251. package/dist/production/src/schema/WhereTypeProvider.js +18 -6
  252. package/dist/production/src/schema/WhereTypeProvider.js.map +1 -1
  253. package/dist/production/src/schema/calendarDate.cjs +21 -0
  254. package/dist/production/src/schema/calendarDate.cjs.map +1 -0
  255. package/dist/production/src/schema/calendarDate.js +21 -0
  256. package/dist/production/src/schema/calendarDate.js.map +1 -0
  257. package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.cjs +11 -3
  258. package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.cjs.map +1 -1
  259. package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.js +11 -3
  260. package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.js.map +1 -1
  261. package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs +11 -3
  262. package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs.map +1 -1
  263. package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.js +11 -3
  264. package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.js.map +1 -1
  265. package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs +39 -2
  266. package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs.map +1 -1
  267. package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js +40 -3
  268. package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js.map +1 -1
  269. package/dist/production/src/schema/utils.cjs +10 -0
  270. package/dist/production/src/schema/utils.cjs.map +1 -1
  271. package/dist/production/src/schema/utils.js +11 -1
  272. package/dist/production/src/schema/utils.js.map +1 -1
  273. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/set.test.d.ts +2 -0
  274. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/set.test.d.ts.map +1 -0
  275. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/set.test.d.ts +2 -0
  276. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/set.test.d.ts.map +1 -0
  277. package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/set.test.d.ts +2 -0
  278. package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/set.test.d.ts.map +1 -0
  279. package/dist/tests/cases/unit/checkViolationError.test.d.ts +2 -0
  280. package/dist/tests/cases/unit/checkViolationError.test.d.ts.map +1 -0
  281. package/dist/tests/cases/unit/dateType.test.d.ts +2 -0
  282. package/dist/tests/cases/unit/dateType.test.d.ts.map +1 -0
  283. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  284. package/dist/types/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.d.ts.map +1 -1
  285. package/dist/types/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.d.ts.map +1 -1
  286. package/dist/types/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts +6 -0
  287. package/dist/types/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts.map +1 -1
  288. package/dist/types/inputProcessing/UpdateInputProcessor.d.ts +7 -0
  289. package/dist/types/inputProcessing/UpdateInputProcessor.d.ts.map +1 -1
  290. package/dist/types/inputProcessing/UpdateInputVisitor.d.ts +2 -0
  291. package/dist/types/inputProcessing/UpdateInputVisitor.d.ts.map +1 -1
  292. package/dist/types/mapper/ErrorUtils.d.ts.map +1 -1
  293. package/dist/types/mapper/Mapper.d.ts +5 -0
  294. package/dist/types/mapper/Mapper.d.ts.map +1 -1
  295. package/dist/types/mapper/MutationProcessorHelper.d.ts +3 -0
  296. package/dist/types/mapper/MutationProcessorHelper.d.ts.map +1 -1
  297. package/dist/types/mapper/Result.d.ts +2 -1
  298. package/dist/types/mapper/Result.d.ts.map +1 -1
  299. package/dist/types/mapper/types.d.ts +8 -1
  300. package/dist/types/mapper/types.d.ts.map +1 -1
  301. package/dist/types/mapper/update/SqlUpdateInputProcessor.d.ts.map +1 -1
  302. package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts +5 -0
  303. package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts.map +1 -1
  304. package/dist/types/mapper/update/relations/OneHasManyUpdateInputProcessor.d.ts +5 -0
  305. package/dist/types/mapper/update/relations/OneHasManyUpdateInputProcessor.d.ts.map +1 -1
  306. package/dist/types/mapper/update/relations/SetManyRelationHelper.d.ts +67 -0
  307. package/dist/types/mapper/update/relations/SetManyRelationHelper.d.ts.map +1 -0
  308. package/dist/types/resolvers/MutationResolver.d.ts.map +1 -1
  309. package/dist/types/schema/CustomTypesProvider.d.ts.map +1 -1
  310. package/dist/types/schema/EntityTypeProvider.d.ts.map +1 -1
  311. package/dist/types/schema/MutationProvider.d.ts.map +1 -1
  312. package/dist/types/schema/OrderByTypeProvider.d.ts.map +1 -1
  313. package/dist/types/schema/QueryProvider.d.ts.map +1 -1
  314. package/dist/types/schema/ValidationQueriesProvider.d.ts.map +1 -1
  315. package/dist/types/schema/WhereTypeProvider.d.ts.map +1 -1
  316. package/dist/types/schema/calendarDate.d.ts +6 -0
  317. package/dist/types/schema/calendarDate.d.ts.map +1 -0
  318. package/dist/types/schema/index.d.ts +1 -0
  319. package/dist/types/schema/index.d.ts.map +1 -1
  320. package/dist/types/schema/mutations/CreateEntityInputFieldVisitor.d.ts.map +1 -1
  321. package/dist/types/schema/mutations/UpdateEntityInputFieldVisitor.d.ts +3 -0
  322. package/dist/types/schema/mutations/UpdateEntityInputFieldVisitor.d.ts.map +1 -1
  323. package/dist/types/schema/mutations/UpdateEntityRelationInputFieldVisitor.d.ts +1 -0
  324. package/dist/types/schema/mutations/UpdateEntityRelationInputFieldVisitor.d.ts.map +1 -1
  325. package/dist/types/schema/utils.d.ts +7 -0
  326. package/dist/types/schema/utils.d.ts.map +1 -1
  327. package/dist/types/tsconfig.tsbuildinfo +1 -1
  328. package/package.json +10 -10
  329. package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts +3 -0
  330. package/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.ts +9 -7
  331. package/src/input-validation/preValidation/UpdateInputPreValidationProcessor.ts +29 -0
  332. package/src/inputProcessing/UpdateInputProcessor.ts +6 -0
  333. package/src/inputProcessing/UpdateInputVisitor.ts +64 -2
  334. package/src/mapper/ErrorUtils.ts +11 -0
  335. package/src/mapper/Mapper.ts +61 -1
  336. package/src/mapper/MutationProcessorHelper.ts +14 -0
  337. package/src/mapper/Result.ts +1 -0
  338. package/src/mapper/select/optimizer/WhereOptimizer.ts +1 -1
  339. package/src/mapper/select/optimizer/WhereReplacer.ts +1 -1
  340. package/src/mapper/types.ts +16 -1
  341. package/src/mapper/update/SqlUpdateInputProcessor.ts +4 -1
  342. package/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.ts +9 -0
  343. package/src/mapper/update/relations/OneHasManyUpdateInputProcessor.ts +9 -0
  344. package/src/mapper/update/relations/SetManyRelationHelper.ts +199 -0
  345. package/src/resolvers/MutationResolver.ts +2 -0
  346. package/src/schema/CustomTypesProvider.ts +40 -15
  347. package/src/schema/EntityTypeProvider.ts +8 -4
  348. package/src/schema/MutationProvider.ts +4 -0
  349. package/src/schema/OrderByTypeProvider.ts +9 -3
  350. package/src/schema/QueryProvider.ts +3 -0
  351. package/src/schema/ValidationQueriesProvider.ts +2 -0
  352. package/src/schema/WhereTypeProvider.ts +18 -6
  353. package/src/schema/calendarDate.ts +26 -0
  354. package/src/schema/index.ts +1 -0
  355. package/src/schema/mutations/CreateEntityInputFieldVisitor.ts +10 -2
  356. package/src/schema/mutations/UpdateEntityInputFieldVisitor.ts +10 -2
  357. package/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.ts +66 -7
  358. package/src/schema/utils.ts +14 -0
  359. package/src/tsconfig.json +2 -1
  360. package/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/set.test.ts +219 -0
  361. package/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/set.test.ts +479 -0
  362. package/tests/cases/integration/graphQlRequests/update/oneHasMany/set.test.ts +948 -0
  363. package/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.ts +102 -1
  364. package/tests/cases/integration/graphQlSchema/schema-acl-allowed.gql +17 -0
  365. package/tests/cases/integration/graphQlSchema/schema-acl-create-only.gql +1 -0
  366. package/tests/cases/integration/graphQlSchema/schema-acl-restricted-create.gql +14 -0
  367. package/tests/cases/integration/graphQlSchema/schema-acl-restricted-delete.gql +11 -0
  368. package/tests/cases/integration/graphQlSchema/schema-acl-restricted-read.gql +254 -0
  369. package/tests/cases/integration/graphQlSchema/schema-acl-restricted-update.gql +1 -0
  370. package/tests/cases/integration/graphQlSchema/schema-acl.gql +1 -0
  371. package/tests/cases/integration/graphQlSchema/schema-aliased-type.gql +1 -0
  372. package/tests/cases/integration/graphQlSchema/schema-array.gql +1 -0
  373. package/tests/cases/integration/graphQlSchema/schema-basic.gql +50 -0
  374. package/tests/cases/integration/graphQlSchema/schema-bug-66.gql +17 -0
  375. package/tests/cases/integration/graphQlSchema/schema-column-types.gql +1 -0
  376. package/tests/cases/integration/graphQlSchema/schema-custom-primary.gql +50 -0
  377. package/tests/cases/integration/graphQlSchema/schema-deprecation.gql +962 -0
  378. package/tests/cases/integration/graphQlSchema/schema-description.gql +992 -0
  379. package/tests/cases/integration/graphQlSchema/schema-has-many-reduction.gql +17 -0
  380. package/tests/cases/integration/graphQlSchema/schema-mixed-root-through.gql +1 -0
  381. package/tests/cases/integration/graphQlSchema/schema-new-builder.gql +50 -0
  382. package/tests/cases/integration/graphQlSchema/schema-no-root-ops.gql +1 -0
  383. package/tests/cases/unit/checkViolationError.test.ts +49 -0
  384. package/tests/cases/unit/dateType.test.ts +46 -0
  385. package/tests/cases/unit/decimalType.test.ts +2 -2
@@ -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.js'\nimport { UpdateBuilder } from './UpdateBuilder.js'\nimport { hasManyProcessor, hasOneProcessor } from '../MutationProcessorHelper.js'\nimport { OneHasOneInverseUpdateInputProcessor } from './relations/OneHasOneInverseUpdateInputProcessor.js'\nimport { OneHasOneOwningUpdateInputProcessor } from './relations/OneHasOneOwningUpdateInputProcessor.js'\nimport { OneHasManyUpdateInputProcessor } from './relations/OneHasManyUpdateInputProcessor.js'\nimport { ManyHasManyUpdateInputProcessor } from './relations/ManyHasManyUpdateInputProcessor.js'\nimport { UpdateInputProcessor } from '../../inputProcessing/index.js'\nimport { MutationResultList } from '../Result.js'\nimport { ManyHasOneUpdateInputProcessor } from './relations/ManyHasOneUpdateInputProcessor.js'\nimport { MapperInput } from '../types.js'\nimport { AclScope } from '../../acl/index.js'\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\t/** Scope of the entity being updated; relation targets are always reached over a relation and stay nested. */\n\t\tprivate readonly scope: AclScope,\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, this.scope, this.updateBuilder)\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":";;;;;;;;;;;AAgBO,MAAM,wBAAuF;AAAA,EAOnG,YACkB,cACA,MACA,eACA,QAEA,OAChB;AANgB,SAAA,eAAA;AACA,SAAA,OAAA;AACA,SAAA,gBAAA;AACA,SAAA,SAAA;AAEA,SAAA,QAAA;AAZlB,kBAAA,MAAQ,sCAAA;AACR,kBAAA,MAAQ,qCAAA;AACR,kBAAA,MAAQ,gCAAA;AACR,kBAAA,MAAQ,gCAAA;AACR,kBAAA,MAAQ,iCAAA;AAwBR,kBAAA,MAAA,sBAAgG;AAAA,MAC/F,SAASA,wBAAAA,iBAAiB,CAAA,QAAO,KAAK,gCAAgC,QAAQ,GAAG,CAAC;AAAA,MAClF,QAAQA,wBAAAA,iBAAiB,CAAA,QAAO,KAAK,gCAAgC,OAAO,GAAG,CAAC;AAAA,MAChF,iBAAiBA,wBAAAA,iBAAiB,CAAA,QAAO,KAAK,gCAAgC,gBAAgB,GAAG,CAAC;AAAA,MAClG,QAAQA,wBAAAA,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kCAAkC,IAAIC,gCAAAA,gCAAgC,KAAK,QAAQ,KAAK,OAAO,KAAK,aAAa;AAAA,EACvH;AAAA,EAEO,OAAO,EAAE,QAAQ,UAA+B;AACtD,QAAI,KAAK,KAAK,OAAO,IAAI,MAAM,QAAW;AACzC,WAAK,cAAc,cAAc,OAAO,MAAM,KAAK,KAAK,OAAO,IAAI,CAAsB;AAAA,IAC1F;AACA,WAAO,QAAQ,QAAQ,EAAE;AAAA,EAC1B;AA6DD;;"}
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.js'\nimport { UpdateBuilder } from './UpdateBuilder.js'\nimport { hasManyProcessor, hasOneProcessor, relationFieldProcessor } from '../MutationProcessorHelper.js'\nimport { OneHasOneInverseUpdateInputProcessor } from './relations/OneHasOneInverseUpdateInputProcessor.js'\nimport { OneHasOneOwningUpdateInputProcessor } from './relations/OneHasOneOwningUpdateInputProcessor.js'\nimport { OneHasManyUpdateInputProcessor } from './relations/OneHasManyUpdateInputProcessor.js'\nimport { ManyHasManyUpdateInputProcessor } from './relations/ManyHasManyUpdateInputProcessor.js'\nimport { UpdateInputProcessor } from '../../inputProcessing/index.js'\nimport { MutationResultList } from '../Result.js'\nimport { ManyHasOneUpdateInputProcessor } from './relations/ManyHasOneUpdateInputProcessor.js'\nimport { MapperInput } from '../types.js'\nimport { AclScope } from '../../acl/index.js'\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\t/** Scope of the entity being updated; relation targets are always reached over a relation and stay nested. */\n\t\tprivate readonly scope: AclScope,\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, this.scope, this.updateBuilder)\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\tset: relationFieldProcessor(ctx => this.manyHasManyUpdateInputProcessor.set(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\tset: relationFieldProcessor(ctx => this.manyHasManyUpdateInputProcessor.set(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\tset: relationFieldProcessor(ctx => this.oneHasManyUpdateInputProcessor.set(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","relationFieldProcessor","hasOneProcessor","OneHasOneInverseUpdateInputProcessor","OneHasOneOwningUpdateInputProcessor","OneHasManyUpdateInputProcessor","ManyHasOneUpdateInputProcessor","ManyHasManyUpdateInputProcessor"],"mappings":";;;;;;;;;;;AAgBO,MAAM,wBAAuF;AAAA,EAOnG,YACkB,cACA,MACA,eACA,QAEA,OAChB;AANgB,SAAA,eAAA;AACA,SAAA,OAAA;AACA,SAAA,gBAAA;AACA,SAAA,SAAA;AAEA,SAAA,QAAA;AAZlB,kBAAA,MAAQ,sCAAA;AACR,kBAAA,MAAQ,qCAAA;AACR,kBAAA,MAAQ,gCAAA;AACR,kBAAA,MAAQ,gCAAA;AACR,kBAAA,MAAQ,iCAAA;AAwBR,kBAAA,MAAA,sBAAgG;AAAA,MAC/F,SAASA,wBAAAA,iBAAiB,CAAA,QAAO,KAAK,gCAAgC,QAAQ,GAAG,CAAC;AAAA,MAClF,QAAQA,wBAAAA,iBAAiB,CAAA,QAAO,KAAK,gCAAgC,OAAO,GAAG,CAAC;AAAA,MAChF,iBAAiBA,wBAAAA,iBAAiB,CAAA,QAAO,KAAK,gCAAgC,gBAAgB,GAAG,CAAC;AAAA,MAClG,QAAQA,wB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AAK,cAAc,KAAK,MAAM;AACnH,SAAK,sCAAsC,IAAIC,oCAAAA,oCAAoC,KAAK,cAAc,KAAK,QAAQ,KAAK,aAAa;AACrI,SAAK,iCAAiC,IAAIC,8DAA+B,KAAK,MAAM;AACpF,SAAK,iCAAiC,IAAIC,+BAAAA,+BAA+B,KAAK,QAAQ,KAAK,eAAe,KAAK,YAAY;AAC3H,SAAK,kCAAkC,IAAIC,gCAAAA,gCAAgC,KAAK,QAAQ,KAAK,OAAO,KAAK,aAAa;AAAA,EACvH;AAAA,EAEO,OAAO,EAAE,QAAQ,UAA+B;AACtD,QAAI,KAAK,KAAK,OAAO,IAAI,MAAM,QAAW;AACzC,WAAK,cAAc,cAAc,OAAO,MAAM,KAAK,KAAK,OAAO,IAAI,CAAsB;AAAA,IAC1F;AACA,WAAO,QAAQ,QAAQ,EAAE;AAAA,EAC1B;AAgED;;"}
@@ -1,4 +1,4 @@
1
- import { hasManyProcessor, hasOneProcessor } from "../MutationProcessorHelper.js";
1
+ import { relationFieldProcessor, hasManyProcessor, hasOneProcessor } from "../MutationProcessorHelper.js";
2
2
  import { OneHasOneInverseUpdateInputProcessor } from "./relations/OneHasOneInverseUpdateInputProcessor.js";
3
3
  import { OneHasOneOwningUpdateInputProcessor } from "./relations/OneHasOneOwningUpdateInputProcessor.js";
4
4
  import { OneHasManyUpdateInputProcessor } from "./relations/OneHasManyUpdateInputProcessor.js";
@@ -26,7 +26,8 @@ class SqlUpdateInputProcessor {
26
26
  update: hasManyProcessor((ctx) => this.manyHasManyUpdateInputProcessor.update(ctx)),
27
27
  upsert: hasManyProcessor((ctx) => this.manyHasManyUpdateInputProcessor.upsert(ctx)),
28
28
  delete: hasManyProcessor((ctx) => this.manyHasManyUpdateInputProcessor.delete(ctx)),
29
- disconnect: hasManyProcessor((ctx) => this.manyHasManyUpdateInputProcessor.disconnect(ctx))
29
+ disconnect: hasManyProcessor((ctx) => this.manyHasManyUpdateInputProcessor.disconnect(ctx)),
30
+ set: relationFieldProcessor((ctx) => this.manyHasManyUpdateInputProcessor.set(ctx))
30
31
  });
31
32
  __publicField(this, "manyHasManyOwning", {
32
33
  connect: hasManyProcessor((ctx) => this.manyHasManyUpdateInputProcessor.connect(ctx)),
@@ -35,7 +36,8 @@ class SqlUpdateInputProcessor {
35
36
  update: hasManyProcessor((ctx) => this.manyHasManyUpdateInputProcessor.update(ctx)),
36
37
  upsert: hasManyProcessor((ctx) => this.manyHasManyUpdateInputProcessor.upsert(ctx)),
37
38
  delete: hasManyProcessor((ctx) => this.manyHasManyUpdateInputProcessor.delete(ctx)),
38
- disconnect: hasManyProcessor((ctx) => this.manyHasManyUpdateInputProcessor.disconnect(ctx))
39
+ disconnect: hasManyProcessor((ctx) => this.manyHasManyUpdateInputProcessor.disconnect(ctx)),
40
+ set: relationFieldProcessor((ctx) => this.manyHasManyUpdateInputProcessor.set(ctx))
39
41
  });
40
42
  __publicField(this, "manyHasOne", {
41
43
  connect: hasOneProcessor((ctx) => this.manyHasOneUpdateInputProcessor.connect(ctx)),
@@ -53,7 +55,8 @@ class SqlUpdateInputProcessor {
53
55
  update: hasManyProcessor((ctx) => this.oneHasManyUpdateInputProcessor.update(ctx)),
54
56
  upsert: hasManyProcessor((ctx) => this.oneHasManyUpdateInputProcessor.upsert(ctx)),
55
57
  delete: hasManyProcessor((ctx) => this.oneHasManyUpdateInputProcessor.delete(ctx)),
56
- disconnect: hasManyProcessor((ctx) => this.oneHasManyUpdateInputProcessor.disconnect(ctx))
58
+ disconnect: hasManyProcessor((ctx) => this.oneHasManyUpdateInputProcessor.disconnect(ctx)),
59
+ set: relationFieldProcessor((ctx) => this.oneHasManyUpdateInputProcessor.set(ctx))
57
60
  });
58
61
  __publicField(this, "oneHasOneInverse", {
59
62
  connect: hasOneProcessor((ctx) => this.oneHasOneInverseUpdateInputProcessor.connect(ctx)),
@@ -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.js'\nimport { UpdateBuilder } from './UpdateBuilder.js'\nimport { hasManyProcessor, hasOneProcessor } from '../MutationProcessorHelper.js'\nimport { OneHasOneInverseUpdateInputProcessor } from './relations/OneHasOneInverseUpdateInputProcessor.js'\nimport { OneHasOneOwningUpdateInputProcessor } from './relations/OneHasOneOwningUpdateInputProcessor.js'\nimport { OneHasManyUpdateInputProcessor } from './relations/OneHasManyUpdateInputProcessor.js'\nimport { ManyHasManyUpdateInputProcessor } from './relations/ManyHasManyUpdateInputProcessor.js'\nimport { UpdateInputProcessor } from '../../inputProcessing/index.js'\nimport { MutationResultList } from '../Result.js'\nimport { ManyHasOneUpdateInputProcessor } from './relations/ManyHasOneUpdateInputProcessor.js'\nimport { MapperInput } from '../types.js'\nimport { AclScope } from '../../acl/index.js'\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\t/** Scope of the entity being updated; relation targets are always reached over a relation and stay nested. */\n\t\tprivate readonly scope: AclScope,\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, this.scope, this.updateBuilder)\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":";;;;;;;;;AAgBO,MAAM,wBAAuF;AAAA,EAOnG,YACkB,cACA,MACA,eACA,QAEA,OAChB;AANgB,S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,iCAAiC,IAAI,+BAA+B,KAAK,MAAM;AACpF,SAAK,iCAAiC,IAAI,+BAA+B,KAAK,QAAQ,KAAK,eAAe,KAAK,YAAY;AAC3H,SAAK,kCAAkC,IAAI,gCAAgC,KAAK,QAAQ,KAAK,OAAO,KAAK,aAAa;AAAA,EACvH;AAAA,EAEO,OAAO,EAAE,QAAQ,UAA+B;AACtD,QAAI,KAAK,KAAK,OAAO,IAAI,MAAM,QAAW;AACzC,WAAK,cAAc,cAAc,OAAO,MAAM,KAAK,KAAK,OAAO,IAAI,CAAsB;AAAA,IAC1F;AACA,WAAO,QAAQ,QAAQ,EAAE;AAAA,EAC1B;AA6DD;"}
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.js'\nimport { UpdateBuilder } from './UpdateBuilder.js'\nimport { hasManyProcessor, hasOneProcessor, relationFieldProcessor } from '../MutationProcessorHelper.js'\nimport { OneHasOneInverseUpdateInputProcessor } from './relations/OneHasOneInverseUpdateInputProcessor.js'\nimport { OneHasOneOwningUpdateInputProcessor } from './relations/OneHasOneOwningUpdateInputProcessor.js'\nimport { OneHasManyUpdateInputProcessor } from './relations/OneHasManyUpdateInputProcessor.js'\nimport { ManyHasManyUpdateInputProcessor } from './relations/ManyHasManyUpdateInputProcessor.js'\nimport { UpdateInputProcessor } from '../../inputProcessing/index.js'\nimport { MutationResultList } from '../Result.js'\nimport { ManyHasOneUpdateInputProcessor } from './relations/ManyHasOneUpdateInputProcessor.js'\nimport { MapperInput } from '../types.js'\nimport { AclScope } from '../../acl/index.js'\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\t/** Scope of the entity being updated; relation targets are always reached over a relation and stay nested. */\n\t\tprivate readonly scope: AclScope,\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, this.scope, this.updateBuilder)\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\tset: relationFieldProcessor(ctx => this.manyHasManyUpdateInputProcessor.set(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\tset: relationFieldProcessor(ctx => this.manyHasManyUpdateInputProcessor.set(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\tset: relationFieldProcessor(ctx => this.oneHasManyUpdateInputProcessor.set(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":";;;;;;;;;AAgBO,MAAM,wBAAuF;AAAA,EAOnG,YACkB,cACA,MACA,eACA,QAEA,OAChB;AANgB,SAAA,eAAA;AACA,SAAA,OAAA;AACA,SAAA,gBAAA;AACA,SAAA,SAAA;AAEA,SAAA,QAAA;AAZlB,kBAAA,MAAQ,sCAAA;AACR,kBAAA,MAAQ,qCAAA;AACR,kBAAA,MAAQ,gCAAA;AACR,kBAAA,MAAQ,gCAAA;AACR,kBAAA,MAAQ,iCAAA;AAwBR,kBAAA,MAAA,sBAAgG;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,QAA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CAAsB;AAAA,IAC1F;AACA,WAAO,QAAQ,QAAQ,EAAE;AAAA,EAC1B;AAgED;"}
@@ -7,7 +7,7 @@ const UpdateInputVisitor = require("../../inputProcessing/UpdateInputVisitor.cjs
7
7
  const Result = require("../Result.cjs");
8
8
  const ColumnValue = require("../ColumnValue.cjs");
9
9
  const AclScope = require("../../acl/AclScope.cjs");
10
- require("fast-deep-equal");
10
+ require("@contember/utilities");
11
11
  require("../../acl/PredicatesInjector.cjs");
12
12
  class Updater {
13
13
  constructor(schema, updateBuilderFactory) {
@@ -5,7 +5,7 @@ import { UpdateInputVisitor } from "../../inputProcessing/UpdateInputVisitor.js"
5
5
  import { MutationNoResultError, MutationEntryNotFoundError, MutationNothingToDo, NothingToDoReason, MutationUpdateOk } from "../Result.js";
6
6
  import { rowDataToFieldValues } from "../ColumnValue.js";
7
7
  import { ROW_LOOKUP_SCOPE } from "../../acl/AclScope.js";
8
- import "fast-deep-equal";
8
+ import "@contember/utilities";
9
9
  import "../../acl/PredicatesInjector.js";
10
10
  class Updater {
11
11
  constructor(schema, updateBuilderFactory) {
@@ -2,12 +2,18 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const Result = require("../../Result.cjs");
4
4
  const CheckedPrimary = require("../../CheckedPrimary.cjs");
5
+ const SetManyRelationHelper = require("./SetManyRelationHelper.cjs");
5
6
  class ManyHasManyUpdateInputProcessor {
6
7
  constructor(mapper, scope, updateBuilder) {
7
8
  this.mapper = mapper;
8
9
  this.scope = scope;
9
10
  this.updateBuilder = updateBuilder;
10
11
  }
12
+ async set(context) {
13
+ return async ({ primary }) => {
14
+ return await SetManyRelationHelper.processSetManyRelationInput(this.mapper, context, primary, this, context.input);
15
+ };
16
+ }
11
17
  async connect({ entity, targetEntity, relation, targetRelation, input }) {
12
18
  this.updateBuilder.markPredicateCheckedElsewhere(relation.name);
13
19
  return async ({ primary }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"ManyHasManyUpdateInputProcessor.cjs","sources":["../../../../../../../packages/engine-content-api/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.ts"],"sourcesContent":["import { UpdateInputProcessor } from '../../../inputProcessing/index.js'\nimport { Input, Model } from '@contember/schema'\nimport { getInsertPrimary, MutationEntryNotFoundError } from '../../Result.js'\nimport { Mapper } from '../../Mapper.js'\nimport { SqlUpdateInputProcessorResult } from '../../update/index.js'\nimport { CheckedPrimary } from '../../CheckedPrimary.js'\nimport { MapperInput } from '../../types.js'\nimport { AclScope } from '../../../acl/index.js'\nimport { UpdateBuilder } from '../UpdateBuilder.js'\n\ntype Context = Model.ManyHasManyOwningContext | Model.ManyHasManyInverseContext\n\nexport class ManyHasManyUpdateInputProcessor implements UpdateInputProcessor.HasManyRelationInputProcessor<Context, SqlUpdateInputProcessorResult> {\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t\t/** Scope of the entity being written, the one that declares this relation; the other side of the junction stays nested. */\n\t\tprivate readonly scope: AclScope,\n\t\tprivate readonly updateBuilder: UpdateBuilder,\n\t) {\n\t}\n\n\tpublic async connect(\n\t\t{ entity, targetEntity, relation, targetRelation, input }: Context & { input: Input.UniqueWhere | CheckedPrimary },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst [otherPrimary, err] = await this.mapper.getPrimaryValue(targetEntity, input, 'nested')\n\t\t\tif (err) return [err]\n\t\t\treturn await this.mapper.connectJunction(entity, relation, primary, otherPrimary, this.scope)\n\t\t}\n\t}\n\n\tpublic async create(\n\t\t{ entity, targetEntity, relation, input }: Context & { input: MapperInput.CreateDataInput },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst insertResult = await this.mapper.insert(targetEntity, input, 'nested')\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\treturn [\n\t\t\t\t...insertResult,\n\t\t\t\t...(await this.mapper.connectJunction(entity, relation, primary, insertPrimary, this.scope)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async connectOrCreate(\n\t\tcontext: Context & { input: MapperInput.ConnectOrCreateInput },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(context.relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tlet [otherPrimary] = await this.mapper.getPrimaryValue(context.targetEntity, context.input.connect, 'nested')\n\t\t\tif (!otherPrimary) {\n\t\t\t\tconst insertResult = await this.mapper.insert(context.targetEntity, context.input.create, 'nested')\n\t\t\t\totherPrimary = getInsertPrimary(insertResult)\n\t\t\t\tif (!otherPrimary) {\n\t\t\t\t\treturn insertResult\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn await this.mapper.connectJunction(context.entity, context.relation, primary, otherPrimary, this.scope)\n\t\t}\n\t}\n\n\tpublic async update(\n\t\t{ entity, targetEntity, relation, input: { where, data } }: Context & { input: UpdateInputProcessor.UpdateManyInput },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst [otherPrimary, err] = await this.mapper.getPrimaryValue(targetEntity, where, 'nested')\n\t\t\tif (err) return [err]\n\t\t\treturn [\n\t\t\t\t...(await this.mapper.update(targetEntity, new CheckedPrimary(otherPrimary), data, 'nested')),\n\t\t\t\t...(await this.mapper.connectJunction(entity, relation, primary, otherPrimary, this.scope)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async upsert(\n\t\t{ entity, relation, targetEntity, input: { create, update, where } }: Context & { input: UpdateInputProcessor.UpsertManyInput },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst [otherPrimary] = await this.mapper.getPrimaryValue(targetEntity, where, 'nested')\n\t\t\tif (otherPrimary) {\n\t\t\t\tconst updateResult = await this.mapper.update(targetEntity, new CheckedPrimary(otherPrimary), update, 'nested')\n\t\t\t\tconst connectResult = await this.mapper.connectJunction(entity, relation, primary, otherPrimary, this.scope)\n\t\t\t\treturn [...updateResult, ...connectResult]\n\t\t\t} else {\n\t\t\t\tconst insertResult = await this.mapper.insert(targetEntity, create, 'nested')\n\n\t\t\t\tconst primaryValue = getInsertPrimary(insertResult)\n\t\t\t\tif (!primaryValue) {\n\t\t\t\t\treturn insertResult\n\t\t\t\t}\n\t\t\t\tconst connectResult = await this.mapper.connectJunction(entity, relation, primary, primaryValue, this.scope)\n\t\t\t\treturn [...insertResult, ...connectResult]\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic async disconnect(\n\t\t{ entity, targetEntity, relation, input }: Context & { input: Input.UniqueWhere },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst [otherPrimary, err] = await this.mapper.getPrimaryValue(targetEntity, input, 'nested')\n\t\t\tif (err) return [err]\n\n\t\t\treturn await this.mapper.disconnectJunction(entity, relation, primary, otherPrimary, this.scope)\n\t\t}\n\t}\n\n\tpublic async delete(\n\t\t{ entity, targetEntity, relation, targetRelation, input }: Context & { input: Input.UniqueWhere },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.delete(targetEntity, input, 'nested')\n\t\t}\n\t}\n}\n"],"names":["getInsertPrimary","CheckedPrimary"],"mappings":";;;;AAYO,MAAM,gCAAsI;AAAA,EAClJ,YACkB,QAEA,OACA,eAChB;AAJgB,SAAA,SAAA;AAEA,SAAA,QAAA;AACA,SAAA,gBAAA;AAAA,EAElB;AAAA,EAEA,MAAa,QACZ,EAAE,QAAQ,cAAc,UAAU,gBAAgB,SACjD;AACD,SAAK,c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G,cAAc,GAAG,aAAa;AAAA,MAC1C;AAAA,IACD;AAAA,EACD;AAAA,EAEA,MAAa,WACZ,EAAE,QAAQ,cAAc,UAAU,SACjC;AACD,SAAK,cAAc,8BAA8B,SAAS,IAAI;AAC9D,WAAO,OAAO,EAAE,cAA+C;AAC9D,YAAM,CAAC,cAAc,GAAG,IAAI,MAAM,KAAK,OAAO,gBAAgB,cAAc,OAAO,QAAQ;AAC3F,UAAI,IAAK,QAAO,CAAC,GAAG;AAEpB,aAAO,MAAM,KAAK,OAAO,mBAAmB,QAAQ,UAAU,SAAS,cAAc,KAAK,KAAK;AAAA,IAChG;AAAA,EACD;AAAA,EAEA,MAAa,OACZ,EAAE,QAAQ,cAAc,UAAU,gBAAgB,SACjD;AACD,WAAO,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc,OAAO,QAAQ;AAAA,IAC9D;AAAA,EACD;AACD;;"}
1
+ {"version":3,"file":"ManyHasManyUpdateInputProcessor.cjs","sources":["../../../../../../../packages/engine-content-api/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.ts"],"sourcesContent":["import { UpdateInputProcessor } from '../../../inputProcessing/index.js'\nimport { Input, Model } from '@contember/schema'\nimport { getInsertPrimary, MutationEntryNotFoundError } from '../../Result.js'\nimport { Mapper } from '../../Mapper.js'\nimport { SqlUpdateInputProcessorResult } from '../../update/index.js'\nimport { CheckedPrimary } from '../../CheckedPrimary.js'\nimport { MapperInput } from '../../types.js'\nimport { AclScope } from '../../../acl/index.js'\nimport { UpdateBuilder } from '../UpdateBuilder.js'\nimport { processSetManyRelationInput } from './SetManyRelationHelper.js'\n\ntype Context = Model.ManyHasManyOwningContext | Model.ManyHasManyInverseContext\n\nexport class ManyHasManyUpdateInputProcessor implements UpdateInputProcessor.HasManyRelationInputProcessor<Context, SqlUpdateInputProcessorResult> {\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t\t/** Scope of the entity being written, the one that declares this relation; the other side of the junction stays nested. */\n\t\tprivate readonly scope: AclScope,\n\t\tprivate readonly updateBuilder: UpdateBuilder,\n\t) {\n\t}\n\n\tpublic async set(\n\t\tcontext: Context & { input: UpdateInputProcessor.SetManyInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await processSetManyRelationInput(this.mapper, context, primary, this, context.input)\n\t\t}\n\t}\n\n\tpublic async connect(\n\t\t{ entity, targetEntity, relation, targetRelation, input }: Context & { input: Input.UniqueWhere | CheckedPrimary },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst [otherPrimary, err] = await this.mapper.getPrimaryValue(targetEntity, input, 'nested')\n\t\t\tif (err) return [err]\n\t\t\treturn await this.mapper.connectJunction(entity, relation, primary, otherPrimary, this.scope)\n\t\t}\n\t}\n\n\tpublic async create(\n\t\t{ entity, targetEntity, relation, input }: Context & { input: MapperInput.CreateDataInput },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst insertResult = await this.mapper.insert(targetEntity, input, 'nested')\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\treturn [\n\t\t\t\t...insertResult,\n\t\t\t\t...(await this.mapper.connectJunction(entity, relation, primary, insertPrimary, this.scope)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async connectOrCreate(\n\t\tcontext: Context & { input: MapperInput.ConnectOrCreateInput },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(context.relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tlet [otherPrimary] = await this.mapper.getPrimaryValue(context.targetEntity, context.input.connect, 'nested')\n\t\t\tif (!otherPrimary) {\n\t\t\t\tconst insertResult = await this.mapper.insert(context.targetEntity, context.input.create, 'nested')\n\t\t\t\totherPrimary = getInsertPrimary(insertResult)\n\t\t\t\tif (!otherPrimary) {\n\t\t\t\t\treturn insertResult\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn await this.mapper.connectJunction(context.entity, context.relation, primary, otherPrimary, this.scope)\n\t\t}\n\t}\n\n\tpublic async update(\n\t\t{ entity, targetEntity, relation, input: { where, data } }: Context & { input: UpdateInputProcessor.UpdateManyInput },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst [otherPrimary, err] = await this.mapper.getPrimaryValue(targetEntity, where, 'nested')\n\t\t\tif (err) return [err]\n\t\t\treturn [\n\t\t\t\t...(await this.mapper.update(targetEntity, new CheckedPrimary(otherPrimary), data, 'nested')),\n\t\t\t\t...(await this.mapper.connectJunction(entity, relation, primary, otherPrimary, this.scope)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async upsert(\n\t\t{ entity, relation, targetEntity, input: { create, update, where } }: Context & { input: UpdateInputProcessor.UpsertManyInput },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst [otherPrimary] = await this.mapper.getPrimaryValue(targetEntity, where, 'nested')\n\t\t\tif (otherPrimary) {\n\t\t\t\tconst updateResult = await this.mapper.update(targetEntity, new CheckedPrimary(otherPrimary), update, 'nested')\n\t\t\t\tconst connectResult = await this.mapper.connectJunction(entity, relation, primary, otherPrimary, this.scope)\n\t\t\t\treturn [...updateResult, ...connectResult]\n\t\t\t} else {\n\t\t\t\tconst insertResult = await this.mapper.insert(targetEntity, create, 'nested')\n\n\t\t\t\tconst primaryValue = getInsertPrimary(insertResult)\n\t\t\t\tif (!primaryValue) {\n\t\t\t\t\treturn insertResult\n\t\t\t\t}\n\t\t\t\tconst connectResult = await this.mapper.connectJunction(entity, relation, primary, primaryValue, this.scope)\n\t\t\t\treturn [...insertResult, ...connectResult]\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic async disconnect(\n\t\t{ entity, targetEntity, relation, input }: Context & { input: Input.UniqueWhere },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst [otherPrimary, err] = await this.mapper.getPrimaryValue(targetEntity, input, 'nested')\n\t\t\tif (err) return [err]\n\n\t\t\treturn await this.mapper.disconnectJunction(entity, relation, primary, otherPrimary, this.scope)\n\t\t}\n\t}\n\n\tpublic async delete(\n\t\t{ entity, targetEntity, relation, targetRelation, input }: Context & { input: Input.UniqueWhere },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.delete(targetEntity, input, 'nested')\n\t\t}\n\t}\n}\n"],"names":["processSetManyRelationInput","getInsertPrimary","CheckedPrimary"],"mappings":";;;;;AAaO,MAAM,gCAAsI;AAAA,EAClJ,YACkB,QAEA,OACA,eAChB;AAJgB,SAAA,SAAA;AAEA,SAAA,QAAA;AACA,SAAA,gBAAA;AAAA,EAElB;AAAA,EAEA,MAAa,IACZ,SACC;AACD,WAAO,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAMA,sBAAAA,4BAA4B,KAAK,QAAQ,SAAS,SAAS,MAAM,QAAQ,KAAK;AAAA,IAC5F;AAAA,EACD;AAAA,EAEA,MAAa,QACZ,EAAE,QAAQ,cAAc,UAAU,gBAAgB,SACjD;AACD,SAAK,cAAc,8BAA8B,SAAS,IAAI;AAC9D,WAAO,OAAO,EAAE,cAA+C;AAC9D,YAAM,CAAC,cAAc,GAAG,IAAI,MAAM,KAAK,OAAO,gBAAgB,cAAc,OAAO,QAAQ;AAC3F,UAAI,IAAK,QAAO,CAAC,GAAG;AACpB,aAAO,MAAM,KAAK,OAAO,gBAAgB,QAAQ,UAAU,S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AAO,gBAAgB,cAAc,OAAO,QAAQ;AAC3F,UAAI,IAAK,QAAO,CAAC,GAAG;AAEpB,aAAO,MAAM,KAAK,OAAO,mBAAmB,QAAQ,UAAU,SAAS,cAAc,KAAK,KAAK;AAAA,IAChG;AAAA,EACD;AAAA,EAEA,MAAa,OACZ,EAAE,QAAQ,cAAc,UAAU,gBAAgB,SACjD;AACD,WAAO,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc,OAAO,QAAQ;AAAA,IAC9D;AAAA,EACD;AACD;;"}
@@ -1,11 +1,17 @@
1
1
  import { getInsertPrimary } from "../../Result.js";
2
2
  import { CheckedPrimary } from "../../CheckedPrimary.js";
3
+ import { processSetManyRelationInput } from "./SetManyRelationHelper.js";
3
4
  class ManyHasManyUpdateInputProcessor {
4
5
  constructor(mapper, scope, updateBuilder) {
5
6
  this.mapper = mapper;
6
7
  this.scope = scope;
7
8
  this.updateBuilder = updateBuilder;
8
9
  }
10
+ async set(context) {
11
+ return async ({ primary }) => {
12
+ return await processSetManyRelationInput(this.mapper, context, primary, this, context.input);
13
+ };
14
+ }
9
15
  async connect({ entity, targetEntity, relation, targetRelation, input }) {
10
16
  this.updateBuilder.markPredicateCheckedElsewhere(relation.name);
11
17
  return async ({ primary }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"ManyHasManyUpdateInputProcessor.js","sources":["../../../../../../../packages/engine-content-api/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.ts"],"sourcesContent":["import { UpdateInputProcessor } from '../../../inputProcessing/index.js'\nimport { Input, Model } from '@contember/schema'\nimport { getInsertPrimary, MutationEntryNotFoundError } from '../../Result.js'\nimport { Mapper } from '../../Mapper.js'\nimport { SqlUpdateInputProcessorResult } from '../../update/index.js'\nimport { CheckedPrimary } from '../../CheckedPrimary.js'\nimport { MapperInput } from '../../types.js'\nimport { AclScope } from '../../../acl/index.js'\nimport { UpdateBuilder } from '../UpdateBuilder.js'\n\ntype Context = Model.ManyHasManyOwningContext | Model.ManyHasManyInverseContext\n\nexport class ManyHasManyUpdateInputProcessor implements UpdateInputProcessor.HasManyRelationInputProcessor<Context, SqlUpdateInputProcessorResult> {\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t\t/** Scope of the entity being written, the one that declares this relation; the other side of the junction stays nested. */\n\t\tprivate readonly scope: AclScope,\n\t\tprivate readonly updateBuilder: UpdateBuilder,\n\t) {\n\t}\n\n\tpublic async connect(\n\t\t{ entity, targetEntity, relation, targetRelation, input }: Context & { input: Input.UniqueWhere | CheckedPrimary },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst [otherPrimary, err] = await this.mapper.getPrimaryValue(targetEntity, input, 'nested')\n\t\t\tif (err) return [err]\n\t\t\treturn await this.mapper.connectJunction(entity, relation, primary, otherPrimary, this.scope)\n\t\t}\n\t}\n\n\tpublic async create(\n\t\t{ entity, targetEntity, relation, input }: Context & { input: MapperInput.CreateDataInput },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst insertResult = await this.mapper.insert(targetEntity, input, 'nested')\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\treturn [\n\t\t\t\t...insertResult,\n\t\t\t\t...(await this.mapper.connectJunction(entity, relation, primary, insertPrimary, this.scope)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async connectOrCreate(\n\t\tcontext: Context & { input: MapperInput.ConnectOrCreateInput },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(context.relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tlet [otherPrimary] = await this.mapper.getPrimaryValue(context.targetEntity, context.input.connect, 'nested')\n\t\t\tif (!otherPrimary) {\n\t\t\t\tconst insertResult = await this.mapper.insert(context.targetEntity, context.input.create, 'nested')\n\t\t\t\totherPrimary = getInsertPrimary(insertResult)\n\t\t\t\tif (!otherPrimary) {\n\t\t\t\t\treturn insertResult\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn await this.mapper.connectJunction(context.entity, context.relation, primary, otherPrimary, this.scope)\n\t\t}\n\t}\n\n\tpublic async update(\n\t\t{ entity, targetEntity, relation, input: { where, data } }: Context & { input: UpdateInputProcessor.UpdateManyInput },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst [otherPrimary, err] = await this.mapper.getPrimaryValue(targetEntity, where, 'nested')\n\t\t\tif (err) return [err]\n\t\t\treturn [\n\t\t\t\t...(await this.mapper.update(targetEntity, new CheckedPrimary(otherPrimary), data, 'nested')),\n\t\t\t\t...(await this.mapper.connectJunction(entity, relation, primary, otherPrimary, this.scope)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async upsert(\n\t\t{ entity, relation, targetEntity, input: { create, update, where } }: Context & { input: UpdateInputProcessor.UpsertManyInput },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst [otherPrimary] = await this.mapper.getPrimaryValue(targetEntity, where, 'nested')\n\t\t\tif (otherPrimary) {\n\t\t\t\tconst updateResult = await this.mapper.update(targetEntity, new CheckedPrimary(otherPrimary), update, 'nested')\n\t\t\t\tconst connectResult = await this.mapper.connectJunction(entity, relation, primary, otherPrimary, this.scope)\n\t\t\t\treturn [...updateResult, ...connectResult]\n\t\t\t} else {\n\t\t\t\tconst insertResult = await this.mapper.insert(targetEntity, create, 'nested')\n\n\t\t\t\tconst primaryValue = getInsertPrimary(insertResult)\n\t\t\t\tif (!primaryValue) {\n\t\t\t\t\treturn insertResult\n\t\t\t\t}\n\t\t\t\tconst connectResult = await this.mapper.connectJunction(entity, relation, primary, primaryValue, this.scope)\n\t\t\t\treturn [...insertResult, ...connectResult]\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic async disconnect(\n\t\t{ entity, targetEntity, relation, input }: Context & { input: Input.UniqueWhere },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst [otherPrimary, err] = await this.mapper.getPrimaryValue(targetEntity, input, 'nested')\n\t\t\tif (err) return [err]\n\n\t\t\treturn await this.mapper.disconnectJunction(entity, relation, primary, otherPrimary, this.scope)\n\t\t}\n\t}\n\n\tpublic async delete(\n\t\t{ entity, targetEntity, relation, targetRelation, input }: Context & { input: Input.UniqueWhere },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.delete(targetEntity, input, 'nested')\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAYO,MAAM,gCAAsI;AAAA,EAClJ,YACkB,QAEA,OACA,eAChB;AAJgB,SAAA,SAAA;AAEA,SAAA,QAAA;AACA,SAAA,gBAAA;AAAA,EAElB;AAAA,EAEA,MAAa,QACZ,EAAE,QAAQ,cAAc,UAAU,gBAAgB,SACjD;AACD,SAAK,cAAc,8BAA8B,SAAS,IAAI;AAC9D,WAAO,OAAO,EAAE,cAA+C;AAC9D,YAAM,CAAC,cAAc,GAAG,IAAI,MAAM,KAAK,OAAO,gBAAgB,cAAc,OAAO,QAAQ;AAC3F,UAAI,IAAK,QAAO,CAAC,GAAG;AACpB,aAAO,MAAM,KAAK,OAAO,gBAAgB,QAAQ,UAAU,SAAS,cAAc,KAAK,KAAK;AAAA,IAC7F;AAAA,EACD;AAAA,EAEA,MAAa,OACZ,EAAE,QAAQ,cAAc,UAAU,SACjC;AACD,SAAK,cAAc,8BAA8B,SAAS,IAAI;AAC9D,WAAO,OAAO,EAAE,cAA+C;A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Ac,UAAU,gBAAgB,SACjD;AACD,WAAO,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc,OAAO,QAAQ;AAAA,IAC9D;AAAA,EACD;AACD;"}
1
+ {"version":3,"file":"ManyHasManyUpdateInputProcessor.js","sources":["../../../../../../../packages/engine-content-api/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.ts"],"sourcesContent":["import { UpdateInputProcessor } from '../../../inputProcessing/index.js'\nimport { Input, Model } from '@contember/schema'\nimport { getInsertPrimary, MutationEntryNotFoundError } from '../../Result.js'\nimport { Mapper } from '../../Mapper.js'\nimport { SqlUpdateInputProcessorResult } from '../../update/index.js'\nimport { CheckedPrimary } from '../../CheckedPrimary.js'\nimport { MapperInput } from '../../types.js'\nimport { AclScope } from '../../../acl/index.js'\nimport { UpdateBuilder } from '../UpdateBuilder.js'\nimport { processSetManyRelationInput } from './SetManyRelationHelper.js'\n\ntype Context = Model.ManyHasManyOwningContext | Model.ManyHasManyInverseContext\n\nexport class ManyHasManyUpdateInputProcessor implements UpdateInputProcessor.HasManyRelationInputProcessor<Context, SqlUpdateInputProcessorResult> {\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t\t/** Scope of the entity being written, the one that declares this relation; the other side of the junction stays nested. */\n\t\tprivate readonly scope: AclScope,\n\t\tprivate readonly updateBuilder: UpdateBuilder,\n\t) {\n\t}\n\n\tpublic async set(\n\t\tcontext: Context & { input: UpdateInputProcessor.SetManyInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await processSetManyRelationInput(this.mapper, context, primary, this, context.input)\n\t\t}\n\t}\n\n\tpublic async connect(\n\t\t{ entity, targetEntity, relation, targetRelation, input }: Context & { input: Input.UniqueWhere | CheckedPrimary },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst [otherPrimary, err] = await this.mapper.getPrimaryValue(targetEntity, input, 'nested')\n\t\t\tif (err) return [err]\n\t\t\treturn await this.mapper.connectJunction(entity, relation, primary, otherPrimary, this.scope)\n\t\t}\n\t}\n\n\tpublic async create(\n\t\t{ entity, targetEntity, relation, input }: Context & { input: MapperInput.CreateDataInput },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst insertResult = await this.mapper.insert(targetEntity, input, 'nested')\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\treturn [\n\t\t\t\t...insertResult,\n\t\t\t\t...(await this.mapper.connectJunction(entity, relation, primary, insertPrimary, this.scope)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async connectOrCreate(\n\t\tcontext: Context & { input: MapperInput.ConnectOrCreateInput },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(context.relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tlet [otherPrimary] = await this.mapper.getPrimaryValue(context.targetEntity, context.input.connect, 'nested')\n\t\t\tif (!otherPrimary) {\n\t\t\t\tconst insertResult = await this.mapper.insert(context.targetEntity, context.input.create, 'nested')\n\t\t\t\totherPrimary = getInsertPrimary(insertResult)\n\t\t\t\tif (!otherPrimary) {\n\t\t\t\t\treturn insertResult\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn await this.mapper.connectJunction(context.entity, context.relation, primary, otherPrimary, this.scope)\n\t\t}\n\t}\n\n\tpublic async update(\n\t\t{ entity, targetEntity, relation, input: { where, data } }: Context & { input: UpdateInputProcessor.UpdateManyInput },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst [otherPrimary, err] = await this.mapper.getPrimaryValue(targetEntity, where, 'nested')\n\t\t\tif (err) return [err]\n\t\t\treturn [\n\t\t\t\t...(await this.mapper.update(targetEntity, new CheckedPrimary(otherPrimary), data, 'nested')),\n\t\t\t\t...(await this.mapper.connectJunction(entity, relation, primary, otherPrimary, this.scope)),\n\t\t\t]\n\t\t}\n\t}\n\n\tpublic async upsert(\n\t\t{ entity, relation, targetEntity, input: { create, update, where } }: Context & { input: UpdateInputProcessor.UpsertManyInput },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst [otherPrimary] = await this.mapper.getPrimaryValue(targetEntity, where, 'nested')\n\t\t\tif (otherPrimary) {\n\t\t\t\tconst updateResult = await this.mapper.update(targetEntity, new CheckedPrimary(otherPrimary), update, 'nested')\n\t\t\t\tconst connectResult = await this.mapper.connectJunction(entity, relation, primary, otherPrimary, this.scope)\n\t\t\t\treturn [...updateResult, ...connectResult]\n\t\t\t} else {\n\t\t\t\tconst insertResult = await this.mapper.insert(targetEntity, create, 'nested')\n\n\t\t\t\tconst primaryValue = getInsertPrimary(insertResult)\n\t\t\t\tif (!primaryValue) {\n\t\t\t\t\treturn insertResult\n\t\t\t\t}\n\t\t\t\tconst connectResult = await this.mapper.connectJunction(entity, relation, primary, primaryValue, this.scope)\n\t\t\t\treturn [...insertResult, ...connectResult]\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic async disconnect(\n\t\t{ entity, targetEntity, relation, input }: Context & { input: Input.UniqueWhere },\n\t) {\n\t\tthis.updateBuilder.markPredicateCheckedElsewhere(relation.name)\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst [otherPrimary, err] = await this.mapper.getPrimaryValue(targetEntity, input, 'nested')\n\t\t\tif (err) return [err]\n\n\t\t\treturn await this.mapper.disconnectJunction(entity, relation, primary, otherPrimary, this.scope)\n\t\t}\n\t}\n\n\tpublic async delete(\n\t\t{ entity, targetEntity, relation, targetRelation, input }: Context & { input: Input.UniqueWhere },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.delete(targetEntity, input, 'nested')\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;AAaO,MAAM,gCAAsI;AAAA,EAClJ,YACkB,QAEA,OACA,eAChB;AAJgB,SAAA,SAAA;AAEA,SAAA,QAAA;AACA,SAAA,gBAAA;AAAA,EAElB;AAAA,EAEA,MAAa,IACZ,SACC;AACD,WAAO,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,4BAA4B,KAAK,QAAQ,SAAS,SAAS,MAAM,QAAQ,KAAK;AAAA,IAC5F;AAAA,EACD;AAAA,EAEA,MAAa,QACZ,EAAE,QAAQ,cAAc,UAAU,gBAAgB,SACjD;AACD,SAAK,cAAc,8BAA8B,SAAS,IAAI;AAC9D,WAAO,OAAO,EAAE,cAA+C;AAC9D,YAAM,CAAC,cAAc,GAAG,IAAI,MAAM,KAAK,OAAO,gBAAgB,cAAc,OAAO,QAAQ;AAC3F,UAAI,IAAK,QAAO,CAAC,GAAG;AACpB,aAAO,MAAM,KAAK,OAAO,gBAAgB,QAAQ,UAAU,SAAS,cAAc,KAAK,KAAK;AAAA,IAC7F;AAAA,EACD;AAAA,EAEA,MAAa,OACZ,EAAE,QAAQ,cAAc,UAAU,SACjC;AACD,SAAK,cAAc,8BAA8B,SAAS,IAAI;AAC9D,WAAO,OAAO,EAAE,cAA+C;AAC9D,YAAM,eAAe,MAAM,KAAK,OAAO,OAAO,cAAc,OAAO,QAAQ;AAC3E,YAAM,gBAAgB,iBAAiB,YAAY;AACnD,UAAI,CAAC,eAAe;AACnB,eAAO;AAAA,MACR;AACA,aAAO;AAAA,QACN,GAAG;AAAA,QACH,GAAI,MAAM,KAAK,OAAO,gBAAgB,QAAQ,UAAU,SAAS,eAAe,KAAK,KAAK;AAAA,MAAA;AAAA,IAE5F;AAAA,EACD;AAAA,EAEA,MAAa,gBACZ,SACC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M,eAAe,MAAM,KAAK,OAAO,OAAO,cAAc,IAAI,eAAe,YAAY,GAAG,QAAQ,QAAQ;AAC9G,cAAM,gBAAgB,MAAM,KAAK,OAAO,gBAAgB,QAAQ,UAAU,SAAS,cAAc,KAAK,KAAK;AAC3G,eAAO,CAAC,GAAG,cAAc,GAAG,aAAa;AAAA,MAC1C,OAAO;AACN,cAAM,eAAe,MAAM,KAAK,OAAO,OAAO,cAAc,QAAQ,QAAQ;AAE5E,cAAM,eAAe,iBAAiB,YAAY;AAClD,YAAI,CAAC,cAAc;AAClB,iBAAO;AAAA,QACR;AACA,cAAM,gBAAgB,MAAM,KAAK,OAAO,gBAAgB,QAAQ,UAAU,SAAS,cAAc,KAAK,KAAK;AAC3G,eAAO,CAAC,GAAG,cAAc,GAAG,aAAa;AAAA,MAC1C;AAAA,IACD;AAAA,EACD;AAAA,EAEA,MAAa,WACZ,EAAE,QAAQ,cAAc,UAAU,SACjC;AACD,SAAK,cAAc,8BAA8B,SAAS,IAAI;AAC9D,WAAO,OAAO,EAAE,cAA+C;AAC9D,YAAM,CAAC,cAAc,GAAG,IAAI,MAAM,KAAK,OAAO,gBAAgB,cAAc,OAAO,QAAQ;AAC3F,UAAI,IAAK,QAAO,CAAC,GAAG;AAEpB,aAAO,MAAM,KAAK,OAAO,mBAAmB,QAAQ,UAAU,SAAS,cAAc,KAAK,KAAK;AAAA,IAChG;AAAA,EACD;AAAA,EAEA,MAAa,OACZ,EAAE,QAAQ,cAAc,UAAU,gBAAgB,SACjD;AACD,WAAO,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc,OAAO,QAAQ;AAAA,IAC9D;AAAA,EACD;AACD;"}
@@ -2,10 +2,16 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const Result = require("../../Result.cjs");
4
4
  const CheckedPrimary = require("../../CheckedPrimary.cjs");
5
+ const SetManyRelationHelper = require("./SetManyRelationHelper.cjs");
5
6
  class OneHasManyUpdateInputProcessor {
6
7
  constructor(mapper) {
7
8
  this.mapper = mapper;
8
9
  }
10
+ async set(context) {
11
+ return async ({ primary }) => {
12
+ return await SetManyRelationHelper.processSetManyRelationInput(this.mapper, context, primary, this, context.input);
13
+ };
14
+ }
9
15
  async connect({ entity, targetEntity, targetRelation, input }) {
10
16
  return async ({ primary }) => {
11
17
  return await this.mapper.update(targetEntity, input, {
@@ -1 +1 @@
1
- {"version":3,"file":"OneHasManyUpdateInputProcessor.cjs","sources":["../../../../../../../packages/engine-content-api/src/mapper/update/relations/OneHasManyUpdateInputProcessor.ts"],"sourcesContent":["import { UpdateInputProcessor } from '../../../inputProcessing/index.js'\nimport { Input, Model } from '@contember/schema'\nimport { Mapper } from '../../Mapper.js'\nimport { MutationResultType } from '../../Result.js'\nimport { SqlUpdateInputProcessorResult } from '../SqlUpdateInputProcessor.js'\nimport { CheckedPrimary } from '../../CheckedPrimary.js'\nimport { MapperInput } from '../../types.js'\n\ntype Context = Model.OneHasManyContext\n\nexport class OneHasManyUpdateInputProcessor implements UpdateInputProcessor.HasManyRelationInputProcessor<Context, SqlUpdateInputProcessorResult> {\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t) {\n\t}\n\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}, 'nested')\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}, 'nested')\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}, 'nested')\n\t\t}\n\t}\n\n\tpublic async update(\n\t\t{ entity, targetEntity, targetRelation, input: { data, where } }: Context & { input: UpdateInputProcessor.UpdateManyInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.update(\n\t\t\t\ttargetEntity,\n\t\t\t\t{ ...where, [targetRelation.name]: { [entity.primary]: primary } },\n\t\t\t\t{\n\t\t\t\t\t...data,\n\t\t\t\t\t// [targetRelation.name]: {connect: thisPrimary}\n\t\t\t\t},\n\t\t\t\t'nested',\n\t\t\t)\n\t\t}\n\t}\n\n\tpublic async upsert(\n\t\t{ entity, targetEntity, targetRelation, input: { create, update, where } }: Context & { input: UpdateInputProcessor.UpsertManyInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst result = await this.mapper.update(\n\t\t\t\ttargetEntity,\n\t\t\t\t{ ...where, [targetRelation.name]: { [entity.primary]: primary } },\n\t\t\t\t{\n\t\t\t\t\t...update,\n\t\t\t\t\t// [targetRelation.name]: {connect: thisPrimary}\n\t\t\t\t},\n\t\t\t\t'nested',\n\t\t\t)\n\t\t\tif (result[0].result === MutationResultType.notFoundError) {\n\t\t\t\treturn await this.mapper.insert(targetEntity, {\n\t\t\t\t\t...create,\n\t\t\t\t\t[targetRelation.name]: { connect: new CheckedPrimary(primary) },\n\t\t\t\t}, 'nested')\n\t\t\t}\n\t\t\treturn result\n\t\t}\n\t}\n\n\tpublic async disconnect(\n\t\t{ entity, targetEntity, relation, targetRelation, input }: Context & { input: Input.UniqueWhere },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.update(\n\t\t\t\ttargetEntity,\n\t\t\t\t{ ...input, [targetRelation.name]: { [entity.primary]: primary } },\n\t\t\t\t{ [targetRelation.name]: { disconnect: true } },\n\t\t\t\t'nested',\n\t\t\t)\n\t\t}\n\t}\n\n\tpublic async delete(\n\t\t{ entity, targetEntity, relation, targetRelation, input }: Context & { input: Input.UniqueWhere },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.delete(targetEntity, {\n\t\t\t\t...input,\n\t\t\t\t[targetRelation.name]: { [entity.primary]: primary },\n\t\t\t}, 'nested')\n\t\t}\n\t}\n}\n"],"names":["CheckedPrimary","MutationResultType"],"mappings":";;;;AAUO,MAAM,+BAAqI;AAAA,EACjJ,YACkB,QAChB;AADgB,SAAA,SAAA;AAAA,EAElB;AAAA,EAEA,MAAa,QACZ,EAAE,QAAQ,cAAc,gBAAgB,SACvC;AACD,WAAO,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc,OAAO;AAAA,QACpD,CAAC,eAAe,IAAI,GAAG,EAAE,SAAS,IAAIA,eAAAA,eAAe,OAAO,EAAA;AAAA,MAAE,GAC5D,QAAQ;AAAA,IACZ;AAAA,EACD;AAAA,EAEA,MAAa,OACZ,EAAE,QAAQ,cAAc,gBAAgB,SACvC;AACD,WAAO,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,EAAA;AAAA,MAAE,GAC5D,QAAQ;AAAA,IACZ;AAAA,EACD;AAAA,EAEA,MAAa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A,QAAE,GAC5D,QAAQ;AAAA,MACZ;AACA,aAAO;AAAA,IACR;AAAA,EACD;AAAA,EAEA,MAAa,WACZ,EAAE,QAAQ,cAAc,UAAU,gBAAgB,SACjD;AACD,WAAO,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO;AAAA,QACxB;AAAA,QACA,EAAE,GAAG,OAAO,CAAC,eAAe,IAAI,GAAG,EAAE,CAAC,OAAO,OAAO,GAAG,UAAQ;AAAA,QAC/D,EAAE,CAAC,eAAe,IAAI,GAAG,EAAE,YAAY,OAAK;AAAA,QAC5C;AAAA,MAAA;AAAA,IAEF;AAAA,EACD;AAAA,EAEA,MAAa,OACZ,EAAE,QAAQ,cAAc,UAAU,gBAAgB,SACjD;AACD,WAAO,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc;AAAA,QAC7C,GAAG;AAAA,QACH,CAAC,eAAe,IAAI,GAAG,EAAE,CAAC,OAAO,OAAO,GAAG,QAAA;AAAA,MAAQ,GACjD,QAAQ;AAAA,IACZ;AAAA,EACD;AACD;;"}
1
+ {"version":3,"file":"OneHasManyUpdateInputProcessor.cjs","sources":["../../../../../../../packages/engine-content-api/src/mapper/update/relations/OneHasManyUpdateInputProcessor.ts"],"sourcesContent":["import { UpdateInputProcessor } from '../../../inputProcessing/index.js'\nimport { Input, Model } from '@contember/schema'\nimport { Mapper } from '../../Mapper.js'\nimport { MutationResultType } from '../../Result.js'\nimport { SqlUpdateInputProcessorResult } from '../SqlUpdateInputProcessor.js'\nimport { CheckedPrimary } from '../../CheckedPrimary.js'\nimport { MapperInput } from '../../types.js'\nimport { processSetManyRelationInput } from './SetManyRelationHelper.js'\n\ntype Context = Model.OneHasManyContext\n\nexport class OneHasManyUpdateInputProcessor implements UpdateInputProcessor.HasManyRelationInputProcessor<Context, SqlUpdateInputProcessorResult> {\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t) {\n\t}\n\n\tpublic async set(\n\t\tcontext: Context & { input: UpdateInputProcessor.SetManyInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await processSetManyRelationInput(this.mapper, context, primary, this, context.input)\n\t\t}\n\t}\n\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}, 'nested')\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}, 'nested')\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}, 'nested')\n\t\t}\n\t}\n\n\tpublic async update(\n\t\t{ entity, targetEntity, targetRelation, input: { data, where } }: Context & { input: UpdateInputProcessor.UpdateManyInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.update(\n\t\t\t\ttargetEntity,\n\t\t\t\t{ ...where, [targetRelation.name]: { [entity.primary]: primary } },\n\t\t\t\t{\n\t\t\t\t\t...data,\n\t\t\t\t\t// [targetRelation.name]: {connect: thisPrimary}\n\t\t\t\t},\n\t\t\t\t'nested',\n\t\t\t)\n\t\t}\n\t}\n\n\tpublic async upsert(\n\t\t{ entity, targetEntity, targetRelation, input: { create, update, where } }: Context & { input: UpdateInputProcessor.UpsertManyInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst result = await this.mapper.update(\n\t\t\t\ttargetEntity,\n\t\t\t\t{ ...where, [targetRelation.name]: { [entity.primary]: primary } },\n\t\t\t\t{\n\t\t\t\t\t...update,\n\t\t\t\t\t// [targetRelation.name]: {connect: thisPrimary}\n\t\t\t\t},\n\t\t\t\t'nested',\n\t\t\t)\n\t\t\tif (result[0].result === MutationResultType.notFoundError) {\n\t\t\t\treturn await this.mapper.insert(targetEntity, {\n\t\t\t\t\t...create,\n\t\t\t\t\t[targetRelation.name]: { connect: new CheckedPrimary(primary) },\n\t\t\t\t}, 'nested')\n\t\t\t}\n\t\t\treturn result\n\t\t}\n\t}\n\n\tpublic async disconnect(\n\t\t{ entity, targetEntity, relation, targetRelation, input }: Context & { input: Input.UniqueWhere },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.update(\n\t\t\t\ttargetEntity,\n\t\t\t\t{ ...input, [targetRelation.name]: { [entity.primary]: primary } },\n\t\t\t\t{ [targetRelation.name]: { disconnect: true } },\n\t\t\t\t'nested',\n\t\t\t)\n\t\t}\n\t}\n\n\tpublic async delete(\n\t\t{ entity, targetEntity, relation, targetRelation, input }: Context & { input: Input.UniqueWhere },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.delete(targetEntity, {\n\t\t\t\t...input,\n\t\t\t\t[targetRelation.name]: { [entity.primary]: primary },\n\t\t\t}, 'nested')\n\t\t}\n\t}\n}\n"],"names":["processSetManyRelationInput","CheckedPrimary","MutationResultType"],"mappings":";;;;;AAWO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,QAAQ,cAAc,UAAU,gBAAgB,SACjD;AACD,WAAO,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc;AAAA,QAC7C,GAAG;AAAA,QACH,CAAC,eAAe,IAAI,GAAG,EAAE,CAAC,OAAO,OAAO,GAAG,QAAA;AAAA,MAAQ,GACjD,QAAQ;AAAA,IACZ;AAAA,EACD;AACD;;"}
@@ -1,9 +1,15 @@
1
1
  import { MutationResultType } from "../../Result.js";
2
2
  import { CheckedPrimary } from "../../CheckedPrimary.js";
3
+ import { processSetManyRelationInput } from "./SetManyRelationHelper.js";
3
4
  class OneHasManyUpdateInputProcessor {
4
5
  constructor(mapper) {
5
6
  this.mapper = mapper;
6
7
  }
8
+ async set(context) {
9
+ return async ({ primary }) => {
10
+ return await processSetManyRelationInput(this.mapper, context, primary, this, context.input);
11
+ };
12
+ }
7
13
  async connect({ entity, targetEntity, targetRelation, input }) {
8
14
  return async ({ primary }) => {
9
15
  return await this.mapper.update(targetEntity, input, {
@@ -1 +1 @@
1
- {"version":3,"file":"OneHasManyUpdateInputProcessor.js","sources":["../../../../../../../packages/engine-content-api/src/mapper/update/relations/OneHasManyUpdateInputProcessor.ts"],"sourcesContent":["import { UpdateInputProcessor } from '../../../inputProcessing/index.js'\nimport { Input, Model } from '@contember/schema'\nimport { Mapper } from '../../Mapper.js'\nimport { MutationResultType } from '../../Result.js'\nimport { SqlUpdateInputProcessorResult } from '../SqlUpdateInputProcessor.js'\nimport { CheckedPrimary } from '../../CheckedPrimary.js'\nimport { MapperInput } from '../../types.js'\n\ntype Context = Model.OneHasManyContext\n\nexport class OneHasManyUpdateInputProcessor implements UpdateInputProcessor.HasManyRelationInputProcessor<Context, SqlUpdateInputProcessorResult> {\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t) {\n\t}\n\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}, 'nested')\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}, 'nested')\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}, 'nested')\n\t\t}\n\t}\n\n\tpublic async update(\n\t\t{ entity, targetEntity, targetRelation, input: { data, where } }: Context & { input: UpdateInputProcessor.UpdateManyInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.update(\n\t\t\t\ttargetEntity,\n\t\t\t\t{ ...where, [targetRelation.name]: { [entity.primary]: primary } },\n\t\t\t\t{\n\t\t\t\t\t...data,\n\t\t\t\t\t// [targetRelation.name]: {connect: thisPrimary}\n\t\t\t\t},\n\t\t\t\t'nested',\n\t\t\t)\n\t\t}\n\t}\n\n\tpublic async upsert(\n\t\t{ entity, targetEntity, targetRelation, input: { create, update, where } }: Context & { input: UpdateInputProcessor.UpsertManyInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst result = await this.mapper.update(\n\t\t\t\ttargetEntity,\n\t\t\t\t{ ...where, [targetRelation.name]: { [entity.primary]: primary } },\n\t\t\t\t{\n\t\t\t\t\t...update,\n\t\t\t\t\t// [targetRelation.name]: {connect: thisPrimary}\n\t\t\t\t},\n\t\t\t\t'nested',\n\t\t\t)\n\t\t\tif (result[0].result === MutationResultType.notFoundError) {\n\t\t\t\treturn await this.mapper.insert(targetEntity, {\n\t\t\t\t\t...create,\n\t\t\t\t\t[targetRelation.name]: { connect: new CheckedPrimary(primary) },\n\t\t\t\t}, 'nested')\n\t\t\t}\n\t\t\treturn result\n\t\t}\n\t}\n\n\tpublic async disconnect(\n\t\t{ entity, targetEntity, relation, targetRelation, input }: Context & { input: Input.UniqueWhere },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.update(\n\t\t\t\ttargetEntity,\n\t\t\t\t{ ...input, [targetRelation.name]: { [entity.primary]: primary } },\n\t\t\t\t{ [targetRelation.name]: { disconnect: true } },\n\t\t\t\t'nested',\n\t\t\t)\n\t\t}\n\t}\n\n\tpublic async delete(\n\t\t{ entity, targetEntity, relation, targetRelation, input }: Context & { input: Input.UniqueWhere },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.delete(targetEntity, {\n\t\t\t\t...input,\n\t\t\t\t[targetRelation.name]: { [entity.primary]: primary },\n\t\t\t}, 'nested')\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAUO,MAAM,+BAAqI;AAAA,EACjJ,YACkB,QAChB;AADgB,SAAA,SAAA;AAAA,EAElB;AAAA,EAEA,MAAa,QACZ,EAAE,QAAQ,cAAc,gBAAgB,SACvC;AACD,WAAO,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc,OAAO;AAAA,QACpD,CAAC,eAAe,IAAI,GAAG,EAAE,SAAS,IAAI,eAAe,OAAO,EAAA;AA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,IAAI,GAAG,EAAE,CAAC,OAAO,OAAO,GAAG,UAAQ;AAAA,QAC/D;AAAA,UACC,GAAG;AAAA;AAAA,QAAA;AAAA,QAGJ;AAAA,MAAA;AAED,UAAI,OAAO,CAAC,EAAE,WAAW,mBAAmB,eAAe;AAC1D,eAAO,MAAM,KAAK,OAAO,OAAO,cAAc;AAAA,UAC7C,GAAG;AAAA,UACH,CAAC,eAAe,IAAI,GAAG,EAAE,SAAS,IAAI,eAAe,OAAO,EAAA;AAAA,QAAE,GAC5D,QAAQ;AAAA,MACZ;AACA,aAAO;AAAA,IACR;AAAA,EACD;AAAA,EAEA,MAAa,WACZ,EAAE,QAAQ,cAAc,UAAU,gBAAgB,SACjD;AACD,WAAO,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO;AAAA,QACxB;AAAA,QACA,EAAE,GAAG,OAAO,CAAC,eAAe,IAAI,GAAG,EAAE,CAAC,OAAO,OAAO,GAAG,UAAQ;AAAA,QAC/D,EAAE,CAAC,eAAe,IAAI,GAAG,EAAE,YAAY,OAAK;AAAA,QAC5C;AAAA,MAAA;AAAA,IAEF;AAAA,EACD;AAAA,EAEA,MAAa,OACZ,EAAE,QAAQ,cAAc,UAAU,gBAAgB,SACjD;AACD,WAAO,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc;AAAA,QAC7C,GAAG;AAAA,QACH,CAAC,eAAe,IAAI,GAAG,EAAE,CAAC,OAAO,OAAO,GAAG,QAAA;AAAA,MAAQ,GACjD,QAAQ;AAAA,IACZ;AAAA,EACD;AACD;"}
1
+ {"version":3,"file":"OneHasManyUpdateInputProcessor.js","sources":["../../../../../../../packages/engine-content-api/src/mapper/update/relations/OneHasManyUpdateInputProcessor.ts"],"sourcesContent":["import { UpdateInputProcessor } from '../../../inputProcessing/index.js'\nimport { Input, Model } from '@contember/schema'\nimport { Mapper } from '../../Mapper.js'\nimport { MutationResultType } from '../../Result.js'\nimport { SqlUpdateInputProcessorResult } from '../SqlUpdateInputProcessor.js'\nimport { CheckedPrimary } from '../../CheckedPrimary.js'\nimport { MapperInput } from '../../types.js'\nimport { processSetManyRelationInput } from './SetManyRelationHelper.js'\n\ntype Context = Model.OneHasManyContext\n\nexport class OneHasManyUpdateInputProcessor implements UpdateInputProcessor.HasManyRelationInputProcessor<Context, SqlUpdateInputProcessorResult> {\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t) {\n\t}\n\n\tpublic async set(\n\t\tcontext: Context & { input: UpdateInputProcessor.SetManyInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await processSetManyRelationInput(this.mapper, context, primary, this, context.input)\n\t\t}\n\t}\n\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}, 'nested')\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}, 'nested')\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}, 'nested')\n\t\t}\n\t}\n\n\tpublic async update(\n\t\t{ entity, targetEntity, targetRelation, input: { data, where } }: Context & { input: UpdateInputProcessor.UpdateManyInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.update(\n\t\t\t\ttargetEntity,\n\t\t\t\t{ ...where, [targetRelation.name]: { [entity.primary]: primary } },\n\t\t\t\t{\n\t\t\t\t\t...data,\n\t\t\t\t\t// [targetRelation.name]: {connect: thisPrimary}\n\t\t\t\t},\n\t\t\t\t'nested',\n\t\t\t)\n\t\t}\n\t}\n\n\tpublic async upsert(\n\t\t{ entity, targetEntity, targetRelation, input: { create, update, where } }: Context & { input: UpdateInputProcessor.UpsertManyInput },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\tconst result = await this.mapper.update(\n\t\t\t\ttargetEntity,\n\t\t\t\t{ ...where, [targetRelation.name]: { [entity.primary]: primary } },\n\t\t\t\t{\n\t\t\t\t\t...update,\n\t\t\t\t\t// [targetRelation.name]: {connect: thisPrimary}\n\t\t\t\t},\n\t\t\t\t'nested',\n\t\t\t)\n\t\t\tif (result[0].result === MutationResultType.notFoundError) {\n\t\t\t\treturn await this.mapper.insert(targetEntity, {\n\t\t\t\t\t...create,\n\t\t\t\t\t[targetRelation.name]: { connect: new CheckedPrimary(primary) },\n\t\t\t\t}, 'nested')\n\t\t\t}\n\t\t\treturn result\n\t\t}\n\t}\n\n\tpublic async disconnect(\n\t\t{ entity, targetEntity, relation, targetRelation, input }: Context & { input: Input.UniqueWhere },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.update(\n\t\t\t\ttargetEntity,\n\t\t\t\t{ ...input, [targetRelation.name]: { [entity.primary]: primary } },\n\t\t\t\t{ [targetRelation.name]: { disconnect: true } },\n\t\t\t\t'nested',\n\t\t\t)\n\t\t}\n\t}\n\n\tpublic async delete(\n\t\t{ entity, targetEntity, relation, targetRelation, input }: Context & { input: Input.UniqueWhere },\n\t) {\n\t\treturn async ({ primary }: { primary: Input.PrimaryValue }) => {\n\t\t\treturn await this.mapper.delete(targetEntity, {\n\t\t\t\t...input,\n\t\t\t\t[targetRelation.name]: { [entity.primary]: primary },\n\t\t\t}, 'nested')\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;AAWO,MAAM,+BAAqI;AAAA,EACjJ,YACkB,QAChB;AADgB,SAAA,SAAA;AAAA,EAElB;AAAA,EAEA,MAAa,IACZ,SACC;AACD,WAAO,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,4BAA4B,KAAK,QAAQ,SAAS,SAAS,MAAM,QAAQ,KAAK;AAAA,IAC5F;AAAA,EACD;AAAA,EAEA,MAAa,QACZ,EAAE,QAAQ,cAAc,gBAAgB,SACvC;AACD,WAAO,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc,OAAO;AAAA,QACpD,CAAC,eAAe,IAAI,GAAG,EAAE,SAAS,IAAI,eAAe,OAAO,EAAA;AAAA,MAAE,GAC5D,QAAQ;AAAA,IACZ;AAAA,EACD;AAAA,EAEA,MAAa,OACZ,EAAE,QAAQ,cAAc,gBAAgB,SACvC;AACD,WAAO,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,EAAA;AAAA,MAAE,GAC5D,QAAQ;AAAA,IACZ;AAAA,EACD;AAAA,EAEA,MAAa,gBACZ,EAAE,QAAQ,gBAAgB,cAAc,OAAO,EAAE,SAAS,OAAA,KACzD;AACD,WAAO,OAAO,EAAE,cAA+C;AAC9D,YAAM,cAAc;AAAA,QACnB,CAAC,eAAe,IAAI,GAAG;AAAA,UACtB,SAAS,IAAI,eAAe,OAAO;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ACA,EAAE,GAAG,OAAO,CAAC,eAAe,IAAI,GAAG,EAAE,CAAC,OAAO,OAAO,GAAG,UAAQ;AAAA,QAC/D,EAAE,CAAC,eAAe,IAAI,GAAG,EAAE,YAAY,OAAK;AAAA,QAC5C;AAAA,MAAA;AAAA,IAEF;AAAA,EACD;AAAA,EAEA,MAAa,OACZ,EAAE,QAAQ,cAAc,UAAU,gBAAgB,SACjD;AACD,WAAO,OAAO,EAAE,cAA+C;AAC9D,aAAO,MAAM,KAAK,OAAO,OAAO,cAAc;AAAA,QAC7C,GAAG;AAAA,QACH,CAAC,eAAe,IAAI,GAAG,EAAE,CAAC,OAAO,OAAO,GAAG,QAAA;AAAA,MAAQ,GACjD,QAAQ;AAAA,IACZ;AAAA,EACD;AACD;"}
@@ -0,0 +1,123 @@
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
+ const exception = require("../../../exception.cjs");
7
+ const runStep = async (result, primary) => {
8
+ return typeof result === "function" ? await result({ primary }) : await result;
9
+ };
10
+ const scopeToOwner = (context, ownerPrimary, where) => {
11
+ if (context.type !== "oneHasMany") {
12
+ return where;
13
+ }
14
+ return { ...where, [context.targetRelation.name]: { [context.entity.primary]: ownerPrimary } };
15
+ };
16
+ const processSetManyRelationInput = async (mapper, context, ownerPrimary, processor, input) => {
17
+ const { targetEntity } = context;
18
+ const results = [];
19
+ const desiredPrimaries = /* @__PURE__ */ new Map();
20
+ const markDesired = (primary, index, alias) => {
21
+ if (primary !== void 0 && primary !== null && !desiredPrimaries.has(String(primary))) {
22
+ desiredPrimaries.set(String(primary), { primary, index, alias });
23
+ }
24
+ };
25
+ const itemPath = (index, alias) => [{ index, alias }];
26
+ const fail = (index, alias, err) => {
27
+ return [...results, ...Result.prependPath(itemPath(index, alias), [err])];
28
+ };
29
+ const currentPrimaries = await mapper.fetchHasManyPrimaries(context, ownerPrimary);
30
+ const connectTargets = [];
31
+ for (const [index, item] of input.items.entries()) {
32
+ if ("connect" in item) {
33
+ const [primary, err] = await mapper.getPrimaryValue(targetEntity, item.connect, "nested");
34
+ if (err) {
35
+ return fail(index, item.alias, err);
36
+ }
37
+ connectTargets[index] = new CheckedPrimary.CheckedPrimary(primary);
38
+ markDesired(primary, index, item.alias);
39
+ } else if ("update" in item) {
40
+ const [primary, err] = await mapper.getPrimaryValue(targetEntity, scopeToOwner(context, ownerPrimary, item.update.by), "nested");
41
+ if (err) {
42
+ return fail(index, item.alias, err);
43
+ }
44
+ markDesired(primary, index, item.alias);
45
+ } else if ("upsert" in item) {
46
+ const [primary] = await mapper.getPrimaryValue(targetEntity, scopeToOwner(context, ownerPrimary, item.upsert.by), "nested");
47
+ markDesired(primary, index, item.alias);
48
+ } else if ("connectOrCreate" in item) {
49
+ const [primary] = await mapper.getPrimaryValue(targetEntity, item.connectOrCreate.connect, "nested");
50
+ markDesired(primary, index, item.alias);
51
+ } else if (!("create" in item)) {
52
+ throw new exception.ImplementationException('Unknown "set" item operation; the input visitor should have rejected it.');
53
+ }
54
+ }
55
+ const removedTargets = /* @__PURE__ */ new Set();
56
+ for (const current of currentPrimaries) {
57
+ if (desiredPrimaries.has(String(current)) || removedTargets.has(String(current))) {
58
+ continue;
59
+ }
60
+ const where = { [targetEntity.primary]: current };
61
+ const orphanResult = input.orphanStrategy === schema.Input.OrphanRemovalStrategy.delete ? await runStep(await processor.delete({ ...context, input: where, index: 0, alias: void 0 }), ownerPrimary) : await runStep(await processor.disconnect({ ...context, input: where, index: 0, alias: void 0 }), ownerPrimary);
62
+ results.push(...orphanResult);
63
+ if (orphanResult.some((it) => it.error)) {
64
+ return results;
65
+ }
66
+ for (const entry of orphanResult) {
67
+ if (entry instanceof Result.MutationDeleteOk && entry.entity.name === targetEntity.name) {
68
+ removedTargets.add(String(entry.primary));
69
+ }
70
+ }
71
+ }
72
+ for (const { primary, index, alias } of desiredPrimaries.values()) {
73
+ if (removedTargets.has(String(primary))) {
74
+ return fail(
75
+ index,
76
+ alias,
77
+ new Result.MutationInputError(
78
+ [],
79
+ Result.InputErrorKind.invalidData,
80
+ `${targetEntity.name} "${String(primary)}" named by "set" was deleted by a cascade of removing an orphan.`
81
+ )
82
+ );
83
+ }
84
+ }
85
+ for (const [index, item] of input.items.entries()) {
86
+ const alias = item.alias;
87
+ let stepResult;
88
+ if ("connect" in item) {
89
+ stepResult = await runStep(
90
+ await processor.connect({ ...context, input: connectTargets[index], index, alias }),
91
+ ownerPrimary
92
+ );
93
+ } else if ("create" in item) {
94
+ stepResult = await runStep(await processor.create({ ...context, input: item.create, index, alias }), ownerPrimary);
95
+ } else if ("connectOrCreate" in item) {
96
+ stepResult = await runStep(await processor.connectOrCreate({ ...context, input: item.connectOrCreate, index, alias }), ownerPrimary);
97
+ } else if ("update" in item) {
98
+ stepResult = await runStep(
99
+ await processor.update({ ...context, input: { where: item.update.by, data: item.update.data }, index, alias }),
100
+ ownerPrimary
101
+ );
102
+ } else if ("upsert" in item) {
103
+ stepResult = await runStep(
104
+ await processor.upsert({
105
+ ...context,
106
+ input: { where: item.upsert.by, update: item.upsert.update, create: item.upsert.create },
107
+ index,
108
+ alias
109
+ }),
110
+ ownerPrimary
111
+ );
112
+ } else {
113
+ throw new exception.ImplementationException('Unknown "set" item operation; the input visitor should have rejected it.');
114
+ }
115
+ results.push(...Result.prependPath(itemPath(index, alias), stepResult));
116
+ if (stepResult.some((it) => it.error)) {
117
+ return results;
118
+ }
119
+ }
120
+ return results;
121
+ };
122
+ exports.processSetManyRelationInput = processSetManyRelationInput;
123
+ //# sourceMappingURL=SetManyRelationHelper.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SetManyRelationHelper.cjs","sources":["../../../../../../../packages/engine-content-api/src/mapper/update/relations/SetManyRelationHelper.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { Mapper } from '../../Mapper.js'\nimport { UpdateInputProcessor } from '../../../inputProcessing/index.js'\nimport { InputErrorKind, MutationDeleteOk, MutationInputError, MutationResult, MutationResultList, prependPath } from '../../Result.js'\nimport { CheckedPrimary } from '../../CheckedPrimary.js'\nimport { MapperInput } from '../../types.js'\nimport { SqlUpdateInputProcessorResult } from '../SqlUpdateInputProcessor.js'\nimport { ImplementationException } from '../../../exception.js'\n\ntype HasManyContext =\n\t| Model.OneHasManyContext\n\t| Model.ManyHasManyOwningContext\n\t| Model.ManyHasManyInverseContext\n\n/**\n * The subset of {@link UpdateInputProcessor.HasManyRelationInputProcessor} methods reused by `set`.\n * Each method returns either a result list or a thunk that finalizes once the owner primary is known.\n */\ninterface SetCapableProcessor<Context> {\n\tconnect(context: Context & { input: Input.UniqueWhere | CheckedPrimary; index: number; alias?: string }): Promise<SqlUpdateInputProcessorResult>\n\tcreate(context: Context & { input: MapperInput.CreateDataInput; index: number; alias?: string }): Promise<SqlUpdateInputProcessorResult>\n\tconnectOrCreate(\n\t\tcontext: Context & { input: MapperInput.ConnectOrCreateInput; index: number; alias?: string },\n\t): Promise<SqlUpdateInputProcessorResult>\n\tupdate(context: Context & { input: UpdateInputProcessor.UpdateManyInput; index: number; alias?: string }): Promise<SqlUpdateInputProcessorResult>\n\tupsert(context: Context & { input: UpdateInputProcessor.UpsertManyInput; index: number; alias?: string }): Promise<SqlUpdateInputProcessorResult>\n\tdisconnect(context: Context & { input: Input.UniqueWhere; index: number; alias?: string }): Promise<SqlUpdateInputProcessorResult>\n\tdelete(context: Context & { input: Input.UniqueWhere; index: number; alias?: string }): Promise<SqlUpdateInputProcessorResult>\n}\n\nconst runStep = async (result: SqlUpdateInputProcessorResult, primary: Input.PrimaryValue): Promise<MutationResultList> => {\n\treturn typeof result === 'function' ? await result({ primary }) : await result\n}\n\n/**\n * `update` and `upsert` on a oneHasMany resolve their `by` *within* the collection - the processor\n * completes the where with the owner, which is what lets a partial composite unique key (say\n * `unique(['locale', 'post'])` addressed by `{locale}` alone) identify a row. Resolving such a\n * where globally would fail as non-unique, so the lookup has to be scoped the same way.\n * Every other lookup - and every lookup on a junction relation - is global, again matching the\n * processor it feeds.\n */\nconst scopeToOwner = <Context extends HasManyContext>(\n\tcontext: Context,\n\townerPrimary: Input.PrimaryValue,\n\twhere: Input.UniqueWhere,\n): Input.UniqueWhere => {\n\tif (context.type !== 'oneHasMany') {\n\t\treturn where\n\t}\n\treturn { ...where, [context.targetRelation.name]: { [context.entity.primary]: ownerPrimary } }\n}\n\n/**\n * Implements the declarative `set` operation for has-many relations.\n *\n * Runs in three phases:\n *\n * 1. resolve which of the current members the input names, without writing anything;\n * 2. remove the members it does not name, according to `orphanStrategy`;\n * 3. connect/create/update the members it does name.\n *\n * Removal comes first so that the old and the new row never coexist: a unique key that includes\n * the owner - `unique(['locale', 'post'])`, the \"replace all translations\" shape this operation\n * exists for - would otherwise be violated by the intermediate state. Phase 1 writes nothing, so\n * a member named by the input is never removed and re-added; and a record created in phase 3\n * cannot be an orphan, because orphans come from a snapshot taken before it existed.\n */\nexport const processSetManyRelationInput = async <Context extends HasManyContext>(\n\tmapper: Mapper,\n\tcontext: Context,\n\townerPrimary: Input.PrimaryValue,\n\tprocessor: SetCapableProcessor<Context>,\n\tinput: UpdateInputProcessor.SetManyInput,\n): Promise<MutationResultList> => {\n\tconst { targetEntity } = context\n\tconst results: MutationResultList = []\n\t// primary of an existing target the input names -> the first item naming it\n\tconst desiredPrimaries = new Map<string, { primary: Input.PrimaryValue; index: number; alias?: string }>()\n\n\tconst markDesired = (primary: Input.PrimaryValue | undefined, index: number, alias?: string) => {\n\t\tif (primary !== undefined && primary !== null && !desiredPrimaries.has(String(primary))) {\n\t\t\tdesiredPrimaries.set(String(primary), { primary, index, alias })\n\t\t}\n\t}\n\tconst itemPath = (index: number, alias?: string) => [{ index, alias }]\n\tconst fail = (index: number, alias: string | undefined, err: MutationResult): MutationResultList => {\n\t\treturn [...results, ...prependPath(itemPath(index, alias), [err])]\n\t}\n\n\tconst currentPrimaries = await mapper.fetchHasManyPrimaries(context, ownerPrimary)\n\n\t// Phase 1 - which current members does the input name? `create` never names one, and a target\n\t// that does not exist yet is not a member either, so both simply leave the set unmarked.\n\tconst connectTargets: CheckedPrimary[] = []\n\tfor (const [index, item] of input.items.entries()) {\n\t\tif ('connect' in item) {\n\t\t\tconst [primary, err] = await mapper.getPrimaryValue(targetEntity, item.connect, 'nested')\n\t\t\tif (err) {\n\t\t\t\treturn fail(index, item.alias, err)\n\t\t\t}\n\t\t\tconnectTargets[index] = new CheckedPrimary(primary)\n\t\t\tmarkDesired(primary, index, item.alias)\n\t\t} else if ('update' in item) {\n\t\t\tconst [primary, err] = await mapper.getPrimaryValue(targetEntity, scopeToOwner(context, ownerPrimary, item.update.by), 'nested')\n\t\t\tif (err) {\n\t\t\t\treturn fail(index, item.alias, err)\n\t\t\t}\n\t\t\tmarkDesired(primary, index, item.alias)\n\t\t} else if ('upsert' in item) {\n\t\t\t// A missing target is not an error here - the processor falls back to creating it.\n\t\t\tconst [primary] = await mapper.getPrimaryValue(targetEntity, scopeToOwner(context, ownerPrimary, item.upsert.by), 'nested')\n\t\t\tmarkDesired(primary, index, item.alias)\n\t\t} else if ('connectOrCreate' in item) {\n\t\t\tconst [primary] = await mapper.getPrimaryValue(targetEntity, item.connectOrCreate.connect, 'nested')\n\t\t\tmarkDesired(primary, index, item.alias)\n\t\t} else if (!('create' in item)) {\n\t\t\tthrow new ImplementationException('Unknown \"set\" item operation; the input visitor should have rejected it.')\n\t\t}\n\t}\n\n\t// Phase 2 - remove the members the input does not name. Only deletes made by these removals count:\n\t// the transaction-wide deletion history keeps rows that were deleted and recreated with the same id.\n\tconst removedTargets = new Set<string>()\n\tfor (const current of currentPrimaries) {\n\t\t// already gone through the cascade of an earlier removal\n\t\tif (desiredPrimaries.has(String(current)) || removedTargets.has(String(current))) {\n\t\t\tcontinue\n\t\t}\n\t\tconst where: Input.UniqueWhere = { [targetEntity.primary]: current }\n\t\tconst orphanResult = input.orphanStrategy === Input.OrphanRemovalStrategy.delete\n\t\t\t? await runStep(await processor.delete({ ...context, input: where, index: 0, alias: undefined }), ownerPrimary)\n\t\t\t: await runStep(await processor.disconnect({ ...context, input: where, index: 0, alias: undefined }), ownerPrimary)\n\t\tresults.push(...orphanResult)\n\t\tif (orphanResult.some(it => it.error)) {\n\t\t\treturn results\n\t\t}\n\t\tfor (const entry of orphanResult) {\n\t\t\tif (entry instanceof MutationDeleteOk && entry.entity.name === targetEntity.name) {\n\t\t\t\tremovedTargets.add(String(entry.primary))\n\t\t\t}\n\t\t}\n\t}\n\n\t// A removal can cascade into a target the input names. Establishing it now would fail (connect,\n\t// update) or silently create a new row in its place (upsert, connectOrCreate), so refuse instead.\n\tfor (const { primary, index, alias } of desiredPrimaries.values()) {\n\t\tif (removedTargets.has(String(primary))) {\n\t\t\treturn fail(\n\t\t\t\tindex,\n\t\t\t\talias,\n\t\t\t\tnew MutationInputError(\n\t\t\t\t\t[],\n\t\t\t\t\tInputErrorKind.invalidData,\n\t\t\t\t\t`${targetEntity.name} \"${String(primary)}\" named by \"set\" was deleted by a cascade of removing an orphan.`,\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\t}\n\n\t// Phase 3 - establish the members the input does name.\n\tfor (const [index, item] of input.items.entries()) {\n\t\tconst alias = item.alias\n\t\tlet stepResult: MutationResultList\n\t\tif ('connect' in item) {\n\t\t\tstepResult = await runStep(\n\t\t\t\tawait processor.connect({ ...context, input: connectTargets[index], index, alias }),\n\t\t\t\townerPrimary,\n\t\t\t)\n\t\t} else if ('create' in item) {\n\t\t\tstepResult = await runStep(await processor.create({ ...context, input: item.create, index, alias }), ownerPrimary)\n\t\t} else if ('connectOrCreate' in item) {\n\t\t\tstepResult = await runStep(await processor.connectOrCreate({ ...context, input: item.connectOrCreate, index, alias }), ownerPrimary)\n\t\t} else if ('update' in item) {\n\t\t\tstepResult = await runStep(\n\t\t\t\tawait processor.update({ ...context, input: { where: item.update.by, data: item.update.data }, index, alias }),\n\t\t\t\townerPrimary,\n\t\t\t)\n\t\t} else if ('upsert' in item) {\n\t\t\tstepResult = await runStep(\n\t\t\t\tawait processor.upsert({\n\t\t\t\t\t...context,\n\t\t\t\t\tinput: { where: item.upsert.by, update: item.upsert.update, create: item.upsert.create },\n\t\t\t\t\tindex,\n\t\t\t\t\talias,\n\t\t\t\t}),\n\t\t\t\townerPrimary,\n\t\t\t)\n\t\t} else {\n\t\t\tthrow new ImplementationException('Unknown \"set\" item operation; the input visitor should have rejected it.')\n\t\t}\n\t\tresults.push(...prependPath(itemPath(index, alias), stepResult))\n\t\tif (stepResult.some(it => it.error)) {\n\t\t\treturn results\n\t\t}\n\t}\n\n\treturn results\n}\n"],"names":["prependPath","CheckedPrimary","ImplementationException","Input","MutationDeleteOk","MutationInputError","InputErrorKind"],"mappings":";;;;;;AA8BA,MAAM,UAAU,OAAO,QAAuC,YAA6D;AAC1H,SAAO,OAAO,WAAW,aAAa,MAAM,OAAO,EAAE,QAAA,CAAS,IAAI,MAAM;AACzE;AAUA,MAAM,eAAe,CACpB,SACA,cACA,UACuB;AACvB,MAAI,QAAQ,SAAS,cAAc;AAClC,WAAO;AAAA,EACR;AACA,SAAO,EAAE,GAAG,OAAO,CAAC,QAAQ,eAAe,IAAI,GAAG,EAAE,CAAC,QAAQ,OAAO,OAAO,GAAG,eAAa;AAC5F;AAiBO,MAAM,8BAA8B,OAC1C,QACA,SACA,cACA,WACA,UACiC;AACjC,QAAM,EAAE,iBAAiB;AACzB,QAAM,UAA8B,CAAA;AAEpC,QAAM,uCAAuB,IAAA;AAE7B,QAAM,cAAc,CAAC,SAAyC,OAAe,UAAmB;AAC/F,QAAI,YAAY,UAAa,YAAY,QAAQ,CAAC,iBAAiB,IAAI,OAAO,OAAO,CAAC,GAAG;AACxF,uBAAiB,IAAI,OAAO,OAAO,GAAG,EAAE,SAAS,OAAO,OAAO;AAAA,IAChE;AAAA,EACD;AACA,QAAM,WAAW,CAAC,OAAe,UAAmB,CAAC,EAAE,OAAO,OAAO;AACrE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