@contember/engine-content-api 2.2.0-alpha.2 → 2.2.0-alpha.20

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 (1205) hide show
  1. package/CLAUDE.md +25 -7
  2. package/dist/development/index.cjs +36 -0
  3. package/dist/development/index.cjs.map +1 -1
  4. package/dist/development/index.js +40 -4
  5. package/dist/development/index.js.map +1 -1
  6. package/dist/development/src/ExecutionContainer.cjs +18 -10
  7. package/dist/development/src/ExecutionContainer.cjs.map +1 -1
  8. package/dist/development/src/ExecutionContainer.js +18 -10
  9. package/dist/development/src/ExecutionContainer.js.map +1 -1
  10. package/dist/development/src/acl/AclScope.cjs +7 -0
  11. package/dist/development/src/acl/AclScope.cjs.map +1 -0
  12. package/dist/development/src/acl/AclScope.js +7 -0
  13. package/dist/development/src/acl/AclScope.js.map +1 -0
  14. package/dist/development/src/acl/Authorizator.cjs +6 -4
  15. package/dist/development/src/acl/Authorizator.cjs.map +1 -1
  16. package/dist/development/src/acl/Authorizator.js +6 -4
  17. package/dist/development/src/acl/Authorizator.js.map +1 -1
  18. package/dist/development/src/acl/EvaluatedPredicateReplacer.cjs +4 -1
  19. package/dist/development/src/acl/EvaluatedPredicateReplacer.cjs.map +1 -1
  20. package/dist/development/src/acl/EvaluatedPredicateReplacer.js +4 -1
  21. package/dist/development/src/acl/EvaluatedPredicateReplacer.js.map +1 -1
  22. package/dist/development/src/acl/PermissionFactory.cjs +57 -68
  23. package/dist/development/src/acl/PermissionFactory.cjs.map +1 -1
  24. package/dist/development/src/acl/PermissionFactory.js +58 -69
  25. package/dist/development/src/acl/PermissionFactory.js.map +1 -1
  26. package/dist/development/src/acl/PredicateFactory.cjs +95 -26
  27. package/dist/development/src/acl/PredicateFactory.cjs.map +1 -1
  28. package/dist/development/src/acl/PredicateFactory.js +95 -26
  29. package/dist/development/src/acl/PredicateFactory.js.map +1 -1
  30. package/dist/development/src/acl/PredicatesInjector.cjs +97 -99
  31. package/dist/development/src/acl/PredicatesInjector.cjs.map +1 -1
  32. package/dist/development/src/acl/PredicatesInjector.js +99 -101
  33. package/dist/development/src/acl/PredicatesInjector.js.map +1 -1
  34. package/dist/development/src/acl/VariableInjector.cjs +7 -2
  35. package/dist/development/src/acl/VariableInjector.cjs.map +1 -1
  36. package/dist/development/src/acl/VariableInjector.js +7 -2
  37. package/dist/development/src/acl/VariableInjector.js.map +1 -1
  38. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs +28 -2
  39. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs.map +1 -1
  40. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js +29 -3
  41. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js.map +1 -1
  42. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +16 -1
  43. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
  44. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +16 -1
  45. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
  46. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs +29 -3
  47. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs.map +1 -1
  48. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js +29 -3
  49. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js.map +1 -1
  50. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs +14 -0
  51. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs.map +1 -1
  52. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +14 -0
  53. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js.map +1 -1
  54. package/dist/development/src/input-validation/ValidationDataSelector.cjs +2 -2
  55. package/dist/development/src/input-validation/ValidationDataSelector.cjs.map +1 -1
  56. package/dist/development/src/input-validation/ValidationDataSelector.js +2 -2
  57. package/dist/development/src/input-validation/ValidationDataSelector.js.map +1 -1
  58. package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs +24 -3
  59. package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs.map +1 -1
  60. package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js +24 -3
  61. package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map +1 -1
  62. package/dist/development/src/inputProcessing/UpdateInputVisitor.cjs +52 -2
  63. package/dist/development/src/inputProcessing/UpdateInputVisitor.cjs.map +1 -1
  64. package/dist/development/src/inputProcessing/UpdateInputVisitor.js +52 -2
  65. package/dist/development/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
  66. package/dist/development/src/introspection/IntrospectionSchemaFactory.cjs +11 -6
  67. package/dist/development/src/introspection/IntrospectionSchemaFactory.cjs.map +1 -1
  68. package/dist/development/src/introspection/IntrospectionSchemaFactory.js +11 -6
  69. package/dist/development/src/introspection/IntrospectionSchemaFactory.js.map +1 -1
  70. package/dist/development/src/introspection/introspection.schema.cjs +2 -2
  71. package/dist/development/src/introspection/introspection.schema.cjs.map +1 -1
  72. package/dist/development/src/introspection/introspection.schema.js +2 -2
  73. package/dist/development/src/introspection/introspection.schema.js.map +1 -1
  74. package/dist/development/src/mapper/ErrorUtils.cjs +17 -1
  75. package/dist/development/src/mapper/ErrorUtils.cjs.map +1 -1
  76. package/dist/development/src/mapper/ErrorUtils.js +17 -1
  77. package/dist/development/src/mapper/ErrorUtils.js.map +1 -1
  78. package/dist/development/src/mapper/JunctionTableManager.cjs +18 -12
  79. package/dist/development/src/mapper/JunctionTableManager.cjs.map +1 -1
  80. package/dist/development/src/mapper/JunctionTableManager.js +19 -13
  81. package/dist/development/src/mapper/JunctionTableManager.js.map +1 -1
  82. package/dist/development/src/mapper/Mapper.cjs +111 -37
  83. package/dist/development/src/mapper/Mapper.cjs.map +1 -1
  84. package/dist/development/src/mapper/Mapper.js +112 -38
  85. package/dist/development/src/mapper/Mapper.js.map +1 -1
  86. package/dist/development/src/mapper/MapperFactory.cjs +7 -4
  87. package/dist/development/src/mapper/MapperFactory.cjs.map +1 -1
  88. package/dist/development/src/mapper/MapperFactory.js +7 -4
  89. package/dist/development/src/mapper/MapperFactory.js.map +1 -1
  90. package/dist/development/src/mapper/MutationProcessorHelper.cjs +12 -0
  91. package/dist/development/src/mapper/MutationProcessorHelper.cjs.map +1 -1
  92. package/dist/development/src/mapper/MutationProcessorHelper.js +13 -1
  93. package/dist/development/src/mapper/MutationProcessorHelper.js.map +1 -1
  94. package/dist/development/src/mapper/Result.cjs +1 -0
  95. package/dist/development/src/mapper/Result.cjs.map +1 -1
  96. package/dist/development/src/mapper/Result.js +1 -0
  97. package/dist/development/src/mapper/Result.js.map +1 -1
  98. package/dist/development/src/mapper/delete/DeleteExecutor.cjs +15 -8
  99. package/dist/development/src/mapper/delete/DeleteExecutor.cjs.map +1 -1
  100. package/dist/development/src/mapper/delete/DeleteExecutor.js +15 -8
  101. package/dist/development/src/mapper/delete/DeleteExecutor.js.map +1 -1
  102. package/dist/development/src/mapper/insert/InsertBuilder.cjs +3 -2
  103. package/dist/development/src/mapper/insert/InsertBuilder.cjs.map +1 -1
  104. package/dist/development/src/mapper/insert/InsertBuilder.js +3 -2
  105. package/dist/development/src/mapper/insert/InsertBuilder.js.map +1 -1
  106. package/dist/development/src/mapper/insert/InsertBuilderFactory.cjs +2 -2
  107. package/dist/development/src/mapper/insert/InsertBuilderFactory.cjs.map +1 -1
  108. package/dist/development/src/mapper/insert/InsertBuilderFactory.js +2 -2
  109. package/dist/development/src/mapper/insert/InsertBuilderFactory.js.map +1 -1
  110. package/dist/development/src/mapper/insert/Inserter.cjs +3 -3
  111. package/dist/development/src/mapper/insert/Inserter.cjs.map +1 -1
  112. package/dist/development/src/mapper/insert/Inserter.js +3 -3
  113. package/dist/development/src/mapper/insert/Inserter.js.map +1 -1
  114. package/dist/development/src/mapper/insert/SqlCreateInputProcessor.cjs +3 -2
  115. package/dist/development/src/mapper/insert/SqlCreateInputProcessor.cjs.map +1 -1
  116. package/dist/development/src/mapper/insert/SqlCreateInputProcessor.js +3 -2
  117. package/dist/development/src/mapper/insert/SqlCreateInputProcessor.js.map +1 -1
  118. package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs +9 -8
  119. package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs.map +1 -1
  120. package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js +9 -8
  121. package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js.map +1 -1
  122. package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs +4 -4
  123. package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs.map +1 -1
  124. package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js +4 -4
  125. package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js.map +1 -1
  126. package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs +3 -3
  127. package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs.map +1 -1
  128. package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js +3 -3
  129. package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js.map +1 -1
  130. package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs +7 -7
  131. package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs.map +1 -1
  132. package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js +7 -7
  133. package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js.map +1 -1
  134. package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs +6 -6
  135. package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs.map +1 -1
  136. package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js +6 -6
  137. package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js.map +1 -1
  138. package/dist/development/src/mapper/select/ConditionBuilder.cjs +8 -1
  139. package/dist/development/src/mapper/select/ConditionBuilder.cjs.map +1 -1
  140. package/dist/development/src/mapper/select/ConditionBuilder.js +8 -1
  141. package/dist/development/src/mapper/select/ConditionBuilder.js.map +1 -1
  142. package/dist/development/src/mapper/select/JoinBuilder.cjs +26 -4
  143. package/dist/development/src/mapper/select/JoinBuilder.cjs.map +1 -1
  144. package/dist/development/src/mapper/select/JoinBuilder.js +27 -5
  145. package/dist/development/src/mapper/select/JoinBuilder.js.map +1 -1
  146. package/dist/development/src/mapper/select/OrderByBuilder.cjs +84 -15
  147. package/dist/development/src/mapper/select/OrderByBuilder.cjs.map +1 -1
  148. package/dist/development/src/mapper/select/OrderByBuilder.js +86 -17
  149. package/dist/development/src/mapper/select/OrderByBuilder.js.map +1 -1
  150. package/dist/development/src/mapper/select/OrderByHelper.cjs +17 -7
  151. package/dist/development/src/mapper/select/OrderByHelper.cjs.map +1 -1
  152. package/dist/development/src/mapper/select/OrderByHelper.js +17 -7
  153. package/dist/development/src/mapper/select/OrderByHelper.js.map +1 -1
  154. package/dist/development/src/mapper/select/Path.cjs +25 -3
  155. package/dist/development/src/mapper/select/Path.cjs.map +1 -1
  156. package/dist/development/src/mapper/select/Path.js +26 -4
  157. package/dist/development/src/mapper/select/Path.js.map +1 -1
  158. package/dist/development/src/mapper/select/RelationFetcher.cjs +6 -5
  159. package/dist/development/src/mapper/select/RelationFetcher.cjs.map +1 -1
  160. package/dist/development/src/mapper/select/RelationFetcher.js +6 -5
  161. package/dist/development/src/mapper/select/RelationFetcher.js.map +1 -1
  162. package/dist/development/src/mapper/select/SelectBuilder.cjs +15 -21
  163. package/dist/development/src/mapper/select/SelectBuilder.cjs.map +1 -1
  164. package/dist/development/src/mapper/select/SelectBuilder.js +13 -19
  165. package/dist/development/src/mapper/select/SelectBuilder.js.map +1 -1
  166. package/dist/development/src/mapper/select/SelectHydrator.cjs +92 -31
  167. package/dist/development/src/mapper/select/SelectHydrator.cjs.map +1 -1
  168. package/dist/development/src/mapper/select/SelectHydrator.js +92 -31
  169. package/dist/development/src/mapper/select/SelectHydrator.js.map +1 -1
  170. package/dist/development/src/mapper/select/WhereBuilder.cjs +261 -47
  171. package/dist/development/src/mapper/select/WhereBuilder.cjs.map +1 -1
  172. package/dist/development/src/mapper/select/WhereBuilder.js +262 -48
  173. package/dist/development/src/mapper/select/WhereBuilder.js.map +1 -1
  174. package/dist/development/src/mapper/select/getFieldReadPredicate.cjs +8 -0
  175. package/dist/development/src/mapper/select/getFieldReadPredicate.cjs.map +1 -0
  176. package/dist/development/src/mapper/select/getFieldReadPredicate.js +8 -0
  177. package/dist/development/src/mapper/select/getFieldReadPredicate.js.map +1 -0
  178. package/dist/development/src/mapper/select/handlers/FieldsVisitor.cjs +9 -13
  179. package/dist/development/src/mapper/select/handlers/FieldsVisitor.cjs.map +1 -1
  180. package/dist/development/src/mapper/select/handlers/FieldsVisitor.js +10 -14
  181. package/dist/development/src/mapper/select/handlers/FieldsVisitor.js.map +1 -1
  182. package/dist/development/src/mapper/select/handlers/MetaHandler.cjs +6 -2
  183. package/dist/development/src/mapper/select/handlers/MetaHandler.cjs.map +1 -1
  184. package/dist/development/src/mapper/select/handlers/MetaHandler.js +6 -2
  185. package/dist/development/src/mapper/select/handlers/MetaHandler.js.map +1 -1
  186. package/dist/development/src/mapper/select/optimizer/WhereOptimizer.cjs +229 -3
  187. package/dist/development/src/mapper/select/optimizer/WhereOptimizer.cjs.map +1 -1
  188. package/dist/development/src/mapper/select/optimizer/WhereOptimizer.js +230 -4
  189. package/dist/development/src/mapper/select/optimizer/WhereOptimizer.js.map +1 -1
  190. package/dist/development/src/mapper/select/optimizer/WhereReplacer.cjs +3 -3
  191. package/dist/development/src/mapper/select/optimizer/WhereReplacer.cjs.map +1 -1
  192. package/dist/development/src/mapper/select/optimizer/WhereReplacer.js +1 -1
  193. package/dist/development/src/mapper/select/optimizer/WhereReplacer.js.map +1 -1
  194. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.cjs +9 -5
  195. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
  196. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.js +10 -6
  197. package/dist/development/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
  198. package/dist/development/src/mapper/update/UpdateBuilder.cjs +35 -2
  199. package/dist/development/src/mapper/update/UpdateBuilder.cjs.map +1 -1
  200. package/dist/development/src/mapper/update/UpdateBuilder.js +36 -3
  201. package/dist/development/src/mapper/update/UpdateBuilder.js.map +1 -1
  202. package/dist/development/src/mapper/update/UpdateBuilderFactory.cjs +3 -2
  203. package/dist/development/src/mapper/update/UpdateBuilderFactory.cjs.map +1 -1
  204. package/dist/development/src/mapper/update/UpdateBuilderFactory.js +3 -2
  205. package/dist/development/src/mapper/update/UpdateBuilderFactory.js.map +1 -1
  206. package/dist/development/src/mapper/update/Updater.cjs +12 -6
  207. package/dist/development/src/mapper/update/Updater.cjs.map +1 -1
  208. package/dist/development/src/mapper/update/Updater.js +13 -7
  209. package/dist/development/src/mapper/update/Updater.js.map +1 -1
  210. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs +33 -19
  211. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -1
  212. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js +33 -19
  213. package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -1
  214. package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs +13 -11
  215. package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs.map +1 -1
  216. package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js +13 -11
  217. package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js.map +1 -1
  218. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs +17 -8
  219. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -1
  220. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js +17 -8
  221. package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -1
  222. package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs +19 -16
  223. package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs.map +1 -1
  224. package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js +19 -16
  225. package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js.map +1 -1
  226. package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs +19 -16
  227. package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs.map +1 -1
  228. package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js +19 -16
  229. package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js.map +1 -1
  230. package/dist/development/src/mapper/update/relations/SetManyRelationHelper.cjs +123 -0
  231. package/dist/development/src/mapper/update/relations/SetManyRelationHelper.cjs.map +1 -0
  232. package/dist/development/src/mapper/update/relations/SetManyRelationHelper.js +123 -0
  233. package/dist/development/src/mapper/update/relations/SetManyRelationHelper.js.map +1 -0
  234. package/dist/development/src/resolvers/GraphQlQueryAstFactory.cjs.map +1 -1
  235. package/dist/development/src/resolvers/GraphQlQueryAstFactory.js.map +1 -1
  236. package/dist/development/src/resolvers/MutationResolver.cjs +76 -79
  237. package/dist/development/src/resolvers/MutationResolver.cjs.map +1 -1
  238. package/dist/development/src/resolvers/MutationResolver.js +78 -81
  239. package/dist/development/src/resolvers/MutationResolver.js.map +1 -1
  240. package/dist/development/src/resolvers/ReadHelpers.cjs +17 -6
  241. package/dist/development/src/resolvers/ReadHelpers.cjs.map +1 -1
  242. package/dist/development/src/resolvers/ReadHelpers.js +17 -6
  243. package/dist/development/src/resolvers/ReadHelpers.js.map +1 -1
  244. package/dist/development/src/resolvers/ReadResolver.cjs +27 -22
  245. package/dist/development/src/resolvers/ReadResolver.cjs.map +1 -1
  246. package/dist/development/src/resolvers/ReadResolver.js +27 -22
  247. package/dist/development/src/resolvers/ReadResolver.js.map +1 -1
  248. package/dist/development/src/schema/CustomTypesProvider.cjs +35 -14
  249. package/dist/development/src/schema/CustomTypesProvider.cjs.map +1 -1
  250. package/dist/development/src/schema/CustomTypesProvider.js +36 -15
  251. package/dist/development/src/schema/CustomTypesProvider.js.map +1 -1
  252. package/dist/development/src/schema/EntityTypeProvider.cjs +11 -7
  253. package/dist/development/src/schema/EntityTypeProvider.cjs.map +1 -1
  254. package/dist/development/src/schema/EntityTypeProvider.js +11 -7
  255. package/dist/development/src/schema/EntityTypeProvider.js.map +1 -1
  256. package/dist/development/src/schema/GraphQlSchemaBuilder.cjs +16 -6
  257. package/dist/development/src/schema/GraphQlSchemaBuilder.cjs.map +1 -1
  258. package/dist/development/src/schema/GraphQlSchemaBuilder.js +16 -6
  259. package/dist/development/src/schema/GraphQlSchemaBuilder.js.map +1 -1
  260. package/dist/development/src/schema/GraphQlSchemaBuilderFactory.cjs +39 -11
  261. package/dist/development/src/schema/GraphQlSchemaBuilderFactory.cjs.map +1 -1
  262. package/dist/development/src/schema/GraphQlSchemaBuilderFactory.js +39 -11
  263. package/dist/development/src/schema/GraphQlSchemaBuilderFactory.js.map +1 -1
  264. package/dist/development/src/schema/MutationProvider.cjs +38 -16
  265. package/dist/development/src/schema/MutationProvider.cjs.map +1 -1
  266. package/dist/development/src/schema/MutationProvider.js +38 -16
  267. package/dist/development/src/schema/MutationProvider.js.map +1 -1
  268. package/dist/development/src/schema/OrderByTypeProvider.cjs +8 -2
  269. package/dist/development/src/schema/OrderByTypeProvider.cjs.map +1 -1
  270. package/dist/development/src/schema/OrderByTypeProvider.js +9 -3
  271. package/dist/development/src/schema/OrderByTypeProvider.js.map +1 -1
  272. package/dist/development/src/schema/QueryProvider.cjs +12 -11
  273. package/dist/development/src/schema/QueryProvider.cjs.map +1 -1
  274. package/dist/development/src/schema/QueryProvider.js +12 -11
  275. package/dist/development/src/schema/QueryProvider.js.map +1 -1
  276. package/dist/development/src/schema/ValidationQueriesProvider.cjs +2 -0
  277. package/dist/development/src/schema/ValidationQueriesProvider.cjs.map +1 -1
  278. package/dist/development/src/schema/ValidationQueriesProvider.js +2 -0
  279. package/dist/development/src/schema/ValidationQueriesProvider.js.map +1 -1
  280. package/dist/development/src/schema/WhereTypeProvider.cjs +17 -5
  281. package/dist/development/src/schema/WhereTypeProvider.cjs.map +1 -1
  282. package/dist/development/src/schema/WhereTypeProvider.js +18 -6
  283. package/dist/development/src/schema/WhereTypeProvider.js.map +1 -1
  284. package/dist/development/src/schema/calendarDate.cjs +21 -0
  285. package/dist/development/src/schema/calendarDate.cjs.map +1 -0
  286. package/dist/development/src/schema/calendarDate.js +21 -0
  287. package/dist/development/src/schema/calendarDate.js.map +1 -0
  288. package/dist/development/src/schema/entities/FieldTypeVisitor.cjs +15 -2
  289. package/dist/development/src/schema/entities/FieldTypeVisitor.cjs.map +1 -1
  290. package/dist/development/src/schema/entities/FieldTypeVisitor.js +15 -2
  291. package/dist/development/src/schema/entities/FieldTypeVisitor.js.map +1 -1
  292. package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.cjs +11 -3
  293. package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.cjs.map +1 -1
  294. package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.js +11 -3
  295. package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.js.map +1 -1
  296. package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs +11 -3
  297. package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs.map +1 -1
  298. package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.js +11 -3
  299. package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.js.map +1 -1
  300. package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs +39 -2
  301. package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs.map +1 -1
  302. package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js +40 -3
  303. package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js.map +1 -1
  304. package/dist/development/src/schema/utils.cjs +10 -0
  305. package/dist/development/src/schema/utils.cjs.map +1 -1
  306. package/dist/development/src/schema/utils.js +11 -1
  307. package/dist/development/src/schema/utils.js.map +1 -1
  308. package/dist/development/src/schema-json/GraphQLJsBridge.cjs +108 -0
  309. package/dist/development/src/schema-json/GraphQLJsBridge.cjs.map +1 -0
  310. package/dist/development/src/schema-json/GraphQLJsBridge.js +108 -0
  311. package/dist/development/src/schema-json/GraphQLJsBridge.js.map +1 -0
  312. package/dist/development/src/schema-json/JsonColumnTypes.cjs +102 -0
  313. package/dist/development/src/schema-json/JsonColumnTypes.cjs.map +1 -0
  314. package/dist/development/src/schema-json/JsonColumnTypes.js +102 -0
  315. package/dist/development/src/schema-json/JsonColumnTypes.js.map +1 -0
  316. package/dist/development/src/schema-json/JsonContentSchemaBuilder.cjs +418 -0
  317. package/dist/development/src/schema-json/JsonContentSchemaBuilder.cjs.map +1 -0
  318. package/dist/development/src/schema-json/JsonContentSchemaBuilder.js +418 -0
  319. package/dist/development/src/schema-json/JsonContentSchemaBuilder.js.map +1 -0
  320. package/dist/development/src/schema-json/JsonContentSchemaShared.cjs +18 -0
  321. package/dist/development/src/schema-json/JsonContentSchemaShared.cjs.map +1 -0
  322. package/dist/development/src/schema-json/JsonContentSchemaShared.js +18 -0
  323. package/dist/development/src/schema-json/JsonContentSchemaShared.js.map +1 -0
  324. package/dist/development/src/schema-json/JsonEntityTypes.cjs +206 -0
  325. package/dist/development/src/schema-json/JsonEntityTypes.cjs.map +1 -0
  326. package/dist/development/src/schema-json/JsonEntityTypes.js +206 -0
  327. package/dist/development/src/schema-json/JsonEntityTypes.js.map +1 -0
  328. package/dist/development/src/schema-json/JsonFilterTypes.cjs +152 -0
  329. package/dist/development/src/schema-json/JsonFilterTypes.cjs.map +1 -0
  330. package/dist/development/src/schema-json/JsonFilterTypes.js +152 -0
  331. package/dist/development/src/schema-json/JsonFilterTypes.js.map +1 -0
  332. package/dist/development/src/schema-json/JsonInputTypes.cjs +256 -0
  333. package/dist/development/src/schema-json/JsonInputTypes.cjs.map +1 -0
  334. package/dist/development/src/schema-json/JsonInputTypes.js +256 -0
  335. package/dist/development/src/schema-json/JsonInputTypes.js.map +1 -0
  336. package/dist/development/src/schema-json/JsonIntrospectionExtension.cjs +36 -0
  337. package/dist/development/src/schema-json/JsonIntrospectionExtension.cjs.map +1 -0
  338. package/dist/development/src/schema-json/JsonIntrospectionExtension.js +36 -0
  339. package/dist/development/src/schema-json/JsonIntrospectionExtension.js.map +1 -0
  340. package/dist/development/src/schema-json/JsonQueryAstFactory.cjs +107 -0
  341. package/dist/development/src/schema-json/JsonQueryAstFactory.cjs.map +1 -0
  342. package/dist/development/src/schema-json/JsonQueryAstFactory.js +107 -0
  343. package/dist/development/src/schema-json/JsonQueryAstFactory.js.map +1 -0
  344. package/dist/development/src/schema-json/JsonTypeRegistry.cjs +230 -0
  345. package/dist/development/src/schema-json/JsonTypeRegistry.cjs.map +1 -0
  346. package/dist/development/src/schema-json/JsonTypeRegistry.js +230 -0
  347. package/dist/development/src/schema-json/JsonTypeRegistry.js.map +1 -0
  348. package/dist/development/src/utils/ResolveInfoUtils.cjs.map +1 -1
  349. package/dist/development/src/utils/ResolveInfoUtils.js.map +1 -1
  350. package/dist/development/src/utils/uniqueWhereFields.cjs +10 -0
  351. package/dist/development/src/utils/uniqueWhereFields.cjs.map +1 -1
  352. package/dist/development/src/utils/uniqueWhereFields.js +10 -0
  353. package/dist/development/src/utils/uniqueWhereFields.js.map +1 -1
  354. package/dist/production/index.cjs +36 -0
  355. package/dist/production/index.cjs.map +1 -1
  356. package/dist/production/index.js +40 -4
  357. package/dist/production/index.js.map +1 -1
  358. package/dist/production/src/ExecutionContainer.cjs +18 -10
  359. package/dist/production/src/ExecutionContainer.cjs.map +1 -1
  360. package/dist/production/src/ExecutionContainer.js +18 -10
  361. package/dist/production/src/ExecutionContainer.js.map +1 -1
  362. package/dist/production/src/acl/AclScope.cjs +7 -0
  363. package/dist/production/src/acl/AclScope.cjs.map +1 -0
  364. package/dist/production/src/acl/AclScope.js +7 -0
  365. package/dist/production/src/acl/AclScope.js.map +1 -0
  366. package/dist/production/src/acl/Authorizator.cjs +6 -4
  367. package/dist/production/src/acl/Authorizator.cjs.map +1 -1
  368. package/dist/production/src/acl/Authorizator.js +6 -4
  369. package/dist/production/src/acl/Authorizator.js.map +1 -1
  370. package/dist/production/src/acl/EvaluatedPredicateReplacer.cjs +4 -1
  371. package/dist/production/src/acl/EvaluatedPredicateReplacer.cjs.map +1 -1
  372. package/dist/production/src/acl/EvaluatedPredicateReplacer.js +4 -1
  373. package/dist/production/src/acl/EvaluatedPredicateReplacer.js.map +1 -1
  374. package/dist/production/src/acl/PermissionFactory.cjs +57 -68
  375. package/dist/production/src/acl/PermissionFactory.cjs.map +1 -1
  376. package/dist/production/src/acl/PermissionFactory.js +58 -69
  377. package/dist/production/src/acl/PermissionFactory.js.map +1 -1
  378. package/dist/production/src/acl/PredicateFactory.cjs +95 -26
  379. package/dist/production/src/acl/PredicateFactory.cjs.map +1 -1
  380. package/dist/production/src/acl/PredicateFactory.js +95 -26
  381. package/dist/production/src/acl/PredicateFactory.js.map +1 -1
  382. package/dist/production/src/acl/PredicatesInjector.cjs +97 -99
  383. package/dist/production/src/acl/PredicatesInjector.cjs.map +1 -1
  384. package/dist/production/src/acl/PredicatesInjector.js +99 -101
  385. package/dist/production/src/acl/PredicatesInjector.js.map +1 -1
  386. package/dist/production/src/acl/VariableInjector.cjs +7 -2
  387. package/dist/production/src/acl/VariableInjector.cjs.map +1 -1
  388. package/dist/production/src/acl/VariableInjector.js +7 -2
  389. package/dist/production/src/acl/VariableInjector.js.map +1 -1
  390. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs +28 -2
  391. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs.map +1 -1
  392. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js +29 -3
  393. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js.map +1 -1
  394. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +16 -1
  395. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
  396. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +16 -1
  397. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
  398. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs +29 -3
  399. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs.map +1 -1
  400. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js +29 -3
  401. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js.map +1 -1
  402. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs +14 -0
  403. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs.map +1 -1
  404. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +14 -0
  405. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js.map +1 -1
  406. package/dist/production/src/input-validation/ValidationDataSelector.cjs +2 -2
  407. package/dist/production/src/input-validation/ValidationDataSelector.cjs.map +1 -1
  408. package/dist/production/src/input-validation/ValidationDataSelector.js +2 -2
  409. package/dist/production/src/input-validation/ValidationDataSelector.js.map +1 -1
  410. package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs +24 -3
  411. package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs.map +1 -1
  412. package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js +24 -3
  413. package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map +1 -1
  414. package/dist/production/src/inputProcessing/UpdateInputVisitor.cjs +52 -2
  415. package/dist/production/src/inputProcessing/UpdateInputVisitor.cjs.map +1 -1
  416. package/dist/production/src/inputProcessing/UpdateInputVisitor.js +52 -2
  417. package/dist/production/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
  418. package/dist/production/src/introspection/IntrospectionSchemaFactory.cjs +11 -6
  419. package/dist/production/src/introspection/IntrospectionSchemaFactory.cjs.map +1 -1
  420. package/dist/production/src/introspection/IntrospectionSchemaFactory.js +11 -6
  421. package/dist/production/src/introspection/IntrospectionSchemaFactory.js.map +1 -1
  422. package/dist/production/src/introspection/introspection.schema.cjs +2 -2
  423. package/dist/production/src/introspection/introspection.schema.cjs.map +1 -1
  424. package/dist/production/src/introspection/introspection.schema.js +2 -2
  425. package/dist/production/src/introspection/introspection.schema.js.map +1 -1
  426. package/dist/production/src/mapper/ErrorUtils.cjs +17 -1
  427. package/dist/production/src/mapper/ErrorUtils.cjs.map +1 -1
  428. package/dist/production/src/mapper/ErrorUtils.js +17 -1
  429. package/dist/production/src/mapper/ErrorUtils.js.map +1 -1
  430. package/dist/production/src/mapper/JunctionTableManager.cjs +18 -12
  431. package/dist/production/src/mapper/JunctionTableManager.cjs.map +1 -1
  432. package/dist/production/src/mapper/JunctionTableManager.js +19 -13
  433. package/dist/production/src/mapper/JunctionTableManager.js.map +1 -1
  434. package/dist/production/src/mapper/Mapper.cjs +111 -37
  435. package/dist/production/src/mapper/Mapper.cjs.map +1 -1
  436. package/dist/production/src/mapper/Mapper.js +112 -38
  437. package/dist/production/src/mapper/Mapper.js.map +1 -1
  438. package/dist/production/src/mapper/MapperFactory.cjs +7 -4
  439. package/dist/production/src/mapper/MapperFactory.cjs.map +1 -1
  440. package/dist/production/src/mapper/MapperFactory.js +7 -4
  441. package/dist/production/src/mapper/MapperFactory.js.map +1 -1
  442. package/dist/production/src/mapper/MutationProcessorHelper.cjs +12 -0
  443. package/dist/production/src/mapper/MutationProcessorHelper.cjs.map +1 -1
  444. package/dist/production/src/mapper/MutationProcessorHelper.js +13 -1
  445. package/dist/production/src/mapper/MutationProcessorHelper.js.map +1 -1
  446. package/dist/production/src/mapper/Result.cjs +1 -0
  447. package/dist/production/src/mapper/Result.cjs.map +1 -1
  448. package/dist/production/src/mapper/Result.js +1 -0
  449. package/dist/production/src/mapper/Result.js.map +1 -1
  450. package/dist/production/src/mapper/delete/DeleteExecutor.cjs +15 -8
  451. package/dist/production/src/mapper/delete/DeleteExecutor.cjs.map +1 -1
  452. package/dist/production/src/mapper/delete/DeleteExecutor.js +15 -8
  453. package/dist/production/src/mapper/delete/DeleteExecutor.js.map +1 -1
  454. package/dist/production/src/mapper/insert/InsertBuilder.cjs +3 -2
  455. package/dist/production/src/mapper/insert/InsertBuilder.cjs.map +1 -1
  456. package/dist/production/src/mapper/insert/InsertBuilder.js +3 -2
  457. package/dist/production/src/mapper/insert/InsertBuilder.js.map +1 -1
  458. package/dist/production/src/mapper/insert/InsertBuilderFactory.cjs +2 -2
  459. package/dist/production/src/mapper/insert/InsertBuilderFactory.cjs.map +1 -1
  460. package/dist/production/src/mapper/insert/InsertBuilderFactory.js +2 -2
  461. package/dist/production/src/mapper/insert/InsertBuilderFactory.js.map +1 -1
  462. package/dist/production/src/mapper/insert/Inserter.cjs +3 -3
  463. package/dist/production/src/mapper/insert/Inserter.cjs.map +1 -1
  464. package/dist/production/src/mapper/insert/Inserter.js +3 -3
  465. package/dist/production/src/mapper/insert/Inserter.js.map +1 -1
  466. package/dist/production/src/mapper/insert/SqlCreateInputProcessor.cjs +3 -2
  467. package/dist/production/src/mapper/insert/SqlCreateInputProcessor.cjs.map +1 -1
  468. package/dist/production/src/mapper/insert/SqlCreateInputProcessor.js +3 -2
  469. package/dist/production/src/mapper/insert/SqlCreateInputProcessor.js.map +1 -1
  470. package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs +9 -8
  471. package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs.map +1 -1
  472. package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js +9 -8
  473. package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js.map +1 -1
  474. package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs +4 -4
  475. package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs.map +1 -1
  476. package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js +4 -4
  477. package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js.map +1 -1
  478. package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs +3 -3
  479. package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs.map +1 -1
  480. package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js +3 -3
  481. package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js.map +1 -1
  482. package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs +7 -7
  483. package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs.map +1 -1
  484. package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js +7 -7
  485. package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js.map +1 -1
  486. package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs +6 -6
  487. package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs.map +1 -1
  488. package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js +6 -6
  489. package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js.map +1 -1
  490. package/dist/production/src/mapper/select/ConditionBuilder.cjs +8 -1
  491. package/dist/production/src/mapper/select/ConditionBuilder.cjs.map +1 -1
  492. package/dist/production/src/mapper/select/ConditionBuilder.js +8 -1
  493. package/dist/production/src/mapper/select/ConditionBuilder.js.map +1 -1
  494. package/dist/production/src/mapper/select/JoinBuilder.cjs +26 -4
  495. package/dist/production/src/mapper/select/JoinBuilder.cjs.map +1 -1
  496. package/dist/production/src/mapper/select/JoinBuilder.js +27 -5
  497. package/dist/production/src/mapper/select/JoinBuilder.js.map +1 -1
  498. package/dist/production/src/mapper/select/OrderByBuilder.cjs +84 -15
  499. package/dist/production/src/mapper/select/OrderByBuilder.cjs.map +1 -1
  500. package/dist/production/src/mapper/select/OrderByBuilder.js +86 -17
  501. package/dist/production/src/mapper/select/OrderByBuilder.js.map +1 -1
  502. package/dist/production/src/mapper/select/OrderByHelper.cjs +17 -7
  503. package/dist/production/src/mapper/select/OrderByHelper.cjs.map +1 -1
  504. package/dist/production/src/mapper/select/OrderByHelper.js +17 -7
  505. package/dist/production/src/mapper/select/OrderByHelper.js.map +1 -1
  506. package/dist/production/src/mapper/select/Path.cjs +25 -3
  507. package/dist/production/src/mapper/select/Path.cjs.map +1 -1
  508. package/dist/production/src/mapper/select/Path.js +26 -4
  509. package/dist/production/src/mapper/select/Path.js.map +1 -1
  510. package/dist/production/src/mapper/select/RelationFetcher.cjs +6 -5
  511. package/dist/production/src/mapper/select/RelationFetcher.cjs.map +1 -1
  512. package/dist/production/src/mapper/select/RelationFetcher.js +6 -5
  513. package/dist/production/src/mapper/select/RelationFetcher.js.map +1 -1
  514. package/dist/production/src/mapper/select/SelectBuilder.cjs +15 -21
  515. package/dist/production/src/mapper/select/SelectBuilder.cjs.map +1 -1
  516. package/dist/production/src/mapper/select/SelectBuilder.js +13 -19
  517. package/dist/production/src/mapper/select/SelectBuilder.js.map +1 -1
  518. package/dist/production/src/mapper/select/SelectHydrator.cjs +92 -31
  519. package/dist/production/src/mapper/select/SelectHydrator.cjs.map +1 -1
  520. package/dist/production/src/mapper/select/SelectHydrator.js +92 -31
  521. package/dist/production/src/mapper/select/SelectHydrator.js.map +1 -1
  522. package/dist/production/src/mapper/select/WhereBuilder.cjs +261 -47
  523. package/dist/production/src/mapper/select/WhereBuilder.cjs.map +1 -1
  524. package/dist/production/src/mapper/select/WhereBuilder.js +262 -48
  525. package/dist/production/src/mapper/select/WhereBuilder.js.map +1 -1
  526. package/dist/production/src/mapper/select/getFieldReadPredicate.cjs +8 -0
  527. package/dist/production/src/mapper/select/getFieldReadPredicate.cjs.map +1 -0
  528. package/dist/production/src/mapper/select/getFieldReadPredicate.js +8 -0
  529. package/dist/production/src/mapper/select/getFieldReadPredicate.js.map +1 -0
  530. package/dist/production/src/mapper/select/handlers/FieldsVisitor.cjs +9 -13
  531. package/dist/production/src/mapper/select/handlers/FieldsVisitor.cjs.map +1 -1
  532. package/dist/production/src/mapper/select/handlers/FieldsVisitor.js +10 -14
  533. package/dist/production/src/mapper/select/handlers/FieldsVisitor.js.map +1 -1
  534. package/dist/production/src/mapper/select/handlers/MetaHandler.cjs +6 -2
  535. package/dist/production/src/mapper/select/handlers/MetaHandler.cjs.map +1 -1
  536. package/dist/production/src/mapper/select/handlers/MetaHandler.js +6 -2
  537. package/dist/production/src/mapper/select/handlers/MetaHandler.js.map +1 -1
  538. package/dist/production/src/mapper/select/optimizer/WhereOptimizer.cjs +229 -3
  539. package/dist/production/src/mapper/select/optimizer/WhereOptimizer.cjs.map +1 -1
  540. package/dist/production/src/mapper/select/optimizer/WhereOptimizer.js +230 -4
  541. package/dist/production/src/mapper/select/optimizer/WhereOptimizer.js.map +1 -1
  542. package/dist/production/src/mapper/select/optimizer/WhereReplacer.cjs +3 -3
  543. package/dist/production/src/mapper/select/optimizer/WhereReplacer.cjs.map +1 -1
  544. package/dist/production/src/mapper/select/optimizer/WhereReplacer.js +1 -1
  545. package/dist/production/src/mapper/select/optimizer/WhereReplacer.js.map +1 -1
  546. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.cjs +9 -5
  547. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
  548. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.js +10 -6
  549. package/dist/production/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
  550. package/dist/production/src/mapper/update/UpdateBuilder.cjs +35 -2
  551. package/dist/production/src/mapper/update/UpdateBuilder.cjs.map +1 -1
  552. package/dist/production/src/mapper/update/UpdateBuilder.js +36 -3
  553. package/dist/production/src/mapper/update/UpdateBuilder.js.map +1 -1
  554. package/dist/production/src/mapper/update/UpdateBuilderFactory.cjs +3 -2
  555. package/dist/production/src/mapper/update/UpdateBuilderFactory.cjs.map +1 -1
  556. package/dist/production/src/mapper/update/UpdateBuilderFactory.js +3 -2
  557. package/dist/production/src/mapper/update/UpdateBuilderFactory.js.map +1 -1
  558. package/dist/production/src/mapper/update/Updater.cjs +12 -6
  559. package/dist/production/src/mapper/update/Updater.cjs.map +1 -1
  560. package/dist/production/src/mapper/update/Updater.js +13 -7
  561. package/dist/production/src/mapper/update/Updater.js.map +1 -1
  562. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs +33 -19
  563. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -1
  564. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js +33 -19
  565. package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -1
  566. package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs +13 -11
  567. package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs.map +1 -1
  568. package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js +13 -11
  569. package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js.map +1 -1
  570. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs +17 -8
  571. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -1
  572. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js +17 -8
  573. package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -1
  574. package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs +19 -16
  575. package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs.map +1 -1
  576. package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js +19 -16
  577. package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js.map +1 -1
  578. package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs +19 -16
  579. package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs.map +1 -1
  580. package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js +19 -16
  581. package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js.map +1 -1
  582. package/dist/production/src/mapper/update/relations/SetManyRelationHelper.cjs +123 -0
  583. package/dist/production/src/mapper/update/relations/SetManyRelationHelper.cjs.map +1 -0
  584. package/dist/production/src/mapper/update/relations/SetManyRelationHelper.js +123 -0
  585. package/dist/production/src/mapper/update/relations/SetManyRelationHelper.js.map +1 -0
  586. package/dist/production/src/resolvers/GraphQlQueryAstFactory.cjs.map +1 -1
  587. package/dist/production/src/resolvers/GraphQlQueryAstFactory.js.map +1 -1
  588. package/dist/production/src/resolvers/MutationResolver.cjs +76 -79
  589. package/dist/production/src/resolvers/MutationResolver.cjs.map +1 -1
  590. package/dist/production/src/resolvers/MutationResolver.js +78 -81
  591. package/dist/production/src/resolvers/MutationResolver.js.map +1 -1
  592. package/dist/production/src/resolvers/ReadHelpers.cjs +17 -6
  593. package/dist/production/src/resolvers/ReadHelpers.cjs.map +1 -1
  594. package/dist/production/src/resolvers/ReadHelpers.js +17 -6
  595. package/dist/production/src/resolvers/ReadHelpers.js.map +1 -1
  596. package/dist/production/src/resolvers/ReadResolver.cjs +27 -22
  597. package/dist/production/src/resolvers/ReadResolver.cjs.map +1 -1
  598. package/dist/production/src/resolvers/ReadResolver.js +27 -22
  599. package/dist/production/src/resolvers/ReadResolver.js.map +1 -1
  600. package/dist/production/src/schema/CustomTypesProvider.cjs +35 -14
  601. package/dist/production/src/schema/CustomTypesProvider.cjs.map +1 -1
  602. package/dist/production/src/schema/CustomTypesProvider.js +36 -15
  603. package/dist/production/src/schema/CustomTypesProvider.js.map +1 -1
  604. package/dist/production/src/schema/EntityTypeProvider.cjs +11 -7
  605. package/dist/production/src/schema/EntityTypeProvider.cjs.map +1 -1
  606. package/dist/production/src/schema/EntityTypeProvider.js +11 -7
  607. package/dist/production/src/schema/EntityTypeProvider.js.map +1 -1
  608. package/dist/production/src/schema/GraphQlSchemaBuilder.cjs +16 -6
  609. package/dist/production/src/schema/GraphQlSchemaBuilder.cjs.map +1 -1
  610. package/dist/production/src/schema/GraphQlSchemaBuilder.js +16 -6
  611. package/dist/production/src/schema/GraphQlSchemaBuilder.js.map +1 -1
  612. package/dist/production/src/schema/GraphQlSchemaBuilderFactory.cjs +39 -11
  613. package/dist/production/src/schema/GraphQlSchemaBuilderFactory.cjs.map +1 -1
  614. package/dist/production/src/schema/GraphQlSchemaBuilderFactory.js +39 -11
  615. package/dist/production/src/schema/GraphQlSchemaBuilderFactory.js.map +1 -1
  616. package/dist/production/src/schema/MutationProvider.cjs +38 -16
  617. package/dist/production/src/schema/MutationProvider.cjs.map +1 -1
  618. package/dist/production/src/schema/MutationProvider.js +38 -16
  619. package/dist/production/src/schema/MutationProvider.js.map +1 -1
  620. package/dist/production/src/schema/OrderByTypeProvider.cjs +8 -2
  621. package/dist/production/src/schema/OrderByTypeProvider.cjs.map +1 -1
  622. package/dist/production/src/schema/OrderByTypeProvider.js +9 -3
  623. package/dist/production/src/schema/OrderByTypeProvider.js.map +1 -1
  624. package/dist/production/src/schema/QueryProvider.cjs +12 -11
  625. package/dist/production/src/schema/QueryProvider.cjs.map +1 -1
  626. package/dist/production/src/schema/QueryProvider.js +12 -11
  627. package/dist/production/src/schema/QueryProvider.js.map +1 -1
  628. package/dist/production/src/schema/ValidationQueriesProvider.cjs +2 -0
  629. package/dist/production/src/schema/ValidationQueriesProvider.cjs.map +1 -1
  630. package/dist/production/src/schema/ValidationQueriesProvider.js +2 -0
  631. package/dist/production/src/schema/ValidationQueriesProvider.js.map +1 -1
  632. package/dist/production/src/schema/WhereTypeProvider.cjs +17 -5
  633. package/dist/production/src/schema/WhereTypeProvider.cjs.map +1 -1
  634. package/dist/production/src/schema/WhereTypeProvider.js +18 -6
  635. package/dist/production/src/schema/WhereTypeProvider.js.map +1 -1
  636. package/dist/production/src/schema/calendarDate.cjs +21 -0
  637. package/dist/production/src/schema/calendarDate.cjs.map +1 -0
  638. package/dist/production/src/schema/calendarDate.js +21 -0
  639. package/dist/production/src/schema/calendarDate.js.map +1 -0
  640. package/dist/production/src/schema/entities/FieldTypeVisitor.cjs +15 -2
  641. package/dist/production/src/schema/entities/FieldTypeVisitor.cjs.map +1 -1
  642. package/dist/production/src/schema/entities/FieldTypeVisitor.js +15 -2
  643. package/dist/production/src/schema/entities/FieldTypeVisitor.js.map +1 -1
  644. package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.cjs +11 -3
  645. package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.cjs.map +1 -1
  646. package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.js +11 -3
  647. package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.js.map +1 -1
  648. package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs +11 -3
  649. package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs.map +1 -1
  650. package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.js +11 -3
  651. package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.js.map +1 -1
  652. package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs +39 -2
  653. package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs.map +1 -1
  654. package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js +40 -3
  655. package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js.map +1 -1
  656. package/dist/production/src/schema/utils.cjs +10 -0
  657. package/dist/production/src/schema/utils.cjs.map +1 -1
  658. package/dist/production/src/schema/utils.js +11 -1
  659. package/dist/production/src/schema/utils.js.map +1 -1
  660. package/dist/production/src/schema-json/GraphQLJsBridge.cjs +108 -0
  661. package/dist/production/src/schema-json/GraphQLJsBridge.cjs.map +1 -0
  662. package/dist/production/src/schema-json/GraphQLJsBridge.js +108 -0
  663. package/dist/production/src/schema-json/GraphQLJsBridge.js.map +1 -0
  664. package/dist/production/src/schema-json/JsonColumnTypes.cjs +102 -0
  665. package/dist/production/src/schema-json/JsonColumnTypes.cjs.map +1 -0
  666. package/dist/production/src/schema-json/JsonColumnTypes.js +102 -0
  667. package/dist/production/src/schema-json/JsonColumnTypes.js.map +1 -0
  668. package/dist/production/src/schema-json/JsonContentSchemaBuilder.cjs +418 -0
  669. package/dist/production/src/schema-json/JsonContentSchemaBuilder.cjs.map +1 -0
  670. package/dist/production/src/schema-json/JsonContentSchemaBuilder.js +418 -0
  671. package/dist/production/src/schema-json/JsonContentSchemaBuilder.js.map +1 -0
  672. package/dist/production/src/schema-json/JsonContentSchemaShared.cjs +18 -0
  673. package/dist/production/src/schema-json/JsonContentSchemaShared.cjs.map +1 -0
  674. package/dist/production/src/schema-json/JsonContentSchemaShared.js +18 -0
  675. package/dist/production/src/schema-json/JsonContentSchemaShared.js.map +1 -0
  676. package/dist/production/src/schema-json/JsonEntityTypes.cjs +206 -0
  677. package/dist/production/src/schema-json/JsonEntityTypes.cjs.map +1 -0
  678. package/dist/production/src/schema-json/JsonEntityTypes.js +206 -0
  679. package/dist/production/src/schema-json/JsonEntityTypes.js.map +1 -0
  680. package/dist/production/src/schema-json/JsonFilterTypes.cjs +152 -0
  681. package/dist/production/src/schema-json/JsonFilterTypes.cjs.map +1 -0
  682. package/dist/production/src/schema-json/JsonFilterTypes.js +152 -0
  683. package/dist/production/src/schema-json/JsonFilterTypes.js.map +1 -0
  684. package/dist/production/src/schema-json/JsonInputTypes.cjs +256 -0
  685. package/dist/production/src/schema-json/JsonInputTypes.cjs.map +1 -0
  686. package/dist/production/src/schema-json/JsonInputTypes.js +256 -0
  687. package/dist/production/src/schema-json/JsonInputTypes.js.map +1 -0
  688. package/dist/production/src/schema-json/JsonIntrospectionExtension.cjs +36 -0
  689. package/dist/production/src/schema-json/JsonIntrospectionExtension.cjs.map +1 -0
  690. package/dist/production/src/schema-json/JsonIntrospectionExtension.js +36 -0
  691. package/dist/production/src/schema-json/JsonIntrospectionExtension.js.map +1 -0
  692. package/dist/production/src/schema-json/JsonQueryAstFactory.cjs +107 -0
  693. package/dist/production/src/schema-json/JsonQueryAstFactory.cjs.map +1 -0
  694. package/dist/production/src/schema-json/JsonQueryAstFactory.js +107 -0
  695. package/dist/production/src/schema-json/JsonQueryAstFactory.js.map +1 -0
  696. package/dist/production/src/schema-json/JsonTypeRegistry.cjs +230 -0
  697. package/dist/production/src/schema-json/JsonTypeRegistry.cjs.map +1 -0
  698. package/dist/production/src/schema-json/JsonTypeRegistry.js +230 -0
  699. package/dist/production/src/schema-json/JsonTypeRegistry.js.map +1 -0
  700. package/dist/production/src/utils/ResolveInfoUtils.cjs.map +1 -1
  701. package/dist/production/src/utils/ResolveInfoUtils.js.map +1 -1
  702. package/dist/production/src/utils/uniqueWhereFields.cjs +10 -0
  703. package/dist/production/src/utils/uniqueWhereFields.cjs.map +1 -1
  704. package/dist/production/src/utils/uniqueWhereFields.js +10 -0
  705. package/dist/production/src/utils/uniqueWhereFields.js.map +1 -1
  706. package/dist/tests/cases/integration/graphQlRequests/delete/acl/throughScope.test.d.ts +2 -0
  707. package/dist/tests/cases/integration/graphQlRequests/delete/acl/throughScope.test.d.ts.map +1 -0
  708. package/dist/tests/cases/integration/graphQlRequests/insert/acl/throughScope.test.d.ts +2 -0
  709. package/dist/tests/cases/integration/graphQlRequests/insert/acl/throughScope.test.d.ts.map +1 -0
  710. package/dist/tests/cases/integration/graphQlRequests/insert/memoryBudget.test.d.ts +2 -0
  711. package/dist/tests/cases/integration/graphQlRequests/insert/memoryBudget.test.d.ts.map +1 -0
  712. package/dist/tests/cases/integration/graphQlRequests/query/acl/hasManyCellPredicate.test.d.ts +2 -0
  713. package/dist/tests/cases/integration/graphQlRequests/query/acl/hasManyCellPredicate.test.d.ts.map +1 -0
  714. package/dist/tests/cases/integration/graphQlRequests/query/acl/impliedReadGuard.test.d.ts +2 -0
  715. package/dist/tests/cases/integration/graphQlRequests/query/acl/impliedReadGuard.test.d.ts.map +1 -0
  716. package/dist/tests/cases/integration/graphQlRequests/query/acl/internalColumnAliases.test.d.ts +2 -0
  717. package/dist/tests/cases/integration/graphQlRequests/query/acl/internalColumnAliases.test.d.ts.map +1 -0
  718. package/dist/tests/cases/integration/graphQlRequests/query/acl/manyHasManyGuardedJoin.test.d.ts +2 -0
  719. package/dist/tests/cases/integration/graphQlRequests/query/acl/manyHasManyGuardedJoin.test.d.ts.map +1 -0
  720. package/dist/tests/cases/integration/graphQlRequests/query/acl/maskedRelationField.test.d.ts +2 -0
  721. package/dist/tests/cases/integration/graphQlRequests/query/acl/maskedRelationField.test.d.ts.map +1 -0
  722. package/dist/tests/cases/integration/graphQlRequests/query/acl/mergedRolePredicate.test.d.ts +2 -0
  723. package/dist/tests/cases/integration/graphQlRequests/query/acl/mergedRolePredicate.test.d.ts.map +1 -0
  724. package/dist/tests/cases/integration/graphQlRequests/query/acl/metaReadableThroughContext.test.d.ts +2 -0
  725. package/dist/tests/cases/integration/graphQlRequests/query/acl/metaReadableThroughContext.test.d.ts.map +1 -0
  726. package/dist/tests/cases/integration/graphQlRequests/query/acl/negationAcrossSubquery.test.d.ts +2 -0
  727. package/dist/tests/cases/integration/graphQlRequests/query/acl/negationAcrossSubquery.test.d.ts.map +1 -0
  728. package/dist/tests/cases/integration/graphQlRequests/query/acl/nonAdjacentBackReference.test.d.ts +2 -0
  729. package/dist/tests/cases/integration/graphQlRequests/query/acl/nonAdjacentBackReference.test.d.ts.map +1 -0
  730. package/dist/tests/cases/integration/graphQlRequests/query/acl/notOverGuardedHop.test.d.ts +2 -0
  731. package/dist/tests/cases/integration/graphQlRequests/query/acl/notOverGuardedHop.test.d.ts.map +1 -0
  732. package/dist/tests/cases/integration/graphQlRequests/query/acl/notOverOrCellPredicate.test.d.ts +2 -0
  733. package/dist/tests/cases/integration/graphQlRequests/query/acl/notOverOrCellPredicate.test.d.ts.map +1 -0
  734. package/dist/tests/cases/integration/graphQlRequests/query/acl/orderByCellPredicate.test.d.ts +2 -0
  735. package/dist/tests/cases/integration/graphQlRequests/query/acl/orderByCellPredicate.test.d.ts.map +1 -0
  736. package/dist/tests/cases/integration/graphQlRequests/query/acl/throughScope.test.d.ts +2 -0
  737. package/dist/tests/cases/integration/graphQlRequests/query/acl/throughScope.test.d.ts.map +1 -0
  738. package/dist/tests/cases/integration/graphQlRequests/query/acl/throughScopeFilter.test.d.ts +2 -0
  739. package/dist/tests/cases/integration/graphQlRequests/query/acl/throughScopeFilter.test.d.ts.map +1 -0
  740. package/dist/tests/cases/integration/graphQlRequests/query/acl/throughScopeNullability.test.d.ts +2 -0
  741. package/dist/tests/cases/integration/graphQlRequests/query/acl/throughScopeNullability.test.d.ts.map +1 -0
  742. package/dist/tests/cases/integration/graphQlRequests/query/filter/hasOneDataViewFilter.test.d.ts +2 -0
  743. package/dist/tests/cases/integration/graphQlRequests/query/filter/hasOneDataViewFilter.test.d.ts.map +1 -0
  744. package/dist/tests/cases/integration/graphQlRequests/update/acl/legacyNoRootRootWrites.test.d.ts +2 -0
  745. package/dist/tests/cases/integration/graphQlRequests/update/acl/legacyNoRootRootWrites.test.d.ts.map +1 -0
  746. package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScope.test.d.ts +2 -0
  747. package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScope.test.d.ts.map +1 -0
  748. package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScopeJunction.test.d.ts +2 -0
  749. package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScopeJunction.test.d.ts.map +1 -0
  750. package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScopeLookup.test.d.ts +2 -0
  751. package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScopeLookup.test.d.ts.map +1 -0
  752. package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScopeRootWrites.test.d.ts +2 -0
  753. package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScopeRootWrites.test.d.ts.map +1 -0
  754. package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScopeUpdate.test.d.ts +2 -0
  755. package/dist/tests/cases/integration/graphQlRequests/update/acl/throughScopeUpdate.test.d.ts.map +1 -0
  756. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/set.test.d.ts +2 -0
  757. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/set.test.d.ts.map +1 -0
  758. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/set.test.d.ts +2 -0
  759. package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/set.test.d.ts.map +1 -0
  760. package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/set.test.d.ts +2 -0
  761. package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/set.test.d.ts.map +1 -0
  762. package/dist/tests/cases/integration/graphQlRequests/upsert/acl/throughScope.test.d.ts +2 -0
  763. package/dist/tests/cases/integration/graphQlRequests/upsert/acl/throughScope.test.d.ts.map +1 -0
  764. package/dist/tests/cases/integration/graphQlRequests/validation/utils.d.ts.map +1 -1
  765. package/dist/tests/cases/integration/graphQlSchema/model.d.ts +1 -1
  766. package/dist/tests/cases/unit/checkViolationError.test.d.ts +2 -0
  767. package/dist/tests/cases/unit/checkViolationError.test.d.ts.map +1 -0
  768. package/dist/tests/cases/unit/dateType.test.d.ts +2 -0
  769. package/dist/tests/cases/unit/dateType.test.d.ts.map +1 -0
  770. package/dist/tests/cases/unit/internalColumnAliases.test.d.ts +2 -0
  771. package/dist/tests/cases/unit/internalColumnAliases.test.d.ts.map +1 -0
  772. package/dist/tests/cases/unit/introspectionAcl.test.d.ts +2 -0
  773. package/dist/tests/cases/unit/introspectionAcl.test.d.ts.map +1 -0
  774. package/dist/tests/cases/unit/mutationSqlError.test.d.ts +2 -0
  775. package/dist/tests/cases/unit/mutationSqlError.test.d.ts.map +1 -0
  776. package/dist/tests/cases/unit/pathAlias.test.d.ts +2 -0
  777. package/dist/tests/cases/unit/pathAlias.test.d.ts.map +1 -0
  778. package/dist/tests/src/assert.d.ts.map +1 -1
  779. package/dist/tests/src/tags.d.ts.map +1 -1
  780. package/dist/tests/src/test.d.ts +12 -0
  781. package/dist/tests/src/test.d.ts.map +1 -1
  782. package/dist/tests/src/testGraphql.d.ts +18 -5
  783. package/dist/tests/src/testGraphql.d.ts.map +1 -1
  784. package/dist/tests/src/testUuid.d.ts.map +1 -1
  785. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  786. package/dist/types/ExecutionContainer.d.ts +4 -2
  787. package/dist/types/ExecutionContainer.d.ts.map +1 -1
  788. package/dist/types/acl/AclScope.d.ts +26 -0
  789. package/dist/types/acl/AclScope.d.ts.map +1 -0
  790. package/dist/types/acl/Authorizator.d.ts +0 -1
  791. package/dist/types/acl/Authorizator.d.ts.map +1 -1
  792. package/dist/types/acl/EvaluatedPredicateReplacer.d.ts +1 -0
  793. package/dist/types/acl/EvaluatedPredicateReplacer.d.ts.map +1 -1
  794. package/dist/types/acl/PermissionFactory.d.ts +19 -4
  795. package/dist/types/acl/PermissionFactory.d.ts.map +1 -1
  796. package/dist/types/acl/PredicateFactory.d.ts +31 -15
  797. package/dist/types/acl/PredicateFactory.d.ts.map +1 -1
  798. package/dist/types/acl/PredicatesInjector.d.ts +66 -12
  799. package/dist/types/acl/PredicatesInjector.d.ts.map +1 -1
  800. package/dist/types/acl/VariableInjector.d.ts.map +1 -1
  801. package/dist/types/acl/VariableUtils.d.ts.map +1 -1
  802. package/dist/types/acl/index.d.ts +1 -0
  803. package/dist/types/acl/index.d.ts.map +1 -1
  804. package/dist/types/exception.d.ts.map +1 -1
  805. package/dist/types/extensions/hasManyToHasOneReducer/HasManyToHasOneReducer.d.ts.map +1 -1
  806. package/dist/types/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.d.ts +3 -1
  807. package/dist/types/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.d.ts.map +1 -1
  808. package/dist/types/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.d.ts.map +1 -1
  809. package/dist/types/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.d.ts.map +1 -1
  810. package/dist/types/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.d.ts +3 -1
  811. package/dist/types/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.d.ts.map +1 -1
  812. package/dist/types/extensions/paginatedHasMany/PaginatedHasManyFieldProvider.d.ts.map +1 -1
  813. package/dist/types/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.d.ts.map +1 -1
  814. package/dist/types/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.d.ts.map +1 -1
  815. package/dist/types/index.d.ts +1 -0
  816. package/dist/types/index.d.ts.map +1 -1
  817. package/dist/types/input-validation/ColumnValueResolver.d.ts.map +1 -1
  818. package/dist/types/input-validation/EntityRulesResolver.d.ts.map +1 -1
  819. package/dist/types/input-validation/JsonSchemaValidator.d.ts.map +1 -1
  820. package/dist/types/input-validation/QueryAstFactory.d.ts.map +1 -1
  821. package/dist/types/input-validation/ValidationContext.d.ts.map +1 -1
  822. package/dist/types/input-validation/ValidationDataSelector.d.ts +2 -1
  823. package/dist/types/input-validation/ValidationDataSelector.d.ts.map +1 -1
  824. package/dist/types/input-validation/ValidationEvaluation.d.ts.map +1 -1
  825. package/dist/types/input-validation/ValidationPath.d.ts.map +1 -1
  826. package/dist/types/input-validation/dependencies/DependencyCollector.d.ts.map +1 -1
  827. package/dist/types/input-validation/dependencies/DependencyMerger.d.ts.map +1 -1
  828. package/dist/types/input-validation/preValidation/CreateInputPreValidationProcessor.d.ts.map +1 -1
  829. package/dist/types/input-validation/preValidation/InputPreValidator.d.ts.map +1 -1
  830. package/dist/types/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts +6 -0
  831. package/dist/types/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts.map +1 -1
  832. package/dist/types/inputProcessing/CreateInputVisitor.d.ts.map +1 -1
  833. package/dist/types/inputProcessing/FieldNode.d.ts.map +1 -1
  834. package/dist/types/inputProcessing/ObjectNode.d.ts.map +1 -1
  835. package/dist/types/inputProcessing/UniqueWhereExpander.d.ts.map +1 -1
  836. package/dist/types/inputProcessing/UpdateInputProcessor.d.ts +7 -0
  837. package/dist/types/inputProcessing/UpdateInputProcessor.d.ts.map +1 -1
  838. package/dist/types/inputProcessing/UpdateInputVisitor.d.ts +2 -0
  839. package/dist/types/inputProcessing/UpdateInputVisitor.d.ts.map +1 -1
  840. package/dist/types/introspection/IntrospectionSchemaDefinitionFactory.d.ts.map +1 -1
  841. package/dist/types/introspection/IntrospectionSchemaFactory.d.ts.map +1 -1
  842. package/dist/types/introspection/introspection.schema.d.ts.map +1 -1
  843. package/dist/types/mapper/CheckedPrimary.d.ts.map +1 -1
  844. package/dist/types/mapper/ColumnValue.d.ts.map +1 -1
  845. package/dist/types/mapper/Constraints.d.ts.map +1 -1
  846. package/dist/types/mapper/ErrorUtils.d.ts.map +1 -1
  847. package/dist/types/mapper/EventManager.d.ts +9 -9
  848. package/dist/types/mapper/EventManager.d.ts.map +1 -1
  849. package/dist/types/mapper/JunctionTableManager.d.ts +17 -5
  850. package/dist/types/mapper/JunctionTableManager.d.ts.map +1 -1
  851. package/dist/types/mapper/Mapper.d.ts +26 -13
  852. package/dist/types/mapper/Mapper.d.ts.map +1 -1
  853. package/dist/types/mapper/MapperFactory.d.ts +3 -2
  854. package/dist/types/mapper/MapperFactory.d.ts.map +1 -1
  855. package/dist/types/mapper/MutationProcessorHelper.d.ts +3 -0
  856. package/dist/types/mapper/MutationProcessorHelper.d.ts.map +1 -1
  857. package/dist/types/mapper/Result.d.ts +2 -1
  858. package/dist/types/mapper/Result.d.ts.map +1 -1
  859. package/dist/types/mapper/delete/DeleteExecutor.d.ts +6 -2
  860. package/dist/types/mapper/delete/DeleteExecutor.d.ts.map +1 -1
  861. package/dist/types/mapper/delete/DeleteState.d.ts.map +1 -1
  862. package/dist/types/mapper/delete/DeletedEntitiesStorage.d.ts.map +1 -1
  863. package/dist/types/mapper/delete/helpers.d.ts +1 -1
  864. package/dist/types/mapper/delete/helpers.d.ts.map +1 -1
  865. package/dist/types/mapper/insert/InsertBuilder.d.ts +3 -2
  866. package/dist/types/mapper/insert/InsertBuilder.d.ts.map +1 -1
  867. package/dist/types/mapper/insert/InsertBuilderFactory.d.ts +2 -2
  868. package/dist/types/mapper/insert/InsertBuilderFactory.d.ts.map +1 -1
  869. package/dist/types/mapper/insert/Inserter.d.ts +2 -1
  870. package/dist/types/mapper/insert/Inserter.d.ts.map +1 -1
  871. package/dist/types/mapper/insert/SqlCreateInputProcessor.d.ts +6 -1
  872. package/dist/types/mapper/insert/SqlCreateInputProcessor.d.ts.map +1 -1
  873. package/dist/types/mapper/insert/relations/ManyHasManyCreateInputProcessor.d.ts +7 -2
  874. package/dist/types/mapper/insert/relations/ManyHasManyCreateInputProcessor.d.ts.map +1 -1
  875. package/dist/types/mapper/insert/relations/ManyHasOneCreateInputProcessor.d.ts.map +1 -1
  876. package/dist/types/mapper/insert/relations/OneHasManyCreateInputProcessor.d.ts.map +1 -1
  877. package/dist/types/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.d.ts +1 -1
  878. package/dist/types/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.d.ts.map +1 -1
  879. package/dist/types/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.d.ts.map +1 -1
  880. package/dist/types/mapper/select/ConditionBuilder.d.ts.map +1 -1
  881. package/dist/types/mapper/select/JoinBuilder.d.ts +8 -2
  882. package/dist/types/mapper/select/JoinBuilder.d.ts.map +1 -1
  883. package/dist/types/mapper/select/JoinVisitor.d.ts.map +1 -1
  884. package/dist/types/mapper/select/OrderByBuilder.d.ts +18 -2
  885. package/dist/types/mapper/select/OrderByBuilder.d.ts.map +1 -1
  886. package/dist/types/mapper/select/OrderByHelper.d.ts +2 -0
  887. package/dist/types/mapper/select/OrderByHelper.d.ts.map +1 -1
  888. package/dist/types/mapper/select/Path.d.ts +12 -0
  889. package/dist/types/mapper/select/Path.d.ts.map +1 -1
  890. package/dist/types/mapper/select/RelationFetcher.d.ts.map +1 -1
  891. package/dist/types/mapper/select/SelectBuilder.d.ts.map +1 -1
  892. package/dist/types/mapper/select/SelectExecutionHandler.d.ts +5 -0
  893. package/dist/types/mapper/select/SelectExecutionHandler.d.ts.map +1 -1
  894. package/dist/types/mapper/select/SelectHydrator.d.ts +10 -1
  895. package/dist/types/mapper/select/SelectHydrator.d.ts.map +1 -1
  896. package/dist/types/mapper/select/WhereBuilder.d.ts +33 -1
  897. package/dist/types/mapper/select/WhereBuilder.d.ts.map +1 -1
  898. package/dist/types/mapper/select/getFieldReadPredicate.d.ts +4 -0
  899. package/dist/types/mapper/select/getFieldReadPredicate.d.ts.map +1 -0
  900. package/dist/types/mapper/select/handlers/FieldsVisitor.d.ts +0 -1
  901. package/dist/types/mapper/select/handlers/FieldsVisitor.d.ts.map +1 -1
  902. package/dist/types/mapper/select/handlers/FieldsVisitorFactory.d.ts.map +1 -1
  903. package/dist/types/mapper/select/handlers/MetaHandler.d.ts.map +1 -1
  904. package/dist/types/mapper/select/index.d.ts +1 -0
  905. package/dist/types/mapper/select/index.d.ts.map +1 -1
  906. package/dist/types/mapper/select/optimizer/ConditionOptimizer.d.ts.map +1 -1
  907. package/dist/types/mapper/select/optimizer/WhereOptimizer.d.ts +36 -0
  908. package/dist/types/mapper/select/optimizer/WhereOptimizer.d.ts.map +1 -1
  909. package/dist/types/mapper/select/optimizer/WhereReplacer.d.ts.map +1 -1
  910. package/dist/types/mapper/select/optimizer/helpers.d.ts +1 -1
  911. package/dist/types/mapper/select/optimizer/helpers.d.ts.map +1 -1
  912. package/dist/types/mapper/types.d.ts +8 -1
  913. package/dist/types/mapper/types.d.ts.map +1 -1
  914. package/dist/types/mapper/update/SqlUpdateInputProcessor.d.ts +6 -1
  915. package/dist/types/mapper/update/SqlUpdateInputProcessor.d.ts.map +1 -1
  916. package/dist/types/mapper/update/UpdateBuilder.d.ts +18 -2
  917. package/dist/types/mapper/update/UpdateBuilder.d.ts.map +1 -1
  918. package/dist/types/mapper/update/UpdateBuilderFactory.d.ts +2 -2
  919. package/dist/types/mapper/update/UpdateBuilderFactory.d.ts.map +1 -1
  920. package/dist/types/mapper/update/Updater.d.ts +3 -2
  921. package/dist/types/mapper/update/Updater.d.ts.map +1 -1
  922. package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts +15 -3
  923. package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts.map +1 -1
  924. package/dist/types/mapper/update/relations/ManyHasOneUpdateInputProcessor.d.ts.map +1 -1
  925. package/dist/types/mapper/update/relations/OneHasManyUpdateInputProcessor.d.ts +5 -0
  926. package/dist/types/mapper/update/relations/OneHasManyUpdateInputProcessor.d.ts.map +1 -1
  927. package/dist/types/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.d.ts.map +1 -1
  928. package/dist/types/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.d.ts.map +1 -1
  929. package/dist/types/mapper/update/relations/SetManyRelationHelper.d.ts +67 -0
  930. package/dist/types/mapper/update/relations/SetManyRelationHelper.d.ts.map +1 -0
  931. package/dist/types/resolvers/GraphQlQueryAstFactory.d.ts +4 -3
  932. package/dist/types/resolvers/GraphQlQueryAstFactory.d.ts.map +1 -1
  933. package/dist/types/resolvers/MutationResolver.d.ts +14 -11
  934. package/dist/types/resolvers/MutationResolver.d.ts.map +1 -1
  935. package/dist/types/resolvers/ReadHelpers.d.ts +1 -2
  936. package/dist/types/resolvers/ReadHelpers.d.ts.map +1 -1
  937. package/dist/types/resolvers/ReadResolver.d.ts +8 -10
  938. package/dist/types/resolvers/ReadResolver.d.ts.map +1 -1
  939. package/dist/types/resolvers/RefreshViewResolver.d.ts.map +1 -1
  940. package/dist/types/resolvers/ValidationResolver.d.ts.map +1 -1
  941. package/dist/types/schema/ColumnTypeResolver.d.ts.map +1 -1
  942. package/dist/types/schema/ConditionTypeProvider.d.ts.map +1 -1
  943. package/dist/types/schema/CustomTypesProvider.d.ts.map +1 -1
  944. package/dist/types/schema/EntityTypeProvider.d.ts +2 -1
  945. package/dist/types/schema/EntityTypeProvider.d.ts.map +1 -1
  946. package/dist/types/schema/EnumsProvider.d.ts.map +1 -1
  947. package/dist/types/schema/FieldAccessVisitor.d.ts.map +1 -1
  948. package/dist/types/schema/GraphQlSchemaBuilder.d.ts.map +1 -1
  949. package/dist/types/schema/GraphQlSchemaBuilderFactory.d.ts +10 -2
  950. package/dist/types/schema/GraphQlSchemaBuilderFactory.d.ts.map +1 -1
  951. package/dist/types/schema/MutationProvider.d.ts +7 -1
  952. package/dist/types/schema/MutationProvider.d.ts.map +1 -1
  953. package/dist/types/schema/OperationExtension.d.ts.map +1 -1
  954. package/dist/types/schema/OrderByTypeProvider.d.ts.map +1 -1
  955. package/dist/types/schema/PaginatedFieldConfigFactory.d.ts.map +1 -1
  956. package/dist/types/schema/QueryProvider.d.ts +2 -1
  957. package/dist/types/schema/QueryProvider.d.ts.map +1 -1
  958. package/dist/types/schema/RefreshViewMutationProvider.d.ts.map +1 -1
  959. package/dist/types/schema/ValidationQueriesProvider.d.ts.map +1 -1
  960. package/dist/types/schema/WhereTypeProvider.d.ts.map +1 -1
  961. package/dist/types/schema/calendarDate.d.ts +6 -0
  962. package/dist/types/schema/calendarDate.d.ts.map +1 -0
  963. package/dist/types/schema/entities/FieldArgsVisitor.d.ts.map +1 -1
  964. package/dist/types/schema/entities/FieldTypeVisitor.d.ts +4 -1
  965. package/dist/types/schema/entities/FieldTypeVisitor.d.ts.map +1 -1
  966. package/dist/types/schema/index.d.ts +1 -0
  967. package/dist/types/schema/index.d.ts.map +1 -1
  968. package/dist/types/schema/mutations/ConnectOrCreateRelationInputProvider.d.ts.map +1 -1
  969. package/dist/types/schema/mutations/CreateEntityInputFieldVisitor.d.ts.map +1 -1
  970. package/dist/types/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.d.ts.map +1 -1
  971. package/dist/types/schema/mutations/CreateEntityRelationInputFieldVisitor.d.ts.map +1 -1
  972. package/dist/types/schema/mutations/CreateEntityRelationInputProvider.d.ts.map +1 -1
  973. package/dist/types/schema/mutations/EntityInputProvider.d.ts.map +1 -1
  974. package/dist/types/schema/mutations/UpdateEntityInputFieldVisitor.d.ts +3 -0
  975. package/dist/types/schema/mutations/UpdateEntityInputFieldVisitor.d.ts.map +1 -1
  976. package/dist/types/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.d.ts.map +1 -1
  977. package/dist/types/schema/mutations/UpdateEntityRelationInputFieldVisitor.d.ts +1 -0
  978. package/dist/types/schema/mutations/UpdateEntityRelationInputFieldVisitor.d.ts.map +1 -1
  979. package/dist/types/schema/mutations/UpdateEntityRelationInputProvider.d.ts.map +1 -1
  980. package/dist/types/schema/utils.d.ts +7 -0
  981. package/dist/types/schema/utils.d.ts.map +1 -1
  982. package/dist/types/schema-json/GraphQLJsBridge.d.ts +12 -0
  983. package/dist/types/schema-json/GraphQLJsBridge.d.ts.map +1 -0
  984. package/dist/types/schema-json/JsonColumnTypes.d.ts +23 -0
  985. package/dist/types/schema-json/JsonColumnTypes.d.ts.map +1 -0
  986. package/dist/types/schema-json/JsonContentSchemaBuilder.d.ts +56 -0
  987. package/dist/types/schema-json/JsonContentSchemaBuilder.d.ts.map +1 -0
  988. package/dist/types/schema-json/JsonContentSchemaShared.d.ts +19 -0
  989. package/dist/types/schema-json/JsonContentSchemaShared.d.ts.map +1 -0
  990. package/dist/types/schema-json/JsonEntityTypes.d.ts +29 -0
  991. package/dist/types/schema-json/JsonEntityTypes.d.ts.map +1 -0
  992. package/dist/types/schema-json/JsonFilterTypes.d.ts +21 -0
  993. package/dist/types/schema-json/JsonFilterTypes.d.ts.map +1 -0
  994. package/dist/types/schema-json/JsonInputTypes.d.ts +36 -0
  995. package/dist/types/schema-json/JsonInputTypes.d.ts.map +1 -0
  996. package/dist/types/schema-json/JsonIntrospectionExtension.d.ts +5 -0
  997. package/dist/types/schema-json/JsonIntrospectionExtension.d.ts.map +1 -0
  998. package/dist/types/schema-json/JsonQueryAstFactory.d.ts +18 -0
  999. package/dist/types/schema-json/JsonQueryAstFactory.d.ts.map +1 -0
  1000. package/dist/types/schema-json/JsonTypeRegistry.d.ts +57 -0
  1001. package/dist/types/schema-json/JsonTypeRegistry.d.ts.map +1 -0
  1002. package/dist/types/schema-json/index.d.ts +7 -0
  1003. package/dist/types/schema-json/index.d.ts.map +1 -0
  1004. package/dist/types/tsconfig.tsbuildinfo +1 -1
  1005. package/dist/types/utils/Mutex.d.ts.map +1 -1
  1006. package/dist/types/utils/ResolveInfoUtils.d.ts +4 -2
  1007. package/dist/types/utils/ResolveInfoUtils.d.ts.map +1 -1
  1008. package/dist/types/utils/accessor.d.ts.map +1 -1
  1009. package/dist/types/utils/isIt.d.ts.map +1 -1
  1010. package/dist/types/utils/paginationUtils.d.ts.map +1 -1
  1011. package/dist/types/utils/promises.d.ts.map +1 -1
  1012. package/dist/types/utils/singletonFactory.d.ts.map +1 -1
  1013. package/dist/types/utils/strings.d.ts.map +1 -1
  1014. package/dist/types/utils/tuple.d.ts.map +1 -1
  1015. package/dist/types/utils/uniqueWhereFields.d.ts.map +1 -1
  1016. package/dist/types/utils/viewComputedId.d.ts.map +1 -1
  1017. package/package.json +11 -10
  1018. package/src/ExecutionContainer.ts +20 -8
  1019. package/src/acl/AclScope.ts +29 -0
  1020. package/src/acl/Authorizator.ts +7 -5
  1021. package/src/acl/EvaluatedPredicateReplacer.ts +6 -2
  1022. package/src/acl/PermissionFactory.ts +68 -104
  1023. package/src/acl/PredicateFactory.ts +131 -28
  1024. package/src/acl/PredicatesInjector.ts +135 -156
  1025. package/src/acl/VariableInjector.ts +8 -3
  1026. package/src/acl/index.ts +1 -0
  1027. package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.ts +14 -3
  1028. package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts +3 -0
  1029. package/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.ts +10 -2
  1030. package/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.ts +9 -7
  1031. package/src/index.ts +1 -0
  1032. package/src/input-validation/ValidationDataSelector.ts +3 -2
  1033. package/src/input-validation/preValidation/UpdateInputPreValidationProcessor.ts +29 -0
  1034. package/src/inputProcessing/UpdateInputProcessor.ts +6 -0
  1035. package/src/inputProcessing/UpdateInputVisitor.ts +64 -2
  1036. package/src/introspection/IntrospectionSchemaFactory.ts +13 -6
  1037. package/src/mapper/ErrorUtils.ts +22 -1
  1038. package/src/mapper/JunctionTableManager.ts +28 -6
  1039. package/src/mapper/Mapper.ts +137 -29
  1040. package/src/mapper/MapperFactory.ts +7 -3
  1041. package/src/mapper/MutationProcessorHelper.ts +14 -0
  1042. package/src/mapper/Result.ts +1 -0
  1043. package/src/mapper/delete/DeleteExecutor.ts +13 -7
  1044. package/src/mapper/insert/InsertBuilder.ts +3 -2
  1045. package/src/mapper/insert/InsertBuilderFactory.ts +3 -3
  1046. package/src/mapper/insert/Inserter.ts +4 -2
  1047. package/src/mapper/insert/SqlCreateInputProcessor.ts +4 -1
  1048. package/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.ts +10 -7
  1049. package/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.ts +4 -4
  1050. package/src/mapper/insert/relations/OneHasManyCreateInputProcessor.ts +3 -3
  1051. package/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.ts +7 -7
  1052. package/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.ts +6 -6
  1053. package/src/mapper/select/ConditionBuilder.ts +12 -1
  1054. package/src/mapper/select/JoinBuilder.ts +39 -6
  1055. package/src/mapper/select/OrderByBuilder.ts +140 -19
  1056. package/src/mapper/select/OrderByHelper.ts +19 -10
  1057. package/src/mapper/select/Path.ts +36 -5
  1058. package/src/mapper/select/RelationFetcher.ts +7 -9
  1059. package/src/mapper/select/SelectBuilder.ts +12 -20
  1060. package/src/mapper/select/SelectExecutionHandler.ts +5 -0
  1061. package/src/mapper/select/SelectHydrator.ts +113 -31
  1062. package/src/mapper/select/WhereBuilder.ts +322 -50
  1063. package/src/mapper/select/getFieldReadPredicate.ts +12 -0
  1064. package/src/mapper/select/handlers/FieldsVisitor.ts +10 -15
  1065. package/src/mapper/select/handlers/MetaHandler.ts +5 -3
  1066. package/src/mapper/select/index.ts +1 -0
  1067. package/src/mapper/select/optimizer/WhereOptimizer.ts +279 -6
  1068. package/src/mapper/select/optimizer/WhereReplacer.ts +1 -1
  1069. package/src/mapper/types.ts +16 -1
  1070. package/src/mapper/update/SqlUpdateInputProcessor.ts +8 -2
  1071. package/src/mapper/update/UpdateBuilder.ts +41 -3
  1072. package/src/mapper/update/UpdateBuilderFactory.ts +3 -2
  1073. package/src/mapper/update/Updater.ts +11 -4
  1074. package/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.ts +38 -18
  1075. package/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.ts +11 -9
  1076. package/src/mapper/update/relations/OneHasManyUpdateInputProcessor.ts +17 -5
  1077. package/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.ts +16 -13
  1078. package/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.ts +16 -13
  1079. package/src/mapper/update/relations/SetManyRelationHelper.ts +199 -0
  1080. package/src/resolvers/GraphQlQueryAstFactory.ts +2 -2
  1081. package/src/resolvers/MutationResolver.ts +87 -85
  1082. package/src/resolvers/ReadHelpers.ts +2 -5
  1083. package/src/resolvers/ReadResolver.ts +29 -23
  1084. package/src/schema/CustomTypesProvider.ts +40 -15
  1085. package/src/schema/EntityTypeProvider.ts +10 -5
  1086. package/src/schema/GraphQlSchemaBuilder.ts +18 -7
  1087. package/src/schema/GraphQlSchemaBuilderFactory.ts +24 -8
  1088. package/src/schema/MutationProvider.ts +41 -16
  1089. package/src/schema/OrderByTypeProvider.ts +9 -3
  1090. package/src/schema/QueryProvider.ts +13 -10
  1091. package/src/schema/ValidationQueriesProvider.ts +2 -0
  1092. package/src/schema/WhereTypeProvider.ts +18 -6
  1093. package/src/schema/calendarDate.ts +26 -0
  1094. package/src/schema/entities/FieldTypeVisitor.ts +17 -1
  1095. package/src/schema/index.ts +1 -0
  1096. package/src/schema/mutations/CreateEntityInputFieldVisitor.ts +10 -2
  1097. package/src/schema/mutations/UpdateEntityInputFieldVisitor.ts +10 -2
  1098. package/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.ts +66 -7
  1099. package/src/schema/utils.ts +14 -0
  1100. package/src/schema-json/GraphQLJsBridge.ts +142 -0
  1101. package/src/schema-json/JsonColumnTypes.ts +116 -0
  1102. package/src/schema-json/JsonContentSchemaBuilder.ts +501 -0
  1103. package/src/schema-json/JsonContentSchemaShared.ts +19 -0
  1104. package/src/schema-json/JsonEntityTypes.ts +237 -0
  1105. package/src/schema-json/JsonFilterTypes.ts +159 -0
  1106. package/src/schema-json/JsonInputTypes.ts +305 -0
  1107. package/src/schema-json/JsonIntrospectionExtension.ts +37 -0
  1108. package/src/schema-json/JsonQueryAstFactory.ts +128 -0
  1109. package/src/schema-json/JsonTypeRegistry.ts +286 -0
  1110. package/src/schema-json/index.ts +6 -0
  1111. package/src/tsconfig.json +3 -1
  1112. package/src/utils/ResolveInfoUtils.ts +2 -2
  1113. package/src/utils/uniqueWhereFields.ts +14 -0
  1114. package/tests/cases/bugs/bug102.test.ts +4 -4
  1115. package/tests/cases/integration/graphQlRequests/delete/acl/throughScope.test.ts +320 -0
  1116. package/tests/cases/integration/graphQlRequests/delete/deleteById.test.ts +4 -3
  1117. package/tests/cases/integration/graphQlRequests/insert/acl/throughScope.test.ts +502 -0
  1118. package/tests/cases/integration/graphQlRequests/insert/memoryBudget.test.ts +96 -0
  1119. package/tests/cases/integration/graphQlRequests/query/acl/differentRowAndFieldPredicate.test.ts +4 -4
  1120. package/tests/cases/integration/graphQlRequests/query/acl/fieldRestrictedByLocale.test.ts +12 -10
  1121. package/tests/cases/integration/graphQlRequests/query/acl/hasManyCellPredicate.test.ts +54 -0
  1122. package/tests/cases/integration/graphQlRequests/query/acl/impliedReadGuard.test.ts +142 -0
  1123. package/tests/cases/integration/graphQlRequests/query/acl/internalColumnAliases.test.ts +326 -0
  1124. package/tests/cases/integration/graphQlRequests/query/acl/isNullAcl.test.ts +7 -4
  1125. package/tests/cases/integration/graphQlRequests/query/acl/manyHasManyGuardedJoin.test.ts +64 -0
  1126. package/tests/cases/integration/graphQlRequests/query/acl/maskedRelationField.test.ts +124 -0
  1127. package/tests/cases/integration/graphQlRequests/query/acl/mergedRolePredicate.test.ts +124 -0
  1128. package/tests/cases/integration/graphQlRequests/query/acl/metaReadableThroughContext.test.ts +315 -0
  1129. package/tests/cases/integration/graphQlRequests/query/acl/negationAcrossSubquery.test.ts +55 -0
  1130. package/tests/cases/integration/graphQlRequests/query/acl/nestedPredicate.test.ts +7 -6
  1131. package/tests/cases/integration/graphQlRequests/query/acl/nonAdjacentBackReference.test.ts +141 -0
  1132. package/tests/cases/integration/graphQlRequests/query/acl/notOverGuardedHop.test.ts +320 -0
  1133. package/tests/cases/integration/graphQlRequests/query/acl/notOverOrCellPredicate.test.ts +156 -0
  1134. package/tests/cases/integration/graphQlRequests/query/acl/orderByCellPredicate.test.ts +513 -0
  1135. package/tests/cases/integration/graphQlRequests/query/acl/predicateElimination.test.ts +25 -23
  1136. package/tests/cases/integration/graphQlRequests/query/acl/relationAcl.test.ts +12 -9
  1137. package/tests/cases/integration/graphQlRequests/query/acl/rowPredicateSubset.test.ts +6 -6
  1138. package/tests/cases/integration/graphQlRequests/query/acl/throughScope.test.ts +350 -0
  1139. package/tests/cases/integration/graphQlRequests/query/acl/throughScopeFilter.test.ts +203 -0
  1140. package/tests/cases/integration/graphQlRequests/query/acl/throughScopeNullability.test.ts +127 -0
  1141. package/tests/cases/integration/graphQlRequests/query/filter/backReferencedFilter.test.ts +3 -1
  1142. package/tests/cases/integration/graphQlRequests/query/filter/hasOneDataViewFilter.test.ts +79 -0
  1143. package/tests/cases/integration/graphQlRequests/query/graphqlFeatures/alias.test.ts +46 -3
  1144. package/tests/cases/integration/graphQlRequests/query/graphqlFeatures/fragments.test.ts +8 -8
  1145. package/tests/cases/integration/graphQlRequests/query/misc/reducedHasMany.test.ts +10 -10
  1146. package/tests/cases/integration/graphQlRequests/query/pagination/hasManyLimit.test.ts +54 -8
  1147. package/tests/cases/integration/graphQlRequests/query/pagination/paginate.test.ts +5 -4
  1148. package/tests/cases/integration/graphQlRequests/query/pagination/paginateAliased.test.ts +5 -4
  1149. package/tests/cases/integration/graphQlRequests/query/relations/advanced.test.ts +17 -8
  1150. package/tests/cases/integration/graphQlRequests/query/relations/manyHasManyInverse.test.ts +6 -6
  1151. package/tests/cases/integration/graphQlRequests/query/relations/manyHasManyOwning.test.ts +6 -6
  1152. package/tests/cases/integration/graphQlRequests/query/relations/manyHasOne.test.ts +12 -9
  1153. package/tests/cases/integration/graphQlRequests/query/relations/oneHasMany.test.ts +15 -15
  1154. package/tests/cases/integration/graphQlRequests/query/relations/oneHasOneInverse.test.ts +6 -4
  1155. package/tests/cases/integration/graphQlRequests/query/relations/oneHasOneOwner.test.ts +6 -4
  1156. package/tests/cases/integration/graphQlRequests/query/sorting/defaultOrdering.test.ts +4 -4
  1157. package/tests/cases/integration/graphQlRequests/query/sorting/randomSort.test.ts +108 -4
  1158. package/tests/cases/integration/graphQlRequests/query/sorting/sortedHasMany.test.ts +2 -2
  1159. package/tests/cases/integration/graphQlRequests/query/view/view.test.ts +6 -6
  1160. package/tests/cases/integration/graphQlRequests/update/acl/legacyNoRootRootWrites.test.ts +127 -0
  1161. package/tests/cases/integration/graphQlRequests/update/acl/throughScope.test.ts +89 -0
  1162. package/tests/cases/integration/graphQlRequests/update/acl/throughScopeJunction.test.ts +296 -0
  1163. package/tests/cases/integration/graphQlRequests/update/acl/throughScopeLookup.test.ts +265 -0
  1164. package/tests/cases/integration/graphQlRequests/update/acl/throughScopeRootWrites.test.ts +441 -0
  1165. package/tests/cases/integration/graphQlRequests/update/acl/throughScopeUpdate.test.ts +415 -0
  1166. package/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/set.test.ts +219 -0
  1167. package/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/set.test.ts +479 -0
  1168. package/tests/cases/integration/graphQlRequests/update/oneHasMany/set.test.ts +948 -0
  1169. package/tests/cases/integration/graphQlRequests/upsert/acl/throughScope.test.ts +134 -0
  1170. package/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.ts +247 -26
  1171. package/tests/cases/integration/graphQlSchema/schema-acl-allowed.gql +18 -0
  1172. package/tests/cases/integration/graphQlSchema/schema-acl-create-only.gql +2 -0
  1173. package/tests/cases/integration/graphQlSchema/schema-acl-restricted-create.gql +15 -0
  1174. package/tests/cases/integration/graphQlSchema/schema-acl-restricted-delete.gql +12 -0
  1175. package/tests/cases/integration/graphQlSchema/schema-acl-restricted-read.gql +254 -0
  1176. package/tests/cases/integration/graphQlSchema/schema-acl-restricted-update.gql +2 -0
  1177. package/tests/cases/integration/graphQlSchema/schema-acl.gql +2 -0
  1178. package/tests/cases/integration/graphQlSchema/schema-aliased-type.gql +2 -0
  1179. package/tests/cases/integration/graphQlSchema/schema-array.gql +2 -0
  1180. package/tests/cases/integration/graphQlSchema/schema-basic.gql +51 -0
  1181. package/tests/cases/integration/graphQlSchema/schema-bug-66.gql +18 -0
  1182. package/tests/cases/integration/graphQlSchema/schema-column-types.gql +2 -0
  1183. package/tests/cases/integration/graphQlSchema/schema-custom-primary.gql +51 -0
  1184. package/tests/cases/integration/graphQlSchema/schema-deprecation.gql +962 -0
  1185. package/tests/cases/integration/graphQlSchema/schema-description.gql +992 -0
  1186. package/tests/cases/integration/graphQlSchema/schema-has-many-reduction.gql +18 -0
  1187. package/tests/cases/integration/graphQlSchema/schema-mixed-root-through.gql +266 -0
  1188. package/tests/cases/integration/graphQlSchema/schema-new-builder.gql +51 -0
  1189. package/tests/cases/integration/graphQlSchema/schema-no-root-ops.gql +2 -0
  1190. package/tests/cases/integration/graphQlSchema/schema-not-null-through.gql +201 -0
  1191. package/tests/cases/unit/checkViolationError.test.ts +49 -0
  1192. package/tests/cases/unit/dateType.test.ts +46 -0
  1193. package/tests/cases/unit/decimalType.test.ts +2 -2
  1194. package/tests/cases/unit/internalColumnAliases.test.ts +41 -0
  1195. package/tests/cases/unit/introspectionAcl.test.ts +30 -0
  1196. package/tests/cases/unit/mutationSqlError.test.ts +30 -0
  1197. package/tests/cases/unit/pathAlias.test.ts +26 -0
  1198. package/tests/cases/unit/permissionMerger.test.ts +947 -13
  1199. package/tests/cases/unit/predicatesFactory.test.ts +7 -16
  1200. package/tests/cases/unit/predicatesInjector.test.ts +1046 -183
  1201. package/tests/cases/unit/variableInjector.test.ts +12 -0
  1202. package/tests/cases/unit/whereOptimizer.test.ts +62 -0
  1203. package/tests/src/test.ts +51 -9
  1204. package/tests/src/testGraphql.ts +43 -20
  1205. package/tests/tsconfig.json +1 -0
