@contember/engine-content-api 2.2.0-alpha.18 → 2.2.0-alpha.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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/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/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/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 +11 -0
- 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/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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutationProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/MutationProvider.ts"],"sourcesContent":["import { GraphQLBoolean, GraphQLFieldConfig, GraphQLNonNull, GraphQLObjectType, GraphQLObjectTypeConfig, GraphQLString } from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { Context } from '../types.js'\nimport { EntityTypeProvider } from './EntityTypeProvider.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { EntityInputProvider, EntityInputType } from './mutations/index.js'\nimport { filterObject } from '../utils/index.js'\nimport { aliasAwareResolver, GqlTypeName } from './utils.js'\nimport { ResultSchemaTypeProvider } from './ResultSchemaTypeProvider.js'\nimport { ExtensionKey, Operation, OperationMeta } from './OperationExtension.js'\n\ntype FieldConfig<TArgs> = GraphQLFieldConfig<any, Context, TArgs>\n\nexport class MutationProvider {\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly createEntityInputProvider: EntityInputProvider<EntityInputType.create>,\n\t\tprivate readonly updateEntityInputProvider: EntityInputProvider<EntityInputType.update>,\n\t\tprivate readonly resultSchemaTypeProvider: ResultSchemaTypeProvider,\n\t) {}\n\n\tpublic getMutations(entity: Model.Entity): { [fieldName: string]: FieldConfig<any> } {\n\t\tconst entityName = entity.name\n\t\tconst mutations: { [fieldName: string]: FieldConfig<any> | undefined } = {}\n\t\tmutations[`create${entityName}`] = this.getCreateMutation(entity)\n\t\tmutations[`delete${entityName}`] = this.getDeleteMutation(entity)\n\t\tmutations[`update${entityName}`] = this.getUpdateMutation(entity)\n\t\tmutations[`upsert${entityName}`] = this.getUpsertMutation(entity)\n\n\t\treturn filterObject(mutations, (key, value): value is FieldConfig<any> => value !== undefined)\n\t}\n\n\t/**\n\t * Root update, delete and upsert locate their row by a unique lookup that reads in the nested set (root ∪ through).\n\t * Without any read grant there the lookup never finds a row, so the mutation would always fail.\n\t */\n\tprivate isLookupReadable(entity: Model.Entity): boolean {\n\t\treturn this.authorizator.getEntityPermission(Acl.Operation.read, entity.name) !== 'no'\n\t}\n\n\tprotected getCreateMutation(entity: Model.Entity): FieldConfig<Input.CreateInput> | undefined {\n\t\t// Root entry points are gated on the root grants alone - a `through` grant must not open one.\n\t\tif (this.rootAuthorizator.getEntityPermission(Acl.Operation.create, entity.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.createEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'create')\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\n\t\t\targs: {\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.create, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.mutation.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveCreate(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprotected getDeleteMutation(entity: Model.Entity): FieldConfig<Input.DeleteInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tif (entity.view) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (!this.isLookupReadable(entity) || this.rootAuthorizator.getEntityPermission(Acl.Operation.delete, entityName) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.createResultType(entityName, 'delete')),\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.delete, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.mutation.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveDelete(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprotected getUpdateMutation(entity: Model.Entity): FieldConfig<Input.UpdateInput> | undefined {\n\t\tif (!this.isLookupReadable(entity) || this.rootAuthorizator.getEntityPermission(Acl.Operation.update, entity.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'update')\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.update, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveUpdate(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getUpsertMutation(entity: Model.Entity): FieldConfig<Input.UpsertInput> | undefined {\n\t\tif (\n\t\t\t!this.isLookupReadable(entity)\n\t\t\t|| this.rootAuthorizator.getEntityPermission(Acl.Operation.update, entity.name) === 'no'\n\t\t\t|| this.rootAuthorizator.getEntityPermission(Acl.Operation.create, entity.name) === 'no'\n\t\t) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst createInput = this.createEntityInputProvider.getInput(entityName)\n\t\tif (createInput === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst updateInput = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (updateInput === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'upsert')\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\tupdate: { type: new GraphQLNonNull(updateInput) },\n\t\t\t\tcreate: { type: new GraphQLNonNull(createInput) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.upsert, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveUpsert(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate createResultType(\n\t\tentityName: string,\n\t\toperation: 'create' | 'update' | 'delete' | 'upsert',\n\t): GraphQLObjectType {\n\t\tconst fields: GraphQLObjectTypeConfig<any, any>['fields'] = {\n\t\t\tok: { type: new GraphQLNonNull(GraphQLBoolean) },\n\t\t\terrorMessage: { type: GraphQLString },\n\t\t\terrors: { type: this.resultSchemaTypeProvider.errorListResultType },\n\t\t}\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) !== 'no') {\n\t\t\tconst nodeType = this.entityTypeProvider.getEntity(entityName)\n\t\t\tfields.node = { type: nodeType, resolve: aliasAwareResolver }\n\t\t}\n\t\tif (operation !== 'delete') {\n\t\t\tfields.validation = {\n\t\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\t}\n\t\t}\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}${operation}Result`,\n\t\t\tfields: fields,\n\t\t\tinterfaces: [this.resultSchemaTypeProvider.mutationResultType],\n\t\t})\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAcO,MAAM,iBAAiB;AAAA,EAC7B,YACkB,cACA,kBACA,mBACA,oBACA,2BACA,2BACA,0BAChB;AAPgB,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,oBAAA;AACA,SAAA,qBAAA;AACA,SAAA,4BAAA;AACA,SAAA,4BAAA;AACA,SAAA,2BAAA;AAAA,EACf;AAAA,EAEI,aAAa,QAAiE;AACpF,UAAM,aAAa,OAAO;AAC1B,UAAM,YAAmE,CAAA;AACzE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAChE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAChE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAChE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAEhE,WAAO,aAAa,WAAW,CAAC,KAAK,UAAqC,UAAU,MAAS;AAAA,EAC9F;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,iBAAiB,QAA+B;AACvD,WAAO,KAAK,aAAa,oBAAoB,IAAI,UAAU,MAAM,OAAO,IAAI,MAAM;AAAA,EACnF;AAAA,EAEU,kBAAkB,QAAkE;AAE7F,QAAI,KAAK,iBAAiB,oBAAoB,IAAI,UAAU,QAAQ,OAAO,IAAI,MAAM,MAAM;AAC1F,aAAO;AAAA,IACR;AACA,UAAM,aAAa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MAAM,SAAkB,SAAS;AAClD,eAAO,QAAQ,MAAM,WAAW,KAAK,SAAS,IAAI,MAAM;AACvD,cAAI,UAAU,KAAK,MAAM;AACxB,mBAAO,OAAO,KAAK,KAAK,GAAG;AAAA,UAC5B;AACA,iBAAO,QAAQ,mBAAmB,iBAAiB,cAAc,QAAQ,IAAI;AAAA,QAC9E,CAAC;AAAA,MACF;AAAA,IAAA;AAAA,EAEF;AAAA,EAEQ,iBACP,YACA,WACoB;AACpB,UAAM,SAAsD;AAAA,MAC3D,IAAI,EAAE,MAAM,IAAI,eAAe,cAAc,EAAA;AAAA,MAC7C,cAAc,EAAE,MAAM,cAAA;AAAA,MACtB,QAAQ,EAAE,MAAM,KAAK,yBAAyB,oBAAA;AAAA,IAAoB;AAEnE,QAAI,KAAK,aAAa,oBAAoB,IAAI,UAAU,MAAM,UAAU,MAAM,MAAM;AACnF,YAAM,WAAW,KAAK,mBAAmB,UAAU,UAAU;AAC7D,aAAO,OAAO,EAAE,MAAM,UAAU,SAAS,mBAAA;AAAA,IAC1C;AACA,QAAI,cAAc,UAAU;AAC3B,aAAO,aAAa;AAAA,QACnB,MAAM,IAAI,eAAe,KAAK,yBAAyB,oBAAoB;AAAA,MAAA;AAAA,IAE7E;AACA,WAAO,IAAI,kBAAkB;AAAA,MAC5B,MAAM,cAAc,UAAU,GAAG,SAAS;AAAA,MAC1C;AAAA,MACA,YAAY,CAAC,KAAK,yBAAyB,kBAAkB;AAAA,IAAA,CAC7D;AAAA,EACF;AACD;"}
|
|
1
|
+
{"version":3,"file":"MutationProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/MutationProvider.ts"],"sourcesContent":["import { GraphQLBoolean, GraphQLFieldConfig, GraphQLNonNull, GraphQLObjectType, GraphQLObjectTypeConfig, GraphQLString } from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { Context } from '../types.js'\nimport { EntityTypeProvider } from './EntityTypeProvider.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { EntityInputProvider, EntityInputType } from './mutations/index.js'\nimport { filterObject } from '../utils/index.js'\nimport { aliasAwareResolver, GqlTypeName } from './utils.js'\nimport { ResultSchemaTypeProvider } from './ResultSchemaTypeProvider.js'\nimport { ExtensionKey, Operation, OperationMeta } from './OperationExtension.js'\n\ntype FieldConfig<TArgs> = GraphQLFieldConfig<any, Context, TArgs>\n\nexport class MutationProvider {\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly createEntityInputProvider: EntityInputProvider<EntityInputType.create>,\n\t\tprivate readonly updateEntityInputProvider: EntityInputProvider<EntityInputType.update>,\n\t\tprivate readonly resultSchemaTypeProvider: ResultSchemaTypeProvider,\n\t) {}\n\n\tpublic getMutations(entity: Model.Entity): { [fieldName: string]: FieldConfig<any> } {\n\t\tconst entityName = entity.name\n\t\tconst mutations: { [fieldName: string]: FieldConfig<any> | undefined } = {}\n\t\tmutations[`create${entityName}`] = this.getCreateMutation(entity)\n\t\tmutations[`delete${entityName}`] = this.getDeleteMutation(entity)\n\t\tmutations[`update${entityName}`] = this.getUpdateMutation(entity)\n\t\tmutations[`upsert${entityName}`] = this.getUpsertMutation(entity)\n\n\t\treturn filterObject(mutations, (key, value): value is FieldConfig<any> => value !== undefined)\n\t}\n\n\t/**\n\t * Root update, delete and upsert locate their row by a unique lookup that reads in the nested set (root ∪ through).\n\t * Without any read grant there the lookup never finds a row, so the mutation would always fail.\n\t */\n\tprivate isLookupReadable(entity: Model.Entity): boolean {\n\t\treturn this.authorizator.getEntityPermission(Acl.Operation.read, entity.name) !== 'no'\n\t}\n\n\tprotected getCreateMutation(entity: Model.Entity): FieldConfig<Input.CreateInput> | undefined {\n\t\t// Root entry points are gated on the root grants alone - a `through` grant must not open one.\n\t\tif (this.rootAuthorizator.getEntityPermission(Acl.Operation.create, entity.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.createEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'create')\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.create, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.mutation.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveCreate(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprotected getDeleteMutation(entity: Model.Entity): FieldConfig<Input.DeleteInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tif (entity.view) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (!this.isLookupReadable(entity) || this.rootAuthorizator.getEntityPermission(Acl.Operation.delete, entityName) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.createResultType(entityName, 'delete')),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.delete, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.mutation.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveDelete(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprotected getUpdateMutation(entity: Model.Entity): FieldConfig<Input.UpdateInput> | undefined {\n\t\tif (!this.isLookupReadable(entity) || this.rootAuthorizator.getEntityPermission(Acl.Operation.update, entity.name) === 'no') {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'update')\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.update, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveUpdate(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getUpsertMutation(entity: Model.Entity): FieldConfig<Input.UpsertInput> | undefined {\n\t\tif (\n\t\t\t!this.isLookupReadable(entity)\n\t\t\t|| this.rootAuthorizator.getEntityPermission(Acl.Operation.update, entity.name) === 'no'\n\t\t\t|| this.rootAuthorizator.getEntityPermission(Acl.Operation.create, entity.name) === 'no'\n\t\t) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst entityName = entity.name\n\t\tconst createInput = this.createEntityInputProvider.getInput(entityName)\n\t\tif (createInput === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst updateInput = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (updateInput === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst resultType = this.createResultType(entityName, 'upsert')\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(resultType),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\tupdate: { type: new GraphQLNonNull(updateInput) },\n\t\t\t\tcreate: { type: new GraphQLNonNull(createInput) },\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.upsert, entity) },\n\t\t\tresolve: (parent, args, context: Context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.mutationResolver.resolveUpsert(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate createResultType(\n\t\tentityName: string,\n\t\toperation: 'create' | 'update' | 'delete' | 'upsert',\n\t): GraphQLObjectType {\n\t\tconst fields: GraphQLObjectTypeConfig<any, any>['fields'] = {\n\t\t\tok: { type: new GraphQLNonNull(GraphQLBoolean) },\n\t\t\terrorMessage: { type: GraphQLString },\n\t\t\terrors: { type: this.resultSchemaTypeProvider.errorListResultType },\n\t\t}\n\t\tif (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) !== 'no') {\n\t\t\tconst nodeType = this.entityTypeProvider.getEntity(entityName)\n\t\t\tfields.node = { type: nodeType, resolve: aliasAwareResolver }\n\t\t}\n\t\tif (operation !== 'delete') {\n\t\t\tfields.validation = {\n\t\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\t}\n\t\t}\n\t\treturn new GraphQLObjectType({\n\t\t\tname: GqlTypeName`${entityName}${operation}Result`,\n\t\t\tfields: fields,\n\t\t\tinterfaces: [this.resultSchemaTypeProvider.mutationResultType],\n\t\t})\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAcO,MAAM,iBAAiB;AAAA,EAC7B,YACkB,cACA,kBACA,mBACA,oBACA,2BACA,2BACA,0BAChB;AAPgB,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,oBAAA;AACA,SAAA,qBAAA;AACA,SAAA,4BAAA;AACA,SAAA,4BAAA;AACA,SAAA,2BAAA;AAAA,EACf;AAAA,EAEI,aAAa,QAAiE;AACpF,UAAM,aAAa,OAAO;AAC1B,UAAM,YAAmE,CAAA;AACzE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAChE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAChE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAChE,cAAU,SAAS,UAAU,EAAE,IAAI,KAAK,kBAAkB,MAAM;AAEhE,WAAO,aAAa,WAAW,CAAC,KAAK,UAAqC,UAAU,MAAS;AAAA,EAC9F;AAAA;AAAA;A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AAA,MACA,YAAY,CAAC,KAAK,yBAAyB,kBAAkB;AAAA,IAAA,CAC7D;AAAA,EACF;AACD;"}
|
|
@@ -52,9 +52,15 @@ class OrderByTypeProvider {
|
|
|
52
52
|
if (column.list) {
|
|
53
53
|
return void 0;
|
|
54
54
|
}
|
|
55
|
-
return {
|
|
55
|
+
return {
|
|
56
|
+
type: this.orderDirectionEnum,
|
|
57
|
+
description: utils.inputFieldDescription(column)
|
|
58
|
+
};
|
|
56
59
|
},
|
|
57
|
-
visitHasOne: ({ relation }) => ({
|
|
60
|
+
visitHasOne: ({ relation }) => ({
|
|
61
|
+
type: this.getEntityOrderByType(relation.target),
|
|
62
|
+
description: utils.inputFieldDescription(relation)
|
|
63
|
+
}),
|
|
58
64
|
visitHasMany: () => void 0
|
|
59
65
|
});
|
|
60
66
|
if (field !== void 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderByTypeProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/OrderByTypeProvider.ts"],"sourcesContent":["import {\n\tGraphQLBoolean,\n\tGraphQLEnumType,\n\tGraphQLInputFieldConfig,\n\tGraphQLInputFieldConfigMap,\n\tGraphQLInputObjectType,\n\tGraphQLInputType,\n\tGraphQLInt,\n} from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { singletonFactory } from '../utils/index.js'\nimport { GqlTypeName } from './utils.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\n\nexport class OrderByTypeProvider {\n\tprivate orderBySingleton = singletonFactory(name => this.createEntityOrderByType(name))\n\n\tprivate orderDirectionEnum = new GraphQLEnumType({\n\t\tname: 'OrderDirection',\n\t\tvalues: {\n\t\t\tasc: { value: 'asc' },\n\t\t\tdesc: { value: 'desc' },\n\t\t\tascNullsFirst: { value: 'ascNullsFirst' },\n\t\t\tdescNullsLast: { value: 'descNullsLast' },\n\t\t},\n\t})\n\n\tconstructor(private readonly schema: Model.Schema, private readonly authorizator: Authorizator) {}\n\n\tpublic getEntityOrderByType(entityName: string): GraphQLInputType {\n\t\treturn this.orderBySingleton(entityName)\n\t}\n\n\tprivate createEntityOrderByType(entityName: string): GraphQLInputType {\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entityName}OrderBy`,\n\t\t\tfields: () => this.getEntityOrderByFields(entityName),\n\t\t})\n\t}\n\n\tprivate getEntityOrderByFields(name: string) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {\n\t\t\t_random: { type: GraphQLBoolean },\n\t\t\t_randomSeeded: { type: GraphQLInt },\n\t\t}\n\t\tconst entity = this.schema.entities[name]\n\n\t\tfor (const fieldName in entity.fields) {\n\t\t\tif (!entity.fields.hasOwnProperty(fieldName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\t\tif (!acceptFieldVisitor(this.schema, name, fieldName, accessVisitor)) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst field = acceptFieldVisitor(this.schema, name, fieldName, {\n\t\t\t\tvisitColumn: ({ column }) => {\n\t\t\t\t\tif (column.list) {\n\t\t\t\t\t\treturn undefined\n\t\t\t\t\t}\n\t\t\t\t\treturn
|
|
1
|
+
{"version":3,"file":"OrderByTypeProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/OrderByTypeProvider.ts"],"sourcesContent":["import {\n\tGraphQLBoolean,\n\tGraphQLEnumType,\n\tGraphQLInputFieldConfig,\n\tGraphQLInputFieldConfigMap,\n\tGraphQLInputObjectType,\n\tGraphQLInputType,\n\tGraphQLInt,\n} from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { singletonFactory } from '../utils/index.js'\nimport { GqlTypeName, inputFieldDescription } from './utils.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\n\nexport class OrderByTypeProvider {\n\tprivate orderBySingleton = singletonFactory(name => this.createEntityOrderByType(name))\n\n\tprivate orderDirectionEnum = new GraphQLEnumType({\n\t\tname: 'OrderDirection',\n\t\tvalues: {\n\t\t\tasc: { value: 'asc' },\n\t\t\tdesc: { value: 'desc' },\n\t\t\tascNullsFirst: { value: 'ascNullsFirst' },\n\t\t\tdescNullsLast: { value: 'descNullsLast' },\n\t\t},\n\t})\n\n\tconstructor(private readonly schema: Model.Schema, private readonly authorizator: Authorizator) {}\n\n\tpublic getEntityOrderByType(entityName: string): GraphQLInputType {\n\t\treturn this.orderBySingleton(entityName)\n\t}\n\n\tprivate createEntityOrderByType(entityName: string): GraphQLInputType {\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entityName}OrderBy`,\n\t\t\tfields: () => this.getEntityOrderByFields(entityName),\n\t\t})\n\t}\n\n\tprivate getEntityOrderByFields(name: string) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {\n\t\t\t_random: { type: GraphQLBoolean },\n\t\t\t_randomSeeded: { type: GraphQLInt },\n\t\t}\n\t\tconst entity = this.schema.entities[name]\n\n\t\tfor (const fieldName in entity.fields) {\n\t\t\tif (!entity.fields.hasOwnProperty(fieldName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\t\tif (!acceptFieldVisitor(this.schema, name, fieldName, accessVisitor)) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst field = acceptFieldVisitor(this.schema, name, fieldName, {\n\t\t\t\tvisitColumn: ({ column }) => {\n\t\t\t\t\tif (column.list) {\n\t\t\t\t\t\treturn undefined\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: this.orderDirectionEnum,\n\t\t\t\t\t\tdescription: inputFieldDescription(column),\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tvisitHasOne: ({ relation }) => ({\n\t\t\t\t\ttype: this.getEntityOrderByType(relation.target),\n\t\t\t\t\tdescription: inputFieldDescription(relation),\n\t\t\t\t}),\n\t\t\t\tvisitHasMany: () => undefined,\n\t\t\t} as Model.FieldVisitor<GraphQLInputFieldConfig | undefined>)\n\n\t\t\tif (field !== undefined) {\n\t\t\t\tfields[fieldName] = field\n\t\t\t}\n\t\t}\n\n\t\treturn fields\n\t}\n}\n"],"names":["schema","singletonFactory","GraphQLEnumType","GraphQLInputObjectType","GqlTypeName","GraphQLBoolean","GraphQLInt","FieldAccessVisitor","Acl","acceptFieldVisitor","inputFieldDescription"],"mappings":";;;;;;;;;;;AAgBO,MAAM,oBAAoB;AAAA,EAahC,YAA6BA,SAAuC,cAA4B;AAAnE,SAAA,SAAAA;AAAuC,SAAA,eAAA;AAZpE,kBAAA,MAAQ,oBAAmBC,kCAAiB,CAAA,SAAQ,KAAK,wBAAwB,IAAI,CAAC,CAAA;AAEtF,kBAAA,MAAQ,sBAAqB,IAAIC,wBAAgB;AAAA,MAChD,MAAM;AAAA,MACN,QAAQ;AAAA,QACP,KAAK,EAAE,OAAO,MAAA;AAAA,QACd,MAAM,EAAE,OAAO,OAAA;AAAA,QACf,eAAe,EAAE,OAAO,gBAAA;AAAA,QACxB,eAAe,EAAE,OAAO,gBAAA;AAAA,MAAgB;AAAA,IACzC,CACA,CAAA;AAAA,EAEgG;AAAA,EAE1F,qBAAqB,YAAsC;AACjE,WAAO,KAAK,iBAAiB,UAAU;AAAA,EACxC;AAAA,EAEQ,wBAAwB,YAAsC;AACrE,WAAO,IAAIC,QAAAA,uBAAuB;AAAA,MACjC,MAAMC,MAAAA,cAAc,UAAU;AAAA,MAC9B,QAAQ,MAAM,KAAK,uBAAuB,UAAU;AAAA,IAAA,CACpD;AAAA,EACF;AAAA,EAEQ,uBAAuB,MAAc;AAC5C,UAAM,SAAqC;AAAA,MAC1C,SAAS,EAAE,MAAMC,uBAAA;AAAA,MACjB,eAAe,EAAE,MAAMC,QAAAA,WAAA;AAAA,IAAW;AAEnC,UAAM,SAAS,KAAK,OAAO,SAAS,IAAI;AAExC,eAAW,aAAa,OAAO,QAAQ;AACtC,UAAI,CAAC,OAAO,OAAO,eAAe,SAAS,GAAG;AAC7C;AAAA,MACD;AACA,YAAM,gBAAgB,IAAIC,sCAAmBC,OAAAA,IAAI,UAAU,MAAM,KAAK,YAAY;AAClF,UAAI,CAACC,YAAAA,mBAAmB,KAAK,QAAQ,MAAM,WAAW,aAAa,GAAG;AACrE;AAAA,MACD;AAEA,YAAM,QAAQA,YAAAA,mBAAmB,KAAK,QAAQ,MAAM,WAAW;AAAA,QAC9D,aAAa,CAAC,EAAE,aAAa;AAC5B,cAAI,OAAO,MAAM;AAChB,mBAAO;AAAA,UACR;AACA,iBAAO;AAAA,YACN,MAAM,KAAK;AAAA,YACX,aAAaC,MAAAA,sBAAsB,MAAM;AAAA,UAAA;AAAA,QAE3C;AAAA,QACA,aAAa,CAAC,EAAE,gBAAgB;AAAA,UAC/B,MAAM,KAAK,qBAAqB,SAAS,MAAM;AAAA,UAC/C,aAAaA,MAAAA,sBAAsB,QAAQ;AAAA,QAAA;AAAA,QAE5C,cAAc,MAAM;AAAA,MAAA,CACuC;AAE5D,UAAI,UAAU,QAAW;AACxB,eAAO,SAAS,IAAI;AAAA,MACrB;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AACD;;"}
|
|
@@ -2,7 +2,7 @@ import { GraphQLEnumType, GraphQLInputObjectType, GraphQLInt, GraphQLBoolean } f
|
|
|
2
2
|
import { Acl } from "@contember/schema";
|
|
3
3
|
import { acceptFieldVisitor } from "@contember/schema-utils";
|
|
4
4
|
import { singletonFactory } from "../utils/singletonFactory.js";
|
|
5
|
-
import { GqlTypeName } from "./utils.js";
|
|
5
|
+
import { GqlTypeName, inputFieldDescription } from "./utils.js";
|
|
6
6
|
import { FieldAccessVisitor } from "./FieldAccessVisitor.js";
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
8
8
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -50,9 +50,15 @@ class OrderByTypeProvider {
|
|
|
50
50
|
if (column.list) {
|
|
51
51
|
return void 0;
|
|
52
52
|
}
|
|
53
|
-
return {
|
|
53
|
+
return {
|
|
54
|
+
type: this.orderDirectionEnum,
|
|
55
|
+
description: inputFieldDescription(column)
|
|
56
|
+
};
|
|
54
57
|
},
|
|
55
|
-
visitHasOne: ({ relation }) => ({
|
|
58
|
+
visitHasOne: ({ relation }) => ({
|
|
59
|
+
type: this.getEntityOrderByType(relation.target),
|
|
60
|
+
description: inputFieldDescription(relation)
|
|
61
|
+
}),
|
|
56
62
|
visitHasMany: () => void 0
|
|
57
63
|
});
|
|
58
64
|
if (field !== void 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderByTypeProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/OrderByTypeProvider.ts"],"sourcesContent":["import {\n\tGraphQLBoolean,\n\tGraphQLEnumType,\n\tGraphQLInputFieldConfig,\n\tGraphQLInputFieldConfigMap,\n\tGraphQLInputObjectType,\n\tGraphQLInputType,\n\tGraphQLInt,\n} from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { singletonFactory } from '../utils/index.js'\nimport { GqlTypeName } from './utils.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\n\nexport class OrderByTypeProvider {\n\tprivate orderBySingleton = singletonFactory(name => this.createEntityOrderByType(name))\n\n\tprivate orderDirectionEnum = new GraphQLEnumType({\n\t\tname: 'OrderDirection',\n\t\tvalues: {\n\t\t\tasc: { value: 'asc' },\n\t\t\tdesc: { value: 'desc' },\n\t\t\tascNullsFirst: { value: 'ascNullsFirst' },\n\t\t\tdescNullsLast: { value: 'descNullsLast' },\n\t\t},\n\t})\n\n\tconstructor(private readonly schema: Model.Schema, private readonly authorizator: Authorizator) {}\n\n\tpublic getEntityOrderByType(entityName: string): GraphQLInputType {\n\t\treturn this.orderBySingleton(entityName)\n\t}\n\n\tprivate createEntityOrderByType(entityName: string): GraphQLInputType {\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entityName}OrderBy`,\n\t\t\tfields: () => this.getEntityOrderByFields(entityName),\n\t\t})\n\t}\n\n\tprivate getEntityOrderByFields(name: string) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {\n\t\t\t_random: { type: GraphQLBoolean },\n\t\t\t_randomSeeded: { type: GraphQLInt },\n\t\t}\n\t\tconst entity = this.schema.entities[name]\n\n\t\tfor (const fieldName in entity.fields) {\n\t\t\tif (!entity.fields.hasOwnProperty(fieldName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\t\tif (!acceptFieldVisitor(this.schema, name, fieldName, accessVisitor)) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst field = acceptFieldVisitor(this.schema, name, fieldName, {\n\t\t\t\tvisitColumn: ({ column }) => {\n\t\t\t\t\tif (column.list) {\n\t\t\t\t\t\treturn undefined\n\t\t\t\t\t}\n\t\t\t\t\treturn
|
|
1
|
+
{"version":3,"file":"OrderByTypeProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/OrderByTypeProvider.ts"],"sourcesContent":["import {\n\tGraphQLBoolean,\n\tGraphQLEnumType,\n\tGraphQLInputFieldConfig,\n\tGraphQLInputFieldConfigMap,\n\tGraphQLInputObjectType,\n\tGraphQLInputType,\n\tGraphQLInt,\n} from 'graphql'\nimport { Acl, Model } from '@contember/schema'\nimport { acceptFieldVisitor } from '@contember/schema-utils'\nimport { singletonFactory } from '../utils/index.js'\nimport { GqlTypeName, inputFieldDescription } from './utils.js'\nimport { Authorizator } from '../acl/index.js'\nimport { FieldAccessVisitor } from './FieldAccessVisitor.js'\n\nexport class OrderByTypeProvider {\n\tprivate orderBySingleton = singletonFactory(name => this.createEntityOrderByType(name))\n\n\tprivate orderDirectionEnum = new GraphQLEnumType({\n\t\tname: 'OrderDirection',\n\t\tvalues: {\n\t\t\tasc: { value: 'asc' },\n\t\t\tdesc: { value: 'desc' },\n\t\t\tascNullsFirst: { value: 'ascNullsFirst' },\n\t\t\tdescNullsLast: { value: 'descNullsLast' },\n\t\t},\n\t})\n\n\tconstructor(private readonly schema: Model.Schema, private readonly authorizator: Authorizator) {}\n\n\tpublic getEntityOrderByType(entityName: string): GraphQLInputType {\n\t\treturn this.orderBySingleton(entityName)\n\t}\n\n\tprivate createEntityOrderByType(entityName: string): GraphQLInputType {\n\t\treturn new GraphQLInputObjectType({\n\t\t\tname: GqlTypeName`${entityName}OrderBy`,\n\t\t\tfields: () => this.getEntityOrderByFields(entityName),\n\t\t})\n\t}\n\n\tprivate getEntityOrderByFields(name: string) {\n\t\tconst fields: GraphQLInputFieldConfigMap = {\n\t\t\t_random: { type: GraphQLBoolean },\n\t\t\t_randomSeeded: { type: GraphQLInt },\n\t\t}\n\t\tconst entity = this.schema.entities[name]\n\n\t\tfor (const fieldName in entity.fields) {\n\t\t\tif (!entity.fields.hasOwnProperty(fieldName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst accessVisitor = new FieldAccessVisitor(Acl.Operation.read, this.authorizator)\n\t\t\tif (!acceptFieldVisitor(this.schema, name, fieldName, accessVisitor)) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst field = acceptFieldVisitor(this.schema, name, fieldName, {\n\t\t\t\tvisitColumn: ({ column }) => {\n\t\t\t\t\tif (column.list) {\n\t\t\t\t\t\treturn undefined\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: this.orderDirectionEnum,\n\t\t\t\t\t\tdescription: inputFieldDescription(column),\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tvisitHasOne: ({ relation }) => ({\n\t\t\t\t\ttype: this.getEntityOrderByType(relation.target),\n\t\t\t\t\tdescription: inputFieldDescription(relation),\n\t\t\t\t}),\n\t\t\t\tvisitHasMany: () => undefined,\n\t\t\t} as Model.FieldVisitor<GraphQLInputFieldConfig | undefined>)\n\n\t\t\tif (field !== undefined) {\n\t\t\t\tfields[fieldName] = field\n\t\t\t}\n\t\t}\n\n\t\treturn fields\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;AAgBO,MAAM,oBAAoB;AAAA,EAahC,YAA6B,QAAuC,cAA4B;AAAnE,SAAA,SAAA;AAAuC,SAAA,eAAA;AAZpE,kBAAA,MAAQ,oBAAmB,iBAAiB,CAAA,SAAQ,KAAK,wBAAwB,IAAI,CAAC,CAAA;AAEtF,kBAAA,MAAQ,sBAAqB,IAAI,gBAAgB;AAAA,MAChD,MAAM;AAAA,MACN,QAAQ;AAAA,QACP,KAAK,EAAE,OAAO,MAAA;AAAA,QACd,MAAM,EAAE,OAAO,OAAA;AAAA,QACf,eAAe,EAAE,OAAO,gBAAA;AAAA,QACxB,eAAe,EAAE,OAAO,gBAAA;AAAA,MAAgB;AAAA,IACzC,CACA,CAAA;AAAA,EAEgG;AAAA,EAE1F,qBAAqB,YAAsC;AACjE,WAAO,KAAK,iBAAiB,UAAU;AAAA,EACxC;AAAA,EAEQ,wBAAwB,YAAsC;AACrE,WAAO,IAAI,uBAAuB;AAAA,MACjC,MAAM,cAAc,UAAU;AAAA,MAC9B,QAAQ,MAAM,KAAK,uBAAuB,UAAU;AAAA,IAAA,CACpD;AAAA,EACF;AAAA,EAEQ,uBAAuB,MAAc;AAC5C,UAAM,SAAqC;AAAA,MAC1C,SAAS,EAAE,MAAM,eAAA;AAAA,MACjB,eAAe,EAAE,MAAM,WAAA;AAAA,IAAW;AAEnC,UAAM,SAAS,KAAK,OAAO,SAAS,IAAI;AAExC,eAAW,aAAa,OAAO,QAAQ;AACtC,UAAI,CAAC,OAAO,OAAO,eAAe,SAAS,GAAG;AAC7C;AAAA,MACD;AACA,YAAM,gBAAgB,IAAI,mBAAmB,IAAI,UAAU,MAAM,KAAK,YAAY;AAClF,UAAI,CAAC,mBAAmB,KAAK,QAAQ,MAAM,WAAW,aAAa,GAAG;AACrE;AAAA,MACD;AAEA,YAAM,QAAQ,mBAAmB,KAAK,QAAQ,MAAM,WAAW;AAAA,QAC9D,aAAa,CAAC,EAAE,aAAa;AAC5B,cAAI,OAAO,MAAM;AAChB,mBAAO;AAAA,UACR;AACA,iBAAO;AAAA,YACN,MAAM,KAAK;AAAA,YACX,aAAa,sBAAsB,MAAM;AAAA,UAAA;AAAA,QAE3C;AAAA,QACA,aAAa,CAAC,EAAE,gBAAgB;AAAA,UAC/B,MAAM,KAAK,qBAAqB,SAAS,MAAM;AAAA,UAC/C,aAAa,sBAAsB,QAAQ;AAAA,QAAA;AAAA,QAE5C,cAAc,MAAM;AAAA,MAAA,CACuC;AAE5D,UAAI,UAAU,QAAW;AACxB,eAAO,SAAS,IAAI;AAAA,MACrB;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AACD;"}
|
|
@@ -32,6 +32,7 @@ class QueryProvider {
|
|
|
32
32
|
}
|
|
33
33
|
return {
|
|
34
34
|
type: entityType,
|
|
35
|
+
deprecationReason: entity.deprecationReason,
|
|
35
36
|
args: {
|
|
36
37
|
by: {
|
|
37
38
|
type: new graphql.GraphQLNonNull(uniqueWhere)
|
|
@@ -56,6 +57,7 @@ class QueryProvider {
|
|
|
56
57
|
const entityType = this.entityTypeProvider.getEntity(entityName);
|
|
57
58
|
return {
|
|
58
59
|
type: new graphql.GraphQLNonNull(new graphql.GraphQLList(new graphql.GraphQLNonNull(entityType))),
|
|
60
|
+
deprecationReason: entity.deprecationReason,
|
|
59
61
|
args: {
|
|
60
62
|
filter: {
|
|
61
63
|
type: this.whereTypeProvider.getEntityWhereType(entityName)
|
|
@@ -84,6 +86,7 @@ class QueryProvider {
|
|
|
84
86
|
getPaginationQuery(entity) {
|
|
85
87
|
return {
|
|
86
88
|
...this.paginatedFieldConfigFactory.createFieldConfig(entity),
|
|
89
|
+
deprecationReason: entity.deprecationReason,
|
|
87
90
|
extensions: { [OperationExtension.ExtensionKey]: new OperationExtension.OperationMeta(OperationExtension.Operation.paginate, entity) },
|
|
88
91
|
resolve: (parent, args, context, info) => {
|
|
89
92
|
return context.timer(`GraphQL.query.${info.fieldName}`, () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/QueryProvider.ts"],"sourcesContent":["import { GraphQLFieldConfig, GraphQLInt, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { Context } from '../types.js'\nimport { EntityTypeProvider } from './EntityTypeProvider.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { OrderByTypeProvider } from './OrderByTypeProvider.js'\nimport { ExtensionKey, Operation, OperationMeta } from './OperationExtension.js'\nimport { ImplementationException } from '../exception.js'\nimport { PaginatedFieldConfigFactory } from './PaginatedFieldConfigFactory.js'\n\nexport class QueryProvider {\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly orderByTypeProvider: OrderByTypeProvider,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly paginatedFieldConfigFactory: PaginatedFieldConfigFactory,\n\t) {}\n\n\tpublic getQueries(entity: Model.Entity): { [fieldName: string]: GraphQLFieldConfig<any, Context, any> } {\n\t\t// Root entry points are gated on the root grants alone; `through` grants exist to apply only\n\t\t// when the entity is reached over a relation, so they must not open a root query.\n\t\tif (this.rootAuthorizator.getEntityPermission(Acl.Operation.read, entity.name) === 'no') {\n\t\t\treturn {}\n\t\t}\n\t\treturn {\n\t\t\t['get' + entity.name]: this.getByUniqueQuery(entity),\n\t\t\t['list' + entity.name]: this.getListQuery(entity),\n\t\t\t['paginate' + entity.name]: this.getPaginationQuery(entity),\n\t\t}\n\t}\n\n\tprivate getByUniqueQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.UniqueQueryInput> {\n\t\tconst entityName = entity.name\n\t\tconst entityType = this.entityTypeProvider.getEntity(entityName)\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn {\n\t\t\ttype: entityType,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.get, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolveGetQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getListQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.ListQueryInput> {\n\t\tconst entityName = entity.name\n\n\t\tconst entityType = this.entityTypeProvider.getEntity(entityName)\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(entityType))),\n\t\t\targs: {\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\torderBy: {\n\t\t\t\t\ttype: new GraphQLList(new GraphQLNonNull(this.orderByTypeProvider.getEntityOrderByType(entityName))),\n\t\t\t\t},\n\t\t\t\toffset: {\n\t\t\t\t\ttype: GraphQLInt,\n\t\t\t\t},\n\t\t\t\tlimit: {\n\t\t\t\t\ttype: GraphQLInt,\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.list, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolveListQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getPaginationQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.ListQueryInput> {\n\t\treturn {\n\t\t\t...this.paginatedFieldConfigFactory.createFieldConfig(entity),\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.paginate, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolvePaginationQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":["Acl","ImplementationException","GraphQLNonNull","ExtensionKey","OperationMeta","Operation","GraphQLList","GraphQLInt"],"mappings":";;;;;;AAWO,MAAM,cAAc;AAAA,EAC1B,YACkB,cACA,kBACA,mBACA,qBACA,oBACA,6BAChB;AANgB,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,oBAAA;AACA,SAAA,sBAAA;AACA,SAAA,qBAAA;AACA,SAAA,8BAAA;AAAA,EACf;AAAA,EAEI,WAAW,QAAsF;AAGvG,QAAI,KAAK,iBAAiB,oBAAoBA,OAAAA,IAAI,UAAU,MAAM,OAAO,IAAI,MAAM,MAAM;AACxF,aAAO,CAAA;AAAA,IACR;AACA,WAAO;AAAA,MACN,CAAC,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ueryProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/QueryProvider.ts"],"sourcesContent":["import { GraphQLFieldConfig, GraphQLInt, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { Context } from '../types.js'\nimport { EntityTypeProvider } from './EntityTypeProvider.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { OrderByTypeProvider } from './OrderByTypeProvider.js'\nimport { ExtensionKey, Operation, OperationMeta } from './OperationExtension.js'\nimport { ImplementationException } from '../exception.js'\nimport { PaginatedFieldConfigFactory } from './PaginatedFieldConfigFactory.js'\n\nexport class QueryProvider {\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly orderByTypeProvider: OrderByTypeProvider,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly paginatedFieldConfigFactory: PaginatedFieldConfigFactory,\n\t) {}\n\n\tpublic getQueries(entity: Model.Entity): { [fieldName: string]: GraphQLFieldConfig<any, Context, any> } {\n\t\t// Root entry points are gated on the root grants alone; `through` grants exist to apply only\n\t\t// when the entity is reached over a relation, so they must not open a root query.\n\t\tif (this.rootAuthorizator.getEntityPermission(Acl.Operation.read, entity.name) === 'no') {\n\t\t\treturn {}\n\t\t}\n\t\treturn {\n\t\t\t['get' + entity.name]: this.getByUniqueQuery(entity),\n\t\t\t['list' + entity.name]: this.getListQuery(entity),\n\t\t\t['paginate' + entity.name]: this.getPaginationQuery(entity),\n\t\t}\n\t}\n\n\tprivate getByUniqueQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.UniqueQueryInput> {\n\t\tconst entityName = entity.name\n\t\tconst entityType = this.entityTypeProvider.getEntity(entityName)\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn {\n\t\t\ttype: entityType,\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.get, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolveGetQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getListQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.ListQueryInput> {\n\t\tconst entityName = entity.name\n\n\t\tconst entityType = this.entityTypeProvider.getEntity(entityName)\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(entityType))),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\torderBy: {\n\t\t\t\t\ttype: new GraphQLList(new GraphQLNonNull(this.orderByTypeProvider.getEntityOrderByType(entityName))),\n\t\t\t\t},\n\t\t\t\toffset: {\n\t\t\t\t\ttype: GraphQLInt,\n\t\t\t\t},\n\t\t\t\tlimit: {\n\t\t\t\t\ttype: GraphQLInt,\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.list, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolveListQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getPaginationQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.ListQueryInput> {\n\t\treturn {\n\t\t\t...this.paginatedFieldConfigFactory.createFieldConfig(entity),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.paginate, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolvePaginationQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":["Acl","ImplementationException","GraphQLNonNull","ExtensionKey","OperationMeta","Operation","GraphQLList","GraphQLInt"],"mappings":";;;;;;AAWO,MAAM,cAAc;AAAA,EAC1B,YACkB,cACA,kBACA,mBACA,qBACA,oBACA,6BAChB;AANgB,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,oBAAA;AACA,SAAA,sBAAA;AACA,SAAA,qBAAA;AACA,SAAA,8BAAA;AAAA,EACf;AAAA,EAEI,WAAW,QAAsF;AAGvG,QAAI,KAAK,iBAAiB,oBAAoBA,OAAAA,IAAI,UAAU,MAAM,OAAO,IAAI,MAAM,MAAM;AACxF,aAAO,CAAA;AAAA,IACR;AACA,WAAO;AAAA,MACN,CAAC,QAAQ,OAAO,IAAI,GAAG,KAAK,iBAAiB,MAAM;AAAA,MACnD,CAAC,SAAS,OAAO,IAAI,GAAG,KAAK,aAAa,MAAM;AAAA,MAChD,CAAC,aAAa,OAAO,IAAI,GAAG,KAAK,mBAAmB,MAAM;AAAA,IAAA;AA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
33
34
|
args: {
|
|
34
35
|
by: {
|
|
35
36
|
type: new GraphQLNonNull(uniqueWhere)
|
|
@@ -54,6 +55,7 @@ class QueryProvider {
|
|
|
54
55
|
const entityType = this.entityTypeProvider.getEntity(entityName);
|
|
55
56
|
return {
|
|
56
57
|
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(entityType))),
|
|
58
|
+
deprecationReason: entity.deprecationReason,
|
|
57
59
|
args: {
|
|
58
60
|
filter: {
|
|
59
61
|
type: this.whereTypeProvider.getEntityWhereType(entityName)
|
|
@@ -82,6 +84,7 @@ class QueryProvider {
|
|
|
82
84
|
getPaginationQuery(entity) {
|
|
83
85
|
return {
|
|
84
86
|
...this.paginatedFieldConfigFactory.createFieldConfig(entity),
|
|
87
|
+
deprecationReason: entity.deprecationReason,
|
|
85
88
|
extensions: { [ExtensionKey]: new OperationMeta(Operation.paginate, entity) },
|
|
86
89
|
resolve: (parent, args, context, info) => {
|
|
87
90
|
return context.timer(`GraphQL.query.${info.fieldName}`, () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/QueryProvider.ts"],"sourcesContent":["import { GraphQLFieldConfig, GraphQLInt, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { Context } from '../types.js'\nimport { EntityTypeProvider } from './EntityTypeProvider.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { OrderByTypeProvider } from './OrderByTypeProvider.js'\nimport { ExtensionKey, Operation, OperationMeta } from './OperationExtension.js'\nimport { ImplementationException } from '../exception.js'\nimport { PaginatedFieldConfigFactory } from './PaginatedFieldConfigFactory.js'\n\nexport class QueryProvider {\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly orderByTypeProvider: OrderByTypeProvider,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly paginatedFieldConfigFactory: PaginatedFieldConfigFactory,\n\t) {}\n\n\tpublic getQueries(entity: Model.Entity): { [fieldName: string]: GraphQLFieldConfig<any, Context, any> } {\n\t\t// Root entry points are gated on the root grants alone; `through` grants exist to apply only\n\t\t// when the entity is reached over a relation, so they must not open a root query.\n\t\tif (this.rootAuthorizator.getEntityPermission(Acl.Operation.read, entity.name) === 'no') {\n\t\t\treturn {}\n\t\t}\n\t\treturn {\n\t\t\t['get' + entity.name]: this.getByUniqueQuery(entity),\n\t\t\t['list' + entity.name]: this.getListQuery(entity),\n\t\t\t['paginate' + entity.name]: this.getPaginationQuery(entity),\n\t\t}\n\t}\n\n\tprivate getByUniqueQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.UniqueQueryInput> {\n\t\tconst entityName = entity.name\n\t\tconst entityType = this.entityTypeProvider.getEntity(entityName)\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn {\n\t\t\ttype: entityType,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.get, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolveGetQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getListQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.ListQueryInput> {\n\t\tconst entityName = entity.name\n\n\t\tconst entityType = this.entityTypeProvider.getEntity(entityName)\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(entityType))),\n\t\t\targs: {\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\torderBy: {\n\t\t\t\t\ttype: new GraphQLList(new GraphQLNonNull(this.orderByTypeProvider.getEntityOrderByType(entityName))),\n\t\t\t\t},\n\t\t\t\toffset: {\n\t\t\t\t\ttype: GraphQLInt,\n\t\t\t\t},\n\t\t\t\tlimit: {\n\t\t\t\t\ttype: GraphQLInt,\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.list, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolveListQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getPaginationQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.ListQueryInput> {\n\t\treturn {\n\t\t\t...this.paginatedFieldConfigFactory.createFieldConfig(entity),\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.paginate, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolvePaginationQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;AAWO,MAAM,cAAc;AAAA,EAC1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AAK,MAAM;AACxB,mBAAO,OAAO,KAAK,KAAK,GAAG;AAAA,UAC5B;AACA,iBAAO,QAAQ,mBAAmB,aAAa,uBAAuB,QAAQ,IAAI;AAAA,QACnF,CAAC;AAAA,MACF;AAAA,IAAA;AAAA,EAEF;AACD;"}
|
|
1
|
+
{"version":3,"file":"QueryProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/QueryProvider.ts"],"sourcesContent":["import { GraphQLFieldConfig, GraphQLInt, GraphQLList, GraphQLNonNull } from 'graphql'\nimport { Acl, Input, Model } from '@contember/schema'\nimport { Context } from '../types.js'\nimport { EntityTypeProvider } from './EntityTypeProvider.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { Authorizator } from '../acl/index.js'\nimport { OrderByTypeProvider } from './OrderByTypeProvider.js'\nimport { ExtensionKey, Operation, OperationMeta } from './OperationExtension.js'\nimport { ImplementationException } from '../exception.js'\nimport { PaginatedFieldConfigFactory } from './PaginatedFieldConfigFactory.js'\n\nexport class QueryProvider {\n\tconstructor(\n\t\tprivate readonly authorizator: Authorizator,\n\t\tprivate readonly rootAuthorizator: Authorizator,\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly orderByTypeProvider: OrderByTypeProvider,\n\t\tprivate readonly entityTypeProvider: EntityTypeProvider,\n\t\tprivate readonly paginatedFieldConfigFactory: PaginatedFieldConfigFactory,\n\t) {}\n\n\tpublic getQueries(entity: Model.Entity): { [fieldName: string]: GraphQLFieldConfig<any, Context, any> } {\n\t\t// Root entry points are gated on the root grants alone; `through` grants exist to apply only\n\t\t// when the entity is reached over a relation, so they must not open a root query.\n\t\tif (this.rootAuthorizator.getEntityPermission(Acl.Operation.read, entity.name) === 'no') {\n\t\t\treturn {}\n\t\t}\n\t\treturn {\n\t\t\t['get' + entity.name]: this.getByUniqueQuery(entity),\n\t\t\t['list' + entity.name]: this.getListQuery(entity),\n\t\t\t['paginate' + entity.name]: this.getPaginationQuery(entity),\n\t\t}\n\t}\n\n\tprivate getByUniqueQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.UniqueQueryInput> {\n\t\tconst entityName = entity.name\n\t\tconst entityType = this.entityTypeProvider.getEntity(entityName)\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\t\treturn {\n\t\t\ttype: entityType,\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.get, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolveGetQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getListQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.ListQueryInput> {\n\t\tconst entityName = entity.name\n\n\t\tconst entityType = this.entityTypeProvider.getEntity(entityName)\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(entityType))),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tfilter: {\n\t\t\t\t\ttype: this.whereTypeProvider.getEntityWhereType(entityName),\n\t\t\t\t},\n\t\t\t\torderBy: {\n\t\t\t\t\ttype: new GraphQLList(new GraphQLNonNull(this.orderByTypeProvider.getEntityOrderByType(entityName))),\n\t\t\t\t},\n\t\t\t\toffset: {\n\t\t\t\t\ttype: GraphQLInt,\n\t\t\t\t},\n\t\t\t\tlimit: {\n\t\t\t\t\ttype: GraphQLInt,\n\t\t\t\t},\n\t\t\t},\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.list, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolveListQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate getPaginationQuery(entity: Model.Entity): GraphQLFieldConfig<any, Context, Input.ListQueryInput> {\n\t\treturn {\n\t\t\t...this.paginatedFieldConfigFactory.createFieldConfig(entity),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\textensions: { [ExtensionKey]: new OperationMeta(Operation.paginate, entity) },\n\t\t\tresolve: (parent, args, context, info) => {\n\t\t\t\treturn context.timer(`GraphQL.query.${info.fieldName}`, () => {\n\t\t\t\t\tif (parent && info.path) {\n\t\t\t\t\t\treturn parent[info.path.key]\n\t\t\t\t\t}\n\t\t\t\t\treturn context.executionContainer.readResolver.resolvePaginationQuery(entity, info)\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;AAWO,MAAM,cAAc;AAAA,EAC1B,YACkB,cACA,kBACA,mBACA,qBACA,oBACA,6BAChB;AANgB,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,oBAAA;AACA,SAAA,sBAAA;AACA,SAAA,qBAAA;AACA,SAAA,8BAAA;AAAA,EACf;AAAA,EAEI,WAAW,QAAsF;AAGvG,QAAI,KAAK,iBAAiB,oBAAoB,IAAI,UAAU,MAAM,OAAO,IAAI,MAAM,MAAM;AACxF,aAAO,CAAA;AAAA,IACR;AACA,WAAO;AAAA,MACN,CAAC,QAAQ,OAAO,IAAI,GAAG,KAAK,iBAAiB,MAAM;AAAA,MACnD,C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ider.validationResultType),
|
|
28
|
+
deprecationReason: entity.deprecationReason,
|
|
28
29
|
args: {
|
|
29
30
|
data: { type: new graphql.GraphQLNonNull(dataType) }
|
|
30
31
|
},
|
|
@@ -43,6 +44,7 @@ class ValidationQueriesProvider {
|
|
|
43
44
|
}
|
|
44
45
|
return {
|
|
45
46
|
type: new graphql.GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),
|
|
47
|
+
deprecationReason: entity.deprecationReason,
|
|
46
48
|
args: {
|
|
47
49
|
by: {
|
|
48
50
|
type: new graphql.GraphQLNonNull(uniqueWhere)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationQueriesProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/ValidationQueriesProvider.ts"],"sourcesContent":["import { GraphQLFieldConfig, GraphQLNonNull } from 'graphql'\nimport { Context } from '../types.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { EntityInputProvider, EntityInputType } from './mutations/index.js'\nimport { Input, Model } from '@contember/schema'\nimport { filterObject } from '../utils/index.js'\nimport { ResultSchemaTypeProvider } from './ResultSchemaTypeProvider.js'\n\ntype FieldConfig<TArgs> = GraphQLFieldConfig<Context, any, TArgs>\n\nexport class ValidationQueriesProvider {\n\tconstructor(\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly createEntityInputProvider: EntityInputProvider<EntityInputType.create>,\n\t\tprivate readonly updateEntityInputProvider: EntityInputProvider<EntityInputType.update>,\n\t\tprivate readonly resultSchemaTypeProvider: ResultSchemaTypeProvider,\n\t) {}\n\n\tpublic getQueries(entity: Model.Entity): { [fieldName: string]: FieldConfig<any> } {\n\t\tconst entityName = entity.name\n\t\tconst validations: { [fieldName: string]: FieldConfig<any> | undefined } = {}\n\t\tvalidations[`validateCreate${entityName}`] = this.getValidateCreateQuery(entity)\n\t\tvalidations[`validateUpdate${entityName}`] = this.getValidateUpdateQuery(entity)\n\n\t\treturn filterObject(validations, (key, value): value is FieldConfig<any> => value !== undefined)\n\t}\n\n\tprivate getValidateCreateQuery(entity: Model.Entity): FieldConfig<Input.CreateInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.createEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\targs: {\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\tresolve: (parent, args, context: Context, info) =>\n\t\t\t\tcontext.timer(`GraphQL.query.${info.fieldName}`, () => context.executionContainer.validationResolver.validateCreate(entity, args)),\n\t\t}\n\t}\n\n\tprivate getValidateUpdateQuery(entity: Model.Entity): FieldConfig<Input.UpdateInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\tresolve: (parent, args, context: Context, info) =>\n\t\t\t\tcontext.timer(`GraphQL.query.${info.fieldName}`, () => context.executionContainer.validationResolver.validateUpdate(entity, args)),\n\t\t}\n\t}\n}\n"],"names":["filterObject","GraphQLNonNull"],"mappings":";;;;;AAUO,MAAM,0BAA0B;AAAA,EACtC,YACkB,mBACA,2BACA,2BACA,0BAChB;AAJgB,SAAA,oBAAA;AACA,SAAA,4BAAA;AACA,SAAA,4BAAA;AACA,SAAA,2BAAA;AAAA,EACf;AAAA,EAEI,W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AE5C,SAAS,CAAC,QAAQ,MAAM,SAAkB,SACzC,QAAQ,MAAM,iBAAiB,KAAK,SAAS,IAAI,MAAM,QAAQ,mBAAmB,mBAAmB,eAAe,QAAQ,IAAI,CAAC;AAAA,IAAA;AAAA,EAEpI;AACD;;"}
|
|
1
|
+
{"version":3,"file":"ValidationQueriesProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/ValidationQueriesProvider.ts"],"sourcesContent":["import { GraphQLFieldConfig, GraphQLNonNull } from 'graphql'\nimport { Context } from '../types.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { EntityInputProvider, EntityInputType } from './mutations/index.js'\nimport { Input, Model } from '@contember/schema'\nimport { filterObject } from '../utils/index.js'\nimport { ResultSchemaTypeProvider } from './ResultSchemaTypeProvider.js'\n\ntype FieldConfig<TArgs> = GraphQLFieldConfig<Context, any, TArgs>\n\nexport class ValidationQueriesProvider {\n\tconstructor(\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly createEntityInputProvider: EntityInputProvider<EntityInputType.create>,\n\t\tprivate readonly updateEntityInputProvider: EntityInputProvider<EntityInputType.update>,\n\t\tprivate readonly resultSchemaTypeProvider: ResultSchemaTypeProvider,\n\t) {}\n\n\tpublic getQueries(entity: Model.Entity): { [fieldName: string]: FieldConfig<any> } {\n\t\tconst entityName = entity.name\n\t\tconst validations: { [fieldName: string]: FieldConfig<any> | undefined } = {}\n\t\tvalidations[`validateCreate${entityName}`] = this.getValidateCreateQuery(entity)\n\t\tvalidations[`validateUpdate${entityName}`] = this.getValidateUpdateQuery(entity)\n\n\t\treturn filterObject(validations, (key, value): value is FieldConfig<any> => value !== undefined)\n\t}\n\n\tprivate getValidateCreateQuery(entity: Model.Entity): FieldConfig<Input.CreateInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.createEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\tresolve: (parent, args, context: Context, info) =>\n\t\t\t\tcontext.timer(`GraphQL.query.${info.fieldName}`, () => context.executionContainer.validationResolver.validateCreate(entity, args)),\n\t\t}\n\t}\n\n\tprivate getValidateUpdateQuery(entity: Model.Entity): FieldConfig<Input.UpdateInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\tresolve: (parent, args, context: Context, info) =>\n\t\t\t\tcontext.timer(`GraphQL.query.${info.fieldName}`, () => context.executionContainer.validationResolver.validateUpdate(entity, args)),\n\t\t}\n\t}\n}\n"],"names":["filterObject","GraphQLNonNull"],"mappings":";;;;;AAUO,MAAM,0BAA0B;AAAA,EACtC,YACkB,mBACA,2BACA,2BACA,0BAChB;AAJgB,SAAA,oBAAA;AACA,SAAA,4BAAA;AACA,SAAA,4BAAA;AACA,SAAA,2BAAA;AAAA,EACf;AAAA,EAEI,WAAW,QAAiE;AAClF,UAAM,aAAa,OAAO;AAC1B,UAAM,cAAqE,CAAA;AAC3E,gBAAY,iBAAiB,UAAU,EAAE,IAAI,KAAK,uBAAuB,MAAM;AAC/E,gBAAY,iBAAiB,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AAQ,mBAAmB,mBAAmB,eAAe,QAAQ,IAAI,CAAC;AAAA,IAAA;AAAA,EAEpI;AACD;;"}
|
|
@@ -23,6 +23,7 @@ class ValidationQueriesProvider {
|
|
|
23
23
|
}
|
|
24
24
|
return {
|
|
25
25
|
type: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),
|
|
26
|
+
deprecationReason: entity.deprecationReason,
|
|
26
27
|
args: {
|
|
27
28
|
data: { type: new GraphQLNonNull(dataType) }
|
|
28
29
|
},
|
|
@@ -41,6 +42,7 @@ class ValidationQueriesProvider {
|
|
|
41
42
|
}
|
|
42
43
|
return {
|
|
43
44
|
type: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),
|
|
45
|
+
deprecationReason: entity.deprecationReason,
|
|
44
46
|
args: {
|
|
45
47
|
by: {
|
|
46
48
|
type: new GraphQLNonNull(uniqueWhere)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationQueriesProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/ValidationQueriesProvider.ts"],"sourcesContent":["import { GraphQLFieldConfig, GraphQLNonNull } from 'graphql'\nimport { Context } from '../types.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { EntityInputProvider, EntityInputType } from './mutations/index.js'\nimport { Input, Model } from '@contember/schema'\nimport { filterObject } from '../utils/index.js'\nimport { ResultSchemaTypeProvider } from './ResultSchemaTypeProvider.js'\n\ntype FieldConfig<TArgs> = GraphQLFieldConfig<Context, any, TArgs>\n\nexport class ValidationQueriesProvider {\n\tconstructor(\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly createEntityInputProvider: EntityInputProvider<EntityInputType.create>,\n\t\tprivate readonly updateEntityInputProvider: EntityInputProvider<EntityInputType.update>,\n\t\tprivate readonly resultSchemaTypeProvider: ResultSchemaTypeProvider,\n\t) {}\n\n\tpublic getQueries(entity: Model.Entity): { [fieldName: string]: FieldConfig<any> } {\n\t\tconst entityName = entity.name\n\t\tconst validations: { [fieldName: string]: FieldConfig<any> | undefined } = {}\n\t\tvalidations[`validateCreate${entityName}`] = this.getValidateCreateQuery(entity)\n\t\tvalidations[`validateUpdate${entityName}`] = this.getValidateUpdateQuery(entity)\n\n\t\treturn filterObject(validations, (key, value): value is FieldConfig<any> => value !== undefined)\n\t}\n\n\tprivate getValidateCreateQuery(entity: Model.Entity): FieldConfig<Input.CreateInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.createEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\targs: {\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\tresolve: (parent, args, context: Context, info) =>\n\t\t\t\tcontext.timer(`GraphQL.query.${info.fieldName}`, () => context.executionContainer.validationResolver.validateCreate(entity, args)),\n\t\t}\n\t}\n\n\tprivate getValidateUpdateQuery(entity: Model.Entity): FieldConfig<Input.UpdateInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\tresolve: (parent, args, context: Context, info) =>\n\t\t\t\tcontext.timer(`GraphQL.query.${info.fieldName}`, () => context.executionContainer.validationResolver.validateUpdate(entity, args)),\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;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,MAAM,IAAI,eAAe,WAAW;AAAA,QAAA;AAAA,QAErC,MAAM,EAAE,MAAM,IAAI,eAAe,QAAQ,EAAA;AAAA,MAAE;AAAA,MAE5C,SAAS,CAAC,QAAQ,MAAM,SAAkB,SACzC,QAAQ,MAAM,iBAAiB,KAAK,SAAS,IAAI,MAAM,QAAQ,mBAAmB,mBAAmB,eAAe,QAAQ,IAAI,CAAC;AAAA,IAAA;AAAA,EAEpI;AACD;"}
|
|
1
|
+
{"version":3,"file":"ValidationQueriesProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/ValidationQueriesProvider.ts"],"sourcesContent":["import { GraphQLFieldConfig, GraphQLNonNull } from 'graphql'\nimport { Context } from '../types.js'\nimport { WhereTypeProvider } from './WhereTypeProvider.js'\nimport { EntityInputProvider, EntityInputType } from './mutations/index.js'\nimport { Input, Model } from '@contember/schema'\nimport { filterObject } from '../utils/index.js'\nimport { ResultSchemaTypeProvider } from './ResultSchemaTypeProvider.js'\n\ntype FieldConfig<TArgs> = GraphQLFieldConfig<Context, any, TArgs>\n\nexport class ValidationQueriesProvider {\n\tconstructor(\n\t\tprivate readonly whereTypeProvider: WhereTypeProvider,\n\t\tprivate readonly createEntityInputProvider: EntityInputProvider<EntityInputType.create>,\n\t\tprivate readonly updateEntityInputProvider: EntityInputProvider<EntityInputType.update>,\n\t\tprivate readonly resultSchemaTypeProvider: ResultSchemaTypeProvider,\n\t) {}\n\n\tpublic getQueries(entity: Model.Entity): { [fieldName: string]: FieldConfig<any> } {\n\t\tconst entityName = entity.name\n\t\tconst validations: { [fieldName: string]: FieldConfig<any> | undefined } = {}\n\t\tvalidations[`validateCreate${entityName}`] = this.getValidateCreateQuery(entity)\n\t\tvalidations[`validateUpdate${entityName}`] = this.getValidateUpdateQuery(entity)\n\n\t\treturn filterObject(validations, (key, value): value is FieldConfig<any> => value !== undefined)\n\t}\n\n\tprivate getValidateCreateQuery(entity: Model.Entity): FieldConfig<Input.CreateInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.createEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\tresolve: (parent, args, context: Context, info) =>\n\t\t\t\tcontext.timer(`GraphQL.query.${info.fieldName}`, () => context.executionContainer.validationResolver.validateCreate(entity, args)),\n\t\t}\n\t}\n\n\tprivate getValidateUpdateQuery(entity: Model.Entity): FieldConfig<Input.UpdateInput> | undefined {\n\t\tconst entityName = entity.name\n\t\tconst dataType = this.updateEntityInputProvider.getInput(entityName)\n\t\tif (dataType === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst uniqueWhere = this.whereTypeProvider.getEntityUniqueWhereType(entityName)\n\t\tif (!uniqueWhere) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(this.resultSchemaTypeProvider.validationResultType),\n\t\t\tdeprecationReason: entity.deprecationReason,\n\t\t\targs: {\n\t\t\t\tby: {\n\t\t\t\t\ttype: new GraphQLNonNull(uniqueWhere),\n\t\t\t\t},\n\t\t\t\tdata: { type: new GraphQLNonNull(dataType) },\n\t\t\t},\n\t\t\tresolve: (parent, args, context: Context, info) =>\n\t\t\t\tcontext.timer(`GraphQL.query.${info.fieldName}`, () => context.executionContainer.validationResolver.validateUpdate(entity, args)),\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;AAUO,MAAM,0BAA0B;AAAA,EACtC,YACkB,mBACA,2BACA,2BACA,0BAChB;AAJgB,SAAA,oBAAA;AACA,SAAA,4BAAA;AACA,SAAA,4BAAA;AACA,SAAA,2BAAA;AAAA,EACf;AAAA,EAEI,WAAW,QAAiE;AAClF,UAAM,aAAa,OAAO;AAC1B,UAAM,cAAqE,CA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AM,iBAAiB,KAAK,SAAS,IAAI,MAAM,QAAQ,mBAAmB,mBAAmB,eAAe,QAAQ,IAAI,CAAC;AAAA,IAAA;AAAA,EAEpI;AACD;"}
|
|
@@ -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,SAA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G;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,YAA4C;AACrE,QAAI,KAAK,aAAa,oBAAoB,IAAI,UAAU,MAAM,UAAU,MAAM,MAAM;AACnF,YAAM,IAAI,wBAAA;AAAA,IACX;AACA,WAAO,KAAK,eAAe,UAAU;AAAA,EACtC;AAAA,EAEO,yBAAyB,YAAwD;AACvF,QAAI,KAAK,aAAa,oBAAoB,IAAI,UAAU,MAAM,UAAU,MAAM,MAAM;A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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;"}
|