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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (385) hide show
  1. package/dist/development/index.cjs +3 -0
  2. package/dist/development/index.cjs.map +1 -1
  3. package/dist/development/index.js +4 -1
  4. package/dist/development/index.js.map +1 -1
  5. package/dist/development/src/ExecutionContainer.cjs +1 -0
  6. package/dist/development/src/ExecutionContainer.cjs.map +1 -1
  7. package/dist/development/src/ExecutionContainer.js +1 -0
  8. package/dist/development/src/ExecutionContainer.js.map +1 -1
  9. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs +2 -1
  10. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs.map +1 -1
  11. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js +2 -1
  12. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js.map +1 -1
  13. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +5 -1
  14. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
  15. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +5 -1
  16. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
  17. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs +2 -1
  18. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs.map +1 -1
  19. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js +2 -1
  20. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js.map +1 -1
  21. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs +4 -1
  22. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs.map +1 -1
  23. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +4 -1
  24. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js.map +1 -1
  25. package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs +24 -3
  26. package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs.map +1 -1
  27. package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js +24 -3
  28. package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map +1 -1
  29. package/dist/development/src/inputProcessing/UpdateInputVisitor.cjs +52 -2
  30. package/dist/development/src/inputProcessing/UpdateInputVisitor.cjs.map +1 -1
  31. package/dist/development/src/inputProcessing/UpdateInputVisitor.js +52 -2
  32. package/dist/development/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
  33. package/dist/development/src/mapper/ErrorUtils.cjs +10 -0
  34. package/dist/development/src/mapper/ErrorUtils.cjs.map +1 -1
  35. package/dist/development/src/mapper/ErrorUtils.js +10 -0
  36. package/dist/development/src/mapper/ErrorUtils.js.map +1 -1
  37. package/dist/development/src/mapper/Mapper.cjs +37 -1
  38. package/dist/development/src/mapper/Mapper.cjs.map +1 -1
  39. package/dist/development/src/mapper/Mapper.js +38 -2
  40. package/dist/development/src/mapper/Mapper.js.map +1 -1
  41. package/dist/development/src/mapper/MutationProcessorHelper.cjs +12 -0
  42. package/dist/development/src/mapper/MutationProcessorHelper.cjs.map +1 -1
  43. package/dist/development/src/mapper/MutationProcessorHelper.js +13 -1
  44. package/dist/development/src/mapper/MutationProcessorHelper.js.map +1 -1
  45. package/dist/development/src/mapper/Result.cjs +1 -0
  46. package/dist/development/src/mapper/Result.cjs.map +1 -1
  47. package/dist/development/src/mapper/Result.js +1 -0
  48. package/dist/development/src/mapper/Result.js.map +1 -1
  49. package/dist/development/src/mapper/delete/DeleteExecutor.cjs +1 -1
  50. package/dist/development/src/mapper/delete/DeleteExecutor.js +1 -1
  51. package/dist/development/src/mapper/select/handlers/MetaHandler.cjs +1 -1
  52. package/dist/development/src/mapper/select/handlers/MetaHandler.js +1 -1
  53. package/dist/development/src/mapper/select/optimizer/WhereOptimizer.cjs +2 -2
  54. package/dist/development/src/mapper/select/optimizer/WhereOptimizer.cjs.map +1 -1
  55. package/dist/development/src/mapper/select/optimizer/WhereOptimizer.js +1 -1
  56. package/dist/development/src/mapper/select/optimizer/WhereOptimizer.js.map +1 -1
  57. package/dist/development/src/mapper/select/optimizer/WhereReplacer.cjs +3 -3
  58. package/dist/development/src/mapper/select/optimizer/WhereReplacer.cjs.map +1 -1
  59. package/dist/development/src/mapper/select/optimizer/WhereReplacer.js +1 -1
  60. package/dist/development/src/mapper/select/optimizer/WhereReplacer.js.map +1 -1
  61. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.cjs +6 -3
  62. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
  63. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.js +7 -4
  64. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
  65. package/dist/development/src/mapper/update/Updater.cjs +1 -1
  66. package/dist/development/src/mapper/update/Updater.js +1 -1
  67. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs +6 -0
  68. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -1
  69. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js +6 -0
  70. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -1
  71. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs +6 -0
  72. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -1
  73. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js +6 -0
  74. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -1
  75. package/dist/development/src/mapper/update/relations/SetManyRelationHelper.cjs +123 -0
  76. package/dist/development/src/mapper/update/relations/SetManyRelationHelper.cjs.map +1 -0
  77. package/dist/development/src/mapper/update/relations/SetManyRelationHelper.js +123 -0
  78. package/dist/development/src/mapper/update/relations/SetManyRelationHelper.js.map +1 -0
  79. package/dist/development/src/resolvers/MutationResolver.cjs +4 -1
  80. package/dist/development/src/resolvers/MutationResolver.cjs.map +1 -1
  81. package/dist/development/src/resolvers/MutationResolver.js +4 -1
  82. package/dist/development/src/resolvers/MutationResolver.js.map +1 -1
  83. package/dist/development/src/resolvers/ReadHelpers.cjs +2 -1
  84. package/dist/development/src/resolvers/ReadHelpers.cjs.map +1 -1
  85. package/dist/development/src/resolvers/ReadHelpers.js +2 -1
  86. package/dist/development/src/resolvers/ReadHelpers.js.map +1 -1
  87. package/dist/development/src/schema/CustomTypesProvider.cjs +35 -14
  88. package/dist/development/src/schema/CustomTypesProvider.cjs.map +1 -1
  89. package/dist/development/src/schema/CustomTypesProvider.js +36 -15
  90. package/dist/development/src/schema/CustomTypesProvider.js.map +1 -1
  91. package/dist/development/src/schema/EntityTypeProvider.cjs +8 -5
  92. package/dist/development/src/schema/EntityTypeProvider.cjs.map +1 -1
  93. package/dist/development/src/schema/EntityTypeProvider.js +8 -5
  94. package/dist/development/src/schema/EntityTypeProvider.js.map +1 -1
  95. package/dist/development/src/schema/GraphQlSchemaBuilderFactory.cjs +1 -1
  96. package/dist/development/src/schema/GraphQlSchemaBuilderFactory.js +1 -1
  97. package/dist/development/src/schema/MutationProvider.cjs +4 -0
  98. package/dist/development/src/schema/MutationProvider.cjs.map +1 -1
  99. package/dist/development/src/schema/MutationProvider.js +4 -0
  100. package/dist/development/src/schema/MutationProvider.js.map +1 -1
  101. package/dist/development/src/schema/OrderByTypeProvider.cjs +8 -2
  102. package/dist/development/src/schema/OrderByTypeProvider.cjs.map +1 -1
  103. package/dist/development/src/schema/OrderByTypeProvider.js +9 -3
  104. package/dist/development/src/schema/OrderByTypeProvider.js.map +1 -1
  105. package/dist/development/src/schema/QueryProvider.cjs +3 -0
  106. package/dist/development/src/schema/QueryProvider.cjs.map +1 -1
  107. package/dist/development/src/schema/QueryProvider.js +3 -0
  108. package/dist/development/src/schema/QueryProvider.js.map +1 -1
  109. package/dist/development/src/schema/ValidationQueriesProvider.cjs +2 -0
  110. package/dist/development/src/schema/ValidationQueriesProvider.cjs.map +1 -1
  111. package/dist/development/src/schema/ValidationQueriesProvider.js +2 -0
  112. package/dist/development/src/schema/ValidationQueriesProvider.js.map +1 -1
  113. package/dist/development/src/schema/WhereTypeProvider.cjs +17 -5
  114. package/dist/development/src/schema/WhereTypeProvider.cjs.map +1 -1
  115. package/dist/development/src/schema/WhereTypeProvider.js +18 -6
  116. package/dist/development/src/schema/WhereTypeProvider.js.map +1 -1
  117. package/dist/development/src/schema/calendarDate.cjs +21 -0
  118. package/dist/development/src/schema/calendarDate.cjs.map +1 -0
  119. package/dist/development/src/schema/calendarDate.js +21 -0
  120. package/dist/development/src/schema/calendarDate.js.map +1 -0
  121. package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.cjs +11 -3
  122. package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.cjs.map +1 -1
  123. package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.js +11 -3
  124. package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.js.map +1 -1
  125. package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs +11 -3
  126. package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs.map +1 -1
  127. package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.js +11 -3
  128. package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.js.map +1 -1
  129. package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs +39 -2
  130. package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs.map +1 -1
  131. package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js +40 -3
  132. package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js.map +1 -1
  133. package/dist/development/src/schema/utils.cjs +10 -0
  134. package/dist/development/src/schema/utils.cjs.map +1 -1
  135. package/dist/development/src/schema/utils.js +11 -1
  136. package/dist/development/src/schema/utils.js.map +1 -1
  137. package/dist/production/index.cjs +3 -0
  138. package/dist/production/index.cjs.map +1 -1
  139. package/dist/production/index.js +4 -1
  140. package/dist/production/index.js.map +1 -1
  141. package/dist/production/src/ExecutionContainer.cjs +1 -0
  142. package/dist/production/src/ExecutionContainer.cjs.map +1 -1
  143. package/dist/production/src/ExecutionContainer.js +1 -0
  144. package/dist/production/src/ExecutionContainer.js.map +1 -1
  145. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs +2 -1
  146. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs.map +1 -1
  147. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js +2 -1
  148. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js.map +1 -1
  149. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +5 -1
  150. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
  151. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +5 -1
  152. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
  153. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs +2 -1
  154. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs.map +1 -1
  155. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js +2 -1
  156. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js.map +1 -1
  157. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs +4 -1
  158. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs.map +1 -1
  159. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +4 -1
  160. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js.map +1 -1
  161. package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs +24 -3
  162. package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs.map +1 -1
  163. package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js +24 -3
  164. package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map +1 -1
  165. package/dist/production/src/inputProcessing/UpdateInputVisitor.cjs +52 -2
  166. package/dist/production/src/inputProcessing/UpdateInputVisitor.cjs.map +1 -1
  167. package/dist/production/src/inputProcessing/UpdateInputVisitor.js +52 -2
  168. package/dist/production/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
  169. package/dist/production/src/mapper/ErrorUtils.cjs +10 -0
  170. package/dist/production/src/mapper/ErrorUtils.cjs.map +1 -1
  171. package/dist/production/src/mapper/ErrorUtils.js +10 -0
  172. package/dist/production/src/mapper/ErrorUtils.js.map +1 -1
  173. package/dist/production/src/mapper/Mapper.cjs +37 -1
  174. package/dist/production/src/mapper/Mapper.cjs.map +1 -1
  175. package/dist/production/src/mapper/Mapper.js +38 -2
  176. package/dist/production/src/mapper/Mapper.js.map +1 -1
  177. package/dist/production/src/mapper/MutationProcessorHelper.cjs +12 -0
  178. package/dist/production/src/mapper/MutationProcessorHelper.cjs.map +1 -1
  179. package/dist/production/src/mapper/MutationProcessorHelper.js +13 -1
  180. package/dist/production/src/mapper/MutationProcessorHelper.js.map +1 -1
  181. package/dist/production/src/mapper/Result.cjs +1 -0
  182. package/dist/production/src/mapper/Result.cjs.map +1 -1
  183. package/dist/production/src/mapper/Result.js +1 -0
  184. package/dist/production/src/mapper/Result.js.map +1 -1
  185. package/dist/production/src/mapper/delete/DeleteExecutor.cjs +1 -1
  186. package/dist/production/src/mapper/delete/DeleteExecutor.js +1 -1
  187. package/dist/production/src/mapper/select/handlers/MetaHandler.cjs +1 -1
  188. package/dist/production/src/mapper/select/handlers/MetaHandler.js +1 -1
  189. package/dist/production/src/mapper/select/optimizer/WhereOptimizer.cjs +2 -2
  190. package/dist/production/src/mapper/select/optimizer/WhereOptimizer.cjs.map +1 -1
  191. package/dist/production/src/mapper/select/optimizer/WhereOptimizer.js +1 -1
  192. package/dist/production/src/mapper/select/optimizer/WhereOptimizer.js.map +1 -1
  193. package/dist/production/src/mapper/select/optimizer/WhereReplacer.cjs +3 -3
  194. package/dist/production/src/mapper/select/optimizer/WhereReplacer.cjs.map +1 -1
  195. package/dist/production/src/mapper/select/optimizer/WhereReplacer.js +1 -1
  196. package/dist/production/src/mapper/select/optimizer/WhereReplacer.js.map +1 -1
  197. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.cjs +6 -3
  198. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
  199. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.js +7 -4
  200. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
  201. package/dist/production/src/mapper/update/Updater.cjs +1 -1
  202. package/dist/production/src/mapper/update/Updater.js +1 -1
  203. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs +6 -0
  204. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -1
  205. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js +6 -0
  206. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -1
  207. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs +6 -0
  208. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -1
  209. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js +6 -0
  210. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -1
  211. package/dist/production/src/mapper/update/relations/SetManyRelationHelper.cjs +123 -0
  212. package/dist/production/src/mapper/update/relations/SetManyRelationHelper.cjs.map +1 -0
  213. package/dist/production/src/mapper/update/relations/SetManyRelationHelper.js +123 -0
  214. package/dist/production/src/mapper/update/relations/SetManyRelationHelper.js.map +1 -0
  215. package/dist/production/src/resolvers/MutationResolver.cjs +4 -1
  216. package/dist/production/src/resolvers/MutationResolver.cjs.map +1 -1
  217. package/dist/production/src/resolvers/MutationResolver.js +4 -1
  218. package/dist/production/src/resolvers/MutationResolver.js.map +1 -1
  219. package/dist/production/src/resolvers/ReadHelpers.cjs +2 -1
  220. package/dist/production/src/resolvers/ReadHelpers.cjs.map +1 -1
  221. package/dist/production/src/resolvers/ReadHelpers.js +2 -1
  222. package/dist/production/src/resolvers/ReadHelpers.js.map +1 -1
  223. package/dist/production/src/schema/CustomTypesProvider.cjs +35 -14
  224. package/dist/production/src/schema/CustomTypesProvider.cjs.map +1 -1
  225. package/dist/production/src/schema/CustomTypesProvider.js +36 -15
  226. package/dist/production/src/schema/CustomTypesProvider.js.map +1 -1
  227. package/dist/production/src/schema/EntityTypeProvider.cjs +8 -5
  228. package/dist/production/src/schema/EntityTypeProvider.cjs.map +1 -1
  229. package/dist/production/src/schema/EntityTypeProvider.js +8 -5
  230. package/dist/production/src/schema/EntityTypeProvider.js.map +1 -1
  231. package/dist/production/src/schema/GraphQlSchemaBuilderFactory.cjs +1 -1
  232. package/dist/production/src/schema/GraphQlSchemaBuilderFactory.js +1 -1
  233. package/dist/production/src/schema/MutationProvider.cjs +4 -0
  234. package/dist/production/src/schema/MutationProvider.cjs.map +1 -1
  235. package/dist/production/src/schema/MutationProvider.js +4 -0
  236. package/dist/production/src/schema/MutationProvider.js.map +1 -1
  237. package/dist/production/src/schema/OrderByTypeProvider.cjs +8 -2
  238. package/dist/production/src/schema/OrderByTypeProvider.cjs.map +1 -1
  239. package/dist/production/src/schema/OrderByTypeProvider.js +9 -3
  240. package/dist/production/src/schema/OrderByTypeProvider.js.map +1 -1
  241. package/dist/production/src/schema/QueryProvider.cjs +3 -0
  242. package/dist/production/src/schema/QueryProvider.cjs.map +1 -1
  243. package/dist/production/src/schema/QueryProvider.js +3 -0
  244. package/dist/production/src/schema/QueryProvider.js.map +1 -1
  245. package/dist/production/src/schema/ValidationQueriesProvider.cjs +2 -0
  246. package/dist/production/src/schema/ValidationQueriesProvider.cjs.map +1 -1
  247. package/dist/production/src/schema/ValidationQueriesProvider.js +2 -0
  248. package/dist/production/src/schema/ValidationQueriesProvider.js.map +1 -1
  249. package/dist/production/src/schema/WhereTypeProvider.cjs +17 -5
  250. package/dist/production/src/schema/WhereTypeProvider.cjs.map +1 -1
  251. package/dist/production/src/schema/WhereTypeProvider.js +18 -6
  252. package/dist/production/src/schema/WhereTypeProvider.js.map +1 -1
  253. package/dist/production/src/schema/calendarDate.cjs +21 -0
  254. package/dist/production/src/schema/calendarDate.cjs.map +1 -0
  255. package/dist/production/src/schema/calendarDate.js +21 -0
  256. package/dist/production/src/schema/calendarDate.js.map +1 -0
  257. package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.cjs +11 -3
  258. package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.cjs.map +1 -1
  259. package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.js +11 -3
  260. package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.js.map +1 -1
  261. package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs +11 -3
  262. package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs.map +1 -1
  263. package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.js +11 -3
  264. package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.js.map +1 -1
  265. package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs +39 -2
  266. package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs.map +1 -1
  267. package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js +40 -3
  268. package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js.map +1 -1
  269. package/dist/production/src/schema/utils.cjs +10 -0
  270. package/dist/production/src/schema/utils.cjs.map +1 -1
  271. package/dist/production/src/schema/utils.js +11 -1
  272. package/dist/production/src/schema/utils.js.map +1 -1
  273. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/set.test.d.ts +2 -0
  274. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/set.test.d.ts.map +1 -0
  275. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/set.test.d.ts +2 -0
  276. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/set.test.d.ts.map +1 -0
  277. package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/set.test.d.ts +2 -0
  278. package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/set.test.d.ts.map +1 -0
  279. package/dist/tests/cases/unit/checkViolationError.test.d.ts +2 -0
  280. package/dist/tests/cases/unit/checkViolationError.test.d.ts.map +1 -0
  281. package/dist/tests/cases/unit/dateType.test.d.ts +2 -0
  282. package/dist/tests/cases/unit/dateType.test.d.ts.map +1 -0
  283. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  284. package/dist/types/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.d.ts.map +1 -1
  285. package/dist/types/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.d.ts.map +1 -1
  286. package/dist/types/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts +6 -0
  287. package/dist/types/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts.map +1 -1
  288. package/dist/types/inputProcessing/UpdateInputProcessor.d.ts +7 -0
  289. package/dist/types/inputProcessing/UpdateInputProcessor.d.ts.map +1 -1
  290. package/dist/types/inputProcessing/UpdateInputVisitor.d.ts +2 -0
  291. package/dist/types/inputProcessing/UpdateInputVisitor.d.ts.map +1 -1
  292. package/dist/types/mapper/ErrorUtils.d.ts.map +1 -1
  293. package/dist/types/mapper/Mapper.d.ts +5 -0
  294. package/dist/types/mapper/Mapper.d.ts.map +1 -1
  295. package/dist/types/mapper/MutationProcessorHelper.d.ts +3 -0
  296. package/dist/types/mapper/MutationProcessorHelper.d.ts.map +1 -1
  297. package/dist/types/mapper/Result.d.ts +2 -1
  298. package/dist/types/mapper/Result.d.ts.map +1 -1
  299. package/dist/types/mapper/types.d.ts +8 -1
  300. package/dist/types/mapper/types.d.ts.map +1 -1
  301. package/dist/types/mapper/update/SqlUpdateInputProcessor.d.ts.map +1 -1
  302. package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts +5 -0
  303. package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts.map +1 -1
  304. package/dist/types/mapper/update/relations/OneHasManyUpdateInputProcessor.d.ts +5 -0
  305. package/dist/types/mapper/update/relations/OneHasManyUpdateInputProcessor.d.ts.map +1 -1
  306. package/dist/types/mapper/update/relations/SetManyRelationHelper.d.ts +67 -0
  307. package/dist/types/mapper/update/relations/SetManyRelationHelper.d.ts.map +1 -0
  308. package/dist/types/resolvers/MutationResolver.d.ts.map +1 -1
  309. package/dist/types/schema/CustomTypesProvider.d.ts.map +1 -1
  310. package/dist/types/schema/EntityTypeProvider.d.ts.map +1 -1
  311. package/dist/types/schema/MutationProvider.d.ts.map +1 -1
  312. package/dist/types/schema/OrderByTypeProvider.d.ts.map +1 -1
  313. package/dist/types/schema/QueryProvider.d.ts.map +1 -1
  314. package/dist/types/schema/ValidationQueriesProvider.d.ts.map +1 -1
  315. package/dist/types/schema/WhereTypeProvider.d.ts.map +1 -1
  316. package/dist/types/schema/calendarDate.d.ts +6 -0
  317. package/dist/types/schema/calendarDate.d.ts.map +1 -0
  318. package/dist/types/schema/index.d.ts +1 -0
  319. package/dist/types/schema/index.d.ts.map +1 -1
  320. package/dist/types/schema/mutations/CreateEntityInputFieldVisitor.d.ts.map +1 -1
  321. package/dist/types/schema/mutations/UpdateEntityInputFieldVisitor.d.ts +3 -0
  322. package/dist/types/schema/mutations/UpdateEntityInputFieldVisitor.d.ts.map +1 -1
  323. package/dist/types/schema/mutations/UpdateEntityRelationInputFieldVisitor.d.ts +1 -0
  324. package/dist/types/schema/mutations/UpdateEntityRelationInputFieldVisitor.d.ts.map +1 -1
  325. package/dist/types/schema/utils.d.ts +7 -0
  326. package/dist/types/schema/utils.d.ts.map +1 -1
  327. package/dist/types/tsconfig.tsbuildinfo +1 -1
  328. package/package.json +10 -10
  329. package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts +3 -0
  330. package/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.ts +9 -7
  331. package/src/input-validation/preValidation/UpdateInputPreValidationProcessor.ts +29 -0
  332. package/src/inputProcessing/UpdateInputProcessor.ts +6 -0
  333. package/src/inputProcessing/UpdateInputVisitor.ts +64 -2
  334. package/src/mapper/ErrorUtils.ts +11 -0
  335. package/src/mapper/Mapper.ts +61 -1
  336. package/src/mapper/MutationProcessorHelper.ts +14 -0
  337. package/src/mapper/Result.ts +1 -0
  338. package/src/mapper/select/optimizer/WhereOptimizer.ts +1 -1
  339. package/src/mapper/select/optimizer/WhereReplacer.ts +1 -1
  340. package/src/mapper/types.ts +16 -1
  341. package/src/mapper/update/SqlUpdateInputProcessor.ts +4 -1
  342. package/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.ts +9 -0
  343. package/src/mapper/update/relations/OneHasManyUpdateInputProcessor.ts +9 -0
  344. package/src/mapper/update/relations/SetManyRelationHelper.ts +199 -0
  345. package/src/resolvers/MutationResolver.ts +2 -0
  346. package/src/schema/CustomTypesProvider.ts +40 -15
  347. package/src/schema/EntityTypeProvider.ts +8 -4
  348. package/src/schema/MutationProvider.ts +4 -0
  349. package/src/schema/OrderByTypeProvider.ts +9 -3
  350. package/src/schema/QueryProvider.ts +3 -0
  351. package/src/schema/ValidationQueriesProvider.ts +2 -0
  352. package/src/schema/WhereTypeProvider.ts +18 -6
  353. package/src/schema/calendarDate.ts +26 -0
  354. package/src/schema/index.ts +1 -0
  355. package/src/schema/mutations/CreateEntityInputFieldVisitor.ts +10 -2
  356. package/src/schema/mutations/UpdateEntityInputFieldVisitor.ts +10 -2
  357. package/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.ts +66 -7
  358. package/src/schema/utils.ts +14 -0
  359. package/src/tsconfig.json +2 -1
  360. package/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/set.test.ts +219 -0
  361. package/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/set.test.ts +479 -0
  362. package/tests/cases/integration/graphQlRequests/update/oneHasMany/set.test.ts +948 -0
  363. package/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.ts +102 -1
  364. package/tests/cases/integration/graphQlSchema/schema-acl-allowed.gql +17 -0
  365. package/tests/cases/integration/graphQlSchema/schema-acl-create-only.gql +1 -0
  366. package/tests/cases/integration/graphQlSchema/schema-acl-restricted-create.gql +14 -0
  367. package/tests/cases/integration/graphQlSchema/schema-acl-restricted-delete.gql +11 -0
  368. package/tests/cases/integration/graphQlSchema/schema-acl-restricted-read.gql +254 -0
  369. package/tests/cases/integration/graphQlSchema/schema-acl-restricted-update.gql +1 -0
  370. package/tests/cases/integration/graphQlSchema/schema-acl.gql +1 -0
  371. package/tests/cases/integration/graphQlSchema/schema-aliased-type.gql +1 -0
  372. package/tests/cases/integration/graphQlSchema/schema-array.gql +1 -0
  373. package/tests/cases/integration/graphQlSchema/schema-basic.gql +50 -0
  374. package/tests/cases/integration/graphQlSchema/schema-bug-66.gql +17 -0
  375. package/tests/cases/integration/graphQlSchema/schema-column-types.gql +1 -0
  376. package/tests/cases/integration/graphQlSchema/schema-custom-primary.gql +50 -0
  377. package/tests/cases/integration/graphQlSchema/schema-deprecation.gql +962 -0
  378. package/tests/cases/integration/graphQlSchema/schema-description.gql +992 -0
  379. package/tests/cases/integration/graphQlSchema/schema-has-many-reduction.gql +17 -0
  380. package/tests/cases/integration/graphQlSchema/schema-mixed-root-through.gql +1 -0
  381. package/tests/cases/integration/graphQlSchema/schema-new-builder.gql +50 -0
  382. package/tests/cases/integration/graphQlSchema/schema-no-root-ops.gql +1 -0
  383. package/tests/cases/unit/checkViolationError.test.ts +49 -0
  384. package/tests/cases/unit/dateType.test.ts +46 -0
  385. package/tests/cases/unit/decimalType.test.ts +2 -2
