@contember/engine-content-api 2.2.0-alpha.17 → 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 (405) hide show
  1. package/CLAUDE.md +1 -1
  2. package/dist/development/index.cjs +3 -0
  3. package/dist/development/index.cjs.map +1 -1
  4. package/dist/development/index.js +4 -1
  5. package/dist/development/index.js.map +1 -1
  6. package/dist/development/src/ExecutionContainer.cjs +1 -0
  7. package/dist/development/src/ExecutionContainer.cjs.map +1 -1
  8. package/dist/development/src/ExecutionContainer.js +1 -0
  9. package/dist/development/src/ExecutionContainer.js.map +1 -1
  10. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs +2 -1
  11. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs.map +1 -1
  12. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js +2 -1
  13. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js.map +1 -1
  14. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +5 -1
  15. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
  16. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +5 -1
  17. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
  18. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs +2 -1
  19. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs.map +1 -1
  20. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js +2 -1
  21. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js.map +1 -1
  22. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs +4 -1
  23. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs.map +1 -1
  24. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +4 -1
  25. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js.map +1 -1
  26. package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs +24 -3
  27. package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs.map +1 -1
  28. package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js +24 -3
  29. package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map +1 -1
  30. package/dist/development/src/inputProcessing/UpdateInputVisitor.cjs +52 -2
  31. package/dist/development/src/inputProcessing/UpdateInputVisitor.cjs.map +1 -1
  32. package/dist/development/src/inputProcessing/UpdateInputVisitor.js +52 -2
  33. package/dist/development/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
  34. package/dist/development/src/mapper/ErrorUtils.cjs +10 -0
  35. package/dist/development/src/mapper/ErrorUtils.cjs.map +1 -1
  36. package/dist/development/src/mapper/ErrorUtils.js +10 -0
  37. package/dist/development/src/mapper/ErrorUtils.js.map +1 -1
  38. package/dist/development/src/mapper/Mapper.cjs +37 -1
  39. package/dist/development/src/mapper/Mapper.cjs.map +1 -1
  40. package/dist/development/src/mapper/Mapper.js +38 -2
  41. package/dist/development/src/mapper/Mapper.js.map +1 -1
  42. package/dist/development/src/mapper/MutationProcessorHelper.cjs +12 -0
  43. package/dist/development/src/mapper/MutationProcessorHelper.cjs.map +1 -1
  44. package/dist/development/src/mapper/MutationProcessorHelper.js +13 -1
  45. package/dist/development/src/mapper/MutationProcessorHelper.js.map +1 -1
  46. package/dist/development/src/mapper/Result.cjs +1 -0
  47. package/dist/development/src/mapper/Result.cjs.map +1 -1
  48. package/dist/development/src/mapper/Result.js +1 -0
  49. package/dist/development/src/mapper/Result.js.map +1 -1
  50. package/dist/development/src/mapper/delete/DeleteExecutor.cjs +1 -1
  51. package/dist/development/src/mapper/delete/DeleteExecutor.js +1 -1
  52. package/dist/development/src/mapper/select/Path.cjs +2 -2
  53. package/dist/development/src/mapper/select/Path.cjs.map +1 -1
  54. package/dist/development/src/mapper/select/Path.js +2 -2
  55. package/dist/development/src/mapper/select/Path.js.map +1 -1
  56. package/dist/development/src/mapper/select/handlers/MetaHandler.cjs +1 -1
  57. package/dist/development/src/mapper/select/handlers/MetaHandler.js +1 -1
  58. package/dist/development/src/mapper/select/optimizer/WhereOptimizer.cjs +2 -2
  59. package/dist/development/src/mapper/select/optimizer/WhereOptimizer.cjs.map +1 -1
  60. package/dist/development/src/mapper/select/optimizer/WhereOptimizer.js +1 -1
  61. package/dist/development/src/mapper/select/optimizer/WhereOptimizer.js.map +1 -1
  62. package/dist/development/src/mapper/select/optimizer/WhereReplacer.cjs +3 -3
  63. package/dist/development/src/mapper/select/optimizer/WhereReplacer.cjs.map +1 -1
  64. package/dist/development/src/mapper/select/optimizer/WhereReplacer.js +1 -1
  65. package/dist/development/src/mapper/select/optimizer/WhereReplacer.js.map +1 -1
  66. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.cjs +6 -3
  67. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
  68. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.js +7 -4
  69. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
  70. package/dist/development/src/mapper/update/Updater.cjs +1 -1
  71. package/dist/development/src/mapper/update/Updater.js +1 -1
  72. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs +6 -0
  73. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -1
  74. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js +6 -0
  75. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -1
  76. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs +6 -0
  77. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -1
  78. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js +6 -0
  79. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -1
  80. package/dist/development/src/mapper/update/relations/SetManyRelationHelper.cjs +123 -0
  81. package/dist/development/src/mapper/update/relations/SetManyRelationHelper.cjs.map +1 -0
  82. package/dist/development/src/mapper/update/relations/SetManyRelationHelper.js +123 -0
  83. package/dist/development/src/mapper/update/relations/SetManyRelationHelper.js.map +1 -0
  84. package/dist/development/src/resolvers/MutationResolver.cjs +4 -1
  85. package/dist/development/src/resolvers/MutationResolver.cjs.map +1 -1
  86. package/dist/development/src/resolvers/MutationResolver.js +4 -1
  87. package/dist/development/src/resolvers/MutationResolver.js.map +1 -1
  88. package/dist/development/src/resolvers/ReadHelpers.cjs +2 -1
  89. package/dist/development/src/resolvers/ReadHelpers.cjs.map +1 -1
  90. package/dist/development/src/resolvers/ReadHelpers.js +2 -1
  91. package/dist/development/src/resolvers/ReadHelpers.js.map +1 -1
  92. package/dist/development/src/schema/CustomTypesProvider.cjs +35 -14
  93. package/dist/development/src/schema/CustomTypesProvider.cjs.map +1 -1
  94. package/dist/development/src/schema/CustomTypesProvider.js +36 -15
  95. package/dist/development/src/schema/CustomTypesProvider.js.map +1 -1
  96. package/dist/development/src/schema/EntityTypeProvider.cjs +8 -5
  97. package/dist/development/src/schema/EntityTypeProvider.cjs.map +1 -1
  98. package/dist/development/src/schema/EntityTypeProvider.js +8 -5
  99. package/dist/development/src/schema/EntityTypeProvider.js.map +1 -1
  100. package/dist/development/src/schema/GraphQlSchemaBuilderFactory.cjs +1 -1
  101. package/dist/development/src/schema/GraphQlSchemaBuilderFactory.js +1 -1
  102. package/dist/development/src/schema/MutationProvider.cjs +4 -0
  103. package/dist/development/src/schema/MutationProvider.cjs.map +1 -1
  104. package/dist/development/src/schema/MutationProvider.js +4 -0
  105. package/dist/development/src/schema/MutationProvider.js.map +1 -1
  106. package/dist/development/src/schema/OrderByTypeProvider.cjs +8 -2
  107. package/dist/development/src/schema/OrderByTypeProvider.cjs.map +1 -1
  108. package/dist/development/src/schema/OrderByTypeProvider.js +9 -3
  109. package/dist/development/src/schema/OrderByTypeProvider.js.map +1 -1
  110. package/dist/development/src/schema/QueryProvider.cjs +3 -0
  111. package/dist/development/src/schema/QueryProvider.cjs.map +1 -1
  112. package/dist/development/src/schema/QueryProvider.js +3 -0
  113. package/dist/development/src/schema/QueryProvider.js.map +1 -1
  114. package/dist/development/src/schema/ValidationQueriesProvider.cjs +2 -0
  115. package/dist/development/src/schema/ValidationQueriesProvider.cjs.map +1 -1
  116. package/dist/development/src/schema/ValidationQueriesProvider.js +2 -0
  117. package/dist/development/src/schema/ValidationQueriesProvider.js.map +1 -1
  118. package/dist/development/src/schema/WhereTypeProvider.cjs +17 -5
  119. package/dist/development/src/schema/WhereTypeProvider.cjs.map +1 -1
  120. package/dist/development/src/schema/WhereTypeProvider.js +18 -6
  121. package/dist/development/src/schema/WhereTypeProvider.js.map +1 -1
  122. package/dist/development/src/schema/calendarDate.cjs +21 -0
  123. package/dist/development/src/schema/calendarDate.cjs.map +1 -0
  124. package/dist/development/src/schema/calendarDate.js +21 -0
  125. package/dist/development/src/schema/calendarDate.js.map +1 -0
  126. package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.cjs +11 -3
  127. package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.cjs.map +1 -1
  128. package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.js +11 -3
  129. package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.js.map +1 -1
  130. package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs +11 -3
  131. package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs.map +1 -1
  132. package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.js +11 -3
  133. package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.js.map +1 -1
  134. package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs +39 -2
  135. package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs.map +1 -1
  136. package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js +40 -3
  137. package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js.map +1 -1
  138. package/dist/development/src/schema/utils.cjs +10 -0
  139. package/dist/development/src/schema/utils.cjs.map +1 -1
  140. package/dist/development/src/schema/utils.js +11 -1
  141. package/dist/development/src/schema/utils.js.map +1 -1
  142. package/dist/production/index.cjs +3 -0
  143. package/dist/production/index.cjs.map +1 -1
  144. package/dist/production/index.js +4 -1
  145. package/dist/production/index.js.map +1 -1
  146. package/dist/production/src/ExecutionContainer.cjs +1 -0
  147. package/dist/production/src/ExecutionContainer.cjs.map +1 -1
  148. package/dist/production/src/ExecutionContainer.js +1 -0
  149. package/dist/production/src/ExecutionContainer.js.map +1 -1
  150. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs +2 -1
  151. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs.map +1 -1
  152. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js +2 -1
  153. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js.map +1 -1
  154. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +5 -1
  155. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
  156. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +5 -1
  157. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
  158. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs +2 -1
  159. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs.map +1 -1
  160. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js +2 -1
  161. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js.map +1 -1
  162. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs +4 -1
  163. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs.map +1 -1
  164. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +4 -1
  165. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js.map +1 -1
  166. package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs +24 -3
  167. package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs.map +1 -1
  168. package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js +24 -3
  169. package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map +1 -1
  170. package/dist/production/src/inputProcessing/UpdateInputVisitor.cjs +52 -2
  171. package/dist/production/src/inputProcessing/UpdateInputVisitor.cjs.map +1 -1
  172. package/dist/production/src/inputProcessing/UpdateInputVisitor.js +52 -2
  173. package/dist/production/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
  174. package/dist/production/src/mapper/ErrorUtils.cjs +10 -0
  175. package/dist/production/src/mapper/ErrorUtils.cjs.map +1 -1
  176. package/dist/production/src/mapper/ErrorUtils.js +10 -0
  177. package/dist/production/src/mapper/ErrorUtils.js.map +1 -1
  178. package/dist/production/src/mapper/Mapper.cjs +37 -1
  179. package/dist/production/src/mapper/Mapper.cjs.map +1 -1
  180. package/dist/production/src/mapper/Mapper.js +38 -2
  181. package/dist/production/src/mapper/Mapper.js.map +1 -1
  182. package/dist/production/src/mapper/MutationProcessorHelper.cjs +12 -0
  183. package/dist/production/src/mapper/MutationProcessorHelper.cjs.map +1 -1
  184. package/dist/production/src/mapper/MutationProcessorHelper.js +13 -1
  185. package/dist/production/src/mapper/MutationProcessorHelper.js.map +1 -1
  186. package/dist/production/src/mapper/Result.cjs +1 -0
  187. package/dist/production/src/mapper/Result.cjs.map +1 -1
  188. package/dist/production/src/mapper/Result.js +1 -0
  189. package/dist/production/src/mapper/Result.js.map +1 -1
  190. package/dist/production/src/mapper/delete/DeleteExecutor.cjs +1 -1
  191. package/dist/production/src/mapper/delete/DeleteExecutor.js +1 -1
  192. package/dist/production/src/mapper/select/Path.cjs +2 -2
  193. package/dist/production/src/mapper/select/Path.cjs.map +1 -1
  194. package/dist/production/src/mapper/select/Path.js +2 -2
  195. package/dist/production/src/mapper/select/Path.js.map +1 -1
  196. package/dist/production/src/mapper/select/handlers/MetaHandler.cjs +1 -1
  197. package/dist/production/src/mapper/select/handlers/MetaHandler.js +1 -1
  198. package/dist/production/src/mapper/select/optimizer/WhereOptimizer.cjs +2 -2
  199. package/dist/production/src/mapper/select/optimizer/WhereOptimizer.cjs.map +1 -1
  200. package/dist/production/src/mapper/select/optimizer/WhereOptimizer.js +1 -1
  201. package/dist/production/src/mapper/select/optimizer/WhereOptimizer.js.map +1 -1
  202. package/dist/production/src/mapper/select/optimizer/WhereReplacer.cjs +3 -3
  203. package/dist/production/src/mapper/select/optimizer/WhereReplacer.cjs.map +1 -1
  204. package/dist/production/src/mapper/select/optimizer/WhereReplacer.js +1 -1
  205. package/dist/production/src/mapper/select/optimizer/WhereReplacer.js.map +1 -1
  206. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.cjs +6 -3
  207. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
  208. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.js +7 -4
  209. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
  210. package/dist/production/src/mapper/update/Updater.cjs +1 -1
  211. package/dist/production/src/mapper/update/Updater.js +1 -1
  212. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs +6 -0
  213. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -1
  214. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js +6 -0
  215. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -1
  216. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs +6 -0
  217. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -1
  218. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js +6 -0
  219. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -1
  220. package/dist/production/src/mapper/update/relations/SetManyRelationHelper.cjs +123 -0
  221. package/dist/production/src/mapper/update/relations/SetManyRelationHelper.cjs.map +1 -0
  222. package/dist/production/src/mapper/update/relations/SetManyRelationHelper.js +123 -0
  223. package/dist/production/src/mapper/update/relations/SetManyRelationHelper.js.map +1 -0
  224. package/dist/production/src/resolvers/MutationResolver.cjs +4 -1
  225. package/dist/production/src/resolvers/MutationResolver.cjs.map +1 -1
  226. package/dist/production/src/resolvers/MutationResolver.js +4 -1
  227. package/dist/production/src/resolvers/MutationResolver.js.map +1 -1
  228. package/dist/production/src/resolvers/ReadHelpers.cjs +2 -1
  229. package/dist/production/src/resolvers/ReadHelpers.cjs.map +1 -1
  230. package/dist/production/src/resolvers/ReadHelpers.js +2 -1
  231. package/dist/production/src/resolvers/ReadHelpers.js.map +1 -1
  232. package/dist/production/src/schema/CustomTypesProvider.cjs +35 -14
  233. package/dist/production/src/schema/CustomTypesProvider.cjs.map +1 -1
  234. package/dist/production/src/schema/CustomTypesProvider.js +36 -15
  235. package/dist/production/src/schema/CustomTypesProvider.js.map +1 -1
  236. package/dist/production/src/schema/EntityTypeProvider.cjs +8 -5
  237. package/dist/production/src/schema/EntityTypeProvider.cjs.map +1 -1
  238. package/dist/production/src/schema/EntityTypeProvider.js +8 -5
  239. package/dist/production/src/schema/EntityTypeProvider.js.map +1 -1
  240. package/dist/production/src/schema/GraphQlSchemaBuilderFactory.cjs +1 -1
  241. package/dist/production/src/schema/GraphQlSchemaBuilderFactory.js +1 -1
  242. package/dist/production/src/schema/MutationProvider.cjs +4 -0
  243. package/dist/production/src/schema/MutationProvider.cjs.map +1 -1
  244. package/dist/production/src/schema/MutationProvider.js +4 -0
  245. package/dist/production/src/schema/MutationProvider.js.map +1 -1
  246. package/dist/production/src/schema/OrderByTypeProvider.cjs +8 -2
  247. package/dist/production/src/schema/OrderByTypeProvider.cjs.map +1 -1
  248. package/dist/production/src/schema/OrderByTypeProvider.js +9 -3
  249. package/dist/production/src/schema/OrderByTypeProvider.js.map +1 -1
  250. package/dist/production/src/schema/QueryProvider.cjs +3 -0
  251. package/dist/production/src/schema/QueryProvider.cjs.map +1 -1
  252. package/dist/production/src/schema/QueryProvider.js +3 -0
  253. package/dist/production/src/schema/QueryProvider.js.map +1 -1
  254. package/dist/production/src/schema/ValidationQueriesProvider.cjs +2 -0
  255. package/dist/production/src/schema/ValidationQueriesProvider.cjs.map +1 -1
  256. package/dist/production/src/schema/ValidationQueriesProvider.js +2 -0
  257. package/dist/production/src/schema/ValidationQueriesProvider.js.map +1 -1
  258. package/dist/production/src/schema/WhereTypeProvider.cjs +17 -5
  259. package/dist/production/src/schema/WhereTypeProvider.cjs.map +1 -1
  260. package/dist/production/src/schema/WhereTypeProvider.js +18 -6
  261. package/dist/production/src/schema/WhereTypeProvider.js.map +1 -1
  262. package/dist/production/src/schema/calendarDate.cjs +21 -0
  263. package/dist/production/src/schema/calendarDate.cjs.map +1 -0
  264. package/dist/production/src/schema/calendarDate.js +21 -0
  265. package/dist/production/src/schema/calendarDate.js.map +1 -0
  266. package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.cjs +11 -3
  267. package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.cjs.map +1 -1
  268. package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.js +11 -3
  269. package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.js.map +1 -1
  270. package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs +11 -3
  271. package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs.map +1 -1
  272. package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.js +11 -3
  273. package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.js.map +1 -1
  274. package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs +39 -2
  275. package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs.map +1 -1
  276. package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js +40 -3
  277. package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js.map +1 -1
  278. package/dist/production/src/schema/utils.cjs +10 -0
  279. package/dist/production/src/schema/utils.cjs.map +1 -1
  280. package/dist/production/src/schema/utils.js +11 -1
  281. package/dist/production/src/schema/utils.js.map +1 -1
  282. package/dist/tests/cases/integration/graphQlRequests/query/acl/internalColumnAliases.test.d.ts +2 -0
  283. package/dist/tests/cases/integration/graphQlRequests/query/acl/internalColumnAliases.test.d.ts.map +1 -0
  284. package/dist/tests/cases/integration/graphQlRequests/query/acl/mergedRolePredicate.test.d.ts +2 -0
  285. package/dist/tests/cases/integration/graphQlRequests/query/acl/mergedRolePredicate.test.d.ts.map +1 -0
  286. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/set.test.d.ts +2 -0
  287. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/set.test.d.ts.map +1 -0
  288. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/set.test.d.ts +2 -0
  289. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/set.test.d.ts.map +1 -0
  290. package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/set.test.d.ts +2 -0
  291. package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/set.test.d.ts.map +1 -0
  292. package/dist/tests/cases/unit/checkViolationError.test.d.ts +2 -0
  293. package/dist/tests/cases/unit/checkViolationError.test.d.ts.map +1 -0
  294. package/dist/tests/cases/unit/dateType.test.d.ts +2 -0
  295. package/dist/tests/cases/unit/dateType.test.d.ts.map +1 -0
  296. package/dist/tests/cases/unit/internalColumnAliases.test.d.ts +2 -0
  297. package/dist/tests/cases/unit/internalColumnAliases.test.d.ts.map +1 -0
  298. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  299. package/dist/types/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.d.ts.map +1 -1
  300. package/dist/types/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.d.ts.map +1 -1
  301. package/dist/types/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts +6 -0
  302. package/dist/types/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts.map +1 -1
  303. package/dist/types/inputProcessing/UpdateInputProcessor.d.ts +7 -0
  304. package/dist/types/inputProcessing/UpdateInputProcessor.d.ts.map +1 -1
  305. package/dist/types/inputProcessing/UpdateInputVisitor.d.ts +2 -0
  306. package/dist/types/inputProcessing/UpdateInputVisitor.d.ts.map +1 -1
  307. package/dist/types/mapper/ErrorUtils.d.ts.map +1 -1
  308. package/dist/types/mapper/Mapper.d.ts +5 -0
  309. package/dist/types/mapper/Mapper.d.ts.map +1 -1
  310. package/dist/types/mapper/MutationProcessorHelper.d.ts +3 -0
  311. package/dist/types/mapper/MutationProcessorHelper.d.ts.map +1 -1
  312. package/dist/types/mapper/Result.d.ts +2 -1
  313. package/dist/types/mapper/Result.d.ts.map +1 -1
  314. package/dist/types/mapper/types.d.ts +8 -1
  315. package/dist/types/mapper/types.d.ts.map +1 -1
  316. package/dist/types/mapper/update/SqlUpdateInputProcessor.d.ts.map +1 -1
  317. package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts +5 -0
  318. package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts.map +1 -1
  319. package/dist/types/mapper/update/relations/OneHasManyUpdateInputProcessor.d.ts +5 -0
  320. package/dist/types/mapper/update/relations/OneHasManyUpdateInputProcessor.d.ts.map +1 -1
  321. package/dist/types/mapper/update/relations/SetManyRelationHelper.d.ts +67 -0
  322. package/dist/types/mapper/update/relations/SetManyRelationHelper.d.ts.map +1 -0
  323. package/dist/types/resolvers/MutationResolver.d.ts.map +1 -1
  324. package/dist/types/schema/CustomTypesProvider.d.ts.map +1 -1
  325. package/dist/types/schema/EntityTypeProvider.d.ts.map +1 -1
  326. package/dist/types/schema/MutationProvider.d.ts.map +1 -1
  327. package/dist/types/schema/OrderByTypeProvider.d.ts.map +1 -1
  328. package/dist/types/schema/QueryProvider.d.ts.map +1 -1
  329. package/dist/types/schema/ValidationQueriesProvider.d.ts.map +1 -1
  330. package/dist/types/schema/WhereTypeProvider.d.ts.map +1 -1
  331. package/dist/types/schema/calendarDate.d.ts +6 -0
  332. package/dist/types/schema/calendarDate.d.ts.map +1 -0
  333. package/dist/types/schema/index.d.ts +1 -0
  334. package/dist/types/schema/index.d.ts.map +1 -1
  335. package/dist/types/schema/mutations/CreateEntityInputFieldVisitor.d.ts.map +1 -1
  336. package/dist/types/schema/mutations/UpdateEntityInputFieldVisitor.d.ts +3 -0
  337. package/dist/types/schema/mutations/UpdateEntityInputFieldVisitor.d.ts.map +1 -1
  338. package/dist/types/schema/mutations/UpdateEntityRelationInputFieldVisitor.d.ts +1 -0
  339. package/dist/types/schema/mutations/UpdateEntityRelationInputFieldVisitor.d.ts.map +1 -1
  340. package/dist/types/schema/utils.d.ts +7 -0
  341. package/dist/types/schema/utils.d.ts.map +1 -1
  342. package/dist/types/tsconfig.tsbuildinfo +1 -1
  343. package/package.json +10 -10
  344. package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts +3 -0
  345. package/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.ts +9 -7
  346. package/src/input-validation/preValidation/UpdateInputPreValidationProcessor.ts +29 -0
  347. package/src/inputProcessing/UpdateInputProcessor.ts +6 -0
  348. package/src/inputProcessing/UpdateInputVisitor.ts +64 -2
  349. package/src/mapper/ErrorUtils.ts +12 -1
  350. package/src/mapper/Mapper.ts +61 -1
  351. package/src/mapper/MutationProcessorHelper.ts +14 -0
  352. package/src/mapper/Result.ts +1 -0
  353. package/src/mapper/select/Path.ts +2 -2
  354. package/src/mapper/select/optimizer/WhereOptimizer.ts +1 -1
  355. package/src/mapper/select/optimizer/WhereReplacer.ts +1 -1
  356. package/src/mapper/types.ts +16 -1
  357. package/src/mapper/update/SqlUpdateInputProcessor.ts +4 -1
  358. package/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.ts +9 -0
  359. package/src/mapper/update/relations/OneHasManyUpdateInputProcessor.ts +9 -0
  360. package/src/mapper/update/relations/SetManyRelationHelper.ts +199 -0
  361. package/src/resolvers/MutationResolver.ts +2 -0
  362. package/src/schema/CustomTypesProvider.ts +40 -15
  363. package/src/schema/EntityTypeProvider.ts +8 -4
  364. package/src/schema/MutationProvider.ts +4 -0
  365. package/src/schema/OrderByTypeProvider.ts +9 -3
  366. package/src/schema/QueryProvider.ts +3 -0
  367. package/src/schema/ValidationQueriesProvider.ts +2 -0
  368. package/src/schema/WhereTypeProvider.ts +18 -6
  369. package/src/schema/calendarDate.ts +26 -0
  370. package/src/schema/index.ts +1 -0
  371. package/src/schema/mutations/CreateEntityInputFieldVisitor.ts +10 -2
  372. package/src/schema/mutations/UpdateEntityInputFieldVisitor.ts +10 -2
  373. package/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.ts +66 -7
  374. package/src/schema/utils.ts +14 -0
  375. package/src/tsconfig.json +2 -1
  376. package/tests/cases/integration/graphQlRequests/query/acl/internalColumnAliases.test.ts +326 -0
  377. package/tests/cases/integration/graphQlRequests/query/acl/mergedRolePredicate.test.ts +124 -0
  378. package/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/set.test.ts +219 -0
  379. package/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/set.test.ts +479 -0
  380. package/tests/cases/integration/graphQlRequests/update/oneHasMany/set.test.ts +948 -0
  381. package/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.ts +102 -1
  382. package/tests/cases/integration/graphQlSchema/schema-acl-allowed.gql +17 -0
  383. package/tests/cases/integration/graphQlSchema/schema-acl-create-only.gql +1 -0
  384. package/tests/cases/integration/graphQlSchema/schema-acl-restricted-create.gql +14 -0
  385. package/tests/cases/integration/graphQlSchema/schema-acl-restricted-delete.gql +11 -0
  386. package/tests/cases/integration/graphQlSchema/schema-acl-restricted-read.gql +254 -0
  387. package/tests/cases/integration/graphQlSchema/schema-acl-restricted-update.gql +1 -0
  388. package/tests/cases/integration/graphQlSchema/schema-acl.gql +1 -0
  389. package/tests/cases/integration/graphQlSchema/schema-aliased-type.gql +1 -0
  390. package/tests/cases/integration/graphQlSchema/schema-array.gql +1 -0
  391. package/tests/cases/integration/graphQlSchema/schema-basic.gql +50 -0
  392. package/tests/cases/integration/graphQlSchema/schema-bug-66.gql +17 -0
  393. package/tests/cases/integration/graphQlSchema/schema-column-types.gql +1 -0
  394. package/tests/cases/integration/graphQlSchema/schema-custom-primary.gql +50 -0
  395. package/tests/cases/integration/graphQlSchema/schema-deprecation.gql +962 -0
  396. package/tests/cases/integration/graphQlSchema/schema-description.gql +992 -0
  397. package/tests/cases/integration/graphQlSchema/schema-has-many-reduction.gql +17 -0
  398. package/tests/cases/integration/graphQlSchema/schema-mixed-root-through.gql +1 -0
  399. package/tests/cases/integration/graphQlSchema/schema-new-builder.gql +50 -0
  400. package/tests/cases/integration/graphQlSchema/schema-no-root-ops.gql +1 -0
  401. package/tests/cases/unit/checkViolationError.test.ts +49 -0
  402. package/tests/cases/unit/dateType.test.ts +46 -0
  403. package/tests/cases/unit/decimalType.test.ts +2 -2
  404. package/tests/cases/unit/internalColumnAliases.test.ts +41 -0
  405. package/tests/cases/unit/mutationSqlError.test.ts +1 -1
