@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
@@ -32,6 +32,7 @@ class QueryProvider {
32
32
  }
33
33
  return {
34
34
  type: entityType,
35
+ deprecationReason: entity.deprecationReason,
35
36
  args: {
36
37
  by: {
37
38
  type: new graphql.GraphQLNonNull(uniqueWhere)
@@ -56,6 +57,7 @@ class QueryProvider {
56
57
  const entityType = this.entityTypeProvider.getEntity(entityName);
57
58
  return {
58
59
  type: new graphql.GraphQLNonNull(new graphql.GraphQLList(new graphql.GraphQLNonNull(entityType))),
60
+ deprecationReason: entity.deprecationReason,
59
61
  args: {
60
62
  filter: {
61
63
  type: this.whereTypeProvider.getEntityWhereType(entityName)
@@ -84,6 +86,7 @@ class QueryProvider {
84
86
  getPaginationQuery(entity) {
85
87
  return {
86
88
  ...this.paginatedFieldConfigFactory.createFieldConfig(entity),
89
+ deprecationReason: entity.deprecationReason,
87
90
  extensions: { [OperationExtension.ExtensionKey]: new OperationExtension.OperationMeta(OperationExtension.Operation.paginate, entity) },
88
91
  resolve: (parent, args, context, info) => {
89
92
  return context.timer(`GraphQL.query.${info.fieldName}`, () => {
@@ -1 +1 @@
1
- {"version":3,"file":"QueryProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/QueryProvider.ts"],"sourcesContent":["import { GraphQLFieldConfig, GraphQLInt, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { Context } from '../types.js'\nimport { EntityTypeProvider } from './EntityTypeProvider.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { OrderByTypeProvider } from './OrderByTypeProvider.js'\nimport { ExtensionKey, Operation, OperationMeta } from './OperationExtension.js'\nimport { ImplementationException } from '../exception.js'\nimport { PaginatedFieldConfigFactory } from './PaginatedFieldConfigFactory.js'\n\nexport class QueryProvider {\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly orderByTypeProvider: OrderByTypeProvider,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly paginatedFieldConfigFactory: PaginatedFieldConfigFactory,\n\t) {}\n\n\tpublic getQueries(entity: Model.Entity): { [fieldName: string]: GraphQLFieldConfig<any, Context, any> } {\n\t\t// Root entry points are gated on the root grants alone; `through` grants exist to apply only\n\t\t// when the entity is reached over a relation, so they must not open a root query.\n\t\tif (this.rootAuthorizator.getEntityPermission(Acl.Operation.read, entity.name) === 'no') {\n\t\t\treturn {}\n\t\t}\n\t\treturn {\n\t\t\t['get' + entity.name]: this.getByUniqueQuery(entity),\n\t\t\t['list' + entity.name]: this.getListQuery(entity),\n\t\t\t['paginate' + entity.name]: this.getPaginationQuery(entity),\n\t\t}\n\t}\n\n\tprivate getByUniqueQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.UniqueQueryInput> {\n\t\tconst entityName = entity.name\n\t\tconst entityType = this.entityTypeProvider.getEntity(entityName)\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn {\n\t\t\ttype: entityType,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.get, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolveGetQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getListQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.ListQueryInput> {\n\t\tconst entityName = entity.name\n\n\t\tconst entityType = this.entityTypeProvider.getEntity(entityName)\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(entityType))),\n\t\t\targs: {\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\torderBy: {\n\t\t\t\t\ttype: new GraphQLList(new GraphQLNonNull(this.orderByTypeProvider.getEntityOrderByType(entityName))),\n\t\t\t\t},\n\t\t\t\toffset: {\n\t\t\t\t\ttype: GraphQLInt,\n\t\t\t\t},\n\t\t\t\tlimit: {\n\t\t\t\t\ttype: GraphQLInt,\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.list, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolveListQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getPaginationQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.ListQueryInput> {\n\t\treturn {\n\t\t\t...this.paginatedFieldConfigFactory.createFieldConfig(entity),\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.paginate, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolvePaginationQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":["Acl","ImplementationException","GraphQLNonNull","ExtensionKey","OperationMeta","Operation","GraphQLList","GraphQLInt"],"mappings":";;;;;;AAWO,MAAM,cAAc;AAAA,EAC1B,YACkB,cACA,kBACA,mBACA,qBACA,oBACA,6BAChB;AANgB,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,oBAAA;AACA,SAAA,sBAAA;AACA,SAAA,qBAAA;AACA,SAAA,8BAAA;AAAA,EACf;AAAA,EAEI,WAAW,QAAsF;AAGvG,QAAI,KAAK,iBAAiB,oBAAoBA,OAAAA,IAAI,UAAU,MAAM,OAAO,IAAI,MAAM,MAAM;AACxF,aAAO,CAAA;AAAA,IACR;AACA,WAAO;AAAA,MACN,CAAC,QAAQ,OAAO,IAAI,GAAG,KAAK,iBAAiB,MAAM;AAAA,MACnD,CAAC,SAAS,OAAO,IAAI,GAAG,KAAK,aAAa,MAAM;AAAA,MAChD,CAAC,aAAa,OAAO,IAAI,GAAG,KAAK,mBAAmB,MAAM;AAAA,IAAA;AAAA,EAE5D;AAAA,EAEQ,iBAAiB,QAAgF;AACxG,UAAM,aAAa,OAAO;AAC1B,UAAM,aAAa,KAAK,mBAAmB,UAAU,UAAU;AAC/D,UAAM,cAAc,KAAK,kBAAkB,yBAAyB,UAAU;AAC9E,QAAI,CAAC,aAAa;AACjB,YAAM,IAAIC,UAAAA,wBAAA;AAAA,IACX;AACA,WAAO;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,QACL,IAAI;AAAA,UACH,MAAM,IAAIC,QAAAA,eAAe,WAAW;AAAA,QAAA;AAAA,QAErC,QAAQ;AAAA,UACP,MAAM,KAAK,kBAAkB,mBAAmB,UAAU;AAAA,QAAA;AAAA,MAC3D;AAAA,MAED,YAAY,EAAE,CAACC,+BAAY,GAAG,IAAIC,mBAAAA,cAAcC,6BAAU,KAAK,M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AAA,IAAA;AAAA,EAEF;AAAA,EAEQ,mBAAmB,QAA8E;AACxG,WAAO;AAAA,MACN,GAAG,KAAK,4BAA4B,kBAAkB,MAAM;AAAA,MAC5D,YAAY,EAAE,CAACF,+BAAY,GAAG,IAAIC,mBAAAA,cAAcC,6BAAU,UAAU,MAAM,EAAA;AAAA,MAC1E,SAAS,CAAC,QAAQ,MAAM,SAAS,SAAS;AACzC,eAAO,QAAQ,MAAM,iBAAiB,KAAK,SAAS,IAAI,MAAM;AAC7D,cAAI,UAAU,KAAK,MAAM;AACxB,mBAAO,OAAO,KAAK,KAAK,GAAG;AAAA,UAC5B;AACA,iBAAO,QAAQ,mBAAmB,aAAa,uBAAuB,QAAQ,IAAI;AAAA,QACnF,CAAC;AAAA,MACF;AAAA,IAAA;AAAA,EAEF;AACD;;"}
1
+ {"version":3,"file":"QueryProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/QueryProvider.ts"],"sourcesContent":["import { GraphQLFieldConfig, GraphQLInt, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { Context } from '../types.js'\nimport { EntityTypeProvider } from './EntityTypeProvider.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { OrderByTypeProvider } from './OrderByTypeProvider.js'\nimport { ExtensionKey, Operation, OperationMeta } from './OperationExtension.js'\nimport { ImplementationException } from '../exception.js'\nimport { PaginatedFieldConfigFactory } from './PaginatedFieldConfigFactory.js'\n\nexport class QueryProvider {\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly orderByTypeProvider: OrderByTypeProvider,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly paginatedFieldConfigFactory: PaginatedFieldConfigFactory,\n\t) {}\n\n\tpublic getQueries(entity: Model.Entity): { [fieldName: string]: GraphQLFieldConfig<any, Context, any> } {\n\t\t// Root entry points are gated on the root grants alone; `through` grants exist to apply only\n\t\t// when the entity is reached over a relation, so they must not open a root query.\n\t\tif (this.rootAuthorizator.getEntityPermission(Acl.Operation.read, entity.name) === 'no') {\n\t\t\treturn {}\n\t\t}\n\t\treturn {\n\t\t\t['get' + entity.name]: this.getByUniqueQuery(entity),\n\t\t\t['list' + entity.name]: this.getListQuery(entity),\n\t\t\t['paginate' + entity.name]: this.getPaginationQuery(entity),\n\t\t}\n\t}\n\n\tprivate getByUniqueQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.UniqueQueryInput> {\n\t\tconst entityName = entity.name\n\t\tconst entityType = this.entityTypeProvider.getEntity(entityName)\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn {\n\t\t\ttype: entityType,\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.get, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolveGetQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getListQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.ListQueryInput> {\n\t\tconst entityName = entity.name\n\n\t\tconst entityType = this.entityTypeProvider.getEntity(entityName)\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(entityType))),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\torderBy: {\n\t\t\t\t\ttype: new GraphQLList(new GraphQLNonNull(this.orderByTypeProvider.getEntityOrderByType(entityName))),\n\t\t\t\t},\n\t\t\t\toffset: {\n\t\t\t\t\ttype: GraphQLInt,\n\t\t\t\t},\n\t\t\t\tlimit: {\n\t\t\t\t\ttype: GraphQLInt,\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.list, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolveListQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getPaginationQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.ListQueryInput> {\n\t\treturn {\n\t\t\t...this.paginatedFieldConfigFactory.createFieldConfig(entity),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.paginate, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolvePaginationQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":["Acl","ImplementationException","GraphQLNonNull","ExtensionKey","OperationMeta","Operation","GraphQLList","GraphQLInt"],"mappings":";;;;;;AAWO,MAAM,cAA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O;AAAA,MAC1B,YAAY,EAAE,CAACF,+BAAY,GAAG,IAAIC,mBAAAA,cAAcC,6BAAU,UAAU,MAAM,EAAA;AAAA,MAC1E,SAAS,CAAC,QAAQ,MAAM,SAAS,SAAS;AACzC,eAAO,QAAQ,MAAM,iBAAiB,KAAK,SAAS,IAAI,MAAM;AAC7D,cAAI,UAAU,KAAK,MAAM;AACxB,mBAAO,OAAO,KAAK,KAAK,GAAG;AAAA,UAC5B;AACA,iBAAO,QAAQ,mBAAmB,aAAa,uBAAuB,QAAQ,IAAI;AAAA,QACnF,CAAC;AAAA,MACF;AAAA,IAAA;AAAA,EAEF;AACD;;"}
@@ -30,6 +30,7 @@ class QueryProvider {
30
30
  }
31
31
  return {
32
32
  type: entityType,
33
+ deprecationReason: entity.deprecationReason,
33
34
  args: {
34
35
  by: {
35
36
  type: new GraphQLNonNull(uniqueWhere)
@@ -54,6 +55,7 @@ class QueryProvider {
54
55
  const entityType = this.entityTypeProvider.getEntity(entityName);
55
56
  return {
56
57
  type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(entityType))),
58
+ deprecationReason: entity.deprecationReason,
57
59
  args: {
58
60
  filter: {
59
61
  type: this.whereTypeProvider.getEntityWhereType(entityName)
@@ -82,6 +84,7 @@ class QueryProvider {
82
84
  getPaginationQuery(entity) {
83
85
  return {
84
86
  ...this.paginatedFieldConfigFactory.createFieldConfig(entity),
87
+ deprecationReason: entity.deprecationReason,
85
88
  extensions: { [ExtensionKey]: new OperationMeta(Operation.paginate, entity) },
86
89
  resolve: (parent, args, context, info) => {
87
90
  return context.timer(`GraphQL.query.${info.fieldName}`, () => {
@@ -1 +1 @@
1
- {"version":3,"file":"QueryProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/QueryProvider.ts"],"sourcesContent":["import { GraphQLFieldConfig, GraphQLInt, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { Context } from '../types.js'\nimport { EntityTypeProvider } from './EntityTypeProvider.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { OrderByTypeProvider } from './OrderByTypeProvider.js'\nimport { ExtensionKey, Operation, OperationMeta } from './OperationExtension.js'\nimport { ImplementationException } from '../exception.js'\nimport { PaginatedFieldConfigFactory } from './PaginatedFieldConfigFactory.js'\n\nexport class QueryProvider {\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly orderByTypeProvider: OrderByTypeProvider,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly paginatedFieldConfigFactory: PaginatedFieldConfigFactory,\n\t) {}\n\n\tpublic getQueries(entity: Model.Entity): { [fieldName: string]: GraphQLFieldConfig<any, Context, any> } {\n\t\t// Root entry points are gated on the root grants alone; `through` grants exist to apply only\n\t\t// when the entity is reached over a relation, so they must not open a root query.\n\t\tif (this.rootAuthorizator.getEntityPermission(Acl.Operation.read, entity.name) === 'no') {\n\t\t\treturn {}\n\t\t}\n\t\treturn {\n\t\t\t['get' + entity.name]: this.getByUniqueQuery(entity),\n\t\t\t['list' + entity.name]: this.getListQuery(entity),\n\t\t\t['paginate' + entity.name]: this.getPaginationQuery(entity),\n\t\t}\n\t}\n\n\tprivate getByUniqueQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.UniqueQueryInput> {\n\t\tconst entityName = entity.name\n\t\tconst entityType = this.entityTypeProvider.getEntity(entityName)\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn {\n\t\t\ttype: entityType,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.get, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolveGetQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getListQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.ListQueryInput> {\n\t\tconst entityName = entity.name\n\n\t\tconst entityType = this.entityTypeProvider.getEntity(entityName)\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(entityType))),\n\t\t\targs: {\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\torderBy: {\n\t\t\t\t\ttype: new GraphQLList(new GraphQLNonNull(this.orderByTypeProvider.getEntityOrderByType(entityName))),\n\t\t\t\t},\n\t\t\t\toffset: {\n\t\t\t\t\ttype: GraphQLInt,\n\t\t\t\t},\n\t\t\t\tlimit: {\n\t\t\t\t\ttype: GraphQLInt,\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.list, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolveListQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getPaginationQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.ListQueryInput> {\n\t\treturn {\n\t\t\t...this.paginatedFieldConfigFactory.createFieldConfig(entity),\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.paginate, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolvePaginationQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;AAWO,MAAM,cAAc;AAAA,EAC1B,YACkB,cACA,kBACA,mBACA,qBACA,oBACA,6BAChB;AANgB,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,oBAAA;AACA,SAAA,sBAAA;AACA,SAAA,qBAAA;AACA,SAAA,8BAAA;AAAA,EACf;AAAA,EAEI,WAAW,QAAsF;AAGvG,QAAI,KAAK,iBAAiB,oBAAoB,IAAI,UAAU,MAAM,OAAO,IAAI,MAAM,MAAM;AACxF,aAAO,CAAA;AAAA,IACR;AACA,WAAO;AAAA,MACN,CAAC,QAAQ,OAAO,IAAI,GAAG,KAAK,iBAAiB,MAAM;AAAA,MACnD,CAAC,SAAS,OAAO,IAAI,GAAG,KAAK,aAAa,MAAM;AAAA,MAChD,CAAC,aAAa,OAAO,IAAI,GAAG,KAAK,mBAAmB,MAAM;AAAA,IAAA;AAAA,EAE5D;AAAA,EAEQ,iBAAiB,QAAgF;AACxG,UAAM,aAAa,OAAO;AAC1B,UAAM,aAAa,KAAK,mBAAmB,UAAU,UAAU;AAC/D,UAAM,cAAc,KAAK,kBAAkB,yBAAyB,UAAU;AAC9E,QAAI,CAAC,aAAa;AACjB,YAAM,IAAI,wBAAA;AAAA,IACX;AACA,WAAO;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,QACL,IAAI;AAAA,UACH,MAAM,IAAI,eAAe,WAAW;AAAA,QAAA;AAAA,QAErC,QAAQ;AAAA,UACP,MAAM,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QAAQ,IAAI;AAAA,QAC7E,CAAC;AAAA,MACF;AAAA,IAAA;AAAA,EAEF;AAAA,EAEQ,mBAAmB,QAA8E;AACxG,WAAO;AAAA,MACN,GAAG,KAAK,4BAA4B,kBAAkB,MAAM;AAAA,MAC5D,YAAY,EAAE,CAAC,YAAY,GAAG,IAAI,cAAc,UAAU,UAAU,MAAM,EAAA;AAAA,MAC1E,SAAS,CAAC,QAAQ,MAAM,SAAS,SAAS;AACzC,eAAO,QAAQ,MAAM,iBAAiB,KAAK,SAAS,IAAI,MAAM;AAC7D,cAAI,UAAU,KAAK,MAAM;AACxB,mBAAO,OAAO,KAAK,KAAK,GAAG;AAAA,UAC5B;AACA,iBAAO,QAAQ,mBAAmB,aAAa,uBAAuB,QAAQ,IAAI;AAAA,QACnF,CAAC;AAAA,MACF;AAAA,IAAA;AAAA,EAEF;AACD;"}
1
+ {"version":3,"file":"QueryProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/QueryProvider.ts"],"sourcesContent":["import { GraphQLFieldConfig, GraphQLInt, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { Context } from '../types.js'\nimport { EntityTypeProvider } from './EntityTypeProvider.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { OrderByTypeProvider } from './OrderByTypeProvider.js'\nimport { ExtensionKey, Operation, OperationMeta } from './OperationExtension.js'\nimport { ImplementationException } from '../exception.js'\nimport { PaginatedFieldConfigFactory } from './PaginatedFieldConfigFactory.js'\n\nexport class QueryProvider {\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly orderByTypeProvider: OrderByTypeProvider,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly paginatedFieldConfigFactory: PaginatedFieldConfigFactory,\n\t) {}\n\n\tpublic getQueries(entity: Model.Entity): { [fieldName: string]: GraphQLFieldConfig<any, Context, any> } {\n\t\t// Root entry points are gated on the root grants alone; `through` grants exist to apply only\n\t\t// when the entity is reached over a relation, so they must not open a root query.\n\t\tif (this.rootAuthorizator.getEntityPermission(Acl.Operation.read, entity.name) === 'no') {\n\t\t\treturn {}\n\t\t}\n\t\treturn {\n\t\t\t['get' + entity.name]: this.getByUniqueQuery(entity),\n\t\t\t['list' + entity.name]: this.getListQuery(entity),\n\t\t\t['paginate' + entity.name]: this.getPaginationQuery(entity),\n\t\t}\n\t}\n\n\tprivate getByUniqueQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.UniqueQueryInput> {\n\t\tconst entityName = entity.name\n\t\tconst entityType = this.entityTypeProvider.getEntity(entityName)\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn {\n\t\t\ttype: entityType,\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.get, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolveGetQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getListQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.ListQueryInput> {\n\t\tconst entityName = entity.name\n\n\t\tconst entityType = this.entityTypeProvider.getEntity(entityName)\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(entityType))),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\torderBy: {\n\t\t\t\t\ttype: new GraphQLList(new GraphQLNonNull(this.orderByTypeProvider.getEntityOrderByType(entityName))),\n\t\t\t\t},\n\t\t\t\toffset: {\n\t\t\t\t\ttype: GraphQLInt,\n\t\t\t\t},\n\t\t\t\tlimit: {\n\t\t\t\t\ttype: GraphQLInt,\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.list, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolveListQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getPaginationQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.ListQueryInput> {\n\t\treturn {\n\t\t\t...this.paginatedFieldConfigFactory.createFieldConfig(entity),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.paginate, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolvePaginationQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;AAWO,MAAM,cAAc;AAAA,EAC1B,YACkB,cACA,kBACA,mBACA,qB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M,iBAAiB,KAAK,SAAS,IAAI,MAAM;AAC7D,cAAI,UAAU,KAAK,MAAM;AACxB,mBAAO,OAAO,KAAK,KAAK,GAAG;AAAA,UAC5B;AACA,iBAAO,QAAQ,mBAAmB,aAAa,uBAAuB,QAAQ,IAAI;AAAA,QACnF,CAAC;AAAA,MACF;AAAA,IAAA;AAAA,EAEF;AACD;"}
@@ -25,6 +25,7 @@ class ValidationQueriesProvider {
25
25
  }
26
26
  return {
27
27
  type: new graphql.GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),
28
+ deprecationReason: entity.deprecationReason,
28
29
  args: {
29
30
  data: { type: new graphql.GraphQLNonNull(dataType) }
30
31
  },
@@ -43,6 +44,7 @@ class ValidationQueriesProvider {
43
44
  }
44
45
  return {
45
46
  type: new graphql.GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),
47
+ deprecationReason: entity.deprecationReason,
46
48
  args: {
47
49
  by: {
48
50
  type: new graphql.GraphQLNonNull(uniqueWhere)
@@ -1 +1 @@
1
- {"version":3,"file":"ValidationQueriesProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/ValidationQueriesProvider.ts"],"sourcesContent":["import { GraphQLFieldConfig, GraphQLNonNull } from 'graphql'\nimport { Context } from '../types.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { EntityInputProvider, EntityInputType } from './mutations/index.js'\nimport { Input, Model } from '@contember/schema'\nimport { filterObject } from '../utils/index.js'\nimport { ResultSchemaTypeProvider } from './ResultSchemaTypeProvider.js'\n\ntype FieldConfig<TArgs> = GraphQLFieldConfig<Context, any, TArgs>\n\nexport class ValidationQueriesProvider {\n\tconstructor(\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly createEntityInputProvider: EntityInputProvider<EntityInputType.create>,\n\t\tprivate readonly updateEntityInputProvider: EntityInputProvider<EntityInputType.update>,\n\t\tprivate readonly resultSchemaTypeProvider: ResultSchemaTypeProvider,\n\t) {}\n\n\tpublic getQueries(entity: Model.Entity): { [fieldName: string]: FieldConfig<any> } {\n\t\tconst entityName = entity.name\n\t\tconst validations: { [fieldName: string]: FieldConfig<any> | undefined } = {}\n\t\tvalidations[`validateCreate${entityName}`] = this.getValidateCreateQuery(entity)\n\t\tvalidations[`validateUpdate${entityName}`] = this.getValidateUpdateQuery(entity)\n\n\t\treturn filterObject(validations, (key, value): value is FieldConfig<any> => value !== undefined)\n\t}\n\n\tprivate getValidateCreateQuery(entity: Model.Entity): FieldConfig<Input.CreateInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.createEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\targs: {\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\tresolve: (parent, args, context: Context, info) =>\n\t\t\t\tcontext.timer(`GraphQL.query.${info.fieldName}`, () => context.executionContainer.validationResolver.validateCreate(entity, args)),\n\t\t}\n\t}\n\n\tprivate getValidateUpdateQuery(entity: Model.Entity): FieldConfig<Input.UpdateInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\tresolve: (parent, args, context: Context, info) =>\n\t\t\t\tcontext.timer(`GraphQL.query.${info.fieldName}`, () => context.executionContainer.validationResolver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AO;AAAA,MACN,MAAM,IAAIA,QAAAA,eAAe,KAAK,yBAAyB,oBAAoB;AAAA,MAC3E,MAAM;AAAA,QACL,IAAI;AAAA,UACH,MAAM,IAAIA,QAAAA,eAAe,WAAW;AAAA,QAAA;AAAA,QAErC,MAAM,EAAE,MAAM,IAAIA,QAAAA,eAAe,QAAQ,EAAA;AAAA,MAAE;AAAA,MAE5C,SAAS,CAAC,QAAQ,MAAM,SAAkB,SACzC,QAAQ,MAAM,iBAAiB,KAAK,SAAS,IAAI,MAAM,QAAQ,mBAAmB,mBAAmB,eAAe,QAAQ,IAAI,CAAC;AAAA,IAAA;AAAA,EAEpI;AACD;;"}
1
+ {"version":3,"file":"ValidationQueriesProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/ValidationQueriesProvider.ts"],"sourcesContent":["import { GraphQLFieldConfig, GraphQLNonNull } from 'graphql'\nimport { Context } from '../types.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { EntityInputProvider, EntityInputType } from './mutations/index.js'\nimport { Input, Model } from '@contember/schema'\nimport { filterObject } from '../utils/index.js'\nimport { ResultSchemaTypeProvider } from './ResultSchemaTypeProvider.js'\n\ntype FieldConfig<TArgs> = GraphQLFieldConfig<Context, any, TArgs>\n\nexport class ValidationQueriesProvider {\n\tconstructor(\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly createEntityInputProvider: EntityInputProvider<EntityInputType.create>,\n\t\tprivate readonly updateEntityInputProvider: EntityInputProvider<EntityInputType.update>,\n\t\tprivate readonly resultSchemaTypeProvider: ResultSchemaTypeProvider,\n\t) {}\n\n\tpublic getQueries(entity: Model.Entity): { [fieldName: string]: FieldConfig<any> } {\n\t\tconst entityName = entity.name\n\t\tconst validations: { [fieldName: string]: FieldConfig<any> | undefined } = {}\n\t\tvalidations[`validateCreate${entityName}`] = this.getValidateCreateQuery(entity)\n\t\tvalidations[`validateUpdate${entityName}`] = this.getValidateUpdateQuery(entity)\n\n\t\treturn filterObject(validations, (key, value): value is FieldConfig<any> => value !== undefined)\n\t}\n\n\tprivate getValidateCreateQuery(entity: Model.Entity): FieldConfig<Input.CreateInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.createEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\tresolve: (parent, args, context: Context, info) =>\n\t\t\t\tcontext.timer(`GraphQL.query.${info.fieldName}`, () => context.executionContainer.validationResolver.validateCreate(entity, args)),\n\t\t}\n\t}\n\n\tprivate getValidateUpdateQuery(entity: Model.Entity): FieldConfig<Input.UpdateInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\tresolve: (parent, args, context: Context, info) =>\n\t\t\t\tcontext.timer(`GraphQL.query.${info.fieldName}`, () => context.executionContainer.validationResolver.validateUpdate(entity, args)),\n\t\t}\n\t}\n}\n"],"names":["filterObject","GraphQLNonNull"],"mappings":";;;;;AAUO,MAAM,0BAA0B;AAAA,EACtC,YACkB,mBACA,2BACA,2BACA,0BAChB;AAJgB,SAAA,o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;AAAA,UACH,MAAM,IAAIA,QAAAA,eAAe,WAAW;AAAA,QAAA;AAAA,QAErC,MAAM,EAAE,MAAM,IAAIA,QAAAA,eAAe,QAAQ,EAAA;AAAA,MAAE;AAAA,MAE5C,SAAS,CAAC,QAAQ,MAAM,SAAkB,SACzC,QAAQ,MAAM,iBAAiB,KAAK,SAAS,IAAI,MAAM,QAAQ,mBAAmB,mBAAmB,eAAe,QAAQ,IAAI,CAAC;AAAA,IAAA;AAAA,EAEpI;AACD;;"}
@@ -23,6 +23,7 @@ class ValidationQueriesProvider {
23
23
  }
24
24
  return {
25
25
  type: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),
26
+ deprecationReason: entity.deprecationReason,
26
27
  args: {
27
28
  data: { type: new GraphQLNonNull(dataType) }
28
29
  },
@@ -41,6 +42,7 @@ class ValidationQueriesProvider {
41
42
  }
42
43
  return {
43
44
  type: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),
45
+ deprecationReason: entity.deprecationReason,
44
46
  args: {
45
47
  by: {
46
48
  type: new GraphQLNonNull(uniqueWhere)
@@ -1 +1 @@
1
- {"version":3,"file":"ValidationQueriesProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/ValidationQueriesProvider.ts"],"sourcesContent":["import { GraphQLFieldConfig, GraphQLNonNull } from 'graphql'\nimport { Context } from '../types.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { EntityInputProvider, EntityInputType } from './mutations/index.js'\nimport { Input, Model } from '@contember/schema'\nimport { filterObject } from '../utils/index.js'\nimport { ResultSchemaTypeProvider } from './ResultSchemaTypeProvider.js'\n\ntype FieldConfig<TArgs> = GraphQLFieldConfig<Context, any, TArgs>\n\nexport class ValidationQueriesProvider {\n\tconstructor(\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly createEntityInputProvider: EntityInputProvider<EntityInputType.create>,\n\t\tprivate readonly updateEntityInputProvider: EntityInputProvider<EntityInputType.update>,\n\t\tprivate readonly resultSchemaTypeProvider: ResultSchemaTypeProvider,\n\t) {}\n\n\tpublic getQueries(entity: Model.Entity): { [fieldName: string]: FieldConfig<any> } {\n\t\tconst entityName = entity.name\n\t\tconst validations: { [fieldName: string]: FieldConfig<any> | undefined } = {}\n\t\tvalidations[`validateCreate${entityName}`] = this.getValidateCreateQuery(entity)\n\t\tvalidations[`validateUpdate${entityName}`] = this.getValidateUpdateQuery(entity)\n\n\t\treturn filterObject(validations, (key, value): value is FieldConfig<any> => value !== undefined)\n\t}\n\n\tprivate getValidateCreateQuery(entity: Model.Entity): FieldConfig<Input.CreateInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.createEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\targs: {\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\tresolve: (parent, args, context: Context, info) =>\n\t\t\t\tcontext.timer(`GraphQL.query.${info.fieldName}`, () => context.executionContainer.validationResolver.validateCreate(entity, args)),\n\t\t}\n\t}\n\n\tprivate getValidateUpdateQuery(entity: Model.Entity): FieldConfig<Input.UpdateInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\tresolve: (parent, args, context: Context, info) =>\n\t\t\t\tcontext.timer(`GraphQL.query.${info.fieldName}`, () => context.executionContainer.validationResolver.validateUpdate(entity, args)),\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;AAUO,MAAM,0BAA0B;AAAA,EACtC,YACkB,mBACA,2BACA,2BACA,0BAChB;AAJgB,SAAA,oBAAA;AACA,SAAA,4BAAA;AACA,SAAA,4BAAA;AACA,SAAA,2BAAA;AAAA,EACf;AAAA,EAEI,WAAW,QAAiE;AAClF,UAAM,aAAa,OAAO;AAC1B,UAAM,cAAqE,CAAA;AAC3E,gBAAY,iBAAiB,UAAU,EAAE,IAAI,KAAK,uBAAuB,MAAM;AAC/E,gBAAY,iBAAiB,UAAU,EAAE,IAAI,KAAK,uBAAuB,MAAM;AAE/E,WAAO,aAAa,aAAa,CAAC,KAAK,UAAqC,UAAU,MAAS;AAAA,EAChG;AAAA,EAEQ,uBAAuB,QAAkE;AAChG,UAAM,aAAa,OAAO;AAC1B,UAAM,WAAW,KAAK,0BAA0B,SAAS,UAAU;AACnE,QAAI,aAAa,QAAW;AAC3B,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN,MAAM,IAAI,eAAe,KAAK,yBAAyB,oBAAoB;AAAA,MAC3E,MAAM;AAAA,QACL,MAAM,EAAE,MAAM,IAAI,eAAe,QAAQ,EAAA;AAAA,MAAE;AAAA,MAE5C,SAAS,CAAC,QAAQ,MAAM,SAAkB,SACzC,QAAQ,MAAM,iBAAiB,KAAK,SAAS,IAAI,MAAM,QAAQ,mBAAmB,mBAAmB,eAAe,QAAQ,IAAI,CAAC;AAAA,IAAA;AAAA,EAEpI;AAAA,EAEQ,uBAAuB,QAAkE;AAChG,UAAM,aAAa,OAAO;AAC1B,UAAM,WAAW,KAAK,0BAA0B,SAAS,UAAU;AACnE,QAAI,aAAa,QAAW;AAC3B,aAAO;AAAA,IACR;AACA,UAAM,cAAc,KAAK,kBAAkB,yBAAyB,UAAU;AAC9E,QAAI,CAAC,aAAa;AACjB,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN,MAAM,IAAI,eAAe,KAAK,yBAAyB,oBAAoB;AAAA,MAC3E,MAAM;AAAA,QACL,IAAI;AAAA,UACH,MAAM,IAAI,eAAe,WAAW;AAAA,QAAA;AAAA,QAErC,MAAM,EAAE,MAAM,IAAI,eAAe,QAAQ,EAAA;AAAA,MAAE;AAAA,MAE5C,SAAS,CAAC,QAAQ,MAAM,SAAkB,SACzC,QAAQ,MAAM,iBAAiB,KAAK,SAAS,IAAI,MAAM,QAAQ,mBAAmB,mBAAmB,eAAe,QAAQ,IAAI,CAAC;AAAA,IAAA;AAAA,EAEpI;AACD;"}
1
+ {"version":3,"file":"ValidationQueriesProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/ValidationQueriesProvider.ts"],"sourcesContent":["import { GraphQLFieldConfig, GraphQLNonNull } from 'graphql'\nimport { Context } from '../types.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { EntityInputProvider, EntityInputType } from './mutations/index.js'\nimport { Input, Model } from '@contember/schema'\nimport { filterObject } from '../utils/index.js'\nimport { ResultSchemaTypeProvider } from './ResultSchemaTypeProvider.js'\n\ntype FieldConfig<TArgs> = GraphQLFieldConfig<Context, any, TArgs>\n\nexport class ValidationQueriesProvider {\n\tconstructor(\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly createEntityInputProvider: EntityInputProvider<EntityInputType.create>,\n\t\tprivate readonly updateEntityInputProvider: EntityInputProvider<EntityInputType.update>,\n\t\tprivate readonly resultSchemaTypeProvider: ResultSchemaTypeProvider,\n\t) {}\n\n\tpublic getQueries(entity: Model.Entity): { [fieldName: string]: FieldConfig<any> } {\n\t\tconst entityName = entity.name\n\t\tconst validations: { [fieldName: string]: FieldConfig<any> | undefined } = {}\n\t\tvalidations[`validateCreate${entityName}`] = this.getValidateCreateQuery(entity)\n\t\tvalidations[`validateUpdate${entityName}`] = this.getValidateUpdateQuery(entity)\n\n\t\treturn filterObject(validations, (key, value): value is FieldConfig<any> => value !== undefined)\n\t}\n\n\tprivate getValidateCreateQuery(entity: Model.Entity): FieldConfig<Input.CreateInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.createEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\tresolve: (parent, args, context: Context, info) =>\n\t\t\t\tcontext.timer(`GraphQL.query.${info.fieldName}`, () => context.executionContainer.validationResolver.validateCreate(entity, args)),\n\t\t}\n\t}\n\n\tprivate getValidateUpdateQuery(entity: Model.Entity): FieldConfig<Input.UpdateInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\tresolve: (parent, args, context: Context, info) =>\n\t\t\t\tcontext.timer(`GraphQL.query.${info.fieldName}`, () => context.executionContainer.validationResolver.validateUpdate(entity, args)),\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;AAUO,MAAM,0BAA0B;AAAA,EACtC,YACkB,mBACA,2BACA,2BACA,0BAChB;AAJgB,SAAA,oBAAA;AACA,SAAA,4BAAA;AACA,SAAA,4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E,MAAM,IAAI,eAAe,QAAQ,EAAA;AAAA,MAAE;AAAA,MAE5C,SAAS,CAAC,QAAQ,MAAM,SAAkB,SACzC,QAAQ,MAAM,iBAAiB,KAAK,SAAS,IAAI,MAAM,QAAQ,mBAAmB,mBAAmB,eAAe,QAAQ,IAAI,CAAC;AAAA,IAAA;AAAA,EAEpI;AACD;"}
@@ -64,14 +64,20 @@ class WhereTypeProvider {
64
64
  continue;
65
65
  }
66
66
  fields[field] = schemaUtils.acceptFieldVisitor(this.schema, entity, field, {
67
- visitRelation: ({ targetEntity }) => {
67
+ visitRelation: ({ relation, targetEntity }) => {
68
68
  const uniqueWhere = this.getEntityUniqueWhereType(targetEntity.name);
69
69
  if (!uniqueWhere) {
70
70
  throw new exception.ImplementationException();
71
71
  }
72
- return { type: uniqueWhere };
72
+ return {
73
+ type: uniqueWhere,
74
+ description: utils.inputFieldDescription(relation)
75
+ };
73
76
  },
74
- visitColumn: ({ column }) => ({ type: this.columnTypeResolver.getType(column)[0] })
77
+ visitColumn: ({ column }) => ({
78
+ type: this.columnTypeResolver.getType(column)[0],
79
+ description: utils.inputFieldDescription(column)
80
+ })
75
81
  });
76
82
  }
77
83
  }
@@ -89,8 +95,14 @@ class WhereTypeProvider {
89
95
  continue;
90
96
  }
91
97
  fields[fieldName] = schemaUtils.acceptFieldVisitor(this.schema, name, fieldName, {
92
- visitColumn: ({ column }) => ({ type: this.conditionTypeProvider.getCondition(column) }),
93
- visitRelation: ({ relation }) => ({ type: this.getEntityWhereType(relation.target) })
98
+ visitColumn: ({ column }) => ({
99
+ type: this.conditionTypeProvider.getCondition(column),
100
+ description: utils.inputFieldDescription(column)
101
+ }),
102
+ visitRelation: ({ relation }) => ({
103
+ type: this.getEntityWhereType(relation.target),
104
+ description: utils.inputFieldDescription(relation)
105
+ })
94
106
  });
95
107
  }
96
108
  fields.and = { type: new graphql.GraphQLList(where) };
@@ -1 +1 @@
1
- {"version":3,"file":"WhereTypeProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/WhereTypeProvider.ts"],"sourcesContent":["import { Acl, Model } from '@contember/schema'\nimport { acceptFieldVisitor, getEntity } from '@contember/schema-utils'\nimport { GraphQLInputFieldConfig, GraphQLInputFieldConfigMap, GraphQLInputObjectType, GraphQLList } from 'graphql'\nimport { capitalizeFirstLetter, getFieldsForUniqueWhere, singletonFactory } from '../utils/index.js'\nimport { ColumnTypeResolver } from './ColumnTypeResolver.js'\nimport { ConditionTypeProvider } from './ConditionTypeProvider.js'\nimport { GqlTypeName } from './utils.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\nimport { ImplementationException } from '../exception.js'\n\nexport class WhereTypeProvider {\n\tprivate whereSingleton = singletonFactory(name => this.createEntityWhereType(name))\n\tprivate uniqueWhereSingleton = singletonFactory(name => this.createEntityUniqueWhereType(name))\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly conditionTypeProvider: ConditionTypeProvider,\n\t) {}\n\n\tpublic getEntityWhereType(entityName: string): GraphQLInputObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.whereSingleton(entityName)\n\t}\n\n\tpublic getEntityUniqueWhereType(entityName: string): undefined | GraphQLInputObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\treturn this.uniqueWhereSingleton(entityName)\n\t}\n\n\tprivate createEntityWhereType(entityName: string) {\n\t\tconst where: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entityName}Where`,\n\t\t\tfields: () => this.getEntityWhereFields(entityName, where),\n\t\t})\n\n\t\treturn where\n\t}\n\n\tprivate createEntityUniqueWhereType(entityName: string, withoutRelation?: string) {\n\t\tconst entity = getEntity(this.schema, entityName)\n\n\t\tconst combinations: string[] = []\n\n\t\tconst possibleUniqueWhereFields = getFieldsForUniqueWhere(this.schema, entity)\n\t\tconst uniqueKeys: (readonly string[])[] = possibleUniqueWhereFields.filter(uniqueKey =>\n\t\t\tuniqueKey.every(it => acceptFieldVisitor(this.schema, entityName, it, new FieldAccessVisitor(Acl.Operation.read, this.authorizator)))\n\t\t)\n\t\tfor (const uniqueKey of uniqueKeys) {\n\t\t\tcombinations.push(uniqueKey.join(', '))\n\t\t}\n\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: capitalizeFirstLetter(entityName) + 'UniqueWhere',\n\t\t\t// description: `Valid combinations are: (${combinations.join('), (')})`, generates invalid schema file\n\t\t\tfields: () => this.getUniqueWhereFields(entity, uniqueKeys),\n\t\t})\n\t}\n\n\tpublic getUniqueWhereFields(entity: Model.Entity, uniqueKeys: (readonly string[])[]) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {}\n\t\tfor (const uniqueKey of uniqueKeys) {\n\t\t\tfor (const field of uniqueKey) {\n\t\t\t\tif (fields[field] !== undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tfields[field] = acceptFieldVisitor<GraphQLInputFieldConfig>(this.schema, entity, field, {\n\t\t\t\t\tvisitRelation: ({ targetEntity }) => {\n\t\t\t\t\t\t// if (!isIt<Model.JoiningColumnRelation>(relation, 'joiningColumn')) {\n\t\t\t\t\t\t// \tthrow new Error('Only column or owning relation can be a part of unique key')\n\t\t\t\t\t\t// }\n\t\t\t\t\t\tconst uniqueWhere = this.getEntityUniqueWhereType(targetEntity.name)\n\t\t\t\t\t\tif (!uniqueWhere) {\n\t\t\t\t\t\t\tthrow new ImplementationException()\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn { type: uniqueWhere }\n\t\t\t\t\t},\n\t\t\t\t\tvisitColumn: ({ column }) => ({ type: this.columnTypeResolver.getType(column)[0] }),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn fields\n\t}\n\n\tprivate getEntityWhereFields(name: string, where: GraphQLInputObjectType) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {}\n\t\tconst entity = this.schema.entities[name]\n\n\t\tfor (const fieldName in entity.fields) {\n\t\t\tif (!entity.fields.hasOwnProperty(fieldName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\t\tif (!acceptFieldVisitor(this.schema, name, fieldName, accessVisitor)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfields[fieldName] = acceptFieldVisitor(this.schema, name, fieldName, {\n\t\t\t\tvisitColumn: ({ column }) => ({ type: this.conditionTypeProvider.getCondition(column) }),\n\t\t\t\tvisitRelation: ({ relation }) => ({ type: this.getEntityWhereType(relation.target) }),\n\t\t\t} as Model.FieldVisitor<GraphQLInputFieldConfig>)\n\t\t}\n\n\t\tfields.and = { type: new GraphQLList(where) }\n\t\tfields.or = { type: new GraphQLList(where) }\n\t\tfields.not = { type: where }\n\n\t\treturn fields\n\t}\n}\n"],"names":["schema","singletonFactory","Acl","ImplementationException","GraphQLInputObjectType","GqlTypeName","getEntity","getFieldsForUniqueWhere","acceptFieldVisitor","FieldAccessVisitor","capitalizeFirstLetter","GraphQLList"],"mappings":";;;;;;;;;;;;;;AAWO,MAAM,kBAAkB;AAAA,EAI9B,YACkBA,SACA,cACA,oBACA,uBAChB;AAJgB,SAAA,SAAAA;AACA,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,wBAAA;AAPlB,kBAAA,MAAQ,kBAAiBC,kCAAiB,CAAA,SAAQ,KAAK,sBAAsB,IAAI,CAAC,CAAA;AAClF,kBAAA,MAAQ,wBAAuBA,kCAAiB,CAAA,SAAQ,KAAK,4BAA4B,IAAI,CAAC,CAAA;AAAA,EAO3F;AAAA,EAEI,mBAAmB,YAA4C;AACrE,QAAI,KAAK,aAAa,oBAAoBC,OAAAA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AAM,EAAE,MAAM,MAAA;AAErB,WAAO;AAAA,EACR;AACD;;"}
1
+ {"version":3,"file":"WhereTypeProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/WhereTypeProvider.ts"],"sourcesContent":["import { Acl, Model } from '@contember/schema'\nimport { acceptFieldVisitor, getEntity } from '@contember/schema-utils'\nimport { GraphQLInputFieldConfig, GraphQLInputFieldConfigMap, GraphQLInputObjectType, GraphQLList } from 'graphql'\nimport { capitalizeFirstLetter, getFieldsForUniqueWhere, singletonFactory } from '../utils/index.js'\nimport { ColumnTypeResolver } from './ColumnTypeResolver.js'\nimport { ConditionTypeProvider } from './ConditionTypeProvider.js'\nimport { GqlTypeName, inputFieldDescription } from './utils.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\nimport { ImplementationException } from '../exception.js'\n\nexport class WhereTypeProvider {\n\tprivate whereSingleton = singletonFactory(name => this.createEntityWhereType(name))\n\tprivate uniqueWhereSingleton = singletonFactory(name => this.createEntityUniqueWhereType(name))\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly conditionTypeProvider: ConditionTypeProvider,\n\t) {}\n\n\tpublic getEntityWhereType(entityName: string): GraphQLInputObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.whereSingleton(entityName)\n\t}\n\n\tpublic getEntityUniqueWhereType(entityName: string): undefined | GraphQLInputObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\treturn this.uniqueWhereSingleton(entityName)\n\t}\n\n\tprivate createEntityWhereType(entityName: string) {\n\t\tconst where: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entityName}Where`,\n\t\t\tfields: () => this.getEntityWhereFields(entityName, where),\n\t\t})\n\n\t\treturn where\n\t}\n\n\tprivate createEntityUniqueWhereType(entityName: string, withoutRelation?: string) {\n\t\tconst entity = getEntity(this.schema, entityName)\n\n\t\tconst combinations: string[] = []\n\n\t\tconst possibleUniqueWhereFields = getFieldsForUniqueWhere(this.schema, entity)\n\t\tconst uniqueKeys: (readonly string[])[] = possibleUniqueWhereFields.filter(uniqueKey =>\n\t\t\tuniqueKey.every(it => acceptFieldVisitor(this.schema, entityName, it, new FieldAccessVisitor(Acl.Operation.read, this.authorizator)))\n\t\t)\n\t\tfor (const uniqueKey of uniqueKeys) {\n\t\t\tcombinations.push(uniqueKey.join(', '))\n\t\t}\n\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: capitalizeFirstLetter(entityName) + 'UniqueWhere',\n\t\t\t// description: `Valid combinations are: (${combinations.join('), (')})`, generates invalid schema file\n\t\t\tfields: () => this.getUniqueWhereFields(entity, uniqueKeys),\n\t\t})\n\t}\n\n\tpublic getUniqueWhereFields(entity: Model.Entity, uniqueKeys: (readonly string[])[]) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {}\n\t\tfor (const uniqueKey of uniqueKeys) {\n\t\t\tfor (const field of uniqueKey) {\n\t\t\t\tif (fields[field] !== undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tfields[field] = acceptFieldVisitor<GraphQLInputFieldConfig>(this.schema, entity, field, {\n\t\t\t\t\tvisitRelation: ({ relation, targetEntity }) => {\n\t\t\t\t\t\t// if (!isIt<Model.JoiningColumnRelation>(relation, 'joiningColumn')) {\n\t\t\t\t\t\t// \tthrow new Error('Only column or owning relation can be a part of unique key')\n\t\t\t\t\t\t// }\n\t\t\t\t\t\tconst uniqueWhere = this.getEntityUniqueWhereType(targetEntity.name)\n\t\t\t\t\t\tif (!uniqueWhere) {\n\t\t\t\t\t\t\tthrow new ImplementationException()\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttype: uniqueWhere,\n\t\t\t\t\t\t\tdescription: inputFieldDescription(relation),\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tvisitColumn: ({ column }) => ({\n\t\t\t\t\t\ttype: this.columnTypeResolver.getType(column)[0],\n\t\t\t\t\t\tdescription: inputFieldDescription(column),\n\t\t\t\t\t}),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn fields\n\t}\n\n\tprivate getEntityWhereFields(name: string, where: GraphQLInputObjectType) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {}\n\t\tconst entity = this.schema.entities[name]\n\n\t\tfor (const fieldName in entity.fields) {\n\t\t\tif (!entity.fields.hasOwnProperty(fieldName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\t\tif (!acceptFieldVisitor(this.schema, name, fieldName, accessVisitor)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfields[fieldName] = acceptFieldVisitor(this.schema, name, fieldName, {\n\t\t\t\tvisitColumn: ({ column }) => ({\n\t\t\t\t\ttype: this.conditionTypeProvider.getCondition(column),\n\t\t\t\t\tdescription: inputFieldDescription(column),\n\t\t\t\t}),\n\t\t\t\tvisitRelation: ({ relation }) => ({\n\t\t\t\t\ttype: this.getEntityWhereType(relation.target),\n\t\t\t\t\tdescription: inputFieldDescription(relation),\n\t\t\t\t}),\n\t\t\t} as Model.FieldVisitor<GraphQLInputFieldConfig>)\n\t\t}\n\n\t\tfields.and = { type: new GraphQLList(where) }\n\t\tfields.or = { type: new GraphQLList(where) }\n\t\tfields.not = { type: where }\n\n\t\treturn fields\n\t}\n}\n"],"names":["schema","singletonFactory","Acl","ImplementationException","GraphQLInputObjectType","GqlTypeName","getEntity","getFieldsForUniqueWhere","acceptFieldVisitor","FieldAccessVisitor","capitalizeFirstLetter","inputFieldDescription","GraphQLList"],"mappings":";;;;;;;;;;;;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M,KAAK,YAAY;AAClF,UAAI,CAACM,YAAAA,mBAAmB,KAAK,QAAQ,MAAM,WAAW,aAAa,GAAG;AACrE;AAAA,MACD;AACA,aAAO,SAAS,IAAIA,YAAAA,mBAAmB,KAAK,QAAQ,MAAM,WAAW;AAAA,QACpE,aAAa,CAAC,EAAE,cAAc;AAAA,UAC7B,MAAM,KAAK,sBAAsB,aAAa,MAAM;AAAA,UACpD,aAAaG,MAAAA,sBAAsB,MAAM;AAAA,QAAA;AAAA,QAE1C,eAAe,CAAC,EAAE,gBAAgB;AAAA,UACjC,MAAM,KAAK,mBAAmB,SAAS,MAAM;AAAA,UAC7C,aAAaA,MAAAA,sBAAsB,QAAQ;AAAA,QAAA;AAAA,MAC5C,CAC+C;AAAA,IACjD;AAEA,WAAO,MAAM,EAAE,MAAM,IAAIC,QAAAA,YAAY,KAAK,EAAA;AAC1C,WAAO,KAAK,EAAE,MAAM,IAAIA,QAAAA,YAAY,KAAK,EAAA;AACzC,WAAO,MAAM,EAAE,MAAM,MAAA;AAErB,WAAO;AAAA,EACR;AACD;;"}
@@ -5,7 +5,7 @@ import { ImplementationException } from "../exception.js";
5
5
  import { singletonFactory } from "../utils/singletonFactory.js";
6
6
  import { capitalizeFirstLetter } from "../utils/strings.js";
7
7
  import { getFieldsForUniqueWhere } from "../utils/uniqueWhereFields.js";
8
- import { GqlTypeName } from "./utils.js";
8
+ import { GqlTypeName, inputFieldDescription } from "./utils.js";
9
9
  import { FieldAccessVisitor } from "./FieldAccessVisitor.js";
10
10
  var __defProp = Object.defineProperty;
11
11
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -62,14 +62,20 @@ class WhereTypeProvider {
62
62
  continue;
63
63
  }
64
64
  fields[field] = acceptFieldVisitor(this.schema, entity, field, {
65
- visitRelation: ({ targetEntity }) => {
65
+ visitRelation: ({ relation, targetEntity }) => {
66
66
  const uniqueWhere = this.getEntityUniqueWhereType(targetEntity.name);
67
67
  if (!uniqueWhere) {
68
68
  throw new ImplementationException();
69
69
  }
70
- return { type: uniqueWhere };
70
+ return {
71
+ type: uniqueWhere,
72
+ description: inputFieldDescription(relation)
73
+ };
71
74
  },
72
- visitColumn: ({ column }) => ({ type: this.columnTypeResolver.getType(column)[0] })
75
+ visitColumn: ({ column }) => ({
76
+ type: this.columnTypeResolver.getType(column)[0],
77
+ description: inputFieldDescription(column)
78
+ })
73
79
  });
74
80
  }
75
81
  }
@@ -87,8 +93,14 @@ class WhereTypeProvider {
87
93
  continue;
88
94
  }
89
95
  fields[fieldName] = acceptFieldVisitor(this.schema, name, fieldName, {
90
- visitColumn: ({ column }) => ({ type: this.conditionTypeProvider.getCondition(column) }),
91
- visitRelation: ({ relation }) => ({ type: this.getEntityWhereType(relation.target) })
96
+ visitColumn: ({ column }) => ({
97
+ type: this.conditionTypeProvider.getCondition(column),
98
+ description: inputFieldDescription(column)
99
+ }),
100
+ visitRelation: ({ relation }) => ({
101
+ type: this.getEntityWhereType(relation.target),
102
+ description: inputFieldDescription(relation)
103
+ })
92
104
  });
93
105
  }
94
106
  fields.and = { type: new GraphQLList(where) };
@@ -1 +1 @@
1
- {"version":3,"file":"WhereTypeProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/WhereTypeProvider.ts"],"sourcesContent":["import { Acl, Model } from '@contember/schema'\nimport { acceptFieldVisitor, getEntity } from '@contember/schema-utils'\nimport { GraphQLInputFieldConfig, GraphQLInputFieldConfigMap, GraphQLInputObjectType, GraphQLList } from 'graphql'\nimport { capitalizeFirstLetter, getFieldsForUniqueWhere, singletonFactory } from '../utils/index.js'\nimport { ColumnTypeResolver } from './ColumnTypeResolver.js'\nimport { ConditionTypeProvider } from './ConditionTypeProvider.js'\nimport { GqlTypeName } from './utils.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\nimport { ImplementationException } from '../exception.js'\n\nexport class WhereTypeProvider {\n\tprivate whereSingleton = singletonFactory(name => this.createEntityWhereType(name))\n\tprivate uniqueWhereSingleton = singletonFactory(name => this.createEntityUniqueWhereType(name))\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly conditionTypeProvider: ConditionTypeProvider,\n\t) {}\n\n\tpublic getEntityWhereType(entityName: string): GraphQLInputObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.whereSingleton(entityName)\n\t}\n\n\tpublic getEntityUniqueWhereType(entityName: string): undefined | GraphQLInputObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\treturn this.uniqueWhereSingleton(entityName)\n\t}\n\n\tprivate createEntityWhereType(entityName: string) {\n\t\tconst where: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entityName}Where`,\n\t\t\tfields: () => this.getEntityWhereFields(entityName, where),\n\t\t})\n\n\t\treturn where\n\t}\n\n\tprivate createEntityUniqueWhereType(entityName: string, withoutRelation?: string) {\n\t\tconst entity = getEntity(this.schema, entityName)\n\n\t\tconst combinations: string[] = []\n\n\t\tconst possibleUniqueWhereFields = getFieldsForUniqueWhere(this.schema, entity)\n\t\tconst uniqueKeys: (readonly string[])[] = possibleUniqueWhereFields.filter(uniqueKey =>\n\t\t\tuniqueKey.every(it => acceptFieldVisitor(this.schema, entityName, it, new FieldAccessVisitor(Acl.Operation.read, this.authorizator)))\n\t\t)\n\t\tfor (const uniqueKey of uniqueKeys) {\n\t\t\tcombinations.push(uniqueKey.join(', '))\n\t\t}\n\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: capitalizeFirstLetter(entityName) + 'UniqueWhere',\n\t\t\t// description: `Valid combinations are: (${combinations.join('), (')})`, generates invalid schema file\n\t\t\tfields: () => this.getUniqueWhereFields(entity, uniqueKeys),\n\t\t})\n\t}\n\n\tpublic getUniqueWhereFields(entity: Model.Entity, uniqueKeys: (readonly string[])[]) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {}\n\t\tfor (const uniqueKey of uniqueKeys) {\n\t\t\tfor (const field of uniqueKey) {\n\t\t\t\tif (fields[field] !== undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tfields[field] = acceptFieldVisitor<GraphQLInputFieldConfig>(this.schema, entity, field, {\n\t\t\t\t\tvisitRelation: ({ targetEntity }) => {\n\t\t\t\t\t\t// if (!isIt<Model.JoiningColumnRelation>(relation, 'joiningColumn')) {\n\t\t\t\t\t\t// \tthrow new Error('Only column or owning relation can be a part of unique key')\n\t\t\t\t\t\t// }\n\t\t\t\t\t\tconst uniqueWhere = this.getEntityUniqueWhereType(targetEntity.name)\n\t\t\t\t\t\tif (!uniqueWhere) {\n\t\t\t\t\t\t\tthrow new ImplementationException()\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn { type: uniqueWhere }\n\t\t\t\t\t},\n\t\t\t\t\tvisitColumn: ({ column }) => ({ type: this.columnTypeResolver.getType(column)[0] }),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn fields\n\t}\n\n\tprivate getEntityWhereFields(name: string, where: GraphQLInputObjectType) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {}\n\t\tconst entity = this.schema.entities[name]\n\n\t\tfor (const fieldName in entity.fields) {\n\t\t\tif (!entity.fields.hasOwnProperty(fieldName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\t\tif (!acceptFieldVisitor(this.schema, name, fieldName, accessVisitor)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfields[fieldName] = acceptFieldVisitor(this.schema, name, fieldName, {\n\t\t\t\tvisitColumn: ({ column }) => ({ type: this.conditionTypeProvider.getCondition(column) }),\n\t\t\t\tvisitRelation: ({ relation }) => ({ type: this.getEntityWhereType(relation.target) }),\n\t\t\t} as Model.FieldVisitor<GraphQLInputFieldConfig>)\n\t\t}\n\n\t\tfields.and = { type: new GraphQLList(where) }\n\t\tfields.or = { type: new GraphQLList(where) }\n\t\tfields.not = { type: where }\n\n\t\treturn fields\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAWO,MAAM,kBAAkB;AAAA,EAI9B,YACkB,QACA,cACA,oBACA,uBAChB;AAJgB,SAAA,SAAA;AACA,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,wBAAA;AAPlB,kBAAA,MAAQ,kBAAiB,iBAAiB,CAAA,SAAQ,KAAK,sBAAsB,IAAI,CAAC,CAAA;AAClF,kBAAA,MAAQ,wBAAuB,iBAAiB,CAAA,SAAQ,KAAK,4BAA4B,IAAI,CAAC,CAAA;AAAA,EAO3F;AAAA,EAEI,mBAAmB,YAA4C;AACrE,QAAI,KAAK,aAAa,oBAAoB,IAAI,UAAU,MAAM,UAAU,MAAM,MAAM;AACnF,YAAM,IAAI,wBAAA;AAAA,IACX;AACA,WAAO,KAAK,eAAe,UAAU;AAAA,EACtC;AAAA,EAEO,yBAAyB,YAAwD;AACvF,QAAI,KAAK,aAAa,oBAAoB,IAAI,UAAU,MAAM,UAAU,MAAM,MAAM;AACnF,aAAO;AAAA,IACR;AACA,WAAO,KAAK,qBAAqB,UAAU;AAAA,EAC5C;AAAA,EAEQ,sBAAsB,YAAoB;AACjD,UAAM,QAAgC,IAAI,uBAAuB;AAAA,MAChE,MAAM,cAAc,UAAU;AAAA,MAC9B,QAAQ,MAAM,KAAK,qBAAqB,YAAY,KAAK;AAAA,IAAA,CACzD;AAED,WAAO;AAAA,EACR;AAAA,EAEQ,4BAA4B,YAAoB,iBAA0B;AACjF,UAAM,SAAS,UAAU,KAAK,QAAQ,UAAU;AAEhD,UAAM,eAAyB,CAAA;AAE/B,UAAM,4BAA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,IAAI,mBAAmB,IAAI,UAAU,MAAM,KAAK,YAAY;AAClF,UAAI,CAAC,mBAAmB,KAAK,QAAQ,MAAM,WAAW,aAAa,GAAG;AACrE;AAAA,MACD;AACA,aAAO,SAAS,IAAI,mBAAmB,KAAK,QAAQ,MAAM,WAAW;AAAA,QACpE,aAAa,CAAC,EAAE,OAAA,OAAc,EAAE,MAAM,KAAK,sBAAsB,aAAa,MAAM;QACpF,eAAe,CAAC,EAAE,SAAA,OAAgB,EAAE,MAAM,KAAK,mBAAmB,SAAS,MAAM,EAAA;AAAA,MAAE,CACpC;AAAA,IACjD;AAEA,WAAO,MAAM,EAAE,MAAM,IAAI,YAAY,KAAK,EAAA;AAC1C,WAAO,KAAK,EAAE,MAAM,IAAI,YAAY,KAAK,EAAA;AACzC,WAAO,MAAM,EAAE,MAAM,MAAA;AAErB,WAAO;AAAA,EACR;AACD;"}
1
+ {"version":3,"file":"WhereTypeProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/WhereTypeProvider.ts"],"sourcesContent":["import { Acl, Model } from '@contember/schema'\nimport { acceptFieldVisitor, getEntity } from '@contember/schema-utils'\nimport { GraphQLInputFieldConfig, GraphQLInputFieldConfigMap, GraphQLInputObjectType, GraphQLList } from 'graphql'\nimport { capitalizeFirstLetter, getFieldsForUniqueWhere, singletonFactory } from '../utils/index.js'\nimport { ColumnTypeResolver } from './ColumnTypeResolver.js'\nimport { ConditionTypeProvider } from './ConditionTypeProvider.js'\nimport { GqlTypeName, inputFieldDescription } from './utils.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\nimport { ImplementationException } from '../exception.js'\n\nexport class WhereTypeProvider {\n\tprivate whereSingleton = singletonFactory(name => this.createEntityWhereType(name))\n\tprivate uniqueWhereSingleton = singletonFactory(name => this.createEntityUniqueWhereType(name))\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly conditionTypeProvider: ConditionTypeProvider,\n\t) {}\n\n\tpublic getEntityWhereType(entityName: string): GraphQLInputObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.whereSingleton(entityName)\n\t}\n\n\tpublic getEntityUniqueWhereType(entityName: string): undefined | GraphQLInputObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\treturn this.uniqueWhereSingleton(entityName)\n\t}\n\n\tprivate createEntityWhereType(entityName: string) {\n\t\tconst where: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entityName}Where`,\n\t\t\tfields: () => this.getEntityWhereFields(entityName, where),\n\t\t})\n\n\t\treturn where\n\t}\n\n\tprivate createEntityUniqueWhereType(entityName: string, withoutRelation?: string) {\n\t\tconst entity = getEntity(this.schema, entityName)\n\n\t\tconst combinations: string[] = []\n\n\t\tconst possibleUniqueWhereFields = getFieldsForUniqueWhere(this.schema, entity)\n\t\tconst uniqueKeys: (readonly string[])[] = possibleUniqueWhereFields.filter(uniqueKey =>\n\t\t\tuniqueKey.every(it => acceptFieldVisitor(this.schema, entityName, it, new FieldAccessVisitor(Acl.Operation.read, this.authorizator)))\n\t\t)\n\t\tfor (const uniqueKey of uniqueKeys) {\n\t\t\tcombinations.push(uniqueKey.join(', '))\n\t\t}\n\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: capitalizeFirstLetter(entityName) + 'UniqueWhere',\n\t\t\t// description: `Valid combinations are: (${combinations.join('), (')})`, generates invalid schema file\n\t\t\tfields: () => this.getUniqueWhereFields(entity, uniqueKeys),\n\t\t})\n\t}\n\n\tpublic getUniqueWhereFields(entity: Model.Entity, uniqueKeys: (readonly string[])[]) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {}\n\t\tfor (const uniqueKey of uniqueKeys) {\n\t\t\tfor (const field of uniqueKey) {\n\t\t\t\tif (fields[field] !== undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tfields[field] = acceptFieldVisitor<GraphQLInputFieldConfig>(this.schema, entity, field, {\n\t\t\t\t\tvisitRelation: ({ relation, targetEntity }) => {\n\t\t\t\t\t\t// if (!isIt<Model.JoiningColumnRelation>(relation, 'joiningColumn')) {\n\t\t\t\t\t\t// \tthrow new Error('Only column or owning relation can be a part of unique key')\n\t\t\t\t\t\t// }\n\t\t\t\t\t\tconst uniqueWhere = this.getEntityUniqueWhereType(targetEntity.name)\n\t\t\t\t\t\tif (!uniqueWhere) {\n\t\t\t\t\t\t\tthrow new ImplementationException()\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttype: uniqueWhere,\n\t\t\t\t\t\t\tdescription: inputFieldDescription(relation),\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tvisitColumn: ({ column }) => ({\n\t\t\t\t\t\ttype: this.columnTypeResolver.getType(column)[0],\n\t\t\t\t\t\tdescription: inputFieldDescription(column),\n\t\t\t\t\t}),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn fields\n\t}\n\n\tprivate getEntityWhereFields(name: string, where: GraphQLInputObjectType) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {}\n\t\tconst entity = this.schema.entities[name]\n\n\t\tfor (const fieldName in entity.fields) {\n\t\t\tif (!entity.fields.hasOwnProperty(fieldName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\t\tif (!acceptFieldVisitor(this.schema, name, fieldName, accessVisitor)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfields[fieldName] = acceptFieldVisitor(this.schema, name, fieldName, {\n\t\t\t\tvisitColumn: ({ column }) => ({\n\t\t\t\t\ttype: this.conditionTypeProvider.getCondition(column),\n\t\t\t\t\tdescription: inputFieldDescription(column),\n\t\t\t\t}),\n\t\t\t\tvisitRelation: ({ relation }) => ({\n\t\t\t\t\ttype: this.getEntityWhereType(relation.target),\n\t\t\t\t\tdescription: inputFieldDescription(relation),\n\t\t\t\t}),\n\t\t\t} as Model.FieldVisitor<GraphQLInputFieldConfig>)\n\t\t}\n\n\t\tfields.and = { type: new GraphQLList(where) }\n\t\tfields.or = { type: new GraphQLList(where) }\n\t\tfields.not = { type: where }\n\n\t\treturn fields\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAWO,MAAM,kBAAkB;AAAA,EAI9B,YACkB,QACA,cACA,oBACA,uBAChB;AAJgB,SAAA,SAAA;AACA,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,wBAAA;AAPlB,kBAAA,MAAQ,kBAAiB,iBAAiB,CAAA,SAAQ,KAAK,sBAAsB,IAAI,CAAC,CAAA;AAClF,kBAAA,MAAQ,wBAAuB,iBAAiB,CAAA,SAAQ,KAAK,4BAA4B,IAAI,CAAC,CAAA;AAAA,EAO3F;AAAA,EAEI,mBAAmB,YAA4C;AACrE,QAAI,KAAK,aAAa,oBAAoB,IAAI,UAAU,MAAM,UAAU,MAAM,MAAM;AACnF,YAAM,IAAI,wBAAA;AAAA,IACX;AACA,WAAO,KAAK,eAAe,UAAU;AAAA,EACtC;AAAA,EAEO,yBAAyB,YAAwD;AACvF,QAAI,KAAK,aAAa,oBAAoB,IAAI,UAAU,MAAM,UAAU,MAAM,MAAM;AACnF,aAAO;AAAA,IACR;AACA,WAAO,KAAK,qBAAqB,UAAU;AAAA,EAC5C;AAAA,EAEQ,sBAAsB,YAAoB;AACjD,UAAM,QAAgC,IAAI,uBAAuB;AAAA,MAChE,MAAM,cAAc,UAAU;AAAA,MAC9B,QAAQ,MAAM,KAAK,qBAAqB,YAAY,KAAK;AAAA,IAAA,CACzD;AAED,WAAO;AAAA,EACR;AAAA,EAEQ,4BAA4B,YAAoB,iBA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AACzE,UAAM,SAAqC,CAAA;AAC3C,UAAM,SAAS,KAAK,OAAO,SAAS,IAAI;AAExC,eAAW,aAAa,OAAO,QAAQ;AACtC,UAAI,CAAC,OAAO,OAAO,eAAe,SAAS,GAAG;AAC7C;AAAA,MACD;AACA,YAAM,gBAAgB,IAAI,mBAAmB,IAAI,UAAU,MAAM,KAAK,YAAY;AAClF,UAAI,CAAC,mBAAmB,KAAK,QAAQ,MAAM,WAAW,aAAa,GAAG;AACrE;AAAA,MACD;AACA,aAAO,SAAS,IAAI,mBAAmB,KAAK,QAAQ,MAAM,WAAW;AAAA,QACpE,aAAa,CAAC,EAAE,cAAc;AAAA,UAC7B,MAAM,KAAK,sBAAsB,aAAa,MAAM;AAAA,UACpD,aAAa,sBAAsB,MAAM;AAAA,QAAA;AAAA,QAE1C,eAAe,CAAC,EAAE,gBAAgB;AAAA,UACjC,MAAM,KAAK,mBAAmB,SAAS,MAAM;AAAA,UAC7C,aAAa,sBAAsB,QAAQ;AAAA,QAAA;AAAA,MAC5C,CAC+C;AAAA,IACjD;AAEA,WAAO,MAAM,EAAE,MAAM,IAAI,YAAY,KAAK,EAAA;AAC1C,WAAO,KAAK,EAAE,MAAM,IAAI,YAAY,KAAK,EAAA;AACzC,WAAO,MAAM,EAAE,MAAM,MAAA;AAErB,WAAO;AAAA,EACR;AACD;"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const ISO_DATE_PREFIX_REGEX = /^(\d{4})-(\d{1,2})-(\d{1,2})(?!\d)/;
4
+ const BC_ERA_REGEX = /BC/i;
5
+ const DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
6
+ const daysInMonth = (year, month) => {
7
+ const isLeapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
8
+ return month === 2 && isLeapYear ? 29 : DAYS_IN_MONTH[month - 1];
9
+ };
10
+ const isImpossibleCalendarDate = (value) => {
11
+ const match = ISO_DATE_PREFIX_REGEX.exec(value);
12
+ if (!match || BC_ERA_REGEX.test(value)) {
13
+ return false;
14
+ }
15
+ const year = Number(match[1]);
16
+ const month = Number(match[2]);
17
+ const day = Number(match[3]);
18
+ return year === 0 || month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month);
19
+ };
20
+ exports.isImpossibleCalendarDate = isImpossibleCalendarDate;
21
+ //# sourceMappingURL=calendarDate.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendarDate.cjs","sources":["../../../../../packages/engine-content-api/src/schema/calendarDate.ts"],"sourcesContent":["const ISO_DATE_PREFIX_REGEX = /^(\\d{4})-(\\d{1,2})-(\\d{1,2})(?!\\d)/\n\n// Over-matching only defers a value to PostgreSQL; `2025-02-29BC` has no word boundary before BC.\nconst BC_ERA_REGEX = /BC/i\n\nconst DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n\nconst daysInMonth = (year: number, month: number): number => {\n\tconst isLeapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)\n\treturn month === 2 && isLeapYear ? 29 : DAYS_IN_MONTH[month - 1]\n}\n\n/**\n * True for an ISO-shaped calendar date that does not exist (e.g. 2026-02-30, year 0000), which PostgreSQL would refuse.\n * Other input formats PostgreSQL accepts, and BC dates, are left for PostgreSQL to judge.\n */\nexport const isImpossibleCalendarDate = (value: string): boolean => {\n\tconst match = ISO_DATE_PREFIX_REGEX.exec(value)\n\tif (!match || BC_ERA_REGEX.test(value)) {\n\t\treturn false\n\t}\n\tconst year = Number(match[1])\n\tconst month = Number(match[2])\n\tconst day = Number(match[3])\n\treturn year === 0 || month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month)\n}\n"],"names":[],"mappings":";;AAAA,MAAM,wBAAwB;AAG9B,MAAM,eAAe;AAErB,MAAM,gBAAgB,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE;AAErE,MAAM,cAAc,CAAC,MAAc,UAA0B;AAC5D,QAAM,aAAa,OAAO,MAAM,MAAM,OAAO,QAAQ,KAAK,OAAO,QAAQ;AACzE,SAAO,UAAU,KAAK,aAAa,KAAK,cAAc,QAAQ,CAAC;AAChE;AAMO,MAAM,2BAA2B,CAAC,UAA2B;AACnE,QAAM,QAAQ,sBAAsB,KAAK,KAAK;AAC9C,MAAI,CAAC,SAAS,aAAa,KAAK,KAAK,GAAG;AACvC,WAAO;AAAA,EACR;AACA,QAAM,OAAO,OAAO,MAAM,CAAC,CAAC;AAC5B,QAAM,QAAQ,OAAO,MAAM,CAAC,CAAC;AAC7B,QAAM,MAAM,OAAO,MAAM,CAAC,CAAC;AAC3B,SAAO,SAAS,KAAK,QAAQ,KAAK,QAAQ,MAAM,MAAM,KAAK,MAAM,YAAY,MAAM,KAAK;AACzF;;"}
@@ -0,0 +1,21 @@
1
+ const ISO_DATE_PREFIX_REGEX = /^(\d{4})-(\d{1,2})-(\d{1,2})(?!\d)/;
2
+ const BC_ERA_REGEX = /BC/i;
3
+ const DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
4
+ const daysInMonth = (year, month) => {
5
+ const isLeapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
6
+ return month === 2 && isLeapYear ? 29 : DAYS_IN_MONTH[month - 1];
7
+ };
8
+ const isImpossibleCalendarDate = (value) => {
9
+ const match = ISO_DATE_PREFIX_REGEX.exec(value);
10
+ if (!match || BC_ERA_REGEX.test(value)) {
11
+ return false;
12
+ }
13
+ const year = Number(match[1]);
14
+ const month = Number(match[2]);
15
+ const day = Number(match[3]);
16
+ return year === 0 || month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month);
17
+ };
18
+ export {
19
+ isImpossibleCalendarDate
20
+ };
21
+ //# sourceMappingURL=calendarDate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendarDate.js","sources":["../../../../../packages/engine-content-api/src/schema/calendarDate.ts"],"sourcesContent":["const ISO_DATE_PREFIX_REGEX = /^(\\d{4})-(\\d{1,2})-(\\d{1,2})(?!\\d)/\n\n// Over-matching only defers a value to PostgreSQL; `2025-02-29BC` has no word boundary before BC.\nconst BC_ERA_REGEX = /BC/i\n\nconst DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n\nconst daysInMonth = (year: number, month: number): number => {\n\tconst isLeapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)\n\treturn month === 2 && isLeapYear ? 29 : DAYS_IN_MONTH[month - 1]\n}\n\n/**\n * True for an ISO-shaped calendar date that does not exist (e.g. 2026-02-30, year 0000), which PostgreSQL would refuse.\n * Other input formats PostgreSQL accepts, and BC dates, are left for PostgreSQL to judge.\n */\nexport const isImpossibleCalendarDate = (value: string): boolean => {\n\tconst match = ISO_DATE_PREFIX_REGEX.exec(value)\n\tif (!match || BC_ERA_REGEX.test(value)) {\n\t\treturn false\n\t}\n\tconst year = Number(match[1])\n\tconst month = Number(match[2])\n\tconst day = Number(match[3])\n\treturn year === 0 || month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month)\n}\n"],"names":[],"mappings":"AAAA,MAAM,wBAAwB;AAG9B,MAAM,eAAe;AAErB,MAAM,gBAAgB,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE;AAErE,MAAM,cAAc,CAAC,MAAc,UAA0B;AAC5D,QAAM,aAAa,OAAO,MAAM,MAAM,OAAO,QAAQ,KAAK,OAAO,QAAQ;AACzE,SAAO,UAAU,KAAK,aAAa,KAAK,cAAc,QAAQ,CAAC;AAChE;AAMO,MAAM,2BAA2B,CAAC,UAA2B;AACnE,QAAM,QAAQ,sBAAsB,KAAK,KAAK;AAC9C,MAAI,CAAC,SAAS,aAAa,KAAK,KAAK,GAAG;AACvC,WAAO;AAAA,EACR;AACA,QAAM,OAAO,OAAO,MAAM,CAAC,CAAC;AAC5B,QAAM,QAAQ,OAAO,MAAM,CAAC,CAAC;AAC7B,QAAM,MAAM,OAAO,MAAM,CAAC,CAAC;AAC3B,SAAO,SAAS,KAAK,QAAQ,KAAK,QAAQ,MAAM,MAAM,KAAK,MAAM,YAAY,MAAM,KAAK;AACzF;"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const graphql = require("graphql");
4
4
  const schema = require("@contember/schema");
5
+ const utils = require("../utils.cjs");
5
6
  class CreateEntityInputFieldVisitor {
6
7
  constructor(schema2, authorizator, columnTypeResolver, createEntityRelationInputProvider) {
7
8
  this.schema = schema2;
@@ -17,14 +18,20 @@ class CreateEntityInputFieldVisitor {
17
18
  return void 0;
18
19
  }
19
20
  const [type] = this.columnTypeResolver.getType(column);
20
- return { type };
21
+ return {
22
+ type,
23
+ description: utils.inputFieldDescription(column)
24
+ };
21
25
  }
22
26
  visitHasOne({ entity, relation }) {
23
27
  const type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name);
24
28
  if (type === void 0) {
25
29
  return void 0;
26
30
  }
27
- return { type };
31
+ return {
32
+ type,
33
+ description: utils.inputFieldDescription(relation)
34
+ };
28
35
  }
29
36
  visitHasMany({ entity, relation }) {
30
37
  const type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name);
@@ -32,7 +39,8 @@ class CreateEntityInputFieldVisitor {
32
39
  return void 0;
33
40
  }
34
41
  return {
35
- type: new graphql.GraphQLList(new graphql.GraphQLNonNull(type))
42
+ type: new graphql.GraphQLList(new graphql.GraphQLNonNull(type)),
43
+ description: utils.inputFieldDescription(relation)
36
44
  };
37
45
  }
38
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CreateEntityInputFieldVisitor.cjs","sources":["../../../../../../packages/engine-content-api/src/schema/mutations/CreateEntityInputFieldVisitor.ts"],"sourcesContent":["import { GraphQLInputFieldConfig, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { ColumnTypeResolver } from '../ColumnTypeResolver.js'\nimport { CreateEntityRelationInputProvider } from './CreateEntityRelationInputProvider.js'\nimport { Authorizator } from '../../acl/index.js'\n\nexport class CreateEntityInputFieldVisitor\n\timplements Model.ColumnVisitor<GraphQLInputFieldConfig | undefined>, Model.RelationByGenericTypeVisitor<GraphQLInputFieldConfig | undefined>\n{\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly createEntityRelationInputProvider: CreateEntityRelationInputProvider,\n\t) {}\n\n\tpublic visitColumn({ entity, column }: Model.ColumnContext): GraphQLInputFieldConfig | undefined {\n\t\tif (entity.primary === column.name && !this.authorizator.isCustomPrimaryAllowed(entity.name)) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (this.authorizator.getFieldPermissions(Acl.Operation.create, entity.name, column.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst [type] = this.columnTypeResolver.getType(column)\n\t\treturn { type }\n\t}\n\n\tpublic visitHasOne({ entity, relation }: Model.AnyHasOneRelationContext): GraphQLInputFieldConfig | undefined {\n\t\tconst type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name)\n\t\tif (type === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn { type }\n\t}\n\n\tpublic visitHasMany({ entity, relation }: Model.AnyHasManyRelationContext): GraphQLInputFieldConfig | undefined {\n\t\tconst type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name)\n\t\tif (type === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLList(new GraphQLNonNull(type)),\n\t\t}\n\t}\n}\n"],"names":["schema","Acl","GraphQLList","GraphQLNonNull"],"mappings":";;;;AAMO,MAAM,8BAEb;AAAA,EACC,YACkBA,SACA,cACA,oBACA,mCAChB;AAJgB,SAAA,SAAAA;AACA,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,oCAAA;AAAA,EACf;AAAA,EAEI,YAAY,EAAE,QAAQ,UAAoE;AAChG,QAAI,OAAO,YAAY,OAAO,QAAQ,CAAC,KAAK,aAAa,uBAAuB,OAAO,IAAI,GAAG;AAC7F,aAAO;AAAA,IACR;AACA,QAAI,KAAK,aAAa,oBAAoBC,OAAAA,IAAI,UAAU,QAAQ,OAAO,MAAM,OAAO,IAAI,MAAM,MAAM;AACnG,aAAO;AAAA,IACR;AACA,UAAM,CAAC,IAAI,IAAI,KAAK,mBAAmB,QAAQ,MAAM;AACrD,WAAO,EAAE,KAAA;AAAA,EACV;AAAA,EAEO,YAAY,EAAE,QAAQ,YAAiF;AAC7G,UAAM,OAAO,KAAK,kCAAkC,6BAA6B,OAAO,MAAM,SAAS,IAAI;AAC3G,QAAI,SAAS,QAAW;AACvB,aAAO;AAAA,IACR;AACA,WAAO,EAAE,KAAA;AAAA,EACV;AAAA,EAEO,aAAa,EAAE,QAAQ,YAAkF;AAC/G,UAAM,OAAO,KAAK,kCAAkC,6BAA6B,OAAO,MAAM,SAAS,IAAI;AAC3G,QAAI,SAAS,QAAW;AACvB,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN,MAAM,IAAIC,QAAAA,YAAY,IAAIC,QAAAA,eAAe,IAAI,CAAC;AAAA,IAAA;AAAA,EAEhD;AACD;;"}
1
+ {"version":3,"file":"CreateEntityInputFieldVisitor.cjs","sources":["../../../../../../packages/engine-content-api/src/schema/mutations/CreateEntityInputFieldVisitor.ts"],"sourcesContent":["import { GraphQLInputFieldConfig, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { inputFieldDescription } from '../utils.js'\nimport { ColumnTypeResolver } from '../ColumnTypeResolver.js'\nimport { CreateEntityRelationInputProvider } from './CreateEntityRelationInputProvider.js'\nimport { Authorizator } from '../../acl/index.js'\n\nexport class CreateEntityInputFieldVisitor\n\timplements Model.ColumnVisitor<GraphQLInputFieldConfig | undefined>, Model.RelationByGenericTypeVisitor<GraphQLInputFieldConfig | undefined>\n{\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly createEntityRelationInputProvider: CreateEntityRelationInputProvider,\n\t) {}\n\n\tpublic visitColumn({ entity, column }: Model.ColumnContext): GraphQLInputFieldConfig | undefined {\n\t\tif (entity.primary === column.name && !this.authorizator.isCustomPrimaryAllowed(entity.name)) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (this.authorizator.getFieldPermissions(Acl.Operation.create, entity.name, column.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst [type] = this.columnTypeResolver.getType(column)\n\t\treturn {\n\t\t\ttype,\n\t\t\tdescription: inputFieldDescription(column),\n\t\t}\n\t}\n\n\tpublic visitHasOne({ entity, relation }: Model.AnyHasOneRelationContext): GraphQLInputFieldConfig | undefined {\n\t\tconst type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name)\n\t\tif (type === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype,\n\t\t\tdescription: inputFieldDescription(relation),\n\t\t}\n\t}\n\n\tpublic visitHasMany({ entity, relation }: Model.AnyHasManyRelationContext): GraphQLInputFieldConfig | undefined {\n\t\tconst type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name)\n\t\tif (type === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLList(new GraphQLNonNull(type)),\n\t\t\tdescription: inputFieldDescription(relation),\n\t\t}\n\t}\n}\n"],"names":["schema","Acl","inputFieldDescription","GraphQLList","GraphQLNonNull"],"mappings":";;;;;AAOO,MAAM,8BAEb;AAAA,EACC,YACkBA,SACA,cACA,oBACA,mCAChB;AAJgB,SAAA,SAAAA;AACA,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,oCAAA;AAAA,EACf;AAAA,EAEI,YAAY,EAAE,QAAQ,UAAoE;AAChG,QAAI,OAAO,YAAY,OAAO,QAAQ,CAAC,KAAK,aAAa,uBAAuB,OAAO,IAAI,GAAG;AAC7F,aAAO;AAAA,IACR;AACA,QAAI,KAAK,aAAa,oBAAoBC,OAAAA,IAAI,UAAU,QAAQ,OAAO,MAAM,OAAO,IAAI,MAAM,MAAM;AACnG,aAAO;AAAA,IACR;AACA,UAAM,CAAC,IAAI,IAAI,KAAK,mBAAmB,QAAQ,MAAM;AACrD,WAAO;AAAA,MACN;AAAA,MACA,aAAaC,MAAAA,sBAAsB,MAAM;AAAA,IAAA;AAAA,EAE3C;AAAA,EAEO,YAAY,EAAE,QAAQ,YAAiF;AAC7G,UAAM,OAAO,KAAK,kCAAkC,6BAA6B,OAAO,MAAM,SAAS,IAAI;AAC3G,QAAI,SAAS,QAAW;AACvB,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN;AAAA,MACA,aAAaA,MAAAA,sBAAsB,QAAQ;AAAA,IAAA;AAAA,EAE7C;AAAA,EAEO,aAAa,EAAE,QAAQ,YAAkF;AAC/G,UAAM,OAAO,KAAK,kCAAkC,6BAA6B,OAAO,MAAM,SAAS,IAAI;AAC3G,QAAI,SAAS,QAAW;AACvB,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN,MAAM,IAAIC,QAAAA,YAAY,IAAIC,QAAAA,eAAe,IAAI,CAAC;AAAA,MAC9C,aAAaF,MAAAA,sBAAsB,QAAQ;AAAA,IAAA;AAAA,EAE7C;AACD;;"}
@@ -1,5 +1,6 @@
1
1
  import { GraphQLList, GraphQLNonNull } from "graphql";
2
2
  import { Acl } from "@contember/schema";
3
+ import { inputFieldDescription } from "../utils.js";
3
4
  class CreateEntityInputFieldVisitor {
4
5
  constructor(schema, authorizator, columnTypeResolver, createEntityRelationInputProvider) {
5
6
  this.schema = schema;
@@ -15,14 +16,20 @@ class CreateEntityInputFieldVisitor {
15
16
  return void 0;
16
17
  }
17
18
  const [type] = this.columnTypeResolver.getType(column);
18
- return { type };
19
+ return {
20
+ type,
21
+ description: inputFieldDescription(column)
22
+ };
19
23
  }
20
24
  visitHasOne({ entity, relation }) {
21
25
  const type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name);
22
26
  if (type === void 0) {
23
27
  return void 0;
24
28
  }
25
- return { type };
29
+ return {
30
+ type,
31
+ description: inputFieldDescription(relation)
32
+ };
26
33
  }
27
34
  visitHasMany({ entity, relation }) {
28
35
  const type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name);
@@ -30,7 +37,8 @@ class CreateEntityInputFieldVisitor {
30
37
  return void 0;
31
38
  }
32
39
  return {
33
- type: new GraphQLList(new GraphQLNonNull(type))
40
+ type: new GraphQLList(new GraphQLNonNull(type)),
41
+ description: inputFieldDescription(relation)
34
42
  };
35
43
  }
36
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CreateEntityInputFieldVisitor.js","sources":["../../../../../../packages/engine-content-api/src/schema/mutations/CreateEntityInputFieldVisitor.ts"],"sourcesContent":["import { GraphQLInputFieldConfig, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { ColumnTypeResolver } from '../ColumnTypeResolver.js'\nimport { CreateEntityRelationInputProvider } from './CreateEntityRelationInputProvider.js'\nimport { Authorizator } from '../../acl/index.js'\n\nexport class CreateEntityInputFieldVisitor\n\timplements Model.ColumnVisitor<GraphQLInputFieldConfig | undefined>, Model.RelationByGenericTypeVisitor<GraphQLInputFieldConfig | undefined>\n{\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly createEntityRelationInputProvider: CreateEntityRelationInputProvider,\n\t) {}\n\n\tpublic visitColumn({ entity, column }: Model.ColumnContext): GraphQLInputFieldConfig | undefined {\n\t\tif (entity.primary === column.name && !this.authorizator.isCustomPrimaryAllowed(entity.name)) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (this.authorizator.getFieldPermissions(Acl.Operation.create, entity.name, column.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst [type] = this.columnTypeResolver.getType(column)\n\t\treturn { type }\n\t}\n\n\tpublic visitHasOne({ entity, relation }: Model.AnyHasOneRelationContext): GraphQLInputFieldConfig | undefined {\n\t\tconst type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name)\n\t\tif (type === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn { type }\n\t}\n\n\tpublic visitHasMany({ entity, relation }: Model.AnyHasManyRelationContext): GraphQLInputFieldConfig | undefined {\n\t\tconst type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name)\n\t\tif (type === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLList(new GraphQLNonNull(type)),\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAMO,MAAM,8BAEb;AAAA,EACC,YACkB,QACA,cACA,oBACA,mCAChB;AAJgB,SAAA,SAAA;AACA,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,oCAAA;AAAA,EACf;AAAA,EAEI,YAAY,EAAE,QAAQ,UAAoE;AAChG,QAAI,OAAO,YAAY,OAAO,QAAQ,CAAC,KAAK,aAAa,uBAAuB,OAAO,IAAI,GAAG;AAC7F,aAAO;AAAA,IACR;AACA,QAAI,KAAK,aAAa,oBAAoB,IAAI,UAAU,QAAQ,OAAO,MAAM,OAAO,IAAI,MAAM,MAAM;AACnG,aAAO;AAAA,IACR;AACA,UAAM,CAAC,IAAI,IAAI,KAAK,mBAAmB,QAAQ,MAAM;AACrD,WAAO,EAAE,KAAA;AAAA,EACV;AAAA,EAEO,YAAY,EAAE,QAAQ,YAAiF;AAC7G,UAAM,OAAO,KAAK,kCAAkC,6BAA6B,OAAO,MAAM,SAAS,IAAI;AAC3G,QAAI,SAAS,QAAW;AACvB,aAAO;AAAA,IACR;AACA,WAAO,EAAE,KAAA;AAAA,EACV;AAAA,EAEO,aAAa,EAAE,QAAQ,YAAkF;AAC/G,UAAM,OAAO,KAAK,kCAAkC,6BAA6B,OAAO,MAAM,SAAS,IAAI;AAC3G,QAAI,SAAS,QAAW;AACvB,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN,MAAM,IAAI,YAAY,IAAI,eAAe,IAAI,CAAC;AAAA,IAAA;AAAA,EAEhD;AACD;"}
1
+ {"version":3,"file":"CreateEntityInputFieldVisitor.js","sources":["../../../../../../packages/engine-content-api/src/schema/mutations/CreateEntityInputFieldVisitor.ts"],"sourcesContent":["import { GraphQLInputFieldConfig, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { inputFieldDescription } from '../utils.js'\nimport { ColumnTypeResolver } from '../ColumnTypeResolver.js'\nimport { CreateEntityRelationInputProvider } from './CreateEntityRelationInputProvider.js'\nimport { Authorizator } from '../../acl/index.js'\n\nexport class CreateEntityInputFieldVisitor\n\timplements Model.ColumnVisitor<GraphQLInputFieldConfig | undefined>, Model.RelationByGenericTypeVisitor<GraphQLInputFieldConfig | undefined>\n{\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly createEntityRelationInputProvider: CreateEntityRelationInputProvider,\n\t) {}\n\n\tpublic visitColumn({ entity, column }: Model.ColumnContext): GraphQLInputFieldConfig | undefined {\n\t\tif (entity.primary === column.name && !this.authorizator.isCustomPrimaryAllowed(entity.name)) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (this.authorizator.getFieldPermissions(Acl.Operation.create, entity.name, column.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst [type] = this.columnTypeResolver.getType(column)\n\t\treturn {\n\t\t\ttype,\n\t\t\tdescription: inputFieldDescription(column),\n\t\t}\n\t}\n\n\tpublic visitHasOne({ entity, relation }: Model.AnyHasOneRelationContext): GraphQLInputFieldConfig | undefined {\n\t\tconst type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name)\n\t\tif (type === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype,\n\t\t\tdescription: inputFieldDescription(relation),\n\t\t}\n\t}\n\n\tpublic visitHasMany({ entity, relation }: Model.AnyHasManyRelationContext): GraphQLInputFieldConfig | undefined {\n\t\tconst type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name)\n\t\tif (type === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLList(new GraphQLNonNull(type)),\n\t\t\tdescription: inputFieldDescription(relation),\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;AAOO,MAAM,8BAEb;AAAA,EACC,YACkB,QACA,cACA,oBACA,mCAChB;AAJgB,SAAA,SAAA;AACA,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,oCAAA;AAAA,EACf;AAAA,EAEI,YAAY,EAAE,QAAQ,UAAoE;AAChG,QAAI,OAAO,YAAY,OAAO,QAAQ,CAAC,KAAK,aAAa,uBAAuB,OAAO,IAAI,GAAG;AAC7F,aAAO;AAAA,IACR;AACA,QAAI,KAAK,aAAa,oBAAoB,IAAI,UAAU,QAAQ,OAAO,MAAM,OAAO,IAAI,MAAM,MAAM;AACnG,aAAO;AAAA,IACR;AACA,UAAM,CAAC,IAAI,IAAI,KAAK,mBAAmB,QAAQ,MAAM;AACrD,WAAO;AAAA,MACN;AAAA,MACA,aAAa,sBAAsB,MAAM;AAAA,IAAA;AAAA,EAE3C;AAAA,EAEO,YAAY,EAAE,QAAQ,YAAiF;AAC7G,UAAM,OAAO,KAAK,kCAAkC,6BAA6B,OAAO,MAAM,SAAS,IAAI;AAC3G,QAAI,SAAS,QAAW;AACvB,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN;AAAA,MACA,aAAa,sBAAsB,QAAQ;AAAA,IAAA;AAAA,EAE7C;AAAA,EAEO,aAAa,EAAE,QAAQ,YAAkF;AAC/G,UAAM,OAAO,KAAK,kCAAkC,6BAA6B,OAAO,MAAM,SAAS,IAAI;AAC3G,QAAI,SAAS,QAAW;AACvB,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN,MAAM,IAAI,YAAY,IAAI,eAAe,IAAI,CAAC;AAAA,MAC9C,aAAa,sBAAsB,QAAQ;AAAA,IAAA;AAAA,EAE7C;AACD;"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const graphql = require("graphql");
4
4
  const schema = require("@contember/schema");
5
+ const utils = require("../utils.cjs");
5
6
  class UpdateEntityInputFieldVisitor {
6
7
  constructor(authorizator, columnTypeResolver, updateEntityRelationInputProvider) {
7
8
  this.authorizator = authorizator;
@@ -16,14 +17,20 @@ class UpdateEntityInputFieldVisitor {
16
17
  return void 0;
17
18
  }
18
19
  const [type] = this.columnTypeResolver.getType(column);
19
- return { type };
20
+ return {
21
+ type,
22
+ description: utils.inputFieldDescription(column)
23
+ };
20
24
  }
21
25
  visitHasOne({ entity, relation }) {
22
26
  const type = this.updateEntityRelationInputProvider.getUpdateEntityRelationInput(entity.name, relation.name);
23
27
  if (type === void 0) {
24
28
  return void 0;
25
29
  }
26
- return { type };
30
+ return {
31
+ type,
32
+ description: utils.inputFieldDescription(relation)
33
+ };
27
34
  }
28
35
  visitHasMany({ entity, relation }) {
29
36
  const type = this.updateEntityRelationInputProvider.getUpdateEntityRelationInput(entity.name, relation.name);
@@ -31,7 +38,8 @@ class UpdateEntityInputFieldVisitor {
31
38
  return void 0;
32
39
  }
33
40
  return {
34
- type: new graphql.GraphQLList(new graphql.GraphQLNonNull(type))
41
+ type: new graphql.GraphQLList(new graphql.GraphQLNonNull(type)),
42
+ description: utils.inputFieldDescription(relation)
35
43
  };
36
44
  }
37
45
  }