@@ -5,11 +5,12 @@ import "@contember/schema-utils";
5
5
  import "@contember/schema";
6
6
  import { ObjectNode } from "../inputProcessing/ObjectNode.js";
7
7
  import "graphql";
8
+ import "../schema/mutations/UpdateEntityRelationInputFieldVisitor.js";
8
9
  import "@contember/graphql-utils";
9
10
  import { readOperationMeta, Operation } from "../schema/OperationExtension.js";
10
11
  import "../extensions/hasManyToHasOneReducer/HasManyToHasOneReducer.js";
11
12
  import "@contember/database";
12
- import "fast-deep-equal";
13
+ import "@contember/utilities";
13
14
  import "../acl/PredicatesInjector.js";
14
15
  import "node:crypto";
15
16
  import "../mapper/select/Path.js";
@@ -1 +1 @@
1
- {"version":3,"file":"ReadHelpers.js","sources":["../../../../../packages/engine-content-api/src/resolvers/ReadHelpers.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { Mapper } from '../mapper/index.js'\nimport { ObjectNode } from '../inputProcessing/index.js'\nimport { assertNever, createPaginationHelper } from '../utils/index.js'\nimport { ImplementationException } from '../exception.js'\nimport { Operation, readOperationMeta } from '../schema/index.js'\nimport { GraphQLFieldMap } from 'graphql'\n\nexport const paginate = async (\n\tmapper: Mapper,\n\tentity: Model.Entity,\n\tqueryAst: ObjectNode<Input.PaginationQueryInput>,\n) => {\n\tconst paginationHelper = createPaginationHelper(queryAst)\n\tconst totalCount = paginationHelper.requiresTotalCount\n\t\t? await mapper.count(entity, queryAst.args.filter || {}, 'root')\n\t\t: undefined\n\tconst nodes = paginationHelper.nodeField ? await mapper.select(entity, paginationHelper.nodeField, []) : undefined\n\n\treturn paginationHelper.createResponse(totalCount, nodes)\n}\n\nexport const executeReadOperations = async (\n\tqueryAst: ObjectNode,\n\tfields: GraphQLFieldMap<any, any>,\n\tmapper: Mapper,\n): Promise<Record<string, any>> => {\n\tconst trxResult: Record<string, any> = {}\n\n\t// todo execute in parallel\n\tfor (const field of queryAst.fields) {\n\t\tif (!(field instanceof ObjectNode)) {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\tconst fieldConfig = fields[field.name]\n\t\tconst meta = readOperationMeta(fieldConfig.extensions)\n\t\ttrxResult[field.alias] = await (() => {\n\t\t\tswitch (meta.operation) {\n\t\t\t\tcase Operation.get:\n\t\t\t\t\treturn mapper.selectUnique(meta.entity, field, [])\n\t\t\t\tcase Operation.list:\n\t\t\t\t\treturn mapper.select(meta.entity, field, [])\n\t\t\t\tcase Operation.paginate:\n\t\t\t\t\treturn paginate(mapper, meta.entity, field)\n\t\t\t\tcase Operation.create:\n\t\t\t\tcase Operation.update:\n\t\t\t\tcase Operation.delete:\n\t\t\t\tcase Operation.upsert:\n\t\t\t\t\tthrow new ImplementationException()\n\t\t\t}\n\t\t\treturn assertNever(meta.operation)\n\t\t})()\n\t}\n\treturn trxResult\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM,WAAW,OACvB,QACA,QACA,aACI;AACJ,QAAM,mBAAmB,uBAAuB,QAAQ;AACxD,QAAM,aAAa,iBAAiB,qBACjC,MAAM,OAAO,MAAM,QAAQ,SAAS,KAAK,UAAU,CAAA,GAAI,MAAM,IAC7D;AACH,QAAM,QAAQ,iBAAiB,YAAY,MAAM,OAAO,OAAO,QAAQ,iBAAiB,WAAW,CAAA,CAAE,IAAI;AAEzG,SAAO,iBAAiB,eAAe,YAAY,KAAK;AACzD;AAEO,MAAM,wBAAwB,OACpC,UACA,QACA,WACkC;AAClC,QAAM,YAAiC,CAAA;AAGvC,aAAW,SAAS,SAAS,QAAQ;AACpC,QAAI,EAAE,iBAAiB,aAAa;AACnC,YAAM,IAAI,wBAAA;AAAA,IACX;AACA,UAAM,cAAc,OAAO,MAAM,IAAI;AACrC,UAAM,OAAO,kBAAkB,YAAY,UAAU;AACrD,cAAU,MAAM,KAAK,IAAI,OAAO,MAAM;AACrC,cAAQ,KAAK,WAAA;AAAA,QACZ,KAAK,UAAU;AACd,iBAAO,OAAO,aAAa,KAAK,QAAQ,OAAO,CAAA,CAAE;AAAA,QAClD,KAAK,UAAU;AACd,iBAAO,OAAO,OAAO,KAAK,QAAQ,OAAO,CAAA,CAAE;AAAA,QAC5C,KAAK,UAAU;AACd,iBAAO,SAAS,QAAQ,KAAK,QAAQ,KAAK;AAAA,QAC3C,KAAK,UAAU;AAAA,QACf,KAAK,UAAU;AAAA,QACf,KAAK,UAAU;AAAA,QACf,KAAK,UAAU;AACd,gBAAM,IAAI,wBAAA;AAAA,MAAwB;AAEpC,aAAO,YAAY,KAAK,SAAS;AAAA,IAClC,GAAA;AAAA,EACD;AACA,SAAO;AACR;"}
1
+ {"version":3,"file":"ReadHelpers.js","sources":["../../../../../packages/engine-content-api/src/resolvers/ReadHelpers.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { Mapper } from '../mapper/index.js'\nimport { ObjectNode } from '../inputProcessing/index.js'\nimport { assertNever, createPaginationHelper } from '../utils/index.js'\nimport { ImplementationException } from '../exception.js'\nimport { Operation, readOperationMeta } from '../schema/index.js'\nimport { GraphQLFieldMap } from 'graphql'\n\nexport const paginate = async (\n\tmapper: Mapper,\n\tentity: Model.Entity,\n\tqueryAst: ObjectNode<Input.PaginationQueryInput>,\n) => {\n\tconst paginationHelper = createPaginationHelper(queryAst)\n\tconst totalCount = paginationHelper.requiresTotalCount\n\t\t? await mapper.count(entity, queryAst.args.filter || {}, 'root')\n\t\t: undefined\n\tconst nodes = paginationHelper.nodeField ? await mapper.select(entity, paginationHelper.nodeField, []) : undefined\n\n\treturn paginationHelper.createResponse(totalCount, nodes)\n}\n\nexport const executeReadOperations = async (\n\tqueryAst: ObjectNode,\n\tfields: GraphQLFieldMap<any, any>,\n\tmapper: Mapper,\n): Promise<Record<string, any>> => {\n\tconst trxResult: Record<string, any> = {}\n\n\t// todo execute in parallel\n\tfor (const field of queryAst.fields) {\n\t\tif (!(field instanceof ObjectNode)) {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\tconst fieldConfig = fields[field.name]\n\t\tconst meta = readOperationMeta(fieldConfig.extensions)\n\t\ttrxResult[field.alias] = await (() => {\n\t\t\tswitch (meta.operation) {\n\t\t\t\tcase Operation.get:\n\t\t\t\t\treturn mapper.selectUnique(meta.entity, field, [])\n\t\t\t\tcase Operation.list:\n\t\t\t\t\treturn mapper.select(meta.entity, field, [])\n\t\t\t\tcase Operation.paginate:\n\t\t\t\t\treturn paginate(mapper, meta.entity, field)\n\t\t\t\tcase Operation.create:\n\t\t\t\tcase Operation.update:\n\t\t\t\tcase Operation.delete:\n\t\t\t\tcase Operation.upsert:\n\t\t\t\t\tthrow new ImplementationException()\n\t\t\t}\n\t\t\treturn assertNever(meta.operation)\n\t\t})()\n\t}\n\treturn trxResult\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM,WAAW,OACvB,QACA,QACA,aACI;AACJ,QAAM,mBAAmB,uBAAuB,QAAQ;AACxD,QAAM,aAAa,iBAAiB,qBACjC,MAAM,OAAO,MAAM,QAAQ,SAAS,KAAK,UAAU,CAAA,GAAI,MAAM,IAC7D;AACH,QAAM,QAAQ,iBAAiB,YAAY,MAAM,OAAO,OAAO,QAAQ,iBAAiB,WAAW,CAAA,CAAE,IAAI;AAEzG,SAAO,iBAAiB,eAAe,YAAY,KAAK;AACzD;AAEO,MAAM,wBAAwB,OACpC,UACA,QACA,WACkC;AAClC,QAAM,YAAiC,CAAA;AAGvC,aAAW,SAAS,SAAS,QAAQ;AACpC,QAAI,EAAE,iBAAiB,aAAa;AACnC,YAAM,IAAI,wBAAA;AAAA,IACX;AACA,UAAM,cAAc,OAAO,MAAM,IAAI;AACrC,UAAM,OAAO,kBAAkB,YAAY,UAAU;AACrD,cAAU,MAAM,KAAK,IAAI,OAAO,MAAM;AACrC,cAAQ,KAAK,WAAA;AAAA,QACZ,KAAK,UAAU;AACd,iBAAO,OAAO,aAAa,KAAK,QAAQ,OAAO,CAAA,CAAE;AAAA,QAClD,KAAK,UAAU;AACd,iBAAO,OAAO,OAAO,KAAK,QAAQ,OAAO,CAAA,CAAE;AAAA,QAC5C,KAAK,UAAU;AACd,iBAAO,SAAS,QAAQ,KAAK,QAAQ,KAAK;AAAA,QAC3C,KAAK,UAAU;AAAA,QACf,KAAK,UAAU;AAAA,QACf,KAAK,UAAU;AAAA,QACf,KAAK,UAAU;AACd,gBAAM,IAAI,wBAAA;AAAA,MAAwB;AAEpC,aAAO,YAAY,KAAK,SAAS;AAAA,IAClC,GAAA;AAAA,EACD;AACA,SAAO;AACR;"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const graphql = require("graphql");
4
4
  const graphqlUtils = require("@contember/graphql-utils");
5
+ const calendarDate = require("./calendarDate.cjs");
5
6
  var __defProp = Object.defineProperty;
6
7
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
8
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -36,15 +37,31 @@ function validateTime(value) {
36
37
  const fraction = match[4] ? `.${match[4]}` : "";
37
38
  return `${hours}:${minutes}:${seconds}${fraction}`;
38
39
  }
40
+ function validateCalendarDate(value) {
41
+ if (calendarDate.isImpossibleCalendarDate(value)) {
42
+ throw new TypeError(`Value is not a valid date: ${value}`);
43
+ }
44
+ return value;
45
+ }
46
+ function parseInput(parse, node) {
47
+ try {
48
+ return parse();
49
+ } catch (error) {
50
+ if (error instanceof TypeError) {
51
+ throw new graphql.GraphQLError(error.message, { nodes: node });
52
+ }
53
+ throw error;
54
+ }
55
+ }
39
56
  class CustomTypesProvider {
40
57
  constructor() {
41
58
  __publicField(this, "uuidType", graphqlUtils.UuidType);
42
59
  __publicField(this, "dateType", new graphql.GraphQLScalarType({
43
60
  name: "Date",
44
61
  serialize: (str) => String(str),
45
- parseValue: (str) => String(str),
62
+ parseValue: (str) => parseInput(() => validateCalendarDate(String(str))),
46
63
  parseLiteral: function parseLiteral(ast) {
47
- return ast.kind === graphql.Kind.STRING ? ast.value : void 0;
64
+ return ast.kind === graphql.Kind.STRING ? parseInput(() => validateCalendarDate(ast.value), ast) : void 0;
48
65
  }
49
66
  }));
50
67
  __publicField(this, "timeType", new graphql.GraphQLScalarType({
@@ -53,21 +70,23 @@ class CustomTypesProvider {
53
70
  return validateTime(value);
54
71
  },
55
72
  parseValue(value) {
56
- return validateTime(value);
73
+ return parseInput(() => validateTime(value));
57
74
  },
58
75
  parseLiteral(ast) {
59
- if (ast.kind !== graphql.Kind.STRING) {
60
- throw new TypeError(`Time scalar can only parse string values, got: ${ast.kind}`);
61
- }
62
- return validateTime(ast.value);
76
+ return parseInput(() => {
77
+ if (ast.kind !== graphql.Kind.STRING) {
78
+ throw new TypeError(`Time scalar can only parse string values, got: ${ast.kind}`);
79
+ }
80
+ return validateTime(ast.value);
81
+ }, ast);
63
82
  }
64
83
  }));
65
84
  __publicField(this, "dateTimeType", new graphql.GraphQLScalarType({
66
85
  name: "DateTime",
67
86
  serialize: (str) => String(str),
68
- parseValue: (str) => String(str),
87
+ parseValue: (str) => parseInput(() => validateCalendarDate(String(str))),
69
88
  parseLiteral: function parseLiteral(ast) {
70
- return ast.kind === graphql.Kind.STRING ? ast.value : void 0;
89
+ return ast.kind === graphql.Kind.STRING ? parseInput(() => validateCalendarDate(ast.value), ast) : void 0;
71
90
  }
72
91
  }));
73
92
  __publicField(this, "jsonType", graphqlUtils.JSONType);
@@ -78,13 +97,15 @@ class CustomTypesProvider {
78
97
  return validateDecimal(value);
79
98
  },
80
99
  parseValue(value) {
81
- return validateDecimal(value);
100
+ return parseInput(() => validateDecimal(value));
82
101
  },
83
102
  parseLiteral(ast) {
84
- if (ast.kind === graphql.Kind.STRING || ast.kind === graphql.Kind.INT || ast.kind === graphql.Kind.FLOAT) {
85
- return validateDecimal(ast.value);
86
- }
87
- throw new TypeError(`Decimal scalar can only parse string or numeric values, got: ${ast.kind}`);
103
+ return parseInput(() => {
104
+ if (ast.kind === graphql.Kind.STRING || ast.kind === graphql.Kind.INT || ast.kind === graphql.Kind.FLOAT) {
105
+ return validateDecimal(ast.value);
106
+ }
107
+ throw new TypeError(`Decimal scalar can only parse string or numeric values, got: ${ast.kind}`);
108
+ }, ast);
88
109
  }
89
110
  }));
90
111
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CustomTypesProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/CustomTypesProvider.ts"],"sourcesContent":["import { GraphQLScalarType, Kind } from 'graphql'\nimport { JSONType, UuidType } from '@contember/graphql-utils'\n\nconst TIME_REGEX = /^([01]\\d|2[0-3]):([0-5]\\d)(?::([0-5]\\d)(?:\\.(\\d+))?)?$/\n\nconst DECIMAL_REGEX = /^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][+-]?\\d+)?$/\n\nfunction validateDecimal(value: unknown): string {\n\t// Numeric values are transported as strings to avoid JS float precision loss.\n\t// Plain numbers are accepted for convenience but normalized to a string.\n\tif (typeof value === 'number') {\n\t\tif (!Number.isFinite(value)) {\n\t\t\tthrow new TypeError(`Decimal value must be a finite number, got: ${value}`)\n\t\t}\n\t\treturn String(value)\n\t}\n\tif (typeof value !== 'string') {\n\t\tthrow new TypeError(`Decimal value must be a string, got: ${typeof value}`)\n\t}\n\tif (!DECIMAL_REGEX.test(value.trim())) {\n\t\tthrow new TypeError(`Value is not a valid decimal: ${value}`)\n\t}\n\treturn value.trim()\n}\n\nfunction validateTime(value: unknown): string {\n\tif (typeof value !== 'string') {\n\t\tthrow new TypeError(`Time value must be a string, got: ${typeof value}`)\n\t}\n\tconst match = TIME_REGEX.exec(value)\n\tif (!match) {\n\t\tthrow new TypeError(`Value is not a valid time: ${value}`)\n\t}\n\n\tconst hours = match[1]\n\tconst minutes = match[2]\n\tconst seconds = match[3] || '00'\n\tconst fraction = match[4] ? `.${match[4]}` : ''\n\n\treturn `${hours}:${minutes}:${seconds}${fraction}`\n}\n\nexport class CustomTypesProvider {\n\tpublic readonly uuidType: GraphQLScalarType = UuidType\n\n\t// todo: implement serialize, parseValue and parseLiteral properly\n\n\tpublic readonly dateType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'Date',\n\t\tserialize: str => String(str),\n\t\tparseValue: str => String(str),\n\t\tparseLiteral: function parseLiteral(ast) {\n\t\t\treturn ast.kind === Kind.STRING ? ast.value : undefined\n\t\t},\n\t})\n\n\tpublic readonly timeType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'Time',\n\t\tserialize(value) {\n\t\t\treturn validateTime(value)\n\t\t},\n\t\tparseValue(value) {\n\t\t\treturn validateTime(value)\n\t\t},\n\t\tparseLiteral(ast) {\n\t\t\tif (ast.kind !== Kind.STRING) {\n\t\t\t\tthrow new TypeError(`Time scalar can only parse string values, got: ${ast.kind}`)\n\t\t\t}\n\t\t\treturn validateTime(ast.value)\n\t\t},\n\t})\n\n\tpublic readonly dateTimeType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'DateTime',\n\t\tserialize: str => String(str),\n\t\tparseValue: str => String(str),\n\t\tparseLiteral: function parseLiteral(ast) {\n\t\t\treturn ast.kind === Kind.STRING ? ast.value : undefined\n\t\t},\n\t})\n\tpublic readonly jsonType: GraphQLScalarType = JSONType\n\n\tpublic readonly decimalType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'Decimal',\n\t\tdescription: 'Arbitrary precision decimal number, transported as a string to avoid floating-point precision loss.',\n\t\tserialize(value) {\n\t\t\treturn validateDecimal(value)\n\t\t},\n\t\tparseValue(value) {\n\t\t\treturn validateDecimal(value)\n\t\t},\n\t\tparseLiteral(ast) {\n\t\t\tif (ast.kind === Kind.STRING || ast.kind === Kind.INT || ast.kind === Kind.FLOAT) {\n\t\t\t\treturn validateDecimal(ast.value)\n\t\t\t}\n\t\t\tthrow new TypeError(`Decimal scalar can only parse string or numeric values, got: ${ast.kind}`)\n\t\t},\n\t})\n}\n"],"names":["UuidType","GraphQLScalarType","Kind","JSONType"],"mappings":";;;;;;;AAGA,MAAM,aAAa;AAEnB,MAAM,gBAAgB;AAEtB,SAAS,gBAAgB,OAAwB;AAGhD,MAAI,OAAO,UAAU,UAAU;AAC9B,QAAI,CAAC,OAAO,SAAS,KAAK,GAAG;AAC5B,YAAM,IAAI,UAAU,+CAA+C,KAAK,EAAE;AAAA,IAC3E;AACA,WAAO,OAAO,KAAK;AAAA,EACpB;AACA,MAAI,OAAO,UAAU,UAAU;AAC9B,UAAM,IAAI,UAAU,wCAAwC,OAAO,KAAK,EAAE;AAAA,EAC3E;AACA,MAAI,CAAC,cAAc,KAAK,MAAM,KAAA,CAAM,GAAG;AACtC,UAAM,IAAI,UAAU,iCAAiC,KAAK,EAAE;AAAA,EAC7D;AACA,SAAO,MAAM,KAAA;AACd;AAEA,SAAS,aAAa,OAAwB;AAC7C,MAAI,OAAO,UAAU,UAAU;AAC9B,UAAM,IAAI,UAAU,qCAAqC,OAAO,KAAK,EAAE;AAAA,EACxE;AACA,QAAM,QAAQ,WAAW,KAAK,KAAK;AACnC,MAAI,CAAC,OAAO;AACX,UAAM,IAAI,UAAU,8BAA8B,KAAK,EAAE;AAAA,EAC1D;AAEA,QAAM,QAAQ,MAAM,CAAC;AACrB,QAAM,UAAU,MAAM,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AgB,eAAiC,IAAIF,0BAAkB;AAAA,MACtE,MAAM;AAAA,MACN,aAAa;AAAA,MACb,UAAU,OAAO;AAChB,eAAO,gBAAgB,KAAK;AAAA,MAC7B;AAAA,MACA,WAAW,OAAO;AACjB,eAAO,gBAAgB,KAAK;AAAA,MAC7B;AAAA,MACA,aAAa,KAAK;AACjB,YAAI,IAAI,SAASC,aAAK,UAAU,IAAI,SAASA,QAAAA,KAAK,OAAO,IAAI,SAASA,QAAAA,KAAK,OAAO;AACjF,iBAAO,gBAAgB,IAAI,KAAK;AAAA,QACjC;AACA,cAAM,IAAI,UAAU,gEAAgE,IAAI,IAAI,EAAE;AAAA,MAC/F;AAAA,IAAA,CACA,CAAA;AAAA,EAAA;AACF;;"}
1
+ {"version":3,"file":"CustomTypesProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/CustomTypesProvider.ts"],"sourcesContent":["import { GraphQLError, GraphQLScalarType, Kind, ValueNode } from 'graphql'\nimport { JSONType, UuidType } from '@contember/graphql-utils'\nimport { isImpossibleCalendarDate } from './calendarDate.js'\n\nconst TIME_REGEX = /^([01]\\d|2[0-3]):([0-5]\\d)(?::([0-5]\\d)(?:\\.(\\d+))?)?$/\n\nconst DECIMAL_REGEX = /^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][+-]?\\d+)?$/\n\nfunction validateDecimal(value: unknown): string {\n\t// Numeric values are transported as strings to avoid JS float precision loss.\n\t// Plain numbers are accepted for convenience but normalized to a string.\n\tif (typeof value === 'number') {\n\t\tif (!Number.isFinite(value)) {\n\t\t\tthrow new TypeError(`Decimal value must be a finite number, got: ${value}`)\n\t\t}\n\t\treturn String(value)\n\t}\n\tif (typeof value !== 'string') {\n\t\tthrow new TypeError(`Decimal value must be a string, got: ${typeof value}`)\n\t}\n\tif (!DECIMAL_REGEX.test(value.trim())) {\n\t\tthrow new TypeError(`Value is not a valid decimal: ${value}`)\n\t}\n\treturn value.trim()\n}\n\nfunction validateTime(value: unknown): string {\n\tif (typeof value !== 'string') {\n\t\tthrow new TypeError(`Time value must be a string, got: ${typeof value}`)\n\t}\n\tconst match = TIME_REGEX.exec(value)\n\tif (!match) {\n\t\tthrow new TypeError(`Value is not a valid time: ${value}`)\n\t}\n\n\tconst hours = match[1]\n\tconst minutes = match[2]\n\tconst seconds = match[3] || '00'\n\tconst fraction = match[4] ? `.${match[4]}` : ''\n\n\treturn `${hours}:${minutes}:${seconds}${fraction}`\n}\n\nfunction validateCalendarDate(value: string): string {\n\tif (isImpossibleCalendarDate(value)) {\n\t\tthrow new TypeError(`Value is not a valid date: ${value}`)\n\t}\n\treturn value\n}\n\n// graphql-js passes a GraphQLError thrown while parsing input through as is, and engine-http reports it as a client error.\n// Any other error becomes the originalError of a wrapping GraphQLError, which engine-http unwraps and reports as internal.\nfunction parseInput<T>(parse: () => T, node?: ValueNode): T {\n\ttry {\n\t\treturn parse()\n\t} catch (error) {\n\t\tif (error instanceof TypeError) {\n\t\t\tthrow new GraphQLError(error.message, { nodes: node })\n\t\t}\n\t\tthrow error\n\t}\n}\n\nexport class CustomTypesProvider {\n\tpublic readonly uuidType: GraphQLScalarType = UuidType\n\n\t// todo: implement serialize, parseValue and parseLiteral properly\n\n\tpublic readonly dateType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'Date',\n\t\tserialize: str => String(str),\n\t\tparseValue: str => parseInput(() => validateCalendarDate(String(str))),\n\t\tparseLiteral: function parseLiteral(ast) {\n\t\t\treturn ast.kind === Kind.STRING ? parseInput(() => validateCalendarDate(ast.value), ast) : undefined\n\t\t},\n\t})\n\n\tpublic readonly timeType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'Time',\n\t\tserialize(value) {\n\t\t\treturn validateTime(value)\n\t\t},\n\t\tparseValue(value) {\n\t\t\treturn parseInput(() => validateTime(value))\n\t\t},\n\t\tparseLiteral(ast) {\n\t\t\treturn parseInput(() => {\n\t\t\t\tif (ast.kind !== Kind.STRING) {\n\t\t\t\t\tthrow new TypeError(`Time scalar can only parse string values, got: ${ast.kind}`)\n\t\t\t\t}\n\t\t\t\treturn validateTime(ast.value)\n\t\t\t}, ast)\n\t\t},\n\t})\n\n\tpublic readonly dateTimeType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'DateTime',\n\t\tserialize: str => String(str),\n\t\tparseValue: str => parseInput(() => validateCalendarDate(String(str))),\n\t\tparseLiteral: function parseLiteral(ast) {\n\t\t\treturn ast.kind === Kind.STRING ? parseInput(() => validateCalendarDate(ast.value), ast) : undefined\n\t\t},\n\t})\n\tpublic readonly jsonType: GraphQLScalarType = JSONType\n\n\tpublic readonly decimalType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'Decimal',\n\t\tdescription: 'Arbitrary precision decimal number, transported as a string to avoid floating-point precision loss.',\n\t\tserialize(value) {\n\t\t\treturn validateDecimal(value)\n\t\t},\n\t\tparseValue(value) {\n\t\t\treturn parseInput(() => validateDecimal(value))\n\t\t},\n\t\tparseLiteral(ast) {\n\t\t\treturn parseInput(() => {\n\t\t\t\tif (ast.kind === Kind.STRING || ast.kind === Kind.INT || ast.kind === Kind.FLOAT) {\n\t\t\t\t\treturn validateDecimal(ast.value)\n\t\t\t\t}\n\t\t\t\tthrow new TypeError(`Decimal scalar can only parse string or numeric values, got: ${ast.kind}`)\n\t\t\t}, ast)\n\t\t},\n\t})\n}\n"],"names":["isImpossibleCalendarDate","GraphQLError","UuidType","GraphQLScalarType","Kind","JSONType"],"mappings":";;;;;;;;AAIA,MAAM,aAAa;AAEnB,MAAM,gBAAgB;AAEtB,SAAS,gBAAgB,OAAwB;AAGhD,MAAI,OAAO,UAAU,UAAU;AAC9B,QAAI,CAAC,OAAO,SAAS,KAAK,GAAG;AAC5B,YAAM,IAAI,UAAU,+CAA+C,KAAK,EAAE;AAAA,IAC3E;AACA,WAAO,OAAO,KAAK;AAAA,EACpB;AACA,MAAI,OAAO,UAAU,UAAU;AAC9B,UAAM,IAAI,UAAU,wCAAwC,OAAO,KAAK,EAAE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WAAW,MAAM;AACvB,cAAI,IAAI,SAASC,aAAK,UAAU,IAAI,SAASA,QAAAA,KAAK,OAAO,IAAI,SAASA,QAAAA,KAAK,OAAO;AACjF,mBAAO,gBAAgB,IAAI,KAAK;AAAA,UACjC;AACA,gBAAM,IAAI,UAAU,gEAAgE,IAAI,IAAI,EAAE;AAAA,QAC/F,GAAG,GAAG;AAAA,MACP;AAAA,IAAA,CACA,CAAA;AAAA,EAAA;AACF;;"}
@@ -1,5 +1,6 @@
1
- import { GraphQLScalarType, Kind } from "graphql";
1
+ import { GraphQLScalarType, Kind, GraphQLError } from "graphql";
2
2
  import { UuidType, JSONType } from "@contember/graphql-utils";