@@ -0,0 +1,219 @@
1
+ import { test } from 'bun:test'
2
+ import { Acl } from '@contember/schema'
3
+ import { execute, sqlTransaction } from '../../../../../src/test.js'
4
+ import { GQL, SQL } from '../../../../../src/tags.js'
5
+ import { testUuid } from '../../../../../src/testUuid.js'
6
+ import { postWithCategories } from './schema.js'
7
+
8
+ test('set with default orphanStrategy (disconnect) - inverse junction', async () => {
9
+ await execute({
10
+ schema: postWithCategories,
11
+ query: GQL`mutation {
12
+ updateCategory(
13
+ by: {id: "${testUuid(2)}"},
14
+ data: {posts: {set: [{connect: {id: "${testUuid(1)}"}}]}}
15
+ ) {
16
+ ok
17
+ }
18
+ }`,
19
+ executes: [
20
+ ...sqlTransaction([
21
+ {
22
+ sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."id" = ?`,
23
+ parameters: [testUuid(2)],
24
+ response: { rows: [{ id: testUuid(2) }] },
25
+ },
26
+ {
27
+ sql: SQL`select "junction_"."post_id" as "primary_" from "public"."post_categories" as "junction_" where "junction_"."category_id" = ?`,
28
+ parameters: [testUuid(2)],
29
+ response: { rows: [{ primary_: testUuid(1) }, { primary_: testUuid(3) }] },
30
+ },
31
+ {
32
+ sql: SQL`select "root_"."id" from "public"."post" as "root_" where "root_"."id" = ?`,
33
+ parameters: [testUuid(1)],
34
+ response: { rows: [{ id: testUuid(1) }] },
35
+ },
36
+ {
37
+ sql: SQL`select "root_"."id" from "public"."post" as "root_" where "root_"."id" = ?`,
38
+ parameters: [testUuid(3)],
39
+ response: { rows: [{ id: testUuid(3) }] },
40
+ },
41
+ {
42
+ sql: SQL`delete from "public"."post_categories"
43
+ where "post_id" = ? and "category_id" = ?`,
44
+ parameters: [testUuid(3), testUuid(2)],
45
+ response: { rowCount: 1 },
46
+ },
47
+ {
48
+ sql: SQL`insert into "public"."post_categories" ("post_id", "category_id") values (?, ?) on conflict do nothing`,
49
+ parameters: [testUuid(1), testUuid(2)],
50
+ response: { rowCount: 1 },
51
+ },
52
+ ]),
53
+ ],
54
+ return: {
55
+ data: {
56
+ updateCategory: {
57
+ ok: true,
58
+ },
59
+ },
60
+ },
61
+ })
62
+ })
63
+
64
+ test('empty set clears the whole collection - inverse junction', async () => {
65
+ await execute({
66
+ schema: postWithCategories,
67
+ query: GQL`mutation {
68
+ updateCategory(
69
+ by: {id: "${testUuid(2)}"},
70
+ data: {posts: {set: []}}
71
+ ) {
72
+ ok
73
+ }
74
+ }`,
75
+ executes: [
76
+ ...sqlTransaction([
77
+ {
78
+ sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."id" = ?`,
79
+ parameters: [testUuid(2)],
80
+ response: { rows: [{ id: testUuid(2) }] },
81
+ },
82
+ // no desired members - every junction row keyed by this category is an orphan
83
+ {
84
+ sql: SQL`select "junction_"."post_id" as "primary_" from "public"."post_categories" as "junction_" where "junction_"."category_id" = ?`,
85
+ parameters: [testUuid(2)],
86
+ response: { rows: [{ primary_: testUuid(1) }, { primary_: testUuid(3) }] },
87
+ },
88
+ // orphan (id=1) disconnected
89
+ {
90
+ sql: SQL`select "root_"."id" from "public"."post" as "root_" where "root_"."id" = ?`,
91
+ parameters: [testUuid(1)],
92
+ response: { rows: [{ id: testUuid(1) }] },
93
+ },
94
+ {
95
+ sql: SQL`delete from "public"."post_categories"
96
+ where "post_id" = ? and "category_id" = ?`,
97
+ parameters: [testUuid(1), testUuid(2)],
98
+ response: { rowCount: 1 },
99
+ },
100
+ // orphan (id=3) disconnected
101
+ {
102
+ sql: SQL`select "root_"."id" from "public"."post" as "root_" where "root_"."id" = ?`,
103
+ parameters: [testUuid(3)],
104
+ response: { rows: [{ id: testUuid(3) }] },
105
+ },
106
+ {
107
+ sql: SQL`delete from "public"."post_categories"
108
+ where "post_id" = ? and "category_id" = ?`,
109
+ parameters: [testUuid(3), testUuid(2)],
110
+ response: { rowCount: 1 },
111
+ },
112
+ ]),
113
+ ],
114
+ return: {
115
+ data: {
116
+ updateCategory: {
117
+ ok: true,
118
+ },
119
+ },
120
+ },
121
+ })
122
+ })
123
+
124
+ // The orphan-candidate set is fetched through the target entity's ACL read predicate, so a current
125
+ // member the role cannot read is invisible to the diff and therefore never orphaned, while a readable
126
+ // omitted member is orphaned as usual. This mirrors the oneHasMany behavior, now also on the inverse side.
127
+ const restrictedReadPermissions: Acl.Permissions = {
128
+ Post: {
129
+ predicates: {
130
+ post_read_predicate: {
131
+ title: { eq: 'visible' },
132
+ },
133
+ },
134
+ operations: {
135
+ read: {
136
+ id: 'post_read_predicate',
137
+ },
138
+ update: {
139
+ categories: true,
140
+ },
141
+ },
142
+ },
143
+ Category: {
144
+ predicates: {},
145
+ operations: {
146
+ read: {
147
+ id: true,
148
+ },
149
+ update: {
150
+ id: true,
151
+ posts: true,
152
+ },
153
+ },
154
+ },
155
+ }
156
+
157
+ test('set applies the target read predicate when computing orphans - inverse junction', async () => {
158
+ await execute({
159
+ schema: postWithCategories,
160
+ permissions: restrictedReadPermissions,
161
+ variables: {},
162
+ query: GQL`mutation {
163
+ updateCategory(
164
+ by: {id: "${testUuid(2)}"},
165
+ data: {posts: {set: [{connect: {id: "${testUuid(1)}"}}]}}
166
+ ) {
167
+ ok
168
+ }
169
+ }`,
170
+ executes: [
171
+ ...sqlTransaction([
172
+ {
173
+ sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."id" = ?`,
174
+ parameters: [testUuid(2)],
175
+ response: { rows: [{ id: testUuid(2) }] },
176
+ },
177
+ // snapshot the members up front - orphans are members from *before* the operation
178
+ // snapshot the members up front - orphans are members from *before* the operation
179
+ {
180
+ sql: SQL`select "junction_"."post_id" as "primary_" from "public"."post_categories" as "junction_"
181
+ inner join "public"."post" as "root_" on "junction_"."post_id" = "root_"."id"
182
+ where "junction_"."category_id" = ? and "root_"."title" = ?`,
183
+ parameters: [testUuid(2), 'visible'],
184
+ response: { rows: [{ primary_: testUuid(1) }, { primary_: testUuid(3) }] },
185
+ },
186
+ // resolving the connect target applies Post's read predicate
187
+ {
188
+ sql: SQL`select "root_"."id" from "public"."post" as "root_" where "root_"."id" = ? and "root_"."title" = ?`,
189
+ parameters: [testUuid(1), 'visible'],
190
+ response: { rows: [{ id: testUuid(1) }] },
191
+ },
192
+ // the readable omitted member (id=3) is disconnected from the junction
193
+ {
194
+ sql: SQL`select "root_"."id" from "public"."post" as "root_" where "root_"."id" = ? and "root_"."title" = ?`,
195
+ parameters: [testUuid(3), 'visible'],
196
+ response: { rows: [{ id: testUuid(3) }] },
197
+ },
198
+ {
199
+ sql: SQL`delete from "public"."post_categories"
200
+ where "post_id" = ? and "category_id" = ?`,
201
+ parameters: [testUuid(3), testUuid(2)],
202
+ response: { rowCount: 1 },
203
+ },
204
+ {
205
+ sql: SQL`insert into "public"."post_categories" ("post_id", "category_id") values (?, ?) on conflict do nothing`,
206
+ parameters: [testUuid(1), testUuid(2)],
207
+ response: { rowCount: 1 },
208
+ },
209
+ ]),
210
+ ],
211
+ return: {
212
+ data: {
213
+ updateCategory: {
214
+ ok: true,
215
+ },
216
+ },
217
+ },
218
+ })
219
+ })
@@ -0,0 +1,479 @@
1
+ import { test } from 'bun:test'
2
+ import { Acl } from '@contember/schema'
3
+ import { execute, failedTransaction, sqlTransaction } from '../../../../../src/test.js'
4
+ import { GQL, SQL } from '../../../../../src/tags.js'
5
+ import { testUuid } from '../../../../../src/testUuid.js'
6
+ import { postWithCategories } from './schema.js'
7
+
8
+ test('set with default orphanStrategy (disconnect) - junction', async () => {
9
+ await execute({
10
+ schema: postWithCategories,
11
+ query: GQL`mutation {
12
+ updatePost(
13
+ by: {id: "${testUuid(2)}"},
14
+ data: {categories: {set: [{connect: {id: "${testUuid(1)}"}}]}}
15
+ ) {
16
+ ok
17
+ }
18
+ }`,
19
+ executes: [
20
+ ...sqlTransaction([
21
+ {
22
+ sql: SQL`select "root_"."id" from "public"."post" as "root_" where "root_"."id" = ?`,
23
+ parameters: [testUuid(2)],
24
+ response: { rows: [{ id: testUuid(2) }] },
25
+ },
26
+ {
27
+ sql: SQL`select "junction_"."category_id" as "primary_" from "public"."post_categories" as "junction_" where "junction_"."post_id" = ?`,
28
+ parameters: [testUuid(2)],
29
+ response: { rows: [{ primary_: testUuid(1) }, { primary_: testUuid(3) }] },
30
+ },
31
+ {
32
+ sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."id" = ?`,
33
+ parameters: [testUuid(1)],
34
+ response: { rows: [{ id: testUuid(1) }] },
35
+ },
36
+ // orphan (id=3) is disconnected from the junction
37
+ {
38
+ sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."id" = ?`,
39
+ parameters: [testUuid(3)],
40
+ response: { rows: [{ id: testUuid(3) }] },
41
+ },
42
+ {
43
+ sql: SQL`delete from "public"."post_categories"
44
+ where "post_id" = ? and "category_id" = ?`,
45
+ parameters: [testUuid(2), testUuid(3)],
46
+ response: { rowCount: 1 },
47
+ },
48
+ {
49
+ sql: SQL`insert into "public"."post_categories" ("post_id", "category_id") values (?, ?) on conflict do nothing`,
50
+ parameters: [testUuid(2), testUuid(1)],
51
+ response: { rowCount: 1 },
52
+ },
53
+ ]),
54
+ ],
55
+ return: {
56
+ data: {
57
+ updatePost: {
58
+ ok: true,
59
+ },
60
+ },
61
+ },
62
+ })
63
+ })
64
+
65
+ test('set with orphanStrategy delete - junction', async () => {
66
+ await execute({
67
+ schema: postWithCategories,
68
+ query: GQL`mutation {
69
+ updatePost(
70
+ by: {id: "${testUuid(2)}"},
71
+ data: {categories: {orphanStrategy: delete, set: [{connect: {id: "${testUuid(1)}"}}]}}
72
+ ) {
73
+ ok
74
+ }
75
+ }`,
76
+ executes: [
77
+ ...sqlTransaction([
78
+ {
79
+ sql: SQL`select "root_"."id" from "public"."post" as "root_" where "root_"."id" = ?`,
80
+ parameters: [testUuid(2)],
81
+ response: { rows: [{ id: testUuid(2) }] },
82
+ },
83
+ {
84
+ sql: SQL`select "junction_"."category_id" as "primary_" from "public"."post_categories" as "junction_" where "junction_"."post_id" = ?`,
85
+ parameters: [testUuid(2)],
86
+ response: { rows: [{ primary_: testUuid(1) }, { primary_: testUuid(3) }] },
87
+ },
88
+ {
89
+ sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."id" = ?`,
90
+ parameters: [testUuid(1)],
91
+ response: { rows: [{ id: testUuid(1) }] },
92
+ },
93
+ // orphan (id=3) is deleted
94
+ {
95
+ sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."id" = ?`,
96
+ parameters: [testUuid(3)],
97
+ response: { rows: [{ id: testUuid(3) }] },
98
+ },
99
+ {
100
+ sql: SQL`select "root_"."id" as "id", true as "allowed" from "public"."category" as "root_" where "root_"."id" = ?`,
101
+ parameters: [testUuid(3)],
102
+ response: { rows: [{ id: testUuid(3), allowed: true }] },
103
+ },
104
+ {
105
+ sql: SQL`delete from "public"."category" where "id" in (?)`,
106
+ parameters: [testUuid(3)],
107
+ response: { rows: [{ id: testUuid(3) }] },
108
+ },
109
+ {
110
+ sql: SQL`insert into "public"."post_categories" ("post_id", "category_id") values (?, ?) on conflict do nothing`,
111
+ parameters: [testUuid(2), testUuid(1)],
112
+ response: { rowCount: 1 },
113
+ },
114
+ ]),
115
+ ],
116
+ return: {
117
+ data: {
118
+ updatePost: {
119
+ ok: true,
120
+ },
121
+ },
122
+ },
123
+ })
124
+ })
125
+
126
+ test('empty set clears the whole collection - junction', async () => {
127
+ await execute({
128
+ schema: postWithCategories,
129
+ query: GQL`mutation {
130
+ updatePost(
131
+ by: {id: "${testUuid(2)}"},
132
+ data: {categories: {set: []}}
133
+ ) {
134
+ ok
135
+ }
136
+ }`,
137
+ executes: [
138
+ ...sqlTransaction([
139
+ {
140
+ sql: SQL`select "root_"."id" from "public"."post" as "root_" where "root_"."id" = ?`,
141
+ parameters: [testUuid(2)],
142
+ response: { rows: [{ id: testUuid(2) }] },
143
+ },
144
+ // no desired members - every junction row is an orphan
145
+ {
146
+ sql: SQL`select "junction_"."category_id" as "primary_" from "public"."post_categories" as "junction_" where "junction_"."post_id" = ?`,
147
+ parameters: [testUuid(2)],
148
+ response: { rows: [{ primary_: testUuid(1) }, { primary_: testUuid(3) }] },
149
+ },
150
+ // orphan (id=1) disconnected
151
+ {
152
+ sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."id" = ?`,
153
+ parameters: [testUuid(1)],
154
+ response: { rows: [{ id: testUuid(1) }] },
155
+ },
156
+ {
157
+ sql: SQL`delete from "public"."post_categories"
158
+ where "post_id" = ? and "category_id" = ?`,
159
+ parameters: [testUuid(2), testUuid(1)],
160
+ response: { rowCount: 1 },
161
+ },
162
+ // orphan (id=3) disconnected
163
+ {
164
+ sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."id" = ?`,
165
+ parameters: [testUuid(3)],
166
+ response: { rows: [{ id: testUuid(3) }] },
167
+ },
168
+ {
169
+ sql: SQL`delete from "public"."post_categories"
170
+ where "post_id" = ? and "category_id" = ?`,
171
+ parameters: [testUuid(2), testUuid(3)],
172
+ response: { rowCount: 1 },
173
+ },
174
+ ]),
175
+ ],
176
+ return: {
177
+ data: {
178
+ updatePost: {
179
+ ok: true,
180
+ },
181
+ },
182
+ },
183
+ })
184
+ })
185
+
186
+ test('set with a connectOrCreate item (existing target) - junction', async () => {
187
+ await execute({
188
+ schema: postWithCategories,
189
+ query: GQL`mutation {
190
+ updatePost(
191
+ by: {id: "${testUuid(2)}"},
192
+ data: {categories: {set: [{connectOrCreate: {connect: {id: "${testUuid(1)}"}, create: {name: "Ipsum"}}}]}}
193
+ ) {
194
+ ok
195
+ }
196
+ }`,
197
+ executes: [
198
+ ...sqlTransaction([
199
+ {
200
+ sql: SQL`select "root_"."id" from "public"."post" as "root_" where "root_"."id" = ?`,
201
+ parameters: [testUuid(2)],
202
+ response: { rows: [{ id: testUuid(2) }] },
203
+ },
204
+ // snapshot the members up front - orphans are members from *before* the operation
205
+ {
206
+ sql: SQL`select "junction_"."category_id" as "primary_" from "public"."post_categories" as "junction_" where "junction_"."post_id" = ?`,
207
+ parameters: [testUuid(2)],
208
+ response: { rows: [{ primary_: testUuid(1) }, { primary_: testUuid(3) }] },
209
+ },
210
+ // the set helper resolves the connectOrCreate target up-front to mark it desired
211
+ {
212
+ sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."id" = ?`,
213
+ parameters: [testUuid(1)],
214
+ response: { rows: [{ id: testUuid(1) }] },
215
+ },
216
+ {
217
+ sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."id" = ?`,
218
+ parameters: [testUuid(3)],
219
+ response: { rows: [{ id: testUuid(3) }] },
220
+ },
221
+ {
222
+ sql: SQL`delete from "public"."post_categories"
223
+ where "post_id" = ? and "category_id" = ?`,
224
+ parameters: [testUuid(2), testUuid(3)],
225
+ response: { rowCount: 1 },
226
+ },
227
+ // connectOrCreate processor resolves the target again and connects it
228
+ {
229
+ sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."id" = ?`,
230
+ parameters: [testUuid(1)],
231
+ response: { rows: [{ id: testUuid(1) }] },
232
+ },
233
+ {
234
+ sql: SQL`insert into "public"."post_categories" ("post_id", "category_id") values (?, ?) on conflict do nothing`,
235
+ parameters: [testUuid(2), testUuid(1)],
236
+ response: { rowCount: 1 },
237
+ },
238
+ ]),
239
+ ],
240
+ return: {
241
+ data: {
242
+ updatePost: {
243
+ ok: true,
244
+ },
245
+ },
246
+ },
247
+ })
248
+ })
249
+
250
+ // The orphan-candidate set is fetched through the target entity's ACL read predicate, so a current
251
+ // member the role cannot read is invisible to the diff and therefore never orphaned, while a readable
252
+ // omitted member is orphaned as usual. This mirrors the oneHasMany behavior.
253
+ const restrictedReadPermissions: Acl.Permissions = {
254
+ Post: {
255
+ predicates: {},
256
+ operations: {
257
+ read: {
258
+ id: true,
259
+ },
260
+ update: {
261
+ id: true,
262
+ categories: true,
263
+ },
264
+ },
265
+ },
266
+ Category: {
267
+ predicates: {
268
+ category_read_predicate: {
269
+ name: { eq: 'visible' },
270
+ },
271
+ },
272
+ operations: {
273
+ read: {
274
+ id: 'category_read_predicate',
275
+ },
276
+ update: {
277
+ posts: true,
278
+ },
279
+ },
280
+ },
281
+ }
282
+
283
+ test('set applies the target read predicate when computing orphans - junction', async () => {
284
+ await execute({
285
+ schema: postWithCategories,
286
+ permissions: restrictedReadPermissions,
287
+ variables: {},
288
+ query: GQL`mutation {
289
+ updatePost(
290
+ by: {id: "${testUuid(2)}"},
291
+ data: {categories: {set: [{connect: {id: "${testUuid(1)}"}}]}}
292
+ ) {
293
+ ok
294
+ }
295
+ }`,
296
+ executes: [
297
+ ...sqlTransaction([
298
+ {
299
+ sql: SQL`select "root_"."id" from "public"."post" as "root_" where "root_"."id" = ?`,
300
+ parameters: [testUuid(2)],
301
+ response: { rows: [{ id: testUuid(2) }] },
302
+ },
303
+ // snapshot the members up front - orphans are members from *before* the operation
304
+ // snapshot the members up front - orphans are members from *before* the operation
305
+ // snapshot the members up front - orphans are members from *before* the operation
306
+ {
307
+ sql: SQL`select "junction_"."category_id" as "primary_" from "public"."post_categories" as "junction_"
308
+ inner join "public"."category" as "root_" on "junction_"."category_id" = "root_"."id"
309
+ where "junction_"."post_id" = ? and "root_"."name" = ?`,
310
+ parameters: [testUuid(2), 'visible'],
311
+ response: { rows: [{ primary_: testUuid(1) }, { primary_: testUuid(3) }] },
312
+ },
313
+ // resolving the connect target applies Category's read predicate
314
+ {
315
+ sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."id" = ? and "root_"."name" = ?`,
316
+ parameters: [testUuid(1), 'visible'],
317
+ response: { rows: [{ id: testUuid(1) }] },
318
+ },
319
+ // the readable omitted member (id=3) is disconnected from the junction
320
+ {
321
+ sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."id" = ? and "root_"."name" = ?`,
322
+ parameters: [testUuid(3), 'visible'],
323
+ response: { rows: [{ id: testUuid(3) }] },
324
+ },
325
+ {
326
+ sql: SQL`delete from "public"."post_categories"
327
+ where "post_id" = ? and "category_id" = ?`,
328
+ parameters: [testUuid(2), testUuid(3)],
329
+ response: { rowCount: 1 },
330
+ },
331
+ {
332
+ sql: SQL`insert into "public"."post_categories" ("post_id", "category_id") values (?, ?) on conflict do nothing`,
333
+ parameters: [testUuid(2), testUuid(1)],
334
+ response: { rowCount: 1 },
335
+ },
336
+ ]),
337
+ ],
338
+ return: {
339
+ data: {
340
+ updatePost: {
341
+ ok: true,
342
+ },
343
+ },
344
+ },
345
+ })
346
+ })
347
+
348
+ test('set with orphanStrategy delete is rejected when delete is ACL-denied - junction', async () => {
349
+ await execute({
350
+ schema: postWithCategories,
351
+ query: GQL`mutation {
352
+ updatePost(
353
+ by: {id: "${testUuid(2)}"},
354
+ data: {categories: {orphanStrategy: delete, set: [{connect: {id: "${testUuid(1)}"}}]}}
355
+ ) {
356
+ ok
357
+ }
358
+ }`,
359
+ executes: [
360
+ ...failedTransaction([
361
+ {
362
+ sql: SQL`select "root_"."id" from "public"."post" as "root_" where "root_"."id" = ?`,
363
+ parameters: [testUuid(2)],
364
+ response: { rows: [{ id: testUuid(2) }] },
365
+ },
366
+ {
367
+ sql: SQL`select "junction_"."category_id" as "primary_" from "public"."post_categories" as "junction_" where "junction_"."post_id" = ?`,
368
+ parameters: [testUuid(2)],
369
+ response: { rows: [{ primary_: testUuid(1) }, { primary_: testUuid(3) }] },
370
+ },
371
+ {
372
+ sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."id" = ?`,
373
+ parameters: [testUuid(1)],
374
+ response: { rows: [{ id: testUuid(1) }] },
375
+ },
376
+ // orphan (id=3): delete is attempted, but the ACL predicate denies it
377
+ {
378
+ sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."id" = ?`,
379
+ parameters: [testUuid(3)],
380
+ response: { rows: [{ id: testUuid(3) }] },
381
+ },
382
+ {
383
+ sql: SQL`select "root_"."id" as "id", true as "allowed" from "public"."category" as "root_" where "root_"."id" = ?`,
384
+ parameters: [testUuid(3)],
385
+ response: { rows: [{ id: testUuid(3), allowed: false }] },
386
+ },
387
+ ]),
388
+ ],
389
+ return: {
390
+ data: {
391
+ updatePost: {
392
+ ok: false,
393
+ },
394
+ },
395
+ },
396
+ })
397
+ })
398
+
399
+ // The manyHasMany connectOrCreate processor returns junction results only, so the created primary
400
+ // cannot be recovered from the step result. The pre-operation snapshot is what keeps the freshly
401
+ // created record out of the orphan set.
402
+ test('set with a connectOrCreate item that creates - junction', async () => {
403
+ await execute({
404
+ schema: postWithCategories,
405
+ query: GQL`mutation {
406
+ updatePost(
407
+ by: {id: "${testUuid(2)}"},
408
+ data: {categories: {orphanStrategy: delete, set: [{connectOrCreate: {connect: {id: "${testUuid(10)}"}, create: {name: "Ipsum"}}}]}}
409
+ ) {
410
+ ok
411
+ }
412
+ }`,
413
+ executes: [
414
+ ...sqlTransaction([
415
+ {
416
+ sql: SQL`select "root_"."id" from "public"."post" as "root_" where "root_"."id" = ?`,
417
+ parameters: [testUuid(2)],
418
+ response: { rows: [{ id: testUuid(2) }] },
419
+ },
420
+ // snapshot the members up front - orphans are members from *before* the operation
421
+ {
422
+ sql: SQL`select "junction_"."category_id" as "primary_" from "public"."post_categories" as "junction_" where "junction_"."post_id" = ?`,
423
+ parameters: [testUuid(2)],
424
+ response: { rows: [{ primary_: testUuid(3) }] },
425
+ },
426
+ // the set helper resolves the connectOrCreate target up-front - it does not exist
427
+ {
428
+ sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."id" = ?`,
429
+ parameters: [testUuid(10)],
430
+ response: { rows: [] },
431
+ },
432
+ // only the pre-existing member (id=3) is deleted; the created category is never orphaned
433
+ {
434
+ sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."id" = ?`,
435
+ parameters: [testUuid(3)],
436
+ response: { rows: [{ id: testUuid(3) }] },
437
+ },
438
+ {
439
+ sql: SQL`select "root_"."id" as "id", true as "allowed" from "public"."category" as "root_" where "root_"."id" = ?`,
440
+ parameters: [testUuid(3)],
441
+ response: { rows: [{ id: testUuid(3), allowed: true }] },
442
+ },
443
+ {
444
+ sql: SQL`delete from "public"."category" where "id" in (?)`,
445
+ parameters: [testUuid(3)],
446
+ response: { rows: [{ id: testUuid(3) }] },
447
+ },
448
+ // connectOrCreate processor resolves the target again and creates it
449
+ {
450
+ sql: SQL`select "root_"."id" from "public"."category" as "root_" where "root_"."id" = ?`,
451
+ parameters: [testUuid(10)],
452
+ response: { rows: [] },
453
+ },
454
+ {
455
+ sql: SQL`with "root_" as
456
+ (select ? :: uuid as "id", ? :: text as "name")
457
+ insert into "public"."category" ("id", "name")
458
+ select "root_"."id", "root_"."name"
459
+ from "root_"
460
+ returning "id"`,
461
+ parameters: [testUuid(1), 'Ipsum'],
462
+ response: { rows: [{ id: testUuid(1) }] },
463
+ },
464
+ {
465
+ sql: SQL`insert into "public"."post_categories" ("post_id", "category_id") values (?, ?) on conflict do nothing`,
466
+ parameters: [testUuid(2), testUuid(1)],
467
+ response: { rowCount: 1 },
468
+ },
469
+ ]),
470
+ ],
471
+ return: {
472
+ data: {
473
+ updatePost: {
474
+ ok: true,
475
+ },
476
+ },
477
+ },
478
+ })
479
+ })