@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,199 @@
1
+ import { Input, Model } from '@contember/schema'
2
+ import { Mapper } from '../../Mapper.js'
3
+ import { UpdateInputProcessor } from '../../../inputProcessing/index.js'
4
+ import { InputErrorKind, MutationDeleteOk, MutationInputError, MutationResult, MutationResultList, prependPath } from '../../Result.js'
5
+ import { CheckedPrimary } from '../../CheckedPrimary.js'
6
+ import { MapperInput } from '../../types.js'
7
+ import { SqlUpdateInputProcessorResult } from '../SqlUpdateInputProcessor.js'
8
+ import { ImplementationException } from '../../../exception.js'
9
+
10
+ type HasManyContext =
11
+ | Model.OneHasManyContext
12
+ | Model.ManyHasManyOwningContext
13
+ | Model.ManyHasManyInverseContext
14
+
15
+ /**
16
+ * The subset of {@link UpdateInputProcessor.HasManyRelationInputProcessor} methods reused by `set`.
17
+ * Each method returns either a result list or a thunk that finalizes once the owner primary is known.
18
+ */
19
+ interface SetCapableProcessor<Context> {
20
+ connect(context: Context & { input: Input.UniqueWhere | CheckedPrimary; index: number; alias?: string }): Promise<SqlUpdateInputProcessorResult>
21
+ create(context: Context & { input: MapperInput.CreateDataInput; index: number; alias?: string }): Promise<SqlUpdateInputProcessorResult>
22
+ connectOrCreate(
23
+ context: Context & { input: MapperInput.ConnectOrCreateInput; index: number; alias?: string },
24
+ ): Promise<SqlUpdateInputProcessorResult>
25
+ update(context: Context & { input: UpdateInputProcessor.UpdateManyInput; index: number; alias?: string }): Promise<SqlUpdateInputProcessorResult>
26
+ upsert(context: Context & { input: UpdateInputProcessor.UpsertManyInput; index: number; alias?: string }): Promise<SqlUpdateInputProcessorResult>
27
+ disconnect(context: Context & { input: Input.UniqueWhere; index: number; alias?: string }): Promise<SqlUpdateInputProcessorResult>
28
+ delete(context: Context & { input: Input.UniqueWhere; index: number; alias?: string }): Promise<SqlUpdateInputProcessorResult>
29
+ }
30
+
31
+ const runStep = async (result: SqlUpdateInputProcessorResult, primary: Input.PrimaryValue): Promise<MutationResultList> => {
32
+ return typeof result === 'function' ? await result({ primary }) : await result
33
+ }
34
+
35
+ /**
36
+ * `update` and `upsert` on a oneHasMany resolve their `by` *within* the collection - the processor
37
+ * completes the where with the owner, which is what lets a partial composite unique key (say
38
+ * `unique(['locale', 'post'])` addressed by `{locale}` alone) identify a row. Resolving such a
39
+ * where globally would fail as non-unique, so the lookup has to be scoped the same way.
40
+ * Every other lookup - and every lookup on a junction relation - is global, again matching the
41
+ * processor it feeds.
42
+ */
43
+ const scopeToOwner = <Context extends HasManyContext>(
44
+ context: Context,
45
+ ownerPrimary: Input.PrimaryValue,
46
+ where: Input.UniqueWhere,
47
+ ): Input.UniqueWhere => {
48
+ if (context.type !== 'oneHasMany') {
49
+ return where
50
+ }
51
+ return { ...where, [context.targetRelation.name]: { [context.entity.primary]: ownerPrimary } }
52
+ }
53
+
54
+ /**
55
+ * Implements the declarative `set` operation for has-many relations.
56
+ *
57
+ * Runs in three phases:
58
+ *
59
+ * 1. resolve which of the current members the input names, without writing anything;
60
+ * 2. remove the members it does not name, according to `orphanStrategy`;
61
+ * 3. connect/create/update the members it does name.
62
+ *
63
+ * Removal comes first so that the old and the new row never coexist: a unique key that includes
64
+ * the owner - `unique(['locale', 'post'])`, the "replace all translations" shape this operation
65
+ * exists for - would otherwise be violated by the intermediate state. Phase 1 writes nothing, so
66
+ * a member named by the input is never removed and re-added; and a record created in phase 3
67
+ * cannot be an orphan, because orphans come from a snapshot taken before it existed.
68
+ */
69
+ export const processSetManyRelationInput = async <Context extends HasManyContext>(
70
+ mapper: Mapper,
71
+ context: Context,
72
+ ownerPrimary: Input.PrimaryValue,
73
+ processor: SetCapableProcessor<Context>,
74
+ input: UpdateInputProcessor.SetManyInput,
75
+ ): Promise<MutationResultList> => {
76
+ const { targetEntity } = context
77
+ const results: MutationResultList = []
78
+ // primary of an existing target the input names -> the first item naming it
79
+ const desiredPrimaries = new Map<string, { primary: Input.PrimaryValue; index: number; alias?: string }>()
80
+
81
+ const markDesired = (primary: Input.PrimaryValue | undefined, index: number, alias?: string) => {
82
+ if (primary !== undefined && primary !== null && !desiredPrimaries.has(String(primary))) {
83
+ desiredPrimaries.set(String(primary), { primary, index, alias })
84
+ }
85
+ }
86
+ const itemPath = (index: number, alias?: string) => [{ index, alias }]
87
+ const fail = (index: number, alias: string | undefined, err: MutationResult): MutationResultList => {
88
+ return [...results, ...prependPath(itemPath(index, alias), [err])]
89
+ }
90
+
91
+ const currentPrimaries = await mapper.fetchHasManyPrimaries(context, ownerPrimary)
92
+
93
+ // Phase 1 - which current members does the input name? `create` never names one, and a target
94
+ // that does not exist yet is not a member either, so both simply leave the set unmarked.
95
+ const connectTargets: CheckedPrimary[] = []
96
+ for (const [index, item] of input.items.entries()) {
97
+ if ('connect' in item) {
98
+ const [primary, err] = await mapper.getPrimaryValue(targetEntity, item.connect, 'nested')
99
+ if (err) {
100
+ return fail(index, item.alias, err)
101
+ }
102
+ connectTargets[index] = new CheckedPrimary(primary)
103
+ markDesired(primary, index, item.alias)
104
+ } else if ('update' in item) {
105
+ const [primary, err] = await mapper.getPrimaryValue(targetEntity, scopeToOwner(context, ownerPrimary, item.update.by), 'nested')
106
+ if (err) {
107
+ return fail(index, item.alias, err)
108
+ }
109
+ markDesired(primary, index, item.alias)
110
+ } else if ('upsert' in item) {
111
+ // A missing target is not an error here - the processor falls back to creating it.
112
+ const [primary] = await mapper.getPrimaryValue(targetEntity, scopeToOwner(context, ownerPrimary, item.upsert.by), 'nested')
113
+ markDesired(primary, index, item.alias)
114
+ } else if ('connectOrCreate' in item) {
115
+ const [primary] = await mapper.getPrimaryValue(targetEntity, item.connectOrCreate.connect, 'nested')
116
+ markDesired(primary, index, item.alias)
117
+ } else if (!('create' in item)) {
118
+ throw new ImplementationException('Unknown "set" item operation; the input visitor should have rejected it.')
119
+ }
120
+ }
121
+
122
+ // Phase 2 - remove the members the input does not name. Only deletes made by these removals count:
123
+ // the transaction-wide deletion history keeps rows that were deleted and recreated with the same id.
124
+ const removedTargets = new Set<string>()
125
+ for (const current of currentPrimaries) {
126
+ // already gone through the cascade of an earlier removal
127
+ if (desiredPrimaries.has(String(current)) || removedTargets.has(String(current))) {
128
+ continue
129
+ }
130
+ const where: Input.UniqueWhere = { [targetEntity.primary]: current }
131
+ const orphanResult = input.orphanStrategy === Input.OrphanRemovalStrategy.delete
132
+ ? await runStep(await processor.delete({ ...context, input: where, index: 0, alias: undefined }), ownerPrimary)
133
+ : await runStep(await processor.disconnect({ ...context, input: where, index: 0, alias: undefined }), ownerPrimary)
134
+ results.push(...orphanResult)
135
+ if (orphanResult.some(it => it.error)) {
136
+ return results
137
+ }
138
+ for (const entry of orphanResult) {
139
+ if (entry instanceof MutationDeleteOk && entry.entity.name === targetEntity.name) {
140
+ removedTargets.add(String(entry.primary))
141
+ }
142
+ }
143
+ }
144
+
145
+ // A removal can cascade into a target the input names. Establishing it now would fail (connect,
146
+ // update) or silently create a new row in its place (upsert, connectOrCreate), so refuse instead.
147
+ for (const { primary, index, alias } of desiredPrimaries.values()) {
148
+ if (removedTargets.has(String(primary))) {
149
+ return fail(
150
+ index,
151
+ alias,
152
+ new MutationInputError(
153
+ [],
154
+ InputErrorKind.invalidData,
155
+ `${targetEntity.name} "${String(primary)}" named by "set" was deleted by a cascade of removing an orphan.`,
156
+ ),
157
+ )
158
+ }
159
+ }
160
+
161
+ // Phase 3 - establish the members the input does name.
162
+ for (const [index, item] of input.items.entries()) {
163
+ const alias = item.alias
164
+ let stepResult: MutationResultList
165
+ if ('connect' in item) {
166
+ stepResult = await runStep(
167
+ await processor.connect({ ...context, input: connectTargets[index], index, alias }),
168
+ ownerPrimary,
169
+ )
170
+ } else if ('create' in item) {
171
+ stepResult = await runStep(await processor.create({ ...context, input: item.create, index, alias }), ownerPrimary)
172
+ } else if ('connectOrCreate' in item) {
173
+ stepResult = await runStep(await processor.connectOrCreate({ ...context, input: item.connectOrCreate, index, alias }), ownerPrimary)
174
+ } else if ('update' in item) {
175
+ stepResult = await runStep(
176
+ await processor.update({ ...context, input: { where: item.update.by, data: item.update.data }, index, alias }),
177
+ ownerPrimary,
178
+ )
179
+ } else if ('upsert' in item) {
180
+ stepResult = await runStep(
181
+ await processor.upsert({
182
+ ...context,
183
+ input: { where: item.upsert.by, update: item.upsert.update, create: item.upsert.create },
184
+ index,
185
+ alias,
186
+ }),
187
+ ownerPrimary,
188
+ )
189
+ } else {
190
+ throw new ImplementationException('Unknown "set" item operation; the input visitor should have rejected it.')
191
+ }
192
+ results.push(...prependPath(itemPath(index, alias), stepResult))
193
+ if (stepResult.some(it => it.error)) {
194
+ return results
195
+ }
196
+ }
197
+
198
+ return results
199
+ }
@@ -583,6 +583,8 @@ export class MutationResolver {
583
583
  }