3
+ import { isImpossibleCalendarDate } from "./calendarDate.js";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
6
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -34,15 +35,31 @@ function validateTime(value) {
34
35
  const fraction = match[4] ? `.${match[4]}` : "";
35
36
  return `${hours}:${minutes}:${seconds}${fraction}`;
36
37
  }
38
+ function validateCalendarDate(value) {
39
+ if (isImpossibleCalendarDate(value)) {
40
+ throw new TypeError(`Value is not a valid date: ${value}`);
41
+ }
42
+ return value;
43
+ }
44
+ function parseInput(parse, node) {
45
+ try {
46
+ return parse();
47
+ } catch (error) {
48
+ if (error instanceof TypeError) {
49
+ throw new GraphQLError(error.message, { nodes: node });
50
+ }
51
+ throw error;
52
+ }
53
+ }
37
54
  class CustomTypesProvider {
38
55
  constructor() {
39
56
  __publicField(this, "uuidType", UuidType);
40
57
  __publicField(this, "dateType", new GraphQLScalarType({
41
58
  name: "Date",
42
59
  serialize: (str) => String(str),
43
- parseValue: (str) => String(str),
60
+ parseValue: (str) => parseInput(() => validateCalendarDate(String(str))),
44
61
  parseLiteral: function parseLiteral(ast) {
45
- return ast.kind === Kind.STRING ? ast.value : void 0;
62
+ return ast.kind === Kind.STRING ? parseInput(() => validateCalendarDate(ast.value), ast) : void 0;
46
63
  }
47
64
  }));
48
65
  __publicField(this, "timeType", new GraphQLScalarType({
@@ -51,21 +68,23 @@ class CustomTypesProvider {
51
68
  return validateTime(value);
52
69
  },
53
70
  parseValue(value) {
54
- return validateTime(value);
71
+ return parseInput(() => validateTime(value));
55
72
  },
56
73
  parseLiteral(ast) {
57
- if (ast.kind !== Kind.STRING) {
58
- throw new TypeError(`Time scalar can only parse string values, got: ${ast.kind}`);
59
- }
60
- return validateTime(ast.value);
74
+ return parseInput(() => {
75
+ if (ast.kind !== Kind.STRING) {
76
+ throw new TypeError(`Time scalar can only parse string values, got: ${ast.kind}`);
77
+ }
78
+ return validateTime(ast.value);
79
+ }, ast);
61
80
  }
62
81
  }));
63
82
  __publicField(this, "dateTimeType", new GraphQLScalarType({
64
83
  name: "DateTime",
65
84
  serialize: (str) => String(str),
66
- parseValue: (str) => String(str),
85
+ parseValue: (str) => parseInput(() => validateCalendarDate(String(str))),
67
86
  parseLiteral: function parseLiteral(ast) {
68
- return ast.kind === Kind.STRING ? ast.value : void 0;
87
+ return ast.kind === Kind.STRING ? parseInput(() => validateCalendarDate(ast.value), ast) : void 0;
69
88
  }
70
89
  }));
71
90
  __publicField(this, "jsonType", JSONType);
@@ -76,13 +95,15 @@ class CustomTypesProvider {
76
95
  return validateDecimal(value);
77
96
  },
78
97
  parseValue(value) {
79
- return validateDecimal(value);
98
+ return parseInput(() => validateDecimal(value));
80
99
  },
81
100
  parseLiteral(ast) {
82
- if (ast.kind === Kind.STRING || ast.kind === Kind.INT || ast.kind === Kind.FLOAT) {
83
- return validateDecimal(ast.value);
84
- }
85
- throw new TypeError(`Decimal scalar can only parse string or numeric values, got: ${ast.kind}`);
101
+ return parseInput(() => {
102
+ if (ast.kind === Kind.STRING || ast.kind === Kind.INT || ast.kind === Kind.FLOAT) {
103
+ return validateDecimal(ast.value);
104
+ }
105
+ throw new TypeError(`Decimal scalar can only parse string or numeric values, got: ${ast.kind}`);
106
+ }, ast);
86
107
  }
87
108
  }));
