@contember/engine-content-api 1.1.2 → 1.2.0-alpha.11

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 (352) hide show
  1. package/dist/src/acl/EvaluatedPredicateReplacer.d.ts +9 -0
  2. package/dist/src/acl/EvaluatedPredicateReplacer.d.ts.map +1 -0
  3. package/dist/src/acl/EvaluatedPredicateReplacer.js +31 -0
  4. package/dist/src/acl/EvaluatedPredicateReplacer.js.map +1 -0
  5. package/dist/src/acl/PermissionFactory.d.ts.map +1 -1
  6. package/dist/src/acl/PermissionFactory.js +15 -11
  7. package/dist/src/acl/PermissionFactory.js.map +1 -1
  8. package/dist/src/acl/PredicateFactory.d.ts +4 -2
  9. package/dist/src/acl/PredicateFactory.d.ts.map +1 -1
  10. package/dist/src/acl/PredicateFactory.js +17 -6
  11. package/dist/src/acl/PredicateFactory.js.map +1 -1
  12. package/dist/src/acl/PredicatesInjector.d.ts +1 -1
  13. package/dist/src/acl/PredicatesInjector.d.ts.map +1 -1
  14. package/dist/src/acl/PredicatesInjector.js +16 -19
  15. package/dist/src/acl/PredicatesInjector.js.map +1 -1
  16. package/dist/src/acl/VariableInjector.d.ts +0 -1
  17. package/dist/src/acl/VariableInjector.d.ts.map +1 -1
  18. package/dist/src/acl/VariableInjector.js +4 -14
  19. package/dist/src/acl/VariableInjector.js.map +1 -1
  20. package/dist/src/acl/VariableUtils.d.ts +2 -13
  21. package/dist/src/acl/VariableUtils.d.ts.map +1 -1
  22. package/dist/src/acl/VariableUtils.js +5 -16
  23. package/dist/src/acl/VariableUtils.js.map +1 -1
  24. package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.d.ts +0 -1
  25. package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.d.ts.map +1 -1
  26. package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js +14 -15
  27. package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js.map +1 -1
  28. package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.d.ts +1 -1
  29. package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.d.ts.map +1 -1
  30. package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +1 -1
  31. package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
  32. package/dist/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.d.ts +5 -4
  33. package/dist/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.d.ts.map +1 -1
  34. package/dist/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.js +29 -20
  35. package/dist/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.js.map +1 -1
  36. package/dist/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.d.ts.map +1 -1
  37. package/dist/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js +2 -2
  38. package/dist/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js.map +1 -1
  39. package/dist/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.d.ts +3 -3
  40. package/dist/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.d.ts.map +1 -1
  41. package/dist/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +3 -3
  42. package/dist/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js.map +1 -1
  43. package/dist/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.d.ts +5 -4
  44. package/dist/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.d.ts.map +1 -1
  45. package/dist/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.js +29 -20
  46. package/dist/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.js.map +1 -1
  47. package/dist/src/input-validation/ColumnValueResolver.d.ts +4 -3
  48. package/dist/src/input-validation/ColumnValueResolver.d.ts.map +1 -1
  49. package/dist/src/input-validation/ColumnValueResolver.js.map +1 -1
  50. package/dist/src/input-validation/EntityRulesResolver.js +4 -4
  51. package/dist/src/input-validation/EntityRulesResolver.js.map +1 -1
  52. package/dist/src/input-validation/QueryAstFactory.js +1 -1
  53. package/dist/src/input-validation/QueryAstFactory.js.map +1 -1
  54. package/dist/src/input-validation/ValidationContext.d.ts +2 -2
  55. package/dist/src/input-validation/ValidationContext.d.ts.map +1 -1
  56. package/dist/src/input-validation/ValidationContext.js.map +1 -1
  57. package/dist/src/input-validation/ValidationDataSelector.d.ts.map +1 -1
  58. package/dist/src/input-validation/ValidationDataSelector.js +1 -1
  59. package/dist/src/input-validation/ValidationDataSelector.js.map +1 -1
  60. package/dist/src/input-validation/preValidation/CreateInputPreValidationProcessor.d.ts +7 -8
  61. package/dist/src/input-validation/preValidation/CreateInputPreValidationProcessor.d.ts.map +1 -1
  62. package/dist/src/input-validation/preValidation/CreateInputPreValidationProcessor.js.map +1 -1
  63. package/dist/src/input-validation/preValidation/InputPreValidator.js +4 -4
  64. package/dist/src/input-validation/preValidation/InputPreValidator.js.map +1 -1
  65. package/dist/src/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts +7 -8
  66. package/dist/src/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts.map +1 -1
  67. package/dist/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map +1 -1
  68. package/dist/src/inputProcessing/CreateInputProcessor.d.ts +8 -9
  69. package/dist/src/inputProcessing/CreateInputProcessor.d.ts.map +1 -1
  70. package/dist/src/inputProcessing/CreateInputVisitor.d.ts +7 -7
  71. package/dist/src/inputProcessing/CreateInputVisitor.d.ts.map +1 -1
  72. package/dist/src/inputProcessing/CreateInputVisitor.js +15 -46
  73. package/dist/src/inputProcessing/CreateInputVisitor.js.map +1 -1
  74. package/dist/src/inputProcessing/UpdateInputProcessor.d.ts +8 -9
  75. package/dist/src/inputProcessing/UpdateInputProcessor.d.ts.map +1 -1
  76. package/dist/src/inputProcessing/UpdateInputVisitor.d.ts +7 -7
  77. package/dist/src/inputProcessing/UpdateInputVisitor.d.ts.map +1 -1
  78. package/dist/src/inputProcessing/UpdateInputVisitor.js +13 -28
  79. package/dist/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
  80. package/dist/src/inputProcessing/index.d.ts +0 -1
  81. package/dist/src/inputProcessing/index.d.ts.map +1 -1
  82. package/dist/src/inputProcessing/index.js +0 -1
  83. package/dist/src/inputProcessing/index.js.map +1 -1
  84. package/dist/src/introspection/IntrospectionSchemaFactory.js +7 -7
  85. package/dist/src/introspection/IntrospectionSchemaFactory.js.map +1 -1
  86. package/dist/src/introspection/content-schema.types.d.ts +19 -223
  87. package/dist/src/introspection/content-schema.types.d.ts.map +1 -1
  88. package/dist/src/introspection/content-schema.types.js +2 -2
  89. package/dist/src/introspection/content-schema.types.js.map +1 -1
  90. package/dist/src/mapper/Mapper.d.ts +6 -6
  91. package/dist/src/mapper/Mapper.d.ts.map +1 -1
  92. package/dist/src/mapper/Mapper.js +28 -23
  93. package/dist/src/mapper/Mapper.js.map +1 -1
  94. package/dist/src/mapper/MapperContainer.d.ts.map +1 -1
  95. package/dist/src/mapper/MapperContainer.js +7 -4
  96. package/dist/src/mapper/MapperContainer.js.map +1 -1
  97. package/dist/src/mapper/delete/DeleteExecutor.js +3 -3
  98. package/dist/src/mapper/delete/DeleteExecutor.js.map +1 -1
  99. package/dist/src/mapper/insert/SqlCreateInputProcessor.d.ts +4 -2
  100. package/dist/src/mapper/insert/SqlCreateInputProcessor.d.ts.map +1 -1
  101. package/dist/src/mapper/insert/SqlCreateInputProcessor.js.map +1 -1
  102. package/dist/src/mapper/select/JoinVisitor.d.ts +6 -6
  103. package/dist/src/mapper/select/JoinVisitor.d.ts.map +1 -1
  104. package/dist/src/mapper/select/JoinVisitor.js +6 -6
  105. package/dist/src/mapper/select/JoinVisitor.js.map +1 -1
  106. package/dist/src/mapper/select/RelationFetcher.d.ts +32 -5
  107. package/dist/src/mapper/select/RelationFetcher.d.ts.map +1 -1
  108. package/dist/src/mapper/select/RelationFetcher.js +37 -15
  109. package/dist/src/mapper/select/RelationFetcher.js.map +1 -1
  110. package/dist/src/mapper/select/SelectBuilder.d.ts +2 -1
  111. package/dist/src/mapper/select/SelectBuilder.d.ts.map +1 -1
  112. package/dist/src/mapper/select/SelectBuilder.js +4 -2
  113. package/dist/src/mapper/select/SelectBuilder.js.map +1 -1
  114. package/dist/src/mapper/select/SelectBuilderFactory.d.ts +2 -1
  115. package/dist/src/mapper/select/SelectBuilderFactory.d.ts.map +1 -1
  116. package/dist/src/mapper/select/SelectExecutionHandler.d.ts +1 -0
  117. package/dist/src/mapper/select/SelectExecutionHandler.d.ts.map +1 -1
  118. package/dist/src/mapper/select/WhereBuilder.d.ts +6 -3
  119. package/dist/src/mapper/select/WhereBuilder.d.ts.map +1 -1
  120. package/dist/src/mapper/select/WhereBuilder.js +31 -24
  121. package/dist/src/mapper/select/WhereBuilder.js.map +1 -1
  122. package/dist/src/mapper/select/handlers/FieldsVisitor.d.ts +9 -8
  123. package/dist/src/mapper/select/handlers/FieldsVisitor.d.ts.map +1 -1
  124. package/dist/src/mapper/select/handlers/FieldsVisitor.js +45 -24
  125. package/dist/src/mapper/select/handlers/FieldsVisitor.js.map +1 -1
  126. package/dist/src/mapper/select/handlers/FieldsVisitorFactory.d.ts.map +1 -1
  127. package/dist/src/mapper/select/handlers/FieldsVisitorFactory.js +1 -1
  128. package/dist/src/mapper/select/handlers/FieldsVisitorFactory.js.map +1 -1
  129. package/dist/src/mapper/select/optimizer/ConditionOptimizer.d.ts +5 -0
  130. package/dist/src/mapper/select/optimizer/ConditionOptimizer.d.ts.map +1 -0
  131. package/dist/src/mapper/select/optimizer/ConditionOptimizer.js +39 -0
  132. package/dist/src/mapper/select/optimizer/ConditionOptimizer.js.map +1 -0
  133. package/dist/src/mapper/select/optimizer/WhereOptimizer.d.ts +15 -0
  134. package/dist/src/mapper/select/optimizer/WhereOptimizer.d.ts.map +1 -0
  135. package/dist/src/mapper/select/optimizer/WhereOptimizer.js +118 -0
  136. package/dist/src/mapper/select/optimizer/WhereOptimizer.js.map +1 -0
  137. package/dist/src/mapper/select/optimizer/WhereReplacer.d.ts +6 -0
  138. package/dist/src/mapper/select/optimizer/WhereReplacer.d.ts.map +1 -0
  139. package/dist/src/mapper/select/optimizer/WhereReplacer.js +28 -0
  140. package/dist/src/mapper/select/optimizer/WhereReplacer.js.map +1 -0
  141. package/dist/src/mapper/select/optimizer/helpers.d.ts +10 -0
  142. package/dist/src/mapper/select/optimizer/helpers.d.ts.map +1 -0
  143. package/dist/src/mapper/select/optimizer/helpers.js +72 -0
  144. package/dist/src/mapper/select/optimizer/helpers.js.map +1 -0
  145. package/dist/src/mapper/update/SqlUpdateInputProcessor.d.ts +2 -3
  146. package/dist/src/mapper/update/SqlUpdateInputProcessor.d.ts.map +1 -1
  147. package/dist/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
  148. package/dist/src/mapper/update/UpdateBuilder.js +3 -3
  149. package/dist/src/mapper/update/UpdateBuilder.js.map +1 -1
  150. package/dist/src/resolvers/GraphQlQueryAstFactory.js +2 -2
  151. package/dist/src/resolvers/GraphQlQueryAstFactory.js.map +1 -1
  152. package/dist/src/resolvers/MutationResolver.js +15 -15
  153. package/dist/src/resolvers/MutationResolver.js.map +1 -1
  154. package/dist/src/resolvers/ReadHelpers.js +10 -10
  155. package/dist/src/resolvers/ReadHelpers.js.map +1 -1
  156. package/dist/src/resolvers/ReadResolver.js +2 -2
  157. package/dist/src/resolvers/ReadResolver.js.map +1 -1
  158. package/dist/src/schema/FieldAccessVisitor.d.ts +2 -2
  159. package/dist/src/schema/FieldAccessVisitor.d.ts.map +1 -1
  160. package/dist/src/schema/FieldAccessVisitor.js +2 -2
  161. package/dist/src/schema/FieldAccessVisitor.js.map +1 -1
  162. package/dist/src/schema/MutationProvider.js +4 -4
  163. package/dist/src/schema/MutationProvider.js.map +1 -1
  164. package/dist/src/schema/OrderByTypeProvider.js +1 -1
  165. package/dist/src/schema/OrderByTypeProvider.js.map +1 -1
  166. package/dist/src/schema/QueryProvider.js +3 -3
  167. package/dist/src/schema/QueryProvider.js.map +1 -1
  168. package/dist/src/schema/ResultSchemaTypeProvider.d.ts +2 -2
  169. package/dist/src/schema/ResultSchemaTypeProvider.d.ts.map +1 -1
  170. package/dist/src/schema/WhereTypeProvider.js +4 -4
  171. package/dist/src/schema/WhereTypeProvider.js.map +1 -1
  172. package/dist/src/schema/entities/FieldArgsVisitor.d.ts +7 -7
  173. package/dist/src/schema/entities/FieldArgsVisitor.d.ts.map +1 -1
  174. package/dist/src/schema/entities/FieldArgsVisitor.js +3 -3
  175. package/dist/src/schema/entities/FieldArgsVisitor.js.map +1 -1
  176. package/dist/src/schema/entities/FieldTypeVisitor.d.ts +3 -3
  177. package/dist/src/schema/entities/FieldTypeVisitor.d.ts.map +1 -1
  178. package/dist/src/schema/entities/FieldTypeVisitor.js +3 -3
  179. package/dist/src/schema/entities/FieldTypeVisitor.js.map +1 -1
  180. package/dist/src/schema/mutations/CreateEntityInputFieldVisitor.d.ts +3 -3
  181. package/dist/src/schema/mutations/CreateEntityInputFieldVisitor.d.ts.map +1 -1
  182. package/dist/src/schema/mutations/CreateEntityInputFieldVisitor.js +3 -3
  183. package/dist/src/schema/mutations/CreateEntityInputFieldVisitor.js.map +1 -1
  184. package/dist/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.d.ts +6 -6
  185. package/dist/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.d.ts.map +1 -1
  186. package/dist/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.js +6 -6
  187. package/dist/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.js.map +1 -1
  188. package/dist/src/schema/mutations/CreateEntityRelationInputFieldVisitor.d.ts +3 -3
  189. package/dist/src/schema/mutations/CreateEntityRelationInputFieldVisitor.d.ts.map +1 -1
  190. package/dist/src/schema/mutations/CreateEntityRelationInputFieldVisitor.js +5 -5
  191. package/dist/src/schema/mutations/CreateEntityRelationInputFieldVisitor.js.map +1 -1
  192. package/dist/src/schema/mutations/UpdateEntityInputFieldVisitor.d.ts +10 -4
  193. package/dist/src/schema/mutations/UpdateEntityInputFieldVisitor.d.ts.map +1 -1
  194. package/dist/src/schema/mutations/UpdateEntityInputFieldVisitor.js +3 -3
  195. package/dist/src/schema/mutations/UpdateEntityInputFieldVisitor.js.map +1 -1
  196. package/dist/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.d.ts +6 -6
  197. package/dist/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.d.ts.map +1 -1
  198. package/dist/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.js +6 -6
  199. package/dist/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.js.map +1 -1
  200. package/dist/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.d.ts +2 -2
  201. package/dist/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.d.ts.map +1 -1
  202. package/dist/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js +2 -2
  203. package/dist/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js.map +1 -1
  204. package/dist/src/tsconfig.tsbuildinfo +1 -1
  205. package/dist/src/utils/object.d.ts.map +1 -1
  206. package/dist/src/utils/object.js +3 -4
  207. package/dist/src/utils/object.js.map +1 -1
  208. package/dist/src/utils/uniqueWhereFields.js +3 -3
  209. package/dist/src/utils/uniqueWhereFields.js.map +1 -1
  210. package/dist/tests/cases/integration/graphQlRequests/delete/aclDelete.test.js +1 -1
  211. package/dist/tests/cases/integration/graphQlRequests/delete/aclDelete.test.js.map +1 -1
  212. package/dist/tests/cases/integration/graphQlRequests/insert/acl/setField.test.js +2 -2
  213. package/dist/tests/cases/integration/graphQlRequests/insert/acl/setField.test.js.map +1 -1
  214. package/dist/tests/cases/integration/graphQlRequests/insert/aclInsert.test.js +1 -1
  215. package/dist/tests/cases/integration/graphQlRequests/insert/aclInsert.test.js.map +1 -1
  216. package/dist/tests/cases/integration/graphQlRequests/query/acl/fieldRestrictedByLocale.test.js +7 -6
  217. package/dist/tests/cases/integration/graphQlRequests/query/acl/fieldRestrictedByLocale.test.js.map +1 -1
  218. package/dist/tests/cases/integration/graphQlRequests/query/acl/nestedPredicate.test.js +1 -1
  219. package/dist/tests/cases/integration/graphQlRequests/query/acl/nestedPredicate.test.js.map +1 -1
  220. package/dist/tests/cases/integration/graphQlRequests/query/acl/predicateElimination.test.d.ts +2 -0
  221. package/dist/tests/cases/integration/graphQlRequests/query/acl/predicateElimination.test.d.ts.map +1 -0
  222. package/dist/tests/cases/integration/graphQlRequests/query/acl/predicateElimination.test.js +137 -0
  223. package/dist/tests/cases/integration/graphQlRequests/query/acl/predicateElimination.test.js.map +1 -0
  224. package/dist/tests/cases/integration/graphQlRequests/query/filter/complexCondition.test.js +1 -1
  225. package/dist/tests/cases/integration/graphQlRequests/query/filter/composedFilter.test.js +1 -1
  226. package/dist/tests/cases/integration/graphQlRequests/query/filter/composedFilter.test.js.map +1 -1
  227. package/dist/tests/cases/integration/graphQlRequests/query/relations/manyHasManyInverse.test.js +73 -0
  228. package/dist/tests/cases/integration/graphQlRequests/query/relations/manyHasManyInverse.test.js.map +1 -1
  229. package/dist/tests/cases/integration/graphQlRequests/query/relations/manyHasManyOwning.test.js +73 -0
  230. package/dist/tests/cases/integration/graphQlRequests/query/relations/manyHasManyOwning.test.js.map +1 -1
  231. package/dist/tests/cases/integration/graphQlRequests/update/acl/aclUpdate.test.js +6 -6
  232. package/dist/tests/cases/integration/graphQlRequests/update/acl/aclUpdate.test.js.map +1 -1
  233. package/dist/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.js +6 -3
  234. package/dist/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.js.map +1 -1
  235. package/dist/tests/cases/integration/graphQlSchema/model.js.map +1 -1
  236. package/dist/tests/cases/unit/aclVariablesFactory.test.js +7 -33
  237. package/dist/tests/cases/unit/aclVariablesFactory.test.js.map +1 -1
  238. package/dist/tests/cases/unit/conditionOptimizer.test.d.ts +2 -0
  239. package/dist/tests/cases/unit/conditionOptimizer.test.d.ts.map +1 -0
  240. package/dist/tests/cases/unit/conditionOptimizer.test.js +118 -0
  241. package/dist/tests/cases/unit/conditionOptimizer.test.js.map +1 -0
  242. package/dist/tests/cases/unit/orderbyHelper.test.js +1 -0
  243. package/dist/tests/cases/unit/orderbyHelper.test.js.map +1 -1
  244. package/dist/tests/cases/unit/permissionMerger.test.js +2 -0
  245. package/dist/tests/cases/unit/permissionMerger.test.js.map +1 -1
  246. package/dist/tests/cases/unit/predicatesFactory.test.d.ts +2 -0
  247. package/dist/tests/cases/unit/predicatesFactory.test.d.ts.map +1 -0
  248. package/dist/tests/cases/unit/predicatesFactory.test.js +109 -0
  249. package/dist/tests/cases/unit/predicatesFactory.test.js.map +1 -0
  250. package/dist/tests/cases/unit/predicatesInjector.test.js +88 -14
  251. package/dist/tests/cases/unit/predicatesInjector.test.js.map +1 -1
  252. package/dist/tests/cases/unit/variableInjector.test.js +4 -3
  253. package/dist/tests/cases/unit/variableInjector.test.js.map +1 -1
  254. package/dist/tests/cases/unit/whereOptimizer.test.d.ts +2 -0
  255. package/dist/tests/cases/unit/whereOptimizer.test.d.ts.map +1 -0
  256. package/dist/tests/cases/unit/whereOptimizer.test.js +265 -0
  257. package/dist/tests/cases/unit/whereOptimizer.test.js.map +1 -0
  258. package/dist/tests/src/testGraphql.d.ts.map +1 -1
  259. package/dist/tests/src/testGraphql.js +10 -2
  260. package/dist/tests/src/testGraphql.js.map +1 -1
  261. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  262. package/graphql.codegen.yml +0 -3
  263. package/package.json +16 -16
  264. package/src/acl/EvaluatedPredicateReplacer.ts +32 -0
  265. package/src/acl/PermissionFactory.ts +18 -13
  266. package/src/acl/PredicateFactory.ts +32 -8
  267. package/src/acl/PredicatesInjector.ts +25 -17
  268. package/src/acl/VariableInjector.ts +2 -15
  269. package/src/acl/VariableUtils.ts +7 -23
  270. package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.ts +17 -24
  271. package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts +1 -6
  272. package/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.ts +26 -46
  273. package/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.ts +6 -3
  274. package/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.ts +4 -22
  275. package/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.ts +26 -49
  276. package/src/input-validation/ColumnValueResolver.ts +2 -3
  277. package/src/input-validation/EntityRulesResolver.ts +4 -4
  278. package/src/input-validation/QueryAstFactory.ts +1 -1
  279. package/src/input-validation/ValidationContext.ts +2 -2
  280. package/src/input-validation/ValidationDataSelector.ts +2 -2
  281. package/src/input-validation/preValidation/CreateInputPreValidationProcessor.ts +7 -8
  282. package/src/input-validation/preValidation/InputPreValidator.ts +4 -4
  283. package/src/input-validation/preValidation/UpdateInputPreValidationProcessor.ts +7 -8
  284. package/src/inputProcessing/CreateInputProcessor.ts +8 -9
  285. package/src/inputProcessing/CreateInputVisitor.ts +27 -89
  286. package/src/inputProcessing/UpdateInputProcessor.ts +8 -9
  287. package/src/inputProcessing/UpdateInputVisitor.ts +25 -71
  288. package/src/inputProcessing/index.ts +0 -1
  289. package/src/introspection/IntrospectionSchemaFactory.ts +7 -7
  290. package/src/introspection/content-schema.types.ts +19 -286
  291. package/src/mapper/Mapper.ts +37 -30
  292. package/src/mapper/MapperContainer.ts +10 -5
  293. package/src/mapper/delete/DeleteExecutor.ts +3 -3
  294. package/src/mapper/insert/SqlCreateInputProcessor.ts +3 -3
  295. package/src/mapper/select/JoinVisitor.ts +6 -33
  296. package/src/mapper/select/RelationFetcher.ts +101 -41
  297. package/src/mapper/select/SelectBuilder.ts +3 -1
  298. package/src/mapper/select/SelectBuilderFactory.ts +2 -1
  299. package/src/mapper/select/SelectExecutionHandler.ts +1 -0
  300. package/src/mapper/select/WhereBuilder.ts +46 -32
  301. package/src/mapper/select/handlers/FieldsVisitor.ts +47 -57
  302. package/src/mapper/select/handlers/FieldsVisitorFactory.ts +1 -0
  303. package/src/mapper/select/optimizer/ConditionOptimizer.ts +41 -0
  304. package/src/mapper/select/optimizer/WhereOptimizer.ts +138 -0
  305. package/src/mapper/select/optimizer/WhereReplacer.ts +27 -0
  306. package/src/mapper/select/optimizer/helpers.ts +58 -0
  307. package/src/mapper/update/SqlUpdateInputProcessor.ts +1 -1
  308. package/src/mapper/update/UpdateBuilder.ts +3 -3
  309. package/src/resolvers/GraphQlQueryAstFactory.ts +3 -3
  310. package/src/resolvers/MutationResolver.ts +1 -1
  311. package/src/resolvers/ReadHelpers.ts +3 -3
  312. package/src/resolvers/ReadResolver.ts +2 -2
  313. package/src/schema/FieldAccessVisitor.ts +2 -2
  314. package/src/schema/OrderByTypeProvider.ts +1 -1
  315. package/src/schema/WhereTypeProvider.ts +4 -4
  316. package/src/schema/entities/FieldArgsVisitor.ts +3 -3
  317. package/src/schema/entities/FieldTypeVisitor.ts +3 -3
  318. package/src/schema/mutations/CreateEntityInputFieldVisitor.ts +3 -6
  319. package/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.ts +6 -20
  320. package/src/schema/mutations/CreateEntityRelationInputFieldVisitor.ts +5 -18
  321. package/src/schema/mutations/UpdateEntityInputFieldVisitor.ts +3 -6
  322. package/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.ts +6 -20
  323. package/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.ts +2 -12
  324. package/src/utils/object.ts +6 -6
  325. package/src/utils/uniqueWhereFields.ts +3 -3
  326. package/tests/cases/integration/graphQlRequests/delete/aclDelete.test.ts +2 -2
  327. package/tests/cases/integration/graphQlRequests/insert/acl/setField.test.ts +3 -3
  328. package/tests/cases/integration/graphQlRequests/insert/aclInsert.test.ts +2 -2
  329. package/tests/cases/integration/graphQlRequests/query/acl/fieldRestrictedByLocale.test.ts +7 -6
  330. package/tests/cases/integration/graphQlRequests/query/acl/nestedPredicate.test.ts +1 -1
  331. package/tests/cases/integration/graphQlRequests/query/acl/predicateElimination.test.ts +130 -0
  332. package/tests/cases/integration/graphQlRequests/query/filter/complexCondition.test.ts +1 -1
  333. package/tests/cases/integration/graphQlRequests/query/filter/composedFilter.test.ts +1 -1
  334. package/tests/cases/integration/graphQlRequests/query/relations/manyHasManyInverse.test.ts +74 -0
  335. package/tests/cases/integration/graphQlRequests/query/relations/manyHasManyOwning.test.ts +77 -0
  336. package/tests/cases/integration/graphQlRequests/update/acl/aclUpdate.test.ts +7 -7
  337. package/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.ts +5 -5
  338. package/tests/cases/unit/aclVariablesFactory.test.ts +8 -35
  339. package/tests/cases/unit/conditionOptimizer.test.ts +135 -0
  340. package/tests/cases/unit/orderbyHelper.test.ts +1 -0
  341. package/tests/cases/unit/permissionMerger.test.ts +2 -0
  342. package/tests/cases/unit/predicatesFactory.test.ts +103 -0
  343. package/tests/cases/unit/predicatesInjector.test.ts +78 -16
  344. package/tests/cases/unit/variableInjector.test.ts +6 -5
  345. package/tests/cases/unit/whereOptimizer.test.ts +289 -0
  346. package/tests/src/testGraphql.ts +9 -2
  347. package/dist/src/inputProcessing/InputContext.d.ts +0 -43
  348. package/dist/src/inputProcessing/InputContext.d.ts.map +0 -1
  349. package/dist/src/inputProcessing/InputContext.js +0 -3
  350. package/dist/src/inputProcessing/InputContext.js.map +0 -1
  351. package/jasmine.json +0 -7
  352. package/src/inputProcessing/InputContext.ts +0 -49
