@contember/engine-system-api 2.0.0-alpha.12 → 2.0.0-alpha.13
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 +4 -3
- package/dist/development/src/SystemContainer.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.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/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/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/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/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/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/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/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/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/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/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 +4 -3
- package/dist/production/src/SystemContainer.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.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/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/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/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/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/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/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/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/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/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/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 +7 -3
- 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 +15 -3
- package/dist/types/schema/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/graphql.codegen.yml +2 -0
- package/package.json +12 -12
- package/src/SystemContainer.ts +14 -11
- 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.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 +12 -2
- package/tests/cases/migrations/2020-05-06-150000-composed-primary.test.ts +9 -1
- package/tests/cases/migrations/2020-06-01-103000-event-trigger-perf.test.ts +9 -1
- package/tests/cases/migrations/2022-10-03-110000-table-on-delete.test.ts +17 -6
- package/tests/cases/migrations/2023-09-11-174000-fix-on-delete.test.ts +32 -12
- package/tests/cases/migrations/2023-10-19-173000-fix-unique.test.ts +9 -1
- 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
|
@@ -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
|
@@ -14,9 +14,10 @@ export type Scalars = {
|
|
|
14
14
|
Boolean: { input: boolean; output: boolean }
|
|
15
15
|
Int: { input: number; output: number }
|
|
16
16
|
Float: { input: number; output: number }
|
|
17
|
+
Schema: { input: any; output: any }
|
|
17
18
|
DateTime: { input: Date; output: Date }
|
|
18
19
|
Json: { input: unknown; output: unknown }
|
|
19
|
-
PrimaryKey: { input:
|
|
20
|
+
PrimaryKey: { input: string | number; output: string | number }
|
|
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
|
|
|
@@ -374,6 +376,7 @@ export type ResolversInterfaceTypes<RefType extends Record<string, unknown>> = {
|
|
|
374
376
|
export type ResolversTypes = {
|
|
375
377
|
Boolean: ResolverTypeWrapper<Scalars['Boolean']['output']>
|
|
376
378
|
ContentMigration: ContentMigration
|
|
379
|
+
Schema: ResolverTypeWrapper<Scalars['Schema']['output']>
|
|
377
380
|
CreateEvent: ResolverTypeWrapper<CreateEvent>
|
|
378
381
|
DateTime: ResolverTypeWrapper<Scalars['DateTime']['output']>
|
|
379
382
|
DeleteEvent: ResolverTypeWrapper<DeleteEvent>
|
|
@@ -415,6 +418,7 @@ export type ResolversTypes = {
|
|
|
415
418
|
export type ResolversParentTypes = {
|
|
416
419
|
Boolean: Scalars['Boolean']['output']
|
|
417
420
|
ContentMigration: ContentMigration
|
|
421
|
+
Schema: Scalars['Schema']['output']
|
|
418
422
|
CreateEvent: CreateEvent
|
|
419
423
|
DateTime: Scalars['DateTime']['output']
|
|
420
424
|
DeleteEvent: DeleteEvent
|
|
@@ -446,6 +450,10 @@ export type ResolversParentTypes = {
|
|
|
446
450
|
UpdateEvent: UpdateEvent
|
|
447
451
|
}
|
|
448
452
|
|
|
453
|
+
export interface SchemaScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['Schema'], any> {
|
|
454
|
+
name: 'Schema'
|
|
455
|
+
}
|
|
456
|
+
|
|
449
457
|
export type CreateEventResolvers<ContextType = any, ParentType extends ResolversParentTypes['CreateEvent'] = ResolversParentTypes['CreateEvent']> = {
|
|
450
458
|
appliedAt?: Resolver<ResolversTypes['DateTime'], ParentType, ContextType>
|
|
451
459
|
createdAt?: Resolver<ResolversTypes['DateTime'], ParentType, ContextType>
|
|
@@ -567,6 +575,7 @@ export interface PrimaryKeyScalarConfig extends GraphQLScalarTypeConfig<Resolver
|
|
|
567
575
|
export type QueryResolvers<ContextType = any, ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query']> = {
|
|
568
576
|
events?: Resolver<ReadonlyArray<ResolversTypes['Event']>, ParentType, ContextType, Partial<QueryEventsArgs>>
|
|
569
577
|
executedMigrations?: Resolver<ReadonlyArray<ResolversTypes['ExecutedMigration']>, ParentType, ContextType, Partial<QueryExecutedMigrationsArgs>>
|
|
578
|
+
schema?: Resolver<ResolversTypes['Schema'], ParentType, ContextType>
|
|
570
579
|
stages?: Resolver<ReadonlyArray<ResolversTypes['Stage']>, ParentType, ContextType>
|
|
571
580
|
}
|
|
572
581
|
|
|
@@ -599,6 +608,7 @@ export type UpdateEventResolvers<ContextType = any, ParentType extends Resolvers
|
|
|
599
608
|
}
|
|
600
609
|
|
|
601
610
|
export type Resolvers<ContextType = any> = {
|
|
611
|
+
Schema?: GraphQLScalarType
|
|
602
612
|
CreateEvent?: CreateEventResolvers<ContextType>
|
|
603
613
|
DateTime?: GraphQLScalarType
|
|
604
614
|
DeleteEvent?: DeleteEventResolvers<ContextType>
|
|
@@ -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',
|
|
@@ -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',
|
|
@@ -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',
|
|
@@ -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',
|
|
@@ -82,12 +93,21 @@ test('table-on-delete test valid', async () => {
|
|
|
82
93
|
}],
|
|
83
94
|
})),
|
|
84
95
|
schemaResolver: () => Promise.resolve(({
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
96
|
+
schema: {
|
|
97
|
+
...emptySchema,
|
|
98
|
+
model: new SchemaBuilder()
|
|
99
|
+
.entity('Post', entity =>
|
|
100
|
+
entity.manyHasOne('author', relation => relation.target('Author').onDelete(Model.OnDelete.setNull)),
|
|
101
|
+
)
|
|
102
|
+
.entity('Author', entity => entity)
|
|
103
|
+
.buildSchema(),
|
|
104
|
+
},
|
|
105
|
+
meta: {
|
|
106
|
+
id: 1,
|
|
107
|
+
version: '2024-06-28-153001',
|
|
108
|
+
checksum: '_checksum_',
|
|
109
|
+
updatedAt: new Date(),
|
|
110
|
+
},
|
|
91
111
|
})),
|
|
92
112
|
project: {
|
|
93
113
|
slug: 'test',
|
|
@@ -45,7 +45,15 @@ test('unique fix test', async () => {
|
|
|
45
45
|
|
|
46
46
|
],
|
|
47
47
|
})),
|
|
48
|
-
schemaResolver: () => Promise.resolve(
|
|
48
|
+
schemaResolver: () => Promise.resolve({
|
|
49
|
+
schema: createSchema(UniqueModel),
|
|
50
|
+
meta: {
|
|
51
|
+
id: 1,
|
|
52
|
+
version: '2024-06-28-153001',
|
|
53
|
+
checksum: '_checksum_',
|
|
54
|
+
updatedAt: new Date(),
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
49
57
|
project: {
|
|
50
58
|
slug: 'test',
|
|
51
59
|
stages: [
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { expect, test } from 'vitest'
|
|
2
|
+
import { EventsQuery } from '../../../src/model'
|
|
3
|
+
import { testUuid } from '../../src/uuid'
|
|
4
|
+
import { EventsOrder } from '../../../src/schema'
|
|
5
|
+
|
|
6
|
+
test('events query', async () => {
|
|
7
|
+
const query = new EventsQuery({
|
|
8
|
+
rows: [
|
|
9
|
+
{ tableName: 'table1', primaryKey: [testUuid(1)] },
|
|
10
|
+
{ tableName: 'table2', primaryKey: [testUuid(2), testUuid(3)] },
|
|
11
|
+
{ tableName: 'table3', primaryKey: [null, testUuid(3)] },
|
|
12
|
+
],
|
|
13
|
+
}, EventsOrder.CreatedAtAsc, 0, 10)
|
|
14
|
+
|
|
15
|
+
let called = false
|
|
16
|
+
await query.fetch({
|
|
17
|
+
db: {
|
|
18
|
+
schema: 'public',
|
|
19
|
+
query: async (sql: string, params: any) => {
|
|
20
|
+
called = true
|
|
21
|
+
expect(sql).toMatchInlineSnapshot(`"select "id", "type", "table_name", "row_ids", "values", "created_at", "applied_at", "identity_id", "event_data"."transaction_id" from "public"."event_data" inner join "public"."stage_transaction" on "event_data"."transaction_id" = "stage_transaction"."transaction_id" where ("table_name" = ? and "row_ids"->0 = ?::jsonb or "table_name" = ? and "row_ids"->0 = ?::jsonb and "row_ids"->1 = ?::jsonb or "table_name" = ? and "row_ids"->1 = ?::jsonb) order by "created_at" asc limit 10 offset 0"`)
|
|
22
|
+
expect(params).toMatchInlineSnapshot(`
|
|
23
|
+
[
|
|
24
|
+
"table1",
|
|
25
|
+
""123e4567-e89b-12d3-a456-000000000001"",
|
|
26
|
+
"table2",
|
|
27
|
+
""123e4567-e89b-12d3-a456-000000000002"",
|
|
28
|
+
""123e4567-e89b-12d3-a456-000000000003"",
|
|
29
|
+
"table3",
|
|
30
|
+
""123e4567-e89b-12d3-a456-000000000003"",
|
|
31
|
+
]
|
|
32
|
+
`)
|
|
33
|
+
|
|
34
|
+
return { rows: [] }
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
} as any)
|
|
38
|
+
expect(called).toBe(true)
|
|
39
|
+
})
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const schemaUtils = require("@contember/schema-utils");
|
|
4
|
-
const emptyVersionedSchema = { ...schemaUtils.normalizeSchema(schemaUtils.emptySchema), version: "", id: -1, notNormalized: { ...schemaUtils.emptySchema, version: "", id: -1 } };
|
|
5
|
-
class SchemaVersionBuilder {
|
|
6
|
-
constructor(executedMigrationsResolver, schemaMigrator) {
|
|
7
|
-
this.executedMigrationsResolver = executedMigrationsResolver;
|
|
8
|
-
this.schemaMigrator = schemaMigrator;
|
|
9
|
-
}
|
|
10
|
-
async buildSchema(db, after) {
|
|
11
|
-
const newMigrations = await this.executedMigrationsResolver.getMigrations(db, after?.version);
|
|
12
|
-
if (newMigrations.length === 0) {
|
|
13
|
-
return after ?? emptyVersionedSchema;
|
|
14
|
-
}
|
|
15
|
-
const schema = newMigrations.reduce(
|
|
16
|
-
(schema2, migration) => {
|
|
17
|
-
if (migration.type !== "schema") {
|
|
18
|
-
return schema2;
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
...this.schemaMigrator.applyModifications(schema2, migration.modifications, migration.formatVersion),
|
|
22
|
-
version: migration.version,
|
|
23
|
-
id: migration.id
|
|
24
|
-
};
|
|
25
|
-
},
|
|
26
|
-
after?.notNormalized ?? emptyVersionedSchema.notNormalized
|
|
27
|
-
);
|
|
28
|
-
const normalized = schemaUtils.normalizeSchema(schema);
|
|
29
|
-
return {
|
|
30
|
-
...normalized,
|
|
31
|
-
notNormalized: schema
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.SchemaVersionBuilder = SchemaVersionBuilder;
|
|
36
|
-
exports.emptyVersionedSchema = emptyVersionedSchema;
|
|
37
|
-
//# sourceMappingURL=SchemaVersionBuilder.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaVersionBuilder.cjs","sources":["../../../../../../packages/engine-system-api/src/model/migrations/SchemaVersionBuilder.ts"],"sourcesContent":["import { Schema } from '@contember/schema'\nimport { SchemaMigrator } from '@contember/schema-migrations'\nimport { emptySchema } from '@contember/schema-utils'\nimport { ExecutedMigrationsResolver } from './ExecutedMigrationsResolver'\nimport { DatabaseContext } from '../database'\nimport { normalizeSchema } from '@contember/schema-utils'\n\nexport type VersionedSchema = Schema & { version: string; id: number; notNormalized: Schema & { version: string; id: number } }\n\nexport const emptyVersionedSchema = { ...normalizeSchema(emptySchema), version: '', id: -1, notNormalized: { ...emptySchema, version: '', id: -1 } }\n\nexport class SchemaVersionBuilder {\n\tconstructor(\n\t\tprivate readonly executedMigrationsResolver: ExecutedMigrationsResolver,\n\t\tprivate readonly schemaMigrator: SchemaMigrator,\n\t) {}\n\n\tasync buildSchema(db: DatabaseContext, after?: VersionedSchema): Promise<VersionedSchema> {\n\t\tconst newMigrations = (await this.executedMigrationsResolver.getMigrations(db, after?.version))\n\t\tif (newMigrations.length === 0) {\n\t\t\treturn after ?? emptyVersionedSchema\n\t\t}\n\n\t\tconst schema = newMigrations.reduce(\n\t\t\t(schema, migration) => {\n\t\t\t\tif (migration.type !== 'schema') {\n\t\t\t\t\treturn schema\n\t\t\t\t}\n\t\t\t\treturn ({\n\t\t\t\t\t...this.schemaMigrator.applyModifications(schema, migration.modifications, migration.formatVersion),\n\t\t\t\t\tversion: migration.version,\n\t\t\t\t\tid: migration.id,\n\t\t\t\t})\n\t\t\t},\n\t\t\tafter?.notNormalized ?? emptyVersionedSchema.notNormalized,\n\t\t)\n\t\tconst normalized = normalizeSchema(schema)\n\t\treturn {\n\t\t\t...normalized,\n\t\t\tnotNormalized: schema,\n\t\t}\n\t}\n}\n"],"names":["normalizeSchema","emptySchema","schema"],"mappings":";;;AASO,MAAM,uBAAuB,EAAE,GAAGA,4BAAgBC,YAAAA,WAAW,GAAG,SAAS,IAAI,IAAI,IAAI,eAAe,EAAE,GAAGA,yBAAa,SAAS,IAAI,IAAI,KAAK;AAE5I,MAAM,qBAAqB;AAAA,EACjC,YACkB,4BACA,gBAChB;AAFgB,SAAA,6BAAA;AACA,SAAA,iBAAA;AAAA,EACf;AAAA,EAEH,MAAM,YAAY,IAAqB,OAAmD;AACzF,UAAM,gBAAiB,MAAM,KAAK,2BAA2B,cAAc,IAAI,OAAO,OAAO;AACzF,QAAA,cAAc,WAAW,GAAG;AAC/B,aAAO,SAAS;AAAA,IACjB;AAEA,UAAM,SAAS,cAAc;AAAA,MAC5B,CAACC,SAAQ,cAAc;AAClB,YAAA,UAAU,SAAS,UAAU;AACzBA,iBAAAA;AAAAA,QACR;AACQ,eAAA;AAAA,UACP,GAAG,KAAK,eAAe,mBAAmBA,SAAQ,UAAU,eAAe,UAAU,aAAa;AAAA,UAClG,SAAS,UAAU;AAAA,UACnB,IAAI,UAAU;AAAA,QAAA;AAAA,MAEhB;AAAA,MACA,OAAO,iBAAiB,qBAAqB;AAAA,IAAA;AAExC,UAAA,aAAaF,4BAAgB,MAAM;AAClC,WAAA;AAAA,MACN,GAAG;AAAA,MACH,eAAe;AAAA,IAAA;AAAA,EAEjB;AACD;;;"}
|