Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module versions #1802

Draft
wants to merge 101 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
7b1bc03
wip: massive refactor for module versions
niekcandaele Nov 4, 2024
36ccee4
wip: bunch more work
niekcandaele Nov 9, 2024
e97fff5
fix: issue seeding builtin modules
niekcandaele Nov 16, 2024
244c6d1
fix: get hook tests working
niekcandaele Nov 16, 2024
e027c0e
fix: modules not being uninstalled correctly
niekcandaele Nov 16, 2024
247d88f
fix: command triggers
niekcandaele Nov 16, 2024
5dc735e
fix: cronjobs
niekcandaele Nov 16, 2024
5d10740
chore: make snapshot overriding better by being more selective about …
niekcandaele Nov 16, 2024
6a72219
fix: ensure systemConfigSchema gets returned with moduleVersions
niekcandaele Nov 16, 2024
a6b821c
chore: get module tests running
niekcandaele Nov 16, 2024
2d77599
wip perms
niekcandaele Dec 1, 2024
5b97c23
fix: module-related permissions
niekcandaele Dec 7, 2024
a0b6181
fix: handle hooks with dupe names properly
niekcandaele Dec 8, 2024
8a70dce
fix a command test
niekcandaele Dec 8, 2024
6862251
fix: a cronjob test
niekcandaele Dec 8, 2024
c94c7ea
chore: add version IDs as standard ignored for snapshots
niekcandaele Dec 8, 2024
9dbaa63
fix: get all API tests working
niekcandaele Dec 10, 2024
45e29fc
refactor: standardize extends for module related models
niekcandaele Dec 13, 2024
dfc6a6a
fix: get a bunch of module tests running again
niekcandaele Dec 13, 2024
7ea5813
fix: some initial frontend fixes
niekcandaele Dec 14, 2024
61a4a0d
Merge branch development into module-versions
niekcandaele Dec 14, 2024
dc702e8
fix: code style
takaro-ci-bot[bot] Dec 14, 2024
4e71eb1
fix: some more frontend fixes
niekcandaele Dec 15, 2024
8e019bf
fix: allow passing moduleId to tag a new version
niekcandaele Dec 15, 2024
cb9ceb7
generate api client
emielvanseveren Dec 15, 2024
d67fbd3
deps: add semver package
emielvanseveren Dec 15, 2024
ed7415d
fix: code style
takaro-ci-bot[bot] Dec 15, 2024
4a3bdad
feat: add QoL property to list available versions
niekcandaele Dec 15, 2024
1c38430
fix: some snapshots after lib-module fixes
niekcandaele Dec 15, 2024
eef63df
refactor: adjust API endpoints for module creation and updates
niekcandaele Dec 17, 2024
dad18ad
feat: add more protections around module edits
niekcandaele Dec 18, 2024
76d0ec0
feat: export/import of modules now handles ALL versions of a module
niekcandaele Dec 18, 2024
1f390cd
fix: code style
takaro-ci-bot[bot] Dec 18, 2024
dae5036
feat: allow selecting which versions to export
niekcandaele Dec 18, 2024
1f89705
chore: regenerate lib apiclient
emielvanseveren Dec 18, 2024
6455ee1
fix: reinstalling a module now correctly updates config like before
niekcandaele Dec 18, 2024
b089021
wip: module versions frontend
emielvanseveren Dec 19, 2024
ecc5bc3
fix(app-api) make sure update module returns latestVersion
emielvanseveren Dec 19, 2024
9312932
Merge branch 'module-versions' of github.com:gettakaro/takaro into mo…
emielvanseveren Dec 19, 2024
3afed7e
wip: module versions frontend
emielvanseveren Dec 22, 2024
391c413
fix: help command
niekcandaele Dec 22, 2024
802e484
fix: localdev scenario when working on modules
niekcandaele Dec 22, 2024
7d25cd3
chore: refactor module installation ID to be a combination of server …
niekcandaele Dec 22, 2024
132ae36
Chore: tag module from module builder
emielvanseveren Dec 22, 2024
4179321
fix(web-main): do not rely on loader cache only
emielvanseveren Dec 22, 2024
ab42c3c
Merge branch 'module-versions' of github.com:gettakaro/takaro into mo…
emielvanseveren Dec 22, 2024
c4af2a1
wip: module versions frontend
emielvanseveren Dec 22, 2024
9111973
Refactor(web-main): replace questiontooltip with more generic IconToo…
emielvanseveren Dec 29, 2024
c05ea96
Refactor(lib-components): restyling of dropdown button
emielvanseveren Dec 29, 2024
b03529d
fix: filtering on gameserverId when searching module installations
niekcandaele Dec 29, 2024
c9de8f5
fix: ensure systemconfigschema is included in installation output
niekcandaele Dec 29, 2024
9da4535
fix: add proper error when unknown ID is provided
niekcandaele Dec 29, 2024
bc5bc22
fix: waypoints module
niekcandaele Dec 29, 2024
3306a9d
fix: a typing issue in lottery tests
niekcandaele Dec 29, 2024
97ae93a
fix: help command API call
niekcandaele Dec 29, 2024
e8c9c34
fix: a regression caught by bug repro test 1047
niekcandaele Dec 29, 2024
cef6ce8
chore: change a log message level to make test logs more readable whe…
niekcandaele Dec 29, 2024
a43e925
fix: include arguments in command update call
niekcandaele Dec 30, 2024
584b0f8
Refactor(lib-components): improve style of dropdownmenu and button
emielvanseveren Dec 31, 2024
42afbd7
Feat(lib-components): add disable prop to disable tooltip showing con…
emielvanseveren Dec 31, 2024
0b944ec
Fix(lib-components): limit select width when not in portal
emielvanseveren Dec 31, 2024
59c5a17
Chore(lib-components): imporve style of action menu in dropdown menu
emielvanseveren Dec 31, 2024
c6e8de7
chore(web-main): more logic for module versions
emielvanseveren Dec 31, 2024
3f173c8
Merge branch 'module-versions' of github.com:gettakaro/takaro into mo…
emielvanseveren Dec 31, 2024
b38e297
Refactor(web-main): move all dialogs into separate dialogs folder
emielvanseveren Jan 1, 2025
2f3a23e
fix(e2e): broken tests because of module versioning
emielvanseveren Jan 1, 2025
d067a29
fix(lib-components): keep track of selected items when query changes
emielvanseveren Jan 1, 2025
1b66bb5
fix(web-main): moduleselect should not reimplement no modules
emielvanseveren Jan 1, 2025
7e03eee
fix(web-main): add missing moduleIds in filter list
emielvanseveren Jan 1, 2025
08141f1
fix(web-main): bug with installation not being available
emielvanseveren Jan 1, 2025
55a3242
Refactor(web-main): make sure that question tooltips have neutral bg
emielvanseveren Jan 1, 2025
7dea762
fix(web-main): tiny typo
emielvanseveren Jan 1, 2025
3fc6e43
chore: add a repro test for a old bug
niekcandaele Jan 3, 2025
5d0d56f
chore: add a bug repro for permissions
niekcandaele Jan 3, 2025
bfddf91
Merge branch 'development' into module-versions
niekcandaele Jan 3, 2025
a08fbc1
chore: rename migration file
niekcandaele Jan 3, 2025
95d3b2c
fix: some merge weirdness
niekcandaele Jan 3, 2025
d3cbef3
chore: regenerate api client
niekcandaele Jan 3, 2025
5fdb2cf
fix: return version id with permission
niekcandaele Jan 3, 2025
a88e5de
Merge branch 'module-versions' of github.com:gettakaro/takaro into mo…
emielvanseveren Jan 3, 2025
b406cbf
chore: adjust response of permissions call
niekcandaele Jan 3, 2025
ce107d2
Fix(web-main): incorrect cache key (missing query params)
emielvanseveren Jan 3, 2025
1f24dc4
Feat(web-main): show module versions next to permissions in role
emielvanseveren Jan 3, 2025
9c95bb1
fix(web-main): error when installed module only has latest version
emielvanseveren Jan 3, 2025
7bdeb72
refactor(web-main): let itemwidget work with all pages with gameserve…
emielvanseveren Jan 3, 2025
6ff250b
fix(web-main): add missing moduelIds
emielvanseveren Jan 3, 2025
f2871c1
fix(lib-components): do not wrap current action
emielvanseveren Jan 4, 2025
9e02ed0
Fix(web-main): improve view for people with a lot of domains
emielvanseveren Jan 4, 2025
22b5e0a
chore(web-main,lib-components): remove console logs + add missing key
emielvanseveren Jan 4, 2025
6f3ec08
Fix(web-main,lib-components): eslint errors
emielvanseveren Jan 4, 2025
9b68f91
fix(web-main): add missing key
emielvanseveren Jan 4, 2025
59da423
Chore(web-main): reenable strict mode
emielvanseveren Jan 4, 2025
79c0422
fix: code style
takaro-ci-bot[bot] Jan 4, 2025
7bc6fe7
fix: pass proper ID
niekcandaele Jan 4, 2025
9464830
fix(web-main): module ids are now correct
emielvanseveren Jan 4, 2025
24cff64
Fix(web-main): gameserver settings update correctly when different ga…
emielvanseveren Jan 4, 2025
b6df9c8
Refactor(web-main): change color of question tooltip
emielvanseveren Jan 4, 2025
2c4d60a
fix: do not allow passing commands hooks or cron when creating module
niekcandaele Jan 4, 2025
5738972
fix: docs build
niekcandaele Jan 4, 2025
d840e49
fix: some more tests
niekcandaele Jan 4, 2025
9dc593a
docs: add docs about module versions
niekcandaele Jan 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deploy/compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ services:
depends_on:
- postgresql
container_name: takaro_migrator
command: npm -w packages/app-api run db:migrate && npm -w packages/app-api run domainInit
command: npm -w packages/app-api run db:migrate
env_file:
- .env
environment:
Expand Down
44 changes: 22 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions packages/app-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
"type": "module",
"scripts": {
"start": "node --experimental-vm-modules --loader ../../node_modules/@takaro/util/dist/tracing.js dist/main.js",
"start:dev": "nodemon --exec 'npm run build && npm run domainInit && node --experimental-vm-modules --inspect=0.0.0.0:12001 --loader ../../node_modules/@takaro/util/dist/tracing.js dist/main.js' --config ../../nodemon.json",
"start:dev": "nodemon --exec 'npm run build && node --experimental-vm-modules --inspect=0.0.0.0:12001 --loader ../../node_modules/@takaro/util/dist/tracing.js dist/main.js' --config ../../nodemon.json",
"prestart:dev": "npm run db:migrate",
"preload": "node -e \"import('geolite2-redist').then(geolite => geolite.downloadDbs())\"",
"build": "tsc -p ./tsconfig.build.json",
"test": "npm run test:unit --if-present && npm run test:integration --if-present",
"test:unit": "mocha --config ../../.mocharc.js src/**/*.unit.test.ts --exit",
"test:integration": "mocha --file ../test/dist/waitUntilReady.js --config ../../.mocharc.js src/**/*.integration.test.ts --exit",
"db:migrate": "node scripts/migrate-up.mjs",
"db:rollback": "node scripts/migrate-down.mjs",
"domainInit": "node --experimental-vm-modules --loader ../../node_modules/@takaro/util/dist/tracing.js dist/domainInit.js"
"db:rollback": "node scripts/migrate-down.mjs"
},
"keywords": [],
"author": "",
Expand Down Expand Up @@ -44,4 +43,4 @@
"bufferutil": "4.0.8",
"utf-8-validate": "6.0.4"
}
}
}
74 changes: 0 additions & 74 deletions packages/app-api/src/controllers/GameServerController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
IsNumber,
IsOptional,
IsString,
IsUUID,
MaxLength,
MinLength,
ValidateNested,
Expand All @@ -26,8 +25,6 @@ import {
GameServerOutputDTO,
GameServerService,
GameServerUpdateDTO,
ModuleInstallationOutputDTO,
ModuleInstallDTO,
} from '../service/GameServerService.js';
import { AuthenticatedRequest, AuthService, checkPermissions } from '../service/AuthService.js';
import { Body, Get, Post, Delete, JsonController, UseBefore, Req, Put, Params, Res } from 'routing-controllers';
Expand Down Expand Up @@ -111,26 +108,6 @@ class GameServerTestReachabilityInputDTO extends TakaroDTO<GameServerTestReachab
type: GAME_SERVER_TYPE;
}