@@ -2,43 +2,72 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const schema = require("@contember/schema");
4
4
  const schemaUtils = require("@contember/schema-utils");
5
- class PredicatesInjector {
5
+ var __defProp = Object.defineProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
8
+ const READ_GUARD_KEY = "$readGuard";
9
+ const FIELD_GUARD_KEY = "$fieldGuard";
10
+ const MASKED_CELL_KEY = "$maskedCell";
11
+ const isWhere = (value) => value !== null && value !== void 0 && typeof value === "object" && !Array.isArray(value);
12
+ const parseMaskedCells = (value) => {
13
+ if (!Array.isArray(value)) {
14
+ throw new Error(`${MASKED_CELL_KEY} expects a list of masked cells`);
15
+ }
16
+ return value.map((cell) => {
17
+ if (!isWhere(cell) || !isWhere(cell.guard) || !isWhere(cell.where)) {
18
+ throw new Error(`${MASKED_CELL_KEY} expects a guard and a where`);
19
+ }
20
+ return { guard: cell.guard, where: cell.where };
21
+ });
22
+ };
23
+ const splitFieldGuard = (where) => {
24
+ const { [FIELD_GUARD_KEY]: fieldGuard, ...rest } = where;
25
+ return { fieldGuard: isWhere(fieldGuard) ? fieldGuard : void 0, where: rest };
26
+ };
27
+ const splitReadGuard = (where) => {
28
+ const { [READ_GUARD_KEY]: guard, [FIELD_GUARD_KEY]: fieldGuard, ...rest } = where;
29
+ return { guard: isWhere(guard) ? guard : {}, fieldGuard: isWhere(fieldGuard) ? fieldGuard : {}, where: rest };
30
+ };
31
+ const _PredicatesInjector = class _PredicatesInjector2 {
6
32
  constructor(schema2, predicateFactory) {
7
33
  this.schema = schema2;
8
34
  this.predicateFactory = predicateFactory;
9
35
  }
10
- inject(entity, where, relationContext, ancestorPath) {
11
- const isQueryRoot = !relationContext && (!ancestorPath || ancestorPath.length === 0);
12
- const restrictedWhere = this.injectToWhere(where, entity, true, relationContext, false, ancestorPath ?? [], isQueryRoot);
13
- return this.createWhere(entity, void 0, restrictedWhere, relationContext, false, ancestorPath ?? [], isQueryRoot);
14
- }
15
36
  /**
16
- * Finds an ancestor in the path that matches the given relation as a back-reference.
17
- * A match occurs when:
18
- * 1. The relation we're traversing has the same name as the inverse (targetRelation) of a relation in the ancestor path
19
- * 2. AND the entity where our relation is defined matches the targetEntity in the path
20
- * (to prevent false positives when different entities have relations with the same name)
37
+ * `scope` is the scope of the entry entity. Relations traversed by `where` are always nested. A lookup
38
+ * without a relation context (a by-unique lookup of a mutation) states the scope of the row it looks for.
21
39
  */
22
- findBackReferencedAncestor(ancestorPath, relationName, relationSourceEntityName) {
23
- return ancestorPath.find(
24
- (ctx) => ctx.targetRelation?.name === relationName && ctx.targetEntity.name === relationSourceEntityName
25
- );
40
+ inject(entity, where, scope, relationContext, ancestorPath) {
41
+ const restrictedWhere = this.injectToWhere(where, entity, true, relationContext, ancestorPath ?? [], scope);
42
+ return this.createWhere(entity, restrictedWhere, relationContext, scope);
26
43
  }
27
- createWhere(entity, fieldNames, where, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot) {
28
- const shouldSimplify = isBackReferenceContext === true && ancestorPath !== void 0 && relationContext !== void 0 && this.findBackReferencedAncestor(ancestorPath, relationContext.relation.name, relationContext.entity.name) !== void 0;
29
- let predicatesWhere;
30
- if (shouldSimplify) {
31
- predicatesWhere = { [entity.primary]: { always: true } };
32
- } else {
33
- const rawPredicate = this.predicateFactory.create(entity, schema.Acl.Operation.read, fieldNames, relationContext, isQueryRoot);
34
- predicatesWhere = this.injectPredicatesToPredicate(
35
- rawPredicate,
36
- entity,
37
- isBackReferenceContext ?? false,
38
- ancestorPath ?? [],
39
- isQueryRoot
40
- );
44
+ /**
45
+ * Row-level read predicate guarding a relation hop's target (the nested scope, since the target
46
+ * is reached through a relation). Empty when the target is freely readable, or when the hop is a to-one
47
+ * back-reference to an ancestor row that is already verified readable. Shared by the filter injection
48
+ * and the order-by join so both guard the same hop identically (they share the join alias).
49
+ */
50
+ createReadGuard(relationContext, ancestorPath) {
51
+ if (this.canSimplifyBackReference(ancestorPath, relationContext)) {
52
+ return {};
41
53
  }
54
+ return this.predicateFactory.create(relationContext.targetEntity, schema.Acl.Operation.read, "nested", void 0, relationContext);
55
+ }
56
+ /**
57
+ * A hop is a back-reference when it is the inverse of the hop that reached its source entity. Only the
58
+ * immediate parent counts: an earlier ancestor of the same entity is generally a different row.
59
+ */
60
+ canSimplifyBackReference(ancestorPath, relationContext) {
61
+ const parent = ancestorPath[ancestorPath.length - 1];
62
+ const isBackReference = parent !== void 0 && parent.targetRelation?.name === relationContext.relation.name && parent.targetEntity.name === relationContext.entity.name;
63
+ return isBackReference && _PredicatesInjector2.toOneBackReferenceTypes.has(relationContext.type);
64
+ }
65
+ /**
66
+ * ANDs the row-level read predicate of the injection root onto `where` — the only place the row predicate
67
+ * lands in the WHERE; relation targets carry theirs in `READ_GUARD_KEY` instead.
68
+ */
69
+ createWhere(entity, where, relationContext, scope) {
70
+ const predicatesWhere = this.predicateFactory.create(entity, schema.Acl.Operation.read, scope, void 0, relationContext);
42
71
  const and = [where, predicatesWhere].filter((it) => Object.keys(it).length > 0);
43
72
  if (and.length === 0) {
44
73
  return {};
@@ -48,85 +77,27 @@ class PredicatesInjector {
48
77
  }
49
78
  return { and };
50
79
  }
51
- /**
52
- * Processes a predicate and injects nested entity predicates for any relation traversals.
53
- * This ensures that when a predicate like { department: { company: { name: 'Acme' } } }
54
- * is used, the predicates of Department and Company are also applied.
55
- */
56
- injectPredicatesToPredicate(where, entity, isBackReferenceContext, ancestorPath, isQueryRoot) {
57
- const resultWhere = {};
58
- if (where.and) {
59
- resultWhere.and = where.and.filter((it) => !!it).map((it) => this.injectPredicatesToPredicate(it, entity, isBackReferenceContext, ancestorPath, isQueryRoot));
60
- }
61
- if (where.or) {
62
- resultWhere.or = where.or.filter((it) => !!it).map((it) => this.injectPredicatesToPredicate(it, entity, isBackReferenceContext, ancestorPath, isQueryRoot));
63
- }
64
- if (where.not) {
65
- resultWhere.not = this.injectPredicatesToPredicate(where.not, entity, isBackReferenceContext, ancestorPath, isQueryRoot);
66
- }
67
- const fields = Object.keys(where).filter((it) => !["and", "or", "not"].includes(it));
68
- for (const field of fields) {
69
- resultWhere[field] = schemaUtils.acceptFieldVisitor(this.schema, entity, field, {
70
- visitColumn: () => where[field],
71
- visitRelation: (context) => {
72
- const relationWhere = where[field];
73
- if (relationWhere === null) {
74
- return null;
75
- }
76
- const isBackReference = this.findBackReferencedAncestor(
77
- ancestorPath,
78
- context.relation.name,
79
- context.entity.name
80
- ) !== void 0;
81
- const nestedIsBackReferenceContext = isBackReference || isBackReferenceContext;
82
- const nestedAncestorPath = [...ancestorPath, context];
83
- const processedNestedWhere = this.injectPredicatesToPredicate(
84
- relationWhere,
85
- context.targetEntity,
86
- nestedIsBackReferenceContext,
87
- nestedAncestorPath,
88
- isQueryRoot
89
- );
90
- const shouldSimplifyNested = nestedIsBackReferenceContext && this.findBackReferencedAncestor(nestedAncestorPath, context.relation.name, context.entity.name) !== void 0;
91
- const targetPredicate = shouldSimplifyNested ? { [context.targetEntity.primary]: { always: true } } : this.predicateFactory.create(context.targetEntity, schema.Acl.Operation.read, void 0, context, isQueryRoot);
92
- const primaryKey = context.targetEntity.primary;
93
- const nestedIsAlwaysTrue = Object.keys(processedNestedWhere).length === 1 && processedNestedWhere[primaryKey] !== void 0 && processedNestedWhere[primaryKey]?.always === true;
94
- const targetIsAlwaysTrue = Object.keys(targetPredicate).length === 1 && targetPredicate[primaryKey] !== void 0 && targetPredicate[primaryKey]?.always === true;
95
- if (nestedIsAlwaysTrue && targetIsAlwaysTrue) {
96
- return processedNestedWhere;
97
- }
98
- const parts = [processedNestedWhere, targetPredicate].filter((it) => Object.keys(it).length > 0);
99
- if (parts.length === 0) {
100
- return {};
101
- }
102
- if (parts.length === 1) {
103
- return parts[0];
104
- }
105
- return { and: parts };
106
- }
107
- });
108
- }
109
- return resultWhere;
110
- }
111
- injectToWhere(where, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot) {
80
+ injectToWhere(where, entity, isRoot, relationContext, ancestorPath, scope) {
112
81
  const resultWhere = {};
113
82
  if (where.and) {
114
83
  resultWhere.and = where.and.filter((it) => !!it).map(
115
- (it) => this.injectToWhere(it, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)
84
+ (it) => this.injectToWhere(it, entity, isRoot, relationContext, ancestorPath, scope)
116
85
  );
117
86
  }
118
87
  if (where.or) {
119
88
  resultWhere.or = where.or.filter((it) => !!it).map(
120
- (it) => this.injectToWhere(it, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)
89
+ (it) => this.injectToWhere(it, entity, isRoot, relationContext, ancestorPath, scope)
121
90
  );
122
91
  }
123
92
  if (where.not) {
124
- resultWhere.not = this.injectToWhere(where.not, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot);
93
+ resultWhere.not = this.injectToWhere(where.not, entity, isRoot, relationContext, ancestorPath, scope);
125
94
  }
126
95
  const fields = Object.keys(where).filter((it) => !["and", "or", "not"].includes(it));
127
96
  if (fields.length === 0) {
128
97
  return resultWhere;
129
98
  }
99
+ const isCellLevel = (field) => this.predicateFactory.shouldApplyCellLevelPredicate(entity, schema.Acl.Operation.read, field, scope);
100
+ const fieldGuard = (field) => this.predicateFactory.create(entity, schema.Acl.Operation.read, scope, [field], relationContext);
130
101
  for (let field of fields) {
131
102
  resultWhere[field] = schemaUtils.acceptFieldVisitor(this.schema, entity, field, {
132
103
  visitColumn: () => where[field],
@@ -135,16 +106,43 @@ class PredicatesInjector {
135
106
  if (relationWhere === null) {
136
107
  return null;
137
108
  }
138
- const isBackReference = this.findBackReferencedAncestor(ancestorPath, context.relation.name, context.entity.name) !== void 0;
139
- const nestedIsBackReferenceContext = isBackReference || isBackReferenceContext;
140
109
  const nestedAncestorPath = [...ancestorPath, context];
141
- return this.injectToWhere(relationWhere, context.targetEntity, false, context, nestedIsBackReferenceContext, nestedAncestorPath, isQueryRoot);
110
+ const nestedWhere = this.injectToWhere(relationWhere, context.targetEntity, false, context, nestedAncestorPath, "nested");
111
+ const guard = this.createReadGuard(context, ancestorPath);
112
+ return {
113
+ ...nestedWhere,
114
+ ...Object.keys(guard).length > 0 ? { [READ_GUARD_KEY]: guard } : {},
115
+ ...isCellLevel(field) ? { [FIELD_GUARD_KEY]: fieldGuard(field) } : {}
116
+ };
142
117
  }
143
118
  });
144
119
  }
145
- const fieldsForPredicate = !isRoot ? fields : fields.filter((it) => this.predicateFactory.shouldApplyCellLevelPredicate(entity, schema.Acl.Operation.read, it, isQueryRoot));
146
- return this.createWhere(entity, fieldsForPredicate, resultWhere, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot);
120
+ const maskedColumns = fields.filter((it) => schemaUtils.isColumn(entity.fields[it]) && !this.isEmptyCondition(where[it]) && isCellLevel(it));
121
+ if (maskedColumns.length === 0) {
122
+ return resultWhere;
123
+ }
124
+ resultWhere[MASKED_CELL_KEY] = maskedColumns.map((field) => ({ guard: fieldGuard(field), where: { [field]: resultWhere[field] } }));
125
+ for (const field of maskedColumns) {
126
+ delete resultWhere[field];
127
+ }
128
+ return resultWhere;
129
+ }
130
+ isEmptyCondition(value) {
131
+ return isWhere(value) && Object.keys(value).length === 0;
147
132
  }
148
- }
133
+ };
134
+ __publicField(_PredicatesInjector, "toOneBackReferenceTypes", /* @__PURE__ */ new Set([
135
+ "manyHasOne",
136
+ "oneHasOneOwning",
137
+ "oneHasOneInverse"
138
+ ]));
139
+ let PredicatesInjector = _PredicatesInjector;
140
+ exports.FIELD_GUARD_KEY = FIELD_GUARD_KEY;
141
+ exports.MASKED_CELL_KEY = MASKED_CELL_KEY;
149
142
  exports.PredicatesInjector = PredicatesInjector;
143
+ exports.READ_GUARD_KEY = READ_GUARD_KEY;
144
+ exports.isWhere = isWhere;
145
+ exports.parseMaskedCells = parseMaskedCells;
146
+ exports.splitFieldGuard = splitFieldGuard;
147
+ exports.splitReadGuard = splitReadGuard;
150
148
  //# sourceMappingURL=PredicatesInjector.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PredicatesInjector.cjs","sources":["../../../../../packages/engine-content-api/src/acl/PredicatesInjector.ts"],"sourcesContent":["import { Acl, Input, Model, Writable } from '@contember/schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { PredicateFactory } from './PredicateFactory.js'\n\nexport class PredicatesInjector {\n\tconstructor(private readonly schema: Model.Schema, private readonly predicateFactory: PredicateFactory) {}\n\n\tpublic inject(\n\t\tentity: Model.Entity,\n\t\twhere: Input.OptionalWhere,\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tancestorPath?: readonly Model.AnyRelationContext[],\n\t): Input.OptionalWhere {\n\t\tconst isQueryRoot = !relationContext && (!ancestorPath || ancestorPath.length === 0)\n\t\tconst restrictedWhere = this.injectToWhere(where, entity, true, relationContext, false, ancestorPath ?? [], isQueryRoot)\n\t\treturn this.createWhere(entity, undefined, restrictedWhere, relationContext, false, ancestorPath ?? [], isQueryRoot)\n\t}\n\n\t/**\n\t * Finds an ancestor in the path that matches the given relation as a back-reference.\n\t * A match occurs when:\n\t * 1. The relation we're traversing has the same name as the inverse (targetRelation) of a relation in the ancestor path\n\t * 2. AND the entity where our relation is defined matches the targetEntity in the path\n\t * (to prevent false positives when different entities have relations with the same name)\n\t */\n\tprivate findBackReferencedAncestor(\n\t\tancestorPath: readonly Model.AnyRelationContext[],\n\t\trelationName: string,\n\t\trelationSourceEntityName: string,\n\t): Model.AnyRelationContext | undefined {\n\t\treturn ancestorPath.find(ctx =>\n\t\t\tctx.targetRelation?.name === relationName\n\t\t\t&& ctx.targetEntity.name === relationSourceEntityName\n\t\t)\n\t}\n\n\tprivate createWhere(\n\t\tentity: Model.Entity,\n\t\tfieldNames: string[] | undefined,\n\t\twhere: Input.OptionalWhere,\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tisBackReferenceContext?: boolean,\n\t\tancestorPath?: readonly Model.AnyRelationContext[],\n\t\tisQueryRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\t// Simplify predicates when:\n\t\t// 1. We're in a back-reference context (inside a filter that traverses back)\n\t\t// 2. AND the relation we traversed to get here corresponds to a relation in our query path\n\t\t// This ensures we only simplify when the traversed relation actually corresponds\n\t\t// to a relation in our query path (not just any relation to the same entity type)\n\t\tconst shouldSimplify = isBackReferenceContext === true\n\t\t\t&& ancestorPath !== undefined\n\t\t\t&& relationContext !== undefined\n\t\t\t&& this.findBackReferencedAncestor(ancestorPath, relationContext.relation.name, relationContext.entity.name) !== undefined\n\n\t\tlet predicatesWhere: Input.OptionalWhere\n\t\tif (shouldSimplify) {\n\t\t\tpredicatesWhere = { [entity.primary]: { always: true } }\n\t\t} else {\n\t\t\tconst rawPredicate = this.predicateFactory.create(entity, Acl.Operation.read, fieldNames, relationContext, isQueryRoot)\n\t\t\t// Process the predicate to inject nested entity predicates\n\t\t\tpredicatesWhere = this.injectPredicatesToPredicate(\n\t\t\t\trawPredicate,\n\t\t\t\tentity,\n\t\t\t\tisBackReferenceContext ?? false,\n\t\t\t\tancestorPath ?? [],\n\t\t\t\tisQueryRoot,\n\t\t\t)\n\t\t}\n\n\t\tconst and = [where, predicatesWhere].filter(it => Object.keys(it).length > 0)\n\t\tif (and.length === 0) {\n\t\t\treturn {}\n\t\t}\n\t\tif (and.length === 1) {\n\t\t\treturn and[0]\n\t\t}\n\t\treturn { and: and }\n\t}\n\n\t/**\n\t * Processes a predicate and injects nested entity predicates for any relation traversals.\n\t * This ensures that when a predicate like { department: { company: { name: 'Acme' } } }\n\t * is used, the predicates of Department and Company are also applied.\n\t */\n\tprivate injectPredicatesToPredicate(\n\t\twhere: Input.OptionalWhere,\n\t\tentity: Model.Entity,\n\t\tisBackReferenceContext: boolean,\n\t\tancestorPath: readonly Model.AnyRelationContext[],\n\t\tisQueryRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\tconst resultWhere: Writable<Input.OptionalWhere> = {}\n\n\t\tif (where.and) {\n\t\t\tresultWhere.and = where.and\n\t\t\t\t.filter((it): it is Input.Where => !!it)\n\t\t\t\t.map(it => this.injectPredicatesToPredicate(it, entity, isBackReferenceContext, ancestorPath, isQueryRoot))\n\t\t}\n\t\tif (where.or) {\n\t\t\tresultWhere.or = where.or\n\t\t\t\t.filter((it): it is Input.Where => !!it)\n\t\t\t\t.map(it => this.injectPredicatesToPredicate(it, entity, isBackReferenceContext, ancestorPath, isQueryRoot))\n\t\t}\n\t\tif (where.not) {\n\t\t\tresultWhere.not = this.injectPredicatesToPredicate(where.not, entity, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t}\n\n\t\tconst fields = Object.keys(where).filter(it => !['and', 'or', 'not'].includes(it))\n\n\t\tfor (const field of fields) {\n\t\t\tresultWhere[field] = acceptFieldVisitor(this.schema, entity, field, {\n\t\t\t\tvisitColumn: () => where[field],\n\t\t\t\tvisitRelation: context => {\n\t\t\t\t\tconst relationWhere = where[field] as Input.OptionalWhere | null\n\t\t\t\t\tif (relationWhere === null) {\n\t\t\t\t\t\treturn null\n\t\t\t\t\t}\n\n\t\t\t\t\t// Check if this relation is a back-reference to somewhere in our ancestor path\n\t\t\t\t\tconst isBackReference = this.findBackReferencedAncestor(\n\t\t\t\t\t\tancestorPath,\n\t\t\t\t\t\tcontext.relation.name,\n\t\t\t\t\t\tcontext.entity.name,\n\t\t\t\t\t) !== undefined\n\t\t\t\t\tconst nestedIsBackReferenceContext = isBackReference || isBackReferenceContext\n\t\t\t\t\tconst nestedAncestorPath: readonly Model.AnyRelationContext[] = [...ancestorPath, context]\n\n\t\t\t\t\t// Recursively process the nested where (always do this to handle deeper nesting)\n\t\t\t\t\tconst processedNestedWhere = this.injectPredicatesToPredicate(\n\t\t\t\t\t\trelationWhere,\n\t\t\t\t\t\tcontext.targetEntity,\n\t\t\t\t\t\tnestedIsBackReferenceContext,\n\t\t\t\t\t\tnestedAncestorPath,\n\t\t\t\t\t\tisQueryRoot,\n\t\t\t\t\t)\n\n\t\t\t\t\t// Check if we should simplify the target entity's predicate\n\t\t\t\t\tconst shouldSimplifyNested = nestedIsBackReferenceContext\n\t\t\t\t\t\t&& this.findBackReferencedAncestor(nestedAncestorPath, context.relation.name, context.entity.name) !== undefined\n\n\t\t\t\t\t// Get target entity's predicate (simplified if back-reference)\n\t\t\t\t\tconst targetPredicate = shouldSimplifyNested\n\t\t\t\t\t\t? { [context.targetEntity.primary]: { always: true } }\n\t\t\t\t\t\t: this.predicateFactory.create(context.targetEntity, Acl.Operation.read, undefined, context, isQueryRoot)\n\n\t\t\t\t\t// Optimization: avoid duplicate { id: always } when both are simplified\n\t\t\t\t\tconst primaryKey = context.targetEntity.primary\n\t\t\t\t\tconst nestedIsAlwaysTrue = Object.keys(processedNestedWhere).length === 1\n\t\t\t\t\t\t&& (processedNestedWhere as Record<string, unknown>)[primaryKey] !== undefined\n\t\t\t\t\t\t&& (processedNestedWhere as Record<string, Record<string, unknown>>)[primaryKey]?.always === true\n\t\t\t\t\tconst targetIsAlwaysTrue = Object.keys(targetPredicate).length === 1\n\t\t\t\t\t\t&& (targetPredicate as Record<string, unknown>)[primaryKey] !== undefined\n\t\t\t\t\t\t&& (targetPredicate as Record<string, Record<string, unknown>>)[primaryKey]?.always === true\n\n\t\t\t\t\tif (nestedIsAlwaysTrue && targetIsAlwaysTrue) {\n\t\t\t\t\t\treturn processedNestedWhere\n\t\t\t\t\t}\n\n\t\t\t\t\t// Combine the processed nested where with target entity's predicate\n\t\t\t\t\tconst parts = [processedNestedWhere, targetPredicate].filter(it => Object.keys(it).length > 0)\n\t\t\t\t\tif (parts.length === 0) {\n\t\t\t\t\t\treturn {}\n\t\t\t\t\t}\n\t\t\t\t\tif (parts.length === 1) {\n\t\t\t\t\t\treturn parts[0]\n\t\t\t\t\t}\n\t\t\t\t\treturn { and: parts }\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\n\t\treturn resultWhere\n\t}\n\n\tprivate injectToWhere(\n\t\twhere: Input.OptionalWhere,\n\t\tentity: Model.Entity,\n\t\tisRoot: boolean,\n\t\trelationContext: Model.AnyRelationContext | undefined,\n\t\tisBackReferenceContext: boolean,\n\t\tancestorPath: readonly Model.AnyRelationContext[],\n\t\tisQueryRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\tconst resultWhere: Writable<Input.OptionalWhere> = {}\n\t\tif (where.and) {\n\t\t\tresultWhere.and = where.and.filter((it): it is Input.Where => !!it).map(it =>\n\t\t\t\tthis.injectToWhere(it, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t\t)\n\t\t}\n\t\tif (where.or) {\n\t\t\tresultWhere.or = where.or.filter((it): it is Input.Where => !!it).map(it =>\n\t\t\t\tthis.injectToWhere(it, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t\t)\n\t\t}\n\t\tif (where.not) {\n\t\t\tresultWhere.not = this.injectToWhere(where.not, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t}\n\n\t\tconst fields = Object.keys(where).filter(it => !['and', 'or', 'not'].includes(it))\n\n\t\tif (fields.length === 0) {\n\t\t\treturn resultWhere\n\t\t}\n\t\tfor (let field of fields) {\n\t\t\tresultWhere[field] = acceptFieldVisitor(this.schema, entity, field, {\n\t\t\t\tvisitColumn: () => where[field],\n\t\t\t\tvisitRelation: context => {\n\t\t\t\t\tconst relationWhere = where[field] as Input.OptionalWhere | null\n\t\t\t\t\tif (relationWhere === null) {\n\t\t\t\t\t\treturn null\n\t\t\t\t\t}\n\t\t\t\t\t// Check if this relation is a back-reference to somewhere in our ancestor path\n\t\t\t\t\tconst isBackReference = this.findBackReferencedAncestor(ancestorPath, context.relation.name, context.entity.name) !== undefined\n\t\t\t\t\t// Once we enter a back-reference context, stay in it for nested relations\n\t\t\t\t\tconst nestedIsBackReferenceContext = isBackReference || isBackReferenceContext\n\t\t\t\t\t// Build extended ancestor path for nested traversal\n\t\t\t\t\tconst nestedAncestorPath: Model.AnyRelationContext[] = [...ancestorPath, context]\n\t\t\t\t\treturn this.injectToWhere(relationWhere, context.targetEntity, false, context, nestedIsBackReferenceContext, nestedAncestorPath, isQueryRoot)\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tconst fieldsForPredicate = !isRoot\n\t\t\t? fields\n\t\t\t: fields.filter(it => this.predicateFactory.shouldApplyCellLevelPredicate(entity, Acl.Operation.read, it, isQueryRoot))\n\n\t\treturn this.createWhere(entity, fieldsForPredicate, resultWhere, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t}\n}\n"],"names":["schema","Acl","acceptFieldVisitor"],"mappings":";;;;AAIO,MAAM,mBAAmB;AAAA,EAC/B,YAA6BA,SAAuC,kBAAoC;AAA3E,SAAA,SAAAA;AAAuC,SAAA,mBAAA;AAAA,EAAqC;AAAA,EAElG,OACN,QACA,OACA,iBACA,cACsB;AACtB,UAAM,cAAc,CAAC,oBAAoB,CAAC,gBAAgB,aAAa,WAAW;AAClF,UAAM,kBAAkB,KAAK,cAAc,OAAO,QAAQ,MAAM,iBAAiB,OAAO,gBAAgB,CAAA,GAAI,WAAW;AACvH,WAAO,KAAK,YAAY,QAAQ,QAAW,iBAAiB,iBAAiB,OAAO,gBAAgB,CAAA,GAAI,WAAW;AAAA,EACpH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASQ,2BACP,cACA,cACA,0BACuC;AACvC,WAAO,aAAa;AAAA,MAAK,SACxB,IAAI,gBAAgB,SAAS,gBAC1B,IAAI,aAAa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A,IACR;AACA,aAAS,SAAS,QAAQ;AACzB,kBAAY,KAAK,IAAIC,YAAAA,mBAAmB,KAAK,QAAQ,QAAQ,OAAO;AAAA,QACnE,aAAa,MAAM,MAAM,KAAK;AAAA,QAC9B,eAAe,CAAA,YAAW;AACzB,gBAAM,gBAAgB,MAAM,KAAK;AACjC,cAAI,kBAAkB,MAAM;AAC3B,mBAAO;AAAA,UACR;AAEA,gBAAM,kBAAkB,KAAK,2BAA2B,cAAc,QAAQ,SAAS,MAAM,QAAQ,OAAO,IAAI,MAAM;AAEtH,gBAAM,+BAA+B,mBAAmB;AAExD,gBAAM,qBAAiD,CAAC,GAAG,cAAc,OAAO;AAChF,iBAAO,KAAK,cAAc,eAAe,QAAQ,cAAc,OAAO,SAAS,8BAA8B,oBAAoB,WAAW;AAAA,QAC7I;AAAA,MAAA,CACA;AAAA,IACF;AACA,UAAM,qBAAqB,CAAC,SACzB,SACA,OAAO,OAAO,CAAA,OAAM,KAAK,iBAAiB,8BAA8B,QAAQD,OAAAA,IAAI,UAAU,MAAM,IAAI,WAAW,CAAC;AAEvH,WAAO,KAAK,YAAY,QAAQ,oBAAoB,aAAa,iBAAiB,wBAAwB,cAAc,WAAW;AAAA,EACpI;AACD;;"}
1
+ {"version":3,"file":"PredicatesInjector.cjs","sources":["../../../../../packages/engine-content-api/src/acl/PredicatesInjector.ts"],"sourcesContent":["import { Acl, Input, Model, Writable } from '@contember/schema'\nimport { acceptFieldVisitor, isColumn } from '@contember/schema-utils'\nimport { PredicateFactory } from './PredicateFactory.js'\nimport { AclScope } from './AclScope.js'\n\n/**\n * Internal where key carrying the row-level read predicate of a relation target. The injector attaches it\n * to every user-authored relation hop; the WhereBuilder compiles it into the hop's table source (a guarded\n * join / subquery), so an unreadable related row null-extends exactly like an absent one under any boolean\n * shape. `$` cannot appear in a GraphQL name, so the key can never arrive from user input.\n */\nexport const READ_GUARD_KEY = '$readGuard'\n\n/**\n * Internal where key on a relation hop carrying the read predicate of the relation FIELD when it is stricter than\n * the source row's (a cell-level relation). It is a where over the SOURCE entity. The WhereBuilder makes the hop\n * read empty where the predicate does not hold, so a masked relation behaves exactly like an empty one.\n */\nexport const FIELD_GUARD_KEY = '$fieldGuard'\n\n/**\n * Internal where key carrying, for each cell-level column of a where level, its condition (`where`, a single-field\n * where) together with the column's read predicate (`guard`). The WhereBuilder compiles each so that a masked cell\n * behaves exactly like a NULL value: the condition holds on a masked cell iff it holds on NULL. The cells sit next\n * to the other keys of the level, so the level keeps the shape the user wrote.\n */\nexport const MASKED_CELL_KEY = '$maskedCell'\n\nexport const isWhere = (value: Input.OptionalWhere[string]): value is Input.OptionalWhere =>\n\tvalue !== null && value !== undefined && typeof value === 'object' && !Array.isArray(value)\n\nexport type MaskedCell = { guard: Input.OptionalWhere; where: Input.OptionalWhere }\n\nexport const parseMaskedCells = (value: Input.OptionalWhere[string]): MaskedCell[] => {\n\tif (!Array.isArray(value)) {\n\t\tthrow new Error(`${MASKED_CELL_KEY} expects a list of masked cells`)\n\t}\n\treturn value.map(cell => {\n\t\tif (!isWhere(cell) || !isWhere(cell.guard) || !isWhere(cell.where)) {\n\t\t\tthrow new Error(`${MASKED_CELL_KEY} expects a guard and a where`)\n\t\t}\n\t\treturn { guard: cell.guard, where: cell.where }\n\t})\n}\n\n/** Separates the field guard of a relation hop; undefined when the relation field is not cell-level. */\nexport const splitFieldGuard = (where: Input.OptionalWhere): { fieldGuard: Input.OptionalWhere | undefined; where: Input.OptionalWhere } => {\n\tconst { [FIELD_GUARD_KEY]: fieldGuard, ...rest } = where\n\treturn { fieldGuard: isWhere(fieldGuard) ? fieldGuard : undefined, where: rest }\n}\n\nexport type HopGuards = { guard: Input.OptionalWhere; fieldGuard: Input.OptionalWhere; where: Input.OptionalWhere }\n\n/** Separates the hop's read guards from the user-authored remainder; a guard is empty when absent. */\nexport const splitReadGuard = (where: Input.OptionalWhere): HopGuards => {\n\tconst { [READ_GUARD_KEY]: guard, [FIELD_GUARD_KEY]: fieldGuard, ...rest } = where\n\treturn { guard: isWhere(guard) ? guard : {}, fieldGuard: isWhere(fieldGuard) ? fieldGuard : {}, where: rest }\n}\n\nexport class PredicatesInjector {\n\t/**\n\t * Back-reference simplification is only sound for to-one back-hops. A to-one round-trip\n\t * re-reaches the exact ancestor row (already verified readable), so its predicate can be dropped.\n\t * A to-many back-hop reaches the ancestor's SIBLINGS, which are NOT guaranteed readable — dropping\n\t * their row predicate would leak a value/presence oracle over unreadable rows. Fail-closed: only the\n\t * types listed here simplify; anything else keeps the full predicate.\n\t */\n\tprivate static readonly toOneBackReferenceTypes = new Set<Model.AnyRelationContext['type']>([\n\t\t'manyHasOne',\n\t\t'oneHasOneOwning',\n\t\t'oneHasOneInverse',\n\t])\n\n\tconstructor(private readonly schema: Model.Schema, private readonly predicateFactory: PredicateFactory) {}\n\n\t/**\n\t * `scope` is the scope of the entry entity. Relations traversed by `where` are always nested. A lookup\n\t * without a relation context (a by-unique lookup of a mutation) states the scope of the row it looks for.\n\t */\n\tpublic inject(\n\t\tentity: Model.Entity,\n\t\twhere: Input.OptionalWhere,\n\t\tscope: AclScope,\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tancestorPath?: readonly Model.AnyRelationContext[],\n\t): Input.OptionalWhere {\n\t\tconst restrictedWhere = this.injectToWhere(where, entity, true, relationContext, ancestorPath ?? [], scope)\n\t\treturn this.createWhere(entity, restrictedWhere, relationContext, scope)\n\t}\n\n\t/**\n\t * Row-level read predicate guarding a relation hop's target (the nested scope, since the target\n\t * is reached through a relation). Empty when the target is freely readable, or when the hop is a to-one\n\t * back-reference to an ancestor row that is already verified readable. Shared by the filter injection\n\t * and the order-by join so both guard the same hop identically (they share the join alias).\n\t */\n\tpublic createReadGuard(relationContext: Model.AnyRelationContext, ancestorPath: readonly Model.AnyRelationContext[]): Input.OptionalWhere {\n\t\tif (this.canSimplifyBackReference(ancestorPath, relationContext)) {\n\t\t\treturn {}\n\t\t}\n\t\treturn this.predicateFactory.create(relationContext.targetEntity, Acl.Operation.read, 'nested', undefined, relationContext)\n\t}\n\n\t/**\n\t * A hop is a back-reference when it is the inverse of the hop that reached its source entity. Only the\n\t * immediate parent counts: an earlier ancestor of the same entity is generally a different row.\n\t */\n\tprivate canSimplifyBackReference(\n\t\tancestorPath: readonly Model.AnyRelationContext[],\n\t\trelationContext: Model.AnyRelationContext,\n\t): boolean {\n\t\tconst parent = ancestorPath[ancestorPath.length - 1]\n\t\tconst isBackReference = parent !== undefined\n\t\t\t&& parent.targetRelation?.name === relationContext.relation.name\n\t\t\t&& parent.targetEntity.name === relationContext.entity.name\n\t\treturn isBackReference && PredicatesInjector.toOneBackReferenceTypes.has(relationContext.type)\n\t}\n\n\t/**\n\t * ANDs the row-level read predicate of the injection root onto `where` — the only place the row predicate\n\t * lands in the WHERE; relation targets carry theirs in `READ_GUARD_KEY` instead.\n\t */\n\tprivate createWhere(\n\t\tentity: Model.Entity,\n\t\twhere: Input.OptionalWhere,\n\t\trelationContext: Model.AnyRelationContext | undefined,\n\t\tscope: AclScope,\n\t): Input.OptionalWhere {\n\t\tconst predicatesWhere = this.predicateFactory.create(entity, Acl.Operation.read, scope, undefined, relationContext)\n\n\t\tconst and = [where, predicatesWhere].filter(it => Object.keys(it).length > 0)\n\t\tif (and.length === 0) {\n\t\t\treturn {}\n\t\t}\n\t\tif (and.length === 1) {\n\t\t\treturn and[0]\n\t\t}\n\t\treturn { and: and }\n\t}\n\n\tprivate injectToWhere(\n\t\twhere: Input.OptionalWhere,\n\t\tentity: Model.Entity,\n\t\tisRoot: boolean,\n\t\trelationContext: Model.AnyRelationContext | undefined,\n\t\tancestorPath: readonly Model.AnyRelationContext[],\n\t\tscope: AclScope,\n\t): Input.OptionalWhere {\n\t\tconst resultWhere: Writable<Input.OptionalWhere> = {}\n\t\tif (where.and) {\n\t\t\tresultWhere.and = where.and.filter((it): it is Input.Where => !!it).map(it =>\n\t\t\t\tthis.injectToWhere(it, entity, isRoot, relationContext, ancestorPath, scope)\n\t\t\t)\n\t\t}\n\t\tif (where.or) {\n\t\t\tresultWhere.or = where.or.filter((it): it is Input.Where => !!it).map(it =>\n\t\t\t\tthis.injectToWhere(it, entity, isRoot, relationContext, ancestorPath, scope)\n\t\t\t)\n\t\t}\n\t\tif (where.not) {\n\t\t\tresultWhere.not = this.injectToWhere(where.not, entity, isRoot, relationContext, ancestorPath, scope)\n\t\t}\n\n\t\tconst fields = Object.keys(where).filter(it => !['and', 'or', 'not'].includes(it))\n\n\t\tif (fields.length === 0) {\n\t\t\treturn resultWhere\n\t\t}\n\t\t// Only cell-level fields (a read predicate stricter than the row-level one) need a guard of their own; the\n\t\t// row-level predicate is enforced once — in the WHERE of the injection root, or in the guarded source of a\n\t\t// relation hop. An empty column condition reads nothing, so a guard there would only filter by readability;\n\t\t// an empty relation condition can still test presence (`EXISTS`), so a relation keeps its guard.\n\t\tconst isCellLevel = (field: string) => this.predicateFactory.shouldApplyCellLevelPredicate(entity, Acl.Operation.read, field, scope)\n\t\tconst fieldGuard = (field: string) => this.predicateFactory.create(entity, Acl.Operation.read, scope, [field], relationContext)\n\t\tfor (let field of fields) {\n\t\t\tresultWhere[field] = acceptFieldVisitor(this.schema, entity, field, {\n\t\t\t\tvisitColumn: () => where[field],\n\t\t\t\tvisitRelation: context => {\n\t\t\t\t\tconst relationWhere = where[field] as Input.OptionalWhere | null\n\t\t\t\t\tif (relationWhere === null) {\n\t\t\t\t\t\treturn null\n\t\t\t\t\t}\n\t\t\t\t\tconst nestedAncestorPath: Model.AnyRelationContext[] = [...ancestorPath, context]\n\t\t\t\t\tconst nestedWhere = this.injectToWhere(relationWhere, context.targetEntity, false, context, nestedAncestorPath, 'nested')\n\t\t\t\t\tconst guard = this.createReadGuard(context, ancestorPath)\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...nestedWhere,\n\t\t\t\t\t\t...(Object.keys(guard).length > 0 ? { [READ_GUARD_KEY]: guard } : {}),\n\t\t\t\t\t\t...(isCellLevel(field) ? { [FIELD_GUARD_KEY]: fieldGuard(field) } : {}),\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tconst maskedColumns = fields.filter(it => isColumn(entity.fields[it]) && !this.isEmptyCondition(where[it]) && isCellLevel(it))\n\t\tif (maskedColumns.length === 0) {\n\t\t\treturn resultWhere\n\t\t}\n\t\tresultWhere[MASKED_CELL_KEY] = maskedColumns.map(field => ({ guard: fieldGuard(field), where: { [field]: resultWhere[field] } }))\n\t\tfor (const field of maskedColumns) {\n\t\t\tdelete resultWhere[field]\n\t\t}\n\t\treturn resultWhere\n\t}\n\n\tprivate isEmptyCondition(value: Input.OptionalWhere[string]): boolean {\n\t\treturn isWhere(value) && Object.keys(value).length === 0\n\t}\n}\n"],"names":["_PredicatesInjector","schema","Acl","acceptFieldVisitor","isColumn"],"mappings":";;;;;;;AAWO,MAAM,iBAAiB;AAOvB,MAAM,kBAAkB;AAQxB,MAAM,kBAAkB;AAExB,MAAM,UAAU,CAAC,UACvB,UAAU,QAAQ,UAAU,UAAa,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AAIpF,MAAM,mBAAmB,CAAC,UAAqD;AACrF,MAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AAC1B,UAAM,IAAI,MAAM,GAAG,eAAe,iCAAiC;AAAA,EACpE;AACA,SAAO,MAAM,IAAI,CAAA,SAAQ;AACxB,QAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,KAAK,KAAK,KAAK,CAAC,QAAQ,KAAK,KAAK,GAAG;AACnE,YAAM,IAAI,MAAM,GAAG,eAAe,8BAA8B;AAAA,IACjE;AACA,WAAO,EAAE,OAAO,KAAK,OAAO,OAAO,KAAK,MAAA;AAAA,EACzC,CAAC;AACF;AAGO,MAAM,kBAAkB,CAAC,UAA4G;AAC3I,QAAM,EAAE,CAAC,eAAe,GAAG,YAAY,GAAG,SAAS;AACnD,SAAO,EAAE,YAAY,QAAQ,UAAU,IAAI,aAAa,QAAW,OAAO,KAAA;AAC3E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,2BAA0B,oBAAI,IAAsC;AAAA,EAC3F;AAAA,EACA;AAAA,EACA;AACD,CAAC,CAAA;AAZK,IAAM,qBAAN;;;;;;;;;"}
@@ -1,42 +1,71 @@
1
1
  import { Acl } from "@contember/schema";
2
- import { acceptFieldVisitor } from "@contember/schema-utils";
3
- class PredicatesInjector {
2
+ import { acceptFieldVisitor, isColumn } from "@contember/schema-utils";
3
+ var __defProp = Object.defineProperty;
4
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
+ var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
6
+ const READ_GUARD_KEY = "$readGuard";
7
+ const FIELD_GUARD_KEY = "$fieldGuard";
8
+ const MASKED_CELL_KEY = "$maskedCell";
9
+ const isWhere = (value) => value !== null && value !== void 0 && typeof value === "object" && !Array.isArray(value);
10
+ const parseMaskedCells = (value) => {
11
+ if (!Array.isArray(value)) {
12
+ throw new Error(`${MASKED_CELL_KEY} expects a list of masked cells`);
13
+ }
14
+ return value.map((cell) => {
15
+ if (!isWhere(cell) || !isWhere(cell.guard) || !isWhere(cell.where)) {
16
+ throw new Error(`${MASKED_CELL_KEY} expects a guard and a where`);
17
+ }
18
+ return { guard: cell.guard, where: cell.where };
19
+ });
20
+ };
21
+ const splitFieldGuard = (where) => {
22
+ const { [FIELD_GUARD_KEY]: fieldGuard, ...rest } = where;
23
+ return { fieldGuard: isWhere(fieldGuard) ? fieldGuard : void 0, where: rest };
24
+ };
25
+ const splitReadGuard = (where) => {
26
+ const { [READ_GUARD_KEY]: guard, [FIELD_GUARD_KEY]: fieldGuard, ...rest } = where;
27
+ return { guard: isWhere(guard) ? guard : {}, fieldGuard: isWhere(fieldGuard) ? fieldGuard : {}, where: rest };
28
+ };
29
+ const _PredicatesInjector = class _PredicatesInjector2 {
4
30
  constructor(schema, predicateFactory) {
5
31
  this.schema = schema;
6
32
  this.predicateFactory = predicateFactory;
7
33
  }
8
- inject(entity, where, relationContext, ancestorPath) {
9
- const isQueryRoot = !relationContext && (!ancestorPath || ancestorPath.length === 0);
10
- const restrictedWhere = this.injectToWhere(where, entity, true, relationContext, false, ancestorPath ?? [], isQueryRoot);
11
- return this.createWhere(entity, void 0, restrictedWhere, relationContext, false, ancestorPath ?? [], isQueryRoot);
12
- }
13
34
  /**
14
- * Finds an ancestor in the path that matches the given relation as a back-reference.
15
- * A match occurs when:
16
- * 1. The relation we're traversing has the same name as the inverse (targetRelation) of a relation in the ancestor path
17
- * 2. AND the entity where our relation is defined matches the targetEntity in the path
18
- * (to prevent false positives when different entities have relations with the same name)
35
+ * `scope` is the scope of the entry entity. Relations traversed by `where` are always nested. A lookup
36
+ * without a relation context (a by-unique lookup of a mutation) states the scope of the row it looks for.
19
37
  */
20
- findBackReferencedAncestor(ancestorPath, relationName, relationSourceEntityName) {
21
- return ancestorPath.find(
22
- (ctx) => ctx.targetRelation?.name === relationName && ctx.targetEntity.name === relationSourceEntityName
23
- );
38
+ inject(entity, where, scope, relationContext, ancestorPath) {
39
+ const restrictedWhere = this.injectToWhere(where, entity, true, relationContext, ancestorPath ?? [], scope);
40
+ return this.createWhere(entity, restrictedWhere, relationContext, scope);
24
41
  }
25
- createWhere(entity, fieldNames, where, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot) {
26
- const shouldSimplify = isBackReferenceContext === true && ancestorPath !== void 0 && relationContext !== void 0 && this.findBackReferencedAncestor(ancestorPath, relationContext.relation.name, relationContext.entity.name) !== void 0;
27
- let predicatesWhere;
28
- if (shouldSimplify) {
29
- predicatesWhere = { [entity.primary]: { always: true } };
30
- } else {
31
- const rawPredicate = this.predicateFactory.create(entity, Acl.Operation.read, fieldNames, relationContext, isQueryRoot);
32
- predicatesWhere = this.injectPredicatesToPredicate(
33
- rawPredicate,
34
- entity,
35
- isBackReferenceContext ?? false,
36
- ancestorPath ?? [],
37
- isQueryRoot
38
- );
42
+ /**
43
+ * Row-level read predicate guarding a relation hop's target (the nested scope, since the target
44
+ * is reached through a relation). Empty when the target is freely readable, or when the hop is a to-one
45
+ * back-reference to an ancestor row that is already verified readable. Shared by the filter injection
46
+ * and the order-by join so both guard the same hop identically (they share the join alias).
47
+ */
48
+ createReadGuard(relationContext, ancestorPath) {
49
+ if (this.canSimplifyBackReference(ancestorPath, relationContext)) {
50
+ return {};
39
51
  }
52
+ return this.predicateFactory.create(relationContext.targetEntity, Acl.Operation.read, "nested", void 0, relationContext);
53
+ }
54
+ /**
55
+ * A hop is a back-reference when it is the inverse of the hop that reached its source entity. Only the
56
+ * immediate parent counts: an earlier ancestor of the same entity is generally a different row.
57
+ */
58
+ canSimplifyBackReference(ancestorPath, relationContext) {
59
+ const parent = ancestorPath[ancestorPath.length - 1];
60
+ const isBackReference = parent !== void 0 && parent.targetRelation?.name === relationContext.relation.name && parent.targetEntity.name === relationContext.entity.name;
61
+ return isBackReference && _PredicatesInjector2.toOneBackReferenceTypes.has(relationContext.type);
62
+ }
63
+ /**
64
+ * ANDs the row-level read predicate of the injection root onto `where` — the only place the row predicate
65
+ * lands in the WHERE; relation targets carry theirs in `READ_GUARD_KEY` instead.
66
+ */
67
+ createWhere(entity, where, relationContext, scope) {
68
+ const predicatesWhere = this.predicateFactory.create(entity, Acl.Operation.read, scope, void 0, relationContext);
40
69
  const and = [where, predicatesWhere].filter((it) => Object.keys(it).length > 0);
41
70
  if (and.length === 0) {
42
71
  return {};
@@ -46,85 +75,27 @@ class PredicatesInjector {
46
75
  }
47
76
  return { and };
48
77
  }
49
- /**
50
- * Processes a predicate and injects nested entity predicates for any relation traversals.
51
- * This ensures that when a predicate like { department: { company: { name: 'Acme' } } }
52
- * is used, the predicates of Department and Company are also applied.
53
- */
54
- injectPredicatesToPredicate(where, entity, isBackReferenceContext, ancestorPath, isQueryRoot) {
55
- const resultWhere = {};
56
- if (where.and) {
57
- resultWhere.and = where.and.filter((it) => !!it).map((it) => this.injectPredicatesToPredicate(it, entity, isBackReferenceContext, ancestorPath, isQueryRoot));
58
- }
59
- if (where.or) {
60
- resultWhere.or = where.or.filter((it) => !!it).map((it) => this.injectPredicatesToPredicate(it, entity, isBackReferenceContext, ancestorPath, isQueryRoot));
61
- }
62
- if (where.not) {
63
- resultWhere.not = this.injectPredicatesToPredicate(where.not, entity, isBackReferenceContext, ancestorPath, isQueryRoot);
64
- }
65
- const fields = Object.keys(where).filter((it) => !["and", "or", "not"].includes(it));
66
- for (const field of fields) {
67
- resultWhere[field] = acceptFieldVisitor(this.schema, entity, field, {
68
- visitColumn: () => where[field],
69
- visitRelation: (context) => {
70
- const relationWhere = where[field];
71
- if (relationWhere === null) {
72
- return null;
73
- }
74
- const isBackReference = this.findBackReferencedAncestor(
75
- ancestorPath,
76
- context.relation.name,
77
- context.entity.name
78
- ) !== void 0;
79
- const nestedIsBackReferenceContext = isBackReference || isBackReferenceContext;
80
- const nestedAncestorPath = [...ancestorPath, context];
81
- const processedNestedWhere = this.injectPredicatesToPredicate(
82
- relationWhere,
83
- context.targetEntity,
84
- nestedIsBackReferenceContext,
85
- nestedAncestorPath,
86
- isQueryRoot
87
- );
88
- const shouldSimplifyNested = nestedIsBackReferenceContext && this.findBackReferencedAncestor(nestedAncestorPath, context.relation.name, context.entity.name) !== void 0;
89
- const targetPredicate = shouldSimplifyNested ? { [context.targetEntity.primary]: { always: true } } : this.predicateFactory.create(context.targetEntity, Acl.Operation.read, void 0, context, isQueryRoot);
90
- const primaryKey = context.targetEntity.primary;
91
- const nestedIsAlwaysTrue = Object.keys(processedNestedWhere).length === 1 && processedNestedWhere[primaryKey] !== void 0 && processedNestedWhere[primaryKey]?.always === true;
92
- const targetIsAlwaysTrue = Object.keys(targetPredicate).length === 1 && targetPredicate[primaryKey] !== void 0 && targetPredicate[primaryKey]?.always === true;
93
- if (nestedIsAlwaysTrue && targetIsAlwaysTrue) {
94
- return processedNestedWhere;
95
- }
96
- const parts = [processedNestedWhere, targetPredicate].filter((it) => Object.keys(it).length > 0);
97
- if (parts.length === 0) {
98
- return {};
99
- }
100
- if (parts.length === 1) {
101
- return parts[0];
102
- }
103
- return { and: parts };
104
- }
105
- });
106
- }
107
- return resultWhere;
108
- }
109
- injectToWhere(where, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot) {
78
+ injectToWhere(where, entity, isRoot, relationContext, ancestorPath, scope) {
110
79
  const resultWhere = {};
111
80
  if (where.and) {
112
81
  resultWhere.and = where.and.filter((it) => !!it).map(
113
- (it) => this.injectToWhere(it, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)
82
+ (it) => this.injectToWhere(it, entity, isRoot, relationContext, ancestorPath, scope)
114
83
  );
115
84
  }
116
85
  if (where.or) {
117
86
  resultWhere.or = where.or.filter((it) => !!it).map(
118
- (it) => this.injectToWhere(it, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)
87
+ (it) => this.injectToWhere(it, entity, isRoot, relationContext, ancestorPath, scope)
119
88
  );
120
89
  }
121
90
  if (where.not) {
122
- resultWhere.not = this.injectToWhere(where.not, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot);
91
+ resultWhere.not = this.injectToWhere(where.not, entity, isRoot, relationContext, ancestorPath, scope);
123
92
  }
124
93
  const fields = Object.keys(where).filter((it) => !["and", "or", "not"].includes(it));
125
94
  if (fields.length === 0) {
126
95
  return resultWhere;
127
96
  }
97
+ const isCellLevel = (field) => this.predicateFactory.shouldApplyCellLevelPredicate(entity, Acl.Operation.read, field, scope);
98
+ const fieldGuard = (field) => this.predicateFactory.create(entity, Acl.Operation.read, scope, [field], relationContext);
128
99
  for (let field of fields) {
129
100
  resultWhere[field] = acceptFieldVisitor(this.schema, entity, field, {
130
101
  visitColumn: () => where[field],
@@ -133,18 +104,45 @@ class PredicatesInjector {
133
104
  if (relationWhere === null) {
134
105
  return null;
135
106
  }
136
- const isBackReference = this.findBackReferencedAncestor(ancestorPath, context.relation.name, context.entity.name) !== void 0;
137
- const nestedIsBackReferenceContext = isBackReference || isBackReferenceContext;
138
107
  const nestedAncestorPath = [...ancestorPath, context];
139
- return this.injectToWhere(relationWhere, context.targetEntity, false, context, nestedIsBackReferenceContext, nestedAncestorPath, isQueryRoot);
108
+ const nestedWhere = this.injectToWhere(relationWhere, context.targetEntity, false, context, nestedAncestorPath, "nested");
109
+ const guard = this.createReadGuard(context, ancestorPath);
110
+ return {
111
+ ...nestedWhere,
112
+ ...Object.keys(guard).length > 0 ? { [READ_GUARD_KEY]: guard } : {},
113
+ ...isCellLevel(field) ? { [FIELD_GUARD_KEY]: fieldGuard(field) } : {}
114
+ };
140
115
  }
141
116
  });
142
117
  }
143
- const fieldsForPredicate = !isRoot ? fields : fields.filter((it) => this.predicateFactory.shouldApplyCellLevelPredicate(entity, Acl.Operation.read, it, isQueryRoot));
144
- return this.createWhere(entity, fieldsForPredicate, resultWhere, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot);
118
+ const maskedColumns = fields.filter((it) => isColumn(entity.fields[it]) && !this.isEmptyCondition(where[it]) && isCellLevel(it));
119
+ if (maskedColumns.length === 0) {
120
+ return resultWhere;
121
+ }
122
+ resultWhere[MASKED_CELL_KEY] = maskedColumns.map((field) => ({ guard: fieldGuard(field), where: { [field]: resultWhere[field] } }));
123
+ for (const field of maskedColumns) {
124
+ delete resultWhere[field];
125
+ }
126
+ return resultWhere;
127
+ }
128
+ isEmptyCondition(value) {
129
+ return isWhere(value) && Object.keys(value).length === 0;
145
130
  }
146
- }
131
+ };
132
+ __publicField(_PredicatesInjector, "toOneBackReferenceTypes", /* @__PURE__ */ new Set([
133
+ "manyHasOne",
134
+ "oneHasOneOwning",
135
+ "oneHasOneInverse"
136
+ ]));
137
+ let PredicatesInjector = _PredicatesInjector;
147
138
  export {
148
- PredicatesInjector
139
+ FIELD_GUARD_KEY,
140
+ MASKED_CELL_KEY,
141
+ PredicatesInjector,
142
+ READ_GUARD_KEY,
143
+ isWhere,
144
+ parseMaskedCells,
145
+ splitFieldGuard,
146
+ splitReadGuard
149
147
  };
150
148
  //# sourceMappingURL=PredicatesInjector.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PredicatesInjector.js","sources":["../../../../../packages/engine-content-api/src/acl/PredicatesInjector.ts"],"sourcesContent":["import { Acl, Input, Model, Writable } from '@contember/schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { PredicateFactory } from './PredicateFactory.js'\n\nexport class PredicatesInjector {\n\tconstructor(private readonly schema: Model.Schema, private readonly predicateFactory: PredicateFactory) {}\n\n\tpublic inject(\n\t\tentity: Model.Entity,\n\t\twhere: Input.OptionalWhere,\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tancestorPath?: readonly Model.AnyRelationContext[],\n\t): Input.OptionalWhere {\n\t\tconst isQueryRoot = !relationContext && (!ancestorPath || ancestorPath.length === 0)\n\t\tconst restrictedWhere = this.injectToWhere(where, entity, true, relationContext, false, ancestorPath ?? [], isQueryRoot)\n\t\treturn this.createWhere(entity, undefined, restrictedWhere, relationContext, false, ancestorPath ?? [], isQueryRoot)\n\t}\n\n\t/**\n\t * Finds an ancestor in the path that matches the given relation as a back-reference.\n\t * A match occurs when:\n\t * 1. The relation we're traversing has the same name as the inverse (targetRelation) of a relation in the ancestor path\n\t * 2. AND the entity where our relation is defined matches the targetEntity in the path\n\t * (to prevent false positives when different entities have relations with the same name)\n\t */\n\tprivate findBackReferencedAncestor(\n\t\tancestorPath: readonly Model.AnyRelationContext[],\n\t\trelationName: string,\n\t\trelationSourceEntityName: string,\n\t): Model.AnyRelationContext | undefined {\n\t\treturn ancestorPath.find(ctx =>\n\t\t\tctx.targetRelation?.name === relationName\n\t\t\t&& ctx.targetEntity.name === relationSourceEntityName\n\t\t)\n\t}\n\n\tprivate createWhere(\n\t\tentity: Model.Entity,\n\t\tfieldNames: string[] | undefined,\n\t\twhere: Input.OptionalWhere,\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tisBackReferenceContext?: boolean,\n\t\tancestorPath?: readonly Model.AnyRelationContext[],\n\t\tisQueryRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\t// Simplify predicates when:\n\t\t// 1. We're in a back-reference context (inside a filter that traverses back)\n\t\t// 2. AND the relation we traversed to get here corresponds to a relation in our query path\n\t\t// This ensures we only simplify when the traversed relation actually corresponds\n\t\t// to a relation in our query path (not just any relation to the same entity type)\n\t\tconst shouldSimplify = isBackReferenceContext === true\n\t\t\t&& ancestorPath !== undefined\n\t\t\t&& relationContext !== undefined\n\t\t\t&& this.findBackReferencedAncestor(ancestorPath, relationContext.relation.name, relationContext.entity.name) !== undefined\n\n\t\tlet predicatesWhere: Input.OptionalWhere\n\t\tif (shouldSimplify) {\n\t\t\tpredicatesWhere = { [entity.primary]: { always: true } }\n\t\t} else {\n\t\t\tconst rawPredicate = this.predicateFactory.create(entity, Acl.Operation.read, fieldNames, relationContext, isQueryRoot)\n\t\t\t// Process the predicate to inject nested entity predicates\n\t\t\tpredicatesWhere = this.injectPredicatesToPredicate(\n\t\t\t\trawPredicate,\n\t\t\t\tentity,\n\t\t\t\tisBackReferenceContext ?? false,\n\t\t\t\tancestorPath ?? [],\n\t\t\t\tisQueryRoot,\n\t\t\t)\n\t\t}\n\n\t\tconst and = [where, predicatesWhere].filter(it => Object.keys(it).length > 0)\n\t\tif (and.length === 0) {\n\t\t\treturn {}\n\t\t}\n\t\tif (and.length === 1) {\n\t\t\treturn and[0]\n\t\t}\n\t\treturn { and: and }\n\t}\n\n\t/**\n\t * Processes a predicate and injects nested entity predicates for any relation traversals.\n\t * This ensures that when a predicate like { department: { company: { name: 'Acme' } } }\n\t * is used, the predicates of Department and Company are also applied.\n\t */\n\tprivate injectPredicatesToPredicate(\n\t\twhere: Input.OptionalWhere,\n\t\tentity: Model.Entity,\n\t\tisBackReferenceContext: boolean,\n\t\tancestorPath: readonly Model.AnyRelationContext[],\n\t\tisQueryRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\tconst resultWhere: Writable<Input.OptionalWhere> = {}\n\n\t\tif (where.and) {\n\t\t\tresultWhere.and = where.and\n\t\t\t\t.filter((it): it is Input.Where => !!it)\n\t\t\t\t.map(it => this.injectPredicatesToPredicate(it, entity, isBackReferenceContext, ancestorPath, isQueryRoot))\n\t\t}\n\t\tif (where.or) {\n\t\t\tresultWhere.or = where.or\n\t\t\t\t.filter((it): it is Input.Where => !!it)\n\t\t\t\t.map(it => this.injectPredicatesToPredicate(it, entity, isBackReferenceContext, ancestorPath, isQueryRoot))\n\t\t}\n\t\tif (where.not) {\n\t\t\tresultWhere.not = this.injectPredicatesToPredicate(where.not, entity, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t}\n\n\t\tconst fields = Object.keys(where).filter(it => !['and', 'or', 'not'].includes(it))\n\n\t\tfor (const field of fields) {\n\t\t\tresultWhere[field] = acceptFieldVisitor(this.schema, entity, field, {\n\t\t\t\tvisitColumn: () => where[field],\n\t\t\t\tvisitRelation: context => {\n\t\t\t\t\tconst relationWhere = where[field] as Input.OptionalWhere | null\n\t\t\t\t\tif (relationWhere === null) {\n\t\t\t\t\t\treturn null\n\t\t\t\t\t}\n\n\t\t\t\t\t// Check if this relation is a back-reference to somewhere in our ancestor path\n\t\t\t\t\tconst isBackReference = this.findBackReferencedAncestor(\n\t\t\t\t\t\tancestorPath,\n\t\t\t\t\t\tcontext.relation.name,\n\t\t\t\t\t\tcontext.entity.name,\n\t\t\t\t\t) !== undefined\n\t\t\t\t\tconst nestedIsBackReferenceContext = isBackReference || isBackReferenceContext\n\t\t\t\t\tconst nestedAncestorPath: readonly Model.AnyRelationContext[] = [...ancestorPath, context]\n\n\t\t\t\t\t// Recursively process the nested where (always do this to handle deeper nesting)\n\t\t\t\t\tconst processedNestedWhere = this.injectPredicatesToPredicate(\n\t\t\t\t\t\trelationWhere,\n\t\t\t\t\t\tcontext.targetEntity,\n\t\t\t\t\t\tnestedIsBackReferenceContext,\n\t\t\t\t\t\tnestedAncestorPath,\n\t\t\t\t\t\tisQueryRoot,\n\t\t\t\t\t)\n\n\t\t\t\t\t// Check if we should simplify the target entity's predicate\n\t\t\t\t\tconst shouldSimplifyNested = nestedIsBackReferenceContext\n\t\t\t\t\t\t&& this.findBackReferencedAncestor(nestedAncestorPath, context.relation.name, context.entity.name) !== undefined\n\n\t\t\t\t\t// Get target entity's predicate (simplified if back-reference)\n\t\t\t\t\tconst targetPredicate = shouldSimplifyNested\n\t\t\t\t\t\t? { [context.targetEntity.primary]: { always: true } }\n\t\t\t\t\t\t: this.predicateFactory.create(context.targetEntity, Acl.Operation.read, undefined, context, isQueryRoot)\n\n\t\t\t\t\t// Optimization: avoid duplicate { id: always } when both are simplified\n\t\t\t\t\tconst primaryKey = context.targetEntity.primary\n\t\t\t\t\tconst nestedIsAlwaysTrue = Object.keys(processedNestedWhere).length === 1\n\t\t\t\t\t\t&& (processedNestedWhere as Record<string, unknown>)[primaryKey] !== undefined\n\t\t\t\t\t\t&& (processedNestedWhere as Record<string, Record<string, unknown>>)[primaryKey]?.always === true\n\t\t\t\t\tconst targetIsAlwaysTrue = Object.keys(targetPredicate).length === 1\n\t\t\t\t\t\t&& (targetPredicate as Record<string, unknown>)[primaryKey] !== undefined\n\t\t\t\t\t\t&& (targetPredicate as Record<string, Record<string, unknown>>)[primaryKey]?.always === true\n\n\t\t\t\t\tif (nestedIsAlwaysTrue && targetIsAlwaysTrue) {\n\t\t\t\t\t\treturn processedNestedWhere\n\t\t\t\t\t}\n\n\t\t\t\t\t// Combine the processed nested where with target entity's predicate\n\t\t\t\t\tconst parts = [processedNestedWhere, targetPredicate].filter(it => Object.keys(it).length > 0)\n\t\t\t\t\tif (parts.length === 0) {\n\t\t\t\t\t\treturn {}\n\t\t\t\t\t}\n\t\t\t\t\tif (parts.length === 1) {\n\t\t\t\t\t\treturn parts[0]\n\t\t\t\t\t}\n\t\t\t\t\treturn { and: parts }\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\n\t\treturn resultWhere\n\t}\n\n\tprivate injectToWhere(\n\t\twhere: Input.OptionalWhere,\n\t\tentity: Model.Entity,\n\t\tisRoot: boolean,\n\t\trelationContext: Model.AnyRelationContext | undefined,\n\t\tisBackReferenceContext: boolean,\n\t\tancestorPath: readonly Model.AnyRelationContext[],\n\t\tisQueryRoot?: boolean,\n\t): Input.OptionalWhere {\n\t\tconst resultWhere: Writable<Input.OptionalWhere> = {}\n\t\tif (where.and) {\n\t\t\tresultWhere.and = where.and.filter((it): it is Input.Where => !!it).map(it =>\n\t\t\t\tthis.injectToWhere(it, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t\t)\n\t\t}\n\t\tif (where.or) {\n\t\t\tresultWhere.or = where.or.filter((it): it is Input.Where => !!it).map(it =>\n\t\t\t\tthis.injectToWhere(it, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t\t)\n\t\t}\n\t\tif (where.not) {\n\t\t\tresultWhere.not = this.injectToWhere(where.not, entity, isRoot, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t\t}\n\n\t\tconst fields = Object.keys(where).filter(it => !['and', 'or', 'not'].includes(it))\n\n\t\tif (fields.length === 0) {\n\t\t\treturn resultWhere\n\t\t}\n\t\tfor (let field of fields) {\n\t\t\tresultWhere[field] = acceptFieldVisitor(this.schema, entity, field, {\n\t\t\t\tvisitColumn: () => where[field],\n\t\t\t\tvisitRelation: context => {\n\t\t\t\t\tconst relationWhere = where[field] as Input.OptionalWhere | null\n\t\t\t\t\tif (relationWhere === null) {\n\t\t\t\t\t\treturn null\n\t\t\t\t\t}\n\t\t\t\t\t// Check if this relation is a back-reference to somewhere in our ancestor path\n\t\t\t\t\tconst isBackReference = this.findBackReferencedAncestor(ancestorPath, context.relation.name, context.entity.name) !== undefined\n\t\t\t\t\t// Once we enter a back-reference context, stay in it for nested relations\n\t\t\t\t\tconst nestedIsBackReferenceContext = isBackReference || isBackReferenceContext\n\t\t\t\t\t// Build extended ancestor path for nested traversal\n\t\t\t\t\tconst nestedAncestorPath: Model.AnyRelationContext[] = [...ancestorPath, context]\n\t\t\t\t\treturn this.injectToWhere(relationWhere, context.targetEntity, false, context, nestedIsBackReferenceContext, nestedAncestorPath, isQueryRoot)\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tconst fieldsForPredicate = !isRoot\n\t\t\t? fields\n\t\t\t: fields.filter(it => this.predicateFactory.shouldApplyCellLevelPredicate(entity, Acl.Operation.read, it, isQueryRoot))\n\n\t\treturn this.createWhere(entity, fieldsForPredicate, resultWhere, relationContext, isBackReferenceContext, ancestorPath, isQueryRoot)\n\t}\n}\n"],"names":[],"mappings":";;AAIO,MAAM,mBAAmB;AAAA,EAC/B,YAA6B,QAAuC,kBAAoC;AAA3E,SAAA,SAAA;AAAuC,SAAA,mBAAA;AAAA,EAAqC;AAAA,EAElG,OACN,QACA,OACA,iBACA,cACsB;AACtB,UAAM,cAAc,CAAC,oBAAoB,CAAC,gBAAgB,aAAa,WAAW;AAClF,UAAM,kBAAkB,KAAK,cAAc,OAAO,QAAQ,MAAM,iBAAiB,OAAO,gBAAgB,CAAA,GAAI,WAAW;AACvH,WAAO,KAAK,YAAY,QAAQ,QAAW,iBAAiB,iBAAiB,OAAO,gBAAgB,CAAA,GAAI,WAAW;AAAA,EACpH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASQ,2BACP,cACA,cACA,0BACuC;AACvC,WAAO,aAAa;AAAA,MAAK,SACxB,IAAI,gBAAgB,SAAS,gBAC1B,IAAI,aAAa,SAAS;AAAA,IAAA;AAAA,EAE/B;AAAA,EAEQ,YACP,QACA,YACA,OACA,iBACA,wBACA,cACA,aACsB;AAMtB,UAAM,iBAAiB,2BAA2B,QAC9C,iBAAiB,UACjB,oBAAoB,UACpB,KAAK,2BAA2B,cAAc,gBAAgB,SAAS,MAAM,gBAAgB,OAAO,IAAI,MAAM;AAElH,QAAI;AACJ,QAAI,gBAAgB;AACnB,wBAAkB,EAAE,CAAC,OAAO,OAAO,GAAG,EAAE,QAAQ,OAAK;AAAA,IACt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,+BAA+B,mBAAmB;AAExD,gBAAM,qBAAiD,CAAC,GAAG,cAAc,OAAO;AAChF,iBAAO,KAAK,cAAc,eAAe,QAAQ,cAAc,OAAO,SAAS,8BAA8B,oBAAoB,WAAW;AAAA,QAC7I;AAAA,MAAA,CACA;AAAA,IACF;AACA,UAAM,qBAAqB,CAAC,SACzB,SACA,OAAO,OAAO,CAAA,OAAM,KAAK,iBAAiB,8BAA8B,QAAQ,IAAI,UAAU,MAAM,IAAI,WAAW,CAAC;AAEvH,WAAO,KAAK,YAAY,QAAQ,oBAAoB,aAAa,iBAAiB,wBAAwB,cAAc,WAAW;AAAA,EACpI;AACD;"}
1
+ {"version":3,"file":"PredicatesInjector.js","sources":["../../../../../packages/engine-content-api/src/acl/PredicatesInjector.ts"],"sourcesContent":["import { Acl, Input, Model, Writable } from '@contember/schema'\nimport { acceptFieldVisitor, isColumn } from '@contember/schema-utils'\nimport { PredicateFactory } from './PredicateFactory.js'\nimport { AclScope } from './AclScope.js'\n\n/**\n * Internal where key carrying the row-level read predicate of a relation target. The injector attaches it\n * to every user-authored relation hop; the WhereBuilder compiles it into the hop's table source (a guarded\n * join / subquery), so an unreadable related row null-extends exactly like an absent one under any boolean\n * shape. `$` cannot appear in a GraphQL name, so the key can never arrive from user input.\n */\nexport const READ_GUARD_KEY = '$readGuard'\n\n/**\n * Internal where key on a relation hop carrying the read predicate of the relation FIELD when it is stricter than\n * the source row's (a cell-level relation). It is a where over the SOURCE entity. The WhereBuilder makes the hop\n * read empty where the predicate does not hold, so a masked relation behaves exactly like an empty one.\n */\nexport const FIELD_GUARD_KEY = '$fieldGuard'\n\n/**\n * Internal where key carrying, for each cell-level column of a where level, its condition (`where`, a single-field\n * where) together with the column's read predicate (`guard`). The WhereBuilder compiles each so that a masked cell\n * behaves exactly like a NULL value: the condition holds on a masked cell iff it holds on NULL. The cells sit next\n * to the other keys of the level, so the level keeps the shape the user wrote.\n */\nexport const MASKED_CELL_KEY = '$maskedCell'\n\nexport const isWhere = (value: Input.OptionalWhere[string]): value is Input.OptionalWhere =>\n\tvalue !== null && value !== undefined && typeof value === 'object' && !Array.isArray(value)\n\nexport type MaskedCell = { guard: Input.OptionalWhere; where: Input.OptionalWhere }\n\nexport const parseMaskedCells = (value: Input.OptionalWhere[string]): MaskedCell[] => {\n\tif (!Array.isArray(value)) {\n\t\tthrow new Error(`${MASKED_CELL_KEY} expects a list of masked cells`)\n\t}\n\treturn value.map(cell => {\n\t\tif (!isWhere(cell) || !isWhere(cell.guard) || !isWhere(cell.where)) {\n\t\t\tthrow new Error(`${MASKED_CELL_KEY} expects a guard and a where`)\n\t\t}\n\t\treturn { guard: cell.guard, where: cell.where }\n\t})\n}\n\n/** Separates the field guard of a relation hop; undefined when the relation field is not cell-level. */\nexport const splitFieldGuard = (where: Input.OptionalWhere): { fieldGuard: Input.OptionalWhere | undefined; where: Input.OptionalWhere } => {\n\tconst { [FIELD_GUARD_KEY]: fieldGuard, ...rest } = where\n\treturn { fieldGuard: isWhere(fieldGuard) ? fieldGuard : undefined, where: rest }\n}\n\nexport type HopGuards = { guard: Input.OptionalWhere; fieldGuard: Input.OptionalWhere; where: Input.OptionalWhere }\n\n/** Separates the hop's read guards from the user-authored remainder; a guard is empty when absent. */\nexport const splitReadGuard = (where: Input.OptionalWhere): HopGuards => {\n\tconst { [READ_GUARD_KEY]: guard, [FIELD_GUARD_KEY]: fieldGuard, ...rest } = where\n\treturn { guard: isWhere(guard) ? guard : {}, fieldGuard: isWhere(fieldGuard) ? fieldGuard : {}, where: rest }\n}\n\nexport class PredicatesInjector {\n\t/**\n\t * Back-reference simplification is only sound for to-one back-hops. A to-one round-trip\n\t * re-reaches the exact ancestor row (already verified readable), so its predicate can be dropped.\n\t * A to-many back-hop reaches the ancestor's SIBLINGS, which are NOT guaranteed readable — dropping\n\t * their row predicate would leak a value/presence oracle over unreadable rows. Fail-closed: only the\n\t * types listed here simplify; anything else keeps the full predicate.\n\t */\n\tprivate static readonly toOneBackReferenceTypes = new Set<Model.AnyRelationContext['type']>([\n\t\t'manyHasOne',\n\t\t'oneHasOneOwning',\n\t\t'oneHasOneInverse',\n\t])\n\n\tconstructor(private readonly schema: Model.Schema, private readonly predicateFactory: PredicateFactory) {}\n\n\t/**\n\t * `scope` is the scope of the entry entity. Relations traversed by `where` are always nested. A lookup\n\t * without a relation context (a by-unique lookup of a mutation) states the scope of the row it looks for.\n\t */\n\tpublic inject(\n\t\tentity: Model.Entity,\n\t\twhere: Input.OptionalWhere,\n\t\tscope: AclScope,\n\t\trelationContext?: Model.AnyRelationContext,\n\t\tancestorPath?: readonly Model.AnyRelationContext[],\n\t): Input.OptionalWhere {\n\t\tconst restrictedWhere = this.injectToWhere(where, entity, true, relationContext, ancestorPath ?? [], scope)\n\t\treturn this.createWhere(entity, restrictedWhere, relationContext, scope)\n\t}\n\n\t/**\n\t * Row-level read predicate guarding a relation hop's target (the nested scope, since the target\n\t * is reached through a relation). Empty when the target is freely readable, or when the hop is a to-one\n\t * back-reference to an ancestor row that is already verified readable. Shared by the filter injection\n\t * and the order-by join so both guard the same hop identically (they share the join alias).\n\t */\n\tpublic createReadGuard(relationContext: Model.AnyRelationContext, ancestorPath: readonly Model.AnyRelationContext[]): Input.OptionalWhere {\n\t\tif (this.canSimplifyBackReference(ancestorPath, relationContext)) {\n\t\t\treturn {}\n\t\t}\n\t\treturn this.predicateFactory.create(relationContext.targetEntity, Acl.Operation.read, 'nested', undefined, relationContext)\n\t}\n\n\t/**\n\t * A hop is a back-reference when it is the inverse of the hop that reached its source entity. Only the\n\t * immediate parent counts: an earlier ancestor of the same entity is generally a different row.\n\t */\n\tprivate canSimplifyBackReference(\n\t\tancestorPath: readonly Model.AnyRelationContext[],\n\t\trelationContext: Model.AnyRelationContext,\n\t): boolean {\n\t\tconst parent = ancestorPath[ancestorPath.length - 1]\n\t\tconst isBackReference = parent !== undefined\n\t\t\t&& parent.targetRelation?.name === relationContext.relation.name\n\t\t\t&& parent.targetEntity.name === relationContext.entity.name\n\t\treturn isBackReference && PredicatesInjector.toOneBackReferenceTypes.has(relationContext.type)\n\t}\n\n\t/**\n\t * ANDs the row-level read predicate of the injection root onto `where` — the only place the row predicate\n\t * lands in the WHERE; relation targets carry theirs in `READ_GUARD_KEY` instead.\n\t */\n\tprivate createWhere(\n\t\tentity: Model.Entity,\n\t\twhere: Input.OptionalWhere,\n\t\trelationContext: Model.AnyRelationContext | undefined,\n\t\tscope: AclScope,\n\t): Input.OptionalWhere {\n\t\tconst predicatesWhere = this.predicateFactory.create(entity, Acl.Operation.read, scope, undefined, relationContext)\n\n\t\tconst and = [where, predicatesWhere].filter(it => Object.keys(it).length > 0)\n\t\tif (and.length === 0) {\n\t\t\treturn {}\n\t\t}\n\t\tif (and.length === 1) {\n\t\t\treturn and[0]\n\t\t}\n\t\treturn { and: and }\n\t}\n\n\tprivate injectToWhere(\n\t\twhere: Input.OptionalWhere,\n\t\tentity: Model.Entity,\n\t\tisRoot: boolean,\n\t\trelationContext: Model.AnyRelationContext | undefined,\n\t\tancestorPath: readonly Model.AnyRelationContext[],\n\t\tscope: AclScope,\n\t): Input.OptionalWhere {\n\t\tconst resultWhere: Writable<Input.OptionalWhere> = {}\n\t\tif (where.and) {\n\t\t\tresultWhere.and = where.and.filter((it): it is Input.Where => !!it).map(it =>\n\t\t\t\tthis.injectToWhere(it, entity, isRoot, relationContext, ancestorPath, scope)\n\t\t\t)\n\t\t}\n\t\tif (where.or) {\n\t\t\tresultWhere.or = where.or.filter((it): it is Input.Where => !!it).map(it =>\n\t\t\t\tthis.injectToWhere(it, entity, isRoot, relationContext, ancestorPath, scope)\n\t\t\t)\n\t\t}\n\t\tif (where.not) {\n\t\t\tresultWhere.not = this.injectToWhere(where.not, entity, isRoot, relationContext, ancestorPath, scope)\n\t\t}\n\n\t\tconst fields = Object.keys(where).filter(it => !['and', 'or', 'not'].includes(it))\n\n\t\tif (fields.length === 0) {\n\t\t\treturn resultWhere\n\t\t}\n\t\t// Only cell-level fields (a read predicate stricter than the row-level one) need a guard of their own; the\n\t\t// row-level predicate is enforced once — in the WHERE of the injection root, or in the guarded source of a\n\t\t// relation hop. An empty column condition reads nothing, so a guard there would only filter by readability;\n\t\t// an empty relation condition can still test presence (`EXISTS`), so a relation keeps its guard.\n\t\tconst isCellLevel = (field: string) => this.predicateFactory.shouldApplyCellLevelPredicate(entity, Acl.Operation.read, field, scope)\n\t\tconst fieldGuard = (field: string) => this.predicateFactory.create(entity, Acl.Operation.read, scope, [field], relationContext)\n\t\tfor (let field of fields) {\n\t\t\tresultWhere[field] = acceptFieldVisitor(this.schema, entity, field, {\n\t\t\t\tvisitColumn: () => where[field],\n\t\t\t\tvisitRelation: context => {\n\t\t\t\t\tconst relationWhere = where[field] as Input.OptionalWhere | null\n\t\t\t\t\tif (relationWhere === null) {\n\t\t\t\t\t\treturn null\n\t\t\t\t\t}\n\t\t\t\t\tconst nestedAncestorPath: Model.AnyRelationContext[] = [...ancestorPath, context]\n\t\t\t\t\tconst nestedWhere = this.injectToWhere(relationWhere, context.targetEntity, false, context, nestedAncestorPath, 'nested')\n\t\t\t\t\tconst guard = this.createReadGuard(context, ancestorPath)\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...nestedWhere,\n\t\t\t\t\t\t...(Object.keys(guard).length > 0 ? { [READ_GUARD_KEY]: guard } : {}),\n\t\t\t\t\t\t...(isCellLevel(field) ? { [FIELD_GUARD_KEY]: fieldGuard(field) } : {}),\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tconst maskedColumns = fields.filter(it => isColumn(entity.fields[it]) && !this.isEmptyCondition(where[it]) && isCellLevel(it))\n\t\tif (maskedColumns.length === 0) {\n\t\t\treturn resultWhere\n\t\t}\n\t\tresultWhere[MASKED_CELL_KEY] = maskedColumns.map(field => ({ guard: fieldGuard(field), where: { [field]: resultWhere[field] } }))\n\t\tfor (const field of maskedColumns) {\n\t\t\tdelete resultWhere[field]\n\t\t}\n\t\treturn resultWhere\n\t}\n\n\tprivate isEm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