@contember/engine-system-api 2.0.0-alpha.9 → 2.0.0-beta.1
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
package/graphql.codegen.yml
CHANGED
|
@@ -7,6 +7,8 @@ config:
|
|
|
7
7
|
scalars:
|
|
8
8
|
DateTime: Date
|
|
9
9
|
Json: unknown
|
|
10
|
+
PrimaryKey: "string | number"
|
|
11
|
+
ContentSchema: unknown
|
|
10
12
|
generates:
|
|
11
13
|
./src/schema/types.ts:
|
|
12
14
|
config:
|
|
@@ -17,4 +19,4 @@ generates:
|
|
|
17
19
|
- "typescript-resolvers"
|
|
18
20
|
hooks:
|
|
19
21
|
afterAllFileWrite:
|
|
20
|
-
- eslint --fix
|
|
22
|
+
- bun run -T eslint --fix
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/engine-system-api",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/production/index.js",
|
|
6
6
|
"typings": "./dist/types/index.d.ts",
|
|
@@ -22,36 +22,29 @@
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
-
"scripts": {
|
|
26
|
-
"generate": "gql-gen --config graphql.codegen.yml"
|
|
27
|
-
},
|
|
28
25
|
"dependencies": {
|
|
29
|
-
"@contember/authorization": "2.0.0-
|
|
30
|
-
"@contember/database": "2.0.0-
|
|
31
|
-
"@contember/database-migrations": "2.0.0-
|
|
32
|
-
"@contember/dic": "2.0.0-
|
|
33
|
-
"@contember/graphql-utils": "2.0.0-
|
|
34
|
-
"@contember/logger": "2.0.0-
|
|
35
|
-
"@contember/queryable": "2.0.0-
|
|
36
|
-
"@contember/schema": "2.0.0-
|
|
37
|
-
"@contember/schema-migrations": "2.0.0-
|
|
38
|
-
"@contember/schema-utils": "2.0.0-
|
|
39
|
-
"@graphql-tools/utils": "^10.
|
|
26
|
+
"@contember/authorization": "2.0.0-beta.1",
|
|
27
|
+
"@contember/database": "2.0.0-beta.1",
|
|
28
|
+
"@contember/database-migrations": "2.0.0-beta.1",
|
|
29
|
+
"@contember/dic": "2.0.0-beta.1",
|
|
30
|
+
"@contember/graphql-utils": "2.0.0-beta.1",
|
|
31
|
+
"@contember/logger": "2.0.0-beta.1",
|
|
32
|
+
"@contember/queryable": "2.0.0-beta.1",
|
|
33
|
+
"@contember/schema": "2.0.0-beta.1",
|
|
34
|
+
"@contember/schema-migrations": "2.0.0-beta.1",
|
|
35
|
+
"@contember/schema-utils": "2.0.0-beta.1",
|
|
36
|
+
"@graphql-tools/utils": "^10.5.5",
|
|
40
37
|
"graphql-tag": "^2.12.6"
|
|
41
38
|
},
|
|
42
39
|
"devDependencies": {
|
|
43
|
-
"@contember/schema-definition": "2.0.0-
|
|
44
|
-
"@
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"@graphql-codegen/typescript-resolvers": "^4.0.1",
|
|
48
|
-
"@types/node": "^20.9.0",
|
|
49
|
-
"graphql": "^16.8.1",
|
|
50
|
-
"pg": "^8.11.3"
|
|
40
|
+
"@contember/schema-definition": "2.0.0-beta.1",
|
|
41
|
+
"@types/node": "^20.16.11",
|
|
42
|
+
"graphql": "^16.9.0",
|
|
43
|
+
"pg": "^8.12.0"
|
|
51
44
|
},
|
|
52
45
|
"peerDependencies": {
|
|
53
46
|
"graphql": ">= 14.6.0",
|
|
54
47
|
"pg": "^8.9.0"
|
|
55
48
|
},
|
|
56
49
|
"type": "module"
|
|
57
|
-
}
|
|
50
|
+
}
|
package/src/SystemContainer.ts
CHANGED
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
PermissionsFactory,
|
|
17
17
|
ProjectMigrator,
|
|
18
18
|
ProjectTruncateExecutor,
|
|
19
|
-
SchemaVersionBuilder,
|
|
20
19
|
} from './model'
|
|
21
20
|
import { UuidProvider } from './utils'
|
|
22
21
|
import {
|
|
@@ -31,12 +30,14 @@ import {
|
|
|
31
30
|
} from './resolvers'
|
|
32
31
|
import { EventOldValuesResolver } from './resolvers/types'
|
|
33
32
|
import { DatabaseMetadataResolver } from '@contember/database'
|
|
33
|
+
import { SchemaProvider } from './model'
|
|
34
|
+
import { SchemaQueryResolver } from './resolvers/query/SchemaQueryResolver'
|
|
34
35
|
|
|
35
36
|
export interface SystemContainer {
|
|
36
37
|
systemResolversFactory: ResolverFactory
|
|
37
38
|
authorizator: Authorizator
|
|
38
39
|
resolverContextFactory: SystemResolverContextFactory
|
|
39
|
-
|
|
40
|
+
schemaProvider: SchemaProvider
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
type Args = {
|
|
@@ -58,7 +59,7 @@ export class SystemContainerFactory {
|
|
|
58
59
|
'systemResolversFactory',
|
|
59
60
|
'authorizator',
|
|
60
61
|
'resolverContextFactory',
|
|
61
|
-
'
|
|
62
|
+
'schemaProvider',
|
|
62
63
|
)
|
|
63
64
|
}
|
|
64
65
|
public createBuilder({ identityFetcher }: Args) {
|
|
@@ -73,26 +74,24 @@ export class SystemContainerFactory {
|
|
|
73
74
|
new SchemaMigrator(modificationHandlerFactory))
|
|
74
75
|
.addService('executedMigrationsResolver', ({}) =>
|
|
75
76
|
new ExecutedMigrationsResolver())
|
|
76
|
-
.addService('
|
|
77
|
-
new
|
|
77
|
+
.addService('schemaProvider', ({ executedMigrationsResolver, schemaMigrator }) =>
|
|
78
|
+
new SchemaProvider(executedMigrationsResolver, schemaMigrator))
|
|
78
79
|
.addService('accessEvaluator', ({}) =>
|
|
79
80
|
new AccessEvaluator.PermissionEvaluator(new PermissionsFactory().create()))
|
|
80
81
|
.addService('authorizator', ({ accessEvaluator }): Authorizator =>
|
|
81
82
|
new Authorizator.Default(accessEvaluator))
|
|
82
|
-
.addService('schemaDiffer', ({ schemaMigrator }) =>
|
|
83
|
-
new SchemaDiffer(schemaMigrator))
|
|
84
83
|
.addService('migrationDescriber', ({ modificationHandlerFactory }) =>
|
|
85
84
|
new MigrationDescriber(modificationHandlerFactory))
|
|
86
85
|
.addService('databaseMetadataResolver', () =>
|
|
87
86
|
new DatabaseMetadataResolver())
|
|
88
87
|
.addService('migrationsDatabaseMetadataResolverStoreFactory', ({ databaseMetadataResolver }) =>
|
|
89
88
|
new MigrationsDatabaseMetadataResolverStoreFactory(databaseMetadataResolver))
|
|
90
|
-
.addService('projectMigrator', ({ migrationDescriber,
|
|
91
|
-
new ProjectMigrator(migrationDescriber,
|
|
89
|
+
.addService('projectMigrator', ({ migrationDescriber, schemaProvider, executedMigrationsResolver, migrationsDatabaseMetadataResolverStoreFactory }) =>
|
|
90
|
+
new ProjectMigrator(migrationDescriber, schemaProvider, executedMigrationsResolver, migrationsDatabaseMetadataResolverStoreFactory, this.contentQueryExecutor))
|
|
92
91
|
.addService('projectTruncateExecutor', () =>
|
|
93
92
|
new ProjectTruncateExecutor())
|
|
94
|
-
.addService('migrationAlterer', () =>
|
|
95
|
-
new MigrationAlterer())
|
|
93
|
+
.addService('migrationAlterer', ({ schemaProvider }) =>
|
|
94
|
+
new MigrationAlterer(schemaProvider))
|
|
96
95
|
.addService('eventResponseBuilder', ({ identityFetcher }) =>
|
|
97
96
|
new EventResponseBuilder(identityFetcher))
|
|
98
97
|
.addService('stagesQueryResolver', () =>
|
|
@@ -109,8 +108,10 @@ export class SystemContainerFactory {
|
|
|
109
108
|
new EventsQueryResolver(eventResponseBuilder))
|
|
110
109
|
.addService('eventOldValuesResolver', () =>
|
|
111
110
|
new EventOldValuesResolver())
|
|
112
|
-
.addService('
|
|
113
|
-
new
|
|
111
|
+
.addService('schemaQueryResolver', () =>
|
|
112
|
+
new SchemaQueryResolver())
|
|
113
|
+
.addService('systemResolversFactory', ({ stagesQueryResolver, executedMigrationsQueryResolver, migrateMutationResolver, truncateMutationResolver, migrationAlterMutationResolver, eventsQueryResolver, eventOldValuesResolver, schemaQueryResolver }) =>
|
|
114
|
+
new ResolverFactory(stagesQueryResolver, executedMigrationsQueryResolver, migrateMutationResolver, truncateMutationResolver, migrationAlterMutationResolver, eventsQueryResolver, eventOldValuesResolver, schemaQueryResolver))
|
|
114
115
|
.addService('resolverContextFactory', ({ authorizator }) =>
|
|
115
116
|
new SystemResolverContextFactory(authorizator))
|
|
116
117
|
}
|
package/src/bin/runMigrations.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SystemMigrationsRunner } from '../migrations'
|
|
2
|
-
import { DatabaseContextFactory, emptyVersionedSchema,
|
|
3
|
-
import {
|
|
2
|
+
import { DatabaseContextFactory, emptyVersionedSchema, SchemaProvider } from '../model'
|
|
3
|
+
import { DatabaseMetadataResolver, emptyDatabaseMetadata } from '@contember/database'
|
|
4
4
|
import { createLogger, PrettyPrintLoggerHandler } from '@contember/logger'
|
|
5
5
|
|
|
6
6
|
|
|
@@ -20,8 +20,8 @@ import { createLogger, PrettyPrintLoggerHandler } from '@contember/logger'
|
|
|
20
20
|
}),
|
|
21
21
|
{ db: dbConfig, slug: 'test', stages: [], systemSchema: 'system' },
|
|
22
22
|
{
|
|
23
|
-
|
|
24
|
-
} as unknown as
|
|
23
|
+
buildSchemaFromMigrations: () => Promise.resolve(emptyVersionedSchema),
|
|
24
|
+
} as unknown as SchemaProvider,
|
|
25
25
|
{},
|
|
26
26
|
{
|
|
27
27
|
resolveMetadata: () => Promise.resolve(emptyDatabaseMetadata),
|
package/src/index.ts
CHANGED
|
@@ -16,12 +16,13 @@ export {
|
|
|
16
16
|
LatestTransactionIdByStageQuery,
|
|
17
17
|
ProjectInitializer,
|
|
18
18
|
ProjectMigrator,
|
|
19
|
-
SchemaVersionBuilder,
|
|
20
19
|
type Stage,
|
|
21
20
|
StageBySlugQuery,
|
|
22
21
|
StageCreator,
|
|
23
22
|
StagesQuery,
|
|
24
|
-
|
|
23
|
+
SchemaProvider,
|
|
24
|
+
type SchemaMeta,
|
|
25
|
+
type SchemaWithMeta,
|
|
25
26
|
} from './model'
|
|
26
27
|
export * from './SystemContainer'
|
|
27
28
|
export * from './resolvers'
|
|
@@ -58,7 +58,7 @@ const migrateEvents = (builder: MigrationBuilder, tableName: string, primaryKeys
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export default async function (builder: MigrationBuilder, args: MigrationArgs<SystemMigrationArgs>) {
|
|
61
|
-
const schema = await args.schemaResolver(args.connection)
|
|
61
|
+
const schema = (await args.schemaResolver(args.connection)).schema
|
|
62
62
|
const tablesToMigrate = getJunctionTables(schema.model)
|
|
63
63
|
const schemas = args.project.stages.map(it => `stage_${it.slug}`)
|
|
64
64
|
for (const table of tablesToMigrate) {
|
|
@@ -16,7 +16,7 @@ const createEventStatementTrigger = (builder: MigrationBuilder, tableName: Name)
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export default async function (builder: MigrationBuilder, args: MigrationArgs<SystemMigrationArgs>) {
|
|
19
|
-
const schema = await args.schemaResolver(args.connection)
|
|
19
|
+
const schema = (await args.schemaResolver(args.connection)).schema
|
|
20
20
|
const junctionTables = getJunctionTables(schema.model)
|
|
21
21
|
const schemas = args.project.stages.map(it => `stage_${it.slug}`)
|
|
22
22
|
builder.sql(`CREATE OR REPLACE FUNCTION "trigger_event"() RETURNS TRIGGER AS $$
|
|
@@ -18,7 +18,7 @@ const createTrxEvent = (builder: MigrationBuilder, tableName: Name) => {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export default async function (builder: MigrationBuilder, args: MigrationArgs<SystemMigrationArgs>) {
|
|
21
|
-
const schema = await args.schemaResolver(args.connection)
|
|
21
|
+
const schema = (await args.schemaResolver(args.connection)).schema
|
|
22
22
|
const junctionTables = getJunctionTables(schema.model)
|
|
23
23
|
const schemas = args.project.stages.map(it => `stage_${it.slug}`)
|
|
24
24
|
builder.sql(`LOCK TABLE event`)
|
|
@@ -21,7 +21,7 @@ const recreateTrigger = (builder: MigrationBuilder, tableName: Name) => {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export default async function (builder: MigrationBuilder, args: MigrationArgs<SystemMigrationArgs>) {
|
|
24
|
-
const schema = await args.schemaResolver(args.connection)
|
|
24
|
+
const schema = (await args.schemaResolver(args.connection)).schema
|
|
25
25
|
const junctionTables = getJunctionTables(schema.model)
|
|
26
26
|
const schemas = args.project.stages.map(it => `stage_${it.slug}`)
|
|
27
27
|
|
|
@@ -5,7 +5,7 @@ import { acceptFieldVisitor } from '@contember/schema-utils'
|
|
|
5
5
|
import { Model } from '@contember/schema'
|
|
6
6
|
|
|
7
7
|
export default async function (builder: MigrationBuilder, args: MigrationArgs<SystemMigrationArgs>) {
|
|
8
|
-
const schema = await args.schemaResolver(args.connection)
|
|
8
|
+
const schema = (await args.schemaResolver(args.connection)).schema
|
|
9
9
|
const stages = (await args.connection.query<{schema: string}>('SELECT schema FROM stage')).rows
|
|
10
10
|
const metadataByStage: Record<string, DatabaseMetadata> = {}
|
|
11
11
|
|
|
@@ -5,7 +5,7 @@ import { acceptFieldVisitor } from '@contember/schema-utils'
|
|
|
5
5
|
import { Model } from '@contember/schema'
|
|
6
6
|
|
|
7
7
|
export default async function (builder: MigrationBuilder, args: MigrationArgs<SystemMigrationArgs>) {
|
|
8
|
-
const schema = await args.schemaResolver(args.connection)
|
|
8
|
+
const schema = (await args.schemaResolver(args.connection)).schema
|
|
9
9
|
const stages = (await args.connection.query<{schema: string}>('SELECT schema FROM stage')).rows
|
|
10
10
|
const metadataByStage: Record<string, DatabaseMetadata> = {}
|
|
11
11
|
|
|
@@ -4,7 +4,7 @@ import { SystemMigrationArgs } from './types'
|
|
|
4
4
|
import { getUniqueConstraintColumns } from '@contember/schema-migrations'
|
|
5
5
|
|
|
6
6
|
export default async function (builder: MigrationBuilder, args: MigrationArgs<SystemMigrationArgs>) {
|
|
7
|
-
const schema = await args.schemaResolver(args.connection)
|
|
7
|
+
const schema = (await args.schemaResolver(args.connection)).schema
|
|
8
8
|
const stages = (await args.connection.query<{schema: string}>('SELECT schema FROM stage')).rows
|
|
9
9
|
const metadataByStage: Record<string, DatabaseMetadata> = {}
|
|
10
10
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MigrationBuilder } from '@contember/database-migrations'
|
|
2
|
+
|
|
3
|
+
// deliberately using "JSON" instead of "JSONB" to preserve the order of keys
|
|
4
|
+
|
|
5
|
+
const sql = `
|
|
6
|
+
CREATE TYPE SCHEMA_SINGLE AS ENUM ('single');
|
|
7
|
+
CREATE TABLE "schema"
|
|
8
|
+
(
|
|
9
|
+
id SCHEMA_SINGLE NOT NULL PRIMARY KEY DEFAULT 'single',
|
|
10
|
+
schema JSON NOT NULL,
|
|
11
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
12
|
+
checksum CHAR(32) NOT NULL,
|
|
13
|
+
version VARCHAR(20) NOT NULL,
|
|
14
|
+
migration_id INT NOT NULL REFERENCES schema_migration(id) DEFERRABLE INITIALLY DEFERRED
|
|
15
|
+
);
|
|
16
|
+
`
|
|
17
|
+
|
|
18
|
+
export default async function (builder: MigrationBuilder) {
|
|
19
|
+
builder.sql(sql)
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { escapeValue, MigrationArgs, MigrationBuilder } from '@contember/database-migrations'
|
|
2
|
+
import { SystemMigrationArgs } from './types'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export default async function (builder: MigrationBuilder, args: MigrationArgs<SystemMigrationArgs>) {
|
|
6
|
+
const schema = await args.schemaResolver(args.connection)
|
|
7
|
+
if (!schema.meta.id) {
|
|
8
|
+
return
|
|
9
|
+
}
|
|
10
|
+
builder.sql(`INSERT INTO schema(schema, checksum, version, migration_id)
|
|
11
|
+
VALUES(${escapeValue(JSON.stringify(schema.schema))}, ${escapeValue(schema.meta.checksum)}, ${escapeValue(schema.meta.version)}, ${schema.meta.id})`)
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MigrationBuilder } from '@contember/database-migrations'
|
|
2
|
+
|
|
3
|
+
const sql = `
|
|
4
|
+
CREATE INDEX IF NOT EXISTS system_event_data_row_id_0 ON event_data USING btree ((row_ids -> 0));
|
|
5
|
+
CREATE INDEX IF NOT EXISTS system_event_data_row_id_1 ON event_data USING btree ((row_ids -> 1));
|
|
6
|
+
DROP INDEX IF EXISTS system_event_row_id;
|
|
7
|
+
`
|
|
8
|
+
|
|
9
|
+
export default async function (builder: MigrationBuilder) {
|
|
10
|
+
builder.sql(sql)
|
|
11
|
+
}
|
package/src/migrations/runner.ts
CHANGED
|
@@ -26,10 +26,13 @@ import _20230911174000fixondelete from './2023-09-11-174000-fix-on-delete'
|
|
|
26
26
|
import _20231019173000fixunique from './2023-10-19-173000-fix-unique'
|
|
27
27
|
import _20231024140000schemanullablechecksum from './2023-10-24-140000-schema-nullable-checksum'
|
|
28
28
|
import _20240628150000migrationsdropsequence from './2024-06-28-150000-migrations-drop-sequence'
|
|
29
|
+
import _20240628153000schema from './2024-06-28-153000-schema'
|
|
30
|
+
import _20240628153001schemainit from './2024-06-28-153001-schema-init'
|
|
31
|
+
import _20240729150000eventdataindex from './2024-07-29-150000-event-data-index'
|
|
29
32
|
import snapshot from './snapshot'
|
|
30
33
|
|
|
31
34
|
import { Connection, createDatabaseIfNotExists, DatabaseConfig, DatabaseMetadataResolver } from '@contember/database'
|
|
32
|
-
import { DatabaseContextFactory,
|
|
35
|
+
import { DatabaseContextFactory, SchemaProvider } from '../model'
|
|
33
36
|
import { ProjectConfig } from '../types'
|
|
34
37
|
import { Logger } from '@contember/logger'
|
|
35
38
|
|
|
@@ -56,6 +59,9 @@ const migrations = {
|
|
|
56
59
|
'2023-10-19-173000-fix-unique': _20231019173000fixunique,
|
|
57
60
|
'2023-10-24-140000-schema-nullable-checksum': _20231024140000schemanullablechecksum,
|
|
58
61
|
'2024-06-28-150000-migrations-drop-sequence': _20240628150000migrationsdropsequence,
|
|
62
|
+
'2024-06-28-153000-schema': _20240628153000schema,
|
|
63
|
+
'2024-06-28-153001-schema-init': _20240628153001schemainit,
|
|
64
|
+
'2024-07-29-150000-event-data-index': _20240729150000eventdataindex,
|
|
59
65
|
}
|
|
60
66
|
|
|
61
67
|
|
|
@@ -63,7 +69,7 @@ export class SystemMigrationsRunner {
|
|
|
63
69
|
constructor(
|
|
64
70
|
private readonly databaseContextFactory: DatabaseContextFactory,
|
|
65
71
|
private readonly project: ProjectConfig & { db: DatabaseConfig },
|
|
66
|
-
private readonly
|
|
72
|
+
private readonly schemaProvider: SchemaProvider,
|
|
67
73
|
private readonly migrationGroups: Record<string, MigrationGroup<unknown>>,
|
|
68
74
|
private readonly databaseMetadataResolver: DatabaseMetadataResolver,
|
|
69
75
|
) {
|
|
@@ -72,9 +78,9 @@ export class SystemMigrationsRunner {
|
|
|
72
78
|
await createDatabaseIfNotExists(this.project.db, message => typeof message === 'string' ? logger.warn(message) : logger.error(message))
|
|
73
79
|
const singleConnection = Connection.createSingle(this.project.db, err => logger.error(err))
|
|
74
80
|
await singleConnection.scope(async connection => {
|
|
75
|
-
const schemaResolver = (connection: Connection.ConnectionLike) => {
|
|
81
|
+
const schemaResolver = async (connection: Connection.ConnectionLike) => {
|
|
76
82
|
const dbContextMigrations = this.databaseContextFactory.create(connection)
|
|
77
|
-
return this.
|
|
83
|
+
return await this.schemaProvider.buildSchemaFromMigrations(dbContextMigrations)
|
|
78
84
|
}
|
|
79
85
|
const migrationResolver = new GroupMigrationsResolver(
|
|
80
86
|
new SnapshotMigrationResolver(snapshot, migrations),
|
|
@@ -10,7 +10,7 @@ export const snapshotMigration = (sqlFactory: (args: { randomUuidFn: string }) =
|
|
|
10
10
|
WHERE pg_namespace.nspname = 'pg_catalog' AND pg_proc.proname = 'gen_random_uuid'
|
|
11
11
|
`)
|
|
12
12
|
let randomUuidFn: string = 'uuid_generate_v4'
|
|
13
|
-
if (hasGenRandomUuid.rowCount > 0) {
|
|
13
|
+
if ((hasGenRandomUuid.rowCount ?? 0) > 0) {
|
|
14
14
|
randomUuidFn = 'gen_random_uuid'
|
|
15
15
|
} else {
|
|
16
16
|
const hasUuidGenV4 = await args.connection.query(`
|
|
@@ -8,6 +8,9 @@ CREATE TYPE "schema_migration_type" AS ENUM (
|
|
|
8
8
|
'schema',
|
|
9
9
|
'content'
|
|
10
10
|
);
|
|
11
|
+
CREATE TYPE "schema_single" AS ENUM (
|
|
12
|
+
'single'
|
|
13
|
+
);
|
|
11
14
|
CREATE FUNCTION "trigger_event"() RETURNS "trigger"
|
|
12
15
|
LANGUAGE "plpgsql"
|
|
13
16
|
AS $$
|
|
@@ -115,6 +118,14 @@ CREATE TABLE "event_data" (
|
|
|
115
118
|
"identity_id" "uuid" NOT NULL,
|
|
116
119
|
"transaction_id" "uuid" DEFAULT COALESCE((NULLIF("current_setting"('system.transaction_id'::"text", true), ''::"text"))::"uuid", ("set_config"('system.transaction_id'::"text", ("${randomUuidFn}"())::"text", true))::"uuid") NOT NULL
|
|
117
120
|
);
|
|
121
|
+
CREATE TABLE "schema" (
|
|
122
|
+
"id" "schema_single" DEFAULT 'single'::"schema_single" NOT NULL,
|
|
123
|
+
"schema" "json" NOT NULL,
|
|
124
|
+
"updated_at" timestamp with time zone DEFAULT "now"() NOT NULL,
|
|
125
|
+
"checksum" character(32) NOT NULL,
|
|
126
|
+
"version" character varying(20) NOT NULL,
|
|
127
|
+
"migration_id" integer NOT NULL
|
|
128
|
+
);
|
|
118
129
|
CREATE TABLE "schema_migration" (
|
|
119
130
|
"id" integer NOT NULL,
|
|
120
131
|
"version" character varying(20) NOT NULL,
|
|
@@ -143,6 +154,8 @@ ALTER TABLE ONLY "schema_migration"
|
|
|
143
154
|
ADD CONSTRAINT "schema_migration_pkey" PRIMARY KEY ("id");
|
|
144
155
|
ALTER TABLE ONLY "schema_migration"
|
|
145
156
|
ADD CONSTRAINT "schema_migration_version_key" UNIQUE ("version");
|
|
157
|
+
ALTER TABLE ONLY "schema"
|
|
158
|
+
ADD CONSTRAINT "schema_pkey" PRIMARY KEY ("id");
|
|
146
159
|
ALTER TABLE ONLY "stage"
|
|
147
160
|
ADD CONSTRAINT "stage_pkey" PRIMARY KEY ("id");
|
|
148
161
|
ALTER TABLE ONLY "stage"
|
|
@@ -155,11 +168,14 @@ CREATE INDEX "event_data_created" ON "event_data" USING "btree" ("created_at");
|
|
|
155
168
|
CREATE INDEX "system_event2_table_name" ON "event_data" USING "btree" ("table_name");
|
|
156
169
|
CREATE INDEX "system_event2_transaction" ON "event_data" USING "btree" ("transaction_id");
|
|
157
170
|
CREATE INDEX "system_event2_type" ON "event_data" USING "btree" ("type");
|
|
158
|
-
CREATE INDEX "
|
|
171
|
+
CREATE INDEX "system_event_data_row_id_0" ON "event_data" USING "btree" ((("row_ids" -> 0)));
|
|
172
|
+
CREATE INDEX "system_event_data_row_id_1" ON "event_data" USING "btree" ((("row_ids" -> 1)));
|
|
159
173
|
CREATE INDEX "system_schema_migration_version" ON "schema_migration" USING "btree" ("version");
|
|
160
174
|
CREATE INDEX "transaction_applied" ON "stage_transaction" USING "btree" ("applied_at");
|
|
161
175
|
ALTER TABLE ONLY "event_data"
|
|
162
176
|
ADD CONSTRAINT "event_data_schema_id_fkey" FOREIGN KEY ("schema_id") REFERENCES "schema_migration"("id");
|
|
177
|
+
ALTER TABLE ONLY "schema"
|
|
178
|
+
ADD CONSTRAINT "schema_migration_id_fkey" FOREIGN KEY ("migration_id") REFERENCES "schema_migration"("id") DEFERRABLE INITIALLY DEFERRED;
|
|
163
179
|
ALTER TABLE ONLY "stage_transaction"
|
|
164
180
|
ADD CONSTRAINT "stage_transaction_stage_id_fkey" FOREIGN KEY ("stage_id") REFERENCES "stage"("id") ON DELETE CASCADE;
|
|
165
181
|
`)
|
package/src/migrations/types.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Schema } from '@contember/schema'
|
|
2
1
|
import { ProjectConfig } from '../types'
|
|
3
2
|
import { Connection, DatabaseMetadata } from '@contember/database'
|
|
3
|
+
import { SchemaWithMeta } from '../model'
|
|
4
4
|
|
|
5
5
|
export interface SystemMigrationArgs {
|
|
6
|
-
schemaResolver: (connection: Connection.ConnectionLike) => Promise<
|
|
6
|
+
schemaResolver: (connection: Connection.ConnectionLike) => Promise<SchemaWithMeta>
|
|
7
7
|
databaseMetadataResolver: (connection: Connection.ConnectionLike, schema: string) => Promise<DatabaseMetadata>
|
|
8
8
|
project: ProjectConfig
|
|
9
9
|
}
|
|
@@ -9,4 +9,5 @@ export namespace AuthorizationActions {
|
|
|
9
9
|
|
|
10
10
|
export const PROJECT_MIGRATE = Authorizator.createAction(Resources.project, 'migrate')
|
|
11
11
|
export const PROJECT_LIST_MIGRATIONS = Authorizator.createAction(Resources.project, 'listMigrations')
|
|
12
|
+
export const PROJECT_SHOW_SCHEMA = Authorizator.createAction(Resources.project, 'showSchema')
|
|
12
13
|
}
|
|
@@ -8,6 +8,7 @@ export class PermissionsFactory {
|
|
|
8
8
|
permissions.allow(ProjectRole.ADMIN, { resource: Permissions.ALL, privilege: Permissions.ALL })
|
|
9
9
|
permissions.allow(ProjectRole.DEPLOYER, AuthorizationActions.PROJECT_MIGRATE)
|
|
10
10
|
permissions.allow(ProjectRole.DEPLOYER, AuthorizationActions.PROJECT_LIST_MIGRATIONS)
|
|
11
|
+
permissions.allow(ProjectRole.DEPLOYER, AuthorizationActions.PROJECT_SHOW_SCHEMA)
|
|
11
12
|
|
|
12
13
|
return permissions
|
|
13
14
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Acl
|
|
1
|
+
import { Acl } from '@contember/schema'
|
|
2
2
|
import { Permissions } from '@contember/authorization'
|
|
3
|
-
import { filterSchemaByStage } from '@contember/schema-utils'
|
|
4
3
|
import { AuthorizationActions } from './AuthorizationActions'
|
|
4
|
+
import { SchemaGetter } from '../SchemaGetter'
|
|
5
5
|
|
|
6
6
|
export class StagePermissionsFactory {
|
|
7
|
-
constructor(private readonly
|
|
7
|
+
constructor(private readonly getSchema: SchemaGetter) {}
|
|
8
8
|
|
|
9
|
-
public create(stage: string): Permissions {
|
|
9
|
+
public async create(stage: string): Promise<Permissions> {
|
|
10
10
|
const permissions = new Permissions()
|
|
11
11
|
|
|
12
|
-
const filteredSchema =
|
|
12
|
+
const filteredSchema = await this.getSchema({ stage })
|
|
13
13
|
|
|
14
14
|
const rolePermissions = this.createRolePermissions(filteredSchema.acl)
|
|
15
15
|
Object.entries(rolePermissions).forEach(([role, value]) => {
|
|
@@ -6,8 +6,8 @@ import { StagePermissionsFactory } from './StagePermissionsFactory'
|
|
|
6
6
|
export class StageScope implements AuthorizationScope<Identity> {
|
|
7
7
|
constructor(private readonly stage: string, private readonly stagePermissionsFactory: StagePermissionsFactory) {}
|
|
8
8
|
|
|
9
|
-
getIdentityAccess(identity: Identity): Promise<AccessNode> {
|
|
10
|
-
const permissions = this.stagePermissionsFactory.create(this.stage)
|
|
9
|
+
async getIdentityAccess(identity: Identity): Promise<AccessNode> {
|
|
10
|
+
const permissions = await this.stagePermissionsFactory.create(this.stage)
|
|
11
11
|
const roles = new AccessNode.Roles(identity.roles)
|
|
12
12
|
const permissionEvaluator = new AccessEvaluator.PermissionEvaluator(permissions)
|
|
13
13
|
const node = new SwitchEvaluatorNode(roles, permissionEvaluator)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ConflictActionType, InsertBuilder } from '@contember/database'
|
|
2
|
+
import { Command } from '../Command'
|
|
3
|
+
import { SchemaWithMeta } from '../../migrations'
|
|
4
|
+
|
|
5
|
+
export class SaveSchemaCommand implements Command<void> {
|
|
6
|
+
constructor(private readonly input: SchemaWithMeta) {}
|
|
7
|
+
|
|
8
|
+
public async execute({ db }: Command.Args): Promise<void> {
|
|
9
|
+
if (!this.input.meta.updatedAt) {
|
|
10
|
+
throw new Error('Cannot persist empty schema')
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
await InsertBuilder.create()
|
|
14
|
+
.into('schema')
|
|
15
|
+
.values({
|
|
16
|
+
schema: this.input.schema,
|
|
17
|
+
updated_at: this.input.meta.updatedAt.toISOString(),
|
|
18
|
+
checksum: this.input.meta.checksum,
|
|
19
|
+
version: this.input.meta.version,
|
|
20
|
+
migration_id: this.input.meta.id,
|
|
21
|
+
})
|
|
22
|
+
.onConflict(ConflictActionType.update, ['id'], {
|
|
23
|
+
schema: expr => expr.select(['excluded', 'schema']),
|
|
24
|
+
updated_at: expr => expr.select(['excluded', 'updated_at']),
|
|
25
|
+
checksum: expr => expr.select(['excluded', 'checksum']),
|
|
26
|
+
version: expr => expr.select(['excluded', 'version']),
|
|
27
|
+
migration_id: expr => expr.select(['excluded', 'migration_id']),
|
|
28
|
+
})
|
|
29
|
+
.execute(db)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Stage } from '../../dtos'
|
|
2
2
|
import { DatabaseContext } from '../../database'
|
|
3
|
-
import { Schema } from '@contember/schema'
|
|
4
3
|
import { ExecutionResult } from 'graphql'
|
|
5
4
|
import { DatabaseMetadata } from '@contember/database'
|
|
5
|
+
import { Schema } from '@contember/schema'
|
|
6
6
|
|
|
7
7
|
export interface ContentQueryExecutorContext {
|
|
8
|
-
schema: Schema
|
|
8
|
+
schema: Schema
|
|
9
|
+
schemaMeta: { id: number }
|
|
9
10
|
identity: { id: string }
|
|
10
11
|
db: DatabaseContext
|
|
11
12
|
stage: Stage
|
|
@@ -3,8 +3,15 @@ import { DeleteMigrationCommand } from '../commands'
|
|
|
3
3
|
import { Response, ResponseError, ResponseOk } from '../../utils'
|
|
4
4
|
import { Migration } from '@contember/schema-migrations'
|
|
5
5
|
import { ModifyMigrationCommand } from '../commands/migrations/ModifyMigrationCommand'
|
|
6
|
+
import { SchemaProvider } from './SchemaProvider'
|
|
7
|
+
import { SaveSchemaCommand } from '../commands/schema/SaveSchemaCommand'
|
|
6
8
|
|
|
7
9
|
export class MigrationAlterer {
|
|
10
|
+
constructor(
|
|
11
|
+
private readonly schemaProvider: SchemaProvider,
|
|
12
|
+
) {
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
public async deleteMigration(
|
|
9
16
|
db: DatabaseContext,
|
|
10
17
|
version: string,
|
|
@@ -15,6 +22,7 @@ export class MigrationAlterer {
|
|
|
15
22
|
await db.client.connection.rollback()
|
|
16
23
|
return new ResponseError(DeleteMigrationErrorCode.notFound, `Migration ${version} was not found`)
|
|
17
24
|
}
|
|
25
|
+
await this.refreshSchema(db)
|
|
18
26
|
return new ResponseOk(undefined)
|
|
19
27
|
})
|
|
20
28
|
}
|
|
@@ -30,9 +38,15 @@ export class MigrationAlterer {
|
|
|
30
38
|
await db.client.connection.rollback()
|
|
31
39
|
return new ResponseError(UpdateMigrationErrorCode.notFound, `Migration ${version} was not found`)
|
|
32
40
|
}
|
|
41
|
+
await this.refreshSchema(db)
|
|
33
42
|
return new ResponseOk(undefined)
|
|
34
43
|
})
|
|
35
44
|
}
|
|
45
|
+
|
|
46
|
+
private async refreshSchema(db: DatabaseContext): Promise<void> {
|
|
47
|
+
const schemaWithMeta = await this.schemaProvider.buildSchemaFromMigrations(db)
|
|
48
|
+
await db.commandBus.execute(new SaveSchemaCommand(schemaWithMeta))
|
|
49
|
+
}
|
|
36
50
|
}
|
|
37
51
|
|
|
38
52
|
export enum DeleteMigrationErrorCode {
|