@@ -0,0 +1,130 @@
1
+ import { SchemaDefinition as def } from '@contember/schema-definition'
2
+ import { Acl } from '@contember/schema'
3
+ import { test } from 'vitest'
4
+ import { execute } from '../../../../../src/test'
5
+ import { GQL, SQL } from '../../../../../src/tags'
6
+ import { testUuid } from '../../../../../src/testUuid'
7
+
8
+ namespace TestModel {
9
+ export class Author {
10
+ name = def.stringColumn()
11
+ isPublic = def.boolColumn().notNull()
12
+ image = def.manyHasOne(Image, 'authors')
13
+ }
14
+ export class Article {
15
+ title = def.stringColumn()
16
+ isPublic = def.boolColumn().notNull()
17
+ image = def.manyHasOne(Image, 'articles')
18
+ }
19
+ export class Image {
20
+ url = def.stringColumn().notNull()
21
+
22
+ articles = def.oneHasMany(Article, 'image')
23
+ authors = def.oneHasMany(Author, 'image')
24
+ }
25
+ }
26
+ const permissions: Acl.Permissions = {
27
+ Author: {
28
+ predicates: {
29
+ authorPredicate: {
30
+ isPublic: { eq: true },
31
+ },
32
+ },
33
+ operations: {
34
+ read: {
35
+ id: 'authorPredicate',
36
+ name: 'authorPredicate',
37
+ image: 'authorPredicate',
38
+ },
39
+ },
40
+ },
41
+ Article: {
42
+ predicates: {
43
+ articlePredicate: {
44
+ isPublic: { eq: true },
45
+ },
46
+ },
47
+ operations: {
48
+ read: {
49
+ id: 'articlePredicate',
50
+ title: 'articlePredicate',
51
+ image: 'articlePredicate',
52
+ },
53
+ },
54
+ },
55
+ Image: {
56
+ predicates: {
57
+ imagePredicate: {
58
+ or: [
59
+ { authors: { isPublic: { eq: true } } },
60
+ { articles: { isPublic: { eq: true } } },
61
+ ],
62
+ },
63
+ },
64
+ operations: {
65
+ read: {
66
+ id: 'imagePredicate',
67
+ url: 'imagePredicate',
68
+ },
69
+ },
70
+ },
71
+ }
72
+
73
+ test('predicate with OR', async () => {
74
+ await execute({
75
+ schema: def.createModel(TestModel),
76
+ permissions: permissions,
77
+ variables: {},
78
+ query: GQL`
79
+ query {
80
+ listAuthor {
81
+ id
82
+ image {
83
+ url
84
+ }
85
+ }
86
+ }`,
87
+ executes: [
88
+ {
89
+ sql: SQL`SELECT "root_"."id" AS "root_id", "root_"."image_id" AS "root_image"
90
+ FROM "public"."author" AS "root_"
91
+ WHERE "root_"."is_public" = ?`,
92
+ parameters: [true],
93
+ response: {
94
+ rows: [
95
+ {
96
+ root_id: testUuid(1),
97
+ root_image: testUuid(2),
98
+ },
99
+ ],
100
+ },
101
+ },
102
+ {
103
+ sql: `select "root_"."id" as "root_id", "root_"."url" as "root_url", "root_"."id" as "root_id" from "public"."image" as "root_" where "root_"."id" in (?)`,
104
+ parameters: [testUuid(2)],
105
+ response: {
106
+ rows: [
107
+ {
108
+ root_id: testUuid(2),
109
+ root_url: 'abcd',
110
+ },
111
+ ],
112
+ },
113
+ },
114
+ ],
115
+ return: {
116
+ data: {
117
+ listAuthor: [
118
+ {
119
+ id: testUuid(1),
120
+ image: {
121
+ url: 'abcd',
122
+ },
123
+ },
124
+ ],
125
+ },
126
+ },
127
+ })
128
+ })
129
+
130
+
@@ -25,7 +25,7 @@ test('Complex condition', async () => {
25
25
  {
26
26
  sql: SQL`select "root_"."id" as "root_id"
27
27
  from "public"."post" as "root_"
28
- where (("root_"."title" = ? or "root_"."title" = ?)
28
+ where ("root_"."title" = ? or "root_"."title" = ?
29
29
  or not("root_"."title" < ?)
30
30
  or "root_"."title" is null and not("root_"."title" is null))`,
31
31
  parameters: ['A', 'B', 'X'],
@@ -19,7 +19,7 @@ test('Composed filter with nulls', async () => {
19
19
  `,
20
20
  executes: [
21
21
  {
22
- sql: SQL`select "root_"."id" as "root_id" from "public"."post" as "root_" where ("root_"."title" = ?)`,
22
+ sql: SQL`select "root_"."id" as "root_id" from "public"."post" as "root_" where "root_"."title" = ?`,
23
23
  parameters: ['John'],
24
24
  response: { rows: [{ root_id: testUuid(1) }] },
25
25
  },
@@ -171,3 +171,77 @@ test('empty many-has-many inverse relation', async () => {
171
171
  })
172
172
 
173
173
 
174
+ test('Posts with filtered tags', async () => {
175
+ await execute({
176
+ schema: new SchemaBuilder()
177
+ .entity('Post', entity => entity)
178
+ .entity('Tag', entity => entity.column('name').manyHasMany('posts', relation => relation.target('Post').inversedBy('tags')))
179
+ .buildSchema(),
180
+ query: GQL`
181
+ query {
182
+ listPost {
183
+ id
184
+ tags(filter: {name: {eq: "Foo"}}) {
185
+ name
186
+ }
187
+ }
188
+ }
189
+ `,
190
+ executes: [
191
+ {
192
+ sql: SQL`select "root_"."id" as "root_id",
193
+ "root_"."id" as "root_id"
194
+ from "public"."post" as "root_"`,
195
+ response: {
196
+ rows: [{ root_id: testUuid(1) }, { root_id: testUuid(2) }],
197
+ },
198
+ },
199
+ {
200
+ sql: SQL`select "junction_"."post_id", "junction_"."tag_id" from "public"."tag_posts" as "junction_" inner join "public"."tag" as "root_" on "junction_"."tag_id" = "root_"."id" where "junction_"."post_id" in (?, ?) and "root_"."name" = ?`,
201
+ parameters: [testUuid(1), testUuid(2), 'Foo'],
202
+ response: {
203
+ rows: [
204
+ { post_id: testUuid(1), tag_id: testUuid(3) },
205
+ { post_id: testUuid(2), tag_id: testUuid(3) },
206
+ ],
207
+ },
208
+ },
209
+ {
210
+ sql: SQL`
211
+ select "root_"."name" as "root_name",
212
+ "root_"."id" as "root_id"
213
+ from "public"."tag" as "root_"
214
+ where "root_"."id" in (?)`,
215
+ parameters: [testUuid(3)],
216
+ response: {
217
+ rows: [
218
+ { root_id: testUuid(3), root_name: 'foo' },
219
+ ],
220
+ },
221
+ },
222
+ ],
223
+ return: {
224
+ data: {
225
+ listPost: [
226
+ {
227
+ id: testUuid(1),
228
+ tags: [
229
+ {
230
+ name: 'foo',
231
+ },
232
+ ],
233
+ },
234
+ {
235
+ id: testUuid(2),
236
+ tags: [
237
+ {
238
+ name: 'foo',
239
+ },
240
+ ],
241
+ },
242
+ ],
243
+ },
244
+ },
245
+ })
246
+ })
247
+
@@ -4,6 +4,83 @@ import { SchemaBuilder } from '@contember/schema-definition'
4
4
  import { GQL, SQL } from '../../../../../src/tags'
5
5
  import { testUuid } from '../../../../../src/testUuid'
6
6
 
7
+
8
+ test('Posts with filtered tags', async () => {
9
+ await execute({
10
+ schema: new SchemaBuilder()
11
+ .entity('Post', entity => entity.manyHasMany('tags', relation => relation.target('Tag')))
12
+ .entity('Tag', entity => entity.column('name'))
13
+ .buildSchema(),
14
+ query: GQL`
15
+ query {
16
+ listPost {
17
+ id
18
+ tags(filter: {name: {eq: "Foo"}}) {
19
+ name
20
+ }
21
+ }
22
+ }
23
+ `,
24
+ executes: [
25
+ {
26
+ sql: SQL`select "root_"."id" as "root_id",
27
+ "root_"."id" as "root_id"
28
+ from "public"."post" as "root_"`,
29
+ response: {
30
+ rows: [{ root_id: testUuid(1) }, { root_id: testUuid(2) }],
31
+ },
32
+ },
33
+ {
34
+ sql: SQL`select "junction_"."tag_id", "junction_"."post_id" from "public"."post_tags" as "junction_" inner join "public"."tag" as "root_" on "junction_"."tag_id" = "root_"."id" where "junction_"."post_id" in (?, ?) and "root_"."name" = ?`,
35
+ parameters: [testUuid(1), testUuid(2), 'Foo'],
36
+ response: {
37
+ rows: [
38
+ { post_id: testUuid(1), tag_id: testUuid(3) },
39
+ { post_id: testUuid(2), tag_id: testUuid(3) },
40
+ ],
41
+ },
42
+ },
43
+ {
44
+ sql: SQL`
45
+ select "root_"."name" as "root_name",
46
+ "root_"."id" as "root_id"
47
+ from "public"."tag" as "root_"
48
+ where "root_"."id" in (?)`,
49
+ parameters: [testUuid(3)],
50
+ response: {
51
+ rows: [
52
+ { root_id: testUuid(3), root_name: 'foo' },
53
+ ],
54
+ },
55
+ },
56
+ ],
57
+ return: {
58
+ data: {
59
+ listPost: [
60
+ {
61
+ id: testUuid(1),
62
+ tags: [
63
+ {
64
+ name: 'foo',
65
+ },
66
+ ],
67
+ },
68
+ {
69
+ id: testUuid(2),
70
+ tags: [
71
+ {
72
+ name: 'foo',
73
+ },
74
+ ],
75
+ },
76
+ ],
77
+ },
78
+ },
79
+ })
80
+ })
81
+
82
+
83
+
7
84
  test('Posts with paginated tags (many has many owning)', async () => {
8
85
  await execute({
9
86
  schema: new SchemaBuilder()
@@ -1,7 +1,7 @@
1
1
  import { test } from 'vitest'
2
2
  import { execute, failedTransaction, sqlTransaction } from '../../../../../src/test'
3
3
  import { SchemaBuilder } from '@contember/schema-definition'
4
- import { Model } from '@contember/schema'
4
+ import { Model } from '@contember/schema'
5
5
  import { GQL, SQL } from '../../../../../src/tags'
6
6
  import { testUuid } from '../../../../../src/testUuid'
7
7
 
@@ -35,7 +35,7 @@ test('update name', async () => {
35
35
  },
36
36
  },
37
37
  variables: {
38
- name_variable: ['John', 'Jack'],
38
+ name_variable: { in: ['John', 'Jack'] },
39
39
  },
40
40
  executes: [
41
41
  ...sqlTransaction([
@@ -98,7 +98,7 @@ test('update name - denied', async () => {
98
98
  },
99
99
  },
100
100
  variables: {
101
- name_variable: ['John', 'Jack'],
101
+ name_variable: { in: ['John', 'Jack'] },
102
102
  },
103
103
  executes: [
104
104
  ...failedTransaction([
@@ -113,10 +113,10 @@ test('update name - denied', async () => {
113
113
  ? :: text as "name",
114
114
  "root_"."id"
115
115
  from "public"."author" as "root_"
116
- where "root_"."id" = ? and false) update "public"."author"
116
+ where false) update "public"."author"
117
117
  set "name" = "newData_"."name" from "newData_"
118
118
  where "author"."id" = "newData_"."id" and false`,
119
- parameters: ['John', testUuid(1)],
119
+ parameters: ['John'],
120
120
  response: 0,
121
121
  },
122
122
  ]),
@@ -176,8 +176,8 @@ test('update m:n', async () => {
176
176
  },
177
177
  },
178
178
  variables: {
179
- post_name_variable: ['Lorem ipsum', 'Dolor sit'],
180
- category_name_variable: ['foo', 'bar'],
179
+ post_name_variable: { in: ['Lorem ipsum', 'Dolor sit'] },
180
+ category_name_variable: { in: ['foo', 'bar'] },
181
181
  },
182
182
  query: GQL`mutation {
183
183
  updatePost(by: {id: "${testUuid(1)}"}, data: {categories: [
@@ -30,20 +30,20 @@ const testSchema = async (test: Test) => {
30
30
  const graphQlSchemaBuilder = schemaFactory.create(schemaWithAcl, authorizator)
31
31
  const graphQlSchema = graphQlSchemaBuilder.build()
32
32
 
33
- const result = await graphql(
34
- graphQlSchema,
35
- `
33
+ const result = await graphql({
34
+ schema: graphQlSchema,
35
+ source: `
36
36
  {
37
37
  _info {
38
38
  description
39
39
  }
40
40
  }
41
41
  `,
42
- )
42
+ })
43
43
  const errors = (result.errors || []).map(it => it.message)
44
44
  assert.deepEqual(errors, [])
45
45
 
46
- const textSchema = printSchema(graphQlSchema)
46
+ const textSchema = printSchema(graphQlSchema) + '\n'
47
47
 
48
48
  const filename = path.join(__dirname, test.graphQlSchemaFile)
49
49
  let expectedSchema: string
@@ -5,24 +5,21 @@ import { testUuid } from '@contember/engine-api-tester'
5
5
 
6
6
  describe('create acl variables', () => {
7
7
 
8
+ const definition: Acl.EntityVariable = { type: Acl.VariableType.entity, entityName: 'Author' }
8
9
  it('prefix from memberships', () => {
9
10
  assert.deepStrictEqual(createAclVariables({
10
11
  roles: {
11
12
  author: {
12
13
  stages: '*',
13
14
  variables: {
14
- authorID: { type: Acl.VariableType.entity, entityName: 'Author' },
15
+ authorID: definition,
15
16
  },
16
17
  entities: {
17
18
  },
18
19
  },
19
20
  },
20
- }, {
21
- identityId: testUuid(1),
22
- personId: null,
23
- memberships: [{ role: 'author', variables: [{ name: 'authorID', values: [testUuid(2)] }] }],
24
- }), {
25
- author__authorID: [testUuid(2)],
21
+ }, [{ role: 'author', variables: [{ name: 'authorID', condition: { in: [testUuid(2)] } }] }]), {
22
+ author__authorID: { in: [testUuid(2)] },
26
23
  })
27
24
  })
28
25
 
@@ -33,38 +30,14 @@ describe('create acl variables', () => {
33
30
  author: {
34
31
  stages: '*',
35
32
  variables: {
36
- authorID: { type: Acl.VariableType.entity, entityName: 'Author' },
33
+ authorID: definition,
37
34
  },
38
35
  entities: {},
39
36
  },
40
37
  },
41
- }, {
42
- identityId: testUuid(1),
43
- personId: null,
44
- memberships: [{ role: 'author', variables: [] }],
45
- }), {
46
- author__authorID: [],
47
- })
48
- })
49
-
50
-
51
- it('predefined', () => {
52
- assert.deepStrictEqual(createAclVariables({
53
- roles: {
54
- author: {
55
- stages: '*',
56
- variables: {
57
- authorIdentity: { type: Acl.VariableType.predefined, value: 'identityID' },
58
- },
59
- entities: {},
60
- },
61
- },
62
- }, {
63
- identityId: testUuid(1),
64
- personId: null,
65
- memberships: [{ role: 'author', variables: [] }],
66
- }), {
67
- author__authorIdentity: [testUuid(1)],
38
+ }, [{ role: 'author', variables: [] }],
39
+ ), {
40
+ author__authorID: { never: true },
68
41
  })
69
42
  })
