@contember/engine-content-api 2.2.0-alpha.17 → 2.2.0-alpha.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +1 -1
- package/dist/development/index.cjs +3 -0
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +4 -1
- package/dist/development/index.js.map +1 -1
- package/dist/development/src/ExecutionContainer.cjs +1 -0
- package/dist/development/src/ExecutionContainer.cjs.map +1 -1
- package/dist/development/src/ExecutionContainer.js +1 -0
- package/dist/development/src/ExecutionContainer.js.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs +2 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js +2 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +5 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +5 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs +2 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js +2 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs +4 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +4 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js.map +1 -1
- package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs +24 -3
- package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs.map +1 -1
- package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js +24 -3
- package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map +1 -1
- package/dist/development/src/inputProcessing/UpdateInputVisitor.cjs +52 -2
- package/dist/development/src/inputProcessing/UpdateInputVisitor.cjs.map +1 -1
- package/dist/development/src/inputProcessing/UpdateInputVisitor.js +52 -2
- package/dist/development/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
- package/dist/development/src/mapper/ErrorUtils.cjs +10 -0
- package/dist/development/src/mapper/ErrorUtils.cjs.map +1 -1
- package/dist/development/src/mapper/ErrorUtils.js +10 -0
- package/dist/development/src/mapper/ErrorUtils.js.map +1 -1
- package/dist/development/src/mapper/Mapper.cjs +37 -1
- package/dist/development/src/mapper/Mapper.cjs.map +1 -1
- package/dist/development/src/mapper/Mapper.js +38 -2
- package/dist/development/src/mapper/Mapper.js.map +1 -1
- package/dist/development/src/mapper/MutationProcessorHelper.cjs +12 -0
- package/dist/development/src/mapper/MutationProcessorHelper.cjs.map +1 -1
- package/dist/development/src/mapper/MutationProcessorHelper.js +13 -1
- package/dist/development/src/mapper/MutationProcessorHelper.js.map +1 -1
- package/dist/development/src/mapper/Result.cjs +1 -0
- package/dist/development/src/mapper/Result.cjs.map +1 -1
- package/dist/development/src/mapper/Result.js +1 -0
- package/dist/development/src/mapper/Result.js.map +1 -1
- package/dist/development/src/mapper/delete/DeleteExecutor.cjs +1 -1
- package/dist/development/src/mapper/delete/DeleteExecutor.js +1 -1
- package/dist/development/src/mapper/select/Path.cjs +2 -2
- package/dist/development/src/mapper/select/Path.cjs.map +1 -1
- package/dist/development/src/mapper/select/Path.js +2 -2
- package/dist/development/src/mapper/select/Path.js.map +1 -1
- package/dist/development/src/mapper/select/handlers/MetaHandler.cjs +1 -1
- package/dist/development/src/mapper/select/handlers/MetaHandler.js +1 -1
- package/dist/development/src/mapper/select/optimizer/WhereOptimizer.cjs +2 -2
- package/dist/development/src/mapper/select/optimizer/WhereOptimizer.cjs.map +1 -1
- package/dist/development/src/mapper/select/optimizer/WhereOptimizer.js +1 -1
- package/dist/development/src/mapper/select/optimizer/WhereOptimizer.js.map +1 -1
- package/dist/development/src/mapper/select/optimizer/WhereReplacer.cjs +3 -3
- package/dist/development/src/mapper/select/optimizer/WhereReplacer.cjs.map +1 -1
- package/dist/development/src/mapper/select/optimizer/WhereReplacer.js +1 -1
- package/dist/development/src/mapper/select/optimizer/WhereReplacer.js.map +1 -1
- package/dist/development/src/mapper/update/SqlUpdateInputProcessor.cjs +6 -3
- package/dist/development/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/SqlUpdateInputProcessor.js +7 -4
- package/dist/development/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/update/Updater.cjs +1 -1
- package/dist/development/src/mapper/update/Updater.js +1 -1
- package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs +6 -0
- package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js +6 -0
- package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs +6 -0
- package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js +6 -0
- package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/update/relations/SetManyRelationHelper.cjs +123 -0
- package/dist/development/src/mapper/update/relations/SetManyRelationHelper.cjs.map +1 -0
- package/dist/development/src/mapper/update/relations/SetManyRelationHelper.js +123 -0
- package/dist/development/src/mapper/update/relations/SetManyRelationHelper.js.map +1 -0
- package/dist/development/src/resolvers/MutationResolver.cjs +4 -1
- package/dist/development/src/resolvers/MutationResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/MutationResolver.js +4 -1
- package/dist/development/src/resolvers/MutationResolver.js.map +1 -1
- package/dist/development/src/resolvers/ReadHelpers.cjs +2 -1
- package/dist/development/src/resolvers/ReadHelpers.cjs.map +1 -1
- package/dist/development/src/resolvers/ReadHelpers.js +2 -1
- package/dist/development/src/resolvers/ReadHelpers.js.map +1 -1
- package/dist/development/src/schema/CustomTypesProvider.cjs +35 -14
- package/dist/development/src/schema/CustomTypesProvider.cjs.map +1 -1
- package/dist/development/src/schema/CustomTypesProvider.js +36 -15
- package/dist/development/src/schema/CustomTypesProvider.js.map +1 -1
- package/dist/development/src/schema/EntityTypeProvider.cjs +8 -5
- package/dist/development/src/schema/EntityTypeProvider.cjs.map +1 -1
- package/dist/development/src/schema/EntityTypeProvider.js +8 -5
- package/dist/development/src/schema/EntityTypeProvider.js.map +1 -1
- package/dist/development/src/schema/GraphQlSchemaBuilderFactory.cjs +1 -1
- package/dist/development/src/schema/GraphQlSchemaBuilderFactory.js +1 -1
- package/dist/development/src/schema/MutationProvider.cjs +4 -0
- package/dist/development/src/schema/MutationProvider.cjs.map +1 -1
- package/dist/development/src/schema/MutationProvider.js +4 -0
- package/dist/development/src/schema/MutationProvider.js.map +1 -1
- package/dist/development/src/schema/OrderByTypeProvider.cjs +8 -2
- package/dist/development/src/schema/OrderByTypeProvider.cjs.map +1 -1
- package/dist/development/src/schema/OrderByTypeProvider.js +9 -3
- package/dist/development/src/schema/OrderByTypeProvider.js.map +1 -1
- package/dist/development/src/schema/QueryProvider.cjs +3 -0
- package/dist/development/src/schema/QueryProvider.cjs.map +1 -1
- package/dist/development/src/schema/QueryProvider.js +3 -0
- package/dist/development/src/schema/QueryProvider.js.map +1 -1
- package/dist/development/src/schema/ValidationQueriesProvider.cjs +2 -0
- package/dist/development/src/schema/ValidationQueriesProvider.cjs.map +1 -1
- package/dist/development/src/schema/ValidationQueriesProvider.js +2 -0
- package/dist/development/src/schema/ValidationQueriesProvider.js.map +1 -1
- package/dist/development/src/schema/WhereTypeProvider.cjs +17 -5
- package/dist/development/src/schema/WhereTypeProvider.cjs.map +1 -1
- package/dist/development/src/schema/WhereTypeProvider.js +18 -6
- package/dist/development/src/schema/WhereTypeProvider.js.map +1 -1
- package/dist/development/src/schema/calendarDate.cjs +21 -0
- package/dist/development/src/schema/calendarDate.cjs.map +1 -0
- package/dist/development/src/schema/calendarDate.js +21 -0
- package/dist/development/src/schema/calendarDate.js.map +1 -0
- package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.cjs +11 -3
- package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.cjs.map +1 -1
- package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.js +11 -3
- package/dist/development/src/schema/mutations/CreateEntityInputFieldVisitor.js.map +1 -1
- package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs +11 -3
- package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs.map +1 -1
- package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.js +11 -3
- package/dist/development/src/schema/mutations/UpdateEntityInputFieldVisitor.js.map +1 -1
- package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs +39 -2
- package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs.map +1 -1
- package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js +40 -3
- package/dist/development/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js.map +1 -1
- package/dist/development/src/schema/utils.cjs +10 -0
- package/dist/development/src/schema/utils.cjs.map +1 -1
- package/dist/development/src/schema/utils.js +11 -1
- package/dist/development/src/schema/utils.js.map +1 -1
- package/dist/production/index.cjs +3 -0
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +4 -1
- package/dist/production/index.js.map +1 -1
- package/dist/production/src/ExecutionContainer.cjs +1 -0
- package/dist/production/src/ExecutionContainer.cjs.map +1 -1
- package/dist/production/src/ExecutionContainer.js +1 -0
- package/dist/production/src/ExecutionContainer.js.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs +2 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js +2 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +5 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +5 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs +2 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js +2 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs +4 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +4 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js.map +1 -1
- package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs +24 -3
- package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs.map +1 -1
- package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js +24 -3
- package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map +1 -1
- package/dist/production/src/inputProcessing/UpdateInputVisitor.cjs +52 -2
- package/dist/production/src/inputProcessing/UpdateInputVisitor.cjs.map +1 -1
- package/dist/production/src/inputProcessing/UpdateInputVisitor.js +52 -2
- package/dist/production/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
- package/dist/production/src/mapper/ErrorUtils.cjs +10 -0
- package/dist/production/src/mapper/ErrorUtils.cjs.map +1 -1
- package/dist/production/src/mapper/ErrorUtils.js +10 -0
- package/dist/production/src/mapper/ErrorUtils.js.map +1 -1
- package/dist/production/src/mapper/Mapper.cjs +37 -1
- package/dist/production/src/mapper/Mapper.cjs.map +1 -1
- package/dist/production/src/mapper/Mapper.js +38 -2
- package/dist/production/src/mapper/Mapper.js.map +1 -1
- package/dist/production/src/mapper/MutationProcessorHelper.cjs +12 -0
- package/dist/production/src/mapper/MutationProcessorHelper.cjs.map +1 -1
- package/dist/production/src/mapper/MutationProcessorHelper.js +13 -1
- package/dist/production/src/mapper/MutationProcessorHelper.js.map +1 -1
- package/dist/production/src/mapper/Result.cjs +1 -0
- package/dist/production/src/mapper/Result.cjs.map +1 -1
- package/dist/production/src/mapper/Result.js +1 -0
- package/dist/production/src/mapper/Result.js.map +1 -1
- package/dist/production/src/mapper/delete/DeleteExecutor.cjs +1 -1
- package/dist/production/src/mapper/delete/DeleteExecutor.js +1 -1
- package/dist/production/src/mapper/select/Path.cjs +2 -2
- package/dist/production/src/mapper/select/Path.cjs.map +1 -1
- package/dist/production/src/mapper/select/Path.js +2 -2
- package/dist/production/src/mapper/select/Path.js.map +1 -1
- package/dist/production/src/mapper/select/handlers/MetaHandler.cjs +1 -1
- package/dist/production/src/mapper/select/handlers/MetaHandler.js +1 -1
- package/dist/production/src/mapper/select/optimizer/WhereOptimizer.cjs +2 -2
- package/dist/production/src/mapper/select/optimizer/WhereOptimizer.cjs.map +1 -1
- package/dist/production/src/mapper/select/optimizer/WhereOptimizer.js +1 -1
- package/dist/production/src/mapper/select/optimizer/WhereOptimizer.js.map +1 -1
- package/dist/production/src/mapper/select/optimizer/WhereReplacer.cjs +3 -3
- package/dist/production/src/mapper/select/optimizer/WhereReplacer.cjs.map +1 -1
- package/dist/production/src/mapper/select/optimizer/WhereReplacer.js +1 -1
- package/dist/production/src/mapper/select/optimizer/WhereReplacer.js.map +1 -1
- package/dist/production/src/mapper/update/SqlUpdateInputProcessor.cjs +6 -3
- package/dist/production/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/SqlUpdateInputProcessor.js +7 -4
- package/dist/production/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/update/Updater.cjs +1 -1
- package/dist/production/src/mapper/update/Updater.js +1 -1
- package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs +6 -0
- package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js +6 -0
- package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs +6 -0
- package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js +6 -0
- package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/update/relations/SetManyRelationHelper.cjs +123 -0
- package/dist/production/src/mapper/update/relations/SetManyRelationHelper.cjs.map +1 -0
- package/dist/production/src/mapper/update/relations/SetManyRelationHelper.js +123 -0
- package/dist/production/src/mapper/update/relations/SetManyRelationHelper.js.map +1 -0
- package/dist/production/src/resolvers/MutationResolver.cjs +4 -1
- package/dist/production/src/resolvers/MutationResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/MutationResolver.js +4 -1
- package/dist/production/src/resolvers/MutationResolver.js.map +1 -1
- package/dist/production/src/resolvers/ReadHelpers.cjs +2 -1
- package/dist/production/src/resolvers/ReadHelpers.cjs.map +1 -1
- package/dist/production/src/resolvers/ReadHelpers.js +2 -1
- package/dist/production/src/resolvers/ReadHelpers.js.map +1 -1
- package/dist/production/src/schema/CustomTypesProvider.cjs +35 -14
- package/dist/production/src/schema/CustomTypesProvider.cjs.map +1 -1
- package/dist/production/src/schema/CustomTypesProvider.js +36 -15
- package/dist/production/src/schema/CustomTypesProvider.js.map +1 -1
- package/dist/production/src/schema/EntityTypeProvider.cjs +8 -5
- package/dist/production/src/schema/EntityTypeProvider.cjs.map +1 -1
- package/dist/production/src/schema/EntityTypeProvider.js +8 -5
- package/dist/production/src/schema/EntityTypeProvider.js.map +1 -1
- package/dist/production/src/schema/GraphQlSchemaBuilderFactory.cjs +1 -1
- package/dist/production/src/schema/GraphQlSchemaBuilderFactory.js +1 -1
- package/dist/production/src/schema/MutationProvider.cjs +4 -0
- package/dist/production/src/schema/MutationProvider.cjs.map +1 -1
- package/dist/production/src/schema/MutationProvider.js +4 -0
- package/dist/production/src/schema/MutationProvider.js.map +1 -1
- package/dist/production/src/schema/OrderByTypeProvider.cjs +8 -2
- package/dist/production/src/schema/OrderByTypeProvider.cjs.map +1 -1
- package/dist/production/src/schema/OrderByTypeProvider.js +9 -3
- package/dist/production/src/schema/OrderByTypeProvider.js.map +1 -1
- package/dist/production/src/schema/QueryProvider.cjs +3 -0
- package/dist/production/src/schema/QueryProvider.cjs.map +1 -1
- package/dist/production/src/schema/QueryProvider.js +3 -0
- package/dist/production/src/schema/QueryProvider.js.map +1 -1
- package/dist/production/src/schema/ValidationQueriesProvider.cjs +2 -0
- package/dist/production/src/schema/ValidationQueriesProvider.cjs.map +1 -1
- package/dist/production/src/schema/ValidationQueriesProvider.js +2 -0
- package/dist/production/src/schema/ValidationQueriesProvider.js.map +1 -1
- package/dist/production/src/schema/WhereTypeProvider.cjs +17 -5
- package/dist/production/src/schema/WhereTypeProvider.cjs.map +1 -1
- package/dist/production/src/schema/WhereTypeProvider.js +18 -6
- package/dist/production/src/schema/WhereTypeProvider.js.map +1 -1
- package/dist/production/src/schema/calendarDate.cjs +21 -0
- package/dist/production/src/schema/calendarDate.cjs.map +1 -0
- package/dist/production/src/schema/calendarDate.js +21 -0
- package/dist/production/src/schema/calendarDate.js.map +1 -0
- package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.cjs +11 -3
- package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.cjs.map +1 -1
- package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.js +11 -3
- package/dist/production/src/schema/mutations/CreateEntityInputFieldVisitor.js.map +1 -1
- package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs +11 -3
- package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.cjs.map +1 -1
- package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.js +11 -3
- package/dist/production/src/schema/mutations/UpdateEntityInputFieldVisitor.js.map +1 -1
- package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs +39 -2
- package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.cjs.map +1 -1
- package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js +40 -3
- package/dist/production/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js.map +1 -1
- package/dist/production/src/schema/utils.cjs +10 -0
- package/dist/production/src/schema/utils.cjs.map +1 -1
- package/dist/production/src/schema/utils.js +11 -1
- package/dist/production/src/schema/utils.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/query/acl/internalColumnAliases.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/internalColumnAliases.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/mergedRolePredicate.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/mergedRolePredicate.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/set.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/set.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/set.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/set.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/set.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/set.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/checkViolationError.test.d.ts +2 -0
- package/dist/tests/cases/unit/checkViolationError.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/dateType.test.d.ts +2 -0
- package/dist/tests/cases/unit/dateType.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/internalColumnAliases.test.d.ts +2 -0
- package/dist/tests/cases/unit/internalColumnAliases.test.d.ts.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.d.ts.map +1 -1
- package/dist/types/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.d.ts.map +1 -1
- package/dist/types/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts +6 -0
- package/dist/types/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts.map +1 -1
- package/dist/types/inputProcessing/UpdateInputProcessor.d.ts +7 -0
- package/dist/types/inputProcessing/UpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/inputProcessing/UpdateInputVisitor.d.ts +2 -0
- package/dist/types/inputProcessing/UpdateInputVisitor.d.ts.map +1 -1
- package/dist/types/mapper/ErrorUtils.d.ts.map +1 -1
- package/dist/types/mapper/Mapper.d.ts +5 -0
- package/dist/types/mapper/Mapper.d.ts.map +1 -1
- package/dist/types/mapper/MutationProcessorHelper.d.ts +3 -0
- package/dist/types/mapper/MutationProcessorHelper.d.ts.map +1 -1
- package/dist/types/mapper/Result.d.ts +2 -1
- package/dist/types/mapper/Result.d.ts.map +1 -1
- package/dist/types/mapper/types.d.ts +8 -1
- package/dist/types/mapper/types.d.ts.map +1 -1
- package/dist/types/mapper/update/SqlUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts +5 -0
- package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/update/relations/OneHasManyUpdateInputProcessor.d.ts +5 -0
- package/dist/types/mapper/update/relations/OneHasManyUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/update/relations/SetManyRelationHelper.d.ts +67 -0
- package/dist/types/mapper/update/relations/SetManyRelationHelper.d.ts.map +1 -0
- package/dist/types/resolvers/MutationResolver.d.ts.map +1 -1
- package/dist/types/schema/CustomTypesProvider.d.ts.map +1 -1
- package/dist/types/schema/EntityTypeProvider.d.ts.map +1 -1
- package/dist/types/schema/MutationProvider.d.ts.map +1 -1
- package/dist/types/schema/OrderByTypeProvider.d.ts.map +1 -1
- package/dist/types/schema/QueryProvider.d.ts.map +1 -1
- package/dist/types/schema/ValidationQueriesProvider.d.ts.map +1 -1
- package/dist/types/schema/WhereTypeProvider.d.ts.map +1 -1
- package/dist/types/schema/calendarDate.d.ts +6 -0
- package/dist/types/schema/calendarDate.d.ts.map +1 -0
- package/dist/types/schema/index.d.ts +1 -0
- package/dist/types/schema/index.d.ts.map +1 -1
- package/dist/types/schema/mutations/CreateEntityInputFieldVisitor.d.ts.map +1 -1
- package/dist/types/schema/mutations/UpdateEntityInputFieldVisitor.d.ts +3 -0
- package/dist/types/schema/mutations/UpdateEntityInputFieldVisitor.d.ts.map +1 -1
- package/dist/types/schema/mutations/UpdateEntityRelationInputFieldVisitor.d.ts +1 -0
- package/dist/types/schema/mutations/UpdateEntityRelationInputFieldVisitor.d.ts.map +1 -1
- package/dist/types/schema/utils.d.ts +7 -0
- package/dist/types/schema/utils.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts +3 -0
- package/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.ts +9 -7
- package/src/input-validation/preValidation/UpdateInputPreValidationProcessor.ts +29 -0
- package/src/inputProcessing/UpdateInputProcessor.ts +6 -0
- package/src/inputProcessing/UpdateInputVisitor.ts +64 -2
- package/src/mapper/ErrorUtils.ts +12 -1
- package/src/mapper/Mapper.ts +61 -1
- package/src/mapper/MutationProcessorHelper.ts +14 -0
- package/src/mapper/Result.ts +1 -0
- package/src/mapper/select/Path.ts +2 -2
- package/src/mapper/select/optimizer/WhereOptimizer.ts +1 -1
- package/src/mapper/select/optimizer/WhereReplacer.ts +1 -1
- package/src/mapper/types.ts +16 -1
- package/src/mapper/update/SqlUpdateInputProcessor.ts +4 -1
- package/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.ts +9 -0
- package/src/mapper/update/relations/OneHasManyUpdateInputProcessor.ts +9 -0
- package/src/mapper/update/relations/SetManyRelationHelper.ts +199 -0
- package/src/resolvers/MutationResolver.ts +2 -0
- package/src/schema/CustomTypesProvider.ts +40 -15
- package/src/schema/EntityTypeProvider.ts +8 -4
- package/src/schema/MutationProvider.ts +4 -0
- package/src/schema/OrderByTypeProvider.ts +9 -3
- package/src/schema/QueryProvider.ts +3 -0
- package/src/schema/ValidationQueriesProvider.ts +2 -0
- package/src/schema/WhereTypeProvider.ts +18 -6
- package/src/schema/calendarDate.ts +26 -0
- package/src/schema/index.ts +1 -0
- package/src/schema/mutations/CreateEntityInputFieldVisitor.ts +10 -2
- package/src/schema/mutations/UpdateEntityInputFieldVisitor.ts +10 -2
- package/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.ts +66 -7
- package/src/schema/utils.ts +14 -0
- package/src/tsconfig.json +2 -1
- package/tests/cases/integration/graphQlRequests/query/acl/internalColumnAliases.test.ts +326 -0
- package/tests/cases/integration/graphQlRequests/query/acl/mergedRolePredicate.test.ts +124 -0
- package/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/set.test.ts +219 -0
- package/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/set.test.ts +479 -0
- package/tests/cases/integration/graphQlRequests/update/oneHasMany/set.test.ts +948 -0
- package/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.ts +102 -1
- package/tests/cases/integration/graphQlSchema/schema-acl-allowed.gql +17 -0
- package/tests/cases/integration/graphQlSchema/schema-acl-create-only.gql +1 -0
- package/tests/cases/integration/graphQlSchema/schema-acl-restricted-create.gql +14 -0
- package/tests/cases/integration/graphQlSchema/schema-acl-restricted-delete.gql +11 -0
- package/tests/cases/integration/graphQlSchema/schema-acl-restricted-read.gql +254 -0
- package/tests/cases/integration/graphQlSchema/schema-acl-restricted-update.gql +1 -0
- package/tests/cases/integration/graphQlSchema/schema-acl.gql +1 -0
- package/tests/cases/integration/graphQlSchema/schema-aliased-type.gql +1 -0
- package/tests/cases/integration/graphQlSchema/schema-array.gql +1 -0
- package/tests/cases/integration/graphQlSchema/schema-basic.gql +50 -0
- package/tests/cases/integration/graphQlSchema/schema-bug-66.gql +17 -0
- package/tests/cases/integration/graphQlSchema/schema-column-types.gql +1 -0
- package/tests/cases/integration/graphQlSchema/schema-custom-primary.gql +50 -0
- package/tests/cases/integration/graphQlSchema/schema-deprecation.gql +962 -0
- package/tests/cases/integration/graphQlSchema/schema-description.gql +992 -0
- package/tests/cases/integration/graphQlSchema/schema-has-many-reduction.gql +17 -0
- package/tests/cases/integration/graphQlSchema/schema-mixed-root-through.gql +1 -0
- package/tests/cases/integration/graphQlSchema/schema-new-builder.gql +50 -0
- package/tests/cases/integration/graphQlSchema/schema-no-root-ops.gql +1 -0
- package/tests/cases/unit/checkViolationError.test.ts +49 -0
- package/tests/cases/unit/dateType.test.ts +46 -0
- package/tests/cases/unit/decimalType.test.ts +2 -2
- package/tests/cases/unit/internalColumnAliases.test.ts +41 -0
- package/tests/cases/unit/mutationSqlError.test.ts +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { GraphQLScalarType, Kind } from "graphql";
|
|
1
|
+
import { GraphQLScalarType, Kind, GraphQLError } from "graphql";
|
|
2
2
|
import { UuidType, JSONType } from "@contember/graphql-utils";
|
|
3
|
+
import { isImpossibleCalendarDate } from "./calendarDate.js";
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
6
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -34,15 +35,31 @@ function validateTime(value) {
|
|
|
34
35
|
const fraction = match[4] ? `.${match[4]}` : "";
|
|
35
36
|
return `${hours}:${minutes}:${seconds}${fraction}`;
|
|
36
37
|
}
|
|
38
|
+
function validateCalendarDate(value) {
|
|
39
|
+
if (isImpossibleCalendarDate(value)) {
|
|
40
|
+
throw new TypeError(`Value is not a valid date: ${value}`);
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
function parseInput(parse, node) {
|
|
45
|
+
try {
|
|
46
|
+
return parse();
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (error instanceof TypeError) {
|
|
49
|
+
throw new GraphQLError(error.message, { nodes: node });
|
|
50
|
+
}
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
37
54
|
class CustomTypesProvider {
|
|
38
55
|
constructor() {
|
|
39
56
|
__publicField(this, "uuidType", UuidType);
|
|
40
57
|
__publicField(this, "dateType", new GraphQLScalarType({
|
|
41
58
|
name: "Date",
|
|
42
59
|
serialize: (str) => String(str),
|
|
43
|
-
parseValue: (str) => String(str),
|
|
60
|
+
parseValue: (str) => parseInput(() => validateCalendarDate(String(str))),
|
|
44
61
|
parseLiteral: function parseLiteral(ast) {
|
|
45
|
-
return ast.kind === Kind.STRING ? ast.value : void 0;
|
|
62
|
+
return ast.kind === Kind.STRING ? parseInput(() => validateCalendarDate(ast.value), ast) : void 0;
|
|
46
63
|
}
|
|
47
64
|
}));
|
|
48
65
|
__publicField(this, "timeType", new GraphQLScalarType({
|
|
@@ -51,21 +68,23 @@ class CustomTypesProvider {
|
|
|
51
68
|
return validateTime(value);
|
|
52
69
|
},
|
|
53
70
|
parseValue(value) {
|
|
54
|
-
return validateTime(value);
|
|
71
|
+
return parseInput(() => validateTime(value));
|
|
55
72
|
},
|
|
56
73
|
parseLiteral(ast) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
74
|
+
return parseInput(() => {
|
|
75
|
+
if (ast.kind !== Kind.STRING) {
|
|
76
|
+
throw new TypeError(`Time scalar can only parse string values, got: ${ast.kind}`);
|
|
77
|
+
}
|
|
78
|
+
return validateTime(ast.value);
|
|
79
|
+
}, ast);
|
|
61
80
|
}
|
|
62
81
|
}));
|
|
63
82
|
__publicField(this, "dateTimeType", new GraphQLScalarType({
|
|
64
83
|
name: "DateTime",
|
|
65
84
|
serialize: (str) => String(str),
|
|
66
|
-
parseValue: (str) => String(str),
|
|
85
|
+
parseValue: (str) => parseInput(() => validateCalendarDate(String(str))),
|
|
67
86
|
parseLiteral: function parseLiteral(ast) {
|
|
68
|
-
return ast.kind === Kind.STRING ? ast.value : void 0;
|
|
87
|
+
return ast.kind === Kind.STRING ? parseInput(() => validateCalendarDate(ast.value), ast) : void 0;
|
|
69
88
|
}
|
|
70
89
|
}));
|
|
71
90
|
__publicField(this, "jsonType", JSONType);
|
|
@@ -76,13 +95,15 @@ class CustomTypesProvider {
|
|
|
76
95
|
return validateDecimal(value);
|
|
77
96
|
},
|
|
78
97
|
parseValue(value) {
|
|
79
|
-
return validateDecimal(value);
|
|
98
|
+
return parseInput(() => validateDecimal(value));
|
|
80
99
|
},
|
|
81
100
|
parseLiteral(ast) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
101
|
+
return parseInput(() => {
|
|
102
|
+
if (ast.kind === Kind.STRING || ast.kind === Kind.INT || ast.kind === Kind.FLOAT) {
|
|
103
|
+
return validateDecimal(ast.value);
|
|
104
|
+
}
|
|
105
|
+
throw new TypeError(`Decimal scalar can only parse string or numeric values, got: ${ast.kind}`);
|
|
106
|
+
}, ast);
|
|
86
107
|
}
|
|
87
108
|
}));
|
|
88
109
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomTypesProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/CustomTypesProvider.ts"],"sourcesContent":["import { GraphQLScalarType, Kind } from 'graphql'\nimport { JSONType, UuidType } from '@contember/graphql-utils'\n\nconst TIME_REGEX = /^([01]\\d|2[0-3]):([0-5]\\d)(?::([0-5]\\d)(?:\\.(\\d+))?)?$/\n\nconst DECIMAL_REGEX = /^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][+-]?\\d+)?$/\n\nfunction validateDecimal(value: unknown): string {\n\t// Numeric values are transported as strings to avoid JS float precision loss.\n\t// Plain numbers are accepted for convenience but normalized to a string.\n\tif (typeof value === 'number') {\n\t\tif (!Number.isFinite(value)) {\n\t\t\tthrow new TypeError(`Decimal value must be a finite number, got: ${value}`)\n\t\t}\n\t\treturn String(value)\n\t}\n\tif (typeof value !== 'string') {\n\t\tthrow new TypeError(`Decimal value must be a string, got: ${typeof value}`)\n\t}\n\tif (!DECIMAL_REGEX.test(value.trim())) {\n\t\tthrow new TypeError(`Value is not a valid decimal: ${value}`)\n\t}\n\treturn value.trim()\n}\n\nfunction validateTime(value: unknown): string {\n\tif (typeof value !== 'string') {\n\t\tthrow new TypeError(`Time value must be a string, got: ${typeof value}`)\n\t}\n\tconst match = TIME_REGEX.exec(value)\n\tif (!match) {\n\t\tthrow new TypeError(`Value is not a valid time: ${value}`)\n\t}\n\n\tconst hours = match[1]\n\tconst minutes = match[2]\n\tconst seconds = match[3] || '00'\n\tconst fraction = match[4] ? `.${match[4]}` : ''\n\n\treturn `${hours}:${minutes}:${seconds}${fraction}`\n}\n\nexport class CustomTypesProvider {\n\tpublic readonly uuidType: GraphQLScalarType = UuidType\n\n\t// todo: implement serialize, parseValue and parseLiteral properly\n\n\tpublic readonly dateType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'Date',\n\t\tserialize: str => String(str),\n\t\tparseValue: str => String(str),\n\t\tparseLiteral: function parseLiteral(ast) {\n\t\t\treturn ast.kind === Kind.STRING ? ast.value : undefined\n\t\t},\n\t})\n\n\tpublic readonly timeType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'Time',\n\t\tserialize(value) {\n\t\t\treturn validateTime(value)\n\t\t},\n\t\tparseValue(value) {\n\t\t\treturn validateTime(value)\n\t\t},\n\t\tparseLiteral(ast) {\n\t\t\tif (ast.kind !== Kind.STRING) {\n\t\t\t\tthrow new TypeError(`Time scalar can only parse string values, got: ${ast.kind}`)\n\t\t\t}\n\t\t\treturn validateTime(ast.value)\n\t\t},\n\t})\n\n\tpublic readonly dateTimeType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'DateTime',\n\t\tserialize: str => String(str),\n\t\tparseValue: str => String(str),\n\t\tparseLiteral: function parseLiteral(ast) {\n\t\t\treturn ast.kind === Kind.STRING ? ast.value : undefined\n\t\t},\n\t})\n\tpublic readonly jsonType: GraphQLScalarType = JSONType\n\n\tpublic readonly decimalType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'Decimal',\n\t\tdescription: 'Arbitrary precision decimal number, transported as a string to avoid floating-point precision loss.',\n\t\tserialize(value) {\n\t\t\treturn validateDecimal(value)\n\t\t},\n\t\tparseValue(value) {\n\t\t\treturn validateDecimal(value)\n\t\t},\n\t\tparseLiteral(ast) {\n\t\t\tif (ast.kind === Kind.STRING || ast.kind === Kind.INT || ast.kind === Kind.FLOAT) {\n\t\t\t\treturn validateDecimal(ast.value)\n\t\t\t}\n\t\t\tthrow new TypeError(`Decimal scalar can only parse string or numeric values, got: ${ast.kind}`)\n\t\t},\n\t})\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CustomTypesProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/CustomTypesProvider.ts"],"sourcesContent":["import { GraphQLError, GraphQLScalarType, Kind, ValueNode } from 'graphql'\nimport { JSONType, UuidType } from '@contember/graphql-utils'\nimport { isImpossibleCalendarDate } from './calendarDate.js'\n\nconst TIME_REGEX = /^([01]\\d|2[0-3]):([0-5]\\d)(?::([0-5]\\d)(?:\\.(\\d+))?)?$/\n\nconst DECIMAL_REGEX = /^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][+-]?\\d+)?$/\n\nfunction validateDecimal(value: unknown): string {\n\t// Numeric values are transported as strings to avoid JS float precision loss.\n\t// Plain numbers are accepted for convenience but normalized to a string.\n\tif (typeof value === 'number') {\n\t\tif (!Number.isFinite(value)) {\n\t\t\tthrow new TypeError(`Decimal value must be a finite number, got: ${value}`)\n\t\t}\n\t\treturn String(value)\n\t}\n\tif (typeof value !== 'string') {\n\t\tthrow new TypeError(`Decimal value must be a string, got: ${typeof value}`)\n\t}\n\tif (!DECIMAL_REGEX.test(value.trim())) {\n\t\tthrow new TypeError(`Value is not a valid decimal: ${value}`)\n\t}\n\treturn value.trim()\n}\n\nfunction validateTime(value: unknown): string {\n\tif (typeof value !== 'string') {\n\t\tthrow new TypeError(`Time value must be a string, got: ${typeof value}`)\n\t}\n\tconst match = TIME_REGEX.exec(value)\n\tif (!match) {\n\t\tthrow new TypeError(`Value is not a valid time: ${value}`)\n\t}\n\n\tconst hours = match[1]\n\tconst minutes = match[2]\n\tconst seconds = match[3] || '00'\n\tconst fraction = match[4] ? `.${match[4]}` : ''\n\n\treturn `${hours}:${minutes}:${seconds}${fraction}`\n}\n\nfunction validateCalendarDate(value: string): string {\n\tif (isImpossibleCalendarDate(value)) {\n\t\tthrow new TypeError(`Value is not a valid date: ${value}`)\n\t}\n\treturn value\n}\n\n// graphql-js passes a GraphQLError thrown while parsing input through as is, and engine-http reports it as a client error.\n// Any other error becomes the originalError of a wrapping GraphQLError, which engine-http unwraps and reports as internal.\nfunction parseInput<T>(parse: () => T, node?: ValueNode): T {\n\ttry {\n\t\treturn parse()\n\t} catch (error) {\n\t\tif (error instanceof TypeError) {\n\t\t\tthrow new GraphQLError(error.message, { nodes: node })\n\t\t}\n\t\tthrow error\n\t}\n}\n\nexport class CustomTypesProvider {\n\tpublic readonly uuidType: GraphQLScalarType = UuidType\n\n\t// todo: implement serialize, parseValue and parseLiteral properly\n\n\tpublic readonly dateType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'Date',\n\t\tserialize: str => String(str),\n\t\tparseValue: str => parseInput(() => validateCalendarDate(String(str))),\n\t\tparseLiteral: function parseLiteral(ast) {\n\t\t\treturn ast.kind === Kind.STRING ? parseInput(() => validateCalendarDate(ast.value), ast) : undefined\n\t\t},\n\t})\n\n\tpublic readonly timeType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'Time',\n\t\tserialize(value) {\n\t\t\treturn validateTime(value)\n\t\t},\n\t\tparseValue(value) {\n\t\t\treturn parseInput(() => validateTime(value))\n\t\t},\n\t\tparseLiteral(ast) {\n\t\t\treturn parseInput(() => {\n\t\t\t\tif (ast.kind !== Kind.STRING) {\n\t\t\t\t\tthrow new TypeError(`Time scalar can only parse string values, got: ${ast.kind}`)\n\t\t\t\t}\n\t\t\t\treturn validateTime(ast.value)\n\t\t\t}, ast)\n\t\t},\n\t})\n\n\tpublic readonly dateTimeType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'DateTime',\n\t\tserialize: str => String(str),\n\t\tparseValue: str => parseInput(() => validateCalendarDate(String(str))),\n\t\tparseLiteral: function parseLiteral(ast) {\n\t\t\treturn ast.kind === Kind.STRING ? parseInput(() => validateCalendarDate(ast.value), ast) : undefined\n\t\t},\n\t})\n\tpublic readonly jsonType: GraphQLScalarType = JSONType\n\n\tpublic readonly decimalType: GraphQLScalarType = new GraphQLScalarType({\n\t\tname: 'Decimal',\n\t\tdescription: 'Arbitrary precision decimal number, transported as a string to avoid floating-point precision loss.',\n\t\tserialize(value) {\n\t\t\treturn validateDecimal(value)\n\t\t},\n\t\tparseValue(value) {\n\t\t\treturn parseInput(() => validateDecimal(value))\n\t\t},\n\t\tparseLiteral(ast) {\n\t\t\treturn parseInput(() => {\n\t\t\t\tif (ast.kind === Kind.STRING || ast.kind === Kind.INT || ast.kind === Kind.FLOAT) {\n\t\t\t\t\treturn validateDecimal(ast.value)\n\t\t\t\t}\n\t\t\t\tthrow new TypeError(`Decimal scalar can only parse string or numeric values, got: ${ast.kind}`)\n\t\t\t}, ast)\n\t\t},\n\t})\n}\n"],"names":[],"mappings":";;;;;;AAIA,MAAM,aAAa;AAEnB,MAAM,gBAAgB;AAEtB,SAAS,gBAAgB,OAAwB;AAGhD,MAAI,OAAO,UAAU,UAAU;AAC9B,QAAI,CAAC,OAAO,SAAS,KAAK,GAAG;AAC5B,YAAM,IAAI,UAAU,+CAA+C,KAAK,EAAE;AAAA,IAC3E;AACA,WAAO,OAAO,KAAK;AAAA,EACpB;AACA,MAAI,OAAO,UAAU,UAAU;AAC9B,UAAM,IAAI,UAAU,wCAAwC,OAAO,KAAK,EAAE;AAAA,EAC3E;AACA,MAAI,CAAC,cAAc,KAAK,MAAM,KAAA,CAAM,GAAG;AACtC,UAAM,IAAI,UAAU,iCAAiC,KAAK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AM,IAAI,UAAU,gEAAgE,IAAI,IAAI,EAAE;AAAA,QAC/F,GAAG,GAAG;AAAA,MACP;AAAA,IAAA,CACA,CAAA;AAAA,EAAA;AACF;"}
|
|
@@ -53,13 +53,14 @@ class EntityTypeProvider {
|
|
|
53
53
|
return this.connections(entityName);
|
|
54
54
|
}
|
|
55
55
|
createEntity(entityName) {
|
|
56
|
+
const entity = schemaUtils.getEntity(this.schema, entityName);
|
|
56
57
|
return new graphql.GraphQLObjectType({
|
|
57
58
|
name: utils.GqlTypeName`${entityName}`,
|
|
58
|
-
|
|
59
|
+
description: entity.description,
|
|
60
|
+
fields: () => this.getEntityFields(entity)
|
|
59
61
|
});
|
|
60
62
|
}
|
|
61
|
-
getEntityFields(
|
|
62
|
-
const entity = schemaUtils.getEntity(this.schema, entityName);
|
|
63
|
+
getEntityFields(entity) {
|
|
63
64
|
const accessVisitor = new FieldAccessVisitor.FieldAccessVisitor(schema.Acl.Operation.read, this.authorizator);
|
|
64
65
|
const accessibleFields = Object.values(entity.fields).filter((field) => schemaUtils.acceptFieldVisitor(this.schema, entity, field.name, accessVisitor));
|
|
65
66
|
const metaFields = {};
|
|
@@ -71,7 +72,7 @@ class EntityTypeProvider {
|
|
|
71
72
|
}
|
|
72
73
|
const metaField = {
|
|
73
74
|
type: new graphql.GraphQLObjectType({
|
|
74
|
-
name: utils.GqlTypeName`${
|
|
75
|
+
name: utils.GqlTypeName`${entity.name}Meta`,
|
|
75
76
|
fields: metaFields
|
|
76
77
|
}),
|
|
77
78
|
resolve: utils.aliasAwareResolver
|
|
@@ -86,7 +87,9 @@ class EntityTypeProvider {
|
|
|
86
87
|
fields[field.name] = {
|
|
87
88
|
type,
|
|
88
89
|
args: schemaUtils.acceptFieldVisitor(this.schema, entity, field.name, fieldArgsVisitor),
|
|
89
|
-
resolve: utils.aliasAwareResolver
|
|
90
|
+
resolve: utils.aliasAwareResolver,
|
|
91
|
+
deprecationReason: field.deprecationReason,
|
|
92
|
+
description: field.description
|
|
90
93
|
};
|
|
91
94
|
}
|
|
92
95
|
for (const [key, provider] of Object.entries(this.entityFieldProviders)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityTypeProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/EntityTypeProvider.ts"],"sourcesContent":["import {\n\tGraphQLBoolean,\n\tGraphQLFieldConfig,\n\tGraphQLInt,\n\tGraphQLList,\n\tGraphQLNonNull,\n\tGraphQLObjectType,\n\tGraphQLObjectTypeConfig,\n\tGraphQLOutputType,\n} from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { acceptFieldVisitor, getEntity as getEntityFromSchema } from '@contember/schema-utils'\nimport { singletonFactory } from '../utils/index.js'\nimport { ColumnTypeResolver } from './ColumnTypeResolver.js'\nimport { FieldArgsVisitor, FieldTypeVisitor } from './entities/index.js'\nimport { aliasAwareResolver, GqlTypeName } from './utils.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\nimport { OrderByTypeProvider } from './OrderByTypeProvider.js'\nimport { EntityFieldsProvider } from '../extensions/index.js'\nimport { ImplementationException } from '../exception.js'\n\nexport class EntityTypeProvider {\n\tprivate entities = singletonFactory(name => this.createEntity(name))\n\tprivate connections = singletonFactory(name => this.createConnection(name))\n\tprivate PageInfo = new GraphQLObjectType({\n\t\tname: 'PageInfo',\n\t\tfields: {\n\t\t\ttotalCount: { type: new GraphQLNonNull(GraphQLInt) },\n\t\t},\n\t})\n\n\tprivate fieldMeta = new GraphQLObjectType({\n\t\tname: 'FieldMeta',\n\t\tfields: {\n\t\t\t[Input.FieldMeta.readable]: { type: GraphQLBoolean, resolve: aliasAwareResolver },\n\t\t\t[Input.FieldMeta.updatable]: { type: GraphQLBoolean, resolve: aliasAwareResolver },\n\t\t},\n\t})\n\tprivate readonly entityFieldProviders: { [key: string]: EntityFieldsProvider } = {}\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly orderByTypeProvider: OrderByTypeProvider,\n\t) {\n\t}\n\n\tpublic registerEntityFieldProvider(key: string, provider: EntityFieldsProvider): void {\n\t\tthis.entityFieldProviders[key] = provider\n\t}\n\n\tpublic getEntity(entityName: string): GraphQLObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.entities(entityName)\n\t}\n\n\tpublic getConnection(entityName: string): GraphQLObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.connections(entityName)\n\t}\n\n\tprivate createEntity(entityName: string) {\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}`,\n\t\t\tfields: () => this.getEntityFields(
|
|
1
|
+
{"version":3,"file":"EntityTypeProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/EntityTypeProvider.ts"],"sourcesContent":["import {\n\tGraphQLBoolean,\n\tGraphQLFieldConfig,\n\tGraphQLInt,\n\tGraphQLList,\n\tGraphQLNonNull,\n\tGraphQLObjectType,\n\tGraphQLObjectTypeConfig,\n\tGraphQLOutputType,\n} from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { acceptFieldVisitor, getEntity as getEntityFromSchema } from '@contember/schema-utils'\nimport { singletonFactory } from '../utils/index.js'\nimport { ColumnTypeResolver } from './ColumnTypeResolver.js'\nimport { FieldArgsVisitor, FieldTypeVisitor } from './entities/index.js'\nimport { aliasAwareResolver, GqlTypeName } from './utils.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\nimport { OrderByTypeProvider } from './OrderByTypeProvider.js'\nimport { EntityFieldsProvider } from '../extensions/index.js'\nimport { ImplementationException } from '../exception.js'\n\nexport class EntityTypeProvider {\n\tprivate entities = singletonFactory(name => this.createEntity(name))\n\tprivate connections = singletonFactory(name => this.createConnection(name))\n\tprivate PageInfo = new GraphQLObjectType({\n\t\tname: 'PageInfo',\n\t\tfields: {\n\t\t\ttotalCount: { type: new GraphQLNonNull(GraphQLInt) },\n\t\t},\n\t})\n\n\tprivate fieldMeta = new GraphQLObjectType({\n\t\tname: 'FieldMeta',\n\t\tfields: {\n\t\t\t[Input.FieldMeta.readable]: { type: GraphQLBoolean, resolve: aliasAwareResolver },\n\t\t\t[Input.FieldMeta.updatable]: { type: GraphQLBoolean, resolve: aliasAwareResolver },\n\t\t},\n\t})\n\tprivate readonly entityFieldProviders: { [key: string]: EntityFieldsProvider } = {}\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly orderByTypeProvider: OrderByTypeProvider,\n\t) {\n\t}\n\n\tpublic registerEntityFieldProvider(key: string, provider: EntityFieldsProvider): void {\n\t\tthis.entityFieldProviders[key] = provider\n\t}\n\n\tpublic getEntity(entityName: string): GraphQLObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.entities(entityName)\n\t}\n\n\tpublic getConnection(entityName: string): GraphQLObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.connections(entityName)\n\t}\n\n\tprivate createEntity(entityName: string) {\n\t\tconst entity = getEntityFromSchema(this.schema, entityName)\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}`,\n\t\t\tdescription: entity.description,\n\t\t\tfields: () => this.getEntityFields(entity),\n\t\t} as GraphQLObjectTypeConfig<any, any>)\n\t}\n\n\tprivate getEntityFields(entity: Model.Entity) {\n\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\tconst accessibleFields = Object.values(entity.fields).filter(field => acceptFieldVisitor(this.schema, entity, field.name, accessVisitor))\n\t\tconst metaFields: { [field: string]: GraphQLFieldConfig<any, any> } = {}\n\t\tfor (const field of accessibleFields) {\n\t\t\tmetaFields[field.name] = {\n\t\t\t\ttype: this.fieldMeta,\n\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t}\n\t\t}\n\n\t\tconst metaField = {\n\t\t\ttype: new GraphQLObjectType({\n\t\t\t\tname: GqlTypeName`${entity.name}Meta`,\n\t\t\t\tfields: metaFields,\n\t\t\t}),\n\t\t\tresolve: aliasAwareResolver,\n\t\t}\n\n\t\tlet fields: { [field: string]: GraphQLFieldConfig<any, any> } = {\n\t\t\t_meta: metaField,\n\t\t}\n\n\t\tfor (const field of accessibleFields) {\n\t\t\tconst fieldTypeVisitor = new FieldTypeVisitor(this.columnTypeResolver, this, this.authorizator, this.rootAuthorizator)\n\t\t\tconst type: GraphQLOutputType = acceptFieldVisitor(this.schema, entity, field.name, fieldTypeVisitor)\n\n\t\t\tconst fieldArgsVisitor = new FieldArgsVisitor(this.whereTypeProvider, this.orderByTypeProvider)\n\t\t\tfields[field.name] = {\n\t\t\t\ttype,\n\t\t\t\targs: acceptFieldVisitor(this.schema, entity, field.name, fieldArgsVisitor),\n\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t\tdeprecationReason: field.deprecationReason,\n\t\t\t\tdescription: field.description,\n\t\t\t}\n\t\t}\n\n\t\tfor (const [key, provider] of Object.entries(this.entityFieldProviders)) {\n\t\t\tfields = {\n\t\t\t\t...fields,\n\t\t\t\t...provider.getFields(entity, accessibleFields),\n\t\t\t}\n\t\t}\n\n\t\treturn fields\n\t}\n\n\tprivate createConnection(entityName: string) {\n\t\tconst entityType = this.getEntity(entityName)\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}Connection`,\n\t\t\tfields: {\n\t\t\t\tpageInfo: {\n\t\t\t\t\ttype: new GraphQLNonNull(this.PageInfo),\n\t\t\t\t},\n\t\t\t\tedges: {\n\t\t\t\t\ttype: new GraphQLNonNull(\n\t\t\t\t\t\tnew GraphQLList(\n\t\t\t\t\t\t\tnew GraphQLNonNull(\n\t\t\t\t\t\t\t\tnew GraphQLObjectType({\n\t\t\t\t\t\t\t\t\tname: GqlTypeName`${entityName}Edge`,\n\t\t\t\t\t\t\t\t\tfields: {\n\t\t\t\t\t\t\t\t\t\tnode: {\n\t\t\t\t\t\t\t\t\t\t\ttype: new GraphQLNonNull(entityType),\n\t\t\t\t\t\t\t\t\t\t\t// resolve: aliasAwareResolver,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t\t// resolve: aliasAwareResolver,\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t}\n}\n"],"names":["schema","singletonFactory","GraphQLObjectType","GraphQLNonNull","GraphQLInt","Input","GraphQLBoolean","aliasAwareResolver","Acl","ImplementationException","getEntityFromSchema","GqlTypeName","FieldAccessVisitor","acceptFieldVisitor","FieldTypeVisitor","FieldArgsVisitor","GraphQLList"],"mappings":";;;;;;;;;;;;;;AAuBO,MAAM,mBAAmB;AAAA,EAmB/B,YACkBA,UACA,cACA,kBACA,oBACA,mBACA,qBAChB;AANgB,SAAA,SAAAA;AACA,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,qBAAA;AACA,SAAA,oBAAA;AACA,SAAA,sBAAA;AAxBlB,kBAAA,MAAQ,Y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,MAAM;AAAA,MAAA;AAAA,IAErB;AAEA,eAAW,CAAC,KAAK,QAAQ,KAAK,OAAO,QAAQ,KAAK,oBAAoB,GAAG;AACxE,eAAS;AAAA,QACR,GAAG;AAAA,QACH,GAAG,SAAS,UAAU,QAAQ,gBAAgB;AAAA,MAAA;AAAA,IAEhD;AAEA,WAAO;AAAA,EACR;AAAA,EAEQ,iBAAiB,YAAoB;AAC5C,UAAM,aAAa,KAAK,UAAU,UAAU;AAC5C,WAAO,IAAIL,QAAAA,kBAAkB;AAAA,MAC5B,MAAMS,MAAAA,cAAc,UAAU;AAAA,MAC9B,QAAQ;AAAA,QACP,UAAU;AAAA,UACT,MAAM,IAAIR,uBAAe,KAAK,QAAQ;AAAA,QAAA;AAAA,QAEvC,OAAO;AAAA,UACN,MAAM,IAAIA,QAAAA;AAAAA,YACT,IAAIa,QAAAA;AAAAA,cACH,IAAIb,QAAAA;AAAAA,gBACH,IAAID,0BAAkB;AAAA,kBACrB,MAAMS,MAAAA,cAAc,UAAU;AAAA,kBAC9B,QAAQ;AAAA,oBACP,MAAM;AAAA,sBACL,MAAM,IAAIR,QAAAA,eAAe,UAAU;AAAA;AAAA,oBAAA;AAAA,kBAEpC;AAAA,gBACD,CACA;AAAA,cAAA;AAAA,YACF;AAAA,UACD;AAAA;AAAA,QACD;AAAA,MAED;AAAA,IACD,CACA;AAAA,EACF;AACD;;"}
|
|
@@ -51,13 +51,14 @@ class EntityTypeProvider {
|
|
|
51
51
|
return this.connections(entityName);
|
|
52
52
|
}
|
|
53
53
|
createEntity(entityName) {
|
|
54
|
+
const entity = getEntity(this.schema, entityName);
|
|
54
55
|
return new GraphQLObjectType({
|
|
55
56
|
name: GqlTypeName`${entityName}`,
|
|
56
|
-
|
|
57
|
+
description: entity.description,
|
|
58
|
+
fields: () => this.getEntityFields(entity)
|
|
57
59
|
});
|
|
58
60
|
}
|
|
59
|
-
getEntityFields(
|
|
60
|
-
const entity = getEntity(this.schema, entityName);
|
|
61
|
+
getEntityFields(entity) {
|
|
61
62
|
const accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator);
|
|
62
63
|
const accessibleFields = Object.values(entity.fields).filter((field) => acceptFieldVisitor(this.schema, entity, field.name, accessVisitor));
|
|
63
64
|
const metaFields = {};
|
|
@@ -69,7 +70,7 @@ class EntityTypeProvider {
|
|
|
69
70
|
}
|
|
70
71
|
const metaField = {
|
|
71
72
|
type: new GraphQLObjectType({
|
|
72
|
-
name: GqlTypeName`${
|
|
73
|
+
name: GqlTypeName`${entity.name}Meta`,
|
|
73
74
|
fields: metaFields
|
|
74
75
|
}),
|
|
75
76
|
resolve: aliasAwareResolver
|
|
@@ -84,7 +85,9 @@ class EntityTypeProvider {
|
|
|
84
85
|
fields[field.name] = {
|
|
85
86
|
type,
|
|
86
87
|
args: acceptFieldVisitor(this.schema, entity, field.name, fieldArgsVisitor),
|
|
87
|
-
resolve: aliasAwareResolver
|
|
88
|
+
resolve: aliasAwareResolver,
|
|
89
|
+
deprecationReason: field.deprecationReason,
|
|
90
|
+
description: field.description
|
|
88
91
|
};
|
|
89
92
|
}
|
|
90
93
|
for (const [key, provider] of Object.entries(this.entityFieldProviders)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityTypeProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/EntityTypeProvider.ts"],"sourcesContent":["import {\n\tGraphQLBoolean,\n\tGraphQLFieldConfig,\n\tGraphQLInt,\n\tGraphQLList,\n\tGraphQLNonNull,\n\tGraphQLObjectType,\n\tGraphQLObjectTypeConfig,\n\tGraphQLOutputType,\n} from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { acceptFieldVisitor, getEntity as getEntityFromSchema } from '@contember/schema-utils'\nimport { singletonFactory } from '../utils/index.js'\nimport { ColumnTypeResolver } from './ColumnTypeResolver.js'\nimport { FieldArgsVisitor, FieldTypeVisitor } from './entities/index.js'\nimport { aliasAwareResolver, GqlTypeName } from './utils.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\nimport { OrderByTypeProvider } from './OrderByTypeProvider.js'\nimport { EntityFieldsProvider } from '../extensions/index.js'\nimport { ImplementationException } from '../exception.js'\n\nexport class EntityTypeProvider {\n\tprivate entities = singletonFactory(name => this.createEntity(name))\n\tprivate connections = singletonFactory(name => this.createConnection(name))\n\tprivate PageInfo = new GraphQLObjectType({\n\t\tname: 'PageInfo',\n\t\tfields: {\n\t\t\ttotalCount: { type: new GraphQLNonNull(GraphQLInt) },\n\t\t},\n\t})\n\n\tprivate fieldMeta = new GraphQLObjectType({\n\t\tname: 'FieldMeta',\n\t\tfields: {\n\t\t\t[Input.FieldMeta.readable]: { type: GraphQLBoolean, resolve: aliasAwareResolver },\n\t\t\t[Input.FieldMeta.updatable]: { type: GraphQLBoolean, resolve: aliasAwareResolver },\n\t\t},\n\t})\n\tprivate readonly entityFieldProviders: { [key: string]: EntityFieldsProvider } = {}\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly orderByTypeProvider: OrderByTypeProvider,\n\t) {\n\t}\n\n\tpublic registerEntityFieldProvider(key: string, provider: EntityFieldsProvider): void {\n\t\tthis.entityFieldProviders[key] = provider\n\t}\n\n\tpublic getEntity(entityName: string): GraphQLObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.entities(entityName)\n\t}\n\n\tpublic getConnection(entityName: string): GraphQLObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.connections(entityName)\n\t}\n\n\tprivate createEntity(entityName: string) {\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}`,\n\t\t\tfields: () => this.getEntityFields(
|
|
1
|
+
{"version":3,"file":"EntityTypeProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/EntityTypeProvider.ts"],"sourcesContent":["import {\n\tGraphQLBoolean,\n\tGraphQLFieldConfig,\n\tGraphQLInt,\n\tGraphQLList,\n\tGraphQLNonNull,\n\tGraphQLObjectType,\n\tGraphQLObjectTypeConfig,\n\tGraphQLOutputType,\n} from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { acceptFieldVisitor, getEntity as getEntityFromSchema } from '@contember/schema-utils'\nimport { singletonFactory } from '../utils/index.js'\nimport { ColumnTypeResolver } from './ColumnTypeResolver.js'\nimport { FieldArgsVisitor, FieldTypeVisitor } from './entities/index.js'\nimport { aliasAwareResolver, GqlTypeName } from './utils.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\nimport { OrderByTypeProvider } from './OrderByTypeProvider.js'\nimport { EntityFieldsProvider } from '../extensions/index.js'\nimport { ImplementationException } from '../exception.js'\n\nexport class EntityTypeProvider {\n\tprivate entities = singletonFactory(name => this.createEntity(name))\n\tprivate connections = singletonFactory(name => this.createConnection(name))\n\tprivate PageInfo = new GraphQLObjectType({\n\t\tname: 'PageInfo',\n\t\tfields: {\n\t\t\ttotalCount: { type: new GraphQLNonNull(GraphQLInt) },\n\t\t},\n\t})\n\n\tprivate fieldMeta = new GraphQLObjectType({\n\t\tname: 'FieldMeta',\n\t\tfields: {\n\t\t\t[Input.FieldMeta.readable]: { type: GraphQLBoolean, resolve: aliasAwareResolver },\n\t\t\t[Input.FieldMeta.updatable]: { type: GraphQLBoolean, resolve: aliasAwareResolver },\n\t\t},\n\t})\n\tprivate readonly entityFieldProviders: { [key: string]: EntityFieldsProvider } = {}\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly orderByTypeProvider: OrderByTypeProvider,\n\t) {\n\t}\n\n\tpublic registerEntityFieldProvider(key: string, provider: EntityFieldsProvider): void {\n\t\tthis.entityFieldProviders[key] = provider\n\t}\n\n\tpublic getEntity(entityName: string): GraphQLObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.entities(entityName)\n\t}\n\n\tpublic getConnection(entityName: string): GraphQLObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.connections(entityName)\n\t}\n\n\tprivate createEntity(entityName: string) {\n\t\tconst entity = getEntityFromSchema(this.schema, entityName)\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}`,\n\t\t\tdescription: entity.description,\n\t\t\tfields: () => this.getEntityFields(entity),\n\t\t} as GraphQLObjectTypeConfig<any, any>)\n\t}\n\n\tprivate getEntityFields(entity: Model.Entity) {\n\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\tconst accessibleFields = Object.values(entity.fields).filter(field => acceptFieldVisitor(this.schema, entity, field.name, accessVisitor))\n\t\tconst metaFields: { [field: string]: GraphQLFieldConfig<any, any> } = {}\n\t\tfor (const field of accessibleFields) {\n\t\t\tmetaFields[field.name] = {\n\t\t\t\ttype: this.fieldMeta,\n\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t}\n\t\t}\n\n\t\tconst metaField = {\n\t\t\ttype: new GraphQLObjectType({\n\t\t\t\tname: GqlTypeName`${entity.name}Meta`,\n\t\t\t\tfields: metaFields,\n\t\t\t}),\n\t\t\tresolve: aliasAwareResolver,\n\t\t}\n\n\t\tlet fields: { [field: string]: GraphQLFieldConfig<any, any> } = {\n\t\t\t_meta: metaField,\n\t\t}\n\n\t\tfor (const field of accessibleFields) {\n\t\t\tconst fieldTypeVisitor = new FieldTypeVisitor(this.columnTypeResolver, this, this.authorizator, this.rootAuthorizator)\n\t\t\tconst type: GraphQLOutputType = acceptFieldVisitor(this.schema, entity, field.name, fieldTypeVisitor)\n\n\t\t\tconst fieldArgsVisitor = new FieldArgsVisitor(this.whereTypeProvider, this.orderByTypeProvider)\n\t\t\tfields[field.name] = {\n\t\t\t\ttype,\n\t\t\t\targs: acceptFieldVisitor(this.schema, entity, field.name, fieldArgsVisitor),\n\t\t\t\tresolve: aliasAwareResolver,\n\t\t\t\tdeprecationReason: field.deprecationReason,\n\t\t\t\tdescription: field.description,\n\t\t\t}\n\t\t}\n\n\t\tfor (const [key, provider] of Object.entries(this.entityFieldProviders)) {\n\t\t\tfields = {\n\t\t\t\t...fields,\n\t\t\t\t...provider.getFields(entity, accessibleFields),\n\t\t\t}\n\t\t}\n\n\t\treturn fields\n\t}\n\n\tprivate createConnection(entityName: string) {\n\t\tconst entityType = this.getEntity(entityName)\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}Connection`,\n\t\t\tfields: {\n\t\t\t\tpageInfo: {\n\t\t\t\t\ttype: new GraphQLNonNull(this.PageInfo),\n\t\t\t\t},\n\t\t\t\tedges: {\n\t\t\t\t\ttype: new GraphQLNonNull(\n\t\t\t\t\t\tnew GraphQLList(\n\t\t\t\t\t\t\tnew GraphQLNonNull(\n\t\t\t\t\t\t\t\tnew GraphQLObjectType({\n\t\t\t\t\t\t\t\t\tname: GqlTypeName`${entityName}Edge`,\n\t\t\t\t\t\t\t\t\tfields: {\n\t\t\t\t\t\t\t\t\t\tnode: {\n\t\t\t\t\t\t\t\t\t\t\ttype: new GraphQLNonNull(entityType),\n\t\t\t\t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KAAK,QAAQ,QAAQ,MAAM,MAAM,gBAAgB;AAEpG,YAAM,mBAAmB,IAAI,iBAAiB,KAAK,mBAAmB,KAAK,mBAAmB;AAC9F,aAAO,MAAM,IAAI,IAAI;AAAA,QACpB;AAAA,QACA,MAAM,mBAAmB,KAAK,QAAQ,QAAQ,MAAM,MAAM,gBAAgB;AAAA,QAC1E,SAAS;AAAA,QACT,mBAAmB,MAAM;AAAA,QACzB,aAAa,MAAM;AAAA,MAAA;AAAA,IAErB;AAEA,eAAW,CAAC,KAAK,QAAQ,KAAK,OAAO,QAAQ,KAAK,oBAAoB,GAAG;AACxE,eAAS;AAAA,QACR,GAAG;AAAA,QACH,GAAG,SAAS,UAAU,QAAQ,gBAAgB;AAAA,MAAA;AAAA,IAEhD;AAEA,WAAO;AAAA,EACR;AAAA,EAEQ,iBAAiB,YAAoB;AAC5C,UAAM,aAAa,KAAK,UAAU,UAAU;AAC5C,WAAO,IAAI,kBAAkB;AAAA,MAC5B,MAAM,cAAc,UAAU;AAAA,MAC9B,QAAQ;AAAA,QACP,UAAU;AAAA,UACT,MAAM,IAAI,eAAe,KAAK,QAAQ;AAAA,QAAA;AAAA,QAEvC,OAAO;AAAA,UACN,MAAM,IAAI;AAAA,YACT,IAAI;AAAA,cACH,IAAI;AAAA,gBACH,IAAI,kBAAkB;AAAA,kBACrB,MAAM,cAAc,UAAU;AAAA,kBAC9B,QAAQ;AAAA,oBACP,MAAM;AAAA,sBACL,MAAM,IAAI,eAAe,UAAU;AAAA;AAAA,oBAAA;AAAA,kBAEpC;AAAA,gBACD,CACA;AAAA,cAAA;AAAA,YACF;AAAA,UACD;AAAA;AAAA,QACD;AAAA,MAED;AAAA,IACD,CACA;AAAA,EACF;AACD;"}
|
|
@@ -23,7 +23,7 @@ const OrderByTypeProvider = require("./OrderByTypeProvider.cjs");
|
|
|
23
23
|
const HasManyToHasOneReducer = require("../extensions/hasManyToHasOneReducer/HasManyToHasOneReducer.cjs");
|
|
24
24
|
require("@contember/schema");
|
|
25
25
|
require("@contember/database");
|
|
26
|
-
require("
|
|
26
|
+
require("@contember/utilities");
|
|
27
27
|
require("../acl/PredicatesInjector.cjs");
|
|
28
28
|
require("node:crypto");
|
|
29
29
|
require("../mapper/select/Path.cjs");
|
|
@@ -21,7 +21,7 @@ import { OrderByTypeProvider } from "./OrderByTypeProvider.js";
|
|
|
21
21
|
import { HasManyToHasOneReducer } from "../extensions/hasManyToHasOneReducer/HasManyToHasOneReducer.js";
|
|
22
22
|
import "@contember/schema";
|
|
23
23
|
import "@contember/database";
|
|
24
|
-
import "
|
|
24
|
+
import "@contember/utilities";
|
|
25
25
|
import "../acl/PredicatesInjector.js";
|
|
26
26
|
import "node:crypto";
|
|
27
27
|
import "../mapper/select/Path.js";
|
|
@@ -44,6 +44,7 @@ class MutationProvider {
|
|
|
44
44
|
const resultType = this.createResultType(entityName, "create");
|
|
45
45
|
return {
|
|
46
46
|
type: new graphql.GraphQLNonNull(resultType),
|
|
47
|
+
deprecationReason: entity.deprecationReason,
|
|
47
48
|
args: {
|
|
48
49
|
data: { type: new graphql.GraphQLNonNull(dataType) }
|
|
49
50
|
},
|
|
@@ -72,6 +73,7 @@ class MutationProvider {
|
|
|
72
73
|
}
|
|
73
74
|
return {
|
|
74
75
|
type: new graphql.GraphQLNonNull(this.createResultType(entityName, "delete")),
|
|
76
|
+
deprecationReason: entity.deprecationReason,
|
|
75
77
|
args: {
|
|
76
78
|
by: {
|
|
77
79
|
type: new graphql.GraphQLNonNull(uniqueWhere)
|
|
@@ -107,6 +109,7 @@ class MutationProvider {
|
|
|
107
109
|
}
|
|
108
110
|
return {
|
|
109
111
|
type: new graphql.GraphQLNonNull(resultType),
|
|
112
|
+
deprecationReason: entity.deprecationReason,
|
|
110
113
|
args: {
|
|
111
114
|
by: {
|
|
112
115
|
type: new graphql.GraphQLNonNull(uniqueWhere)
|
|
@@ -147,6 +150,7 @@ class MutationProvider {
|
|
|
147
150
|
}
|
|
148
151
|
return {
|
|
149
152
|
type: new graphql.GraphQLNonNull(resultType),
|
|
153
|
+
deprecationReason: entity.deprecationReason,
|
|
150
154
|
args: {
|
|
151
155
|
by: {
|
|
152
156
|
type: new graphql.GraphQLNonNull(uniqueWhere)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutationProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/MutationProvider.ts"],"sourcesContent":["import { GraphQLBoolean, GraphQLFieldConfig, GraphQLNonNull, GraphQLObjectType, GraphQLObjectTypeConfig, GraphQLString } from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { Context } from '../types.js'\nimport { EntityTypeProvider } from './EntityTypeProvider.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { EntityInputProvider, EntityInputType } from './mutations/index.js'\nimport { filterObject } from '../utils/index.js'\nimport { aliasAwareResolver, GqlTypeName } from './utils.js'\nimport { ResultSchemaTypeProvider } from './ResultSchemaTypeProvider.js'\nimport { ExtensionKey, Operation, OperationMeta } from './OperationExtension.js'\n\ntype FieldConfig<TArgs> = GraphQLFieldConfig<any, Context, TArgs>\n\nexport class MutationProvider {\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly createEntityInputProvider: EntityInputProvider<EntityInputType.create>,\n\t\tprivate readonly updateEntityInputProvider: EntityInputProvider<EntityInputType.update>,\n\t\tprivate readonly resultSchemaTypeProvider: ResultSchemaTypeProvider,\n\t) {}\n\n\tpublic getMutations(entity: Model.Entity): { [fieldName: string]: FieldConfig<any> } {\n\t\tconst entityName = entity.name\n\t\tconst mutations: { [fieldName: string]: FieldConfig<any> | undefined } = {}\n\t\tmutations[`create${entityName}`] = this.getCreateMutation(entity)\n\t\tmutations[`delete${entityName}`] = this.getDeleteMutation(entity)\n\t\tmutations[`update${entityName}`] = this.getUpdateMutation(entity)\n\t\tmutations[`upsert${entityName}`] = this.getUpsertMutation(entity)\n\n\t\treturn filterObject(mutations, (key, value): value is FieldConfig<any> => value !== undefined)\n\t}\n\n\t/**\n\t * Root update, delete and upsert locate their row by a unique lookup that reads in the nested set (root ∪ through).\n\t * Without any read grant there the lookup never finds a row, so the mutation would always fail.\n\t */\n\tprivate isLookupReadable(entity: Model.Entity): boolean {\n\t\treturn this.authorizator.getEntityPermission(Acl.Operation.read, entity.name) !== 'no'\n\t}\n\n\tprotected getCreateMutation(entity: Model.Entity): FieldConfig<Input.CreateInput> | undefined {\n\t\t// Root entry points are gated on the root grants alone - a `through` grant must not open one.\n\t\tif (this.rootAuthorizator.getEntityPermission(Acl.Operation.create, entity.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.createEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'create')\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\n\t\t\targs: {\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.create, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.mutation.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveCreate(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprotected getDeleteMutation(entity: Model.Entity): FieldConfig<Input.DeleteInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tif (entity.view) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (!this.isLookupReadable(entity) || this.rootAuthorizator.getEntityPermission(Acl.Operation.delete, entityName) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.createResultType(entityName, 'delete')),\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.delete, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.mutation.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveDelete(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprotected getUpdateMutation(entity: Model.Entity): FieldConfig<Input.UpdateInput> | undefined {\n\t\tif (!this.isLookupReadable(entity) || this.rootAuthorizator.getEntityPermission(Acl.Operation.update, entity.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'update')\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.update, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveUpdate(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getUpsertMutation(entity: Model.Entity): FieldConfig<Input.UpsertInput> | undefined {\n\t\tif (\n\t\t\t!this.isLookupReadable(entity)\n\t\t\t|| this.rootAuthorizator.getEntityPermission(Acl.Operation.update, entity.name) === 'no'\n\t\t\t|| this.rootAuthorizator.getEntityPermission(Acl.Operation.create, entity.name) === 'no'\n\t\t) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst createInput = this.createEntityInputProvider.getInput(entityName)\n\t\tif (createInput === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst updateInput = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (updateInput === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'upsert')\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\tupdate: { type: new GraphQLNonNull(updateInput) },\n\t\t\t\tcreate: { type: new GraphQLNonNull(createInput) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.upsert, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveUpsert(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate createResultType(\n\t\tentityName: string,\n\t\toperation: 'create' | 'update' | 'delete' | 'upsert',\n\t): GraphQLObjectType {\n\t\tconst fields: GraphQLObjectTypeConfig<any, any>['fields'] = {\n\t\t\tok: { type: new GraphQLNonNull(GraphQLBoolean) },\n\t\t\terrorMessage: { type: GraphQLString },\n\t\t\terrors: { type: this.resultSchemaTypeProvider.errorListResultType },\n\t\t}\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) !== 'no') {\n\t\t\tconst nodeType = this.entityTypeProvider.getEntity(entityName)\n\t\t\tfields.node = { type: nodeType, resolve: aliasAwareResolver }\n\t\t}\n\t\tif (operation !== 'delete') {\n\t\t\tfields.validation = {\n\t\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\t}\n\t\t}\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}${operation}Result`,\n\t\t\tfields: fields,\n\t\t\tinterfaces: [this.resultSchemaTypeProvider.mutationResultType],\n\t\t})\n\t}\n}\n"],"names":["filterObject","Acl","GraphQLNonNull","ExtensionKey","OperationMeta","Operation","GraphQLBoolean","GraphQLString","aliasAwareResolver","GraphQLObjectType","GqlTypeName"],"mappings":";;;;;;;;AAcO,MAAM,iBAAiB;AAAA,EAC7B,YACkB,cACA,kBACA,mBACA,oBACA,2BACA,2BACA,0BAChB;AAPgB,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,oBAAA;AACA,SAAA,qBAAA;AACA,SAAA,4BAAA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3D,IAAI,EAAE,MAAM,IAAIH,QAAAA,eAAeI,QAAAA,cAAc,EAAA;AAAA,MAC7C,cAAc,EAAE,MAAMC,sBAAA;AAAA,MACtB,QAAQ,EAAE,MAAM,KAAK,yBAAyB,oBAAA;AAAA,IAAoB;AAEnE,QAAI,KAAK,aAAa,oBAAoBN,OAAAA,IAAI,UAAU,MAAM,UAAU,MAAM,MAAM;AACnF,YAAM,WAAW,KAAK,mBAAmB,UAAU,UAAU;AAC7D,aAAO,OAAO,EAAE,MAAM,UAAU,SAASO,MAAAA,mBAAA;AAAA,IAC1C;AACA,QAAI,cAAc,UAAU;AAC3B,aAAO,aAAa;AAAA,QACnB,MAAM,IAAIN,QAAAA,eAAe,KAAK,yBAAyB,oBAAoB;AAAA,MAAA;AAAA,IAE7E;AACA,WAAO,IAAIO,QAAAA,kBAAkB;AAAA,MAC5B,MAAMC,MAAAA,cAAc,UAAU,GAAG,SAAS;AAAA,MAC1C;AAAA,MACA,YAAY,CAAC,KAAK,yBAAyB,kBAAkB;AAAA,IAAA,CAC7D;AAAA,EACF;AACD;;"}
|
|
1
|
+
{"version":3,"file":"MutationProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/MutationProvider.ts"],"sourcesContent":["import { GraphQLBoolean, GraphQLFieldConfig, GraphQLNonNull, GraphQLObjectType, GraphQLObjectTypeConfig, GraphQLString } from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { Context } from '../types.js'\nimport { EntityTypeProvider } from './EntityTypeProvider.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { EntityInputProvider, EntityInputType } from './mutations/index.js'\nimport { filterObject } from '../utils/index.js'\nimport { aliasAwareResolver, GqlTypeName } from './utils.js'\nimport { ResultSchemaTypeProvider } from './ResultSchemaTypeProvider.js'\nimport { ExtensionKey, Operation, OperationMeta } from './OperationExtension.js'\n\ntype FieldConfig<TArgs> = GraphQLFieldConfig<any, Context, TArgs>\n\nexport class MutationProvider {\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly createEntityInputProvider: EntityInputProvider<EntityInputType.create>,\n\t\tprivate readonly updateEntityInputProvider: EntityInputProvider<EntityInputType.update>,\n\t\tprivate readonly resultSchemaTypeProvider: ResultSchemaTypeProvider,\n\t) {}\n\n\tpublic getMutations(entity: Model.Entity): { [fieldName: string]: FieldConfig<any> } {\n\t\tconst entityName = entity.name\n\t\tconst mutations: { [fieldName: string]: FieldConfig<any> | undefined } = {}\n\t\tmutations[`create${entityName}`] = this.getCreateMutation(entity)\n\t\tmutations[`delete${entityName}`] = this.getDeleteMutation(entity)\n\t\tmutations[`update${entityName}`] = this.getUpdateMutation(entity)\n\t\tmutations[`upsert${entityName}`] = this.getUpsertMutation(entity)\n\n\t\treturn filterObject(mutations, (key, value): value is FieldConfig<any> => value !== undefined)\n\t}\n\n\t/**\n\t * Root update, delete and upsert locate their row by a unique lookup that reads in the nested set (root ∪ through).\n\t * Without any read grant there the lookup never finds a row, so the mutation would always fail.\n\t */\n\tprivate isLookupReadable(entity: Model.Entity): boolean {\n\t\treturn this.authorizator.getEntityPermission(Acl.Operation.read, entity.name) !== 'no'\n\t}\n\n\tprotected getCreateMutation(entity: Model.Entity): FieldConfig<Input.CreateInput> | undefined {\n\t\t// Root entry points are gated on the root grants alone - a `through` grant must not open one.\n\t\tif (this.rootAuthorizator.getEntityPermission(Acl.Operation.create, entity.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.createEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'create')\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.create, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.mutation.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveCreate(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprotected getDeleteMutation(entity: Model.Entity): FieldConfig<Input.DeleteInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tif (entity.view) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (!this.isLookupReadable(entity) || this.rootAuthorizator.getEntityPermission(Acl.Operation.delete, entityName) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.createResultType(entityName, 'delete')),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.delete, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.mutation.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveDelete(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprotected getUpdateMutation(entity: Model.Entity): FieldConfig<Input.UpdateInput> | undefined {\n\t\tif (!this.isLookupReadable(entity) || this.rootAuthorizator.getEntityPermission(Acl.Operation.update, entity.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'update')\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.update, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveUpdate(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getUpsertMutation(entity: Model.Entity): FieldConfig<Input.UpsertInput> | undefined {\n\t\tif (\n\t\t\t!this.isLookupReadable(entity)\n\t\t\t|| this.rootAuthorizator.getEntityPermission(Acl.Operation.update, entity.name) === 'no'\n\t\t\t|| this.rootAuthorizator.getEntityPermission(Acl.Operation.create, entity.name) === 'no'\n\t\t) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst createInput = this.createEntityInputProvider.getInput(entityName)\n\t\tif (createInput === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst updateInput = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (updateInput === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'upsert')\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\tupdate: { type: new GraphQLNonNull(updateInput) },\n\t\t\t\tcreate: { type: new GraphQLNonNull(createInput) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.upsert, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveUpsert(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate createResultType(\n\t\tentityName: string,\n\t\toperation: 'create' | 'update' | 'delete' | 'upsert',\n\t): GraphQLObjectType {\n\t\tconst fields: GraphQLObjectTypeConfig<any, any>['fields'] = {\n\t\t\tok: { type: new GraphQLNonNull(GraphQLBoolean) },\n\t\t\terrorMessage: { type: GraphQLString },\n\t\t\terrors: { type: this.resultSchemaTypeProvider.errorListResultType },\n\t\t}\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) !== 'no') {\n\t\t\tconst nodeType = this.entityTypeProvider.getEntity(entityName)\n\t\t\tfields.node = { type: nodeType, resolve: aliasAwareResolver }\n\t\t}\n\t\tif (operation !== 'delete') {\n\t\t\tfields.validation = {\n\t\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\t}\n\t\t}\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}${operation}Result`,\n\t\t\tfields: fields,\n\t\t\tinterfaces: [this.resultSchemaTypeProvider.mutationResultType],\n\t\t})\n\t}\n}\n"],"names":["filterObject","Acl","GraphQLNonNull","ExtensionKey","OperationMeta","Operation","GraphQLBoolean","GraphQLString","aliasAwareResolver","GraphQLObjectType","GqlTypeName"],"mappings":";;;;;;;;AAcO,MAAM,iBAAiB;AAAA,EAC7B,YACkB,cACA,kBACA,mBACA,oBACA,2BACA,2BACA,0BAChB;AAPgB,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,oBAAA;AACA,SAAA,qBAAA;AACA,SAAA,4BAAA;AACA,SAAA,4BAAA;AACA,SAAA,2BAAA;AAAA,EACf;AAAA,EAEI,aAAa,QAAiE;AACpF,UAAM,aAAa,OAAO;AAC1B,UAAM,YAAmE,CAAA;AACzE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAChE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAChE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAChE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAEhE,WAAOA,OAAAA,aAAa,WAAW,CAAC,KAAK,UAAqC,UAAU,MAAS;AAAA,EAC9F;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,iBAAiB,QAA+B;AACvD,WAAO,KAAK,aAAa,oBAAoBC,OAAAA,IAAI,UAAU,MAAM,OAAO,IAAI,MAAM;AAAA,EACnF;AAAA,EAEU,kBAAkB,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AA,IAE7E;AACA,WAAO,IAAIO,QAAAA,kBAAkB;AAAA,MAC5B,MAAMC,MAAAA,cAAc,UAAU,GAAG,SAAS;AAAA,MAC1C;AAAA,MACA,YAAY,CAAC,KAAK,yBAAyB,kBAAkB;AAAA,IAAA,CAC7D;AAAA,EACF;AACD;;"}
|
|
@@ -42,6 +42,7 @@ class MutationProvider {
|
|
|
42
42
|
const resultType = this.createResultType(entityName, "create");
|
|
43
43
|
return {
|
|
44
44
|
type: new GraphQLNonNull(resultType),
|
|
45
|
+
deprecationReason: entity.deprecationReason,
|
|
45
46
|
args: {
|
|
46
47
|
data: { type: new GraphQLNonNull(dataType) }
|
|
47
48
|
},
|
|
@@ -70,6 +71,7 @@ class MutationProvider {
|
|
|
70
71
|
}
|
|
71
72
|
return {
|
|
72
73
|
type: new GraphQLNonNull(this.createResultType(entityName, "delete")),
|
|
74
|
+
deprecationReason: entity.deprecationReason,
|
|
73
75
|
args: {
|
|
74
76
|
by: {
|
|
75
77
|
type: new GraphQLNonNull(uniqueWhere)
|
|
@@ -105,6 +107,7 @@ class MutationProvider {
|
|
|
105
107
|
}
|
|
106
108
|
return {
|
|
107
109
|
type: new GraphQLNonNull(resultType),
|
|
110
|
+
deprecationReason: entity.deprecationReason,
|
|
108
111
|
args: {
|
|
109
112
|
by: {
|
|
110
113
|
type: new GraphQLNonNull(uniqueWhere)
|
|
@@ -145,6 +148,7 @@ class MutationProvider {
|
|
|
145
148
|
}
|
|
146
149
|
return {
|
|
147
150
|
type: new GraphQLNonNull(resultType),
|
|
151
|
+
deprecationReason: entity.deprecationReason,
|
|
148
152
|
args: {
|
|
149
153
|
by: {
|
|
150
154
|
type: new GraphQLNonNull(uniqueWhere)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutationProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/MutationProvider.ts"],"sourcesContent":["import { GraphQLBoolean, GraphQLFieldConfig, GraphQLNonNull, GraphQLObjectType, GraphQLObjectTypeConfig, GraphQLString } from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { Context } from '../types.js'\nimport { EntityTypeProvider } from './EntityTypeProvider.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { EntityInputProvider, EntityInputType } from './mutations/index.js'\nimport { filterObject } from '../utils/index.js'\nimport { aliasAwareResolver, GqlTypeName } from './utils.js'\nimport { ResultSchemaTypeProvider } from './ResultSchemaTypeProvider.js'\nimport { ExtensionKey, Operation, OperationMeta } from './OperationExtension.js'\n\ntype FieldConfig<TArgs> = GraphQLFieldConfig<any, Context, TArgs>\n\nexport class MutationProvider {\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly createEntityInputProvider: EntityInputProvider<EntityInputType.create>,\n\t\tprivate readonly updateEntityInputProvider: EntityInputProvider<EntityInputType.update>,\n\t\tprivate readonly resultSchemaTypeProvider: ResultSchemaTypeProvider,\n\t) {}\n\n\tpublic getMutations(entity: Model.Entity): { [fieldName: string]: FieldConfig<any> } {\n\t\tconst entityName = entity.name\n\t\tconst mutations: { [fieldName: string]: FieldConfig<any> | undefined } = {}\n\t\tmutations[`create${entityName}`] = this.getCreateMutation(entity)\n\t\tmutations[`delete${entityName}`] = this.getDeleteMutation(entity)\n\t\tmutations[`update${entityName}`] = this.getUpdateMutation(entity)\n\t\tmutations[`upsert${entityName}`] = this.getUpsertMutation(entity)\n\n\t\treturn filterObject(mutations, (key, value): value is FieldConfig<any> => value !== undefined)\n\t}\n\n\t/**\n\t * Root update, delete and upsert locate their row by a unique lookup that reads in the nested set (root ∪ through).\n\t * Without any read grant there the lookup never finds a row, so the mutation would always fail.\n\t */\n\tprivate isLookupReadable(entity: Model.Entity): boolean {\n\t\treturn this.authorizator.getEntityPermission(Acl.Operation.read, entity.name) !== 'no'\n\t}\n\n\tprotected getCreateMutation(entity: Model.Entity): FieldConfig<Input.CreateInput> | undefined {\n\t\t// Root entry points are gated on the root grants alone - a `through` grant must not open one.\n\t\tif (this.rootAuthorizator.getEntityPermission(Acl.Operation.create, entity.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.createEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'create')\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\n\t\t\targs: {\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.create, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.mutation.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveCreate(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprotected getDeleteMutation(entity: Model.Entity): FieldConfig<Input.DeleteInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tif (entity.view) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (!this.isLookupReadable(entity) || this.rootAuthorizator.getEntityPermission(Acl.Operation.delete, entityName) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.createResultType(entityName, 'delete')),\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.delete, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.mutation.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveDelete(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprotected getUpdateMutation(entity: Model.Entity): FieldConfig<Input.UpdateInput> | undefined {\n\t\tif (!this.isLookupReadable(entity) || this.rootAuthorizator.getEntityPermission(Acl.Operation.update, entity.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'update')\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.update, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveUpdate(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getUpsertMutation(entity: Model.Entity): FieldConfig<Input.UpsertInput> | undefined {\n\t\tif (\n\t\t\t!this.isLookupReadable(entity)\n\t\t\t|| this.rootAuthorizator.getEntityPermission(Acl.Operation.update, entity.name) === 'no'\n\t\t\t|| this.rootAuthorizator.getEntityPermission(Acl.Operation.create, entity.name) === 'no'\n\t\t) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst createInput = this.createEntityInputProvider.getInput(entityName)\n\t\tif (createInput === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst updateInput = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (updateInput === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'upsert')\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\tupdate: { type: new GraphQLNonNull(updateInput) },\n\t\t\t\tcreate: { type: new GraphQLNonNull(createInput) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.upsert, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveUpsert(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate createResultType(\n\t\tentityName: string,\n\t\toperation: 'create' | 'update' | 'delete' | 'upsert',\n\t): GraphQLObjectType {\n\t\tconst fields: GraphQLObjectTypeConfig<any, any>['fields'] = {\n\t\t\tok: { type: new GraphQLNonNull(GraphQLBoolean) },\n\t\t\terrorMessage: { type: GraphQLString },\n\t\t\terrors: { type: this.resultSchemaTypeProvider.errorListResultType },\n\t\t}\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) !== 'no') {\n\t\t\tconst nodeType = this.entityTypeProvider.getEntity(entityName)\n\t\t\tfields.node = { type: nodeType, resolve: aliasAwareResolver }\n\t\t}\n\t\tif (operation !== 'delete') {\n\t\t\tfields.validation = {\n\t\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\t}\n\t\t}\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}${operation}Result`,\n\t\t\tfields: fields,\n\t\t\tinterfaces: [this.resultSchemaTypeProvider.mutationResultType],\n\t\t})\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAcO,MAAM,iBAAiB;AAAA,EAC7B,YACkB,cACA,kBACA,mBACA,oBACA,2BACA,2BACA,0BAChB;AAPgB,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,oBAAA;AACA,SAAA,qBAAA;AACA,SAAA,4BAAA;AACA,SAAA,4BAAA;AACA,SAAA,2BAAA;AAAA,EACf;AAAA,EAEI,aAAa,QAAiE;AACpF,UAAM,aAAa,OAAO;AAC1B,UAAM,YAAmE,CAAA;AACzE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAChE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAChE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAChE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAEhE,WAAO,aAAa,WAAW,CAAC,KAAK,UAAqC,UAAU,MAAS;AAAA,EAC9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{"version":3,"file":"MutationProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/MutationProvider.ts"],"sourcesContent":["import { GraphQLBoolean, GraphQLFieldConfig, GraphQLNonNull, GraphQLObjectType, GraphQLObjectTypeConfig, GraphQLString } from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { Context } from '../types.js'\nimport { EntityTypeProvider } from './EntityTypeProvider.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { EntityInputProvider, EntityInputType } from './mutations/index.js'\nimport { filterObject } from '../utils/index.js'\nimport { aliasAwareResolver, GqlTypeName } from './utils.js'\nimport { ResultSchemaTypeProvider } from './ResultSchemaTypeProvider.js'\nimport { ExtensionKey, Operation, OperationMeta } from './OperationExtension.js'\n\ntype FieldConfig<TArgs> = GraphQLFieldConfig<any, Context, TArgs>\n\nexport class MutationProvider {\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly createEntityInputProvider: EntityInputProvider<EntityInputType.create>,\n\t\tprivate readonly updateEntityInputProvider: EntityInputProvider<EntityInputType.update>,\n\t\tprivate readonly resultSchemaTypeProvider: ResultSchemaTypeProvider,\n\t) {}\n\n\tpublic getMutations(entity: Model.Entity): { [fieldName: string]: FieldConfig<any> } {\n\t\tconst entityName = entity.name\n\t\tconst mutations: { [fieldName: string]: FieldConfig<any> | undefined } = {}\n\t\tmutations[`create${entityName}`] = this.getCreateMutation(entity)\n\t\tmutations[`delete${entityName}`] = this.getDeleteMutation(entity)\n\t\tmutations[`update${entityName}`] = this.getUpdateMutation(entity)\n\t\tmutations[`upsert${entityName}`] = this.getUpsertMutation(entity)\n\n\t\treturn filterObject(mutations, (key, value): value is FieldConfig<any> => value !== undefined)\n\t}\n\n\t/**\n\t * Root update, delete and upsert locate their row by a unique lookup that reads in the nested set (root ∪ through).\n\t * Without any read grant there the lookup never finds a row, so the mutation would always fail.\n\t */\n\tprivate isLookupReadable(entity: Model.Entity): boolean {\n\t\treturn this.authorizator.getEntityPermission(Acl.Operation.read, entity.name) !== 'no'\n\t}\n\n\tprotected getCreateMutation(entity: Model.Entity): FieldConfig<Input.CreateInput> | undefined {\n\t\t// Root entry points are gated on the root grants alone - a `through` grant must not open one.\n\t\tif (this.rootAuthorizator.getEntityPermission(Acl.Operation.create, entity.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.createEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'create')\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.create, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.mutation.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveCreate(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprotected getDeleteMutation(entity: Model.Entity): FieldConfig<Input.DeleteInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tif (entity.view) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (!this.isLookupReadable(entity) || this.rootAuthorizator.getEntityPermission(Acl.Operation.delete, entityName) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.createResultType(entityName, 'delete')),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.delete, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.mutation.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveDelete(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprotected getUpdateMutation(entity: Model.Entity): FieldConfig<Input.UpdateInput> | undefined {\n\t\tif (!this.isLookupReadable(entity) || this.rootAuthorizator.getEntityPermission(Acl.Operation.update, entity.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'update')\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.update, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveUpdate(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getUpsertMutation(entity: Model.Entity): FieldConfig<Input.UpsertInput> | undefined {\n\t\tif (\n\t\t\t!this.isLookupReadable(entity)\n\t\t\t|| this.rootAuthorizator.getEntityPermission(Acl.Operation.update, entity.name) === 'no'\n\t\t\t|| this.rootAuthorizator.getEntityPermission(Acl.Operation.create, entity.name) === 'no'\n\t\t) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst createInput = this.createEntityInputProvider.getInput(entityName)\n\t\tif (createInput === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst updateInput = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (updateInput === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'upsert')\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\tupdate: { type: new GraphQLNonNull(updateInput) },\n\t\t\t\tcreate: { type: new GraphQLNonNull(createInput) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.upsert, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveUpsert(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate createResultType(\n\t\tentityName: string,\n\t\toperation: 'create' | 'update' | 'delete' | 'upsert',\n\t): GraphQLObjectType {\n\t\tconst fields: GraphQLObjectTypeConfig<any, any>['fields'] = {\n\t\t\tok: { type: new GraphQLNonNull(GraphQLBoolean) },\n\t\t\terrorMessage: { type: GraphQLString },\n\t\t\terrors: { type: this.resultSchemaTypeProvider.errorListResultType },\n\t\t}\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) !== 'no') {\n\t\t\tconst nodeType = this.entityTypeProvider.getEntity(entityName)\n\t\t\tfields.node = { type: nodeType, resolve: aliasAwareResolver }\n\t\t}\n\t\tif (operation !== 'delete') {\n\t\t\tfields.validation = {\n\t\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\t}\n\t\t}\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}${operation}Result`,\n\t\t\tfields: fields,\n\t\t\tinterfaces: [this.resultSchemaTypeProvider.mutationResultType],\n\t\t})\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAcO,MAAM,iBAAiB;AAAA,EAC7B,YACkB,cACA,kBACA,mBACA,oBACA,2BACA,2BACA,0BAChB;AAPgB,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,oBAAA;AACA,SAAA,qBAAA;AACA,SAAA,4BAAA;AACA,SAAA,4BAAA;AACA,SAAA,2BAAA;AAAA,EACf;AAAA,EAEI,aAAa,QAAiE;AACpF,UAAM,aAAa,OAAO;AAC1B,UAAM,YAAmE,CAAA;AACzE,cAAU,SAAS,UAAU,EA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mB,UAAU,UAAU;AAC7D,aAAO,OAAO,EAAE,MAAM,UAAU,SAAS,mBAAA;AAAA,IAC1C;AACA,QAAI,cAAc,UAAU;AAC3B,aAAO,aAAa;AAAA,QACnB,MAAM,IAAI,eAAe,KAAK,yBAAyB,oBAAoB;AAAA,MAAA;AAAA,IAE7E;AACA,WAAO,IAAI,kBAAkB;AAAA,MAC5B,MAAM,cAAc,UAAU,GAAG,SAAS;AAAA,MAC1C;AAAA,MACA,YAAY,CAAC,KAAK,yBAAyB,kBAAkB;AAAA,IAAA,CAC7D;AAAA,EACF;AACD;"}
|
|
@@ -52,9 +52,15 @@ class OrderByTypeProvider {
|
|
|
52
52
|
if (column.list) {
|
|
53
53
|
return void 0;
|
|
54
54
|
}
|
|
55
|
-
return {
|
|
55
|
+
return {
|
|
56
|
+
type: this.orderDirectionEnum,
|
|
57
|
+
description: utils.inputFieldDescription(column)
|
|
58
|
+
};
|
|
56
59
|
},
|
|
57
|
-
visitHasOne: ({ relation }) => ({
|
|
60
|
+
visitHasOne: ({ relation }) => ({
|
|
61
|
+
type: this.getEntityOrderByType(relation.target),
|
|
62
|
+
description: utils.inputFieldDescription(relation)
|
|
63
|
+
}),
|
|
58
64
|
visitHasMany: () => void 0
|
|
59
65
|
});
|
|
60
66
|
if (field !== void 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderByTypeProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/OrderByTypeProvider.ts"],"sourcesContent":["import {\n\tGraphQLBoolean,\n\tGraphQLEnumType,\n\tGraphQLInputFieldConfig,\n\tGraphQLInputFieldConfigMap,\n\tGraphQLInputObjectType,\n\tGraphQLInputType,\n\tGraphQLInt,\n} from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { singletonFactory } from '../utils/index.js'\nimport { GqlTypeName } from './utils.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\n\nexport class OrderByTypeProvider {\n\tprivate orderBySingleton = singletonFactory(name => this.createEntityOrderByType(name))\n\n\tprivate orderDirectionEnum = new GraphQLEnumType({\n\t\tname: 'OrderDirection',\n\t\tvalues: {\n\t\t\tasc: { value: 'asc' },\n\t\t\tdesc: { value: 'desc' },\n\t\t\tascNullsFirst: { value: 'ascNullsFirst' },\n\t\t\tdescNullsLast: { value: 'descNullsLast' },\n\t\t},\n\t})\n\n\tconstructor(private readonly schema: Model.Schema, private readonly authorizator: Authorizator) {}\n\n\tpublic getEntityOrderByType(entityName: string): GraphQLInputType {\n\t\treturn this.orderBySingleton(entityName)\n\t}\n\n\tprivate createEntityOrderByType(entityName: string): GraphQLInputType {\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entityName}OrderBy`,\n\t\t\tfields: () => this.getEntityOrderByFields(entityName),\n\t\t})\n\t}\n\n\tprivate getEntityOrderByFields(name: string) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {\n\t\t\t_random: { type: GraphQLBoolean },\n\t\t\t_randomSeeded: { type: GraphQLInt },\n\t\t}\n\t\tconst entity = this.schema.entities[name]\n\n\t\tfor (const fieldName in entity.fields) {\n\t\t\tif (!entity.fields.hasOwnProperty(fieldName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\t\tif (!acceptFieldVisitor(this.schema, name, fieldName, accessVisitor)) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst field = acceptFieldVisitor(this.schema, name, fieldName, {\n\t\t\t\tvisitColumn: ({ column }) => {\n\t\t\t\t\tif (column.list) {\n\t\t\t\t\t\treturn undefined\n\t\t\t\t\t}\n\t\t\t\t\treturn
|
|
1
|
+
{"version":3,"file":"OrderByTypeProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/OrderByTypeProvider.ts"],"sourcesContent":["import {\n\tGraphQLBoolean,\n\tGraphQLEnumType,\n\tGraphQLInputFieldConfig,\n\tGraphQLInputFieldConfigMap,\n\tGraphQLInputObjectType,\n\tGraphQLInputType,\n\tGraphQLInt,\n} from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { singletonFactory } from '../utils/index.js'\nimport { GqlTypeName, inputFieldDescription } from './utils.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\n\nexport class OrderByTypeProvider {\n\tprivate orderBySingleton = singletonFactory(name => this.createEntityOrderByType(name))\n\n\tprivate orderDirectionEnum = new GraphQLEnumType({\n\t\tname: 'OrderDirection',\n\t\tvalues: {\n\t\t\tasc: { value: 'asc' },\n\t\t\tdesc: { value: 'desc' },\n\t\t\tascNullsFirst: { value: 'ascNullsFirst' },\n\t\t\tdescNullsLast: { value: 'descNullsLast' },\n\t\t},\n\t})\n\n\tconstructor(private readonly schema: Model.Schema, private readonly authorizator: Authorizator) {}\n\n\tpublic getEntityOrderByType(entityName: string): GraphQLInputType {\n\t\treturn this.orderBySingleton(entityName)\n\t}\n\n\tprivate createEntityOrderByType(entityName: string): GraphQLInputType {\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entityName}OrderBy`,\n\t\t\tfields: () => this.getEntityOrderByFields(entityName),\n\t\t})\n\t}\n\n\tprivate getEntityOrderByFields(name: string) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {\n\t\t\t_random: { type: GraphQLBoolean },\n\t\t\t_randomSeeded: { type: GraphQLInt },\n\t\t}\n\t\tconst entity = this.schema.entities[name]\n\n\t\tfor (const fieldName in entity.fields) {\n\t\t\tif (!entity.fields.hasOwnProperty(fieldName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\t\tif (!acceptFieldVisitor(this.schema, name, fieldName, accessVisitor)) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst field = acceptFieldVisitor(this.schema, name, fieldName, {\n\t\t\t\tvisitColumn: ({ column }) => {\n\t\t\t\t\tif (column.list) {\n\t\t\t\t\t\treturn undefined\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: this.orderDirectionEnum,\n\t\t\t\t\t\tdescription: inputFieldDescription(column),\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tvisitHasOne: ({ relation }) => ({\n\t\t\t\t\ttype: this.getEntityOrderByType(relation.target),\n\t\t\t\t\tdescription: inputFieldDescription(relation),\n\t\t\t\t}),\n\t\t\t\tvisitHasMany: () => undefined,\n\t\t\t} as Model.FieldVisitor<GraphQLInputFieldConfig | undefined>)\n\n\t\t\tif (field !== undefined) {\n\t\t\t\tfields[fieldName] = field\n\t\t\t}\n\t\t}\n\n\t\treturn fields\n\t}\n}\n"],"names":["schema","singletonFactory","GraphQLEnumType","GraphQLInputObjectType","GqlTypeName","GraphQLBoolean","GraphQLInt","FieldAccessVisitor","Acl","acceptFieldVisitor","inputFieldDescription"],"mappings":";;;;;;;;;;;AAgBO,MAAM,oBAAoB;AAAA,EAahC,YAA6BA,SAAuC,cAA4B;AAAnE,SAAA,SAAAA;AAAuC,SAAA,eAAA;AAZpE,kBAAA,MAAQ,oBAAmBC,kCAAiB,CAAA,SAAQ,KAAK,wBAAwB,IAAI,CAAC,CAAA;AAEtF,kBAAA,MAAQ,sBAAqB,IAAIC,wBAAgB;AAAA,MAChD,MAAM;AAAA,MACN,QAAQ;AAAA,QACP,KAAK,EAAE,OAAO,MAAA;AAAA,QACd,MAAM,EAAE,OAAO,OAAA;AAAA,QACf,eAAe,EAAE,OAAO,gBAAA;AAAA,QACxB,eAAe,EAAE,OAAO,gBAAA;AAAA,MAAgB;AAAA,IACzC,CACA,CAAA;AAAA,EAEgG;AAAA,EAE1F,qBAAqB,YAAsC;AACjE,WAAO,KAAK,iBAAiB,UAAU;AAAA,EACxC;AAAA,EAEQ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
2
|
import { Acl } from "@contember/schema";
|
|
3
3
|
import { acceptFieldVisitor } from "@contember/schema-utils";
|
|
4
4
|
import { singletonFactory } from "../utils/singletonFactory.js";
|
|
5
|
-
import { GqlTypeName } from "./utils.js";
|
|
5
|
+
import { GqlTypeName, inputFieldDescription } from "./utils.js";
|
|
6
6
|
import { FieldAccessVisitor } from "./FieldAccessVisitor.js";
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
8
8
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -50,9 +50,15 @@ class OrderByTypeProvider {
|
|
|
50
50
|
if (column.list) {
|
|
51
51
|
return void 0;
|
|
52
52
|
}
|
|
53
|
-
return {
|
|
53
|
+
return {
|
|
54
|
+
type: this.orderDirectionEnum,
|
|
55
|
+
description: inputFieldDescription(column)
|
|
56
|
+
};
|
|
54
57
|
},
|
|
55
|
-
visitHasOne: ({ relation }) => ({
|
|
58
|
+
visitHasOne: ({ relation }) => ({
|
|
59
|
+
type: this.getEntityOrderByType(relation.target),
|
|
60
|
+
description: inputFieldDescription(relation)
|
|
61
|
+
}),
|
|
56
62
|
visitHasMany: () => void 0
|
|
57
63
|
});
|
|
58
64
|
if (field !== void 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderByTypeProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/OrderByTypeProvider.ts"],"sourcesContent":["import {\n\tGraphQLBoolean,\n\tGraphQLEnumType,\n\tGraphQLInputFieldConfig,\n\tGraphQLInputFieldConfigMap,\n\tGraphQLInputObjectType,\n\tGraphQLInputType,\n\tGraphQLInt,\n} from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { singletonFactory } from '../utils/index.js'\nimport { GqlTypeName } from './utils.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\n\nexport class OrderByTypeProvider {\n\tprivate orderBySingleton = singletonFactory(name => this.createEntityOrderByType(name))\n\n\tprivate orderDirectionEnum = new GraphQLEnumType({\n\t\tname: 'OrderDirection',\n\t\tvalues: {\n\t\t\tasc: { value: 'asc' },\n\t\t\tdesc: { value: 'desc' },\n\t\t\tascNullsFirst: { value: 'ascNullsFirst' },\n\t\t\tdescNullsLast: { value: 'descNullsLast' },\n\t\t},\n\t})\n\n\tconstructor(private readonly schema: Model.Schema, private readonly authorizator: Authorizator) {}\n\n\tpublic getEntityOrderByType(entityName: string): GraphQLInputType {\n\t\treturn this.orderBySingleton(entityName)\n\t}\n\n\tprivate createEntityOrderByType(entityName: string): GraphQLInputType {\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entityName}OrderBy`,\n\t\t\tfields: () => this.getEntityOrderByFields(entityName),\n\t\t})\n\t}\n\n\tprivate getEntityOrderByFields(name: string) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {\n\t\t\t_random: { type: GraphQLBoolean },\n\t\t\t_randomSeeded: { type: GraphQLInt },\n\t\t}\n\t\tconst entity = this.schema.entities[name]\n\n\t\tfor (const fieldName in entity.fields) {\n\t\t\tif (!entity.fields.hasOwnProperty(fieldName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\t\tif (!acceptFieldVisitor(this.schema, name, fieldName, accessVisitor)) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst field = acceptFieldVisitor(this.schema, name, fieldName, {\n\t\t\t\tvisitColumn: ({ column }) => {\n\t\t\t\t\tif (column.list) {\n\t\t\t\t\t\treturn undefined\n\t\t\t\t\t}\n\t\t\t\t\treturn
|
|
1
|
+
{"version":3,"file":"OrderByTypeProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/OrderByTypeProvider.ts"],"sourcesContent":["import {\n\tGraphQLBoolean,\n\tGraphQLEnumType,\n\tGraphQLInputFieldConfig,\n\tGraphQLInputFieldConfigMap,\n\tGraphQLInputObjectType,\n\tGraphQLInputType,\n\tGraphQLInt,\n} from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { singletonFactory } from '../utils/index.js'\nimport { GqlTypeName, inputFieldDescription } from './utils.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\n\nexport class OrderByTypeProvider {\n\tprivate orderBySingleton = singletonFactory(name => this.createEntityOrderByType(name))\n\n\tprivate orderDirectionEnum = new GraphQLEnumType({\n\t\tname: 'OrderDirection',\n\t\tvalues: {\n\t\t\tasc: { value: 'asc' },\n\t\t\tdesc: { value: 'desc' },\n\t\t\tascNullsFirst: { value: 'ascNullsFirst' },\n\t\t\tdescNullsLast: { value: 'descNullsLast' },\n\t\t},\n\t})\n\n\tconstructor(private readonly schema: Model.Schema, private readonly authorizator: Authorizator) {}\n\n\tpublic getEntityOrderByType(entityName: string): GraphQLInputType {\n\t\treturn this.orderBySingleton(entityName)\n\t}\n\n\tprivate createEntityOrderByType(entityName: string): GraphQLInputType {\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entityName}OrderBy`,\n\t\t\tfields: () => this.getEntityOrderByFields(entityName),\n\t\t})\n\t}\n\n\tprivate getEntityOrderByFields(name: string) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {\n\t\t\t_random: { type: GraphQLBoolean },\n\t\t\t_randomSeeded: { type: GraphQLInt },\n\t\t}\n\t\tconst entity = this.schema.entities[name]\n\n\t\tfor (const fieldName in entity.fields) {\n\t\t\tif (!entity.fields.hasOwnProperty(fieldName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\t\tif (!acceptFieldVisitor(this.schema, name, fieldName, accessVisitor)) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst field = acceptFieldVisitor(this.schema, name, fieldName, {\n\t\t\t\tvisitColumn: ({ column }) => {\n\t\t\t\t\tif (column.list) {\n\t\t\t\t\t\treturn undefined\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: this.orderDirectionEnum,\n\t\t\t\t\t\tdescription: inputFieldDescription(column),\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tvisitHasOne: ({ relation }) => ({\n\t\t\t\t\ttype: this.getEntityOrderByType(relation.target),\n\t\t\t\t\tdescription: inputFieldDescription(relation),\n\t\t\t\t}),\n\t\t\t\tvisitHasMany: () => undefined,\n\t\t\t} as Model.FieldVisitor<GraphQLInputFieldConfig | undefined>)\n\n\t\t\tif (field !== undefined) {\n\t\t\t\tfields[fieldName] = field\n\t\t\t}\n\t\t}\n\n\t\treturn fields\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;AAgBO,MAAM,oBAAoB;AAAA,EAahC,YAA6B,QAAuC,cAA4B;AAAnE,SAAA,SAAA;AAAuC,SAAA,eAAA;AAZpE,kBAAA,MAAQ,oBAAmB,iBAAiB,CAAA,SAAQ,KAAK,wBAAwB,IAAI,CAAC,CAAA;AAEtF,kBAAA,MAAQ,sBAAqB,IAAI,gBAAgB;AAAA,MAChD,MAAM;AAAA,MACN,QAAQ;AAAA,QACP,KAAK,EAAE,OAAO,MAAA;AAAA,QACd,MAAM,EAAE,OAAO,OAAA;AAAA,QACf,eAAe,EAAE,OAAO,gBAAA;AAAA,QACxB,eAAe,EAAE,OAAO,gBAAA;AAAA,MAAgB;AAAA,IACzC,CACA,CAAA;AAAA,EAEgG;AAAA,EAE1F,qBAAqB,YAAsC;AACjE,WAAO,KAAK,iBAAiB,UAAU;AAAA,EACxC;AAAA,EAEQ,wBAAwB,YAAsC;AACrE,WAAO,IAAI,uBAAuB;AAAA,MACjC,MAAM,cAAc,UAAU;AAAA,MAC9B,QAAQ,MAAM,KAAK,uBAAuB,UAAU;AAAA,IAAA,C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