88
109
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CustomTypesProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/CustomTypesProvider.ts"],"sourcesContent":["import { GraphQLScalarType, Kind } from 'graphql'\nimport { JSONType, UuidType } from '@contember/graphql-utils'\n\nconst TIME_REGEX = /^([01]\\d|2[0-3]):([0-5]\\d)(?::([0-5]\\d)(?:\\.(\\d+))?)?$/\n\nconst DECIMAL_REGEX = /^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][+-]?\\d+)?$/\n\nfunction validateDecimal(value: unknown): string {\n\t// Numeric values are transported as strings to avoid JS float precision loss.\n\t// Plain numbers are accepted for convenience but normalized to a string.\n\tif (typeof value === 'number') {\n\t\tif (!Number.isFinite(value)) {\n\t\t\tthrow new TypeError(`Decimal value must be a finite number, got: ${value}`)\n\t\t}\n\t\treturn String(value)\n\t}\n\tif (typeof value !== 'string') {\n\t\tthrow new TypeError(`Decimal value must be a string, got: ${typeof value}`)\n\t}\n\tif (!DECIMAL_REGEX.test(value.trim())) {\n\t\tthrow new TypeError(`Value is not a valid decimal: ${value}`)\n\t}\n\treturn value.trim()\n}\n\nfunction validateTime(value: unknown): string {\n\tif (typeof value !== 'string') {\n\t\tthrow new TypeError(`Time value must be a string, got: ${typeof value}`)\n\t}\n\tconst match = TIME_REGEX.exec(value)\n\tif (!match) {\n\t\tthrow new TypeError(`Value is not a valid time: ${value}`)\n\t}\n\n\tconst hours = match[1]\n\tconst minutes = match[2]\n\tconst seconds = match[3] || '00'\n\tconst fraction = match[4] ? `.${match[4]}` : ''\n\n\treturn `${hours}:${minutes}:${seconds}${fraction}`\n}\n\nexport class CustomTypesProvider {\n\tpublic readonly uuidType: GraphQLScalarType = UuidType\n\n\t// todo: implement serialize, parseValue and parseLiteral properly\n\n\tpublic readonly dateType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'Date',\n\t\tserialize: str => String(str),\n\t\tparseValue: str => String(str),\n\t\tparseLiteral: function parseLiteral(ast) {\n\t\t\treturn ast.kind === Kind.STRING ? ast.value : undefined\n\t\t},\n\t})\n\n\tpublic readonly timeType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'Time',\n\t\tserialize(value) {\n\t\t\treturn validateTime(value)\n\t\t},\n\t\tparseValue(value) {\n\t\t\treturn validateTime(value)\n\t\t},\n\t\tparseLiteral(ast) {\n\t\t\tif (ast.kind !== Kind.STRING) {\n\t\t\t\tthrow new TypeError(`Time scalar can only parse string values, got: ${ast.kind}`)\n\t\t\t}\n\t\t\treturn validateTime(ast.value)\n\t\t},\n\t})\n\n\tpublic readonly dateTimeType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'DateTime',\n\t\tserialize: str => String(str),\n\t\tparseValue: str => String(str),\n\t\tparseLiteral: function parseLiteral(ast) {\n\t\t\treturn ast.kind === Kind.STRING ? ast.value : undefined\n\t\t},\n\t})\n\tpublic readonly jsonType: GraphQLScalarType = JSONType\n\n\tpublic readonly decimalType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'Decimal',\n\t\tdescription: 'Arbitrary precision decimal number, transported as a string to avoid floating-point precision loss.',\n\t\tserialize(value) {\n\t\t\treturn validateDecimal(value)\n\t\t},\n\t\tparseValue(value) {\n\t\t\treturn validateDecimal(value)\n\t\t},\n\t\tparseLiteral(ast) {\n\t\t\tif (ast.kind === Kind.STRING || ast.kind === Kind.INT || ast.kind === Kind.FLOAT) {\n\t\t\t\treturn validateDecimal(ast.value)\n\t\t\t}\n\t\t\tthrow new TypeError(`Decimal scalar can only parse string or numeric values, got: ${ast.kind}`)\n\t\t},\n\t})\n}\n"],"names":[],"mappings":";;;;;AAGA,MAAM,aAAa;AAEnB,MAAM,gBAAgB;AAEtB,SAAS,gBAAgB,OAAwB;AAGhD,MAAI,OAAO,UAAU,UAAU;AAC9B,QAAI,CAAC,OAAO,SAAS,K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ChB,eAAO,aAAa,KAAK;AAAA,MAC1B;AAAA,MACA,WAAW,OAAO;AACjB,eAAO,aAAa,KAAK;AAAA,MAC1B;AAAA,MACA,aAAa,KAAK;AACjB,YAAI,IAAI,SAAS,KAAK,QAAQ;AAC7B,gBAAM,IAAI,UAAU,kDAAkD,IAAI,IAAI,EAAE;AAAA,QACjF;AACA,eAAO,aAAa,IAAI,KAAK;AAAA,MAC9B;AAAA,IAAA,CACA,CAAA;AAED,kBAAA,MAAgB,gBAAkC,IAAI,kBAAkB;AAAA,MACvE,MAAM;AAAA,MACN,WAAW,CAAA,QAAO,OAAO,GAAG;AAAA,MAC5B,YAAY,CAAA,QAAO,OAAO,GAAG;AAAA,MAC7B,cAAc,SAAS,aAAa,KAAK;AACxC,eAAO,IAAI,SAAS,KAAK,SAAS,IAAI,QAAQ;AAAA,MAC/C;AAAA,IAAA,CACA,CAAA;AACD,kBAAA,MAAgB,YAA8B,QAAA;AAE9C,kBAAA,MAAgB,eAAiC,IAAI,kBAAkB;AAAA,MACtE,MAAM;AAAA,MACN,aAAa;AAAA,MACb,UAAU,OAAO;AAChB,eAAO,gBAAgB,KAAK;AAAA,MAC7B;AAAA,MACA,WAAW,OAAO;AACjB,eAAO,gBAAgB,KAAK;AAAA,MAC7B;AAAA,MACA,aAAa,KAAK;AACjB,YAAI,IAAI,SAAS,KAAK,UAAU,IAAI,SAAS,KAAK,OAAO,IAAI,SAAS,KAAK,OAAO;AACjF,iBAAO,gBAAgB,IAAI,KAAK;AAAA,QACjC;AACA,cAAM,IAAI,UAAU,gEAAgE,IAAI,IAAI,EAAE;AAAA,MAC/F;AAAA,IAAA,CACA,CAAA;AAAA,EAAA;AACF;"}
1
+ {"version":3,"file":"CustomTypesProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/CustomTypesProvider.ts"],"sourcesContent":["import { GraphQLError, GraphQLScalarType, Kind, ValueNode } from 'graphql'\nimport { JSONType, UuidType } from '@contember/graphql-utils'\nimport { isImpossibleCalendarDate } from './calendarDate.js'\n\nconst TIME_REGEX = /^([01]\\d|2[0-3]):([0-5]\\d)(?::([0-5]\\d)(?:\\.(\\d+))?)?$/\n\nconst DECIMAL_REGEX = /^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][+-]?\\d+)?$/\n\nfunction validateDecimal(value: unknown): string {\n\t// Numeric values are transported as strings to avoid JS float precision loss.\n\t// Plain numbers are accepted for convenience but normalized to a string.\n\tif (typeof value === 'number') {\n\t\tif (!Number.isFinite(value)) {\n\t\t\tthrow new TypeError(`Decimal value must be a finite number, got: ${value}`)\n\t\t}\n\t\treturn String(value)\n\t}\n\tif (typeof value !== 'string') {\n\t\tthrow new TypeError(`Decimal value must be a string, got: ${typeof value}`)\n\t}\n\tif (!DECIMAL_REGEX.test(value.trim())) {\n\t\tthrow new TypeError(`Value is not a valid decimal: ${value}`)\n\t}\n\treturn value.trim()\n}\n\nfunction validateTime(value: unknown): string {\n\tif (typeof value !== 'string') {\n\t\tthrow new TypeError(`Time value must be a string, got: ${typeof value}`)\n\t}\n\tconst match = TIME_REGEX.exec(value)\n\tif (!match) {\n\t\tthrow new TypeError(`Value is not a valid time: ${value}`)\n\t}\n\n\tconst hours = match[1]\n\tconst minutes = match[2]\n\tconst seconds = match[3] || '00'\n\tconst fraction = match[4] ? `.${match[4]}` : ''\n\n\treturn `${hours}:${minutes}:${seconds}${fraction}`\n}\n\nfunction validateCalendarDate(value: string): string {\n\tif (isImpossibleCalendarDate(value)) {\n\t\tthrow new TypeError(`Value is not a valid date: ${value}`)\n\t}\n\treturn value\n}\n\n// graphql-js passes a GraphQLError thrown while parsing input through as is, and engine-http reports it as a client error.\n// Any other error becomes the originalError of a wrapping GraphQLError, which engine-http unwraps and reports as internal.\nfunction parseInput<T>(parse: () => T, node?: ValueNode): T {\n\ttry {\n\t\treturn parse()\n\t} catch (error) {\n\t\tif (error instanceof TypeError) {\n\t\t\tthrow new GraphQLError(error.message, { nodes: node })\n\t\t}\n\t\tthrow error\n\t}\n}\n\nexport class CustomTypesProvider {\n\tpublic readonly uuidType: GraphQLScalarType = UuidType\n\n\t// todo: implement serialize, parseValue and parseLiteral properly\n\n\tpublic readonly dateType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'Date',\n\t\tserialize: str => String(str),\n\t\tparseValue: str => parseInput(() => validateCalendarDate(String(str))),\n\t\tparseLiteral: function parseLiteral(ast) {\n\t\t\treturn ast.kind === Kind.STRING ? parseInput(() => validateCalendarDate(ast.value), ast) : undefined\n\t\t},\n\t})\n\n\tpublic readonly timeType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'Time',\n\t\tserialize(value) {\n\t\t\treturn validateTime(value)\n\t\t},\n\t\tparseValue(value) {\n\t\t\treturn parseInput(() => validateTime(value))\n\t\t},\n\t\tparseLiteral(ast) {\n\t\t\treturn parseInput(() => {\n\t\t\t\tif (ast.kind !== Kind.STRING) {\n\t\t\t\t\tthrow new TypeError(`Time scalar can only parse string values, got: ${ast.kind}`)\n\t\t\t\t}\n\t\t\t\treturn validateTime(ast.value)\n\t\t\t}, ast)\n\t\t},\n\t})\n\n\tpublic readonly dateTimeType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'DateTime',\n\t\tserialize: str => String(str),\n\t\tparseValue: str => parseInput(() => validateCalendarDate(String(str))),\n\t\tparseLiteral: function parseLiteral(ast) {\n\t\t\treturn ast.kind === Kind.STRING ? parseInput(() => validateCalendarDate(ast.value), ast) : undefined\n\t\t},\n\t})\n\tpublic readonly jsonType: GraphQLScalarType = JSONType\n\n\tpublic readonly decimalType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'Decimal',\n\t\tdescription: 'Arbitrary precision decimal number, transported as a string to avoid floating-point precision loss.',\n\t\tserialize(value) {\n\t\t\treturn validateDecimal(value)\n\t\t},\n\t\tparseValue(value) {\n\t\t\treturn parseInput(() => validateDecimal(value))\n\t\t},\n\t\tparseLiteral(ast) {\n\t\t\treturn parseInput(() => {\n\t\t\t\tif (ast.kind === Kind.STRING || ast.kind === Kind.INT || ast.kind === Kind.FLOAT) {\n\t\t\t\t\treturn validateDecimal(ast.value)\n\t\t\t\t}\n\t\t\t\tthrow new TypeError(`Decimal scalar can only parse string or numeric values, got: ${ast.kind}`)\n\t\t\t}, ast)\n\t\t},\n\t})\n}\n"],"names":[],"mappings":";;;;;;AAIA,MAAM,aAAa;AAEnB,MAAM,gBAAgB;AAEtB,SAAS,gBAAgB,OAAwB;AAGhD,MAAI,OAAO,UAAU,UAAU;AAC9B,QAAI,CAAC,OAAO,SAAS,KAAK,GAAG;AAC5B,YAAM,IAAI,UAAU,+CAA+C,KAAK,EAAE;AAAA,IAC3E;AACA,WAAO,OAAO,KAAK;AAAA,EACpB;AACA,MAAI,OAAO,UAAU,UAAU;AAC9B,UAAM,IAAI,UAAU,wCAAwC,OAAO,KAAK,EAAE;AAAA,EAC3E;AACA,MAAI,CAAC,cAAc,KAAK,MAAM,KAAA,CAAM,GAAG;AACtC,UAAM,IAAI,UAAU,iCAAiC,KAAK,EAAE;AAAA,EAC7D;AACA,SAAO,MAAM,KAAA;AACd;AAEA,SAAS,aAAa,OAAwB;AAC7C,MAAI,OAAO,UAAU,UAAU;AAC9B,UAAM,IAAI,UAAU,qCAAqC,OAAO,KAAK,EAAE;AAAA,EACxE;AACA,QAAM,QAAQ,WAAW,KAAK,KAAK;AACnC,MAAI,CAAC,OAAO;AACX,UAAM,IAAI,UAAU,8BAA8B,KAAK,EAAE;AAAA,EAC1D;AAEA,QAAM,QAAQ,MAAM,CAAC;AACrB,QAAM,UAAU,MAAM,CAAC;AACvB,QAAM,UAAU,MAAM,CAAC,KAAK;AAC5B,QAAM,WAAW,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC,KAAK;AAE7C,SAAO,GAAG,KAAK,IAAI,OAAO,IAAI,OAAO,GAAG,QAAQ;AACjD;AAEA,SAAS,qBAAqB,OAAuB;AACpD,MAAI,yBAAyB,KAAK,GAAG;AACpC,UAAM,IAAI,UAA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,qBAAqB,OAAO,GAAG,CAAC,CAAC;AAAA,MACrE,cAAc,SAAS,aAAa,KAAK;AACxC,eAAO,IAAI,SAAS,KAAK,SAAS,WAAW,MAAM,qBAAqB,IAAI,KAAK,GAAG,GAAG,IAAI;AAAA,MAC5F;AAAA,IAAA,CACA,CAAA;AACD,kBAAA,MAAgB,YAA8B,QAAA;AAE9C,kBAAA,MAAgB,eAAiC,IAAI,kBAAkB;AAAA,MACtE,MAAM;AAAA,MACN,aAAa;AAAA,MACb,UAAU,OAAO;AAChB,eAAO,gBAAgB,KAAK;AAAA,MAC7B;AAAA,MACA,WAAW,OAAO;AACjB,eAAO,WAAW,MAAM,gBAAgB,KAAK,CAAC;AAAA,MAC/C;AAAA,MACA,aAAa,KAAK;AACjB,eAAO,WAAW,MAAM;AACvB,cAAI,IAAI,SAAS,KAAK,UAAU,IAAI,SAAS,KAAK,OAAO,IAAI,SAAS,KAAK,OAAO;AACjF,mBAAO,gBAAgB,IAAI,KAAK;AAAA,UACjC;AACA,gBAAM,IAAI,UAAU,gEAAgE,IAAI,IAAI,EAAE;AAAA,QAC/F,GAAG,GAAG;AAAA,MACP;AAAA,IAAA,CACA,CAAA;AAAA,EAAA;AACF;"}
@@ -53,13 +53,14 @@ class EntityTypeProvider {
53
53
  return this.connections(entityName);
54
54
  }
