diff --git a/apps/server/src/migrations/mikro-orm/Migration20240419075957.ts b/apps/server/src/migrations/mikro-orm/Migration20240419075957.ts new file mode 100644 index 00000000000..b63651d1d42 --- /dev/null +++ b/apps/server/src/migrations/mikro-orm/Migration20240419075957.ts @@ -0,0 +1,22 @@ +import { Migration } from '@mikro-orm/migrations-mongodb'; +import { LtiMessageType, ToolConfigType } from '@modules/tool/common/enum'; + +export class Migration20240419075957 extends Migration { + async up(): Promise { + const result = await this.driver.nativeUpdate( + 'external-tools', + { + config_type: ToolConfigType.LTI11, + config_lti_message_type: { $ne: LtiMessageType.BASIC_LTI_LAUNCH_REQUEST }, + }, + { config_lti_message_type: LtiMessageType.BASIC_LTI_LAUNCH_REQUEST } + ); + + console.info(`Changed ${result.affectedRows} lti_message_type(s) to basic-lti-launch-request in external-tools`); + } + + // eslint-disable-next-line @typescript-eslint/require-await + async down(): Promise { + console.error(`Migration down not implemented. You might need to restore database from backup!`); + } +} diff --git a/apps/server/src/modules/tool/common/enum/lti-message-type.enum.ts b/apps/server/src/modules/tool/common/enum/lti-message-type.enum.ts index 669e02301bd..6574f8d89b7 100644 --- a/apps/server/src/modules/tool/common/enum/lti-message-type.enum.ts +++ b/apps/server/src/modules/tool/common/enum/lti-message-type.enum.ts @@ -1,5 +1,3 @@ export enum LtiMessageType { BASIC_LTI_LAUNCH_REQUEST = 'basic-lti-launch-request', - LTI_RESOURCE_LINK_REQUEST = 'LtiResourceLinkRequest', - LTI_DEEP_LINKING_REQUEST = 'LtiDeepLinkingRequest', } diff --git a/apps/server/src/modules/tool/external-tool/controller/dto/request/config/lti11-tool-config-create.params.ts b/apps/server/src/modules/tool/external-tool/controller/dto/request/config/lti11-tool-config-create.params.ts index 86887a9ab42..ca33df4d1b1 100644 --- a/apps/server/src/modules/tool/external-tool/controller/dto/request/config/lti11-tool-config-create.params.ts +++ b/apps/server/src/modules/tool/external-tool/controller/dto/request/config/lti11-tool-config-create.params.ts @@ -5,7 +5,7 @@ import { ExternalToolConfigCreateParams } from './external-tool-config.params'; export class Lti11ToolConfigCreateParams extends ExternalToolConfigCreateParams { @IsEnum(ToolConfigType) - @ApiProperty() + @ApiProperty({ enum: ToolConfigType, enumName: 'ToolConfigType' }) type!: ToolConfigType; @IsString() @@ -21,11 +21,11 @@ export class Lti11ToolConfigCreateParams extends ExternalToolConfigCreateParams secret!: string; @IsEnum(LtiMessageType) - @ApiProperty() + @ApiProperty({ enum: LtiMessageType, enumName: 'LtiMessageType' }) lti_message_type!: LtiMessageType; @IsEnum(LtiPrivacyPermission) - @ApiProperty() + @ApiProperty({ enum: LtiPrivacyPermission, enumName: 'LtiPrivacyPermission' }) privacy_permission!: LtiPrivacyPermission; @IsLocale() diff --git a/apps/server/src/modules/tool/external-tool/controller/dto/request/config/lti11-tool-config-update.params.ts b/apps/server/src/modules/tool/external-tool/controller/dto/request/config/lti11-tool-config-update.params.ts index 7b238690f58..8893351a91c 100644 --- a/apps/server/src/modules/tool/external-tool/controller/dto/request/config/lti11-tool-config-update.params.ts +++ b/apps/server/src/modules/tool/external-tool/controller/dto/request/config/lti11-tool-config-update.params.ts @@ -5,7 +5,7 @@ import { ExternalToolConfigCreateParams } from './external-tool-config.params'; export class Lti11ToolConfigUpdateParams extends ExternalToolConfigCreateParams { @IsEnum(ToolConfigType) - @ApiProperty() + @ApiProperty({ enum: ToolConfigType, enumName: 'ToolConfigType' }) type!: ToolConfigType; @IsString() @@ -22,11 +22,11 @@ export class Lti11ToolConfigUpdateParams extends ExternalToolConfigCreateParams secret?: string; @IsEnum(LtiMessageType) - @ApiProperty() + @ApiProperty({ enum: LtiMessageType, enumName: 'LtiMessageType' }) lti_message_type!: LtiMessageType; @IsEnum(LtiPrivacyPermission) - @ApiProperty() + @ApiProperty({ enum: LtiPrivacyPermission, enumName: 'LtiPrivacyPermission' }) privacy_permission!: LtiPrivacyPermission; @IsLocale() diff --git a/apps/server/src/modules/tool/external-tool/controller/dto/response/config/lti11-tool-config.response.ts b/apps/server/src/modules/tool/external-tool/controller/dto/response/config/lti11-tool-config.response.ts index a3c68ba5f43..29e39e637bd 100644 --- a/apps/server/src/modules/tool/external-tool/controller/dto/response/config/lti11-tool-config.response.ts +++ b/apps/server/src/modules/tool/external-tool/controller/dto/response/config/lti11-tool-config.response.ts @@ -3,7 +3,7 @@ import { LtiMessageType, LtiPrivacyPermission, ToolConfigType } from '../../../. import { ExternalToolConfigResponse } from './external-tool-config.response'; export class Lti11ToolConfigResponse extends ExternalToolConfigResponse { - @ApiProperty() + @ApiProperty({ enum: ToolConfigType, enumName: 'ToolConfigType' }) type: ToolConfigType; @ApiProperty() @@ -12,10 +12,10 @@ export class Lti11ToolConfigResponse extends ExternalToolConfigResponse { @ApiProperty() key: string; - @ApiProperty() + @ApiProperty({ enum: LtiMessageType, enumName: 'LtiMessageType' }) lti_message_type: LtiMessageType; - @ApiProperty() + @ApiProperty({ enum: LtiPrivacyPermission, enumName: 'LtiPrivacyPermission' }) privacy_permission: LtiPrivacyPermission; @ApiProperty() diff --git a/backup/setup/migrations.json b/backup/setup/migrations.json index fa332adf663..4a071c622f2 100644 --- a/backup/setup/migrations.json +++ b/backup/setup/migrations.json @@ -28,38 +28,47 @@ }, { "_id": { - "$oid": "65eecc9abaf077b6f9fdb878" + "$oid": "661d0a8f95c6e7265aa4f180" }, "name": "Migration20240304123509", "created_at": { - "$date": "2024-03-11T09:19:22.532Z" + "$date": "2024-04-15T11:07:59.291Z" } }, { "_id": { - "$oid": "65fad61d12d7267c5d7a520c" + "$oid": "661d0a8f95c6e7265aa4f181" }, - "name": "Migration20240320122229", + "name": "Migration20240315140224", "created_at": { - "$date": "2024-03-20T12:27:09.614Z" + "$date": "2024-04-15T11:07:59.301Z" } }, { "_id": { - "$oid": "65faff9f8009e32be883536d" + "$oid": "661d0a8f95c6e7265aa4f182" }, - "name": "Migration20240315140224", + "name": "Migration20240320122229", "created_at": { - "$date": "2024-03-20T15:24:15.250Z" + "$date": "2024-04-15T11:07:59.306Z" } }, { "_id": { - "$oid": "6602deeb0611e07702de5cb8" + "$oid": "661d0a8f95c6e7265aa4f183" }, "name": "Migration20240326072506", "created_at": { - "$date": "2024-03-26T14:42:51.024Z" + "$date": "2024-04-15T11:07:59.312Z" + } + }, + { + "_id": { + "$oid": "6622341440e305c6e36dcd81" + }, + "name": "Migration20240419075957", + "created_at": { + "$date": "2024-04-19T09:06:28.592Z" } } ] diff --git a/scripts/copy-legacy-tool-to-ctl.js b/scripts/copy-legacy-tool-to-ctl.js index 659379501ba..5f41bc3b6f9 100644 --- a/scripts/copy-legacy-tool-to-ctl.js +++ b/scripts/copy-legacy-tool-to-ctl.js @@ -92,7 +92,7 @@ const ExternalTool = mongoose.model( config_secret: String, config_lti_message_type: { type: String, - enum: ['basic-lti-launch-request', 'LtiResourceLinkRequest', 'LtiDeepLinkingRequest'], + enum: ['basic-lti-launch-request'], }, config_privacy_permission: { type: String,