584
584
  case ConstraintType.uniqueKey:
585
585
  return { path, paths, type: Result.ExecutionErrorType.UniqueConstraintViolation, message: it.message }
586
+ case ConstraintType.check:
587
+ return { path, paths, type: Result.ExecutionErrorType.CheckConstraintViolation, message: it.message }
586
588
  default:
587
589
  return assertNever(it.constraint)
588
590
  }
@@ -1,5 +1,6 @@
1
- import { GraphQLScalarType, Kind } from 'graphql'
1
+ import { GraphQLError, GraphQLScalarType, Kind, ValueNode } from 'graphql'
2
2
  import { JSONType, UuidType } from '@contember/graphql-utils'
3
+ import { isImpossibleCalendarDate } from './calendarDate.js'
3
4
 
4
5
  const TIME_REGEX = /^([01]\d|2[0-3]):([0-5]\d)(?::([0-5]\d)(?:\.(\d+))?)?$/
5
6
 
@@ -40,6 +41,26 @@ function validateTime(value: unknown): string {
40
41
  return `${hours}:${minutes}:${seconds}${fraction}`
41
42
  }
42
43
 
44
+ function validateCalendarDate(value: string): string {
45
+ if (isImpossibleCalendarDate(value)) {
46
+ throw new TypeError(`Value is not a valid date: ${value}`)
47
+ }
48
+ return value
49
+ }
50
+
51
+ // graphql-js passes a GraphQLError thrown while parsing input through as is, and engine-http reports it as a client error.
52
+ // Any other error becomes the originalError of a wrapping GraphQLError, which engine-http unwraps and reports as internal.
53
+ function parseInput<T>(parse: () => T, node?: ValueNode): T {
54
+ try {
55
+ return parse()
56
+ } catch (error) {
57
+ if (error instanceof TypeError) {
58
+ throw new GraphQLError(error.message, { nodes: node })
59
+ }
60
+ throw error
61
+ }
62
+ }
63
+
43
64
  export class CustomTypesProvider {
44
65
  public readonly uuidType: GraphQLScalarType = UuidType
45
66
 
@@ -48,9 +69,9 @@ export class CustomTypesProvider {
48
69
  public readonly dateType: GraphQLScalarType = new GraphQLScalarType({
49
70
  name: 'Date',
50
71
  serialize: str => String(str),
51
- parseValue: str => String(str),
72
+ parseValue: str => parseInput(() => validateCalendarDate(String(str))),
52
73
  parseLiteral: function parseLiteral(ast) {
53
- return ast.kind === Kind.STRING ? ast.value : undefined
74
+ return ast.kind === Kind.STRING ? parseInput(() => validateCalendarDate(ast.value), ast) : undefined
54
75
  },
55
76
  })
56
77
 
@@ -60,22 +81,24 @@ export class CustomTypesProvider {
60
81
  return validateTime(value)
61
82
  },
62
83
  parseValue(value) {
63
- return validateTime(value)
84
+ return parseInput(() => validateTime(value))
64
85
  },
65
86
  parseLiteral(ast) {
66
- if (ast.kind !== Kind.STRING) {
67
- throw new TypeError(`Time scalar can only parse string values, got: ${ast.kind}`)
68
- }
69
- return validateTime(ast.value)
87
+ return parseInput(() => {
88
+ if (ast.kind !== Kind.STRING) {
89
+ throw new TypeError(`Time scalar can only parse string values, got: ${ast.kind}`)
90
+ }
91
+ return validateTime(ast.value)
92
+ }, ast)
70
93
  },
71
94
  })