55
55
  createEntity(entityName) {
56
+ const entity = schemaUtils.getEntity(this.schema, entityName);
56
57
  return new graphql.GraphQLObjectType({
57
58
  name: utils.GqlTypeName`${entityName}`,
58
- fields: () => this.getEntityFields(entityName)
59
+ description: entity.description,
60
+ fields: () => this.getEntityFields(entity)
59
61
  });
60
62
  }
61
- getEntityFields(entityName) {
62
- const entity = schemaUtils.getEntity(this.schema, entityName);
63
+ getEntityFields(entity) {
63
64
  const accessVisitor = new FieldAccessVisitor.FieldAccessVisitor(schema.Acl.Operation.read, this.authorizator);
64
65
  const accessibleFields = Object.values(entity.fields).filter((field) => schemaUtils.acceptFieldVisitor(this.schema, entity, field.name, accessVisitor));
65
66
  const metaFields = {};
@@ -71,7 +72,7 @@ class EntityTypeProvider {
71
72
  }
72
73
  const metaField = {
73
74
  type: new graphql.GraphQLObjectType({
74
- name: utils.GqlTypeName`${entityName}Meta`,
75
+ name: utils.GqlTypeName`${entity.name}Meta`,
75
76
  fields: metaFields
76
77
  }),
77
78
  resolve: utils.aliasAwareResolver
@@ -86,7 +87,9 @@ class EntityTypeProvider {
86
87
  fields[field.name] = {
87
88
  type,
88
89
  args: schemaUtils.acceptFieldVisitor(this.schema, entity, field.name, fieldArgsVisitor),
89
- resolve: utils.aliasAwareResolver
90
+ resolve: utils.aliasAwareResolver,
91
+ deprecationReason: field.deprecationReason,
92
+ description: field.description
90
93
  };
91
94
  }
92
95
  for (const [key, provider] of Object.entries(this.entityFieldProviders)) {
@@ -1 +1 @@
1
- {"version":3,"file":"EntityTypeProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/EntityTypeProvider.ts"],"sourcesContent":["import {\n\tGraphQLBoolean,\n\tGraphQLFieldConfig,\n\tGraphQLInt,\n\tGraphQLList,\n\tGraphQLNonNull,\n\tGraphQLObjectType,\n\tGraphQLObjectTypeConfig,\n\tGraphQLOutputType,\n} from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { acceptFieldVisitor, getEntity as getEntityFromSchema } from '@contember/schema-utils'\nimport { singletonFactory } from '../utils/index.js'\nimport { ColumnTypeResolver } from './ColumnTypeResolver.js'\nimport { FieldArgsVisitor, FieldTypeVisitor } from './entities/index.js'\nimport { aliasAwareResolver, GqlTypeName } from './utils.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\nimport { OrderByTypeProvider } from './OrderByTypeProvider.js'\nimport { EntityFieldsProvider } from '../extensions/index.js'\nimport { ImplementationException } from '../exception.js'\n\nexport class EntityTypeProvider {\n\tprivate entities = singletonFactory(name => this.createEntity(name))\n\tprivate connections = singletonFactory(name => this.createConnection(name))\n\tprivate PageInfo = new GraphQLObjectType({\n\t\tname: 'PageInfo',\n\t\tfields: {\n\t\t\ttotalCount: { type: new GraphQLNonNull(GraphQLInt) },\n\t\t},\n\t})\n\n\tprivate fieldMeta = new GraphQLObjectType({\n\t\tname: 'FieldMeta',\n\t\tfields: {\n\t\t\t[Input.FieldMeta.readable]: { type: GraphQLBoolean, resolve: aliasAwareResolver },\n\t\t\t[Input.FieldMeta.updatable]: { type: GraphQLBoolean, resolve: aliasAwareResolver },\n\t\t},\n\t})\n\tprivate readonly entityFieldProviders: { [key: string]: EntityFieldsProvider } = {}\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly orderByTypeProvider: OrderByTypeProvider,\n\t) {\n\t}\n\n\tpublic registerEntityFieldProvider(key: string, provider: EntityFieldsProvider): void {\n\t\tthis.entityFieldProviders[key] = provider\n\t}\n\n\tpublic getEntity(entityName: string): GraphQLObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.entities(entityName)\n\t}\n\n\tpublic getConnection(entityName: string): GraphQLObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.connections(entityName)\n\t}\n\n\tprivate createEntity(entityName: string) {\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}`,\n\t\t\tfields: () => this.getEntityFields(entityName),\n\t\t} as GraphQLObjectTypeConfig<any, any>)\n\t}\n\n\tprivate getEntityFields(entityName: string) {\n\t\tconst entity = getEntityFromSchema(this.schema, entityName)\n\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\tconst accessibleFields = Object.values(entity.fields).filter(field => acceptFieldVisitor(this.schema, entity, field.name, accessVisitor))\n\t\tconst metaFields: { [field: string]: GraphQLFieldConfig<any, any> } = {}\n\t\tfor (const field of accessibleFields) {\n\t\t\tmetaFields[field.name] = {\n\t\t\t\ttype: this.fieldMeta,\n\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t}\n\t\t}\n\n\t\tconst metaField = {\n\t\t\ttype: new GraphQLObjectType({\n\t\t\t\tname: GqlTypeName`${entityName}Meta`,\n\t\t\t\tfields: metaFields,\n\t\t\t}),\n\t\t\tresolve: aliasAwareResolver,\n\t\t}\n\n\t\tlet fields: { [field: string]: GraphQLFieldConfig<any, any> } = {\n\t\t\t_meta: metaField,\n\t\t}\n\n\t\tfor (const field of accessibleFields) {\n\t\t\tconst fieldTypeVisitor = new FieldTypeVisitor(this.columnTypeResolver, this, this.authorizator, this.rootAuthorizator)\n\t\t\tconst type: GraphQLOutputType = acceptFieldVisitor(this.schema, entity, field.name, fieldTypeVisitor)\n\n\t\t\tconst fieldArgsVisitor = new FieldArgsVisitor(this.whereTypeProvider, this.orderByTypeProvider)\n\t\t\tfields[field.name] = {\n\t\t\t\ttype,\n\t\t\t\targs: acceptFieldVisitor(this.schema, entity, field.name, fieldArgsVisitor),\n\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t}\n\t\t}\n\n\t\tfor (const [key, provider] of Object.entries(this.entityFieldProviders)) {\n\t\t\tfields = {\n\t\t\t\t...fields,\n\t\t\t\t...provider.getFields(entity, accessibleFields),\n\t\t\t}\n\t\t}\n\t\treturn fields\n\t}\n\n\tprivate createConnection(entityName: string) {\n\t\tconst entityType = this.getEntity(entityName)\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}Connection`,\n\t\t\tfields: {\n\t\t\t\tpageInfo: {\n\t\t\t\t\ttype: new GraphQLNonNull(this.PageInfo),\n\t\t\t\t},\n\t\t\t\tedges: {\n\t\t\t\t\ttype: new GraphQLNonNull(\n\t\t\t\t\t\tnew GraphQLList(\n\t\t\t\t\t\t\tnew GraphQLNonNull(\n\t\t\t\t\t\t\t\tnew GraphQLObjectType({\n\t\t\t\t\t\t\t\t\tname: GqlTypeName`${entityName}Edge`,\n\t\t\t\t\t\t\t\t\tfields: {\n\t\t\t\t\t\t\t\t\t\tnode: {\n\t\t\t\t\t\t\t\t\t\t\ttype: new GraphQLNonNull(entityType),\n\t\t\t\t\t\t\t\t\t\t\t// resolve: aliasAwareResolver,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t\t// resolve: aliasAwareResolver,\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t}\n}\n"],"names":["schema","singletonFactory","GraphQLObjectType","GraphQLNonNull","GraphQLInt","Input","GraphQLBoolean","aliasAwareResolver","Acl","ImplementationException","GqlTypeName","getEntityFromSchema","FieldAccessVisitor","acceptFieldVisitor","FieldTypeVisitor","FieldArgsVisitor","GraphQLList"],"mappings":";;;;;;;;;;;;;;AAuBO,MAAM,mBAAmB;AAAA,EAmB/B,YACkBA,UACA,cACA,kBACA,oBACA,mBACA,qBAChB;AANgB,SAAA,SAAAA;AACA,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,qBAAA;AACA,SAAA,oBAAA;AACA,SAAA,sBAAA;AAxBlB,kBAAA,MAAQ,YAAWC,kCAAiB,CAAA,SAAQ,KAAK,aAAa,IAAI,CAAC,CAAA;AACnE,kBAAA,MAAQ,eAAcA,kCAAiB,CAAA,SAAQ,KAAK,iBAAiB,IAAI,CAAC,CAAA;AAC1E,kBAAA,MAAQ,YAAW,IAAIC,0BAAkB;AAAA,MACxC,MAAM;AAAA,MACN,QAAQ;AAAA,QACP,YAAY,EAAE,MAAM,IAAIC,QAAAA,eAAeC,QAAAA,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Ac,UAAU;AAAA,MAC9B,QAAQ;AAAA,QACP,UAAU;AAAA,UACT,MAAM,IAAIP,uBAAe,KAAK,QAAQ;AAAA,QAAA;AAAA,QAEvC,OAAO;AAAA,UACN,MAAM,IAAIA,QAAAA;AAAAA,YACT,IAAIa,QAAAA;AAAAA,cACH,IAAIb,QAAAA;AAAAA,gBACH,IAAID,0BAAkB;AAAA,kBACrB,MAAMQ,MAAAA,cAAc,UAAU;AAAA,kBAC9B,QAAQ;AAAA,oBACP,MAAM;AAAA,sBACL,MAAM,IAAIP,QAAAA,eAAe,UAAU;AAAA;AAAA,oBAAA;AAAA,kBAEpC;AAAA,gBACD,CACA;AAAA,cAAA;AAAA,YACF;AAAA,UACD;AAAA;AAAA,QACD;AAAA,MAED;AAAA,IACD,CACA;AAAA,EACF;AACD;;"}
1
+ {"version":3,"file":"EntityTypeProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/EntityTypeProvider.ts"],"sourcesContent":["import {\n\tGraphQLBoolean,\n\tGraphQLFieldConfig,\n\tGraphQLInt,\n\tGraphQLList,\n\tGraphQLNonNull,\n\tGraphQLObjectType,\n\tGraphQLObjectTypeConfig,\n\tGraphQLOutputType,\n} from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { acceptFieldVisitor, getEntity as getEntityFromSchema } from '@contember/schema-utils'\nimport { singletonFactory } from '../utils/index.js'\nimport { ColumnTypeResolver } from './ColumnTypeResolver.js'\nimport { FieldArgsVisitor, FieldTypeVisitor } from './entities/index.js'\nimport { aliasAwareResolver, GqlTypeName } from './utils.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\nimport { OrderByTypeProvider } from './OrderByTypeProvider.js'\nimport { EntityFieldsProvider } from '../extensions/index.js'\nimport { ImplementationException } from '../exception.js'\n\nexport class EntityTypeProvider {\n\tprivate entities = singletonFactory(name => this.createEntity(name))\n\tprivate connections = singletonFactory(name => this.createConnection(name))\n\tprivate PageInfo = new GraphQLObjectType({\n\t\tname: 'PageInfo',\n\t\tfields: {\n\t\t\ttotalCount: { type: new GraphQLNonNull(GraphQLInt) },\n\t\t},\n\t})\n\n\tprivate fieldMeta = new GraphQLObjectType({\n\t\tname: 'FieldMeta',\n\t\tfields: {\n\t\t\t[Input.FieldMeta.readable]: { type: GraphQLBoolean, resolve: aliasAwareResolver },\n\t\t\t[Input.FieldMeta.updatable]: { type: GraphQLBoolean, resolve: aliasAwareResolver },\n\t\t},\n\t})\n\tprivate readonly entityFieldProviders: { [key: string]: EntityFieldsProvider } = {}\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly orderByTypeProvider: OrderByTypeProvider,\n\t) {\n\t}\n\n\tpublic registerEntityFieldProvider(key: string, provider: EntityFieldsProvider): void {\n\t\tthis.entityFieldProviders[key] = provider\n\t}\n\n\tpublic getEntity(entityName: string): GraphQLObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.entities(entityName)\n\t}\n\n\tpublic getConnection(entityName: string): GraphQLObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.connections(entityName)\n\t}\n\n\tprivate createEntity(entityName: string) {\n\t\tconst entity = getEntityFromSchema(this.schema, entityName)\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}`,\n\t\t\tdescription: entity.description,\n\t\t\tfields: () => this.getEntityFields(entity),\n\t\t} as GraphQLObjectTypeConfig<any, any>)\n\t}\n\n\tprivate getEntityFields(entity: Model.Entity) {\n\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\tconst accessibleFields = Object.values(entity.fields).filter(field => acceptFieldVisitor(this.schema, entity, field.name, accessVisitor))\n\t\tconst metaFields: { [field: string]: GraphQLFieldConfig<any, any> } = {}\n\t\tfor (const field of accessibleFields) {\n\t\t\tmetaFields[field.name] = {\n\t\t\t\ttype: this.fieldMeta,\n\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t}\n\t\t}\n\n\t\tconst metaField = {\n\t\t\ttype: new GraphQLObjectType({\n\t\t\t\tname: GqlTypeName`${entity.name}Meta`,\n\t\t\t\tfields: metaFields,\n\t\t\t}),\n\t\t\tresolve: aliasAwareResolver,\n\t\t}\n\n\t\tlet fields: { [field: string]: GraphQLFieldConfig<any, any> } = {\n\t\t\t_meta: metaField,\n\t\t}\n\n\t\tfor (const field of accessibleFields) {\n\t\t\tconst fieldTypeVisitor = new FieldTypeVisitor(this.columnTypeResolver, this, this.authorizator, this.rootAuthorizator)\n\t\t\tconst type: GraphQLOutputType = acceptFieldVisitor(this.schema, entity, field.name, fieldTypeVisitor)\n\n\t\t\tconst fieldArgsVisitor = new FieldArgsVisitor(this.whereTypeProvider, this.orderByTypeProvider)\n\t\t\tfields[field.name] = {\n\t\t\t\ttype,\n\t\t\t\targs: acceptFieldVisitor(this.schema, entity, field.name, fieldArgsVisitor),\n\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t\tdeprecationReason: field.deprecationReason,\n\t\t\t\tdescription: field.description,\n\t\t\t}\n\t\t}\n\n\t\tfor (const [key, provider] of Object.entries(this.entityFieldProviders)) {\n\t\t\tfields = {\n\t\t\t\t...fields,\n\t\t\t\t...provider.getFields(entity, accessibleFields),\n\t\t\t}\n\t\t}\n\n\t\treturn fields\n\t}\n\n\tprivate createConnection(entityName: string) {\n\t\tconst entityType = this.getEntity(entityName)\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}Connection`,\n\t\t\tfields: {\n\t\t\t\tpageInfo: {\n\t\t\t\t\ttype: new GraphQLNonNull(this.PageInfo),\n\t\t\t\t},\n\t\t\t\tedges: {\n\t\t\t\t\ttype: new GraphQLNonNull(\n\t\t\t\t\t\tnew GraphQLList(\n\t\t\t\t\t\t\tnew GraphQLNonNull(\n\t\t\t\t\t\t\t\tnew GraphQLObjectType({\n\t\t\t\t\t\t\t\t\tname: GqlTypeName`${entityName}Edge`,\n\t\t\t\t\t\t\t\t\tfields: {\n\t\t\t\t\t\t\t\t\t\tnode: {\n\t\t\t\t\t\t\t\t\t\t\ttype: new GraphQLNonNull(entityType),\n\t\t\t\t\t\t\t\t\t\t\t// resolve: aliasAwareResolver,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t\t// resolve: aliasAwareResolver,\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t}\n}\n"],"names":["schema","singletonFactory","GraphQLObjectType","GraphQLNonNull","GraphQLInt","Input","GraphQLBoolean","aliasAwareResolver","Acl","ImplementationException","getEntityFromSchema","GqlTypeName","FieldAccessVisitor","acceptFieldVisitor","FieldTypeVisitor","FieldArgsVisitor","GraphQLList"],"mappings":";;;;;;;;;;;;;;AAuBO,MAAM,mBAAmB;AAAA,EAmB/B,YACkBA,UACA,cACA,kBACA,oBACA,mBACA,qBAChB;AANgB,SAAA,SAAAA;AACA,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,qBAAA;AACA,SAAA,oBAAA;AACA,SAAA,sBAAA;AAxBlB,kBAAA,MAAQ,YAAWC,kCAAiB,CAAA,SAAQ,KAAK,aAAa,IAAI,CAAC,CAAA;AACnE,kBAAA,MAAQ,eAAcA,kCAAiB,CAAA,SAAQ,KAAK,iBAAiB,IAAI,CAAC,CAAA;AAC1E,kBAAA,MAAQ,YAAW,IAAIC,0BAAkB;AAAA,MAC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A,IAEhD;AAEA,WAAO;AAAA,EACR;AAAA,EAEQ,iBAAiB,YAAoB;AAC5C,UAAM,aAAa,KAAK,UAAU,UAAU;AAC5C,WAAO,IAAIL,QAAAA,kBAAkB;AAAA,MAC5B,MAAMS,MAAAA,cAAc,UAAU;AAAA,MAC9B,QAAQ;AAAA,QACP,UAAU;AAAA,UACT,MAAM,IAAIR,uBAAe,KAAK,QAAQ;AAAA,QAAA;AAAA,QAEvC,OAAO;AAAA,UACN,MAAM,IAAIA,QAAAA;AAAAA,YACT,IAAIa,QAAAA;AAAAA,cACH,IAAIb,QAAAA;AAAAA,gBACH,IAAID,0BAAkB;AAAA,kBACrB,MAAMS,MAAAA,cAAc,UAAU;AAAA,kBAC9B,QAAQ;AAAA,oBACP,MAAM;AAAA,sBACL,MAAM,IAAIR,QAAAA,eAAe,UAAU;AAAA;AAAA,oBAAA;AAAA,kBAEpC;AAAA,gBACD,CACA;AAAA,cAAA;AAAA,YACF;AAAA,UACD;AAAA;AAAA,QACD;AAAA,MAED;AAAA,IACD,CACA;AAAA,EACF;AACD;;"}
@@ -51,13 +51,14 @@ class EntityTypeProvider {
51
51
  return this.connections(entityName);
52
52
  }
53
53
  createEntity(entityName) {
54
+ const entity = getEntity(this.schema, entityName);
54
55
  return new GraphQLObjectType({
55
56
  name: GqlTypeName`${entityName}`,
56
- fields: () => this.getEntityFields(entityName)
57
+ description: entity.description,
58
+ fields: () => this.getEntityFields(entity)
57
59
  });
58
60
  }
59
- getEntityFields(entityName) {
60
- const entity = getEntity(this.schema, entityName);
61
+ getEntityFields(entity) {
61
62
  const accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator);
62
63
  const accessibleFields = Object.values(entity.fields).filter((field) => acceptFieldVisitor(this.schema, entity, field.name, accessVisitor));
63
64
  const metaFields = {};
@@ -69,7 +70,7 @@ class EntityTypeProvider {
69
70
  }
70
71
  const metaField = {
71
72
  type: new GraphQLObjectType({
72
- name: GqlTypeName`${entityName}Meta`,
73
+ name: GqlTypeName`${entity.name}Meta`,
73
74
  fields: metaFields
74
75
  }),
75
76
  resolve: aliasAwareResolver
@@ -84,7 +85,9 @@ class EntityTypeProvider {
84
85
  fields[field.name] = {
85
86
  type,
86
87
  args: acceptFieldVisitor(this.schema, entity, field.name, fieldArgsVisitor),
87
- resolve: aliasAwareResolver
88
+ resolve: aliasAwareResolver,
89
+ deprecationReason: field.deprecationReason,
90
+ description: field.description
88
91
  };
89
92
  }
90
93
  for (const [key, provider] of Object.entries(this.entityFieldProviders)) {
@@ -1 +1 @@
1
- {"version":3,"file":"EntityTypeProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/EntityTypeProvider.ts"],"sourcesContent":["import {\n\tGraphQLBoolean,\n\tGraphQLFieldConfig,\n\tGraphQLInt,\n\tGraphQLList,\n\tGraphQLNonNull,\n\tGraphQLObjectType,\n\tGraphQLObjectTypeConfig,\n\tGraphQLOutputType,\n} from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { acceptFieldVisitor, getEntity as getEntityFromSchema } from '@contember/schema-utils'\nimport { singletonFactory } from '../utils/index.js'\nimport { ColumnTypeResolver } from './ColumnTypeResolver.js'\nimport { FieldArgsVisitor, FieldTypeVisitor } from './entities/index.js'\nimport { aliasAwareResolver, GqlTypeName } from './utils.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\nimport { OrderByTypeProvider } from './OrderByTypeProvider.js'\nimport { EntityFieldsProvider } from '../extensions/index.js'\nimport { ImplementationException } from '../exception.js'\n\nexport class EntityTypeProvider {\n\tprivate entities = singletonFactory(name => this.createEntity(name))\n\tprivate connections = singletonFactory(name => this.createConnection(name))\n\tprivate PageInfo = new GraphQLObjectType({\n\t\tname: 'PageInfo',\n\t\tfields: {\n\t\t\ttotalCount: { type: new GraphQLNonNull(GraphQLInt) },\n\t\t},\n\t})\n\n\tprivate fieldMeta = new GraphQLObjectType({\n\t\tname: 'FieldMeta',\n\t\tfields: {\n\t\t\t[Input.FieldMeta.readable]: { type: GraphQLBoolean, resolve: aliasAwareResolver },\n\t\t\t[Input.FieldMeta.updatable]: { type: GraphQLBoolean, resolve: aliasAwareResolver },\n\t\t},\n\t})\n\tprivate readonly entityFieldProviders: { [key: string]: EntityFieldsProvider } = {}\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly orderByTypeProvider: OrderByTypeProvider,\n\t) {\n\t}\n\n\tpublic registerEntityFieldProvider(key: string, provider: EntityFieldsProvider): void {\n\t\tthis.entityFieldProviders[key] = provider\n\t}\n\n\tpublic getEntity(entityName: string): GraphQLObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.entities(entityName)\n\t}\n\n\tpublic getConnection(entityName: string): GraphQLObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.connections(entityName)\n\t}\n\n\tprivate createEntity(entityName: string) {\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}`,\n\t\t\tfields: () => this.getEntityFields(entityName),\n\t\t} as GraphQLObjectTypeConfig<any, any>)\n\t}\n\n\tprivate getEntityFields(entityName: string) {\n\t\tconst entity = getEntityFromSchema(this.schema, entityName)\n\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\tconst accessibleFields = Object.values(entity.fields).filter(field => acceptFieldVisitor(this.schema, entity, field.name, accessVisitor))\n\t\tconst metaFields: { [field: string]: GraphQLFieldConfig<any, any> } = {}\n\t\tfor (const field of accessibleFields) {\n\t\t\tmetaFields[field.name] = {\n\t\t\t\ttype: this.fieldMeta,\n\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t}\n\t\t}\n\n\t\tconst metaField = {\n\t\t\ttype: new GraphQLObjectType({\n\t\t\t\tname: GqlTypeName`${entityName}Meta`,\n\t\t\t\tfields: metaFields,\n\t\t\t}),\n\t\t\tresolve: aliasAwareResolver,\n\t\t}\n\n\t\tlet fields: { [field: string]: GraphQLFieldConfig<any, any> } = {\n\t\t\t_meta: metaField,\n\t\t}\n\n\t\tfor (const field of accessibleFields) {\n\t\t\tconst fieldTypeVisitor = new FieldTypeVisitor(this.columnTypeResolver, this, this.authorizator, this.rootAuthorizator)\n\t\t\tconst type: GraphQLOutputType = acceptFieldVisitor(this.schema, entity, field.name, fieldTypeVisitor)\n\n\t\t\tconst fieldArgsVisitor = new FieldArgsVisitor(this.whereTypeProvider, this.orderByTypeProvider)\n\t\t\tfields[field.name] = {\n\t\t\t\ttype,\n\t\t\t\targs: acceptFieldVisitor(this.schema, entity, field.name, fieldArgsVisitor),\n\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t}\n\t\t}\n\n\t\tfor (const [key, provider] of Object.entries(this.entityFieldProviders)) {\n\t\t\tfields = {\n\t\t\t\t...fields,\n\t\t\t\t...provider.getFields(entity, accessibleFields),\n\t\t\t}\n\t\t}\n\t\treturn fields\n\t}\n\n\tprivate createConnection(entityName: string) {\n\t\tconst entityType = this.getEntity(entityName)\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}Connection`,\n\t\t\tfields: {\n\t\t\t\tpageInfo: {\n\t\t\t\t\ttype: new GraphQLNonNull(this.PageInfo),\n\t\t\t\t},\n\t\t\t\tedges: {\n\t\t\t\t\ttype: new GraphQLNonNull(\n\t\t\t\t\t\tnew GraphQLList(\n\t\t\t\t\t\t\tnew GraphQLNonNull(\n\t\t\t\t\t\t\t\tnew GraphQLObjectType({\n\t\t\t\t\t\t\t\t\tname: GqlTypeName`${entityName}Edge`,\n\t\t\t\t\t\t\t\t\tfields: {\n\t\t\t\t\t\t\t\t\t\tnode: {\n\t\t\t\t\t\t\t\t\t\t\ttype: new GraphQLNonNull(entityType),\n\t\t\t\t\t\t\t\t\t\t\t// resolve: aliasAwareResolver,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t\t// resolve: aliasAwareResolver,\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t}\n}\n"],"names":["getEntityFromSchema"],"mappings":";;;;;;;;;;;;AAuBO,MAAM,mBAAmB;AAAA,EAmB/B,YACkB,QACA,cACA,kBACA,oBACA,mBACA,qBAChB;AANgB,SAAA,SAAA;AACA,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,qBAAA;AACA,SAAA,oBAAA;AACA,SAAA,sBAAA;AAxBlB,kBAAA,MAAQ,YAAW,iBAAiB,CAAA,SAAQ,KAAK,aAAa,IAAI,CAAC,CAAA;AACnE,kBAAA,MAAQ,eAAc,iBAAiB,CAAA,SAAQ,KAAK,iBAAiB,IAAI,CAAC,CAAA;AAC1E,kBAAA,MAAQ,YAAW,IAAI,kBAAkB;AAAA,MACxC,MAAM;AAAA,MACN,QAAQ;AAAA,QACP,YAAY,EAAE,MAAM,IAAI,eAAe,UAAU,EAAA;AAAA,MAAE;AAAA,IACpD,CACA,CAAA;AAED,kBAAA,MAAQ,aAAY,IAAI,kBAAkB;AAAA,MACzC,MAAM;AAAA,MACN,QAAQ;AAAA,QACP,CAAC,MAAM,UAAU,QAAQ,GAAG,EAAE,MAAM,gBAAgB,SAAS,mBAAA;AAAA,QAC7D,CAAC,MAAM,UAAU,SAAS,GAAG,EAAE,MAAM,gBAAgB,SAAS,mBAAA;AAAA,MAAmB;AAAA,IAClF,CACA,CAAA;AACD,kBAAA,MAAiB,wBAAgE,EAAC;AAA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YAAM,mBAAmB,IAAI,iBAAiB,KAAK,oBAAoB,MAAM,KAAK,cAAc,KAAK,gBAAgB;AACrH,YAAM,OAA0B,mBAAmB,KAAK,QAAQ,QAAQ,MAAM,MAAM,gBAAgB;AAEpG,YAAM,mBAAmB,IAAI,iBAAiB,KAAK,mBAAmB,KAAK,mBAAmB;AAC9F,aAAO,MAAM,IAAI,IAAI;AAAA,QACpB;AAAA,QACA,MAAM,mBAAmB,KAAK,QAAQ,QAAQ,MAAM,MAAM,gBAAgB;AAAA,QAC1E,SAAS;AAAA,MAAA;AAAA,IAEX;AAEA,eAAW,CAAC,KAAK,QAAQ,KAAK,OAAO,QAAQ,KAAK,oBAAoB,GAAG;AACxE,eAAS;AAAA,QACR,GAAG;AAAA,QACH,GAAG,SAAS,UAAU,QAAQ,gBAAgB;AAAA,MAAA;AAAA,IAEhD;AACA,WAAO;AAAA,EACR;AAAA,EAEQ,iBAAiB,YAAoB;AAC5C,UAAM,aAAa,KAAK,UAAU,UAAU;AAC5C,WAAO,IAAI,kBAAkB;AAAA,MAC5B,MAAM,cAAc,UAAU;AAAA,MAC9B,QAAQ;AAAA,QACP,UAAU;AAAA,UACT,MAAM,IAAI,eAAe,KAAK,QAAQ;AAAA,QAAA;AAAA,QAEvC,OAAO;AAAA,UACN,MAAM,IAAI;AAAA,YACT,IAAI;AAAA,cACH,IAAI;AAAA,gBACH,IAAI,kBAAkB;AAAA,kBACrB,MAAM,cAAc,UAAU;AAAA,kBAC9B,QAAQ;AAAA,oBACP,MAAM;AAAA,sBACL,MAAM,IAAI,eAAe,UAAU;AAAA;AAAA,oBAAA;AAAA,kBAEpC;AAAA,gBACD,CACA;AAAA,cAAA;AAAA,YACF;AAAA,UACD;AAAA;AAAA,QACD;AAAA,MAED;AAAA,IACD,CACA;AAAA,EACF;AACD;"}
1
+ {"version":3,"file":"EntityTypeProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/EntityTypeProvider.ts"],"sourcesContent":["import {\n\tGraphQLBoolean,\n\tGraphQLFieldConfig,\n\tGraphQLInt,\n\tGraphQLList,\n\tGraphQLNonNull,\n\tGraphQLObjectType,\n\tGraphQLObjectTypeConfig,\n\tGraphQLOutputType,\n} from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { acceptFieldVisitor, getEntity as getEntityFromSchema } from '@contember/schema-utils'\nimport { singletonFactory } from '../utils/index.js'\nimport { ColumnTypeResolver } from './ColumnTypeResolver.js'\nimport { FieldArgsVisitor, FieldTypeVisitor } from './entities/index.js'\nimport { aliasAwareResolver, GqlTypeName } from './utils.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\nimport { OrderByTypeProvider } from './OrderByTypeProvider.js'\nimport { EntityFieldsProvider } from '../extensions/index.js'\nimport { ImplementationException } from '../exception.js'\n\nexport class EntityTypeProvider {\n\tprivate entities = singletonFactory(name => this.createEntity(name))\n\tprivate connections = singletonFactory(name => this.createConnection(name))\n\tprivate PageInfo = new GraphQLObjectType({\n\t\tname: 'PageInfo',\n\t\tfields: {\n\t\t\ttotalCount: { type: new GraphQLNonNull(GraphQLInt) },\n\t\t},\n\t})\n\n\tprivate fieldMeta = new GraphQLObjectType({\n\t\tname: 'FieldMeta',\n\t\tfields: {\n\t\t\t[Input.FieldMeta.readable]: { type: GraphQLBoolean, resolve: aliasAwareResolver },\n\t\t\t[Input.FieldMeta.updatable]: { type: GraphQLBoolean, resolve: aliasAwareResolver },\n\t\t},\n\t})\n\tprivate readonly entityFieldProviders: { [key: string]: EntityFieldsProvider } = {}\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly orderByTypeProvider: OrderByTypeProvider,\n\t) {\n\t}\n\n\tpublic registerEntityFieldProvider(key: string, provider: EntityFieldsProvider): void {\n\t\tthis.entityFieldProviders[key] = provider\n\t}\n\n\tpublic getEntity(entityName: string): GraphQLObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.entities(entityName)\n\t}\n\n\tpublic getConnection(entityName: string): GraphQLObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.connections(entityName)\n\t}\n\n\tprivate createEntity(entityName: string) {\n\t\tconst entity = getEntityFromSchema(this.schema, entityName)\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}`,\n\t\t\tdescription: entity.description,\n\t\t\tfields: () => this.getEntityFields(entity),\n\t\t} as GraphQLObjectTypeConfig<any, any>)\n\t}\n\n\tprivate getEntityFields(entity: Model.Entity) {\n\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\tconst accessibleFields = Object.values(entity.fields).filter(field => acceptFieldVisitor(this.schema, entity, field.name, accessVisitor))\n\t\tconst metaFields: { [field: string]: GraphQLFieldConfig<any, any> } = {}\n\t\tfor (const field of accessibleFields) {\n\t\t\tmetaFields[field.name] = {\n\t\t\t\ttype: this.fieldMeta,\n\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t}\n\t\t}\n\n\t\tconst metaField = {\n\t\t\ttype: new GraphQLObjectType({\n\t\t\t\tname: GqlTypeName`${entity.name}Meta`,\n\t\t\t\tfields: metaFields,\n\t\t\t}),\n\t\t\tresolve: aliasAwareResolver,\n\t\t}\n\n\t\tlet fields: { [field: string]: GraphQLFieldConfig<any, any> } = {\n\t\t\t_meta: metaField,\n\t\t}\n\n\t\tfor (const field of accessibleFields) {\n\t\t\tconst fieldTypeVisitor = new FieldTypeVisitor(this.columnTypeResolver, this, this.authorizator, this.rootAuthorizator)\n\t\t\tconst type: GraphQLOutputType = acceptFieldVisitor(this.schema, entity, field.name, fieldTypeVisitor)\n\n\t\t\tconst fieldArgsVisitor = new FieldArgsVisitor(this.whereTypeProvider, this.orderByTypeProvider)\n\t\t\tfields[field.name] = {\n\t\t\t\ttype,\n\t\t\t\targs: acceptFieldVisitor(this.schema, entity, field.name, fieldArgsVisitor),\n\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t\tdeprecationReason: field.deprecationReason,\n\t\t\t\tdescription: field.description,\n\t\t\t}\n\t\t}\n\n\t\tfor (const [key, provider] of Object.entries(this.entityFieldProviders)) {\n\t\t\tfields = {\n\t\t\t\t...fields,\n\t\t\t\t...provider.getFields(entity, accessibleFields),\n\t\t\t}\n\t\t}\n\n\t\treturn fields\n\t}\n\n\tprivate createConnection(entityName: string) {\n\t\tconst entityType = this.getEntity(entityName)\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}Connection`,\n\t\t\tfields: {\n\t\t\t\tpageInfo: {\n\t\t\t\t\ttype: new GraphQLNonNull(this.PageInfo),\n\t\t\t\t},\n\t\t\t\tedges: {\n\t\t\t\t\ttype: new GraphQLNonNull(\n\t\t\t\t\t\tnew GraphQLList(\n\t\t\t\t\t\t\tnew GraphQLNonNull(\n\t\t\t\t\t\t\t\tnew GraphQLObjectType({\n\t\t\t\t\t\t\t\t\tname: GqlTypeName`${entityName}Edge`,\n\t\t\t\t\t\t\t\t\tfields: {\n\t\t\t\t\t\t\t\t\t\tnode: {\n\t\t\t\t\t\t\t\t\t\t\ttype: new GraphQLNonNull(entityType),\n\t\t\t\t\t\t\t\t\t\t\t// resolve: aliasAwareResolver,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t\t// resolve: aliasAwareResolver,\n\t\t\t\t},\n\t\t\t},\n\t\t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AAS;AAAA,QACT,mBAAmB,MAAM;AAAA,QACzB,aAAa,MAAM;AAAA,MAAA;AAAA,IAErB;AAEA,eAAW,CAAC,KAAK,QAAQ,KAAK,OAAO,QAAQ,KAAK,oBAAoB,GAAG;AACxE,eAAS;AAAA,QACR,GAAG;AAAA,QACH,GAAG,SAAS,UAAU,QAAQ,gBAAgB;AAAA,MAAA;AAAA,IAEhD;AAEA,WAAO;AAAA,EACR;AAAA,EAEQ,iBAAiB,YAAoB;AAC5C,UAAM,aAAa,KAAK,UAAU,UAAU;AAC5C,WAAO,IAAI,kBAAkB;AAAA,MAC5B,MAAM,cAAc,UAAU;AAAA,MAC9B,QAAQ;AAAA,QACP,UAAU;AAAA,UACT,MAAM,IAAI,eAAe,KAAK,QAAQ;AAAA,QAAA;AAAA,QAEvC,OAAO;AAAA,UACN,MAAM,IAAI;AAAA,YACT,IAAI;AAAA,cACH,IAAI;AAAA,gBACH,IAAI,kBAAkB;AAAA,kBACrB,MAAM,cAAc,UAAU;AAAA,kBAC9B,QAAQ;AAAA,oBACP,MAAM;AAAA,sBACL,MAAM,IAAI,eAAe,UAAU;AAAA;AAAA,oBAAA;AAAA,kBAEpC;AAAA,gBACD,CACA;AAAA,cAAA;AAAA,YACF;AAAA,UACD;AAAA;AAAA,QACD;AAAA,MAED;AAAA,IACD,CACA;AAAA,EACF;AACD;"}
@@ -23,7 +23,7 @@ const OrderByTypeProvider = require("./OrderByTypeProvider.cjs");
23
23
  const HasManyToHasOneReducer = require("../extensions/hasManyToHasOneReducer/HasManyToHasOneReducer.cjs");
24
24
  require("@contember/schema");
25
25
  require("@contember/database");
26
- require("fast-deep-equal");
26
+ require("@contember/utilities");
27
27
  require("../acl/PredicatesInjector.cjs");
28
28
  require("node:crypto");
29
29
  require("../mapper/select/Path.cjs");
@@ -21,7 +21,7 @@ import { OrderByTypeProvider } from "./OrderByTypeProvider.js";
21
21
  import { HasManyToHasOneReducer } from "../extensions/hasManyToHasOneReducer/HasManyToHasOneReducer.js";
22
22
  import "@contember/schema";
23
23
  import "@contember/database";
24
- import "fast-deep-equal";
24
+ import "@contember/utilities";
25
25
  import "../acl/PredicatesInjector.js";
26
26
  import "node:crypto";
27
27
  import "../mapper/select/Path.js";
@@ -44,6 +44,7 @@ class MutationProvider {
44
44
  const resultType = this.createResultType(entityName, "create");
45
45
  return {
46
46
  type: new graphql.GraphQLNonNull(resultType),
47
+ deprecationReason: entity.deprecationReason,
47
48
  args: {
48
49
  data: { type: new graphql.GraphQLNonNull(dataType) }
49
50
  },
@@ -72,6 +73,7 @@ class MutationProvider {
72
73
  }
73
74
  return {
74
75
  type: new graphql.GraphQLNonNull(this.createResultType(entityName, "delete")),
76
+ deprecationReason: entity.deprecationReason,
75
77
  args: {
76
78
  by: {
77
79
  type: new graphql.GraphQLNonNull(uniqueWhere)
@@ -107,6 +109,7 @@ class MutationProvider {
107
109
  }
108
110
  return {
109
111
  type: new graphql.GraphQLNonNull(resultType),
112
+ deprecationReason: entity.deprecationReason,
110
113
  args: {
111
114
  by: {
112
115
  type: new graphql.GraphQLNonNull(uniqueWhere)
@@ -147,6 +150,7 @@ class MutationProvider {
147
150
  }
148
151
  return {
149
152
  type: new graphql.GraphQLNonNull(resultType),
153
+ deprecationReason: entity.deprecationReason,
150
154
  args: {
151
155
  by: {
152
156
  type: new graphql.GraphQLNonNull(uniqueWhere)
@@ -1 +1 @@
1
- {"version":3,"file":"MutationProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/MutationProvider.ts"],"sourcesContent":["import { GraphQLBoolean, GraphQLFieldConfig, GraphQLNonNull, GraphQLObjectType, GraphQLObjectTypeConfig, GraphQLString } 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 { EntityInputProvider, EntityInputType } from './mutations/index.js'\nimport { filterObject } from '../utils/index.js'\nimport { aliasAwareResolver, GqlTypeName } from './utils.js'\nimport { ResultSchemaTypeProvider } from './ResultSchemaTypeProvider.js'\nimport { ExtensionKey, Operation, OperationMeta } from './OperationExtension.js'\n\ntype FieldConfig<TArgs> = GraphQLFieldConfig<any, Context, TArgs>\n\nexport class MutationProvider {\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\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 getMutations(entity: Model.Entity): { [fieldName: string]: FieldConfig<any> } {\n\t\tconst entityName = entity.name\n\t\tconst mutations: { [fieldName: string]: FieldConfig<any> | undefined } = {}\n\t\tmutations[`create${entityName}`] = this.getCreateMutation(entity)\n\t\tmutations[`delete${entityName}`] = this.getDeleteMutation(entity)\n\t\tmutations[`update${entityName}`] = this.getUpdateMutation(entity)\n\t\tmutations[`upsert${entityName}`] = this.getUpsertMutation(entity)\n\n\t\treturn filterObject(mutations, (key, value): value is FieldConfig<any> => value !== undefined)\n\t}\n\n\t/**\n\t * Root update, delete and upsert locate their row by a unique lookup that reads in the nested set (root ∪ through).\n\t * Without any read grant there the lookup never finds a row, so the mutation would always fail.\n\t */\n\tprivate isLookupReadable(entity: Model.Entity): boolean {\n\t\treturn this.authorizator.getEntityPermission(Acl.Operation.read, entity.name) !== 'no'\n\t}\n\n\tprotected getCreateMutation(entity: Model.Entity): FieldConfig<Input.CreateInput> | undefined {\n\t\t// Root entry points are gated on the root grants alone - a `through` grant must not open one.\n\t\tif (this.rootAuthorizator.getEntityPermission(Acl.Operation.create, entity.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\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\tconst resultType = this.createResultType(entityName, 'create')\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\n\t\t\targs: {\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.create, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.mutation.${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.mutationResolver.resolveCreate(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprotected getDeleteMutation(entity: Model.Entity): FieldConfig<Input.DeleteInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tif (entity.view) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (!this.isLookupReadable(entity) || this.rootAuthorizator.getEntityPermission(Acl.Operation.delete, entityName) === 'no') {\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.createResultType(entityName, 'delete')),\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.delete, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.mutation.${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.mutationResolver.resolveDelete(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprotected getUpdateMutation(entity: Model.Entity): FieldConfig<Input.UpdateInput> | undefined {\n\t\tif (!this.isLookupReadable(entity) || this.rootAuthorizator.getEntityPermission(Acl.Operation.update, entity.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\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 resultType = this.createResultType(entityName, 'update')\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(resultType),\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\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.update, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.${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.mutationResolver.resolveUpdate(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getUpsertMutation(entity: Model.Entity): FieldConfig<Input.UpsertInput> | undefined {\n\t\tif (\n\t\t\t!this.isLookupReadable(entity)\n\t\t\t|| this.rootAuthorizator.getEntityPermission(Acl.Operation.update, entity.name) === 'no'\n\t\t\t|| this.rootAuthorizator.getEntityPermission(Acl.Operation.create, entity.name) === 'no'\n\t\t) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst createInput = this.createEntityInputProvider.getInput(entityName)\n\t\tif (createInput === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst updateInput = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (updateInput === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'upsert')\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(resultType),\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\tupdate: { type: new GraphQLNonNull(updateInput) },\n\t\t\t\tcreate: { type: new GraphQLNonNull(createInput) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.upsert, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.${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.mutationResolver.resolveUpsert(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate createResultType(\n\t\tentityName: string,\n\t\toperation: 'create' | 'update' | 'delete' | 'upsert',\n\t): GraphQLObjectType {\n\t\tconst fields: GraphQLObjectTypeConfig<any, any>['fields'] = {\n\t\t\tok: { type: new GraphQLNonNull(GraphQLBoolean) },\n\t\t\terrorMessage: { type: GraphQLString },\n\t\t\terrors: { type: this.resultSchemaTypeProvider.errorListResultType },\n\t\t}\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) !== 'no') {\n\t\t\tconst nodeType = this.entityTypeProvider.getEntity(entityName)\n\t\t\tfields.node = { type: nodeType, resolve: aliasAwareResolver }\n\t\t}\n\t\tif (operation !== 'delete') {\n\t\t\tfields.validation = {\n\t\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\t}\n\t\t}\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}${operation}Result`,\n\t\t\tfields: fields,\n\t\t\tinterfaces: [this.resultSchemaTypeProvider.mutationResultType],\n\t\t})\n\t}\n}\n"],"names":["filterObject","Acl","GraphQLNonNull","ExtensionKey","OperationMeta","Operation","GraphQLBoolean","GraphQLString","aliasAwareResolver","GraphQLObjectType","GqlTypeName"],"mappings":";;;;;;;;AAcO,MAAM,iBAAiB;AAAA,EAC7B,YACkB,cACA,kBACA,mBACA,oBACA,2BACA,2BACA,0BAChB;AAPgB,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,oBAAA;AACA,SAAA,qBAAA;AACA,SAAA,4BAAA;AACA,SAAA,4BAAA;AACA,SAAA,2BAAA;AAAA,EACf;AAAA,EAEI,aAAa,QAAiE;AACpF,UAAM,aAAa,OAAO;AAC1B,UAAM,YAAmE,CAAA;AACzE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAChE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAChE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAChE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAEhE,WAAOA,OAAAA,aAAa,WAAW,CAAC,KAAK,UAAqC,UAAU,MAAS;AAAA,EAC9F;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,iBAAiB,QAA+B;AACvD,WAAO,KAAK,aAAa,oBAAoBC,OAAAA,IAAI,UAAU,MAAM,OAA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,MAAAA,cAAc,UAAU,GAAG,SAAS;AAAA,MAC1C;AAAA,MACA,YAAY,CAAC,KAAK,yBAAyB,kBAAkB;AAAA,IAAA,CAC7D;AAAA,EACF;AACD;;"}
1
+ {"version":3,"file":"MutationProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/MutationProvider.ts"],"sourcesContent":["import { GraphQLBoolean, GraphQLFieldConfig, GraphQLNonNull, GraphQLObjectType, GraphQLObjectTypeConfig, GraphQLString } 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 { EntityInputProvider, EntityInputType } from './mutations/index.js'\nimport { filterObject } from '../utils/index.js'\nimport { aliasAwareResolver, GqlTypeName } from './utils.js'\nimport { ResultSchemaTypeProvider } from './ResultSchemaTypeProvider.js'\nimport { ExtensionKey, Operation, OperationMeta } from './OperationExtension.js'\n\ntype FieldConfig<TArgs> = GraphQLFieldConfig<any, Context, TArgs>\n\nexport class MutationProvider {\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\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 getMutations(entity: Model.Entity): { [fieldName: string]: FieldConfig<any> } {\n\t\tconst entityName = entity.name\n\t\tconst mutations: { [fieldName: string]: FieldConfig<any> | undefined } = {}\n\t\tmutations[`create${entityName}`] = this.getCreateMutation(entity)\n\t\tmutations[`delete${entityName}`] = this.getDeleteMutation(entity)\n\t\tmutations[`update${entityName}`] = this.getUpdateMutation(entity)\n\t\tmutations[`upsert${entityName}`] = this.getUpsertMutation(entity)\n\n\t\treturn filterObject(mutations, (key, value): value is FieldConfig<any> => value !== undefined)\n\t}\n\n\t/**\n\t * Root update, delete and upsert locate their row by a unique lookup that reads in the nested set (root ∪ through).\n\t * Without any read grant there the lookup never finds a row, so the mutation would always fail.\n\t */\n\tprivate isLookupReadable(entity: Model.Entity): boolean {\n\t\treturn this.authorizator.getEntityPermission(Acl.Operation.read, entity.name) !== 'no'\n\t}\n\n\tprotected getCreateMutation(entity: Model.Entity): FieldConfig<Input.CreateInput> | undefined {\n\t\t// Root entry points are gated on the root grants alone - a `through` grant must not open one.\n\t\tif (this.rootAuthorizator.getEntityPermission(Acl.Operation.create, entity.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\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\tconst resultType = this.createResultType(entityName, 'create')\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\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\textensions: { [ExtensionKey]: new OperationMeta(Operation.create, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.mutation.${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.mutationResolver.resolveCreate(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprotected getDeleteMutation(entity: Model.Entity): FieldConfig<Input.DeleteInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tif (entity.view) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (!this.isLookupReadable(entity) || this.rootAuthorizator.getEntityPermission(Acl.Operation.delete, entityName) === 'no') {\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.createResultType(entityName, 'delete')),\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.delete, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.mutation.${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.mutationResolver.resolveDelete(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprotected getUpdateMutation(entity: Model.Entity): FieldConfig<Input.UpdateInput> | undefined {\n\t\tif (!this.isLookupReadable(entity) || this.rootAuthorizator.getEntityPermission(Acl.Operation.update, entity.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\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 resultType = this.createResultType(entityName, 'update')\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(resultType),\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\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.update, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.${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.mutationResolver.resolveUpdate(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getUpsertMutation(entity: Model.Entity): FieldConfig<Input.UpsertInput> | undefined {\n\t\tif (\n\t\t\t!this.isLookupReadable(entity)\n\t\t\t|| this.rootAuthorizator.getEntityPermission(Acl.Operation.update, entity.name) === 'no'\n\t\t\t|| this.rootAuthorizator.getEntityPermission(Acl.Operation.create, entity.name) === 'no'\n\t\t) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst createInput = this.createEntityInputProvider.getInput(entityName)\n\t\tif (createInput === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst updateInput = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (updateInput === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'upsert')\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(resultType),\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\tupdate: { type: new GraphQLNonNull(updateInput) },\n\t\t\t\tcreate: { type: new GraphQLNonNull(createInput) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.upsert, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.${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.mutationResolver.resolveUpsert(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate createResultType(\n\t\tentityName: string,\n\t\toperation: 'create' | 'update' | 'delete' | 'upsert',\n\t): GraphQLObjectType {\n\t\tconst fields: GraphQLObjectTypeConfig<any, any>['fields'] = {\n\t\t\tok: { type: new GraphQLNonNull(GraphQLBoolean) },\n\t\t\terrorMessage: { type: GraphQLString },\n\t\t\terrors: { type: this.resultSchemaTypeProvider.errorListResultType },\n\t\t}\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) !== 'no') {\n\t\t\tconst nodeType = this.entityTypeProvider.getEntity(entityName)\n\t\t\tfields.node = { type: nodeType, resolve: aliasAwareResolver }\n\t\t}\n\t\tif (operation !== 'delete') {\n\t\t\tfields.validation = {\n\t\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\t}\n\t\t}\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}${operation}Result`,\n\t\t\tfields: fields,\n\t\t\tinterfaces: [this.resultSchemaTypeProvider.mutationResultType],\n\t\t})\n\t}\n}\n"],"names":["filterObject","Acl","GraphQLNonNull","ExtensionKey","OperationMeta","Operation","GraphQLBoolean","GraphQLString","aliasAwareResolver","GraphQLObjectType","GqlTypeName"],"mappings":";;;;;;;;AAcO,MAAM,iBAAiB;AAAA,EAC7B,YACkB,cACA,kBACA,mBACA,oBACA,2BACA,2BACA,0BAChB;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,KAAK,KAAK,GAAG;AAAA,UAC5B;AACA,iBAAO,QAAQ,mBAAmB,iBAAiB,cAAc,QAAQ,IAAI;AAAA,QAC9E,CAAC;AAAA,MACF;AAAA,IAAA;AAAA,EAEF;AAAA,EAEQ,iBACP,YACA,WACoB;AACpB,UAAM,SAAsD;AAAA,MAC3D,IAAI,EAAE,MAAM,IAAIH,QAAAA,eAAeI,QAAAA,cAAc,EAAA;AAAA,MAC7C,cAAc,EAAE,MAAMC,sBAAA;AAAA,MACtB,QAAQ,EAAE,MAAM,KAAK,yBAAyB,oBAAA;AAAA,IAAoB;AAEnE,QAAI,KAAK,aAAa,oBAAoBN,OAAAA,IAAI,UAAU,MAAM,UAAU,MAAM,MAAM;AACnF,YAAM,WAAW,KAAK,mBAAmB,UAAU,UAAU;AAC7D,aAAO,OAAO,EAAE,MAAM,UAAU,SAASO,MAAAA,mBAAA;AAAA,IAC1C;AACA,QAAI,cAAc,UAAU;AAC3B,aAAO,aAAa;AAAA,QACnB,MAAM,IAAIN,QAAAA,eAAe,KAAK,yBAAyB,oBAAoB;AAAA,MAAA;AAAA,IAE7E;AACA,WAAO,IAAIO,QAAAA,kBAAkB;AAAA,MAC5B,MAAMC,MAAAA,cAAc,UAAU,GAAG,SAAS;AAAA,MAC1C;AAAA,MACA,YAAY,CAAC,KAAK,yBAAyB,kBAAkB;AAAA,IAAA,CAC7D;AAAA,EACF;AACD;;"}
@@ -42,6 +42,7 @@ class MutationProvider {
42
42
  const resultType = this.createResultType(entityName, "create");
43
43
  return {
44
44
  type: new GraphQLNonNull(resultType),
45
+ deprecationReason: entity.deprecationReason,
45
46
  args: {
46
47
  data: { type: new GraphQLNonNull(dataType) }
47
48
  },
@@ -70,6 +71,7 @@ class MutationProvider {
70
71
  }
71
72
  return {
72
73
  type: new GraphQLNonNull(this.createResultType(entityName, "delete")),
74
+ deprecationReason: entity.deprecationReason,
73
75
  args: {
74
76
  by: {
75
77
  type: new GraphQLNonNull(uniqueWhere)
@@ -105,6 +107,7 @@ class MutationProvider {
105
107
  }
106
108
  return {
107
109
  type: new GraphQLNonNull(resultType),
110
+ deprecationReason: entity.deprecationReason,
108
111
  args: {
109
112
  by: {
110
113
  type: new GraphQLNonNull(uniqueWhere)
@@ -145,6 +148,7 @@ class MutationProvider {
145
148
  }
146
149
  return {
147
150
  type: new GraphQLNonNull(resultType),
151
+ deprecationReason: entity.deprecationReason,
148
152
  args: {
149
153
  by: {
150
154
  type: new GraphQLNonNull(uniqueWhere)