class ParamIdAndModuleId {
@IsUUID('4')
gameServerId!: string;

@IsUUID('4')
moduleId!: string;
}

class ModuleInstallationOutputDTOAPI extends APIOutput<ModuleInstallationOutputDTO> {
@Type(() => ModuleInstallationOutputDTO)
@ValidateNested()
declare data: ModuleInstallationOutputDTO;
}

class ModuleInstallationOutputArrayDTOAPI extends APIOutput<ModuleInstallationOutputDTO[]> {
@Type(() => ModuleInstallationOutputDTO)
@ValidateNested({ each: true })
declare data: ModuleInstallationOutputDTO[];
}

class CommandExecuteDTOAPI extends APIOutput<CommandOutput> {
@Type(() => CommandOutput)
@ValidateNested()
Expand Down Expand Up @@ -346,57 +323,6 @@ export class GameServerController {
return apiResponse(res);
}

@UseBefore(AuthService.getAuthMiddleware([]))
@ResponseSchema(ModuleInstallationOutputDTOAPI)
@OpenAPI({
description: 'Get a module installation by id',
})
@Get('/gameserver/:gameServerId/module/:moduleId')
async getModuleInstallation(@Req() req: AuthenticatedRequest, @Params() params: ParamIdAndModuleId) {
const service = new GameServerService(req.domainId);
const res = await service.getModuleInstallation(params.gameServerId, params.moduleId);
return apiResponse(res);
}

@UseBefore(AuthService.getAuthMiddleware([]))
@ResponseSchema(ModuleInstallationOutputArrayDTOAPI)
@OpenAPI({
description: 'Get all module installations for a gameserver',
})
@Get('/gameserver/:id/modules')
async getInstalledModules(@Req() req: AuthenticatedRequest, @Params() params: ParamId) {
const service = new GameServerService(req.domainId);
const res = await service.getInstalledModules({ gameserverId: params.id });
return apiResponse(res);
}

@UseBefore(AuthService.getAuthMiddleware([PERMISSIONS.MANAGE_GAMESERVERS]))
@ResponseSchema(ModuleInstallationOutputDTOAPI)
@OpenAPI({
description: 'Install a module on a gameserver. If the module is already installed, it will be updated.',
})
@Post('/gameserver/:gameServerId/modules/:moduleId')
async installModule(
@Req() req: AuthenticatedRequest,
@Params() params: ParamIdAndModuleId,
@Body() data?: ModuleInstallDTO,
) {
const service = new GameServerService(req.domainId);

return apiResponse(await service.installModule(params.gameServerId, params.moduleId, data));
}

@UseBefore(AuthService.getAuthMiddleware([PERMISSIONS.MANAGE_GAMESERVERS]))
@ResponseSchema(ModuleInstallationOutputDTOAPI)
@OpenAPI({
description: 'Uninstall a module from a gameserver. This will not delete the module from the database.',
})
@Delete('/gameserver/:gameServerId/modules/:moduleId')
async uninstallModule(@Req() req: AuthenticatedRequest, @Params() params: ParamIdAndModuleId) {
const service = new GameServerService(req.domainId);
return apiResponse(await service.uninstallModule(params.gameServerId, params.moduleId));
}

@UseBefore(AuthService.getAuthMiddleware([PERMISSIONS.MANAGE_GAMESERVERS]))
@ResponseSchema(CommandExecuteDTOAPI)
@OpenAPI({
Expand Down
115 changes: 115 additions & 0 deletions packages/app-api/src/controllers/Module/installations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import { IsOptional, IsUUID, ValidateNested } from 'class-validator';
import { ITakaroQuery } from '@takaro/db';
import { APIOutput, apiResponse } from '@takaro/http';
import { ModuleService } from '../../service/Module/index.js';
import { AuthenticatedRequest, AuthService } from '../../service/AuthService.js';
import { Body, Get, Post, Delete, JsonController, UseBefore, Req, Params, Res } from 'routing-controllers';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { Type } from 'class-transformer';
import { ParamId } from '../../lib/validators.js';
import { PERMISSIONS } from '@takaro/auth';
import { Response } from 'express';
import { AllowedFilters } from '../shared.js';
import { InstallModuleDTO, ModuleInstallationOutputDTO } from '../../service/Module/dto.js';


class ModuleInstallationOutputDTOAPI extends APIOutput<ModuleInstallationOutputDTO> {
@Type(() => ModuleInstallationOutputDTO)
@ValidateNested()
declare data: ModuleInstallationOutputDTO;
}

class ModuleInstallationOutputArrayDTOAPI extends APIOutput<ModuleInstallationOutputDTO[]> {
@Type(() => ModuleInstallationOutputDTO)
@ValidateNested({ each: true })
declare data: ModuleInstallationOutputDTO[];
}


class ModuleInstallationSearchInputAllowedFilters extends AllowedFilters {
@IsOptional()
@IsUUID('4', { each: true })
versionId: string[];
@IsOptional()
@IsUUID('4', { each: true })
moduleId: string[];
@IsOptional()
@IsUUID('4', { each: true })
gameServerId: string[];
}

class ModuleInstallationSearchInputDTO extends ITakaroQuery<ModuleInstallationSearchInputAllowedFilters> {
@ValidateNested()
@Type(() => ModuleInstallationSearchInputAllowedFilters)
declare filters: ModuleInstallationSearchInputAllowedFilters;

@ValidateNested()
@Type(() => ModuleInstallationSearchInputAllowedFilters)
declare search: ModuleInstallationSearchInputAllowedFilters;
}


@OpenAPI({
security: [{ domainAuth: [] }],
tags: ['Module'],
})
@JsonController('/module/installation')
export class ModuleInstallationsController {
@UseBefore(AuthService.getAuthMiddleware([PERMISSIONS.READ_MODULES]))
@ResponseSchema(ModuleInstallationOutputArrayDTOAPI)
@OpenAPI({
summary: 'Search module installations',
})
@Post('/search')
async getInstalledModules(@Req() req: AuthenticatedRequest, @Res() res: Response, @Body() query: ModuleInstallationSearchInputDTO) {
const service = new ModuleService(req.domainId);
const result = await service.findInstallations({
...query,
page: res.locals.page,
limit: res.locals.limit,
});
return apiResponse(result.results, {
meta: { total: result.total },
req,
res,
});
}

@UseBefore(AuthService.getAuthMiddleware([PERMISSIONS.READ_MODULES]))
@ResponseSchema(ModuleInstallationOutputDTOAPI)
@OpenAPI({
summary: 'Get one installation',
})
@Get('/:id')
async getModuleInstallation(@Req() req: AuthenticatedRequest, @Params() params: ParamId) {
const service = new ModuleService(req.domainId);
const res = await service.findOneInstallation(params.id);
return apiResponse(res);
}


@UseBefore(AuthService.getAuthMiddleware([PERMISSIONS.MANAGE_GAMESERVERS]))
@ResponseSchema(ModuleInstallationOutputDTOAPI)
@OpenAPI({
description: 'Install a module on a gameserver. You can have multiple installations of the same module on the same gameserver.',
})
@Post('/')
async installModule(
@Req() req: AuthenticatedRequest,
@Body() data: InstallModuleDTO,
) {
const service = new ModuleService(req.domainId);
return apiResponse(await service.installModule(data));
}

@UseBefore(AuthService.getAuthMiddleware([PERMISSIONS.MANAGE_GAMESERVERS]))
@ResponseSchema(ModuleInstallationOutputDTOAPI)
@OpenAPI({
description: 'Uninstall a module from a gameserver. This will not delete the module from the database.',
})
@Delete('/:id')
async uninstallModule(@Req() req: AuthenticatedRequest, @Params() params: ParamId) {
const service = new ModuleService(req.domainId);
return apiResponse(await service.uninstallModule(params.id));
}
}
Loading
Loading