72
95
 
73
96
  public readonly dateTimeType: GraphQLScalarType = new GraphQLScalarType({
74
97
  name: 'DateTime',
75
98
  serialize: str => String(str),
76
- parseValue: str => String(str),
99
+ parseValue: str => parseInput(() => validateCalendarDate(String(str))),
77
100
  parseLiteral: function parseLiteral(ast) {
78
- return ast.kind === Kind.STRING ? ast.value : undefined
101
+ return ast.kind === Kind.STRING ? parseInput(() => validateCalendarDate(ast.value), ast) : undefined
79
102
  },
80
103
  })
81
104
  public readonly jsonType: GraphQLScalarType = JSONType
@@ -87,13 +110,15 @@ export class CustomTypesProvider {
87
110
  return validateDecimal(value)
88
111
  },
89
112
  parseValue(value) {
90
- return validateDecimal(value)
113
+ return parseInput(() => validateDecimal(value))
91
114
  },
92
115
  parseLiteral(ast) {
93
- if (ast.kind === Kind.STRING || ast.kind === Kind.INT || ast.kind === Kind.FLOAT) {
94
- return validateDecimal(ast.value)
95
- }
96
- throw new TypeError(`Decimal scalar can only parse string or numeric values, got: ${ast.kind}`)
116
+ return parseInput(() => {
117
+ if (ast.kind === Kind.STRING || ast.kind === Kind.INT || ast.kind === Kind.FLOAT) {
118
+ return validateDecimal(ast.value)
119
+ }
120
+ throw new TypeError(`Decimal scalar can only parse string or numeric values, got: ${ast.kind}`)
121
+ }, ast)
97
122
  },