70
43
  })
@@ -0,0 +1,135 @@
1
+ import { describe, it, assert } from 'vitest'
2
+ import { ConditionOptimizer } from '../../../src/mapper/select/optimizer/ConditionOptimizer'
3
+
4
+ describe('condition optimizer', () => {
5
+ const optimizer = new ConditionOptimizer()
6
+
7
+ it('remove OR when only 1', () => {
8
+ assert.deepStrictEqual(optimizer.optimize({
9
+ or: [{ eq: 1 }],
10
+ }), { eq: 1 })
11
+ })
12
+
13
+ it('keep OR when > 1', () => {
14
+ assert.deepStrictEqual(optimizer.optimize({
15
+ or: [{ eq: 1 }, { eq: 2 }],
16
+ }), {
17
+ or: [{ eq: 1 }, { eq: 2 }],
18
+ })
19
+ })
20
+
21
+ it('keep never in OR', () => {
22
+ assert.deepStrictEqual(optimizer.optimize({
23
+ or: [{ never: true }],
24
+ }), false)
25
+ })
26
+
27
+ it('optimizes OR with never', () => {
28
+ assert.deepStrictEqual(optimizer.optimize({
29
+ or: [{ eq: 1 }, { never: true }],
30
+ }), { eq: 1 })
31
+ })
32
+
33
+ it('optimizes OR with always', () => {
34
+ assert.deepStrictEqual(optimizer.optimize({
35
+ or: [{ eq: 1 }, { always: true }],
36
+ }), true)
37
+ })
38
+
39
+ it('optimizes AND with never', () => {
40
+ assert.deepStrictEqual(optimizer.optimize({
41
+ and: [{ eq: 1 }, { never: true }],
42
+ }), false)
43
+ })
44
+
45
+ it('optimizes AND with always', () => {
46
+ assert.deepStrictEqual(optimizer.optimize({
47
+ and: [{ eq: 1 }, { always: true }],
48
+ }), { eq: 1 })
49
+ })
50
+
51
+ it('optimizes NOT with never', () => {
52
+ assert.deepStrictEqual(optimizer.optimize({
53
+ not: { never: true },
54
+ }), true)
55
+ })
56
+
57
+ it('optimizes NOT with always', () => {
58
+ assert.deepStrictEqual(optimizer.optimize({
59
+ not: { always: true },
60
+ }), false)
61
+ })
62
+
63
+ it('optimizes empty AND', () => {
64
+ assert.deepStrictEqual(optimizer.optimize({
65
+ and: [],
66
+ }), {})
67
+ })
68
+
69
+ it('optimizes empty OR', () => {
70
+ assert.deepStrictEqual(optimizer.optimize({
71
+ or: [],
72
+ }), {})
73
+ })
74
+
75
+
76
+ it('flattens AND', () => {
77
+ assert.deepStrictEqual(optimizer.optimize({
78
+ eq: 0,
79
+ and: [
80
+ { eq: 1 },
81
+ {
82
+ eq: 2,
83
+ and: [
84
+ { eq: 3 },
85
+ {
86
+ eq: 4,
87
+ and: [{ eq: 5 }, { eq: 6 }],
88
+ },
89
+ ],
90
+ },
91
+ ],
92
+ }), { and: [{ eq: 0 }, { eq: 1 }, { eq: 2 }, { eq: 3 }, { eq: 4 }, { eq: 5 }, { eq: 6 }] })
93
+ })
94
+
95
+ it('flattens OR', () => {
96
+ assert.deepStrictEqual(optimizer.optimize({
97
+ or: [
98
+ { eq: 1 },
99
+ {
100
+
101
+ or: [
102
+ { eq: 2 },
103
+ { or: [{ eq: 3 }, { eq: 4 }] },
104
+ ],
105
+ },
106
+ ],
107
+ }), { or: [{ eq: 1 }, { eq: 2 }, { eq: 3 }, { eq: 4 }] })
108
+ })
109
+
110
+ it('flattens NOT', () => {
111
+ assert.deepStrictEqual(optimizer.optimize({
112
+ not: { not: { not: { eq: 1 } } },
113
+ }), { not: { eq: 1 } })
114
+ })
115
+
116
+ it('combine AND and OR', () => {
117
+ assert.deepStrictEqual(optimizer.optimize({
118
+ or: [
119
+ { and: [{ eq: 1 }, { eq: 2 }] },
120
+ { and: [{ eq: 3 }, { eq: 4 }], eq: 5 },
121
+ ],
122
+ }), { or: [
123
+ { and: [{ eq: 1 }, { eq: 2 }] },
124
+ { and: [{ eq: 3 }, { eq: 4 }, { eq: 5 }] },
125
+ ] })
126
+ })
127
+
128
+ it('remove conditions with null value', () => {
129
+ assert.deepStrictEqual(optimizer.optimize({ eq: null }), {})
130
+ })
131
+
132
+ it('remove conditions with undefined value', () => {
133
+ assert.deepStrictEqual(optimizer.optimize({ eq: undefined }), {})
134
+ })
135
+ })
@@ -11,6 +11,7 @@ const entity: Model.Entity = {
11
11
  fields: {},
12
12
  unique: {},
13
13
  eventLog: { enabled: true },
14
+ indexes: {},
14
15
  }
15
16
 
16
17
  describe('order by helper', () => {
@@ -15,8 +15,10 @@ const execute = (test: Test) => {
15
15
  .entity('Entity2', e => e.oneHasOne('xyz', r => r.target('Entity1')))
16
16
  .buildSchema()
17
17
  const merger = new PermissionFactory(schema)
18
+ const initialAcl = JSON.parse(JSON.stringify(test.acl))
18
19
  const result = merger.create(test.acl, test.roles)
19
20
  assert.deepStrictEqual(result, test.result)
21
+ assert.deepStrictEqual(test.acl, initialAcl)
20
22
  }
21
23
 
22
24
  describe('Permission merger', () => {