@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
|
@@ -64,14 +64,20 @@ class WhereTypeProvider {
|
|
|
64
64
|
continue;
|
|
65
65
|
}
|
|
66
66
|
fields[field] = schemaUtils.acceptFieldVisitor(this.schema, entity, field, {
|
|
67
|
-
visitRelation: ({ targetEntity }) => {
|
|
67
|
+
visitRelation: ({ relation, targetEntity }) => {
|
|
68
68
|
const uniqueWhere = this.getEntityUniqueWhereType(targetEntity.name);
|
|
69
69
|
if (!uniqueWhere) {
|
|
70
70
|
throw new exception.ImplementationException();
|
|
71
71
|
}
|
|
72
|
-
return {
|
|
72
|
+
return {
|
|
73
|
+
type: uniqueWhere,
|
|
74
|
+
description: utils.inputFieldDescription(relation)
|
|
75
|
+
};
|
|
73
76
|
},
|
|
74
|
-
visitColumn: ({ column }) => ({
|
|
77
|
+
visitColumn: ({ column }) => ({
|
|
78
|
+
type: this.columnTypeResolver.getType(column)[0],
|
|
79
|
+
description: utils.inputFieldDescription(column)
|
|
80
|
+
})
|
|
75
81
|
});
|
|
76
82
|
}
|
|
77
83
|
}
|
|
@@ -89,8 +95,14 @@ class WhereTypeProvider {
|
|
|
89
95
|
continue;
|
|
90
96
|
}
|
|
91
97
|
fields[fieldName] = schemaUtils.acceptFieldVisitor(this.schema, name, fieldName, {
|
|
92
|
-
visitColumn: ({ column }) => ({
|
|
93
|
-
|
|
98
|
+
visitColumn: ({ column }) => ({
|
|
99
|
+
type: this.conditionTypeProvider.getCondition(column),
|
|
100
|
+
description: utils.inputFieldDescription(column)
|
|
101
|
+
}),
|
|
102
|
+
visitRelation: ({ relation }) => ({
|
|
103
|
+
type: this.getEntityWhereType(relation.target),
|
|
104
|
+
description: utils.inputFieldDescription(relation)
|
|
105
|
+
})
|
|
94
106
|
});
|
|
95
107
|
}
|
|
96
108
|
fields.and = { type: new graphql.GraphQLList(where) };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WhereTypeProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/WhereTypeProvider.ts"],"sourcesContent":["import { Acl, Model } from '@contember/schema'\nimport { acceptFieldVisitor, getEntity } from '@contember/schema-utils'\nimport { GraphQLInputFieldConfig, GraphQLInputFieldConfigMap, GraphQLInputObjectType, GraphQLList } from 'graphql'\nimport { capitalizeFirstLetter, getFieldsForUniqueWhere, singletonFactory } from '../utils/index.js'\nimport { ColumnTypeResolver } from './ColumnTypeResolver.js'\nimport { ConditionTypeProvider } from './ConditionTypeProvider.js'\nimport { GqlTypeName } from './utils.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\nimport { ImplementationException } from '../exception.js'\n\nexport class WhereTypeProvider {\n\tprivate whereSingleton = singletonFactory(name => this.createEntityWhereType(name))\n\tprivate uniqueWhereSingleton = singletonFactory(name => this.createEntityUniqueWhereType(name))\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly conditionTypeProvider: ConditionTypeProvider,\n\t) {}\n\n\tpublic getEntityWhereType(entityName: string): GraphQLInputObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.whereSingleton(entityName)\n\t}\n\n\tpublic getEntityUniqueWhereType(entityName: string): undefined | GraphQLInputObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\treturn this.uniqueWhereSingleton(entityName)\n\t}\n\n\tprivate createEntityWhereType(entityName: string) {\n\t\tconst where: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entityName}Where`,\n\t\t\tfields: () => this.getEntityWhereFields(entityName, where),\n\t\t})\n\n\t\treturn where\n\t}\n\n\tprivate createEntityUniqueWhereType(entityName: string, withoutRelation?: string) {\n\t\tconst entity = getEntity(this.schema, entityName)\n\n\t\tconst combinations: string[] = []\n\n\t\tconst possibleUniqueWhereFields = getFieldsForUniqueWhere(this.schema, entity)\n\t\tconst uniqueKeys: (readonly string[])[] = possibleUniqueWhereFields.filter(uniqueKey =>\n\t\t\tuniqueKey.every(it => acceptFieldVisitor(this.schema, entityName, it, new FieldAccessVisitor(Acl.Operation.read, this.authorizator)))\n\t\t)\n\t\tfor (const uniqueKey of uniqueKeys) {\n\t\t\tcombinations.push(uniqueKey.join(', '))\n\t\t}\n\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: capitalizeFirstLetter(entityName) + 'UniqueWhere',\n\t\t\t// description: `Valid combinations are: (${combinations.join('), (')})`, generates invalid schema file\n\t\t\tfields: () => this.getUniqueWhereFields(entity, uniqueKeys),\n\t\t})\n\t}\n\n\tpublic getUniqueWhereFields(entity: Model.Entity, uniqueKeys: (readonly string[])[]) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {}\n\t\tfor (const uniqueKey of uniqueKeys) {\n\t\t\tfor (const field of uniqueKey) {\n\t\t\t\tif (fields[field] !== undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tfields[field] = acceptFieldVisitor<GraphQLInputFieldConfig>(this.schema, entity, field, {\n\t\t\t\t\tvisitRelation: ({ targetEntity }) => {\n\t\t\t\t\t\t// if (!isIt<Model.JoiningColumnRelation>(relation, 'joiningColumn')) {\n\t\t\t\t\t\t// \tthrow new Error('Only column or owning relation can be a part of unique key')\n\t\t\t\t\t\t// }\n\t\t\t\t\t\tconst uniqueWhere = this.getEntityUniqueWhereType(targetEntity.name)\n\t\t\t\t\t\tif (!uniqueWhere) {\n\t\t\t\t\t\t\tthrow new ImplementationException()\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn {
|
|
1
|
+
{"version":3,"file":"WhereTypeProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/WhereTypeProvider.ts"],"sourcesContent":["import { Acl, Model } from '@contember/schema'\nimport { acceptFieldVisitor, getEntity } from '@contember/schema-utils'\nimport { GraphQLInputFieldConfig, GraphQLInputFieldConfigMap, GraphQLInputObjectType, GraphQLList } from 'graphql'\nimport { capitalizeFirstLetter, getFieldsForUniqueWhere, singletonFactory } from '../utils/index.js'\nimport { ColumnTypeResolver } from './ColumnTypeResolver.js'\nimport { ConditionTypeProvider } from './ConditionTypeProvider.js'\nimport { GqlTypeName, inputFieldDescription } from './utils.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\nimport { ImplementationException } from '../exception.js'\n\nexport class WhereTypeProvider {\n\tprivate whereSingleton = singletonFactory(name => this.createEntityWhereType(name))\n\tprivate uniqueWhereSingleton = singletonFactory(name => this.createEntityUniqueWhereType(name))\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly conditionTypeProvider: ConditionTypeProvider,\n\t) {}\n\n\tpublic getEntityWhereType(entityName: string): GraphQLInputObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.whereSingleton(entityName)\n\t}\n\n\tpublic getEntityUniqueWhereType(entityName: string): undefined | GraphQLInputObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\treturn this.uniqueWhereSingleton(entityName)\n\t}\n\n\tprivate createEntityWhereType(entityName: string) {\n\t\tconst where: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entityName}Where`,\n\t\t\tfields: () => this.getEntityWhereFields(entityName, where),\n\t\t})\n\n\t\treturn where\n\t}\n\n\tprivate createEntityUniqueWhereType(entityName: string, withoutRelation?: string) {\n\t\tconst entity = getEntity(this.schema, entityName)\n\n\t\tconst combinations: string[] = []\n\n\t\tconst possibleUniqueWhereFields = getFieldsForUniqueWhere(this.schema, entity)\n\t\tconst uniqueKeys: (readonly string[])[] = possibleUniqueWhereFields.filter(uniqueKey =>\n\t\t\tuniqueKey.every(it => acceptFieldVisitor(this.schema, entityName, it, new FieldAccessVisitor(Acl.Operation.read, this.authorizator)))\n\t\t)\n\t\tfor (const uniqueKey of uniqueKeys) {\n\t\t\tcombinations.push(uniqueKey.join(', '))\n\t\t}\n\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: capitalizeFirstLetter(entityName) + 'UniqueWhere',\n\t\t\t// description: `Valid combinations are: (${combinations.join('), (')})`, generates invalid schema file\n\t\t\tfields: () => this.getUniqueWhereFields(entity, uniqueKeys),\n\t\t})\n\t}\n\n\tpublic getUniqueWhereFields(entity: Model.Entity, uniqueKeys: (readonly string[])[]) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {}\n\t\tfor (const uniqueKey of uniqueKeys) {\n\t\t\tfor (const field of uniqueKey) {\n\t\t\t\tif (fields[field] !== undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tfields[field] = acceptFieldVisitor<GraphQLInputFieldConfig>(this.schema, entity, field, {\n\t\t\t\t\tvisitRelation: ({ relation, targetEntity }) => {\n\t\t\t\t\t\t// if (!isIt<Model.JoiningColumnRelation>(relation, 'joiningColumn')) {\n\t\t\t\t\t\t// \tthrow new Error('Only column or owning relation can be a part of unique key')\n\t\t\t\t\t\t// }\n\t\t\t\t\t\tconst uniqueWhere = this.getEntityUniqueWhereType(targetEntity.name)\n\t\t\t\t\t\tif (!uniqueWhere) {\n\t\t\t\t\t\t\tthrow new ImplementationException()\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttype: uniqueWhere,\n\t\t\t\t\t\t\tdescription: inputFieldDescription(relation),\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tvisitColumn: ({ column }) => ({\n\t\t\t\t\t\ttype: this.columnTypeResolver.getType(column)[0],\n\t\t\t\t\t\tdescription: inputFieldDescription(column),\n\t\t\t\t\t}),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn fields\n\t}\n\n\tprivate getEntityWhereFields(name: string, where: GraphQLInputObjectType) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {}\n\t\tconst entity = this.schema.entities[name]\n\n\t\tfor (const fieldName in entity.fields) {\n\t\t\tif (!entity.fields.hasOwnProperty(fieldName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\t\tif (!acceptFieldVisitor(this.schema, name, fieldName, accessVisitor)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfields[fieldName] = acceptFieldVisitor(this.schema, name, fieldName, {\n\t\t\t\tvisitColumn: ({ column }) => ({\n\t\t\t\t\ttype: this.conditionTypeProvider.getCondition(column),\n\t\t\t\t\tdescription: inputFieldDescription(column),\n\t\t\t\t}),\n\t\t\t\tvisitRelation: ({ relation }) => ({\n\t\t\t\t\ttype: this.getEntityWhereType(relation.target),\n\t\t\t\t\tdescription: inputFieldDescription(relation),\n\t\t\t\t}),\n\t\t\t} as Model.FieldVisitor<GraphQLInputFieldConfig>)\n\t\t}\n\n\t\tfields.and = { type: new GraphQLList(where) }\n\t\tfields.or = { type: new GraphQLList(where) }\n\t\tfields.not = { type: where }\n\n\t\treturn fields\n\t}\n}\n"],"names":["schema","singletonFactory","Acl","ImplementationException","GraphQLInputObjectType","GqlTypeName","getEntity","getFieldsForUniqueWhere","acceptFieldVisitor","FieldAccessVisitor","capitalizeFirstLetter","inputFieldDescription","GraphQLList"],"mappings":";;;;;;;;;;;;;;AAWO,MAAM,kBAAkB;AAAA,EAI9B,YACkBA,SACA,cACA,oBACA,uBAChB;AAJgB,SAAA,SAAAA;AACA,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,wBAAA;AAPlB,kBAAA,MAAQ,kBAAiBC,kCAAiB,CAAA,SAAQ,KAAK,sBAAsB,IAAI,CAAC,CAAA;AAClF,kBAAA,MAAQ,wBAAuBA,kCAAiB,CAAA,SAAQ,KAAK,4BAA4B,IAAI,CAAC,CAAA;AAAA,EAO3F;AAAA,EAEI,mBAAmB,YAA4C;AACrE,QAAI,KAAK,aAAa,oBAAoBC,OAAAA,IAAI,UAAU,MAAM,UAAU,MAAM,MAAM;AACnF,YAAM,IAAIC,UAAAA,wBAAA;AAAA,IACX;AACA,WAAO,KAAK,eAAe,UAAU;AAAA,EACtC;AAAA,EAEO,yBAAyB,YAAwD;AACvF,QAAI,KAAK,aAAa,oBAAoBD,OAAAA,IAAI,UAAU,MAAM,UAAU,MAAM,MAAM;AACnF,aAAO;AAAA,IACR;AACA,WAAO,KAAK,qBAAqB,UAAU;AAAA,EAC5C;AAAA,EAEQ,sBAAsB,YAAoB;AACjD,UAAM,QAAgC,IAAIE,+BAAuB;AAAA,MAChE,MAAMC,MAAAA,cAAc,UAAU;AAAA,MAC9B,QAAQ,MAAM,KAAK,qBAAqB,YAAY,KAAK;AAAA,IAAA,CACzD;AAED,WAAO;AAAA,EACR;AAAA,EAEQ,4BAA4B,YAAoB,iBAA0B;AACjF,UAAM,SAASC,YAAAA,UAAU,KAAK,QAAQ,UAAU;AAEhD,UAAM,eAAyB,CAAA;AAE/B,UAAM,4BAA4BC,kBAAAA,wBAAwB,KAAK,QAAQ,MAAM;AAC7E,UAA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SAAS,IAAI;AAExC,eAAW,aAAa,OAAO,QAAQ;AACtC,UAAI,CAAC,OAAO,OAAO,eAAe,SAAS,GAAG;AAC7C;AAAA,MACD;AACA,YAAM,gBAAgB,IAAIF,sCAAmBP,OAAAA,IAAI,UAAU,MAAM,KAAK,YAAY;AAClF,UAAI,CAACM,YAAAA,mBAAmB,KAAK,QAAQ,MAAM,WAAW,aAAa,GAAG;AACrE;AAAA,MACD;AACA,aAAO,SAAS,IAAIA,YAAAA,mBAAmB,KAAK,QAAQ,MAAM,WAAW;AAAA,QACpE,aAAa,CAAC,EAAE,cAAc;AAAA,UAC7B,MAAM,KAAK,sBAAsB,aAAa,MAAM;AAAA,UACpD,aAAaG,MAAAA,sBAAsB,MAAM;AAAA,QAAA;AAAA,QAE1C,eAAe,CAAC,EAAE,gBAAgB;AAAA,UACjC,MAAM,KAAK,mBAAmB,SAAS,MAAM;AAAA,UAC7C,aAAaA,MAAAA,sBAAsB,QAAQ;AAAA,QAAA;AAAA,MAC5C,CAC+C;AAAA,IACjD;AAEA,WAAO,MAAM,EAAE,MAAM,IAAIC,QAAAA,YAAY,KAAK,EAAA;AAC1C,WAAO,KAAK,EAAE,MAAM,IAAIA,QAAAA,YAAY,KAAK,EAAA;AACzC,WAAO,MAAM,EAAE,MAAM,MAAA;AAErB,WAAO;AAAA,EACR;AACD;;"}
|
|
@@ -5,7 +5,7 @@ import { ImplementationException } from "../exception.js";
|
|
|
5
5
|
import { singletonFactory } from "../utils/singletonFactory.js";
|
|
6
6
|
import { capitalizeFirstLetter } from "../utils/strings.js";
|
|
7
7
|
import { getFieldsForUniqueWhere } from "../utils/uniqueWhereFields.js";
|
|
8
|
-
import { GqlTypeName } from "./utils.js";
|
|
8
|
+
import { GqlTypeName, inputFieldDescription } from "./utils.js";
|
|
9
9
|
import { FieldAccessVisitor } from "./FieldAccessVisitor.js";
|
|
10
10
|
var __defProp = Object.defineProperty;
|
|
11
11
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -62,14 +62,20 @@ class WhereTypeProvider {
|
|
|
62
62
|
continue;
|
|
63
63
|
}
|
|
64
64
|
fields[field] = acceptFieldVisitor(this.schema, entity, field, {
|
|
65
|
-
visitRelation: ({ targetEntity }) => {
|
|
65
|
+
visitRelation: ({ relation, targetEntity }) => {
|
|
66
66
|
const uniqueWhere = this.getEntityUniqueWhereType(targetEntity.name);
|
|
67
67
|
if (!uniqueWhere) {
|
|
68
68
|
throw new ImplementationException();
|
|
69
69
|
}
|
|
70
|
-
return {
|
|
70
|
+
return {
|
|
71
|
+
type: uniqueWhere,
|
|
72
|
+
description: inputFieldDescription(relation)
|
|
73
|
+
};
|
|
71
74
|
},
|
|
72
|
-
visitColumn: ({ column }) => ({
|
|
75
|
+
visitColumn: ({ column }) => ({
|
|
76
|
+
type: this.columnTypeResolver.getType(column)[0],
|
|
77
|
+
description: inputFieldDescription(column)
|
|
78
|
+
})
|
|
73
79
|
});
|
|
74
80
|
}
|
|
75
81
|
}
|
|
@@ -87,8 +93,14 @@ class WhereTypeProvider {
|
|
|
87
93
|
continue;
|
|
88
94
|
}
|
|
89
95
|
fields[fieldName] = acceptFieldVisitor(this.schema, name, fieldName, {
|
|
90
|
-
visitColumn: ({ column }) => ({
|
|
91
|
-
|
|
96
|
+
visitColumn: ({ column }) => ({
|
|
97
|
+
type: this.conditionTypeProvider.getCondition(column),
|
|
98
|
+
description: inputFieldDescription(column)
|
|
99
|
+
}),
|
|
100
|
+
visitRelation: ({ relation }) => ({
|
|
101
|
+
type: this.getEntityWhereType(relation.target),
|
|
102
|
+
description: inputFieldDescription(relation)
|
|
103
|
+
})
|
|
92
104
|
});
|
|
93
105
|
}
|
|
94
106
|
fields.and = { type: new GraphQLList(where) };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WhereTypeProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/WhereTypeProvider.ts"],"sourcesContent":["import { Acl, Model } from '@contember/schema'\nimport { acceptFieldVisitor, getEntity } from '@contember/schema-utils'\nimport { GraphQLInputFieldConfig, GraphQLInputFieldConfigMap, GraphQLInputObjectType, GraphQLList } from 'graphql'\nimport { capitalizeFirstLetter, getFieldsForUniqueWhere, singletonFactory } from '../utils/index.js'\nimport { ColumnTypeResolver } from './ColumnTypeResolver.js'\nimport { ConditionTypeProvider } from './ConditionTypeProvider.js'\nimport { GqlTypeName } from './utils.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\nimport { ImplementationException } from '../exception.js'\n\nexport class WhereTypeProvider {\n\tprivate whereSingleton = singletonFactory(name => this.createEntityWhereType(name))\n\tprivate uniqueWhereSingleton = singletonFactory(name => this.createEntityUniqueWhereType(name))\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly conditionTypeProvider: ConditionTypeProvider,\n\t) {}\n\n\tpublic getEntityWhereType(entityName: string): GraphQLInputObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.whereSingleton(entityName)\n\t}\n\n\tpublic getEntityUniqueWhereType(entityName: string): undefined | GraphQLInputObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\treturn this.uniqueWhereSingleton(entityName)\n\t}\n\n\tprivate createEntityWhereType(entityName: string) {\n\t\tconst where: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entityName}Where`,\n\t\t\tfields: () => this.getEntityWhereFields(entityName, where),\n\t\t})\n\n\t\treturn where\n\t}\n\n\tprivate createEntityUniqueWhereType(entityName: string, withoutRelation?: string) {\n\t\tconst entity = getEntity(this.schema, entityName)\n\n\t\tconst combinations: string[] = []\n\n\t\tconst possibleUniqueWhereFields = getFieldsForUniqueWhere(this.schema, entity)\n\t\tconst uniqueKeys: (readonly string[])[] = possibleUniqueWhereFields.filter(uniqueKey =>\n\t\t\tuniqueKey.every(it => acceptFieldVisitor(this.schema, entityName, it, new FieldAccessVisitor(Acl.Operation.read, this.authorizator)))\n\t\t)\n\t\tfor (const uniqueKey of uniqueKeys) {\n\t\t\tcombinations.push(uniqueKey.join(', '))\n\t\t}\n\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: capitalizeFirstLetter(entityName) + 'UniqueWhere',\n\t\t\t// description: `Valid combinations are: (${combinations.join('), (')})`, generates invalid schema file\n\t\t\tfields: () => this.getUniqueWhereFields(entity, uniqueKeys),\n\t\t})\n\t}\n\n\tpublic getUniqueWhereFields(entity: Model.Entity, uniqueKeys: (readonly string[])[]) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {}\n\t\tfor (const uniqueKey of uniqueKeys) {\n\t\t\tfor (const field of uniqueKey) {\n\t\t\t\tif (fields[field] !== undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tfields[field] = acceptFieldVisitor<GraphQLInputFieldConfig>(this.schema, entity, field, {\n\t\t\t\t\tvisitRelation: ({ targetEntity }) => {\n\t\t\t\t\t\t// if (!isIt<Model.JoiningColumnRelation>(relation, 'joiningColumn')) {\n\t\t\t\t\t\t// \tthrow new Error('Only column or owning relation can be a part of unique key')\n\t\t\t\t\t\t// }\n\t\t\t\t\t\tconst uniqueWhere = this.getEntityUniqueWhereType(targetEntity.name)\n\t\t\t\t\t\tif (!uniqueWhere) {\n\t\t\t\t\t\t\tthrow new ImplementationException()\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn {
|
|
1
|
+
{"version":3,"file":"WhereTypeProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/WhereTypeProvider.ts"],"sourcesContent":["import { Acl, Model } from '@contember/schema'\nimport { acceptFieldVisitor, getEntity } from '@contember/schema-utils'\nimport { GraphQLInputFieldConfig, GraphQLInputFieldConfigMap, GraphQLInputObjectType, GraphQLList } from 'graphql'\nimport { capitalizeFirstLetter, getFieldsForUniqueWhere, singletonFactory } from '../utils/index.js'\nimport { ColumnTypeResolver } from './ColumnTypeResolver.js'\nimport { ConditionTypeProvider } from './ConditionTypeProvider.js'\nimport { GqlTypeName, inputFieldDescription } from './utils.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\nimport { ImplementationException } from '../exception.js'\n\nexport class WhereTypeProvider {\n\tprivate whereSingleton = singletonFactory(name => this.createEntityWhereType(name))\n\tprivate uniqueWhereSingleton = singletonFactory(name => this.createEntityUniqueWhereType(name))\n\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly conditionTypeProvider: ConditionTypeProvider,\n\t) {}\n\n\tpublic getEntityWhereType(entityName: string): GraphQLInputObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn this.whereSingleton(entityName)\n\t}\n\n\tpublic getEntityUniqueWhereType(entityName: string): undefined | GraphQLInputObjectType {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\treturn this.uniqueWhereSingleton(entityName)\n\t}\n\n\tprivate createEntityWhereType(entityName: string) {\n\t\tconst where: GraphQLInputObjectType = new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entityName}Where`,\n\t\t\tfields: () => this.getEntityWhereFields(entityName, where),\n\t\t})\n\n\t\treturn where\n\t}\n\n\tprivate createEntityUniqueWhereType(entityName: string, withoutRelation?: string) {\n\t\tconst entity = getEntity(this.schema, entityName)\n\n\t\tconst combinations: string[] = []\n\n\t\tconst possibleUniqueWhereFields = getFieldsForUniqueWhere(this.schema, entity)\n\t\tconst uniqueKeys: (readonly string[])[] = possibleUniqueWhereFields.filter(uniqueKey =>\n\t\t\tuniqueKey.every(it => acceptFieldVisitor(this.schema, entityName, it, new FieldAccessVisitor(Acl.Operation.read, this.authorizator)))\n\t\t)\n\t\tfor (const uniqueKey of uniqueKeys) {\n\t\t\tcombinations.push(uniqueKey.join(', '))\n\t\t}\n\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: capitalizeFirstLetter(entityName) + 'UniqueWhere',\n\t\t\t// description: `Valid combinations are: (${combinations.join('), (')})`, generates invalid schema file\n\t\t\tfields: () => this.getUniqueWhereFields(entity, uniqueKeys),\n\t\t})\n\t}\n\n\tpublic getUniqueWhereFields(entity: Model.Entity, uniqueKeys: (readonly string[])[]) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {}\n\t\tfor (const uniqueKey of uniqueKeys) {\n\t\t\tfor (const field of uniqueKey) {\n\t\t\t\tif (fields[field] !== undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tfields[field] = acceptFieldVisitor<GraphQLInputFieldConfig>(this.schema, entity, field, {\n\t\t\t\t\tvisitRelation: ({ relation, targetEntity }) => {\n\t\t\t\t\t\t// if (!isIt<Model.JoiningColumnRelation>(relation, 'joiningColumn')) {\n\t\t\t\t\t\t// \tthrow new Error('Only column or owning relation can be a part of unique key')\n\t\t\t\t\t\t// }\n\t\t\t\t\t\tconst uniqueWhere = this.getEntityUniqueWhereType(targetEntity.name)\n\t\t\t\t\t\tif (!uniqueWhere) {\n\t\t\t\t\t\t\tthrow new ImplementationException()\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttype: uniqueWhere,\n\t\t\t\t\t\t\tdescription: inputFieldDescription(relation),\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tvisitColumn: ({ column }) => ({\n\t\t\t\t\t\ttype: this.columnTypeResolver.getType(column)[0],\n\t\t\t\t\t\tdescription: inputFieldDescription(column),\n\t\t\t\t\t}),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn fields\n\t}\n\n\tprivate getEntityWhereFields(name: string, where: GraphQLInputObjectType) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {}\n\t\tconst entity = this.schema.entities[name]\n\n\t\tfor (const fieldName in entity.fields) {\n\t\t\tif (!entity.fields.hasOwnProperty(fieldName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\t\tif (!acceptFieldVisitor(this.schema, name, fieldName, accessVisitor)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfields[fieldName] = acceptFieldVisitor(this.schema, name, fieldName, {\n\t\t\t\tvisitColumn: ({ column }) => ({\n\t\t\t\t\ttype: this.conditionTypeProvider.getCondition(column),\n\t\t\t\t\tdescription: inputFieldDescription(column),\n\t\t\t\t}),\n\t\t\t\tvisitRelation: ({ relation }) => ({\n\t\t\t\t\ttype: this.getEntityWhereType(relation.target),\n\t\t\t\t\tdescription: inputFieldDescription(relation),\n\t\t\t\t}),\n\t\t\t} as Model.FieldVisitor<GraphQLInputFieldConfig>)\n\t\t}\n\n\t\tfields.and = { type: new GraphQLList(where) }\n\t\tfields.or = { type: new GraphQLList(where) }\n\t\tfields.not = { type: where }\n\n\t\treturn fields\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAWO,MAAM,kBAAkB;AAAA,EAI9B,YACkB,QACA,cACA,oBACA,uBAChB;AAJgB,SAAA,SAAA;AACA,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,wBAAA;AAPlB,kBAAA,MAAQ,kBAAiB,iBAAiB,CAAA,SAAQ,KAAK,sBAAsB,IAAI,CAAC,CAAA;AAClF,kBAAA,MAAQ,wBAAuB,iBAAiB,CAAA,SAAQ,KAAK,4BAA4B,IAAI,CAAC,CAAA;AAAA,EAO3F;AAAA,EAEI,mBAAmB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Y,KAAK,EAAA;AAC1C,WAAO,KAAK,EAAE,MAAM,IAAI,YAAY,KAAK,EAAA;AACzC,WAAO,MAAM,EAAE,MAAM,MAAA;AAErB,WAAO;AAAA,EACR;AACD;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const ISO_DATE_PREFIX_REGEX = /^(\d{4})-(\d{1,2})-(\d{1,2})(?!\d)/;
|
|
4
|
+
const BC_ERA_REGEX = /BC/i;
|
|
5
|
+
const DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
6
|
+
const daysInMonth = (year, month) => {
|
|
7
|
+
const isLeapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
8
|
+
return month === 2 && isLeapYear ? 29 : DAYS_IN_MONTH[month - 1];
|
|
9
|
+
};
|
|
10
|
+
const isImpossibleCalendarDate = (value) => {
|
|
11
|
+
const match = ISO_DATE_PREFIX_REGEX.exec(value);
|
|
12
|
+
if (!match || BC_ERA_REGEX.test(value)) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const year = Number(match[1]);
|
|
16
|
+
const month = Number(match[2]);
|
|
17
|
+
const day = Number(match[3]);
|
|
18
|
+
return year === 0 || month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month);
|
|
19
|
+
};
|
|
20
|
+
exports.isImpossibleCalendarDate = isImpossibleCalendarDate;
|
|
21
|
+
//# sourceMappingURL=calendarDate.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendarDate.cjs","sources":["../../../../../packages/engine-content-api/src/schema/calendarDate.ts"],"sourcesContent":["const ISO_DATE_PREFIX_REGEX = /^(\\d{4})-(\\d{1,2})-(\\d{1,2})(?!\\d)/\n\n// Over-matching only defers a value to PostgreSQL; `2025-02-29BC` has no word boundary before BC.\nconst BC_ERA_REGEX = /BC/i\n\nconst DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n\nconst daysInMonth = (year: number, month: number): number => {\n\tconst isLeapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)\n\treturn month === 2 && isLeapYear ? 29 : DAYS_IN_MONTH[month - 1]\n}\n\n/**\n * True for an ISO-shaped calendar date that does not exist (e.g. 2026-02-30, year 0000), which PostgreSQL would refuse.\n * Other input formats PostgreSQL accepts, and BC dates, are left for PostgreSQL to judge.\n */\nexport const isImpossibleCalendarDate = (value: string): boolean => {\n\tconst match = ISO_DATE_PREFIX_REGEX.exec(value)\n\tif (!match || BC_ERA_REGEX.test(value)) {\n\t\treturn false\n\t}\n\tconst year = Number(match[1])\n\tconst month = Number(match[2])\n\tconst day = Number(match[3])\n\treturn year === 0 || month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month)\n}\n"],"names":[],"mappings":";;AAAA,MAAM,wBAAwB;AAG9B,MAAM,eAAe;AAErB,MAAM,gBAAgB,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE;AAErE,MAAM,cAAc,CAAC,MAAc,UAA0B;AAC5D,QAAM,aAAa,OAAO,MAAM,MAAM,OAAO,QAAQ,KAAK,OAAO,QAAQ;AACzE,SAAO,UAAU,KAAK,aAAa,KAAK,cAAc,QAAQ,CAAC;AAChE;AAMO,MAAM,2BAA2B,CAAC,UAA2B;AACnE,QAAM,QAAQ,sBAAsB,KAAK,KAAK;AAC9C,MAAI,CAAC,SAAS,aAAa,KAAK,KAAK,GAAG;AACvC,WAAO;AAAA,EACR;AACA,QAAM,OAAO,OAAO,MAAM,CAAC,CAAC;AAC5B,QAAM,QAAQ,OAAO,MAAM,CAAC,CAAC;AAC7B,QAAM,MAAM,OAAO,MAAM,CAAC,CAAC;AAC3B,SAAO,SAAS,KAAK,QAAQ,KAAK,QAAQ,MAAM,MAAM,KAAK,MAAM,YAAY,MAAM,KAAK;AACzF;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const ISO_DATE_PREFIX_REGEX = /^(\d{4})-(\d{1,2})-(\d{1,2})(?!\d)/;
|
|
2
|
+
const BC_ERA_REGEX = /BC/i;
|
|
3
|
+
const DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
4
|
+
const daysInMonth = (year, month) => {
|
|
5
|
+
const isLeapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
6
|
+
return month === 2 && isLeapYear ? 29 : DAYS_IN_MONTH[month - 1];
|
|
7
|
+
};
|
|
8
|
+
const isImpossibleCalendarDate = (value) => {
|
|
9
|
+
const match = ISO_DATE_PREFIX_REGEX.exec(value);
|
|
10
|
+
if (!match || BC_ERA_REGEX.test(value)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const year = Number(match[1]);
|
|
14
|
+
const month = Number(match[2]);
|
|
15
|
+
const day = Number(match[3]);
|
|
16
|
+
return year === 0 || month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month);
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
isImpossibleCalendarDate
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=calendarDate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendarDate.js","sources":["../../../../../packages/engine-content-api/src/schema/calendarDate.ts"],"sourcesContent":["const ISO_DATE_PREFIX_REGEX = /^(\\d{4})-(\\d{1,2})-(\\d{1,2})(?!\\d)/\n\n// Over-matching only defers a value to PostgreSQL; `2025-02-29BC` has no word boundary before BC.\nconst BC_ERA_REGEX = /BC/i\n\nconst DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n\nconst daysInMonth = (year: number, month: number): number => {\n\tconst isLeapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)\n\treturn month === 2 && isLeapYear ? 29 : DAYS_IN_MONTH[month - 1]\n}\n\n/**\n * True for an ISO-shaped calendar date that does not exist (e.g. 2026-02-30, year 0000), which PostgreSQL would refuse.\n * Other input formats PostgreSQL accepts, and BC dates, are left for PostgreSQL to judge.\n */\nexport const isImpossibleCalendarDate = (value: string): boolean => {\n\tconst match = ISO_DATE_PREFIX_REGEX.exec(value)\n\tif (!match || BC_ERA_REGEX.test(value)) {\n\t\treturn false\n\t}\n\tconst year = Number(match[1])\n\tconst month = Number(match[2])\n\tconst day = Number(match[3])\n\treturn year === 0 || month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month)\n}\n"],"names":[],"mappings":"AAAA,MAAM,wBAAwB;AAG9B,MAAM,eAAe;AAErB,MAAM,gBAAgB,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE;AAErE,MAAM,cAAc,CAAC,MAAc,UAA0B;AAC5D,QAAM,aAAa,OAAO,MAAM,MAAM,OAAO,QAAQ,KAAK,OAAO,QAAQ;AACzE,SAAO,UAAU,KAAK,aAAa,KAAK,cAAc,QAAQ,CAAC;AAChE;AAMO,MAAM,2BAA2B,CAAC,UAA2B;AACnE,QAAM,QAAQ,sBAAsB,KAAK,KAAK;AAC9C,MAAI,CAAC,SAAS,aAAa,KAAK,KAAK,GAAG;AACvC,WAAO;AAAA,EACR;AACA,QAAM,OAAO,OAAO,MAAM,CAAC,CAAC;AAC5B,QAAM,QAAQ,OAAO,MAAM,CAAC,CAAC;AAC7B,QAAM,MAAM,OAAO,MAAM,CAAC,CAAC;AAC3B,SAAO,SAAS,KAAK,QAAQ,KAAK,QAAQ,MAAM,MAAM,KAAK,MAAM,YAAY,MAAM,KAAK;AACzF;"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const graphql = require("graphql");
|
|
4
4
|
const schema = require("@contember/schema");
|
|
5
|
+
const utils = require("../utils.cjs");
|
|
5
6
|
class CreateEntityInputFieldVisitor {
|
|
6
7
|
constructor(schema2, authorizator, columnTypeResolver, createEntityRelationInputProvider) {
|
|
7
8
|
this.schema = schema2;
|
|
@@ -17,14 +18,20 @@ class CreateEntityInputFieldVisitor {
|
|
|
17
18
|
return void 0;
|
|
18
19
|
}
|
|
19
20
|
const [type] = this.columnTypeResolver.getType(column);
|
|
20
|
-
return {
|
|
21
|
+
return {
|
|
22
|
+
type,
|
|
23
|
+
description: utils.inputFieldDescription(column)
|
|
24
|
+
};
|
|
21
25
|
}
|
|
22
26
|
visitHasOne({ entity, relation }) {
|
|
23
27
|
const type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name);
|
|
24
28
|
if (type === void 0) {
|
|
25
29
|
return void 0;
|
|
26
30
|
}
|
|
27
|
-
return {
|
|
31
|
+
return {
|
|
32
|
+
type,
|
|
33
|
+
description: utils.inputFieldDescription(relation)
|
|
34
|
+
};
|
|
28
35
|
}
|
|
29
36
|
visitHasMany({ entity, relation }) {
|
|
30
37
|
const type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name);
|
|
@@ -32,7 +39,8 @@ class CreateEntityInputFieldVisitor {
|
|
|
32
39
|
return void 0;
|
|
33
40
|
}
|
|
34
41
|
return {
|
|
35
|
-
type: new graphql.GraphQLList(new graphql.GraphQLNonNull(type))
|
|
42
|
+
type: new graphql.GraphQLList(new graphql.GraphQLNonNull(type)),
|
|
43
|
+
description: utils.inputFieldDescription(relation)
|
|
36
44
|
};
|
|
37
45
|
}
|
|
38
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateEntityInputFieldVisitor.cjs","sources":["../../../../../../packages/engine-content-api/src/schema/mutations/CreateEntityInputFieldVisitor.ts"],"sourcesContent":["import { GraphQLInputFieldConfig, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { ColumnTypeResolver } from '../ColumnTypeResolver.js'\nimport { CreateEntityRelationInputProvider } from './CreateEntityRelationInputProvider.js'\nimport { Authorizator } from '../../acl/index.js'\n\nexport class CreateEntityInputFieldVisitor\n\timplements Model.ColumnVisitor<GraphQLInputFieldConfig | undefined>, Model.RelationByGenericTypeVisitor<GraphQLInputFieldConfig | undefined>\n{\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly createEntityRelationInputProvider: CreateEntityRelationInputProvider,\n\t) {}\n\n\tpublic visitColumn({ entity, column }: Model.ColumnContext): GraphQLInputFieldConfig | undefined {\n\t\tif (entity.primary === column.name && !this.authorizator.isCustomPrimaryAllowed(entity.name)) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (this.authorizator.getFieldPermissions(Acl.Operation.create, entity.name, column.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst [type] = this.columnTypeResolver.getType(column)\n\t\treturn {
|
|
1
|
+
{"version":3,"file":"CreateEntityInputFieldVisitor.cjs","sources":["../../../../../../packages/engine-content-api/src/schema/mutations/CreateEntityInputFieldVisitor.ts"],"sourcesContent":["import { GraphQLInputFieldConfig, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { inputFieldDescription } from '../utils.js'\nimport { ColumnTypeResolver } from '../ColumnTypeResolver.js'\nimport { CreateEntityRelationInputProvider } from './CreateEntityRelationInputProvider.js'\nimport { Authorizator } from '../../acl/index.js'\n\nexport class CreateEntityInputFieldVisitor\n\timplements Model.ColumnVisitor<GraphQLInputFieldConfig | undefined>, Model.RelationByGenericTypeVisitor<GraphQLInputFieldConfig | undefined>\n{\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly createEntityRelationInputProvider: CreateEntityRelationInputProvider,\n\t) {}\n\n\tpublic visitColumn({ entity, column }: Model.ColumnContext): GraphQLInputFieldConfig | undefined {\n\t\tif (entity.primary === column.name && !this.authorizator.isCustomPrimaryAllowed(entity.name)) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (this.authorizator.getFieldPermissions(Acl.Operation.create, entity.name, column.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst [type] = this.columnTypeResolver.getType(column)\n\t\treturn {\n\t\t\ttype,\n\t\t\tdescription: inputFieldDescription(column),\n\t\t}\n\t}\n\n\tpublic visitHasOne({ entity, relation }: Model.AnyHasOneRelationContext): GraphQLInputFieldConfig | undefined {\n\t\tconst type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name)\n\t\tif (type === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype,\n\t\t\tdescription: inputFieldDescription(relation),\n\t\t}\n\t}\n\n\tpublic visitHasMany({ entity, relation }: Model.AnyHasManyRelationContext): GraphQLInputFieldConfig | undefined {\n\t\tconst type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name)\n\t\tif (type === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLList(new GraphQLNonNull(type)),\n\t\t\tdescription: inputFieldDescription(relation),\n\t\t}\n\t}\n}\n"],"names":["schema","Acl","inputFieldDescription","GraphQLList","GraphQLNonNull"],"mappings":";;;;;AAOO,MAAM,8BAEb;AAAA,EACC,YACkBA,SACA,cACA,oBACA,mCAChB;AAJgB,SAAA,SAAAA;AACA,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,oCAAA;AAAA,EACf;AAAA,EAEI,YAAY,EAAE,QAAQ,UAAoE;AAChG,QAAI,OAAO,YAAY,OAAO,QAAQ,CAAC,KAAK,aAAa,uBAAuB,OAAO,IAAI,GAAG;AAC7F,aAAO;AAAA,IACR;AACA,QAAI,KAAK,aAAa,oBAAoBC,OAAAA,IAAI,UAAU,QAAQ,OAAO,MAAM,OAAO,IAAI,MAAM,MAAM;AACnG,aAAO;AAAA,IACR;AACA,UAAM,CAAC,IAAI,IAAI,KAAK,mBAAmB,QAAQ,MAAM;AACrD,WAAO;AAAA,MACN;AAAA,MACA,aAAaC,MAAAA,sBAAsB,MAAM;AAAA,IAAA;AAAA,EAE3C;AAAA,EAEO,YAAY,EAAE,QAAQ,YAAiF;AAC7G,UAAM,OAAO,KAAK,kCAAkC,6BAA6B,OAAO,MAAM,SAAS,IAAI;AAC3G,QAAI,SAAS,QAAW;AACvB,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN;AAAA,MACA,aAAaA,MAAAA,sBAAsB,QAAQ;AAAA,IAAA;AAAA,EAE7C;AAAA,EAEO,aAAa,EAAE,QAAQ,YAAkF;AAC/G,UAAM,OAAO,KAAK,kCAAkC,6BAA6B,OAAO,MAAM,SAAS,IAAI;AAC3G,QAAI,SAAS,QAAW;AACvB,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN,MAAM,IAAIC,QAAAA,YAAY,IAAIC,QAAAA,eAAe,IAAI,CAAC;AAAA,MAC9C,aAAaF,MAAAA,sBAAsB,QAAQ;AAAA,IAAA;AAAA,EAE7C;AACD;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GraphQLList, GraphQLNonNull } from "graphql";
|
|
2
2
|
import { Acl } from "@contember/schema";
|
|
3
|
+
import { inputFieldDescription } from "../utils.js";
|
|
3
4
|
class CreateEntityInputFieldVisitor {
|
|
4
5
|
constructor(schema, authorizator, columnTypeResolver, createEntityRelationInputProvider) {
|
|
5
6
|
this.schema = schema;
|
|
@@ -15,14 +16,20 @@ class CreateEntityInputFieldVisitor {
|
|
|
15
16
|
return void 0;
|
|
16
17
|
}
|
|
17
18
|
const [type] = this.columnTypeResolver.getType(column);
|
|
18
|
-
return {
|
|
19
|
+
return {
|
|
20
|
+
type,
|
|
21
|
+
description: inputFieldDescription(column)
|
|
22
|
+
};
|
|
19
23
|
}
|
|
20
24
|
visitHasOne({ entity, relation }) {
|
|
21
25
|
const type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name);
|
|
22
26
|
if (type === void 0) {
|
|
23
27
|
return void 0;
|
|
24
28
|
}
|
|
25
|
-
return {
|
|
29
|
+
return {
|
|
30
|
+
type,
|
|
31
|
+
description: inputFieldDescription(relation)
|
|
32
|
+
};
|
|
26
33
|
}
|
|
27
34
|
visitHasMany({ entity, relation }) {
|
|
28
35
|
const type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name);
|
|
@@ -30,7 +37,8 @@ class CreateEntityInputFieldVisitor {
|
|
|
30
37
|
return void 0;
|
|
31
38
|
}
|
|
32
39
|
return {
|
|
33
|
-
type: new GraphQLList(new GraphQLNonNull(type))
|
|
40
|
+
type: new GraphQLList(new GraphQLNonNull(type)),
|
|
41
|
+
description: inputFieldDescription(relation)
|
|
34
42
|
};
|
|
35
43
|
}
|
|
36
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateEntityInputFieldVisitor.js","sources":["../../../../../../packages/engine-content-api/src/schema/mutations/CreateEntityInputFieldVisitor.ts"],"sourcesContent":["import { GraphQLInputFieldConfig, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { ColumnTypeResolver } from '../ColumnTypeResolver.js'\nimport { CreateEntityRelationInputProvider } from './CreateEntityRelationInputProvider.js'\nimport { Authorizator } from '../../acl/index.js'\n\nexport class CreateEntityInputFieldVisitor\n\timplements Model.ColumnVisitor<GraphQLInputFieldConfig | undefined>, Model.RelationByGenericTypeVisitor<GraphQLInputFieldConfig | undefined>\n{\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly createEntityRelationInputProvider: CreateEntityRelationInputProvider,\n\t) {}\n\n\tpublic visitColumn({ entity, column }: Model.ColumnContext): GraphQLInputFieldConfig | undefined {\n\t\tif (entity.primary === column.name && !this.authorizator.isCustomPrimaryAllowed(entity.name)) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (this.authorizator.getFieldPermissions(Acl.Operation.create, entity.name, column.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst [type] = this.columnTypeResolver.getType(column)\n\t\treturn {
|
|
1
|
+
{"version":3,"file":"CreateEntityInputFieldVisitor.js","sources":["../../../../../../packages/engine-content-api/src/schema/mutations/CreateEntityInputFieldVisitor.ts"],"sourcesContent":["import { GraphQLInputFieldConfig, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { inputFieldDescription } from '../utils.js'\nimport { ColumnTypeResolver } from '../ColumnTypeResolver.js'\nimport { CreateEntityRelationInputProvider } from './CreateEntityRelationInputProvider.js'\nimport { Authorizator } from '../../acl/index.js'\n\nexport class CreateEntityInputFieldVisitor\n\timplements Model.ColumnVisitor<GraphQLInputFieldConfig | undefined>, Model.RelationByGenericTypeVisitor<GraphQLInputFieldConfig | undefined>\n{\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly createEntityRelationInputProvider: CreateEntityRelationInputProvider,\n\t) {}\n\n\tpublic visitColumn({ entity, column }: Model.ColumnContext): GraphQLInputFieldConfig | undefined {\n\t\tif (entity.primary === column.name && !this.authorizator.isCustomPrimaryAllowed(entity.name)) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (this.authorizator.getFieldPermissions(Acl.Operation.create, entity.name, column.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst [type] = this.columnTypeResolver.getType(column)\n\t\treturn {\n\t\t\ttype,\n\t\t\tdescription: inputFieldDescription(column),\n\t\t}\n\t}\n\n\tpublic visitHasOne({ entity, relation }: Model.AnyHasOneRelationContext): GraphQLInputFieldConfig | undefined {\n\t\tconst type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name)\n\t\tif (type === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype,\n\t\t\tdescription: inputFieldDescription(relation),\n\t\t}\n\t}\n\n\tpublic visitHasMany({ entity, relation }: Model.AnyHasManyRelationContext): GraphQLInputFieldConfig | undefined {\n\t\tconst type = this.createEntityRelationInputProvider.getCreateEntityRelationInput(entity.name, relation.name)\n\t\tif (type === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLList(new GraphQLNonNull(type)),\n\t\t\tdescription: inputFieldDescription(relation),\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;AAOO,MAAM,8BAEb;AAAA,EACC,YACkB,QACA,cACA,oBACA,mCAChB;AAJgB,SAAA,SAAA;AACA,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,oCAAA;AAAA,EACf;AAAA,EAEI,YAAY,EAAE,QAAQ,UAAoE;AAChG,QAAI,OAAO,YAAY,OAAO,QAAQ,CAAC,KAAK,aAAa,uBAAuB,OAAO,IAAI,GAAG;AAC7F,aAAO;AAAA,IACR;AACA,QAAI,KAAK,aAAa,oBAAoB,IAAI,UAAU,QAAQ,OAAO,MAAM,OAAO,IAAI,MAAM,MAAM;AACnG,aAAO;AAAA,IACR;AACA,UAAM,CAAC,IAAI,IAAI,KAAK,mBAAmB,QAAQ,MAAM;AACrD,WAAO;AAAA,MACN;AAAA,MACA,aAAa,sBAAsB,MAAM;AAAA,IAAA;AAAA,EAE3C;AAAA,EAEO,YAAY,EAAE,QAAQ,YAAiF;AAC7G,UAAM,OAAO,KAAK,kCAAkC,6BAA6B,OAAO,MAAM,SAAS,IAAI;AAC3G,QAAI,SAAS,QAAW;AACvB,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN;AAAA,MACA,aAAa,sBAAsB,QAAQ;AAAA,IAAA;AAAA,EAE7C;AAAA,EAEO,aAAa,EAAE,QAAQ,YAAkF;AAC/G,UAAM,OAAO,KAAK,kCAAkC,6BAA6B,OAAO,MAAM,SAAS,IAAI;AAC3G,QAAI,SAAS,QAAW;AACvB,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN,MAAM,IAAI,YAAY,IAAI,eAAe,IAAI,CAAC;AAAA,MAC9C,aAAa,sBAAsB,QAAQ;AAAA,IAAA;AAAA,EAE7C;AACD;"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const graphql = require("graphql");
|
|
4
4
|
const schema = require("@contember/schema");
|
|
5
|
+
const utils = require("../utils.cjs");
|
|
5
6
|
class UpdateEntityInputFieldVisitor {
|
|
6
7
|
constructor(authorizator, columnTypeResolver, updateEntityRelationInputProvider) {
|
|
7
8
|
this.authorizator = authorizator;
|
|
@@ -16,14 +17,20 @@ class UpdateEntityInputFieldVisitor {
|
|
|
16
17
|
return void 0;
|
|
17
18
|
}
|
|
18
19
|
const [type] = this.columnTypeResolver.getType(column);
|
|
19
|
-
return {
|
|
20
|
+
return {
|
|
21
|
+
type,
|
|
22
|
+
description: utils.inputFieldDescription(column)
|
|
23
|
+
};
|
|
20
24
|
}
|
|
21
25
|
visitHasOne({ entity, relation }) {
|
|
22
26
|
const type = this.updateEntityRelationInputProvider.getUpdateEntityRelationInput(entity.name, relation.name);
|
|
23
27
|
if (type === void 0) {
|
|
24
28
|
return void 0;
|
|
25
29
|
}
|
|
26
|
-
return {
|
|
30
|
+
return {
|
|
31
|
+
type,
|
|
32
|
+
description: utils.inputFieldDescription(relation)
|
|
33
|
+
};
|
|
27
34
|
}
|
|
28
35
|
visitHasMany({ entity, relation }) {
|
|
29
36
|
const type = this.updateEntityRelationInputProvider.getUpdateEntityRelationInput(entity.name, relation.name);
|
|
@@ -31,7 +38,8 @@ class UpdateEntityInputFieldVisitor {
|
|
|
31
38
|
return void 0;
|
|
32
39
|
}
|
|
33
40
|
return {
|
|
34
|
-
type: new graphql.GraphQLList(new graphql.GraphQLNonNull(type))
|
|
41
|
+
type: new graphql.GraphQLList(new graphql.GraphQLNonNull(type)),
|
|
42
|
+
description: utils.inputFieldDescription(relation)
|
|
35
43
|
};
|
|
36
44
|
}
|
|
37
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateEntityInputFieldVisitor.cjs","sources":["../../../../../../packages/engine-content-api/src/schema/mutations/UpdateEntityInputFieldVisitor.ts"],"sourcesContent":["import { GraphQLInputFieldConfig, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { ColumnTypeResolver } from '../ColumnTypeResolver.js'\nimport { UpdateEntityRelationInputProvider } from './UpdateEntityRelationInputProvider.js'\nimport { Authorizator } from '../../acl/index.js'\n\nexport class UpdateEntityInputFieldVisitor\n\timplements Model.ColumnVisitor<GraphQLInputFieldConfig | undefined>, Model.RelationByGenericTypeVisitor<GraphQLInputFieldConfig | undefined>\n{\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly updateEntityRelationInputProvider: UpdateEntityRelationInputProvider,\n\t) {}\n\n\tpublic visitColumn({ entity, column }: Model.ColumnContext) {\n\t\tif (entity.primary === column.name) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (this.authorizator.getFieldPermissions(Acl.Operation.update, entity.name, column.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst [type] = this.columnTypeResolver.getType(column)\n\t\treturn {
|
|
1
|
+
{"version":3,"file":"UpdateEntityInputFieldVisitor.cjs","sources":["../../../../../../packages/engine-content-api/src/schema/mutations/UpdateEntityInputFieldVisitor.ts"],"sourcesContent":["import { GraphQLInputFieldConfig, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { inputFieldDescription } from '../utils.js'\nimport { ColumnTypeResolver } from '../ColumnTypeResolver.js'\nimport { UpdateEntityRelationInputProvider } from './UpdateEntityRelationInputProvider.js'\nimport { Authorizator } from '../../acl/index.js'\n\nexport class UpdateEntityInputFieldVisitor\n\timplements Model.ColumnVisitor<GraphQLInputFieldConfig | undefined>, Model.RelationByGenericTypeVisitor<GraphQLInputFieldConfig | undefined>\n{\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly updateEntityRelationInputProvider: UpdateEntityRelationInputProvider,\n\t) {}\n\n\tpublic visitColumn({ entity, column }: Model.ColumnContext) {\n\t\tif (entity.primary === column.name) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (this.authorizator.getFieldPermissions(Acl.Operation.update, entity.name, column.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst [type] = this.columnTypeResolver.getType(column)\n\t\treturn {\n\t\t\ttype,\n\t\t\tdescription: inputFieldDescription(column),\n\t\t}\n\t}\n\n\tpublic visitHasOne({ entity, relation }: Model.AnyHasOneRelationContext) {\n\t\tconst type = this.updateEntityRelationInputProvider.getUpdateEntityRelationInput(entity.name, relation.name)\n\t\tif (type === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype,\n\t\t\tdescription: inputFieldDescription(relation),\n\t\t}\n\t}\n\n\tpublic visitHasMany({ entity, relation }: Model.AnyHasManyRelationContext) {\n\t\tconst type = this.updateEntityRelationInputProvider.getUpdateEntityRelationInput(entity.name, relation.name)\n\t\tif (type === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLList(new GraphQLNonNull(type)),\n\t\t\tdescription: inputFieldDescription(relation),\n\t\t}\n\t}\n}\n"],"names":["Acl","inputFieldDescription","GraphQLList","GraphQLNonNull"],"mappings":";;;;;AAOO,MAAM,8BAEb;AAAA,EACC,YACkB,cACA,oBACA,mCAChB;AAHgB,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,oCAAA;AAAA,EACf;AAAA,EAEI,YAAY,EAAE,QAAQ,UAA+B;AAC3D,QAAI,OAAO,YAAY,OAAO,MAAM;AACnC,aAAO;AAAA,IACR;AACA,QAAI,KAAK,aAAa,oBAAoBA,OAAAA,IAAI,UAAU,QAAQ,OAAO,MAAM,OAAO,IAAI,MAAM,MAAM;AACnG,aAAO;AAAA,IACR;AACA,UAAM,CAAC,IAAI,IAAI,KAAK,mBAAmB,QAAQ,MAAM;AACrD,WAAO;AAAA,MACN;AAAA,MACA,aAAaC,MAAAA,sBAAsB,MAAM;AAAA,IAAA;AAAA,EAE3C;AAAA,EAEO,YAAY,EAAE,QAAQ,YAA4C;AACxE,UAAM,OAAO,KAAK,kCAAkC,6BAA6B,OAAO,MAAM,SAAS,IAAI;AAC3G,QAAI,SAAS,QAAW;AACvB,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN;AAAA,MACA,aAAaA,MAAAA,sBAAsB,QAAQ;AAAA,IAAA;AAAA,EAE7C;AAAA,EAEO,aAAa,EAAE,QAAQ,YAA6C;AAC1E,UAAM,OAAO,KAAK,kCAAkC,6BAA6B,OAAO,MAAM,SAAS,IAAI;AAC3G,QAAI,SAAS,QAAW;AACvB,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN,MAAM,IAAIC,QAAAA,YAAY,IAAIC,QAAAA,eAAe,IAAI,CAAC;AAAA,MAC9C,aAAaF,MAAAA,sBAAsB,QAAQ;AAAA,IAAA;AAAA,EAE7C;AACD;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GraphQLList, GraphQLNonNull } from "graphql";
|
|
2
2
|
import { Acl } from "@contember/schema";
|
|
3
|
+
import { inputFieldDescription } from "../utils.js";
|
|
3
4
|
class UpdateEntityInputFieldVisitor {
|
|
4
5
|
constructor(authorizator, columnTypeResolver, updateEntityRelationInputProvider) {
|
|
5
6
|
this.authorizator = authorizator;
|
|
@@ -14,14 +15,20 @@ class UpdateEntityInputFieldVisitor {
|
|
|
14
15
|
return void 0;
|
|
15
16
|
}
|
|
16
17
|
const [type] = this.columnTypeResolver.getType(column);
|
|
17
|
-
return {
|
|
18
|
+
return {
|
|
19
|
+
type,
|
|
20
|
+
description: inputFieldDescription(column)
|
|
21
|
+
};
|
|
18
22
|
}
|
|
19
23
|
visitHasOne({ entity, relation }) {
|
|
20
24
|
const type = this.updateEntityRelationInputProvider.getUpdateEntityRelationInput(entity.name, relation.name);
|
|
21
25
|
if (type === void 0) {
|
|
22
26
|
return void 0;
|
|
23
27
|
}
|
|
24
|
-
return {
|
|
28
|
+
return {
|
|
29
|
+
type,
|
|
30
|
+
description: inputFieldDescription(relation)
|
|
31
|
+
};
|
|
25
32
|
}
|
|
26
33
|
visitHasMany({ entity, relation }) {
|
|
27
34
|
const type = this.updateEntityRelationInputProvider.getUpdateEntityRelationInput(entity.name, relation.name);
|
|
@@ -29,7 +36,8 @@ class UpdateEntityInputFieldVisitor {
|
|
|
29
36
|
return void 0;
|
|
30
37
|
}
|
|
31
38
|
return {
|
|
32
|
-
type: new GraphQLList(new GraphQLNonNull(type))
|
|
39
|
+
type: new GraphQLList(new GraphQLNonNull(type)),
|
|
40
|
+
description: inputFieldDescription(relation)
|
|
33
41
|
};
|
|
34
42
|
}
|
|
35
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateEntityInputFieldVisitor.js","sources":["../../../../../../packages/engine-content-api/src/schema/mutations/UpdateEntityInputFieldVisitor.ts"],"sourcesContent":["import { GraphQLInputFieldConfig, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { ColumnTypeResolver } from '../ColumnTypeResolver.js'\nimport { UpdateEntityRelationInputProvider } from './UpdateEntityRelationInputProvider.js'\nimport { Authorizator } from '../../acl/index.js'\n\nexport class UpdateEntityInputFieldVisitor\n\timplements Model.ColumnVisitor<GraphQLInputFieldConfig | undefined>, Model.RelationByGenericTypeVisitor<GraphQLInputFieldConfig | undefined>\n{\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly updateEntityRelationInputProvider: UpdateEntityRelationInputProvider,\n\t) {}\n\n\tpublic visitColumn({ entity, column }: Model.ColumnContext) {\n\t\tif (entity.primary === column.name) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (this.authorizator.getFieldPermissions(Acl.Operation.update, entity.name, column.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst [type] = this.columnTypeResolver.getType(column)\n\t\treturn {
|
|
1
|
+
{"version":3,"file":"UpdateEntityInputFieldVisitor.js","sources":["../../../../../../packages/engine-content-api/src/schema/mutations/UpdateEntityInputFieldVisitor.ts"],"sourcesContent":["import { GraphQLInputFieldConfig, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { inputFieldDescription } from '../utils.js'\nimport { ColumnTypeResolver } from '../ColumnTypeResolver.js'\nimport { UpdateEntityRelationInputProvider } from './UpdateEntityRelationInputProvider.js'\nimport { Authorizator } from '../../acl/index.js'\n\nexport class UpdateEntityInputFieldVisitor\n\timplements Model.ColumnVisitor<GraphQLInputFieldConfig | undefined>, Model.RelationByGenericTypeVisitor<GraphQLInputFieldConfig | undefined>\n{\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly columnTypeResolver: ColumnTypeResolver,\n\t\tprivate readonly updateEntityRelationInputProvider: UpdateEntityRelationInputProvider,\n\t) {}\n\n\tpublic visitColumn({ entity, column }: Model.ColumnContext) {\n\t\tif (entity.primary === column.name) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (this.authorizator.getFieldPermissions(Acl.Operation.update, entity.name, column.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst [type] = this.columnTypeResolver.getType(column)\n\t\treturn {\n\t\t\ttype,\n\t\t\tdescription: inputFieldDescription(column),\n\t\t}\n\t}\n\n\tpublic visitHasOne({ entity, relation }: Model.AnyHasOneRelationContext) {\n\t\tconst type = this.updateEntityRelationInputProvider.getUpdateEntityRelationInput(entity.name, relation.name)\n\t\tif (type === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype,\n\t\t\tdescription: inputFieldDescription(relation),\n\t\t}\n\t}\n\n\tpublic visitHasMany({ entity, relation }: Model.AnyHasManyRelationContext) {\n\t\tconst type = this.updateEntityRelationInputProvider.getUpdateEntityRelationInput(entity.name, relation.name)\n\t\tif (type === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLList(new GraphQLNonNull(type)),\n\t\t\tdescription: inputFieldDescription(relation),\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;AAOO,MAAM,8BAEb;AAAA,EACC,YACkB,cACA,oBACA,mCAChB;AAHgB,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,oCAAA;AAAA,EACf;AAAA,EAEI,YAAY,EAAE,QAAQ,UAA+B;AAC3D,QAAI,OAAO,YAAY,OAAO,MAAM;AACnC,aAAO;AAAA,IACR;AACA,QAAI,KAAK,aAAa,oBAAoB,IAAI,UAAU,QAAQ,OAAO,MAAM,OAAO,IAAI,MAAM,MAAM;AACnG,aAAO;AAAA,IACR;AACA,UAAM,CAAC,IAAI,IAAI,KAAK,mBAAmB,QAAQ,MAAM;AACrD,WAAO;AAAA,MACN;AAAA,MACA,aAAa,sBAAsB,MAAM;AAAA,IAAA;AAAA,EAE3C;AAAA,EAEO,YAAY,EAAE,QAAQ,YAA4C;AACxE,UAAM,OAAO,KAAK,kCAAkC,6BAA6B,OAAO,MAAM,SAAS,IAAI;AAC3G,QAAI,SAAS,QAAW;AACvB,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN;AAAA,MACA,aAAa,sBAAsB,QAAQ;AAAA,IAAA;AAAA,EAE7C;AAAA,EAEO,aAAa,EAAE,QAAQ,YAA6C;AAC1E,UAAM,OAAO,KAAK,kCAAkC,6BAA6B,OAAO,MAAM,SAAS,IAAI;AAC3G,QAAI,SAAS,QAAW;AACvB,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN,MAAM,IAAI,YAAY,IAAI,eAAe,IAAI,CAAC;AAAA,MAC9C,aAAa,sBAAsB,QAAQ;AAAA,IAAA;AAAA,EAE7C;AACD;"}
|
|
@@ -6,6 +6,13 @@ const utils = require("../utils.cjs");
|
|
|
6
6
|
const exception = require("../../exception.cjs");
|
|
7
7
|
const object = require("../../utils/object.cjs");
|
|
8
8
|
const schemaUtils = require("@contember/schema-utils");
|
|
9
|
+
const orphanRemovalStrategyEnum = new graphql.GraphQLEnumType({
|
|
10
|
+
name: "OrphanRemovalStrategy",
|
|
11
|
+
values: {
|
|
12
|
+
[schema.Input.OrphanRemovalStrategy.disconnect]: {},
|
|
13
|
+
[schema.Input.OrphanRemovalStrategy.delete]: {}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
9
16
|
class UpdateEntityRelationInputFieldVisitor {
|
|
10
17
|
constructor(schema2, authorizator, whereTypeBuilder, updateEntityInputProviderAccessor, createEntityInputProvider, updateEntityRelationAllowedOperationsVisitor, connectOrCreateRelationInputProvider) {
|
|
11
18
|
this.schema = schema2;
|
|
@@ -98,21 +105,51 @@ class UpdateEntityRelationInputFieldVisitor {
|
|
|
98
105
|
if (Object.keys(filteredFields).length === 0) {
|
|
99
106
|
return void 0;
|
|
100
107
|
}
|
|
108
|
+
const setItemFields = this.filterAllowedOperations(entity, relation, {
|
|
109
|
+
[schema.Input.UpdateRelationOperation.create]: createInput,
|
|
110
|
+
[schema.Input.UpdateRelationOperation.connect]: whereInput,
|
|
111
|
+
[schema.Input.UpdateRelationOperation.connectOrCreate]: connectOrCreateInput,
|
|
112
|
+
[schema.Input.UpdateRelationOperation.update]: updateSpecifiedInput,
|
|
113
|
+
[schema.Input.UpdateRelationOperation.upsert]: upsertInput
|
|
114
|
+
});
|
|
115
|
+
const canReadTarget = this.authorizator.getEntityPermission(schema.Acl.Operation.read, targetEntity.name) !== "no";
|
|
116
|
+
const canDeleteOrphans = this.getAllowedOperations(entity, relation).includes(schema.Input.UpdateRelationOperation.delete);
|
|
117
|
+
const setField = canReadTarget && Object.keys(setItemFields).length > 0 ? {
|
|
118
|
+
type: new graphql.GraphQLList(
|
|
119
|
+
new graphql.GraphQLNonNull(
|
|
120
|
+
new graphql.GraphQLInputObjectType({
|
|
121
|
+
name: utils.GqlTypeName`${entity.name}Set${relation.name}ItemRelationInput`,
|
|
122
|
+
fields: () => ({
|
|
123
|
+
...setItemFields,
|
|
124
|
+
alias: { type: graphql.GraphQLString }
|
|
125
|
+
})
|
|
126
|
+
})
|
|
127
|
+
)
|
|
128
|
+
)
|
|
129
|
+
} : void 0;
|
|
101
130
|
return new graphql.GraphQLInputObjectType({
|
|
102
131
|
name: utils.GqlTypeName`${entity.name}Update${relation.name}EntityRelationInput`,
|
|
103
132
|
fields: () => ({
|
|
104
133
|
...filteredFields,
|
|
134
|
+
...setField ? {
|
|
135
|
+
[schema.Input.UpdateRelationOperation.set]: setField,
|
|
136
|
+
// Only exposed when the role may delete the target - `disconnect` is the default anyway.
|
|
137
|
+
...canDeleteOrphans ? { orphanStrategy: { type: orphanRemovalStrategyEnum } } : {}
|
|
138
|
+
} : {},
|
|
105
139
|
alias: { type: graphql.GraphQLString }
|
|
106
140
|
})
|
|
107
141
|
});
|
|
108
142
|
}
|
|
109
|
-
|
|
110
|
-
|
|
143
|
+
getAllowedOperations(entity, relation) {
|
|
144
|
+
return schemaUtils.acceptFieldVisitor(
|
|
111
145
|
this.schema,
|
|
112
146
|
entity,
|
|
113
147
|
relation.name,
|
|
114
148
|
this.updateEntityRelationAllowedOperationsVisitor
|
|
115
149
|
);
|
|
150
|
+
}
|
|
151
|
+
filterAllowedOperations(entity, relation, graphQlFields) {
|
|
152
|
+
const allowedOperations = this.getAllowedOperations(entity, relation);
|
|
116
153
|
return object.filterObject(
|
|
117
154
|
graphQlFields,
|
|
118
155
|
(key, value) => allowedOperations.includes(key) && value !== void 0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateEntityRelationInputFieldVisitor.cjs","sources":["../../../../../../packages/engine-content-api/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.ts"],"sourcesContent":["import { GraphQLBoolean, GraphQLInputFieldConfig, GraphQLInputFieldConfigMap, GraphQLInputObjectType, GraphQLNonNull, GraphQLString } from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { GqlTypeName } from '../utils.js'\nimport { WhereTypeProvider } from '../WhereTypeProvider.js'\nimport { Accessor, filterObject } from '../../utils/index.js'\nimport { EntityInputProvider, EntityInputType } from './EntityInputProvider.js'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { UpdateEntityRelationAllowedOperationsVisitor } from './UpdateEntityRelationAllowedOperationsVisitor.js'\nimport { Authorizator } from '../../acl/index.js'\nimport { ImplementationException } from '../../exception.js'\nimport { ConnectOrCreateRelationInputProvider } from './ConnectOrCreateRelationInputProvider.js'\n\nexport class UpdateEntityRelationInputFieldVisitor\n\timplements Model.ColumnVisitor<never>, Model.RelationByGenericTypeVisitor<GraphQLInputObjectType | undefined>\n{\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly whereTypeBuilder: WhereTypeProvider,\n\t\tprivate readonly updateEntityInputProviderAccessor: Accessor<EntityInputProvider<EntityInputType.update>>,\n\t\tprivate readonly createEntityInputProvider: EntityInputProvider<EntityInputType.create>,\n\t\tprivate readonly updateEntityRelationAllowedOperationsVisitor: UpdateEntityRelationAllowedOperationsVisitor,\n\t\tprivate readonly connectOrCreateRelationInputProvider: ConnectOrCreateRelationInputProvider,\n\t) {\n\t}\n\n\tpublic visitColumn(): never {\n\t\tthrow new Error('UpdateEntityRelationInputFieldVisitor: Not applicable for a column')\n\t}\n\n\tpublic visitHasOne({ targetRelation, targetEntity, relation, entity }: Model.AnyHasOneRelationContext) {\n\t\tconst withoutRelation = targetRelation ? targetRelation.name : undefined\n\n\t\tconst whereInputType = this.createUniqueWhereInput(targetEntity)\n\t\tconst whereInput = whereInputType ? { type: whereInputType } : undefined\n\n\t\tconst createInputType = this.createEntityInputProvider.getInput(targetEntity.name, withoutRelation)\n\t\tconst createInput = createInputType ? { type: createInputType } : undefined\n\n\t\tconst updateInputType = this.updateEntityInputProviderAccessor.get().getInput(targetEntity.name, withoutRelation)\n\t\tconst updateInput = updateInputType ? { type: updateInputType } : undefined\n\n\t\tconst upsertInput = updateInputType && createInputType\n\t\t\t? {\n\t\t\t\ttype: new GraphQLInputObjectType({\n\t\t\t\t\tname: GqlTypeName`${entity.name}Upsert${relation.name}RelationInput`,\n\t\t\t\t\tfields: () => ({\n\t\t\t\t\t\tupdate: { type: new GraphQLNonNull(updateInputType) },\n\t\t\t\t\t\tcreate: { type: new GraphQLNonNull(createInputType) },\n\t\t\t\t\t}),\n\t\t\t\t}),\n\t\t\t}\n\t\t\t: undefined\n\n\t\tconst booleanInput = {\n\t\t\ttype: GraphQLBoolean,\n\t\t}\n\n\t\tconst connectOrCreateInput = createInput && whereInputType\n\t\t\t? { type: this.connectOrCreateRelationInputProvider.getInput(entity.name, relation.name) }\n\t\t\t: undefined\n\n\t\tconst fields = {\n\t\t\t[Input.UpdateRelationOperation.connect]: whereInput,\n\t\t\t[Input.UpdateRelationOperation.create]: createInput,\n\t\t\t[Input.UpdateRelationOperation.connectOrCreate]: connectOrCreateInput,\n\t\t\t[Input.UpdateRelationOperation.update]: updateInput,\n\t\t\t[Input.UpdateRelationOperation.upsert]: upsertInput,\n\t\t\t[Input.UpdateRelationOperation.disconnect]: booleanInput,\n\t\t\t[Input.UpdateRelationOperation.delete]: booleanInput,\n\t\t}\n\n\t\tconst filteredFields = this.filterAllowedOperations(entity, relation, fields)\n\t\tif (Object.keys(filteredFields).length === 0) {\n\t\t\treturn undefined\n\t\t}\n\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entity.name}Update${relation.name}EntityRelationInput`,\n\t\t\tfields: () => filteredFields,\n\t\t})\n\t}\n\n\tpublic visitHasMany({ entity, relation, targetEntity, targetRelation }: Model.AnyHasManyRelationContext) {\n\t\tconst withoutRelation = targetRelation ? targetRelation.name : undefined\n\n\t\tconst whereInputType = this.createUniqueWhereInput(targetEntity)\n\t\tconst whereInput = whereInputType ? { type: whereInputType } : undefined\n\n\t\tconst createInputType = this.createEntityInputProvider.getInput(targetEntity.name, withoutRelation)\n\t\tconst createInput = createInputType ? { type: createInputType } : undefined\n\n\t\tconst updateInputType = this.updateEntityInputProviderAccessor.get().getInput(targetEntity.name, withoutRelation)\n\n\t\tconst updateSpecifiedInput = updateInputType && whereInputType\n\t\t\t? {\n\t\t\t\ttype: new GraphQLInputObjectType({\n\t\t\t\t\tname: GqlTypeName`${entity.name}Update${relation.name}RelationInput`,\n\t\t\t\t\tfields: () => ({\n\t\t\t\t\t\tby: { type: new GraphQLNonNull(whereInputType) },\n\t\t\t\t\t\tdata: { type: new GraphQLNonNull(updateInputType) },\n\t\t\t\t\t}),\n\t\t\t\t}),\n\t\t\t}\n\t\t\t: undefined\n\n\t\tconst upsertInput = updateInputType && createInputType && whereInputType\n\t\t\t? {\n\t\t\t\ttype: new GraphQLInputObjectType({\n\t\t\t\t\tname: GqlTypeName`${entity.name}Upsert${relation.name}RelationInput`,\n\t\t\t\t\tfields: () => ({\n\t\t\t\t\t\tby: { type: new GraphQLNonNull(whereInputType) },\n\t\t\t\t\t\tupdate: { type: new GraphQLNonNull(updateInputType) },\n\t\t\t\t\t\tcreate: { type: new GraphQLNonNull(createInputType) },\n\t\t\t\t\t}),\n\t\t\t\t}),\n\t\t\t}\n\t\t\t: undefined\n\n\t\tconst connectOrCreateInput = createInput && whereInputType\n\t\t\t? { type: this.connectOrCreateRelationInputProvider.getInput(entity.name, relation.name) }\n\t\t\t: undefined\n\n\t\tconst fields = {\n\t\t\t[Input.UpdateRelationOperation.create]: createInput,\n\t\t\t[Input.UpdateRelationOperation.update]: updateSpecifiedInput,\n\t\t\t[Input.UpdateRelationOperation.upsert]: upsertInput,\n\t\t\t[Input.UpdateRelationOperation.connect]: whereInput,\n\t\t\t[Input.UpdateRelationOperation.connectOrCreate]: connectOrCreateInput,\n\t\t\t[Input.UpdateRelationOperation.disconnect]: whereInput,\n\t\t\t[Input.UpdateRelationOperation.delete]: whereInput,\n\t\t}\n\n\t\tconst filteredFields = this.filterAllowedOperations(entity, relation, fields)\n\t\tif (Object.keys(filteredFields).length === 0) {\n\t\t\treturn undefined\n\t\t}\n\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entity.name}Update${relation.name}EntityRelationInput`,\n\t\t\tfields: () => ({\n\t\t\t\t...filteredFields,\n\t\t\t\talias: { type: GraphQLString },\n\t\t\t}),\n\t\t})\n\t}\n\n\tprivate filterAllowedOperations(\n\t\tentity: Model.Entity,\n\t\trelation: Model.Relation,\n\t\tgraphQlFields: { [key: string]: GraphQLInputFieldConfig | undefined },\n\t): GraphQLInputFieldConfigMap {\n\t\tconst allowedOperations = acceptFieldVisitor(\n\t\t\tthis.schema,\n\t\t\tentity,\n\t\t\trelation.name,\n\t\t\tthis.updateEntityRelationAllowedOperationsVisitor,\n\t\t)\n\t\treturn filterObject(\n\t\t\tgraphQlFields,\n\t\t\t(key, value): value is GraphQLInputFieldConfig => allowedOperations.includes(key as Input.UpdateRelationOperation) && value !== undefined,\n\t\t)\n\t}\n\n\tprivate createUniqueWhereInput(targetEntity: Model.Entity): GraphQLInputObjectType | undefined {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, targetEntity.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst uniqueWhere = this.whereTypeBuilder.getEntityUniqueWhereType(targetEntity.name)\n\t\tif (!uniqueWhere) {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn uniqueWhere\n\t}\n}\n"],"names":["schema","GraphQLInputObjectType","GqlTypeName","GraphQLNonNull","GraphQLBoolean","Input","GraphQLString","acceptFieldVisitor","filterObject","Acl","ImplementationException"],"mappings":";;;;;;;;AAYO,MAAM,sCAEb;AAAA,EACC,YACkBA,SACA,cACA,kBACA,mCACA,2BACA,8CACA,sCAChB;AAPgB,SAAA,SAAAA;AACA,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,oCAAA;AACA,SAAA,4BAAA;AACA,SAAA,+CAAA;AACA,SAAA,uCAAA;AAAA,EAElB;AAAA,EAEO,cAAqB;AAC3B,UAAM,IAAI,MAAM,oEAAoE;AAAA,EACrF;AAAA,EAEO,YAAY,EAAE,gBAAgB,cAAc,UAAU,UAA0C;AACtG,UAAM,kBAAkB,iBAAiB,eAAe,OAAO;AAE/D,UAAM,iBAAiB,KAAK,uBAAuB,YAAY;AAC/D,UAAM,aAAa,iBAAiB,EAAE,MAAM,mBAAmB;AAE/D,UAAM,kBAAkB,KAAK,0BAA0B,SAAS,aAAa,MAAM,eAAe;AAClG,UAAM,cAAc,kBAAkB,EAAE,MAAM,oBAAoB;AAElE,UAAM,kBAAkB,KAAK,kCAAkC,IAAA,EAAM,SAAS,aAAa,MAAM,eAAe;AAChH,UAAM,cAAc,kBAAkB,EAAE,MAAM,oBAAoB;AAElE,UAAM,cAAc,mBAAmB,kBACpC;AAAA,MACD,MAAM,IAAIC,QAAAA,uBAAuB;AAAA,QAChC,MAAMC,MAAAA,cAAc,OAAO,IAAI,SAAS,SAAS,IAAI;AAAA,QACrD,QAAQ,OAAO;AAAA,UACd,QAAQ,EAAE,MAAM,IAAIC,QAAAA,eAAe,eAAe,EAAA;AAAA,UAClD,QAAQ,EAAE,MAAM,IAAIA,QAAAA,eAAe,eAAe,EAAA;AAAA,QAAE;AAAA,MACrD,CACA;AAAA,IAAA,IAEA;AAEH,UAAM,eAAe;AAAA,MACpB,MAAMC,QAAAA;AAAAA,IAAA;AAGP,UAAM,uBAAuB,eAAe,iBACzC,EA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O,IAAIJ,QAAAA,uBAAuB;AAAA,MACjC,MAAMC,MAAAA,cAAc,OAAO,IAAI,SAAS,SAAS,IAAI;AAAA,MACrD,QAAQ,OAAO;AAAA,QACd,GAAG;AAAA,QACH,OAAO,EAAE,MAAMI,QAAAA,cAAA;AAAA,MAAc;AAAA,IAC9B,CACA;AAAA,EACF;AAAA,EAEQ,wBACP,QACA,UACA,eAC6B;AAC7B,UAAM,oBAAoBC,YAAAA;AAAAA,MACzB,KAAK;AAAA,MACL;AAAA,MACA,SAAS;AAAA,MACT,KAAK;AAAA,IAAA;AAEN,WAAOC,OAAAA;AAAAA,MACN;AAAA,MACA,CAAC,KAAK,UAA4C,kBAAkB,SAAS,GAAoC,KAAK,UAAU;AAAA,IAAA;AAAA,EAElI;AAAA,EAEQ,uBAAuB,cAAgE;AAC9F,QAAI,KAAK,aAAa,oBAAoBC,OAAAA,IAAI,UAAU,MAAM,aAAa,IAAI,MAAM,MAAM;AAC1F,aAAO;AAAA,IACR;AACA,UAAM,cAAc,KAAK,iBAAiB,yBAAyB,aAAa,IAAI;AACpF,QAAI,CAAC,aAAa;AACjB,YAAM,IAAIC,UAAAA,wBAAA;AAAA,IACX;AACA,WAAO;AAAA,EACR;AACD;;"}
|
|
1
|
+
{"version":3,"file":"UpdateEntityRelationInputFieldVisitor.cjs","sources":["../../../../../../packages/engine-content-api/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.ts"],"sourcesContent":["import {\n\tGraphQLBoolean,\n\tGraphQLEnumType,\n\tGraphQLInputFieldConfig,\n\tGraphQLInputFieldConfigMap,\n\tGraphQLInputObjectType,\n\tGraphQLList,\n\tGraphQLNonNull,\n\tGraphQLString,\n} from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { GqlTypeName } from '../utils.js'\nimport { WhereTypeProvider } from '../WhereTypeProvider.js'\nimport { Accessor, filterObject } from '../../utils/index.js'\nimport { EntityInputProvider, EntityInputType } from './EntityInputProvider.js'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { UpdateEntityRelationAllowedOperationsVisitor } from './UpdateEntityRelationAllowedOperationsVisitor.js'\nimport { Authorizator } from '../../acl/index.js'\nimport { ImplementationException } from '../../exception.js'\nimport { ConnectOrCreateRelationInputProvider } from './ConnectOrCreateRelationInputProvider.js'\n\nconst orphanRemovalStrategyEnum = new GraphQLEnumType({\n\tname: 'OrphanRemovalStrategy',\n\tvalues: {\n\t\t[Input.OrphanRemovalStrategy.disconnect]: {},\n\t\t[Input.OrphanRemovalStrategy.delete]: {},\n\t},\n})\n\nexport class UpdateEntityRelationInputFieldVisitor\n\timplements Model.ColumnVisitor<never>, Model.RelationByGenericTypeVisitor<GraphQLInputObjectType | undefined>\n{\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly whereTypeBuilder: WhereTypeProvider,\n\t\tprivate readonly updateEntityInputProviderAccessor: Accessor<EntityInputProvider<EntityInputType.update>>,\n\t\tprivate readonly createEntityInputProvider: EntityInputProvider<EntityInputType.create>,\n\t\tprivate readonly updateEntityRelationAllowedOperationsVisitor: UpdateEntityRelationAllowedOperationsVisitor,\n\t\tprivate readonly connectOrCreateRelationInputProvider: ConnectOrCreateRelationInputProvider,\n\t) {\n\t}\n\n\tpublic visitColumn(): never {\n\t\tthrow new Error('UpdateEntityRelationInputFieldVisitor: Not applicable for a column')\n\t}\n\n\tpublic visitHasOne({ targetRelation, targetEntity, relation, entity }: Model.AnyHasOneRelationContext) {\n\t\tconst withoutRelation = targetRelation ? targetRelation.name : undefined\n\n\t\tconst whereInputType = this.createUniqueWhereInput(targetEntity)\n\t\tconst whereInput = whereInputType ? { type: whereInputType } : undefined\n\n\t\tconst createInputType = this.createEntityInputProvider.getInput(targetEntity.name, withoutRelation)\n\t\tconst createInput = createInputType ? { type: createInputType } : undefined\n\n\t\tconst updateInputType = this.updateEntityInputProviderAccessor.get().getInput(targetEntity.name, withoutRelation)\n\t\tconst updateInput = updateInputType ? { type: updateInputType } : undefined\n\n\t\tconst upsertInput = updateInputType && createInputType\n\t\t\t? {\n\t\t\t\ttype: new GraphQLInputObjectType({\n\t\t\t\t\tname: GqlTypeName`${entity.name}Upsert${relation.name}RelationInput`,\n\t\t\t\t\tfields: () => ({\n\t\t\t\t\t\tupdate: { type: new GraphQLNonNull(updateInputType) },\n\t\t\t\t\t\tcreate: { type: new GraphQLNonNull(createInputType) },\n\t\t\t\t\t}),\n\t\t\t\t}),\n\t\t\t}\n\t\t\t: undefined\n\n\t\tconst booleanInput = {\n\t\t\ttype: GraphQLBoolean,\n\t\t}\n\n\t\tconst connectOrCreateInput = createInput && whereInputType\n\t\t\t? { type: this.connectOrCreateRelationInputProvider.getInput(entity.name, relation.name) }\n\t\t\t: undefined\n\n\t\tconst fields = {\n\t\t\t[Input.UpdateRelationOperation.connect]: whereInput,\n\t\t\t[Input.UpdateRelationOperation.create]: createInput,\n\t\t\t[Input.UpdateRelationOperation.connectOrCreate]: connectOrCreateInput,\n\t\t\t[Input.UpdateRelationOperation.update]: updateInput,\n\t\t\t[Input.UpdateRelationOperation.upsert]: upsertInput,\n\t\t\t[Input.UpdateRelationOperation.disconnect]: booleanInput,\n\t\t\t[Input.UpdateRelationOperation.delete]: booleanInput,\n\t\t}\n\n\t\tconst filteredFields = this.filterAllowedOperations(entity, relation, fields)\n\t\tif (Object.keys(filteredFields).length === 0) {\n\t\t\treturn undefined\n\t\t}\n\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entity.name}Update${relation.name}EntityRelationInput`,\n\t\t\tfields: () => filteredFields,\n\t\t})\n\t}\n\n\tpublic visitHasMany({ entity, relation, targetEntity, targetRelation }: Model.AnyHasManyRelationContext) {\n\t\tconst withoutRelation = targetRelation ? targetRelation.name : undefined\n\n\t\tconst whereInputType = this.createUniqueWhereInput(targetEntity)\n\t\tconst whereInput = whereInputType ? { type: whereInputType } : undefined\n\n\t\tconst createInputType = this.createEntityInputProvider.getInput(targetEntity.name, withoutRelation)\n\t\tconst createInput = createInputType ? { type: createInputType } : undefined\n\n\t\tconst updateInputType = this.updateEntityInputProviderAccessor.get().getInput(targetEntity.name, withoutRelation)\n\n\t\tconst updateSpecifiedInput = updateInputType && whereInputType\n\t\t\t? {\n\t\t\t\ttype: new GraphQLInputObjectType({\n\t\t\t\t\tname: GqlTypeName`${entity.name}Update${relation.name}RelationInput`,\n\t\t\t\t\tfields: () => ({\n\t\t\t\t\t\tby: { type: new GraphQLNonNull(whereInputType) },\n\t\t\t\t\t\tdata: { type: new GraphQLNonNull(updateInputType) },\n\t\t\t\t\t}),\n\t\t\t\t}),\n\t\t\t}\n\t\t\t: undefined\n\n\t\tconst upsertInput = updateInputType && createInputType && whereInputType\n\t\t\t? {\n\t\t\t\ttype: new GraphQLInputObjectType({\n\t\t\t\t\tname: GqlTypeName`${entity.name}Upsert${relation.name}RelationInput`,\n\t\t\t\t\tfields: () => ({\n\t\t\t\t\t\tby: { type: new GraphQLNonNull(whereInputType) },\n\t\t\t\t\t\tupdate: { type: new GraphQLNonNull(updateInputType) },\n\t\t\t\t\t\tcreate: { type: new GraphQLNonNull(createInputType) },\n\t\t\t\t\t}),\n\t\t\t\t}),\n\t\t\t}\n\t\t\t: undefined\n\n\t\tconst connectOrCreateInput = createInput && whereInputType\n\t\t\t? { type: this.connectOrCreateRelationInputProvider.getInput(entity.name, relation.name) }\n\t\t\t: undefined\n\n\t\tconst fields = {\n\t\t\t[Input.UpdateRelationOperation.create]: createInput,\n\t\t\t[Input.UpdateRelationOperation.update]: updateSpecifiedInput,\n\t\t\t[Input.UpdateRelationOperation.upsert]: upsertInput,\n\t\t\t[Input.UpdateRelationOperation.connect]: whereInput,\n\t\t\t[Input.UpdateRelationOperation.connectOrCreate]: connectOrCreateInput,\n\t\t\t[Input.UpdateRelationOperation.disconnect]: whereInput,\n\t\t\t[Input.UpdateRelationOperation.delete]: whereInput,\n\t\t}\n\n\t\tconst filteredFields = this.filterAllowedOperations(entity, relation, fields)\n\t\tif (Object.keys(filteredFields).length === 0) {\n\t\t\treturn undefined\n\t\t}\n\n\t\t// The `set` operation declaratively replaces the whole collection. Its items reuse the\n\t\t// positive operations (no delete/disconnect); orphans are removed via `orphanStrategy`.\n\t\tconst setItemFields = this.filterAllowedOperations(entity, relation, {\n\t\t\t[Input.UpdateRelationOperation.create]: createInput,\n\t\t\t[Input.UpdateRelationOperation.connect]: whereInput,\n\t\t\t[Input.UpdateRelationOperation.connectOrCreate]: connectOrCreateInput,\n\t\t\t[Input.UpdateRelationOperation.update]: updateSpecifiedInput,\n\t\t\t[Input.UpdateRelationOperation.upsert]: upsertInput,\n\t\t})\n\t\t// Orphans are computed by diffing the current members against the input, and that diff is taken\n\t\t// through the target's read predicate. A role that cannot read the target sees an empty\n\t\t// collection, so `set` could only ever add - it is not offered at all. This is about reading,\n\t\t// not about `disconnect`: `orphanStrategy: delete` is just as unusable without it.\n\t\tconst canReadTarget = this.authorizator.getEntityPermission(Acl.Operation.read, targetEntity.name) !== 'no'\n\t\tconst canDeleteOrphans = this.getAllowedOperations(entity, relation).includes(Input.UpdateRelationOperation.delete)\n\t\tconst setField = canReadTarget && Object.keys(setItemFields).length > 0\n\t\t\t? {\n\t\t\t\ttype: new GraphQLList(\n\t\t\t\t\tnew GraphQLNonNull(\n\t\t\t\t\t\tnew GraphQLInputObjectType({\n\t\t\t\t\t\t\tname: GqlTypeName`${entity.name}Set${relation.name}ItemRelationInput`,\n\t\t\t\t\t\t\tfields: () => ({\n\t\t\t\t\t\t\t\t...setItemFields,\n\t\t\t\t\t\t\t\talias: { type: GraphQLString },\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),\n\t\t\t}\n\t\t\t: undefined\n\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entity.name}Update${relation.name}EntityRelationInput`,\n\t\t\tfields: () => ({\n\t\t\t\t...filteredFields,\n\t\t\t\t...(setField\n\t\t\t\t\t? {\n\t\t\t\t\t\t[Input.UpdateRelationOperation.set]: setField,\n\t\t\t\t\t\t// Only exposed when the role may delete the target - `disconnect` is the default anyway.\n\t\t\t\t\t\t...(canDeleteOrphans ? { orphanStrategy: { type: orphanRemovalStrategyEnum } } : {}),\n\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\talias: { type: GraphQLString },\n\t\t\t}),\n\t\t})\n\t}\n\n\tprivate getAllowedOperations(entity: Model.Entity, relation: Model.Relation): Input.UpdateRelationOperation[] {\n\t\treturn acceptFieldVisitor(\n\t\t\tthis.schema,\n\t\t\tentity,\n\t\t\trelation.name,\n\t\t\tthis.updateEntityRelationAllowedOperationsVisitor,\n\t\t)\n\t}\n\n\tprivate filterAllowedOperations(\n\t\tentity: Model.Entity,\n\t\trelation: Model.Relation,\n\t\tgraphQlFields: { [key: string]: GraphQLInputFieldConfig | undefined },\n\t): GraphQLInputFieldConfigMap {\n\t\tconst allowedOperations = this.getAllowedOperations(entity, relation)\n\t\treturn filterObject(\n\t\t\tgraphQlFields,\n\t\t\t(key, value): value is GraphQLInputFieldConfig => allowedOperations.includes(key as Input.UpdateRelationOperation) && value !== undefined,\n\t\t)\n\t}\n\n\tprivate createUniqueWhereInput(targetEntity: Model.Entity): GraphQLInputObjectType | undefined {\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, targetEntity.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst uniqueWhere = this.whereTypeBuilder.getEntityUniqueWhereType(targetEntity.name)\n\t\tif (!uniqueWhere) {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn uniqueWhere\n\t}\n}\n"],"names":["GraphQLEnumType","Input","schema","GraphQLInputObjectType","GqlTypeName","GraphQLNonNull","GraphQLBoolean","Acl","GraphQLList","GraphQLString","acceptFieldVisitor","filterObject","ImplementationException"],"mappings":";;;;;;;;AAqBA,MAAM,4BAA4B,IAAIA,QAAAA,gBAAgB;AAAA,EACrD,MAAM;AAAA,E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