98
123
  })
99
124
  }
@@ -69,14 +69,15 @@ export class EntityTypeProvider {
69
69
  }
70
70
 
71
71
  private createEntity(entityName: string) {
72
+ const entity = getEntityFromSchema(this.schema, entityName)
72
73
  return new GraphQLObjectType({
73
74
  name: GqlTypeName`${entityName}`,
74
- fields: () => this.getEntityFields(entityName),
75
+ description: entity.description,
76
+ fields: () => this.getEntityFields(entity),
75
77
  } as GraphQLObjectTypeConfig<any, any>)
76
78
  }
77
79
 
78
- private getEntityFields(entityName: string) {
79
- const entity = getEntityFromSchema(this.schema, entityName)
80
+ private getEntityFields(entity: Model.Entity) {
80
81
  const accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)
81
82
  const accessibleFields = Object.values(entity.fields).filter(field => acceptFieldVisitor(this.schema, entity, field.name, accessVisitor))
82
83
  const metaFields: { [field: string]: GraphQLFieldConfig<any, any> } = {}
@@ -89,7 +90,7 @@ export class EntityTypeProvider {
89
90
 
90
91
  const metaField = {
91
92
  type: new GraphQLObjectType({
92
- name: GqlTypeName`${entityName}Meta`,
93
+ name: GqlTypeName`${entity.name}Meta`,
93
94
  fields: metaFields,
94
95
  }),
95
96
  resolve: aliasAwareResolver,
@@ -108,6 +109,8 @@ export class EntityTypeProvider {
108
109
  type,
109
110
  args: acceptFieldVisitor(this.schema, entity, field.name, fieldArgsVisitor),
110
111
  resolve: aliasAwareResolver,
112
+ deprecationReason: field.deprecationReason,
113
+ description: field.description,
111
114
  }
112
115
  }
113
116
 
@@ -117,6 +120,7 @@ export class EntityTypeProvider {
117
120
  ...provider.getFields(entity, accessibleFields),
118
121
  }
119
122
  }
123
+
120
124
  return fields
121
125
  }
