@contember/engine-system-api 2.0.0-alpha.9 → 2.0.0-beta.2
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 +2 -2
- package/dist/development/index.js +2 -2
- package/dist/development/src/SystemContainer.cjs +4 -3
- package/dist/development/src/SystemContainer.cjs.map +1 -1
- package/dist/development/src/SystemContainer.js +5 -4
- package/dist/development/src/SystemContainer.js.map +1 -1
- package/dist/development/src/migrations/2020-03-27-130000-project-migrations.cjs.map +1 -1
- package/dist/development/src/migrations/2020-03-27-130000-project-migrations.js.map +1 -1
- package/dist/development/src/migrations/2020-05-06-150000-composed-primary.cjs +1 -2
- package/dist/development/src/migrations/2020-05-06-150000-composed-primary.cjs.map +1 -1
- package/dist/development/src/migrations/2020-05-06-150000-composed-primary.js +1 -2
- package/dist/development/src/migrations/2020-05-06-150000-composed-primary.js.map +1 -1
- package/dist/development/src/migrations/2020-06-01-103000-event-trigger-perf.cjs +1 -2
- package/dist/development/src/migrations/2020-06-01-103000-event-trigger-perf.cjs.map +1 -1
- package/dist/development/src/migrations/2020-06-01-103000-event-trigger-perf.js +1 -2
- package/dist/development/src/migrations/2020-06-01-103000-event-trigger-perf.js.map +1 -1
- package/dist/development/src/migrations/2021-05-07-155800-event-log-rework.cjs +1 -2
- package/dist/development/src/migrations/2021-05-07-155800-event-log-rework.cjs.map +1 -1
- package/dist/development/src/migrations/2021-05-07-155800-event-log-rework.js +1 -2
- package/dist/development/src/migrations/2021-05-07-155800-event-log-rework.js.map +1 -1
- package/dist/development/src/migrations/2021-05-19-1232000-event-log-fix-constraint.cjs +1 -2
- package/dist/development/src/migrations/2021-05-19-1232000-event-log-fix-constraint.cjs.map +1 -1
- package/dist/development/src/migrations/2021-05-19-1232000-event-log-fix-constraint.js +1 -2
- package/dist/development/src/migrations/2021-05-19-1232000-event-log-fix-constraint.js.map +1 -1
- package/dist/development/src/migrations/2022-10-03-110000-table-on-delete.cjs +1 -1
- package/dist/development/src/migrations/2022-10-03-110000-table-on-delete.cjs.map +1 -1
- package/dist/development/src/migrations/2022-10-03-110000-table-on-delete.js +1 -1
- package/dist/development/src/migrations/2022-10-03-110000-table-on-delete.js.map +1 -1
- package/dist/development/src/migrations/2023-09-11-174000-fix-on-delete.cjs +1 -1
- package/dist/development/src/migrations/2023-09-11-174000-fix-on-delete.cjs.map +1 -1
- package/dist/development/src/migrations/2023-09-11-174000-fix-on-delete.js +1 -1
- package/dist/development/src/migrations/2023-09-11-174000-fix-on-delete.js.map +1 -1
- package/dist/development/src/migrations/2023-10-19-173000-fix-unique.cjs +1 -1
- package/dist/development/src/migrations/2023-10-19-173000-fix-unique.cjs.map +1 -1
- package/dist/development/src/migrations/2023-10-19-173000-fix-unique.js +1 -1
- package/dist/development/src/migrations/2023-10-19-173000-fix-unique.js.map +1 -1
- package/dist/development/src/migrations/2024-06-28-153000-schema.cjs +18 -0
- package/dist/development/src/migrations/2024-06-28-153000-schema.cjs.map +1 -0
- package/dist/development/src/migrations/2024-06-28-153000-schema.js +19 -0
- package/dist/development/src/migrations/2024-06-28-153000-schema.js.map +1 -0
- package/dist/development/src/migrations/2024-06-28-153001-schema-init.cjs +12 -0
- package/dist/development/src/migrations/2024-06-28-153001-schema-init.cjs.map +1 -0
- package/dist/development/src/migrations/2024-06-28-153001-schema-init.js +13 -0
- package/dist/development/src/migrations/2024-06-28-153001-schema-init.js.map +1 -0
- package/dist/development/src/migrations/2024-07-29-150000-event-data-index.cjs +11 -0
- package/dist/development/src/migrations/2024-07-29-150000-event-data-index.cjs.map +1 -0
- package/dist/development/src/migrations/2024-07-29-150000-event-data-index.js +12 -0
- package/dist/development/src/migrations/2024-07-29-150000-event-data-index.js.map +1 -0
- package/dist/development/src/migrations/runner.cjs +11 -5
- package/dist/development/src/migrations/runner.cjs.map +1 -1
- package/dist/development/src/migrations/runner.js +11 -5
- package/dist/development/src/migrations/runner.js.map +1 -1
- package/dist/development/src/migrations/snapshot-factory.cjs +1 -1
- package/dist/development/src/migrations/snapshot-factory.cjs.map +1 -1
- package/dist/development/src/migrations/snapshot-factory.js +1 -1
- package/dist/development/src/migrations/snapshot-factory.js.map +1 -1
- package/dist/development/src/migrations/snapshot.cjs +17 -1
- package/dist/development/src/migrations/snapshot.cjs.map +1 -1
- package/dist/development/src/migrations/snapshot.js +17 -1
- package/dist/development/src/migrations/snapshot.js.map +1 -1
- package/dist/development/src/model/ProjectInitializer.cjs.map +1 -1
- package/dist/development/src/model/ProjectInitializer.js.map +1 -1
- package/dist/development/src/model/ProjectTruncateExecutor.cjs.map +1 -1
- package/dist/development/src/model/ProjectTruncateExecutor.js.map +1 -1
- package/dist/development/src/model/authorization/AuthorizationActions.cjs +1 -0
- package/dist/development/src/model/authorization/AuthorizationActions.cjs.map +1 -1
- package/dist/development/src/model/authorization/AuthorizationActions.js +1 -0
- package/dist/development/src/model/authorization/AuthorizationActions.js.map +1 -1
- package/dist/development/src/model/authorization/Identity.cjs.map +1 -1
- package/dist/development/src/model/authorization/Identity.js.map +1 -1
- package/dist/development/src/model/authorization/PermissionsFactory.cjs +1 -0
- package/dist/development/src/model/authorization/PermissionsFactory.cjs.map +1 -1
- package/dist/development/src/model/authorization/PermissionsFactory.js +1 -0
- package/dist/development/src/model/authorization/PermissionsFactory.js.map +1 -1
- package/dist/development/src/model/authorization/StagePermissionsFactory.cjs +4 -5
- package/dist/development/src/model/authorization/StagePermissionsFactory.cjs.map +1 -1
- package/dist/development/src/model/authorization/StagePermissionsFactory.js +4 -5
- package/dist/development/src/model/authorization/StagePermissionsFactory.js.map +1 -1
- package/dist/development/src/model/authorization/StageScope.cjs +2 -2
- package/dist/development/src/model/authorization/StageScope.cjs.map +1 -1
- package/dist/development/src/model/authorization/StageScope.js +2 -2
- package/dist/development/src/model/authorization/StageScope.js.map +1 -1
- package/dist/development/src/model/authorization/SwitchEvaluatorNode.cjs.map +1 -1
- package/dist/development/src/model/authorization/SwitchEvaluatorNode.js.map +1 -1
- package/dist/development/src/model/commands/CommandBus.cjs.map +1 -1
- package/dist/development/src/model/commands/CommandBus.js.map +1 -1
- package/dist/development/src/model/commands/events/TruncateEventsCommand.cjs.map +1 -1
- package/dist/development/src/model/commands/events/TruncateEventsCommand.js.map +1 -1
- package/dist/development/src/model/commands/migrations/DeleteMigrationCommand.cjs.map +1 -1
- package/dist/development/src/model/commands/migrations/DeleteMigrationCommand.js.map +1 -1
- package/dist/development/src/model/commands/migrations/ModifyMigrationCommand.cjs.map +1 -1
- package/dist/development/src/model/commands/migrations/ModifyMigrationCommand.js.map +1 -1
- package/dist/development/src/model/commands/migrations/SaveMigrationCommand.cjs.map +1 -1
- package/dist/development/src/model/commands/migrations/SaveMigrationCommand.js.map +1 -1
- package/dist/development/src/model/commands/schema/SaveSchemaCommand.cjs +28 -0
- package/dist/development/src/model/commands/schema/SaveSchemaCommand.cjs.map +1 -0
- package/dist/development/src/model/commands/schema/SaveSchemaCommand.js +28 -0
- package/dist/development/src/model/commands/schema/SaveSchemaCommand.js.map +1 -0
- package/dist/development/src/model/commands/stages/CreateStageCommand.cjs.map +1 -1
- package/dist/development/src/model/commands/stages/CreateStageCommand.js.map +1 -1
- package/dist/development/src/model/database/DatabaseContext.cjs.map +1 -1
- package/dist/development/src/model/database/DatabaseContext.js.map +1 -1
- package/dist/development/src/model/dtos/ExecutedMigration.cjs.map +1 -1
- package/dist/development/src/model/dtos/ExecutedMigration.js.map +1 -1
- package/dist/development/src/model/events/EventResponseBuilder.cjs.map +1 -1
- package/dist/development/src/model/events/EventResponseBuilder.js.map +1 -1
- package/dist/development/src/model/events/EventResponseHelper.cjs.map +1 -1
- package/dist/development/src/model/events/EventResponseHelper.js.map +1 -1
- package/dist/development/src/model/events/identityUtils.cjs.map +1 -1
- package/dist/development/src/model/events/identityUtils.js.map +1 -1
- package/dist/development/src/model/events/types.cjs.map +1 -1
- package/dist/development/src/model/events/types.js.map +1 -1
- package/dist/development/src/model/helpers/modelHelpers.cjs.map +1 -1
- package/dist/development/src/model/helpers/modelHelpers.js.map +1 -1
- package/dist/development/src/model/metadata/SchemaDatabaseMetadataResolverStore.cjs.map +1 -1
- package/dist/development/src/model/metadata/SchemaDatabaseMetadataResolverStore.js.map +1 -1
- package/dist/development/src/model/migrations/ExecutedMigrationsResolver.cjs.map +1 -1
- package/dist/development/src/model/migrations/ExecutedMigrationsResolver.js.map +1 -1
- package/dist/development/src/model/migrations/MigrationAlterer.cjs +10 -0
- package/dist/development/src/model/migrations/MigrationAlterer.cjs.map +1 -1
- package/dist/development/src/model/migrations/MigrationAlterer.js +10 -0
- package/dist/development/src/model/migrations/MigrationAlterer.js.map +1 -1
- package/dist/development/src/model/migrations/ProjectMigrator.cjs +29 -10
- package/dist/development/src/model/migrations/ProjectMigrator.cjs.map +1 -1
- package/dist/development/src/model/migrations/ProjectMigrator.js +30 -11
- package/dist/development/src/model/migrations/ProjectMigrator.js.map +1 -1
- package/dist/development/src/model/migrations/SchemaProvider.cjs +58 -0
- package/dist/development/src/model/migrations/SchemaProvider.cjs.map +1 -0
- package/dist/development/src/model/migrations/SchemaProvider.js +58 -0
- package/dist/development/src/model/migrations/SchemaProvider.js.map +1 -0
- package/dist/development/src/model/queries/events/EventQueryHelpers.cjs.map +1 -1
- package/dist/development/src/model/queries/events/EventQueryHelpers.js.map +1 -1
- package/dist/development/src/model/queries/events/EventsQuery.cjs +10 -14
- package/dist/development/src/model/queries/events/EventsQuery.cjs.map +1 -1
- package/dist/development/src/model/queries/events/EventsQuery.js +10 -14
- package/dist/development/src/model/queries/events/EventsQuery.js.map +1 -1
- package/dist/development/src/model/queries/events/LatestTransactionIdByStageQuery.cjs.map +1 -1
- package/dist/development/src/model/queries/events/LatestTransactionIdByStageQuery.js.map +1 -1
- package/dist/development/src/model/queries/events/OldValuesQuery.cjs.map +1 -1
- package/dist/development/src/model/queries/events/OldValuesQuery.js.map +1 -1
- package/dist/development/src/model/queries/migrations/ExecutedMigrationByVersionQuery.cjs.map +1 -1
- package/dist/development/src/model/queries/migrations/ExecutedMigrationByVersionQuery.js.map +1 -1
- package/dist/development/src/model/queries/migrations/ExecutedMigrationsQuery.cjs.map +1 -1
- package/dist/development/src/model/queries/migrations/ExecutedMigrationsQuery.js.map +1 -1
- package/dist/development/src/model/queries/schema/SchemaQuery.cjs +34 -0
- package/dist/development/src/model/queries/schema/SchemaQuery.cjs.map +1 -0
- package/dist/development/src/model/queries/schema/SchemaQuery.js +34 -0
- package/dist/development/src/model/queries/schema/SchemaQuery.js.map +1 -0
- package/dist/development/src/model/queries/stages/StageBySlugQuery.cjs.map +1 -1
- package/dist/development/src/model/queries/stages/StageBySlugQuery.js.map +1 -1
- package/dist/development/src/model/queries/stages/StagesQuery.cjs.map +1 -1
- package/dist/development/src/model/queries/stages/StagesQuery.js.map +1 -1
- package/dist/development/src/model/stages/StageCreator.cjs.map +1 -1
- package/dist/development/src/model/stages/StageCreator.js.map +1 -1
- package/dist/development/src/resolvers/ResolverFactory.cjs +6 -2
- package/dist/development/src/resolvers/ResolverFactory.cjs.map +1 -1
- package/dist/development/src/resolvers/ResolverFactory.js +7 -3
- package/dist/development/src/resolvers/ResolverFactory.js.map +1 -1
- package/dist/development/src/resolvers/SystemResolverContext.cjs +5 -5
- package/dist/development/src/resolvers/SystemResolverContext.cjs.map +1 -1
- package/dist/development/src/resolvers/SystemResolverContext.js +5 -5
- package/dist/development/src/resolvers/SystemResolverContext.js.map +1 -1
- package/dist/development/src/resolvers/mutation/MigrateMutationResolver.cjs +0 -1
- package/dist/development/src/resolvers/mutation/MigrateMutationResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/mutation/MigrateMutationResolver.js +0 -1
- package/dist/development/src/resolvers/mutation/MigrateMutationResolver.js.map +1 -1
- package/dist/development/src/resolvers/mutation/MigrationAlterMutationResolver.cjs +0 -1
- package/dist/development/src/resolvers/mutation/MigrationAlterMutationResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/mutation/MigrationAlterMutationResolver.js +0 -1
- package/dist/development/src/resolvers/mutation/MigrationAlterMutationResolver.js.map +1 -1
- package/dist/development/src/resolvers/mutation/TruncateMutationResolver.cjs +1 -1
- package/dist/development/src/resolvers/mutation/TruncateMutationResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/mutation/TruncateMutationResolver.js +1 -1
- package/dist/development/src/resolvers/mutation/TruncateMutationResolver.js.map +1 -1
- package/dist/development/src/resolvers/query/EventsQueryResolver.cjs +0 -1
- package/dist/development/src/resolvers/query/EventsQueryResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/query/EventsQueryResolver.js +0 -1
- package/dist/development/src/resolvers/query/EventsQueryResolver.js.map +1 -1
- package/dist/development/src/resolvers/query/ExecutedMigrationsQueryResolver.cjs +0 -1
- package/dist/development/src/resolvers/query/ExecutedMigrationsQueryResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/query/ExecutedMigrationsQueryResolver.js +0 -1
- package/dist/development/src/resolvers/query/ExecutedMigrationsQueryResolver.js.map +1 -1
- package/dist/development/src/resolvers/query/SchemaQueryResolver.cjs +23 -0
- package/dist/development/src/resolvers/query/SchemaQueryResolver.cjs.map +1 -0
- package/dist/development/src/resolvers/query/SchemaQueryResolver.js +23 -0
- package/dist/development/src/resolvers/query/SchemaQueryResolver.js.map +1 -0
- package/dist/development/src/resolvers/query/StagesQueryResolver.cjs +0 -1
- package/dist/development/src/resolvers/query/StagesQueryResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/query/StagesQueryResolver.js +0 -1
- package/dist/development/src/resolvers/query/StagesQueryResolver.js.map +1 -1
- package/dist/development/src/resolvers/types/EventOldValuesResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/types/EventOldValuesResolver.js.map +1 -1
- package/dist/development/src/resolvers/types/OldValuesHelpers.cjs +0 -1
- package/dist/development/src/resolvers/types/OldValuesHelpers.cjs.map +1 -1
- package/dist/development/src/resolvers/types/OldValuesHelpers.js +0 -1
- package/dist/development/src/resolvers/types/OldValuesHelpers.js.map +1 -1
- package/dist/development/src/schema/dev.graphql.cjs.map +1 -1
- package/dist/development/src/schema/system.graphql.cjs +3 -1
- package/dist/development/src/schema/system.graphql.cjs.map +1 -1
- package/dist/development/src/schema/system.graphql.js +3 -1
- package/dist/development/src/schema/system.graphql.js.map +1 -1
- package/dist/development/src/schema/types.cjs.map +1 -1
- package/dist/development/src/schema/types.js.map +1 -1
- package/dist/development/src/utils/MapSet.cjs.map +1 -1
- package/dist/development/src/utils/MapSet.js.map +1 -1
- package/dist/development/src/utils/Response.cjs.map +1 -1
- package/dist/development/src/utils/Response.js.map +1 -1
- package/dist/development/src/utils/batchQuery.cjs.map +1 -1
- package/dist/development/src/utils/batchQuery.js.map +1 -1
- package/dist/production/index.cjs +2 -2
- package/dist/production/index.js +2 -2
- package/dist/production/src/SystemContainer.cjs +4 -3
- package/dist/production/src/SystemContainer.cjs.map +1 -1
- package/dist/production/src/SystemContainer.js +5 -4
- package/dist/production/src/SystemContainer.js.map +1 -1
- package/dist/production/src/migrations/2020-03-27-130000-project-migrations.cjs.map +1 -1
- package/dist/production/src/migrations/2020-03-27-130000-project-migrations.js.map +1 -1
- package/dist/production/src/migrations/2020-05-06-150000-composed-primary.cjs +1 -2
- package/dist/production/src/migrations/2020-05-06-150000-composed-primary.cjs.map +1 -1
- package/dist/production/src/migrations/2020-05-06-150000-composed-primary.js +1 -2
- package/dist/production/src/migrations/2020-05-06-150000-composed-primary.js.map +1 -1
- package/dist/production/src/migrations/2020-06-01-103000-event-trigger-perf.cjs +1 -2
- package/dist/production/src/migrations/2020-06-01-103000-event-trigger-perf.cjs.map +1 -1
- package/dist/production/src/migrations/2020-06-01-103000-event-trigger-perf.js +1 -2
- package/dist/production/src/migrations/2020-06-01-103000-event-trigger-perf.js.map +1 -1
- package/dist/production/src/migrations/2021-05-07-155800-event-log-rework.cjs +1 -2
- package/dist/production/src/migrations/2021-05-07-155800-event-log-rework.cjs.map +1 -1
- package/dist/production/src/migrations/2021-05-07-155800-event-log-rework.js +1 -2
- package/dist/production/src/migrations/2021-05-07-155800-event-log-rework.js.map +1 -1
- package/dist/production/src/migrations/2021-05-19-1232000-event-log-fix-constraint.cjs +1 -2
- package/dist/production/src/migrations/2021-05-19-1232000-event-log-fix-constraint.cjs.map +1 -1
- package/dist/production/src/migrations/2021-05-19-1232000-event-log-fix-constraint.js +1 -2
- package/dist/production/src/migrations/2021-05-19-1232000-event-log-fix-constraint.js.map +1 -1
- package/dist/production/src/migrations/2022-10-03-110000-table-on-delete.cjs +1 -1
- package/dist/production/src/migrations/2022-10-03-110000-table-on-delete.cjs.map +1 -1
- package/dist/production/src/migrations/2022-10-03-110000-table-on-delete.js +1 -1
- package/dist/production/src/migrations/2022-10-03-110000-table-on-delete.js.map +1 -1
- package/dist/production/src/migrations/2023-09-11-174000-fix-on-delete.cjs +1 -1
- package/dist/production/src/migrations/2023-09-11-174000-fix-on-delete.cjs.map +1 -1
- package/dist/production/src/migrations/2023-09-11-174000-fix-on-delete.js +1 -1
- package/dist/production/src/migrations/2023-09-11-174000-fix-on-delete.js.map +1 -1
- package/dist/production/src/migrations/2023-10-19-173000-fix-unique.cjs +1 -1
- package/dist/production/src/migrations/2023-10-19-173000-fix-unique.cjs.map +1 -1
- package/dist/production/src/migrations/2023-10-19-173000-fix-unique.js +1 -1
- package/dist/production/src/migrations/2023-10-19-173000-fix-unique.js.map +1 -1
- package/dist/production/src/migrations/2024-06-28-153000-schema.cjs +18 -0
- package/dist/production/src/migrations/2024-06-28-153000-schema.cjs.map +1 -0
- package/dist/production/src/migrations/2024-06-28-153000-schema.js +19 -0
- package/dist/production/src/migrations/2024-06-28-153000-schema.js.map +1 -0
- package/dist/production/src/migrations/2024-06-28-153001-schema-init.cjs +12 -0
- package/dist/production/src/migrations/2024-06-28-153001-schema-init.cjs.map +1 -0
- package/dist/production/src/migrations/2024-06-28-153001-schema-init.js +13 -0
- package/dist/production/src/migrations/2024-06-28-153001-schema-init.js.map +1 -0
- package/dist/production/src/migrations/2024-07-29-150000-event-data-index.cjs +11 -0
- package/dist/production/src/migrations/2024-07-29-150000-event-data-index.cjs.map +1 -0
- package/dist/production/src/migrations/2024-07-29-150000-event-data-index.js +12 -0
- package/dist/production/src/migrations/2024-07-29-150000-event-data-index.js.map +1 -0
- package/dist/production/src/migrations/runner.cjs +11 -5
- package/dist/production/src/migrations/runner.cjs.map +1 -1
- package/dist/production/src/migrations/runner.js +11 -5
- package/dist/production/src/migrations/runner.js.map +1 -1
- package/dist/production/src/migrations/snapshot-factory.cjs +1 -1
- package/dist/production/src/migrations/snapshot-factory.cjs.map +1 -1
- package/dist/production/src/migrations/snapshot-factory.js +1 -1
- package/dist/production/src/migrations/snapshot-factory.js.map +1 -1
- package/dist/production/src/migrations/snapshot.cjs +17 -1
- package/dist/production/src/migrations/snapshot.cjs.map +1 -1
- package/dist/production/src/migrations/snapshot.js +17 -1
- package/dist/production/src/migrations/snapshot.js.map +1 -1
- package/dist/production/src/model/ProjectInitializer.cjs.map +1 -1
- package/dist/production/src/model/ProjectInitializer.js.map +1 -1
- package/dist/production/src/model/ProjectTruncateExecutor.cjs.map +1 -1
- package/dist/production/src/model/ProjectTruncateExecutor.js.map +1 -1
- package/dist/production/src/model/authorization/AuthorizationActions.cjs +1 -0
- package/dist/production/src/model/authorization/AuthorizationActions.cjs.map +1 -1
- package/dist/production/src/model/authorization/AuthorizationActions.js +1 -0
- package/dist/production/src/model/authorization/AuthorizationActions.js.map +1 -1
- package/dist/production/src/model/authorization/Identity.cjs.map +1 -1
- package/dist/production/src/model/authorization/Identity.js.map +1 -1
- package/dist/production/src/model/authorization/PermissionsFactory.cjs +1 -0
- package/dist/production/src/model/authorization/PermissionsFactory.cjs.map +1 -1
- package/dist/production/src/model/authorization/PermissionsFactory.js +1 -0
- package/dist/production/src/model/authorization/PermissionsFactory.js.map +1 -1
- package/dist/production/src/model/authorization/StagePermissionsFactory.cjs +4 -5
- package/dist/production/src/model/authorization/StagePermissionsFactory.cjs.map +1 -1
- package/dist/production/src/model/authorization/StagePermissionsFactory.js +4 -5
- package/dist/production/src/model/authorization/StagePermissionsFactory.js.map +1 -1
- package/dist/production/src/model/authorization/StageScope.cjs +2 -2
- package/dist/production/src/model/authorization/StageScope.cjs.map +1 -1
- package/dist/production/src/model/authorization/StageScope.js +2 -2
- package/dist/production/src/model/authorization/StageScope.js.map +1 -1
- package/dist/production/src/model/authorization/SwitchEvaluatorNode.cjs.map +1 -1
- package/dist/production/src/model/authorization/SwitchEvaluatorNode.js.map +1 -1
- package/dist/production/src/model/commands/CommandBus.cjs.map +1 -1
- package/dist/production/src/model/commands/CommandBus.js.map +1 -1
- package/dist/production/src/model/commands/events/TruncateEventsCommand.cjs.map +1 -1
- package/dist/production/src/model/commands/events/TruncateEventsCommand.js.map +1 -1
- package/dist/production/src/model/commands/migrations/DeleteMigrationCommand.cjs.map +1 -1
- package/dist/production/src/model/commands/migrations/DeleteMigrationCommand.js.map +1 -1
- package/dist/production/src/model/commands/migrations/ModifyMigrationCommand.cjs.map +1 -1
- package/dist/production/src/model/commands/migrations/ModifyMigrationCommand.js.map +1 -1
- package/dist/production/src/model/commands/migrations/SaveMigrationCommand.cjs.map +1 -1
- package/dist/production/src/model/commands/migrations/SaveMigrationCommand.js.map +1 -1
- package/dist/production/src/model/commands/schema/SaveSchemaCommand.cjs +28 -0
- package/dist/production/src/model/commands/schema/SaveSchemaCommand.cjs.map +1 -0
- package/dist/production/src/model/commands/schema/SaveSchemaCommand.js +28 -0
- package/dist/production/src/model/commands/schema/SaveSchemaCommand.js.map +1 -0
- package/dist/production/src/model/commands/stages/CreateStageCommand.cjs.map +1 -1
- package/dist/production/src/model/commands/stages/CreateStageCommand.js.map +1 -1
- package/dist/production/src/model/database/DatabaseContext.cjs.map +1 -1
- package/dist/production/src/model/database/DatabaseContext.js.map +1 -1
- package/dist/production/src/model/dtos/ExecutedMigration.cjs.map +1 -1
- package/dist/production/src/model/dtos/ExecutedMigration.js.map +1 -1
- package/dist/production/src/model/events/EventResponseBuilder.cjs.map +1 -1
- package/dist/production/src/model/events/EventResponseBuilder.js.map +1 -1
- package/dist/production/src/model/events/EventResponseHelper.cjs.map +1 -1
- package/dist/production/src/model/events/EventResponseHelper.js.map +1 -1
- package/dist/production/src/model/events/identityUtils.cjs.map +1 -1
- package/dist/production/src/model/events/identityUtils.js.map +1 -1
- package/dist/production/src/model/events/types.cjs.map +1 -1
- package/dist/production/src/model/events/types.js.map +1 -1
- package/dist/production/src/model/helpers/modelHelpers.cjs.map +1 -1
- package/dist/production/src/model/helpers/modelHelpers.js.map +1 -1
- package/dist/production/src/model/metadata/SchemaDatabaseMetadataResolverStore.cjs.map +1 -1
- package/dist/production/src/model/metadata/SchemaDatabaseMetadataResolverStore.js.map +1 -1
- package/dist/production/src/model/migrations/ExecutedMigrationsResolver.cjs.map +1 -1
- package/dist/production/src/model/migrations/ExecutedMigrationsResolver.js.map +1 -1
- package/dist/production/src/model/migrations/MigrationAlterer.cjs +10 -0
- package/dist/production/src/model/migrations/MigrationAlterer.cjs.map +1 -1
- package/dist/production/src/model/migrations/MigrationAlterer.js +10 -0
- package/dist/production/src/model/migrations/MigrationAlterer.js.map +1 -1
- package/dist/production/src/model/migrations/ProjectMigrator.cjs +29 -10
- package/dist/production/src/model/migrations/ProjectMigrator.cjs.map +1 -1
- package/dist/production/src/model/migrations/ProjectMigrator.js +30 -11
- package/dist/production/src/model/migrations/ProjectMigrator.js.map +1 -1
- package/dist/production/src/model/migrations/SchemaProvider.cjs +58 -0
- package/dist/production/src/model/migrations/SchemaProvider.cjs.map +1 -0
- package/dist/production/src/model/migrations/SchemaProvider.js +58 -0
- package/dist/production/src/model/migrations/SchemaProvider.js.map +1 -0
- package/dist/production/src/model/queries/events/EventQueryHelpers.cjs.map +1 -1
- package/dist/production/src/model/queries/events/EventQueryHelpers.js.map +1 -1
- package/dist/production/src/model/queries/events/EventsQuery.cjs +10 -14
- package/dist/production/src/model/queries/events/EventsQuery.cjs.map +1 -1
- package/dist/production/src/model/queries/events/EventsQuery.js +10 -14
- package/dist/production/src/model/queries/events/EventsQuery.js.map +1 -1
- package/dist/production/src/model/queries/events/LatestTransactionIdByStageQuery.cjs.map +1 -1
- package/dist/production/src/model/queries/events/LatestTransactionIdByStageQuery.js.map +1 -1
- package/dist/production/src/model/queries/events/OldValuesQuery.cjs.map +1 -1
- package/dist/production/src/model/queries/events/OldValuesQuery.js.map +1 -1
- package/dist/production/src/model/queries/migrations/ExecutedMigrationByVersionQuery.cjs.map +1 -1
- package/dist/production/src/model/queries/migrations/ExecutedMigrationByVersionQuery.js.map +1 -1
- package/dist/production/src/model/queries/migrations/ExecutedMigrationsQuery.cjs.map +1 -1
- package/dist/production/src/model/queries/migrations/ExecutedMigrationsQuery.js.map +1 -1
- package/dist/production/src/model/queries/schema/SchemaQuery.cjs +34 -0
- package/dist/production/src/model/queries/schema/SchemaQuery.cjs.map +1 -0
- package/dist/production/src/model/queries/schema/SchemaQuery.js +34 -0
- package/dist/production/src/model/queries/schema/SchemaQuery.js.map +1 -0
- package/dist/production/src/model/queries/stages/StageBySlugQuery.cjs.map +1 -1
- package/dist/production/src/model/queries/stages/StageBySlugQuery.js.map +1 -1
- package/dist/production/src/model/queries/stages/StagesQuery.cjs.map +1 -1
- package/dist/production/src/model/queries/stages/StagesQuery.js.map +1 -1
- package/dist/production/src/model/stages/StageCreator.cjs.map +1 -1
- package/dist/production/src/model/stages/StageCreator.js.map +1 -1
- package/dist/production/src/resolvers/ResolverFactory.cjs +6 -2
- package/dist/production/src/resolvers/ResolverFactory.cjs.map +1 -1
- package/dist/production/src/resolvers/ResolverFactory.js +7 -3
- package/dist/production/src/resolvers/ResolverFactory.js.map +1 -1
- package/dist/production/src/resolvers/SystemResolverContext.cjs +5 -5
- package/dist/production/src/resolvers/SystemResolverContext.cjs.map +1 -1
- package/dist/production/src/resolvers/SystemResolverContext.js +5 -5
- package/dist/production/src/resolvers/SystemResolverContext.js.map +1 -1
- package/dist/production/src/resolvers/mutation/MigrateMutationResolver.cjs +0 -1
- package/dist/production/src/resolvers/mutation/MigrateMutationResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/mutation/MigrateMutationResolver.js +0 -1
- package/dist/production/src/resolvers/mutation/MigrateMutationResolver.js.map +1 -1
- package/dist/production/src/resolvers/mutation/MigrationAlterMutationResolver.cjs +0 -1
- package/dist/production/src/resolvers/mutation/MigrationAlterMutationResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/mutation/MigrationAlterMutationResolver.js +0 -1
- package/dist/production/src/resolvers/mutation/MigrationAlterMutationResolver.js.map +1 -1
- package/dist/production/src/resolvers/mutation/TruncateMutationResolver.cjs +1 -1
- package/dist/production/src/resolvers/mutation/TruncateMutationResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/mutation/TruncateMutationResolver.js +1 -1
- package/dist/production/src/resolvers/mutation/TruncateMutationResolver.js.map +1 -1
- package/dist/production/src/resolvers/query/EventsQueryResolver.cjs +0 -1
- package/dist/production/src/resolvers/query/EventsQueryResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/query/EventsQueryResolver.js +0 -1
- package/dist/production/src/resolvers/query/EventsQueryResolver.js.map +1 -1
- package/dist/production/src/resolvers/query/ExecutedMigrationsQueryResolver.cjs +0 -1
- package/dist/production/src/resolvers/query/ExecutedMigrationsQueryResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/query/ExecutedMigrationsQueryResolver.js +0 -1
- package/dist/production/src/resolvers/query/ExecutedMigrationsQueryResolver.js.map +1 -1
- package/dist/production/src/resolvers/query/SchemaQueryResolver.cjs +23 -0
- package/dist/production/src/resolvers/query/SchemaQueryResolver.cjs.map +1 -0
- package/dist/production/src/resolvers/query/SchemaQueryResolver.js +23 -0
- package/dist/production/src/resolvers/query/SchemaQueryResolver.js.map +1 -0
- package/dist/production/src/resolvers/query/StagesQueryResolver.cjs +0 -1
- package/dist/production/src/resolvers/query/StagesQueryResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/query/StagesQueryResolver.js +0 -1
- package/dist/production/src/resolvers/query/StagesQueryResolver.js.map +1 -1
- package/dist/production/src/resolvers/types/EventOldValuesResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/types/EventOldValuesResolver.js.map +1 -1
- package/dist/production/src/resolvers/types/OldValuesHelpers.cjs +0 -1
- package/dist/production/src/resolvers/types/OldValuesHelpers.cjs.map +1 -1
- package/dist/production/src/resolvers/types/OldValuesHelpers.js +0 -1
- package/dist/production/src/resolvers/types/OldValuesHelpers.js.map +1 -1
- package/dist/production/src/schema/dev.graphql.cjs.map +1 -1
- package/dist/production/src/schema/system.graphql.cjs +3 -1
- package/dist/production/src/schema/system.graphql.cjs.map +1 -1
- package/dist/production/src/schema/system.graphql.js +3 -1
- package/dist/production/src/schema/system.graphql.js.map +1 -1
- package/dist/production/src/schema/types.cjs.map +1 -1
- package/dist/production/src/schema/types.js.map +1 -1
- package/dist/production/src/utils/MapSet.cjs.map +1 -1
- package/dist/production/src/utils/MapSet.js.map +1 -1
- package/dist/production/src/utils/Response.cjs.map +1 -1
- package/dist/production/src/utils/Response.js.map +1 -1
- package/dist/production/src/utils/batchQuery.cjs.map +1 -1
- package/dist/production/src/utils/batchQuery.js.map +1 -1
- package/dist/tests/cases/unit/eventsQuery.test.d.ts +2 -0
- package/dist/tests/cases/unit/eventsQuery.test.d.ts.map +1 -0
- package/dist/tests/src/uuid.d.ts +3 -0
- package/dist/tests/src/uuid.d.ts.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/SystemContainer.d.ts +8 -6
- package/dist/types/SystemContainer.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/migrations/2024-06-28-153000-schema.d.ts +3 -0
- package/dist/types/migrations/2024-06-28-153000-schema.d.ts.map +1 -0
- package/dist/types/migrations/2024-06-28-153001-schema-init.d.ts +4 -0
- package/dist/types/migrations/2024-06-28-153001-schema-init.d.ts.map +1 -0
- package/dist/types/migrations/2024-07-29-150000-event-data-index.d.ts +3 -0
- package/dist/types/migrations/2024-07-29-150000-event-data-index.d.ts.map +1 -0
- package/dist/types/migrations/runner.d.ts +3 -3
- package/dist/types/migrations/runner.d.ts.map +1 -1
- package/dist/types/migrations/snapshot.d.ts.map +1 -1
- package/dist/types/migrations/types.d.ts +2 -2
- package/dist/types/migrations/types.d.ts.map +1 -1
- package/dist/types/model/SchemaGetter.d.ts +6 -0
- package/dist/types/model/SchemaGetter.d.ts.map +1 -0
- package/dist/types/model/authorization/AuthorizationActions.d.ts +5 -0
- package/dist/types/model/authorization/AuthorizationActions.d.ts.map +1 -1
- package/dist/types/model/authorization/PermissionsFactory.d.ts.map +1 -1
- package/dist/types/model/authorization/StagePermissionsFactory.d.ts +4 -4
- package/dist/types/model/authorization/StagePermissionsFactory.d.ts.map +1 -1
- package/dist/types/model/authorization/StageScope.d.ts.map +1 -1
- package/dist/types/model/commands/schema/SaveSchemaCommand.d.ts +8 -0
- package/dist/types/model/commands/schema/SaveSchemaCommand.d.ts.map +1 -0
- package/dist/types/model/dependencies/content/ContentQueryExecutor.d.ts +3 -2
- package/dist/types/model/dependencies/content/ContentQueryExecutor.d.ts.map +1 -1
- package/dist/types/model/migrations/MigrationAlterer.d.ts +4 -0
- package/dist/types/model/migrations/MigrationAlterer.d.ts.map +1 -1
- package/dist/types/model/migrations/ProjectMigrator.d.ts +3 -3
- package/dist/types/model/migrations/ProjectMigrator.d.ts.map +1 -1
- package/dist/types/model/migrations/SchemaProvider.d.ts +28 -0
- package/dist/types/model/migrations/SchemaProvider.d.ts.map +1 -0
- package/dist/types/model/migrations/index.d.ts +1 -1
- package/dist/types/model/migrations/index.d.ts.map +1 -1
- package/dist/types/model/queries/events/EventsQuery.d.ts.map +1 -1
- package/dist/types/model/queries/index.d.ts +1 -0
- package/dist/types/model/queries/index.d.ts.map +1 -1
- package/dist/types/model/queries/schema/SchemaQuery.d.ts +8 -0
- package/dist/types/model/queries/schema/SchemaQuery.d.ts.map +1 -0
- package/dist/types/model/queries/schema/index.d.ts +2 -0
- package/dist/types/model/queries/schema/index.d.ts.map +1 -0
- package/dist/types/resolvers/ResolverFactory.d.ts +3 -1
- package/dist/types/resolvers/ResolverFactory.d.ts.map +1 -1
- package/dist/types/resolvers/SystemResolverContext.d.ts +4 -4
- package/dist/types/resolvers/SystemResolverContext.d.ts.map +1 -1
- package/dist/types/resolvers/query/SchemaQueryResolver.d.ts +7 -0
- package/dist/types/resolvers/query/SchemaQueryResolver.d.ts.map +1 -0
- package/dist/types/schema/system.graphql.d.ts.map +1 -1
- package/dist/types/schema/types.d.ts +14 -2
- package/dist/types/schema/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/graphql.codegen.yml +3 -1
- package/package.json +17 -24
- package/src/SystemContainer.ts +14 -13
- package/src/bin/runMigrations.ts +4 -4
- package/src/index.ts +3 -2
- package/src/migrations/2020-05-06-150000-composed-primary.ts +1 -1
- package/src/migrations/2020-06-01-103000-event-trigger-perf.ts +1 -1
- package/src/migrations/2021-05-07-155800-event-log-rework.ts +1 -1
- package/src/migrations/2021-05-19-1232000-event-log-fix-constraint.ts +1 -1
- package/src/migrations/2022-10-03-110000-table-on-delete.ts +1 -1
- package/src/migrations/2023-09-11-174000-fix-on-delete.ts +1 -1
- package/src/migrations/2023-10-19-173000-fix-unique.ts +1 -1
- package/src/migrations/2024-06-28-153000-schema.ts +20 -0
- package/src/migrations/2024-06-28-153001-schema-init.ts +12 -0
- package/src/migrations/2024-07-29-150000-event-data-index.ts +11 -0
- package/src/migrations/runner.ts +10 -4
- package/src/migrations/snapshot-factory.ts +1 -1
- package/src/migrations/snapshot.ts +17 -1
- package/src/migrations/types.ts +2 -2
- package/src/model/SchemaGetter.ts +3 -0
- package/src/model/authorization/AuthorizationActions.ts +1 -0
- package/src/model/authorization/PermissionsFactory.ts +1 -0
- package/src/model/authorization/StagePermissionsFactory.ts +5 -5
- package/src/model/authorization/StageScope.ts +2 -2
- package/src/model/commands/schema/SaveSchemaCommand.ts +31 -0
- package/src/model/dependencies/content/ContentQueryExecutor.ts +3 -2
- package/src/model/migrations/MigrationAlterer.ts +14 -0
- package/src/model/migrations/ProjectMigrator.ts +34 -12
- package/src/model/migrations/SchemaProvider.ts +77 -0
- package/src/model/migrations/index.ts +1 -1
- package/src/model/queries/events/EventsQuery.ts +15 -17
- package/src/model/queries/index.ts +1 -0
- package/src/model/queries/schema/SchemaQuery.ts +48 -0
- package/src/model/queries/schema/index.ts +1 -0
- package/src/resolvers/ResolverFactory.ts +9 -1
- package/src/resolvers/SystemResolverContext.ts +8 -13
- package/src/resolvers/mutation/TruncateMutationResolver.ts +1 -1
- package/src/resolvers/query/SchemaQueryResolver.ts +19 -0
- package/src/schema/system.graphql.ts +3 -1
- package/src/schema/types.ts +13 -3
- package/tests/cases/migrations/2020-05-06-150000-composed-primary.test.ts +12 -3
- package/tests/cases/migrations/2020-06-01-103000-event-trigger-perf.test.ts +12 -3
- package/tests/cases/migrations/2022-10-03-110000-table-on-delete.test.ts +20 -8
- package/tests/cases/migrations/2023-09-11-174000-fix-on-delete.test.ts +37 -16
- package/tests/cases/migrations/2023-10-19-173000-fix-unique.test.ts +12 -3
- package/tests/cases/unit/eventsQuery.test.ts +39 -0
- package/tests/src/uuid.ts +4 -0
- package/dist/development/src/model/migrations/SchemaVersionBuilder.cjs +0 -37
- package/dist/development/src/model/migrations/SchemaVersionBuilder.cjs.map +0 -1
- package/dist/development/src/model/migrations/SchemaVersionBuilder.js +0 -37
- package/dist/development/src/model/migrations/SchemaVersionBuilder.js.map +0 -1
- package/dist/production/src/model/migrations/SchemaVersionBuilder.cjs +0 -37
- package/dist/production/src/model/migrations/SchemaVersionBuilder.cjs.map +0 -1
- package/dist/production/src/model/migrations/SchemaVersionBuilder.js +0 -37
- package/dist/production/src/model/migrations/SchemaVersionBuilder.js.map +0 -1
- package/dist/types/model/migrations/SchemaVersionBuilder.d.ts +0 -37
- package/dist/types/model/migrations/SchemaVersionBuilder.d.ts.map +0 -1
- package/src/model/migrations/SchemaVersionBuilder.ts +0 -43
|
@@ -6,17 +6,19 @@ import { Stage } from '../dtos'
|
|
|
6
6
|
import { DatabaseContext } from '../database'
|
|
7
7
|
import { ExecutedMigrationsResolver } from './ExecutedMigrationsResolver'
|
|
8
8
|
import { MigrateErrorCode } from '../../schema'
|
|
9
|
-
import {
|
|
10
|
-
import { SchemaValidator, SchemaValidatorSkippedErrors } from '@contember/schema-utils'
|
|
9
|
+
import { calculateSchemaChecksum, SchemaValidator, SchemaValidatorSkippedErrors } from '@contember/schema-utils'
|
|
11
10
|
import { logger } from '@contember/logger'
|
|
12
11
|
import { MigrationsDatabaseMetadataResolverStoreFactory, SchemaDatabaseMetadataResolverStore } from '../metadata'
|
|
13
12
|
import { ContentMigrationQuery, MigrationInput } from './MigrationInput'
|
|
14
13
|
import { ContentQueryExecutor } from '../dependencies'
|
|
14
|
+
import { SchemaProvider } from './SchemaProvider'
|
|
15
|
+
import { SaveSchemaCommand } from '../commands/schema/SaveSchemaCommand'
|
|
16
|
+
import { ImplementationException } from '../../utils'
|
|
15
17
|
|
|
16
18
|
export class ProjectMigrator {
|
|
17
19
|
constructor(
|
|
18
20
|
private readonly migrationDescriber: MigrationDescriber,
|
|
19
|
-
private readonly
|
|
21
|
+
private readonly schemaProvider: SchemaProvider,
|
|
20
22
|
private readonly executedMigrationsResolver: ExecutedMigrationsResolver,
|
|
21
23
|
private readonly migrationsDatabaseMetadataResolverStoreFactory: MigrationsDatabaseMetadataResolverStoreFactory,
|
|
22
24
|
private readonly contentQueryExecutor: ContentQueryExecutor,
|
|
@@ -36,8 +38,14 @@ export class ProjectMigrator {
|
|
|
36
38
|
if (migrationsToExecute.length === 0) {
|
|
37
39
|
return
|
|
38
40
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
const schemaWithMeta = await this.schemaProvider.fetch({ db })
|
|
42
|
+
let schema = schemaWithMeta.schema
|
|
43
|
+
let id = schemaWithMeta.meta.id
|
|
44
|
+
|
|
45
|
+
const validated = await this.validateMigrations(db, schema, schemaWithMeta.meta.version ?? null, migrationsToExecute, { ignoreOrder, skipExecuted })
|
|
46
|
+
if (validated.length === 0) {
|
|
47
|
+
return
|
|
48
|
+
}
|
|
41
49
|
|
|
42
50
|
const sorted = [...validated].sort((a, b) => a.version.localeCompare(b.version))
|
|
43
51
|
|
|
@@ -61,16 +69,16 @@ export class ProjectMigrator {
|
|
|
61
69
|
)
|
|
62
70
|
}
|
|
63
71
|
} else if (migration.type === 'content') {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
id,
|
|
72
|
+
if (!id) {
|
|
73
|
+
throw new FailedContentMigrationError(migration.version, `Cannot execute content migration without schema`)
|
|
67
74
|
}
|
|
68
75
|
for (const query of migration.queries) {
|
|
69
76
|
await this.executeContentMigration({
|
|
70
77
|
version: migration.version,
|
|
71
78
|
query,
|
|
72
79
|
db,
|
|
73
|
-
schema
|
|
80
|
+
schema,
|
|
81
|
+
schemaMeta: { id },
|
|
74
82
|
stages,
|
|
75
83
|
databaseMetadata: await metadataStore.getMetadata(db.client.schema),
|
|
76
84
|
identity,
|
|
@@ -84,6 +92,19 @@ export class ProjectMigrator {
|
|
|
84
92
|
}
|
|
85
93
|
id = await db.commandBus.execute(new SaveMigrationCommand(migration))
|
|
86
94
|
}
|
|
95
|
+
if (!id) {
|
|
96
|
+
throw new ImplementationException()
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
await db.commandBus.execute(new SaveSchemaCommand({
|
|
100
|
+
schema,
|
|
101
|
+
meta: {
|
|
102
|
+
id,
|
|
103
|
+
updatedAt: new Date(),
|
|
104
|
+
version: sorted[sorted.length - 1].version,
|
|
105
|
+
checksum: calculateSchemaChecksum(schema),
|
|
106
|
+
},
|
|
107
|
+
}))
|
|
87
108
|
}
|
|
88
109
|
|
|
89
110
|
private async executeContentMigration({ query, stages, version, ...ctx }: {
|
|
@@ -91,7 +112,8 @@ export class ProjectMigrator {
|
|
|
91
112
|
db: DatabaseContext
|
|
92
113
|
query: ContentMigrationQuery
|
|
93
114
|
stages: Stage[]
|
|
94
|
-
schema: Schema
|
|
115
|
+
schema: Schema
|
|
116
|
+
schemaMeta: { id: number }
|
|
95
117
|
project: { slug: string; systemSchema: string }
|
|
96
118
|
identity: { id: string }
|
|
97
119
|
databaseMetadata: DatabaseMetadata
|
|
@@ -120,7 +142,7 @@ export class ProjectMigrator {
|
|
|
120
142
|
private async validateMigrations(
|
|
121
143
|
db: DatabaseContext,
|
|
122
144
|
schema: Schema,
|
|
123
|
-
version: string,
|
|
145
|
+
version: string | null,
|
|
124
146
|
migrationsToExecute: readonly MigrationInput[],
|
|
125
147
|
{ ignoreOrder, skipExecuted }: {
|
|
126
148
|
ignoreOrder: boolean
|
|
@@ -140,7 +162,7 @@ export class ProjectMigrator {
|
|
|
140
162
|
}
|
|
141
163
|
}
|
|
142
164
|
|
|
143
|
-
if (migration.version < version && !ignoreOrder) {
|
|
165
|
+
if (version && migration.version < version && !ignoreOrder) {
|
|
144
166
|
throw new MustFollowLatestMigrationError(migration.version, `Must follow latest executed migration ${version}`)
|
|
145
167
|
}
|
|
146
168
|
if (migration.type === 'schema') {
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { SchemaQuery } from '../queries'
|
|
2
|
+
import { DatabaseContext } from '../database'
|
|
3
|
+
import { calculateSchemaChecksum, emptySchema, normalizeSchema } from '@contember/schema-utils'
|
|
4
|
+
import { ExecutedMigrationsResolver } from './ExecutedMigrationsResolver'
|
|
5
|
+
import { SchemaMigrator } from '@contember/schema-migrations'
|
|
6
|
+
import { Schema } from '@contember/schema'
|
|
7
|
+
|
|
8
|
+
export type SchemaMeta = {
|
|
9
|
+
checksum: string
|
|
10
|
+
version: string
|
|
11
|
+
updatedAt: Date
|
|
12
|
+
id: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const emptyVersionedSchema: SchemaWithMeta = {
|
|
16
|
+
schema: emptySchema,
|
|
17
|
+
meta: {},
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type SchemaWithMeta = {
|
|
21
|
+
schema: Schema
|
|
22
|
+
meta: SchemaMeta | { [K in keyof SchemaMeta]?: undefined }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export class SchemaProvider {
|
|
26
|
+
constructor(
|
|
27
|
+
private readonly executedMigrationsResolver: ExecutedMigrationsResolver,
|
|
28
|
+
private readonly schemaMigrator: SchemaMigrator,
|
|
29
|
+
) {
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async buildSchemaFromMigrations(db: DatabaseContext): Promise<SchemaWithMeta> {
|
|
33
|
+
const newMigrations = (await this.executedMigrationsResolver.getMigrations(db))
|
|
34
|
+
|
|
35
|
+
const partialResult = newMigrations.reduce<SchemaWithMeta>(
|
|
36
|
+
(schema, migration) => {
|
|
37
|
+
if (migration.type !== 'schema') {
|
|
38
|
+
return schema
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
schema: this.schemaMigrator.applyModifications(schema.schema, migration.modifications, migration.formatVersion),
|
|
42
|
+
meta: {
|
|
43
|
+
version: migration.version,
|
|
44
|
+
id: migration.id,
|
|
45
|
+
updatedAt: migration.executedAt,
|
|
46
|
+
checksum: '',
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
emptyVersionedSchema,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
if (!partialResult.meta.version) {
|
|
54
|
+
return emptyVersionedSchema
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
schema: partialResult.schema,
|
|
59
|
+
meta: {
|
|
60
|
+
...partialResult.meta,
|
|
61
|
+
checksum: calculateSchemaChecksum(partialResult.schema),
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public async fetch({ db, currentSchema }: {
|
|
67
|
+
db: DatabaseContext
|
|
68
|
+
currentSchema?: SchemaWithMeta | null
|
|
69
|
+
}): Promise<SchemaWithMeta> {
|
|
70
|
+
const newSchema = await db.queryHandler.fetch(new SchemaQuery(currentSchema?.meta.checksum))
|
|
71
|
+
if (!newSchema) {
|
|
72
|
+
return currentSchema ?? emptyVersionedSchema
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return newSchema
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
ConditionBuilder,
|
|
3
3
|
DatabaseQuery,
|
|
4
4
|
DatabaseQueryable,
|
|
5
|
+
Literal,
|
|
5
6
|
Operator,
|
|
6
7
|
SelectBuilder,
|
|
7
8
|
SelectBuilderSpecification, Value,
|
|
@@ -78,23 +79,20 @@ export class EventsQuery extends DatabaseQuery<ContentEvent[]> {
|
|
|
78
79
|
if (!this.filter.rows) {
|
|
79
80
|
return qb
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
expr.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
ConditionBuilder.create(),
|
|
96
|
-
)
|
|
97
|
-
return qb.where(ConditionBuilder.create().or(ors))
|
|
82
|
+
|
|
83
|
+
const ors: Literal[] = this.filter.rows.map(row => {
|
|
84
|
+
const builder = ConditionBuilder.create()
|
|
85
|
+
.compare('table_name', Operator.eq, row.tableName)
|
|
86
|
+
|
|
87
|
+
return row.primaryKey.reduce((expr, val, index) => {
|
|
88
|
+
if (val === null) {
|
|
89
|
+
return expr
|
|
90
|
+
}
|
|
91
|
+
return expr.raw(`"row_ids"->${index} = ?::jsonb`, JSON.stringify(val))
|
|
92
|
+
}, builder).getSql()
|
|
93
|
+
}).filter((it): it is Literal => it !== null)
|
|
94
|
+
|
|
95
|
+
return qb.where(ConditionBuilder.create().or(ConditionBuilder.create(ors)))
|
|
98
96
|
})
|
|
99
97
|
|
|
100
98
|
.limit(this.limit, this.offset)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { DatabaseQuery, DatabaseQueryable, Literal, SelectBuilder } from '@contember/database'
|
|
2
|
+
import { Schema } from '@contember/schema'
|
|
3
|
+
import { SchemaWithMeta } from '../../migrations'
|
|
4
|
+
|
|
5
|
+
export class SchemaQuery extends DatabaseQuery<SchemaWithMeta | null> {
|
|
6
|
+
|
|
7
|
+
constructor(
|
|
8
|
+
private readonly currentHash?: string,
|
|
9
|
+
) {
|
|
10
|
+
super()
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
async fetch(queryable: DatabaseQueryable): Promise<SchemaWithMeta | null> {
|
|
15
|
+
const query = SelectBuilder.create<{
|
|
16
|
+
schema: Schema
|
|
17
|
+
checksum: string
|
|
18
|
+
version: string
|
|
19
|
+
updated_at: Date
|
|
20
|
+
migration_id: number
|
|
21
|
+
}>()
|
|
22
|
+
.from('schema')
|
|
23
|
+
.select(new Literal('*'))
|
|
24
|
+
.where({
|
|
25
|
+
id: 'single',
|
|
26
|
+
})
|
|
27
|
+
.match(it => {
|
|
28
|
+
if (!this.currentHash) {
|
|
29
|
+
return it
|
|
30
|
+
}
|
|
31
|
+
return it.where(it => it.raw('checksum != ?', this.currentHash))
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const row = this.fetchOneOrNull(await query.getResult(queryable.db))
|
|
35
|
+
if (!row) {
|
|
36
|
+
return null
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
schema: row.schema,
|
|
40
|
+
meta: {
|
|
41
|
+
checksum: row.checksum,
|
|
42
|
+
version: row.version,
|
|
43
|
+
updatedAt: row.updated_at,
|
|
44
|
+
id: row.migration_id,
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SchemaQuery'
|
|
@@ -2,9 +2,10 @@ import { EventsQueryResolver, ExecutedMigrationsQueryResolver, StagesQueryResolv
|
|
|
2
2
|
import { Event, EventType, Resolvers } from '../schema'
|
|
3
3
|
import { assertNever } from '../utils'
|
|
4
4
|
import { MigrateMutationResolver, MigrationAlterMutationResolver, TruncateMutationResolver } from './mutation'
|
|
5
|
-
import { DateTimeType, JSONType } from '@contember/graphql-utils'
|
|
5
|
+
import { DateTimeType, JSONType, createJsonLikeType } from '@contember/graphql-utils'
|
|
6
6
|
import { EventOldValuesResolver } from './types'
|
|
7
7
|
import { GraphQLError, GraphQLScalarType, Kind } from 'graphql'
|
|
8
|
+
import { SchemaQueryResolver } from './query/SchemaQueryResolver'
|
|
8
9
|
|
|
9
10
|
export class ResolverFactory {
|
|
10
11
|
public constructor(
|
|
@@ -15,6 +16,7 @@ export class ResolverFactory {
|
|
|
15
16
|
private readonly migrationAlterMutationResolver: MigrationAlterMutationResolver,
|
|
16
17
|
private readonly eventsQueryResolver: EventsQueryResolver,
|
|
17
18
|
private readonly eventOldValuesResolver: EventOldValuesResolver,
|
|
19
|
+
private readonly schemaQueryResolver: SchemaQueryResolver,
|
|
18
20
|
) {}
|
|
19
21
|
|
|
20
22
|
create(debugMode: boolean): Resolvers {
|
|
@@ -22,6 +24,7 @@ export class ResolverFactory {
|
|
|
22
24
|
DateTime: DateTimeType,
|
|
23
25
|
Json: JSONType,
|
|
24
26
|
PrimaryKey: PrimaryKeyType,
|
|
27
|
+
Schema: SchemaType,
|
|
25
28
|
Event: {
|
|
26
29
|
__resolveType: (obj: Event) => {
|
|
27
30
|
switch (obj.type) {
|
|
@@ -43,6 +46,7 @@ export class ResolverFactory {
|
|
|
43
46
|
stages: this.stagesQueryResolver.stages.bind(this.stagesQueryResolver),
|
|
44
47
|
executedMigrations: this.executedMigrationsQueryResolver.executedMigrations.bind(this.executedMigrationsQueryResolver),
|
|
45
48
|
events: this.eventsQueryResolver.events.bind(this.eventsQueryResolver),
|
|
49
|
+
schema: this.schemaQueryResolver.schema.bind(this.schemaQueryResolver),
|
|
46
50
|
},
|
|
47
51
|
Mutation: {
|
|
48
52
|
migrate: this.migrateMutationResolver.migrate.bind(this.migrateMutationResolver),
|
|
@@ -70,6 +74,10 @@ const parseValue = (value: any) => {
|
|
|
70
74
|
}
|
|
71
75
|
throw new GraphQLError('PrimaryKey cannot represent value: ' + JSON.stringify(value))
|
|
72
76
|
}
|
|
77
|
+
|
|
78
|
+
const SchemaType = createJsonLikeType('Schema', 'Content schema custom scalar type')
|
|
79
|
+
|
|
80
|
+
|
|
73
81
|
export const PrimaryKeyType = new GraphQLScalarType({
|
|
74
82
|
name: 'PrimaryKey',
|
|
75
83
|
description: 'PrimaryKey custom scalar type. Can be Int or String',
|
|
@@ -1,31 +1,26 @@
|
|
|
1
1
|
import { Authorizator } from '@contember/authorization'
|
|
2
|
-
import { Schema } from '@contember/schema'
|
|
3
2
|
import { ForbiddenError } from '@contember/graphql-utils'
|
|
4
|
-
import { DatabaseContext, Identity
|
|
3
|
+
import { DatabaseContext, Identity } from '../model'
|
|
5
4
|
import { ProjectConfig } from '../types'
|
|
6
5
|
import { StagePermissionsFactory } from '../model/authorization/StagePermissionsFactory'
|
|
7
6
|
import { StageScope } from '../model/authorization/StageScope'
|
|
8
7
|
import { ItemLoader } from '../utils/batchQuery'
|
|
8
|
+
import { SchemaGetter } from '../model/SchemaGetter'
|
|
9
9
|
|
|
10
10
|
export class SystemResolverContextFactory {
|
|
11
11
|
constructor(
|
|
12
12
|
private readonly authorizator: Authorizator<Identity>,
|
|
13
13
|
) {}
|
|
14
14
|
|
|
15
|
-
public async create(
|
|
16
|
-
|
|
17
|
-
systemDbContext: DatabaseContext,
|
|
18
|
-
project: ProjectConfig,
|
|
19
|
-
identity: Identity,
|
|
20
|
-
): Promise<SystemResolverContext> {
|
|
21
|
-
const stagePermissionsFactory = new StagePermissionsFactory(schema)
|
|
15
|
+
public async create({ getSchema, identity, project, db }: Pick<SystemResolverContext, 'getSchema' | 'db' | 'identity' | 'project'>): Promise<SystemResolverContext> {
|
|
16
|
+
const stagePermissionsFactory = new StagePermissionsFactory(getSchema)
|
|
22
17
|
const loaders = new Map<LoaderFactory<any, any>, ItemLoader<any, any>>()
|
|
23
18
|
return {
|
|
24
19
|
project,
|
|
25
20
|
identity,
|
|
26
|
-
|
|
21
|
+
getSchema,
|
|
27
22
|
authorizator: this.authorizator,
|
|
28
|
-
db
|
|
23
|
+
db,
|
|
29
24
|
requireAccess: async (action, stage, message?) => {
|
|
30
25
|
if (!(await this.authorizator.isAllowed(identity, new StageScope(stage, stagePermissionsFactory), action))) {
|
|
31
26
|
throw new ForbiddenError(message || 'Forbidden')
|
|
@@ -36,7 +31,7 @@ export class SystemResolverContextFactory {
|
|
|
36
31
|
if (loader) {
|
|
37
32
|
return loader
|
|
38
33
|
}
|
|
39
|
-
const newLoader = loaderFactory(
|
|
34
|
+
const newLoader = loaderFactory(db)
|
|
40
35
|
loaders.set(loaderFactory, newLoader)
|
|
41
36
|
return newLoader
|
|
42
37
|
},
|
|
@@ -48,7 +43,7 @@ export type LoaderFactory<Args, Item> = (db: DatabaseContext) => ItemLoader<Args
|
|
|
48
43
|
|
|
49
44
|
export interface SystemResolverContext {
|
|
50
45
|
readonly project: ProjectConfig
|
|
51
|
-
readonly
|
|
46
|
+
readonly getSchema: SchemaGetter
|
|
52
47
|
readonly identity: Identity
|
|
53
48
|
readonly db: DatabaseContext
|
|
54
49
|
readonly authorizator: Authorizator<Identity>
|
|
@@ -12,7 +12,7 @@ export class TruncateMutationResolver implements MutationResolver<'truncate'> {
|
|
|
12
12
|
context: SystemResolverContext,
|
|
13
13
|
info: GraphQLResolveInfo,
|
|
14
14
|
): Promise<TruncateResponse> {
|
|
15
|
-
await this.projectTruncateExecutor.truncateProject(context.db, context.project, context.
|
|
15
|
+
await this.projectTruncateExecutor.truncateProject(context.db, context.project, await context.getSchema())
|
|
16
16
|
return {
|
|
17
17
|
ok: true,
|
|
18
18
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { GraphQLResolveInfo } from 'graphql'
|
|
2
|
+
import { SystemResolverContext } from '../SystemResolverContext'
|
|
3
|
+
import { QueryResolver } from '../Resolver'
|
|
4
|
+
import { AuthorizationActions, StagesQuery } from '../../model'
|
|
5
|
+
|
|
6
|
+
export class SchemaQueryResolver implements QueryResolver<'schema'> {
|
|
7
|
+
async schema(
|
|
8
|
+
parent: any,
|
|
9
|
+
args: unknown,
|
|
10
|
+
context: SystemResolverContext,
|
|
11
|
+
info: GraphQLResolveInfo,
|
|
12
|
+
) {
|
|
13
|
+
const stages = await context.db.queryHandler.fetch(new StagesQuery())
|
|
14
|
+
for (const stage of stages) {
|
|
15
|
+
await context.requireAccess(AuthorizationActions.PROJECT_SHOW_SCHEMA, stage.slug)
|
|
16
|
+
}
|
|
17
|
+
return context.getSchema()
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -5,6 +5,7 @@ const schema: DocumentNode = gql`
|
|
|
5
5
|
scalar DateTime
|
|
6
6
|
scalar Json
|
|
7
7
|
scalar PrimaryKey
|
|
8
|
+
scalar Schema
|
|
8
9
|
|
|
9
10
|
schema {
|
|
10
11
|
query: Query
|
|
@@ -15,6 +16,7 @@ const schema: DocumentNode = gql`
|
|
|
15
16
|
stages: [Stage!]!
|
|
16
17
|
executedMigrations(version: String): [ExecutedMigration!]!
|
|
17
18
|
events(args: EventsArgs): [Event!]!
|
|
19
|
+
schema: Schema!
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
type Mutation {
|
|
@@ -56,7 +58,7 @@ const schema: DocumentNode = gql`
|
|
|
56
58
|
|
|
57
59
|
input EventFilterRow {
|
|
58
60
|
tableName: String!
|
|
59
|
-
primaryKey: [PrimaryKey
|
|
61
|
+
primaryKey: [PrimaryKey]!
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
interface Event {
|
package/src/schema/types.ts
CHANGED
|
@@ -16,7 +16,8 @@ export type Scalars = {
|
|
|
16
16
|
Float: { input: number; output: number }
|
|
17
17
|
DateTime: { input: Date; output: Date }
|
|
18
18
|
Json: { input: unknown; output: unknown }
|
|
19
|
-
PrimaryKey: { input:
|
|
19
|
+
PrimaryKey: { input: string | number; output: string | number }
|
|
20
|
+
Schema: { input: any; output: any }
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export type ContentMigration = {
|
|
@@ -70,7 +71,7 @@ export type Event = {
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
export type EventFilterRow = {
|
|
73
|
-
readonly primaryKey: ReadonlyArray<Scalars['PrimaryKey']['input']
|
|
74
|
+
readonly primaryKey: ReadonlyArray<InputMaybe<Scalars['PrimaryKey']['input']>>
|
|
74
75
|
readonly tableName: Scalars['String']['input']
|
|
75
76
|
}
|
|
76
77
|
|
|
@@ -250,6 +251,7 @@ export type Query = {
|
|
|
250
251
|
readonly __typename?: 'Query'
|
|
251
252
|
readonly events: ReadonlyArray<Event>
|
|
252
253
|
readonly executedMigrations: ReadonlyArray<ExecutedMigration>
|
|
254
|
+
readonly schema: Scalars['Schema']['output']
|
|
253
255
|
readonly stages: ReadonlyArray<Stage>
|
|
254
256
|
}
|
|
255
257
|
|
|
@@ -366,7 +368,7 @@ export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs
|
|
|
366
368
|
|
|
367
369
|
|
|
368
370
|
/** Mapping of interface types */
|
|
369
|
-
export type ResolversInterfaceTypes<
|
|
371
|
+
export type ResolversInterfaceTypes<_RefType extends Record<string, unknown>> = {
|
|
370
372
|
Event: (CreateEvent) | (DeleteEvent) | (UpdateEvent)
|
|
371
373
|
}
|
|
372
374
|
|
|
@@ -404,6 +406,7 @@ export type ResolversTypes = {
|
|
|
404
406
|
Mutation: ResolverTypeWrapper<{}>
|
|
405
407
|
PrimaryKey: ResolverTypeWrapper<Scalars['PrimaryKey']['output']>
|
|
406
408
|
Query: ResolverTypeWrapper<{}>
|
|
409
|
+
Schema: ResolverTypeWrapper<Scalars['Schema']['output']>
|
|
407
410
|
SchemaMigration: SchemaMigration
|
|
408
411
|
Stage: ResolverTypeWrapper<Stage>
|
|
409
412
|
String: ResolverTypeWrapper<Scalars['String']['output']>
|
|
@@ -439,6 +442,7 @@ export type ResolversParentTypes = {
|
|
|
439
442
|
Mutation: {}
|
|
440
443
|
PrimaryKey: Scalars['PrimaryKey']['output']
|
|
441
444
|
Query: {}
|
|
445
|
+
Schema: Scalars['Schema']['output']
|
|
442
446
|
SchemaMigration: SchemaMigration
|
|
443
447
|
Stage: Stage
|
|
444
448
|
String: Scalars['String']['output']
|
|
@@ -567,9 +571,14 @@ export interface PrimaryKeyScalarConfig extends GraphQLScalarTypeConfig<Resolver
|
|
|
567
571
|
export type QueryResolvers<ContextType = any, ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query']> = {
|
|
568
572
|
events?: Resolver<ReadonlyArray<ResolversTypes['Event']>, ParentType, ContextType, Partial<QueryEventsArgs>>
|
|
569
573
|
executedMigrations?: Resolver<ReadonlyArray<ResolversTypes['ExecutedMigration']>, ParentType, ContextType, Partial<QueryExecutedMigrationsArgs>>
|
|
574
|
+
schema?: Resolver<ResolversTypes['Schema'], ParentType, ContextType>
|
|
570
575
|
stages?: Resolver<ReadonlyArray<ResolversTypes['Stage']>, ParentType, ContextType>
|
|
571
576
|
}
|
|
572
577
|
|
|
578
|
+
export interface SchemaScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['Schema'], any> {
|
|
579
|
+
name: 'Schema'
|
|
580
|
+
}
|
|
581
|
+
|
|
573
582
|
export type StageResolvers<ContextType = any, ParentType extends ResolversParentTypes['Stage'] = ResolversParentTypes['Stage']> = {
|
|
574
583
|
id?: Resolver<ResolversTypes['String'], ParentType, ContextType>
|
|
575
584
|
name?: Resolver<ResolversTypes['String'], ParentType, ContextType>
|
|
@@ -615,6 +624,7 @@ export type Resolvers<ContextType = any> = {
|
|
|
615
624
|
Mutation?: MutationResolvers<ContextType>
|
|
616
625
|
PrimaryKey?: GraphQLScalarType
|
|
617
626
|
Query?: QueryResolvers<ContextType>
|
|
627
|
+
Schema?: GraphQLScalarType
|
|
618
628
|
Stage?: StageResolvers<ContextType>
|
|
619
629
|
TruncateResponse?: TruncateResponseResolvers<ContextType>
|
|
620
630
|
UpdateEvent?: UpdateEventResolvers<ContextType>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { emptyDatabaseMetadata } from '@contember/database'
|
|
2
2
|
import migration from '../../../src/migrations/2020-05-06-150000-composed-primary'
|
|
3
3
|
import { createMigrationBuilder } from '@contember/database-migrations'
|
|
4
|
-
import {
|
|
4
|
+
import { expect, test } from 'bun:test'
|
|
5
5
|
import { c, createSchema } from '@contember/schema-definition'
|
|
6
6
|
|
|
7
7
|
namespace SampleProject {
|
|
@@ -37,7 +37,15 @@ test('many-has-many-primary migration sql', async () => {
|
|
|
37
37
|
const builder = createMigrationBuilder()
|
|
38
38
|
await migration(builder, {
|
|
39
39
|
connection: undefined as any,
|
|
40
|
-
schemaResolver: () => Promise.resolve(
|
|
40
|
+
schemaResolver: () => Promise.resolve({
|
|
41
|
+
schema: createSchema(SampleProject),
|
|
42
|
+
meta: {
|
|
43
|
+
id: 1,
|
|
44
|
+
version: '2024-06-28-153001',
|
|
45
|
+
checksum: '_checksum_',
|
|
46
|
+
updatedAt: new Date(),
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
41
49
|
databaseMetadataResolver: () => Promise.resolve(emptyDatabaseMetadata),
|
|
42
50
|
project: {
|
|
43
51
|
slug: 'test',
|
|
@@ -54,8 +62,9 @@ test('many-has-many-primary migration sql', async () => {
|
|
|
54
62
|
],
|
|
55
63
|
},
|
|
56
64
|
})
|
|
57
|
-
|
|
65
|
+
expect(
|
|
58
66
|
builder.getSql(),
|
|
67
|
+
).toEqual(
|
|
59
68
|
`ALTER TABLE "stage_prod"."post_tags"
|
|
60
69
|
DROP "id";
|
|
61
70
|
ALTER TABLE "stage_prod"."post_tags" DROP CONSTRAINT "post_tags_uniq_post_id_tag_id";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import migration from '../../../src/migrations/2020-06-01-103000-event-trigger-perf'
|
|
2
2
|
import { createMigrationBuilder } from '@contember/database-migrations'
|
|
3
|
-
import {
|
|
3
|
+
import { expect, test } from 'bun:test'
|
|
4
4
|
import { emptyDatabaseMetadata } from '@contember/database'
|
|
5
5
|
import { c, createSchema } from '@contember/schema-definition'
|
|
6
6
|
|
|
@@ -37,7 +37,15 @@ test('event-trigger-performance sql', async () => {
|
|
|
37
37
|
const builder = createMigrationBuilder()
|
|
38
38
|
await migration(builder, {
|
|
39
39
|
connection: undefined as any,
|
|
40
|
-
schemaResolver: () => Promise.resolve(
|
|
40
|
+
schemaResolver: () => Promise.resolve({
|
|
41
|
+
schema: createSchema(SampleProject),
|
|
42
|
+
meta: {
|
|
43
|
+
id: 1,
|
|
44
|
+
version: '2024-06-28-153001',
|
|
45
|
+
checksum: '_checksum_',
|
|
46
|
+
updatedAt: new Date(),
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
41
49
|
databaseMetadataResolver: () => Promise.resolve(emptyDatabaseMetadata),
|
|
42
50
|
project: {
|
|
43
51
|
slug: 'test',
|
|
@@ -54,8 +62,9 @@ test('event-trigger-performance sql', async () => {
|
|
|
54
62
|
],
|
|
55
63
|
},
|
|
56
64
|
})
|
|
57
|
-
|
|
65
|
+
expect(
|
|
58
66
|
builder.getSql(),
|
|
67
|
+
).toEqual(
|
|
59
68
|
`CREATE OR REPLACE FUNCTION "trigger_event"() RETURNS TRIGGER AS $$
|
|
60
69
|
DECLARE
|
|
61
70
|
DECLARE new_event_type TEXT;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import migration from '../../../src/migrations/2022-10-03-110000-table-on-delete'
|
|
2
2
|
import { createMigrationBuilder } from '@contember/database-migrations'
|
|
3
|
-
import {
|
|
3
|
+
import { expect, test } from 'bun:test'
|
|
4
4
|
import { SchemaBuilder } from '@contember/schema-definition'
|
|
5
5
|
import { emptySchema } from '@contember/schema-utils'
|
|
6
6
|
import { Model } from '@contember/schema'
|
|
@@ -30,12 +30,23 @@ test('table-on-delete test', async () => {
|
|
|
30
30
|
deferred: false,
|
|
31
31
|
}],
|
|
32
32
|
})),
|
|
33
|
-
schemaResolver: () => Promise.resolve(({
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
schemaResolver: () => Promise.resolve(({
|
|
34
|
+
schema: {
|
|
35
|
+
...emptySchema,
|
|
36
|
+
model: new SchemaBuilder()
|
|
37
|
+
.entity('Post', entity =>
|
|
38
|
+
entity.manyHasOne('author', relation => relation.target('Author').onDelete(Model.OnDelete.setNull)),
|
|
39
|
+
)
|
|
40
|
+
.entity('Author', entity => entity)
|
|
41
|
+
.buildSchema(),
|
|
42
|
+
},
|
|
43
|
+
meta: {
|
|
44
|
+
id: 1,
|
|
45
|
+
version: '2024-06-28-153001',
|
|
46
|
+
checksum: '_checksum_',
|
|
47
|
+
updatedAt: new Date(),
|
|
48
|
+
},
|
|
49
|
+
})),
|
|
39
50
|
project: {
|
|
40
51
|
slug: 'test',
|
|
41
52
|
systemSchema: 'system',
|
|
@@ -47,8 +58,9 @@ test('table-on-delete test', async () => {
|
|
|
47
58
|
],
|
|
48
59
|
},
|
|
49
60
|
})
|
|
50
|
-
|
|
61
|
+
expect(
|
|
51
62
|
builder.getSql(),
|
|
63
|
+
).toEqual(
|
|
52
64
|
`ALTER TABLE "stage_live"."post" DROP CONSTRAINT "fk_post_author_id_author_id";
|
|
53
65
|
ALTER TABLE "stage_live"."post"
|
|
54
66
|
ADD FOREIGN KEY ("author_id")
|