122
126
 
@@ -55,6 +55,7 @@ export class MutationProvider {
55
55
  const resultType = this.createResultType(entityName, 'create')
56
56
  return {
57
57
  type: new GraphQLNonNull(resultType),
58
+ deprecationReason: entity.deprecationReason,
58
59
  args: {
59
60
  data: { type: new GraphQLNonNull(dataType) },
60
61
  },
@@ -84,6 +85,7 @@ export class MutationProvider {
84
85
  }
85
86
  return {
86
87
  type: new GraphQLNonNull(this.createResultType(entityName, 'delete')),
88
+ deprecationReason: entity.deprecationReason,
87
89
  args: {
88
90
  by: {
89
91
  type: new GraphQLNonNull(uniqueWhere),
@@ -120,6 +122,7 @@ export class MutationProvider {
120
122
  }
121
123
  return {
122
124
  type: new GraphQLNonNull(resultType),
125
+ deprecationReason: entity.deprecationReason,
123
126
  args: {
124
127
  by: {
125
128
  type: new GraphQLNonNull(uniqueWhere),
@@ -165,6 +168,7 @@ export class MutationProvider {
165
168
  }
166
169
  return {
167
170
  type: new GraphQLNonNull(resultType),
171
+ deprecationReason: entity.deprecationReason,
168
172
  args: {
169
173
  by: {
170
174
  type: new GraphQLNonNull(uniqueWhere),
@@ -10,7 +10,7 @@ import {
10
10
  import { Acl, Model } from '@contember/schema'
11
11
  import { acceptFieldVisitor } from '@contember/schema-utils'
12
12
  import { singletonFactory } from '../utils/index.js'
13
- import { GqlTypeName } from './utils.js'
13
+ import { GqlTypeName, inputFieldDescription } from './utils.js'
14
14
  import { Authorizator } from '../acl/index.js'
15
15
  import { FieldAccessVisitor } from './FieldAccessVisitor.js'
16
16
 
@@ -61,9 +61,15 @@ export class OrderByTypeProvider {
61
61
  if (column.list) {
62
62
  return undefined
63
63
  }
64
- return ({ type: this.orderDirectionEnum })
64
+ return {
65
+ type: this.orderDirectionEnum,
66
+ description: inputFieldDescription(column),
67
+ }
65
68
  },
66
- visitHasOne: ({ relation }) => ({ type: this.getEntityOrderByType(relation.target) }),
69
+ visitHasOne: ({ relation }) => ({
70
+ type: this.getEntityOrderByType(relation.target),
71
+ description: inputFieldDescription(relation),
72
+ }),
67
73
  visitHasMany: () => undefined,
68
74
  } as Model.FieldVisitor<GraphQLInputFieldConfig | undefined>)
69
75
 
@@ -41,6 +41,7 @@ export class QueryProvider {
41
41
  }
42
42
  return {
43
43
  type: entityType,
44
+ deprecationReason: entity.deprecationReason,
44
45
  args: {
45
46
  by: {
46
47
  type: new GraphQLNonNull(uniqueWhere),
@@ -67,6 +68,7 @@ export class QueryProvider {
67
68
  const entityType = this.entityTypeProvider.getEntity(entityName)
68
69
  return {
69
70
  type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(entityType))),
71
+ deprecationReason: entity.deprecationReason,
70
72
  args: {
71
73
  filter: {
72
74
  type: this.whereTypeProvider.getEntityWhereType(entityName),
@@ -96,6 +98,7 @@ export class QueryProvider {
96
98
  private getPaginationQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.ListQueryInput> {
97
99
  return {
98
100
  ...this.paginatedFieldConfigFactory.createFieldConfig(entity),
101
+ deprecationReason: entity.deprecationReason,
99
102
  extensions: { [ExtensionKey]: new OperationMeta(Operation.paginate, entity) },
100
103
  resolve: (parent, args, context, info) => {
101
104
  return context.timer(`GraphQL.query.${info.fieldName}`, () => {
@@ -33,6 +33,7 @@ export class ValidationQueriesProvider {
33
33
  }
34
34
  return {
35
35
  type: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),
36
+ deprecationReason: entity.deprecationReason,
36
37
  args: {
37
38
  data: { type: new GraphQLNonNull(dataType) },
38
39
  },
@@ -53,6 +54,7 @@ export class ValidationQueriesProvider {
53
54
  }
54
55
  return {
55
56
  type: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),
57
+ deprecationReason: entity.deprecationReason,
56
58
  args: {
57
59
  by: {
58
60
  type: new GraphQLNonNull(uniqueWhere),
@@ -4,7 +4,7 @@ import { GraphQLInputFieldConfig, GraphQLInputFieldConfigMap, GraphQLInputObject
4
4
  import { capitalizeFirstLetter, getFieldsForUniqueWhere, singletonFactory } from '../utils/index.js'
5
5
  import { ColumnTypeResolver } from './ColumnTypeResolver.js'
6
6
  import { ConditionTypeProvider } from './ConditionTypeProvider.js'
7
- import { GqlTypeName } from './utils.js'
7
+ import { GqlTypeName, inputFieldDescription } from './utils.js'
8
8
  import { Authorizator } from '../acl/index.js'
9
9
  import { FieldAccessVisitor } from './FieldAccessVisitor.js'
10
10
  import { ImplementationException } from '../exception.js'
@@ -71,7 +71,7 @@ export class WhereTypeProvider {
71
71
  continue
72
72
  }
73
73
  fields[field] = acceptFieldVisitor<GraphQLInputFieldConfig>(this.schema, entity, field, {
74
- visitRelation: ({ targetEntity }) => {
74
+ visitRelation: ({ relation, targetEntity }) => {
75
75
  // if (!isIt<Model.JoiningColumnRelation>(relation, 'joiningColumn')) {
76
76
  // throw new Error('Only column or owning relation can be a part of unique key')
77
77
  // }
@@ -79,9 +79,15 @@ export class WhereTypeProvider {
79
79
  if (!uniqueWhere) {
80
80
  throw new ImplementationException()
81
81
  }
82
- return { type: uniqueWhere }
82
+ return {
83
+ type: uniqueWhere,
84
+ description: inputFieldDescription(relation),
85
+ }
83
86
  },
84
- visitColumn: ({ column }) => ({ type: this.columnTypeResolver.getType(column)[0] }),
87
+ visitColumn: ({ column }) => ({
88
+ type: this.columnTypeResolver.getType(column)[0],
89
+ description: inputFieldDescription(column),
90
+ }),
85
91
  })
86
92
  }
87
93
  }
@@ -101,8 +107,14 @@ export class WhereTypeProvider {
101
107
  continue
102
108
  }
103
109
  fields[fieldName] = acceptFieldVisitor(this.schema, name, fieldName, {
104
- visitColumn: ({ column }) => ({ type: this.conditionTypeProvider.getCondition(column) }),
105
- visitRelation: ({ relation }) => ({ type: this.getEntityWhereType(relation.target) }),
110
+ visitColumn: ({ column }) => ({
111
+ type: this.conditionTypeProvider.getCondition(column),
112
+ description: inputFieldDescription(column),
113
+ }),
114
+ visitRelation: ({ relation }) => ({
115
+ type: this.getEntityWhereType(relation.target),
116
+ description: inputFieldDescription(relation),
117
+ }),
106
118
  } as Model.FieldVisitor<GraphQLInputFieldConfig>)
107
119
  }
108
120
 
@@ -0,0 +1,26 @@
1
+ const ISO_DATE_PREFIX_REGEX = /^(\d{4})-(\d{1,2})-(\d{1,2})(?!\d)/
2
+
3
+ // Over-matching only defers a value to PostgreSQL; `2025-02-29BC` has no word boundary before BC.
4
+ const BC_ERA_REGEX = /BC/i
5
+
6
+ const DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
7
+
8
+ const daysInMonth = (year: number, month: number): number => {
9
+ const isLeapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)
10
+ return month === 2 && isLeapYear ? 29 : DAYS_IN_MONTH[month - 1]
11
+ }
12
+
13
+ /**
14
+ * True for an ISO-shaped calendar date that does not exist (e.g. 2026-02-30, year 0000), which PostgreSQL would refuse.
15
+ * Other input formats PostgreSQL accepts, and BC dates, are left for PostgreSQL to judge.
16
+ */
17
+ export const isImpossibleCalendarDate = (value: string): boolean => {
18
+ const match = ISO_DATE_PREFIX_REGEX.exec(value)
19
+ if (!match || BC_ERA_REGEX.test(value)) {
20
+ return false
21
+ }
22
+ const year = Number(match[1])
23
+ const month = Number(match[2])
24
+ const day = Number(match[3])
25
+ return year === 0 || month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month)
26
+ }
@@ -1,5 +1,6 @@
1
1
  export * from './entities/index.js'
2
2
  export * from './mutations/index.js'
3
+ export * from './calendarDate.js'
3
4
  export * from './ColumnTypeResolver.js'
4
5
  export * from './ConditionTypeProvider.js'
5
6
  export * from './CustomTypesProvider.js'
@@ -1,5 +1,6 @@
1
1
  import { GraphQLInputFieldConfig, GraphQLList, GraphQLNonNull } from 'graphql'
2
2
  import { Acl, Model } from '@contember/schema'
3
+ import { inputFieldDescription } from '../utils.js'
3
4
  import { ColumnTypeResolver } from '../ColumnTypeResolver.js'
4
5
  import { CreateEntityRelationInputProvider } from './CreateEntityRelationInputProvider.js'
5
6
  import { Authorizator } from '../../acl/index.js'
@@ -22,7 +23,10 @@ export class CreateEntityInputFieldVisitor
22
23
  return undefined
23
24
  }
24
25
  const [type] = this.columnTypeResolver.getType(column)
25
- return { type }
26
+ return {
27
+ type,
28
+ description: inputFieldDescription(column),
29
+ }
26
30
  }
27
31
 
28
32
  public visitHasOne({ entity, relation }: Model.AnyHasOneRelationContext): GraphQLInputFieldConfig | undefined {
@@ -30,7 +34,10 @@ export class CreateEntityInputFieldVisitor
30
34
  if (type === undefined) {
31
35
  return undefined
32
36
  }
33
- return { type }
37
+ return {
38
+ type,
39
+ description: inputFieldDescription(relation),
40
+ }
34
41
  }
35
42
 
36
43
  public visitHasMany({ entity, relation }: Model.AnyHasManyRelationContext): GraphQLInputFieldConfig | undefined {
@@ -40,6 +47,7 @@ export class CreateEntityInputFieldVisitor
40
47
  }
41
48
  return {
42
49
  type: new GraphQLList(new GraphQLNonNull(type)),
50
+ description: inputFieldDescription(relation),
43
51
  }
44
52
  }
45
53
  }
@@ -1,5 +1,6 @@
1
1
  import { GraphQLInputFieldConfig, GraphQLList, GraphQLNonNull } from 'graphql'
2
2
  import { Acl, Model } from '@contember/schema'
3
+ import { inputFieldDescription } from '../utils.js'
3
4
  import { ColumnTypeResolver } from '../ColumnTypeResolver.js'
4
5
  import { UpdateEntityRelationInputProvider } from './UpdateEntityRelationInputProvider.js'
5
6
  import { Authorizator } from '../../acl/index.js'
@@ -21,7 +22,10 @@ export class UpdateEntityInputFieldVisitor
21
22
  return undefined
22
23
  }
23
24
  const [type] = this.columnTypeResolver.getType(column)
24
- return { type }
25
+ return {
26
+ type,
27
+ description: inputFieldDescription(column),
28
+ }
25
29
  }
26
30
 
27
31
  public visitHasOne({ entity, relation }: Model.AnyHasOneRelationContext) {
@@ -29,7 +33,10 @@ export class UpdateEntityInputFieldVisitor
29
33
  if (type === undefined) {
30
34
  return undefined
31
35
  }
32
- return { type }
36
+ return {
37
+ type,
38
+ description: inputFieldDescription(relation),
39
+ }
33
40
  }
34
41
 
35
42
  public visitHasMany({ entity, relation }: Model.AnyHasManyRelationContext) {
@@ -39,6 +46,7 @@ export class UpdateEntityInputFieldVisitor
39
46
  }
40
47
  return {
41
48
  type: new GraphQLList(new GraphQLNonNull(type)),
49
+ description: inputFieldDescription(relation),
42
50
  }
43
51
  }
44
52
  }