From 76d0ec03752e9ed92e7635c8d081e1ea0151d969 Mon Sep 17 00:00:00 2001 From: Niek Candaele Date: Wed, 18 Dec 2024 20:54:29 +0100 Subject: [PATCH] feat: export/import of modules now handles ALL versions of a module --- .../app-api/src/controllers/Module/modules.ts | 120 +++++ .../src/controllers/Module/versions.ts | 113 +--- .../ModuleController.integration.test.ts | 32 +- packages/app-api/src/lib/systemConfig.ts | 4 + packages/app-api/src/service/Module/dto.ts | 5 - packages/app-api/src/service/Module/index.ts | 140 ++--- packages/lib-apiclient/src/generated/api.ts | 506 +++++++++--------- packages/lib-modules/src/BuiltinModule.ts | 46 +- packages/lib-modules/src/main.ts | 16 +- .../src/modules/chatBridge/index.ts | 106 ++-- .../src/modules/dailyRewards/index.ts | 233 ++++---- .../src/modules/economyUtils/index.ts | 362 ++++++------- .../lib-modules/src/modules/geoBlock/index.ts | 143 ++--- .../lib-modules/src/modules/gimme/index.ts | 115 ++-- .../src/modules/highPingKicker/index.ts | 68 +-- .../lib-modules/src/modules/lottery/index.ts | 145 ++--- .../src/modules/playerOnboarding/index.ts | 139 ++--- .../src/modules/serverMessages/index.ts | 69 +-- .../src/modules/teleports/index.ts | 365 ++++++------- .../src/modules/timedShutdown/index.ts | 66 +-- .../lib-modules/src/modules/utils/index.ts | 69 +-- ...t-type is discord-message, happy path.json | 2 +- ...stalling a module with correct config.json | 2 +- ...ct system config - multiple cron jobs.json | 2 +- ...onfig - should default cronjob values.json | 2 +- ...Installing with correct system config.json | 2 +- ...of permissions when creating a module.json | 2 +- ...of permissions when updating a module.json | 2 +- .../ModuleController/Create.json | 2 +- .../ModuleController/Get by ID.json | 2 +- ...permission returns updated permission.json | 2 +- ...ng permissions can remove permissions.json | 2 +- ...tatic of already-existing permissions.json | 2 +- .../versioning: Can tag a version.json | 2 +- 34 files changed, 1468 insertions(+), 1420 deletions(-) diff --git a/packages/app-api/src/controllers/Module/modules.ts b/packages/app-api/src/controllers/Module/modules.ts index 0c21ef5c6b..9e35758643 100644 --- a/packages/app-api/src/controllers/Module/modules.ts +++ b/packages/app-api/src/controllers/Module/modules.ts @@ -14,6 +14,10 @@ import { ITakaroQuery } from '@takaro/db'; import { ModuleService } from '../../service/Module/index.js'; import { ModuleCreateAPIDTO, ModuleOutputDTO, ModuleUpdateDTO } from '../../service/Module/dto.js'; +import { ModuleTransferDTO, ICommand, ICommandArgument, ICronJob, IFunction, IHook } from '@takaro/modules'; +import { PermissionCreateDTO } from '../../service/RoleService.js'; +import { ModuleTransferVersionDTO } from '@takaro/modules'; + export class ModuleOutputDTOAPI extends APIOutput { @Type(() => ModuleOutputDTO) @ValidateNested() @@ -50,12 +54,19 @@ class ModuleSearchInputDTO extends ITakaroQuery declare lessThan: RangeFilterCreatedAndUpdatedAt; } +class ModuleExportDTOAPI extends APIOutput> { + @Type(() => ModuleTransferDTO) + @ValidateNested() + declare data: ModuleTransferDTO; +} + @OpenAPI({ security: [{ domainAuth: [] }], tags: ['Module'], }) @JsonController('/module') export class ModuleController { + // #region CRUD @UseBefore(AuthService.getAuthMiddleware([PERMISSIONS.READ_MODULES])) @ResponseSchema(ModuleOutputArrayDTOAPI) @OpenAPI({ @@ -127,4 +138,113 @@ export class ModuleController { await service.delete(params.id); return apiResponse(); } + // #endregion CRUD + // #region Export/Import + + @UseBefore(AuthService.getAuthMiddleware([PERMISSIONS.READ_MODULES])) + @OpenAPI({ + summary: 'Export a module', + description: + 'Exports a module to a format that can be imported into another Takaro instance. This endpoint will export all known versions of the module', + }) + @Post('/:id/export') + @ResponseSchema(ModuleExportDTOAPI) + async export(@Req() req: AuthenticatedRequest, @Params() params: ParamId) { + const service = new ModuleService(req.domainId); + const mod = await service.findOne(params.id); + if (!mod) throw new errors.NotFoundError('Module not found'); + const versions = await service.findVersions({ filters: { moduleId: [params.id] } }); + + const preparedVersions = await Promise.all( + versions.results.map( + async (version) => + new ModuleTransferVersionDTO({ + tag: version.tag, + description: version.description, + configSchema: version.configSchema, + uiSchema: version.uiSchema, + commands: await Promise.all( + version.commands.map( + (_) => + new ICommand({ + function: _.function.code, + name: _.name, + trigger: _.trigger, + helpText: _.helpText, + arguments: _.arguments.map( + (arg) => + new ICommandArgument({ + name: arg.name, + type: arg.type, + defaultValue: arg.defaultValue, + helpText: arg.helpText, + position: arg.position, + }), + ), + }), + ), + ), + hooks: await Promise.all( + version.hooks.map( + (_) => + new IHook({ + function: _.function.code, + name: _.name, + eventType: _.eventType, + }), + ), + ), + cronJobs: await Promise.all( + version.cronJobs.map( + (_) => + new ICronJob({ + function: _.function.code, + name: _.name, + temporalValue: _.temporalValue, + }), + ), + ), + functions: await Promise.all( + version.functions.map( + (_) => + new IFunction({ + function: _.code, + name: _.name, + }), + ), + ), + permissions: await Promise.all( + version.permissions.map( + (_) => + new PermissionCreateDTO({ + canHaveCount: _.canHaveCount, + description: _.description, + permission: _.permission, + friendlyName: _.friendlyName, + }), + ), + ), + }), + ), + ); + + const output = new ModuleTransferDTO({ + name: mod.name, + versions: preparedVersions, + }); + + return apiResponse(output); + } + + @UseBefore(AuthService.getAuthMiddleware([PERMISSIONS.MANAGE_MODULES])) + @OpenAPI({ + summary: 'Import a module', + description: 'Imports a module from a format that was exported from another Takaro instance', + }) + @Post('/import') + async import(@Req() req: AuthenticatedRequest, @Body() data: ModuleTransferDTO) { + const service = new ModuleService(req.domainId); + return apiResponse(await service.import(data)); + } + // #endregion Export/Import } diff --git a/packages/app-api/src/controllers/Module/versions.ts b/packages/app-api/src/controllers/Module/versions.ts index dbb020b7d1..8870a13a12 100644 --- a/packages/app-api/src/controllers/Module/versions.ts +++ b/packages/app-api/src/controllers/Module/versions.ts @@ -9,11 +9,8 @@ import { Type } from 'class-transformer'; import { ParamId } from '../../lib/validators.js'; import { PERMISSIONS } from '@takaro/auth'; import { Response } from 'express'; -import { errors } from '@takaro/util'; -import { BuiltinModule, ICommand, ICommandArgument, ICronJob, IFunction, IHook } from '@takaro/modules'; import { AllowedFilters, RangeFilterCreatedAndUpdatedAt } from '../shared.js'; -import { ModuleExportInputDTO, ModuleVersionCreateAPIDTO, ModuleVersionOutputDTO } from '../../service/Module/dto.js'; -import { PermissionCreateDTO } from '../../service/RoleService.js'; +import { ModuleVersionCreateAPIDTO, ModuleVersionOutputDTO } from '../../service/Module/dto.js'; export class ModuleVersionOutputDTOAPI extends APIOutput { @Type(() => ModuleVersionOutputDTO) @@ -51,12 +48,6 @@ class ModuleVersionSearchInputDTO extends ITakaroQuery> { - @Type(() => BuiltinModule) - @ValidateNested() - declare data: BuiltinModule; -} - @OpenAPI({ security: [{ domainAuth: [] }], tags: ['Module'], @@ -112,106 +103,4 @@ export class ModuleVersionController { const result = await service.tagVersion(data.moduleId, data.tag); return apiResponse(result); } - - @UseBefore(AuthService.getAuthMiddleware([PERMISSIONS.READ_MODULES])) - @OpenAPI({ - summary: 'Export a module version', - description: 'Exports a module to a format that can be imported into another Takaro instance', - }) - @Post('/export') - @ResponseSchema(ModuleExportDTOAPI) - async export(@Req() req: AuthenticatedRequest, @Body() data: ModuleExportInputDTO) { - const service = new ModuleService(req.domainId); - const version = await service.findOneVersion(data.versionId); - if (!version) throw new errors.NotFoundError('Version not found'); - const mod = await service.findOne(version.moduleId); - if (!mod) throw new errors.NotFoundError('Module not found'); - if (!version) throw new errors.NotFoundError('Version not found'); - - const output = new BuiltinModule( - mod.name, - version.description, - version.tag, - version.configSchema, - version.uiSchema, - ); - output.commands = await Promise.all( - version.commands.map( - (_) => - new ICommand({ - function: _.function.code, - name: _.name, - trigger: _.trigger, - helpText: _.helpText, - arguments: _.arguments.map( - (arg) => - new ICommandArgument({ - name: arg.name, - type: arg.type, - defaultValue: arg.defaultValue, - helpText: arg.helpText, - position: arg.position, - }), - ), - }), - ), - ); - - output.hooks = await Promise.all( - version.hooks.map( - (_) => - new IHook({ - function: _.function.code, - name: _.name, - eventType: _.eventType, - }), - ), - ); - - output.cronJobs = await Promise.all( - version.cronJobs.map( - (_) => - new ICronJob({ - function: _.function.code, - name: _.name, - temporalValue: _.temporalValue, - }), - ), - ); - - output.functions = await Promise.all( - version.functions.map( - (_) => - new IFunction({ - function: _.code, - name: _.name, - }), - ), - ); - - output.permissions = await Promise.all( - version.permissions.map( - (_) => - new PermissionCreateDTO({ - canHaveCount: _.canHaveCount, - description: _.description, - permission: _.permission, - friendlyName: _.friendlyName, - }), - ), - ); - - return apiResponse(output); - } - - @UseBefore(AuthService.getAuthMiddleware([PERMISSIONS.MANAGE_MODULES])) - @OpenAPI({ - summary: 'Import a module version', - description: 'Imports a module from a format that was exported from another Takaro instance', - }) - @Post('/import') - async import(@Req() req: AuthenticatedRequest, @Body() data: BuiltinModule) { - const service = new ModuleService(req.domainId); - return apiResponse(await service.import(data)); - } } diff --git a/packages/app-api/src/controllers/__tests__/ModuleController.integration.test.ts b/packages/app-api/src/controllers/__tests__/ModuleController.integration.test.ts index 05507ebc0a..121909e5ab 100644 --- a/packages/app-api/src/controllers/__tests__/ModuleController.integration.test.ts +++ b/packages/app-api/src/controllers/__tests__/ModuleController.integration.test.ts @@ -319,15 +319,23 @@ const tests = [ }, }) ).data.data[0]; - const versions = ( - await this.client.module.moduleVersionControllerSearchVersions({ - filters: { moduleId: [mod.id], version: [builtin.version] }, - }) - ).data.data; - const version = versions.find((v) => v.tag === builtin.version); - if (!version) throw new Error('Version not found'); - const exportRes = await this.client.module.moduleVersionControllerExport({ versionId: version.id }); - expect(exportRes.data.data).to.deep.equalInAnyOrder(builtin); + const exportRes = await this.client.module.moduleControllerExport(mod.id); + expect(exportRes.data.data.name).to.be.equal(builtin.name); + + const expectedTags = builtin.versions.map((v) => v.tag); + for (const tag of expectedTags) { + const version = exportRes.data.data.versions.find((v) => v.tag === tag); + // Check that each builtin version is present in the exported module + expect(version).to.exist; + // Typescipt doesn't understand that `expect` already checks for existence + if (!version) throw new Error(`Version ${tag} not found in exported module`); + // Each version should contain hooks,commands,cronjobs,... + expect(version.hooks).to.exist; + expect(version.commands).to.exist; + expect(version.cronJobs).to.exist; + expect(version.functions).to.exist; + expect(version.permissions).to.exist; + } }, }), ), @@ -346,10 +354,8 @@ const tests = [ }) ).data.data; expect(mods).to.have.length(1); - const exportRes = await this.client.module.moduleVersionControllerExport({ - versionId: mods[0].latestVersion.id, - }); - await this.client.module.moduleVersionControllerImport(exportRes.data.data); + const exportRes = await this.client.module.moduleControllerExport(mods[0].id); + await this.client.module.moduleControllerImport(exportRes.data.data); const modsAfter = ( await this.client.module.moduleControllerSearch({ filters: { diff --git a/packages/app-api/src/lib/systemConfig.ts b/packages/app-api/src/lib/systemConfig.ts index a324d53cb5..7ca05c723d 100644 --- a/packages/app-api/src/lib/systemConfig.ts +++ b/packages/app-api/src/lib/systemConfig.ts @@ -14,6 +14,10 @@ export function getEmptyConfigSchema(): Ajv.AnySchemaObject { }; } +export function getEmptyUiSchema() { + return {}; +} + export function getSystemConfigSchema(mod: ModuleVersionOutputDTO | ModuleVersionOutputDTOApi): string { const systemConfigSchema = getEmptyConfigSchema(); diff --git a/packages/app-api/src/service/Module/dto.ts b/packages/app-api/src/service/Module/dto.ts index b00732ed3b..c915d20dae 100644 --- a/packages/app-api/src/service/Module/dto.ts +++ b/packages/app-api/src/service/Module/dto.ts @@ -183,11 +183,6 @@ export class ModuleVersionCreateAPIDTO extends TakaroDTO { - @IsUUID() - versionId: string; -} - export class InstallModuleDTO extends TakaroDTO { @IsUUID('4') versionId: string; diff --git a/packages/app-api/src/service/Module/index.ts b/packages/app-api/src/service/Module/index.ts index 1823c74a5b..7508b10fa1 100644 --- a/packages/app-api/src/service/Module/index.ts +++ b/packages/app-api/src/service/Module/index.ts @@ -9,7 +9,7 @@ import { ITakaroQuery, SortDirection } from '@takaro/db'; import { PaginatedOutput } from '../../db/base.js'; import { CommandCreateDTO, CommandService } from '../CommandService.js'; import { - BuiltinModule, + ModuleTransferDTO, TakaroEventModuleCreated, TakaroEventModuleUpdated, TakaroEventModuleDeleted, @@ -17,12 +17,12 @@ import { TakaroEventModuleInstalled, TakaroEventModuleUninstalled, } from '@takaro/modules'; -import { PermissionCreateDTO, PermissionOutputDTO } from '../RoleService.js'; +import { PermissionCreateDTO } from '../RoleService.js'; import * as semver from 'semver'; // Curse you ESM... :( import _Ajv from 'ajv'; -import { getEmptyConfigSchema, getSystemConfigSchema } from '../../lib/systemConfig.js'; +import { getEmptyConfigSchema, getEmptyUiSchema, getSystemConfigSchema } from '../../lib/systemConfig.js'; import { EVENT_TYPES, EventCreateDTO, EventService } from '../EventService.js'; import { FunctionCreateDTO, FunctionService } from '../FunctionService.js'; import { @@ -124,11 +124,15 @@ export class ModuleService extends TakaroService) { + async import(mod: ModuleTransferDTO) { const existing = await this.repo.find({ filters: { name: [mod.name] }, }); @@ -226,7 +230,7 @@ export class ModuleService extends TakaroService this.seedModule(m))); } - async seedModule(builtin: BuiltinModule, isImport = false) { + async seedModule(builtin: ModuleTransferDTO, isImport = false) { const existingModule = await this.repo.find({ filters: { builtin: [builtin.name] }, }); @@ -240,73 +244,79 @@ export class ModuleService extends TakaroService new PermissionOutputDTO(p))), - }), }), ); } - const existingVersionRes = await this.findVersions({ filters: { version: [builtin.version], moduleId: [mod.id] } }); - - const existingVersions = existingVersionRes.results.filter((v) => v.tag === builtin.version); - - // Version already exists, no action needed - if (existingVersions.length) return; - - const latestVersion = await this.getLatestVersion(mod.id); - - this.log.info(`Creating new module version ${builtin.name}-${builtin.version}`, { - name: builtin.name, - version: builtin.version, - }); - const commands = Promise.all( - builtin.commands.map(async (c) => { - const data = new CommandCreateDTO({ - ...c, - versionId: latestVersion.id, - }); - return this.commandService().create(data); - }), - ); + for (const version of builtin.versions) { + this.log.info(`Creating new module version ${builtin.name}-${version.tag}`, { + name: builtin.name, + tag: version.tag, + }); + const existingVersionRes = await this.findVersions({ filters: { tag: [version.tag], moduleId: [mod.id] } }); + const existingVersions = existingVersionRes.results.filter((v) => v.tag === version.tag); + // Version already exists, no action needed + if (existingVersions.length) return; + + const latestVersion = await this.getLatestVersion(mod.id); + + const commands = Promise.all( + (version.commands || []).map(async (c) => { + const data = new CommandCreateDTO({ + ...c, + versionId: latestVersion.id, + }); + return this.commandService().create(data); + }), + ); - const hooks = Promise.all( - builtin.hooks.map(async (h) => { - const data = new HookCreateDTO({ - ...h, - eventType: h.eventType, - versionId: latestVersion.id, - }); - return this.hookService().create(data); - }), - ); - const cronjobs = Promise.all( - builtin.cronJobs.map(async (c) => { - const data = new CronJobCreateDTO({ - ...c, - versionId: latestVersion.id, - }); - return this.cronjobService().create(data); - }), - ); + const hooks = Promise.all( + (version.hooks || []).map(async (h) => { + const data = new HookCreateDTO({ + ...h, + eventType: h.eventType, + versionId: latestVersion.id, + }); + return this.hookService().create(data); + }), + ); + const cronjobs = Promise.all( + (version.cronJobs || []).map(async (c) => { + const data = new CronJobCreateDTO({ + ...c, + versionId: latestVersion.id, + }); + return this.cronjobService().create(data); + }), + ); - const functions = Promise.all( - builtin.functions.map(async (f) => { - const data = new FunctionCreateDTO({ - name: f.name, - code: f.function, - versionId: latestVersion.id, - }); - return this.functionService().create(data); - }), - ); - await Promise.all([commands, hooks, cronjobs, commands, functions]); + const functions = Promise.all( + (version.functions || []).map(async (f) => { + const data = new FunctionCreateDTO({ + name: f.name, + code: f.function, + versionId: latestVersion.id, + }); + return this.functionService().create(data); + }), + ); + await Promise.all([commands, hooks, cronjobs, commands, functions]); + + await this.update( + mod.id, + new ModuleUpdateDTO({ + latestVersion: new ModuleVersionUpdateDTO({ + configSchema: version.configSchema, + description: version.description, + uiSchema: version.uiSchema, + permissions: (version.permissions as PermissionCreateDTO[]) || [], + }), + }), + ); - // With everything in place, we can now create the version - await this.tagVersion(mod.id, builtin.version); + // With everything in place, we can now create the version + await this.tagVersion(mod.id, version.tag); + } } async findOneBy(itemType: string, itemId: string | undefined): Promise { diff --git a/packages/lib-apiclient/src/generated/api.ts b/packages/lib-apiclient/src/generated/api.ts index 23814cf93f..7832c5a766 100644 --- a/packages/lib-apiclient/src/generated/api.ts +++ b/packages/lib-apiclient/src/generated/api.ts @@ -582,73 +582,6 @@ export interface BaseTakaroEvent { */ timestamp: NOTDOMAINSCOPEDTakaroModelDTOCreatedAt; } -/** - * - * @export - * @interface BuiltinModule - */ -export interface BuiltinModule { - /** - * - * @type {string} - * @memberof BuiltinModule - */ - name: string; - /** - * - * @type {string} - * @memberof BuiltinModule - */ - version: string; - /** - * - * @type {string} - * @memberof BuiltinModule - */ - description: string; - /** - * - * @type {string} - * @memberof BuiltinModule - */ - configSchema: string; - /** - * - * @type {string} - * @memberof BuiltinModule - */ - uiSchema: string; - /** - * - * @type {Array} - * @memberof BuiltinModule - */ - commands: Array; - /** - * - * @type {Array} - * @memberof BuiltinModule - */ - hooks: Array; - /** - * - * @type {Array} - * @memberof BuiltinModule - */ - cronJobs: Array; - /** - * - * @type {Array} - * @memberof BuiltinModule - */ - functions: Array; - /** - * - * @type {Array} - * @memberof BuiltinModule - */ - permissions: Array; -} /** * * @export @@ -5383,10 +5316,10 @@ export interface ModuleCreateVersionInputDTO { export interface ModuleExportDTOAPI { /** * - * @type {BuiltinModule} + * @type {ModuleTransferDTO} * @memberof ModuleExportDTOAPI */ - data: BuiltinModule; + data: ModuleTransferDTO; /** * * @type {MetadataOutput} @@ -5394,19 +5327,6 @@ export interface ModuleExportDTOAPI { */ meta: MetadataOutput; } -/** - * - * @export - * @interface ModuleExportInputDTO - */ -export interface ModuleExportInputDTO { - /** - * - * @type {string} - * @memberof ModuleExportInputDTO - */ - versionId: string; -} /** * * @export @@ -5795,6 +5715,86 @@ export const ModuleSearchInputDTOSortDirectionEnum = { export type ModuleSearchInputDTOSortDirectionEnum = (typeof ModuleSearchInputDTOSortDirectionEnum)[keyof typeof ModuleSearchInputDTOSortDirectionEnum]; +/** + * + * @export + * @interface ModuleTransferDTO + */ +export interface ModuleTransferDTO { + /** + * + * @type {string} + * @memberof ModuleTransferDTO + */ + name: string; + /** + * + * @type {Array} + * @memberof ModuleTransferDTO + */ + versions: Array; +} +/** + * + * @export + * @interface ModuleTransferVersionDTO + */ +export interface ModuleTransferVersionDTO { + /** + * + * @type {string} + * @memberof ModuleTransferVersionDTO + */ + tag: string; + /** + * + * @type {string} + * @memberof ModuleTransferVersionDTO + */ + description: string; + /** + * + * @type {string} + * @memberof ModuleTransferVersionDTO + */ + configSchema: string; + /** + * + * @type {string} + * @memberof ModuleTransferVersionDTO + */ + uiSchema: string; + /** + * + * @type {Array} + * @memberof ModuleTransferVersionDTO + */ + commands?: Array; + /** + * + * @type {Array} + * @memberof ModuleTransferVersionDTO + */ + hooks?: Array; + /** + * + * @type {Array} + * @memberof ModuleTransferVersionDTO + */ + cronJobs?: Array; + /** + * + * @type {Array} + * @memberof ModuleTransferVersionDTO + */ + functions?: Array; + /** + * + * @type {Array} + * @memberof ModuleTransferVersionDTO + */ + permissions?: Array; +} /** * * @export @@ -17562,6 +17562,39 @@ export const ModuleApiAxiosParamCreator = function (configuration?: Configuratio options: localVarRequestOptions, }; }, + /** + * Exports a module to a format that can be imported into another Takaro instance. This endpoint will export all known versions of the module Required permissions: `READ_MODULES` + * @summary Export a module + * @param {string} id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + moduleControllerExport: async (id: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('moduleControllerExport', 'id', id); + const localVarPath = `/module/{id}/export`.replace(`{${'id'}}`, encodeURIComponent(String(id))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options }; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication domainAuth required + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, /** * Required permissions: `READ_MODULES` * @summary Get one module @@ -17595,6 +17628,43 @@ export const ModuleApiAxiosParamCreator = function (configuration?: Configuratio options: localVarRequestOptions, }; }, + /** + * Imports a module from a format that was exported from another Takaro instance Required permissions: `MANAGE_MODULES` + * @summary Import a module version + * @param {ModuleTransferDTO} [moduleTransferDTO] ModuleTransferDTO + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + moduleControllerImport: async ( + moduleTransferDTO?: ModuleTransferDTO, + options: RawAxiosRequestConfig = {}, + ): Promise => { + const localVarPath = `/module/import`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options }; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication domainAuth required + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers }; + localVarRequestOptions.data = serializeDataIfNeeded(moduleTransferDTO, localVarRequestOptions, configuration); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, /** * Removes a module, including all versions and config Required permissions: `MANAGE_MODULES` * @summary Remove a module @@ -17856,43 +17926,6 @@ export const ModuleApiAxiosParamCreator = function (configuration?: Configuratio options: localVarRequestOptions, }; }, - /** - * Exports a module to a format that can be imported into another Takaro instance Required permissions: `READ_MODULES` - * @summary Export a module version - * @param {ModuleExportInputDTO} [moduleExportInputDTO] ModuleExportInputDTO - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - moduleVersionControllerExport: async ( - moduleExportInputDTO?: ModuleExportInputDTO, - options: RawAxiosRequestConfig = {}, - ): Promise => { - const localVarPath = `/module/version/export`; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options }; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication domainAuth required - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers }; - localVarRequestOptions.data = serializeDataIfNeeded(moduleExportInputDTO, localVarRequestOptions, configuration); - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, /** * Required permissions: `READ_MODULES` * @summary Get one version @@ -17929,43 +17962,6 @@ export const ModuleApiAxiosParamCreator = function (configuration?: Configuratio options: localVarRequestOptions, }; }, - /** - * Imports a module from a format that was exported from another Takaro instance Required permissions: `MANAGE_MODULES` - * @summary Import a module version - * @param {BuiltinModule} [builtinModule] BuiltinModule - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - moduleVersionControllerImport: async ( - builtinModule?: BuiltinModule, - options: RawAxiosRequestConfig = {}, - ): Promise => { - const localVarPath = `/module/version/import`; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options }; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication domainAuth required - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers }; - localVarRequestOptions.data = serializeDataIfNeeded(builtinModule, localVarRequestOptions, configuration); - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, /** * Required permissions: `READ_MODULES` * @summary Search module versions @@ -18081,6 +18077,29 @@ export const ModuleApiFp = function (configuration?: Configuration) { configuration, )(axios, localVarOperationServerBasePath || basePath); }, + /** + * Exports a module to a format that can be imported into another Takaro instance. This endpoint will export all known versions of the module Required permissions: `READ_MODULES` + * @summary Export a module + * @param {string} id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async moduleControllerExport( + id: string, + options?: RawAxiosRequestConfig, + ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.moduleControllerExport(id, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = + operationServerMap['ModuleApi.moduleControllerExport']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => + createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration, + )(axios, localVarOperationServerBasePath || basePath); + }, /** * Required permissions: `READ_MODULES` * @summary Get one module @@ -18104,6 +18123,29 @@ export const ModuleApiFp = function (configuration?: Configuration) { configuration, )(axios, localVarOperationServerBasePath || basePath); }, + /** + * Imports a module from a format that was exported from another Takaro instance Required permissions: `MANAGE_MODULES` + * @summary Import a module version + * @param {ModuleTransferDTO} [moduleTransferDTO] ModuleTransferDTO + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async moduleControllerImport( + moduleTransferDTO?: ModuleTransferDTO, + options?: RawAxiosRequestConfig, + ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.moduleControllerImport(moduleTransferDTO, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = + operationServerMap['ModuleApi.moduleControllerImport']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => + createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration, + )(axios, localVarOperationServerBasePath || basePath); + }, /** * Removes a module, including all versions and config Required permissions: `MANAGE_MODULES` * @summary Remove a module @@ -18283,32 +18325,6 @@ export const ModuleApiFp = function (configuration?: Configuration) { configuration, )(axios, localVarOperationServerBasePath || basePath); }, - /** - * Exports a module to a format that can be imported into another Takaro instance Required permissions: `READ_MODULES` - * @summary Export a module version - * @param {ModuleExportInputDTO} [moduleExportInputDTO] ModuleExportInputDTO - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async moduleVersionControllerExport( - moduleExportInputDTO?: ModuleExportInputDTO, - options?: RawAxiosRequestConfig, - ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.moduleVersionControllerExport( - moduleExportInputDTO, - options, - ); - const localVarOperationServerIndex = configuration?.serverIndex ?? 0; - const localVarOperationServerBasePath = - operationServerMap['ModuleApi.moduleVersionControllerExport']?.[localVarOperationServerIndex]?.url; - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, localVarOperationServerBasePath || basePath); - }, /** * Required permissions: `READ_MODULES` * @summary Get one version @@ -18332,29 +18348,6 @@ export const ModuleApiFp = function (configuration?: Configuration) { configuration, )(axios, localVarOperationServerBasePath || basePath); }, - /** - * Imports a module from a format that was exported from another Takaro instance Required permissions: `MANAGE_MODULES` - * @summary Import a module version - * @param {BuiltinModule} [builtinModule] BuiltinModule - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async moduleVersionControllerImport( - builtinModule?: BuiltinModule, - options?: RawAxiosRequestConfig, - ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.moduleVersionControllerImport(builtinModule, options); - const localVarOperationServerIndex = configuration?.serverIndex ?? 0; - const localVarOperationServerBasePath = - operationServerMap['ModuleApi.moduleVersionControllerImport']?.[localVarOperationServerIndex]?.url; - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, localVarOperationServerBasePath || basePath); - }, /** * Required permissions: `READ_MODULES` * @summary Search module versions @@ -18430,6 +18423,16 @@ export const ModuleApiFactory = function (configuration?: Configuration, basePat ): AxiosPromise { return localVarFp.moduleControllerCreate(moduleCreateAPIDTO, options).then((request) => request(axios, basePath)); }, + /** + * Exports a module to a format that can be imported into another Takaro instance. This endpoint will export all known versions of the module Required permissions: `READ_MODULES` + * @summary Export a module + * @param {string} id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + moduleControllerExport(id: string, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.moduleControllerExport(id, options).then((request) => request(axios, basePath)); + }, /** * Required permissions: `READ_MODULES` * @summary Get one module @@ -18440,6 +18443,16 @@ export const ModuleApiFactory = function (configuration?: Configuration, basePat moduleControllerGetOne(id: string, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.moduleControllerGetOne(id, options).then((request) => request(axios, basePath)); }, + /** + * Imports a module from a format that was exported from another Takaro instance Required permissions: `MANAGE_MODULES` + * @summary Import a module version + * @param {ModuleTransferDTO} [moduleTransferDTO] ModuleTransferDTO + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + moduleControllerImport(moduleTransferDTO?: ModuleTransferDTO, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.moduleControllerImport(moduleTransferDTO, options).then((request) => request(axios, basePath)); + }, /** * Removes a module, including all versions and config Required permissions: `MANAGE_MODULES` * @summary Remove a module @@ -18542,21 +18555,6 @@ export const ModuleApiFactory = function (configuration?: Configuration, basePat .moduleInstallationsControllerUninstallModule(id, options) .then((request) => request(axios, basePath)); }, - /** - * Exports a module to a format that can be imported into another Takaro instance Required permissions: `READ_MODULES` - * @summary Export a module version - * @param {ModuleExportInputDTO} [moduleExportInputDTO] ModuleExportInputDTO - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - moduleVersionControllerExport( - moduleExportInputDTO?: ModuleExportInputDTO, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .moduleVersionControllerExport(moduleExportInputDTO, options) - .then((request) => request(axios, basePath)); - }, /** * Required permissions: `READ_MODULES` * @summary Get one version @@ -18572,18 +18570,6 @@ export const ModuleApiFactory = function (configuration?: Configuration, basePat .moduleVersionControllerGetModuleVersion(id, options) .then((request) => request(axios, basePath)); }, - /** - * Imports a module from a format that was exported from another Takaro instance Required permissions: `MANAGE_MODULES` - * @summary Import a module version - * @param {BuiltinModule} [builtinModule] BuiltinModule - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - moduleVersionControllerImport(builtinModule?: BuiltinModule, options?: RawAxiosRequestConfig): AxiosPromise { - return localVarFp - .moduleVersionControllerImport(builtinModule, options) - .then((request) => request(axios, basePath)); - }, /** * Required permissions: `READ_MODULES` * @summary Search module versions @@ -18638,6 +18624,20 @@ export class ModuleApi extends BaseAPI { .then((request) => request(this.axios, this.basePath)); } + /** + * Exports a module to a format that can be imported into another Takaro instance. This endpoint will export all known versions of the module Required permissions: `READ_MODULES` + * @summary Export a module + * @param {string} id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ModuleApi + */ + public moduleControllerExport(id: string, options?: RawAxiosRequestConfig) { + return ModuleApiFp(this.configuration) + .moduleControllerExport(id, options) + .then((request) => request(this.axios, this.basePath)); + } + /** * Required permissions: `READ_MODULES` * @summary Get one module @@ -18652,6 +18652,20 @@ export class ModuleApi extends BaseAPI { .then((request) => request(this.axios, this.basePath)); } + /** + * Imports a module from a format that was exported from another Takaro instance Required permissions: `MANAGE_MODULES` + * @summary Import a module version + * @param {ModuleTransferDTO} [moduleTransferDTO] ModuleTransferDTO + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ModuleApi + */ + public moduleControllerImport(moduleTransferDTO?: ModuleTransferDTO, options?: RawAxiosRequestConfig) { + return ModuleApiFp(this.configuration) + .moduleControllerImport(moduleTransferDTO, options) + .then((request) => request(this.axios, this.basePath)); + } + /** * Removes a module, including all versions and config Required permissions: `MANAGE_MODULES` * @summary Remove a module @@ -18757,20 +18771,6 @@ export class ModuleApi extends BaseAPI { .then((request) => request(this.axios, this.basePath)); } - /** - * Exports a module to a format that can be imported into another Takaro instance Required permissions: `READ_MODULES` - * @summary Export a module version - * @param {ModuleExportInputDTO} [moduleExportInputDTO] ModuleExportInputDTO - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ModuleApi - */ - public moduleVersionControllerExport(moduleExportInputDTO?: ModuleExportInputDTO, options?: RawAxiosRequestConfig) { - return ModuleApiFp(this.configuration) - .moduleVersionControllerExport(moduleExportInputDTO, options) - .then((request) => request(this.axios, this.basePath)); - } - /** * Required permissions: `READ_MODULES` * @summary Get one version @@ -18785,20 +18785,6 @@ export class ModuleApi extends BaseAPI { .then((request) => request(this.axios, this.basePath)); } - /** - * Imports a module from a format that was exported from another Takaro instance Required permissions: `MANAGE_MODULES` - * @summary Import a module version - * @param {BuiltinModule} [builtinModule] BuiltinModule - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ModuleApi - */ - public moduleVersionControllerImport(builtinModule?: BuiltinModule, options?: RawAxiosRequestConfig) { - return ModuleApiFp(this.configuration) - .moduleVersionControllerImport(builtinModule, options) - .then((request) => request(this.axios, this.basePath)); - } - /** * Required permissions: `READ_MODULES` * @summary Search module versions diff --git a/packages/lib-modules/src/BuiltinModule.ts b/packages/lib-modules/src/BuiltinModule.ts index 1404332b72..f56c899ad8 100644 --- a/packages/lib-modules/src/BuiltinModule.ts +++ b/packages/lib-modules/src/BuiltinModule.ts @@ -77,49 +77,45 @@ export class IPermission extends TakaroDTO { canHaveCount?: boolean; } -export class BuiltinModule extends TakaroDTO { - constructor( - name: string, - description: string, - version: string, - configSchema: string, - uiSchema: string = JSON.stringify({}), - ) { - super(); - this.name = name; - this.description = description; - this.version = version; - this.configSchema = configSchema; - this.uiSchema = uiSchema; - } - - @IsString() - public name: string; +export class ModuleTransferVersionDTO extends TakaroDTO { @IsString() - public version: string; + public tag: string; @IsString() public description: string; @IsString() public configSchema: string; @IsString() public uiSchema: string; - @ValidateNested({ each: true }) @Type(() => ICommand) - public commands: Array = []; + @IsOptional() + public commands?: Array; @ValidateNested({ each: true }) @Type(() => IHook) - public hooks: Array = []; + @IsOptional() + public hooks?: Array; @ValidateNested({ each: true }) @Type(() => ICronJob) - public cronJobs: Array = []; + @IsOptional() + public cronJobs?: Array; @ValidateNested({ each: true }) @Type(() => IFunction) - public functions: Array = []; + @IsOptional() + public functions?: Array; @IsArray() @Type(() => IPermission) @ValidateNested({ each: true }) - public permissions: IPermission[] = []; + @IsOptional() + public permissions?: IPermission[]; +} + +export class ModuleTransferDTO extends TakaroDTO { + @IsString() + public name: string; + + @ValidateNested({ each: true }) + @Type(() => ModuleTransferVersionDTO) + versions: ModuleTransferVersionDTO[]; protected loadFn(type: 'commands' | 'hooks' | 'cronJobs' | 'functions', name: string) { const folderPath = path.join(__dirname, 'modules', this.name, type); diff --git a/packages/lib-modules/src/main.ts b/packages/lib-modules/src/main.ts index e2d76231f2..3d646297f9 100644 --- a/packages/lib-modules/src/main.ts +++ b/packages/lib-modules/src/main.ts @@ -1,4 +1,4 @@ -import { BuiltinModule } from './BuiltinModule.js'; +import { ModuleTransferDTO } from './BuiltinModule.js'; import { ChatBridge } from './modules/chatBridge/index.js'; import { DailyRewards } from './modules/dailyRewards/index.js'; import { EconomyUtils } from './modules/economyUtils/index.js'; @@ -12,12 +12,20 @@ import { Teleports } from './modules/teleports/index.js'; import { TimedShutdown } from './modules/timedShutdown/index.js'; import { Utils } from './modules/utils/index.js'; -export { BuiltinModule, ICommand, ICommandArgument, ICronJob, IHook, IFunction } from './BuiltinModule.js'; +export { + ModuleTransferDTO, + ModuleTransferVersionDTO, + ICommand, + ICommandArgument, + ICronJob, + IHook, + IFunction, +} from './BuiltinModule.js'; export * from './dto/index.js'; -let cached: Array> | null = null; +let cached: Array> | null = null; -export function getModules(): Array> { +export function getModules(): Array> { if (!cached) { cached = [ new Utils(), diff --git a/packages/lib-modules/src/modules/chatBridge/index.ts b/packages/lib-modules/src/modules/chatBridge/index.ts index 51b5a65496..224554bb98 100644 --- a/packages/lib-modules/src/modules/chatBridge/index.ts +++ b/packages/lib-modules/src/modules/chatBridge/index.ts @@ -1,59 +1,61 @@ -import { BuiltinModule, IHook } from '../../BuiltinModule.js'; +import { ModuleTransferDTO, IHook, ModuleTransferVersionDTO } from '../../BuiltinModule.js'; import { HookEvents } from '../../dto/index.js'; -export class ChatBridge extends BuiltinModule { +export class ChatBridge extends ModuleTransferDTO { constructor() { - super( - 'chatBridge', - 'Connect chat to other services like Discord.', - '0.0.1', - JSON.stringify({ - $schema: 'http://json-schema.org/draft-07/schema#', - type: 'object', - properties: { - sendPlayerConnected: { - title: 'Send player connected', - type: 'boolean', - description: 'Send a message when a player connects.', - default: true, + super(); + this.name = 'chatBridge'; + this.versions = [ + new ModuleTransferVersionDTO({ + tag: '0.0.1', + description: 'Connect chat to other services like Discord.', + configSchema: JSON.stringify({ + $schema: 'http://json-schema.org/draft-07/schema#', + type: 'object', + properties: { + sendPlayerConnected: { + title: 'Send player connected', + type: 'boolean', + description: 'Send a message when a player connects.', + default: true, + }, + sendPlayerDisconnected: { + title: 'Send player disconnected', + type: 'boolean', + description: 'Send a message when a player disconnects.', + default: true, + }, + onlyGlobalChat: { + title: 'Only global chat', + type: 'boolean', + default: true, + description: 'Only relay messages from global chat. (no team chat or private messages)', + }, }, - sendPlayerDisconnected: { - title: 'Send player disconnected', - type: 'boolean', - description: 'Send a message when a player disconnects.', - default: true, - }, - onlyGlobalChat: { - title: 'Only global chat', - type: 'boolean', - default: true, - description: 'Only relay messages from global chat. (no team chat or private messages)', - }, - }, - additionalProperties: false, - }), - ); - - this.hooks = [ - new IHook({ - eventType: HookEvents.DISCORD_MESSAGE, - name: 'DiscordToGame', - function: this.loadFn('hooks', 'DiscordToGame'), - }), - new IHook({ - eventType: HookEvents.CHAT_MESSAGE, - name: 'GameToDiscord', - function: this.loadFn('hooks', 'GameToDiscord'), - }), - new IHook({ - eventType: HookEvents.PLAYER_CONNECTED, - name: 'PlayerConnected', - function: this.loadFn('hooks', 'PlayerConnected'), - }), - new IHook({ - eventType: HookEvents.PLAYER_DISCONNECTED, - name: 'PlayerDisconnected', - function: this.loadFn('hooks', 'PlayerDisconnected'), + additionalProperties: false, + }), + hooks: [ + new IHook({ + eventType: HookEvents.DISCORD_MESSAGE, + name: 'DiscordToGame', + function: this.loadFn('hooks', 'DiscordToGame'), + }), + new IHook({ + eventType: HookEvents.CHAT_MESSAGE, + name: 'GameToDiscord', + function: this.loadFn('hooks', 'GameToDiscord'), + }), + new IHook({ + eventType: HookEvents.PLAYER_CONNECTED, + name: 'PlayerConnected', + function: this.loadFn('hooks', 'PlayerConnected'), + }), + new IHook({ + eventType: HookEvents.PLAYER_DISCONNECTED, + name: 'PlayerDisconnected', + function: this.loadFn('hooks', 'PlayerDisconnected'), + }), + ], }), ]; } diff --git a/packages/lib-modules/src/modules/dailyRewards/index.ts b/packages/lib-modules/src/modules/dailyRewards/index.ts index b8d585a9f8..6b662f7e1b 100644 --- a/packages/lib-modules/src/modules/dailyRewards/index.ts +++ b/packages/lib-modules/src/modules/dailyRewards/index.ts @@ -1,126 +1,135 @@ /* eslint-disable quotes */ -import { BuiltinModule, ICommand, IFunction, IHook, IPermission } from '../../BuiltinModule.js'; +import { + ModuleTransferDTO, + ICommand, + IFunction, + IHook, + IPermission, + ModuleTransferVersionDTO, +} from '../../BuiltinModule.js'; -export class DailyRewards extends BuiltinModule { +export class DailyRewards extends ModuleTransferDTO { constructor() { - super( - 'dailyRewards', - 'Provides daily login rewards with streak tracking', - '0.0.1', - JSON.stringify({ - $schema: 'http://json-schema.org/draft-07/schema#', - type: 'object', - properties: { - baseReward: { - type: 'number', - title: 'Base Reward', - description: 'Base amount of currency given for daily rewards. This is multiplied by streak level.', - default: 100, - minimum: 1, - }, - maxStreak: { - type: 'number', - title: 'Maximum Streak', - description: 'Maximum streak level a player can reach', - default: 365, - minimum: 1, - }, - milestoneRewards: { - type: 'array', - title: 'Milestone Rewards', - description: 'Additional rewards for reaching certain streak milestones', - items: { - type: 'object', - properties: { - days: { - type: 'number', - description: 'Days needed to reach milestone', - minimum: 1, - }, - reward: { - type: 'number', - description: 'Bonus reward amount', - }, - message: { - type: 'string', - description: 'Message to show when milestone is reached', + super(); + this.name = 'dailyRewards'; + this.versions = [ + new ModuleTransferVersionDTO({ + description: 'Provides daily login rewards with streak tracking', + tag: '0.0.1', + configSchema: JSON.stringify({ + $schema: 'http://json-schema.org/draft-07/schema#', + type: 'object', + properties: { + baseReward: { + type: 'number', + title: 'Base Reward', + description: 'Base amount of currency given for daily rewards. This is multiplied by streak level.', + default: 100, + minimum: 1, + }, + maxStreak: { + type: 'number', + title: 'Maximum Streak', + description: 'Maximum streak level a player can reach', + default: 365, + minimum: 1, + }, + milestoneRewards: { + type: 'array', + title: 'Milestone Rewards', + description: 'Additional rewards for reaching certain streak milestones', + items: { + type: 'object', + properties: { + days: { + type: 'number', + description: 'Days needed to reach milestone', + minimum: 1, + }, + reward: { + type: 'number', + description: 'Bonus reward amount', + }, + message: { + type: 'string', + description: 'Message to show when milestone is reached', + }, }, }, + default: [ + { days: 7, reward: 1000, message: 'You did it! 7 days in a row!' }, + { days: 30, reward: 5000, message: "A whole month! You're on fire!" }, + { days: 90, reward: 20000, message: "90 days! You're unstoppable!" }, + { days: 180, reward: 50000, message: "Half a year! You're a legend!" }, + { days: 365, reward: 150000, message: "365 days! You're a true champion!" }, + ], }, - default: [ - { days: 7, reward: 1000, message: 'You did it! 7 days in a row!' }, - { days: 30, reward: 5000, message: "A whole month! You're on fire!" }, - { days: 90, reward: 20000, message: "90 days! You're unstoppable!" }, - { days: 180, reward: 50000, message: "Half a year! You're a legend!" }, - { days: 365, reward: 150000, message: "365 days! You're a true champion!" }, - ], }, - }, - required: ['baseReward', 'maxStreak', 'milestoneRewards'], - additionalProperties: false, - }), - ); - - this.functions = [ - new IFunction({ - name: 'utils', - function: this.loadFn('functions', 'utils'), - }), - ]; + required: ['baseReward', 'maxStreak', 'milestoneRewards'], + additionalProperties: false, + }), + functions: [ + new IFunction({ + name: 'utils', + function: this.loadFn('functions', 'utils'), + }), + ], - this.permissions = [ - new IPermission({ - permission: 'DAILY_CLAIM', - friendlyName: 'Claim Daily Rewards', - description: 'Allows the player to claim daily rewards', - canHaveCount: false, - }), - new IPermission({ - permission: 'DAILY_REWARD_MULTIPLIER', - friendlyName: 'Multiplier', - description: - 'Control the multiplier per role. This is useful to give your donors a little extra. Count is an integer multiplier.', - canHaveCount: true, - }), - ]; + permissions: [ + new IPermission({ + permission: 'DAILY_CLAIM', + friendlyName: 'Claim Daily Rewards', + description: 'Allows the player to claim daily rewards', + canHaveCount: false, + }), + new IPermission({ + permission: 'DAILY_REWARD_MULTIPLIER', + friendlyName: 'Multiplier', + description: + 'Control the multiplier per role. This is useful to give your donors a little extra. Count is an integer multiplier.', + canHaveCount: true, + }), + ], - this.commands = [ - new ICommand({ - function: this.loadFn('commands', 'daily'), - name: 'daily', - trigger: 'daily', - helpText: 'Claim your daily reward', - arguments: [], - }), - new ICommand({ - function: this.loadFn('commands', 'streak'), - name: 'streak', - trigger: 'streak', - helpText: 'Check your current daily reward streak and next claim time', - arguments: [], - }), - new ICommand({ - function: this.loadFn('commands', 'topstreak'), - name: 'topstreak', - trigger: 'topstreak', - helpText: 'Shows the players with highest daily reward streaks', - arguments: [ - { - name: 'count', - type: 'number', - defaultValue: '5', - helpText: 'Number of players to show (max 25)', - position: 0, - }, + commands: [ + new ICommand({ + function: this.loadFn('commands', 'daily'), + name: 'daily', + trigger: 'daily', + helpText: 'Claim your daily reward', + arguments: [], + }), + new ICommand({ + function: this.loadFn('commands', 'streak'), + name: 'streak', + trigger: 'streak', + helpText: 'Check your current daily reward streak and next claim time', + arguments: [], + }), + new ICommand({ + function: this.loadFn('commands', 'topstreak'), + name: 'topstreak', + trigger: 'topstreak', + helpText: 'Shows the players with highest daily reward streaks', + arguments: [ + { + name: 'count', + type: 'number', + defaultValue: '5', + helpText: 'Number of players to show (max 25)', + position: 0, + }, + ], + }), ], - }), - ]; - this.hooks = [ - new IHook({ - eventType: 'player-connected', - name: 'dailyLoginCheck', - function: this.loadFn('hooks', 'dailyLoginCheck'), + hooks: [ + new IHook({ + eventType: 'player-connected', + name: 'dailyLoginCheck', + function: this.loadFn('hooks', 'dailyLoginCheck'), + }), + ], }), ]; } diff --git a/packages/lib-modules/src/modules/economyUtils/index.ts b/packages/lib-modules/src/modules/economyUtils/index.ts index ef404090f7..b447bc28e7 100644 --- a/packages/lib-modules/src/modules/economyUtils/index.ts +++ b/packages/lib-modules/src/modules/economyUtils/index.ts @@ -1,189 +1,191 @@ -import { BuiltinModule, ICommand, ICronJob, IPermission } from '../../BuiltinModule.js'; +import { ModuleTransferDTO, ICommand, ICronJob, IPermission, ModuleTransferVersionDTO } from '../../BuiltinModule.js'; -export class EconomyUtils extends BuiltinModule { +export class EconomyUtils extends ModuleTransferDTO { constructor() { - super( - 'economyUtils', - 'A set of commands to allow players to manage their currency.', - '0.0.1', - JSON.stringify({ - $schema: 'http://json-schema.org/draft-07/schema#', - type: 'object', - properties: { - pendingAmount: { - title: 'Pending amount', - type: 'number', - description: - 'When a player transfers money, they must confirm the transfer when the amount is equal or above this value. Set to 0 to disable.', - default: 0, - }, - zombieKillReward: { - title: 'Zombie kill reward', - type: 'number', - description: - 'The default amount of currency a player receives for killing a zombie. This can be overridden by roles.', - default: 1, - }, - }, - required: [], - additionalProperties: false, - }), - ); - - this.permissions = [ - new IPermission({ - permission: 'ECONOMY_UTILS_MANAGE_CURRENCY', - friendlyName: 'Manage currency', - description: - 'Allows players to manage currency of other players. This includes granting and revoking currency.', - canHaveCount: false, - }), - new IPermission({ - permission: 'ZOMBIE_KILL_REWARD_OVERRIDE', - friendlyName: 'Zombie kill reward override', - description: 'Allows a role to override the amount of currency a player receives for killing a entity.', - canHaveCount: true, - }), - ]; - - this.cronJobs = [ - new ICronJob({ - function: this.loadFn('cronJobs', 'zombieKillReward'), - name: 'zombieKillReward', - temporalValue: '*/5 * * * *', - }), - ]; + super(); - this.commands = [ - new ICommand({ - function: this.loadFn('commands', 'balance'), - name: 'balance', - trigger: 'balance', - helpText: 'Check your balance.', - arguments: [], - }), - new ICommand({ - function: this.loadFn('commands', 'topCurrency'), - name: 'topCurrency', - trigger: 'topcurrency', - helpText: 'List of the 10 players with the highest balance.', - arguments: [], - }), - new ICommand({ - function: this.loadFn('commands', 'grantCurrency'), - name: 'grantCurrency', - trigger: 'grantcurrency', - helpText: 'Grant money to a player. The money is not taken from your own balance but is new currency.', - arguments: [ - { - name: 'receiver', - type: 'player', - helpText: 'The player to grant currency to.', - position: 0, - defaultValue: null, - }, - { - name: 'amount', - type: 'number', - helpText: 'The amount of money.', - position: 1, - defaultValue: null, - }, - ], - }), - new ICommand({ - function: this.loadFn('commands', 'revokeCurrency'), - name: 'revokeCurrency', - trigger: 'revokecurrency', - helpText: 'Revokes money from a player. The money disappears.', - arguments: [ - { - name: 'receiver', - type: 'player', - helpText: 'The player to revoke currency from.', - position: 0, - defaultValue: null, - }, - { - name: 'amount', - type: 'number', - helpText: 'The amount of money.', - position: 1, - defaultValue: null, - }, - ], - }), - new ICommand({ - function: this.loadFn('commands', 'confirmTransfer'), - name: 'confirmTransfer', - trigger: 'confirmtransfer', - helpText: 'Confirms a pending transfer.', - arguments: [], - }), - new ICommand({ - function: this.loadFn('commands', 'transfer'), - name: 'transfer', - trigger: 'transfer', - helpText: 'Transfer money to another player.', - arguments: [ - { - name: 'receiver', - type: 'player', - helpText: 'The player to transfer money to.', - position: 0, - defaultValue: null, - }, - { - name: 'amount', - type: 'number', - helpText: 'The amount of money to transfer.', - position: 1, - defaultValue: null, + this.name = 'economyUtils'; + this.versions = [ + new ModuleTransferVersionDTO({ + tag: '0.0.1', + description: 'A set of commands to allow players to manage their currency.', + configSchema: JSON.stringify({ + $schema: 'http://json-schema.org/draft-07/schema#', + type: 'object', + properties: { + pendingAmount: { + title: 'Pending amount', + type: 'number', + description: + 'When a player transfers money, they must confirm the transfer when the amount is equal or above this value. Set to 0 to disable.', + default: 0, + }, + zombieKillReward: { + title: 'Zombie kill reward', + type: 'number', + description: + 'The default amount of currency a player receives for killing a zombie. This can be overridden by roles.', + default: 1, + }, }, + required: [], + additionalProperties: false, + }), + permissions: [ + new IPermission({ + permission: 'ECONOMY_UTILS_MANAGE_CURRENCY', + friendlyName: 'Manage currency', + description: + 'Allows players to manage currency of other players. This includes granting and revoking currency.', + canHaveCount: false, + }), + new IPermission({ + permission: 'ZOMBIE_KILL_REWARD_OVERRIDE', + friendlyName: 'Zombie kill reward override', + description: 'Allows a role to override the amount of currency a player receives for killing a entity.', + canHaveCount: true, + }), ], - }), - new ICommand({ - function: this.loadFn('commands', 'claim'), - name: 'claim', - trigger: 'claim', - helpText: 'Claim your pending shop orders.', - arguments: [ - { - name: 'all', - type: 'boolean', - helpText: 'If true, claim ALL pending orders. If false, claim only the first one.', - position: 0, - defaultValue: 'false', - }, + cronJobs: [ + new ICronJob({ + function: this.loadFn('cronJobs', 'zombieKillReward'), + name: 'zombieKillReward', + temporalValue: '*/5 * * * *', + }), ], - }), - new ICommand({ - function: this.loadFn('commands', 'shop'), - name: 'shop', - trigger: 'shop', - helpText: 'Browse the shop and view available items.', - arguments: [ - { - name: 'page', - type: 'number', - helpText: 'Display more items from the shop by specifying a page number.', - position: 0, - defaultValue: '1', - }, - { - name: 'item', - type: 'number', - helpText: 'Select a specific item to view more details.', - position: 1, - defaultValue: '0', - }, - { - name: 'action', - type: 'string', - helpText: 'Perform an action on the selected item. Currently only "buy" is supported.', - position: 2, - defaultValue: 'none', - }, + + commands: [ + new ICommand({ + function: this.loadFn('commands', 'balance'), + name: 'balance', + trigger: 'balance', + helpText: 'Check your balance.', + arguments: [], + }), + new ICommand({ + function: this.loadFn('commands', 'topCurrency'), + name: 'topCurrency', + trigger: 'topcurrency', + helpText: 'List of the 10 players with the highest balance.', + arguments: [], + }), + new ICommand({ + function: this.loadFn('commands', 'grantCurrency'), + name: 'grantCurrency', + trigger: 'grantcurrency', + helpText: 'Grant money to a player. The money is not taken from your own balance but is new currency.', + arguments: [ + { + name: 'receiver', + type: 'player', + helpText: 'The player to grant currency to.', + position: 0, + defaultValue: null, + }, + { + name: 'amount', + type: 'number', + helpText: 'The amount of money.', + position: 1, + defaultValue: null, + }, + ], + }), + new ICommand({ + function: this.loadFn('commands', 'revokeCurrency'), + name: 'revokeCurrency', + trigger: 'revokecurrency', + helpText: 'Revokes money from a player. The money disappears.', + arguments: [ + { + name: 'receiver', + type: 'player', + helpText: 'The player to revoke currency from.', + position: 0, + defaultValue: null, + }, + { + name: 'amount', + type: 'number', + helpText: 'The amount of money.', + position: 1, + defaultValue: null, + }, + ], + }), + new ICommand({ + function: this.loadFn('commands', 'confirmTransfer'), + name: 'confirmTransfer', + trigger: 'confirmtransfer', + helpText: 'Confirms a pending transfer.', + arguments: [], + }), + new ICommand({ + function: this.loadFn('commands', 'transfer'), + name: 'transfer', + trigger: 'transfer', + helpText: 'Transfer money to another player.', + arguments: [ + { + name: 'receiver', + type: 'player', + helpText: 'The player to transfer money to.', + position: 0, + defaultValue: null, + }, + { + name: 'amount', + type: 'number', + helpText: 'The amount of money to transfer.', + position: 1, + defaultValue: null, + }, + ], + }), + new ICommand({ + function: this.loadFn('commands', 'claim'), + name: 'claim', + trigger: 'claim', + helpText: 'Claim your pending shop orders.', + arguments: [ + { + name: 'all', + type: 'boolean', + helpText: 'If true, claim ALL pending orders. If false, claim only the first one.', + position: 0, + defaultValue: 'false', + }, + ], + }), + new ICommand({ + function: this.loadFn('commands', 'shop'), + name: 'shop', + trigger: 'shop', + helpText: 'Browse the shop and view available items.', + arguments: [ + { + name: 'page', + type: 'number', + helpText: 'Display more items from the shop by specifying a page number.', + position: 0, + defaultValue: '1', + }, + { + name: 'item', + type: 'number', + helpText: 'Select a specific item to view more details.', + position: 1, + defaultValue: '0', + }, + { + name: 'action', + type: 'string', + helpText: 'Perform an action on the selected item. Currently only "buy" is supported.', + position: 2, + defaultValue: 'none', + }, + ], + }), ], }), ]; diff --git a/packages/lib-modules/src/modules/geoBlock/index.ts b/packages/lib-modules/src/modules/geoBlock/index.ts index 95de9eb9bc..cac8e94837 100644 --- a/packages/lib-modules/src/modules/geoBlock/index.ts +++ b/packages/lib-modules/src/modules/geoBlock/index.ts @@ -1,4 +1,4 @@ -import { BuiltinModule, IHook, IPermission } from '../../BuiltinModule.js'; +import { ModuleTransferDTO, IHook, IPermission, ModuleTransferVersionDTO } from '../../BuiltinModule.js'; import { HookEvents } from '../../dto/index.js'; import { Duration } from 'luxon'; @@ -252,80 +252,81 @@ export const countryCodes = [ { code: 'ZW', name: 'Zimbabwe' }, ]; -export class GeoBlock extends BuiltinModule { +export class GeoBlock extends ModuleTransferDTO { constructor() { - super( - 'geoBlock', - 'Block players from certain countries from joining the server.', - '0.0.1', - JSON.stringify({ - $schema: 'http://json-schema.org/draft-07/schema#', - type: 'object', - properties: { - mode: { - title: 'Mode', - type: 'string', - description: - 'If set to allow, only players from the specified countries will be allowed to join. If set to deny, players from the specified countries will be banned from the server.', - enum: ['allow', 'deny'], - default: 'deny', - }, - countries: { - title: 'Countries', - description: 'List of countries', - type: 'array', - uniqueItems: true, - 'x-component': 'country', - items: { + super(); + + this.name = 'geoBlock'; + this.versions = [ + new ModuleTransferVersionDTO({ + tag: '0.0.1', + description: 'Block players from certain countries from joining the server.', + configSchema: JSON.stringify({ + $schema: 'http://json-schema.org/draft-07/schema#', + type: 'object', + properties: { + mode: { + title: 'Mode', type: 'string', - anyOf: countryCodes.map(({ code, name }) => ({ const: code, title: name })), + description: + 'If set to allow, only players from the specified countries will be allowed to join. If set to deny, players from the specified countries will be banned from the server.', + enum: ['allow', 'deny'], + default: 'deny', + }, + countries: { + title: 'Countries', + description: 'List of countries', + type: 'array', + uniqueItems: true, + 'x-component': 'country', + items: { + type: 'string', + anyOf: countryCodes.map(({ code, name }) => ({ const: code, title: name })), + }, + }, + ban: { + title: 'Ban', + description: + 'Ban players from the server when they are detected. When false, players will be kicked instead.', + type: 'boolean', + default: true, + }, + banDuration: { + title: 'Ban duration', + description: 'Duration of the ban.', + 'x-component': 'duration', + type: 'number', + minimum: 0, + default: Duration.fromObject({ days: 1 }).as('milliseconds'), + }, + message: { + title: 'Message', + type: 'string', + description: 'Message to send to the player when they are kicked or banned.', + default: 'Your IP address is banned.', }, }, - ban: { - title: 'Ban', - description: - 'Ban players from the server when they are detected. When false, players will be kicked instead.', - type: 'boolean', - default: true, - }, - banDuration: { - title: 'Ban duration', - description: 'Duration of the ban.', - 'x-component': 'duration', - type: 'number', - minimum: 0, - default: Duration.fromObject({ days: 1 }).as('milliseconds'), - }, - message: { - title: 'Message', - type: 'string', - description: 'Message to send to the player when they are kicked or banned.', - default: 'Your IP address is banned.', - }, - }, - required: ['countries'], - additionalProperties: false, - }), - JSON.stringify({ - banDuration: { 'ui:widget': 'duration' }, - }), - ); - - this.permissions = [ - new IPermission({ - permission: 'GEOBLOCK_IMMUNITY', - friendlyName: 'GeoBlock immunity', - description: 'Players with this permission will not be kicked or banned by GeoBlock.', - canHaveCount: false, - }), - ]; - - this.commands = []; - this.hooks = [ - new IHook({ - eventType: HookEvents.PLAYER_NEW_IP_DETECTED, - name: 'IPDetected', - function: this.loadFn('hooks', 'IPDetected'), + required: ['countries'], + additionalProperties: false, + }), + uiSchema: JSON.stringify({ + banDuration: { 'ui:widget': 'duration' }, + }), + permissions: [ + new IPermission({ + permission: 'GEOBLOCK_IMMUNITY', + friendlyName: 'GeoBlock immunity', + description: 'Players with this permission will not be kicked or banned by GeoBlock.', + canHaveCount: false, + }), + ], + hooks: [ + new IHook({ + eventType: HookEvents.PLAYER_NEW_IP_DETECTED, + name: 'IPDetected', + function: this.loadFn('hooks', 'IPDetected'), + }), + ], }), ]; } diff --git a/packages/lib-modules/src/modules/gimme/index.ts b/packages/lib-modules/src/modules/gimme/index.ts index 24cdd079ec..f09026dad8 100644 --- a/packages/lib-modules/src/modules/gimme/index.ts +++ b/packages/lib-modules/src/modules/gimme/index.ts @@ -1,70 +1,73 @@ -import { BuiltinModule, ICommand } from '../../BuiltinModule.js'; +import { ModuleTransferDTO, ICommand, ModuleTransferVersionDTO } from '../../BuiltinModule.js'; -export class Gimme extends BuiltinModule { +export class Gimme extends ModuleTransferDTO { constructor() { - super( - 'gimme', - 'Randomly selects an item from a list of items.', - '0.0.1', - JSON.stringify({ - $schema: 'http://json-schema.org/draft-07/schema#', - type: 'object', - properties: { - items: { - 'x-component': 'item', - type: 'array', - title: 'Items', - description: 'List of items that a player can receive.', - uniqueItems: true, + super(); + + this.name = 'gimme'; + this.versions = [ + new ModuleTransferVersionDTO({ + tag: '0.0.1', + description: 'Randomly selects item from a list of items and entities.', + configSchema: JSON.stringify({ + $schema: 'http://json-schema.org/draft-07/schema#', + type: 'object', + properties: { items: { - type: 'object', - title: 'Item', - properties: { - item: { - type: 'string', - title: 'Item', - }, - amount: { - type: 'number', - title: 'Amount', - }, - quality: { - type: 'string', - title: 'Quality', + 'x-component': 'item', + type: 'array', + title: 'Items', + description: 'List of items that a player can receive.', + uniqueItems: true, + items: { + type: 'object', + title: 'Item', + properties: { + item: { + type: 'string', + title: 'Item', + }, + amount: { + type: 'number', + title: 'Amount', + }, + quality: { + type: 'string', + title: 'Quality', + }, }, }, }, - }, - commands: { - title: 'Commands', - type: 'array', - default: ['say hello from gimme'], - items: { - type: 'string', + commands: { + title: 'Commands', + type: 'array', + default: ['say hello from gimme'], + items: { + type: 'string', + }, }, }, - }, - required: ['items'], - additionalProperties: false, - }), - JSON.stringify({ - items: { + required: ['items'], + additionalProperties: false, + }), + uiSchema: JSON.stringify({ items: { - item: { - 'ui:widget': 'item', + items: { + item: { + 'ui:widget': 'item', + }, }, }, - }, - }), - ); - - this.commands = [ - new ICommand({ - function: this.loadFn('commands', 'gimme'), - name: 'gimme', - trigger: 'gimme', - helpText: 'Randomly selects item from a list of items and entities.', - arguments: [], + }), + commands: [ + new ICommand({ + function: this.loadFn('commands', 'gimme'), + name: 'gimme', + trigger: 'gimme', + helpText: 'Randomly selects item from a list of items and entities.', + arguments: [], + }), + ], }), ]; } diff --git a/packages/lib-modules/src/modules/highPingKicker/index.ts b/packages/lib-modules/src/modules/highPingKicker/index.ts index 8c06934427..c5c65fd7a4 100644 --- a/packages/lib-modules/src/modules/highPingKicker/index.ts +++ b/packages/lib-modules/src/modules/highPingKicker/index.ts @@ -1,39 +1,41 @@ -import { BuiltinModule, ICronJob } from '../../BuiltinModule.js'; +import { ModuleTransferDTO, ICronJob, ModuleTransferVersionDTO } from '../../BuiltinModule.js'; -export class HighPingKicker extends BuiltinModule { +export class HighPingKicker extends ModuleTransferDTO { constructor() { - super( - 'highPingKicker', - 'Automatically kick players with high ping, with warnings and configurable thresholds.', - '0.0.1', - JSON.stringify({ - $schema: 'http://json-schema.org/draft-07/schema#', - type: 'object', - properties: { - pingThreshold: { - type: 'number', - title: 'Ping threshold', - description: 'A ping value that is deemed too high and prompts a warning.', - default: 200, - minimum: 0, + super(); + this.name = 'highPingKicker'; + this.versions = [ + new ModuleTransferVersionDTO({ + tag: '0.0.1', + description: 'Automatically kick players with high ping, with warnings and configurable thresholds.', + configSchema: JSON.stringify({ + $schema: 'http://json-schema.org/draft-07/schema#', + type: 'object', + properties: { + pingThreshold: { + type: 'number', + title: 'Ping threshold', + description: 'A ping value that is deemed too high and prompts a warning.', + default: 200, + minimum: 0, + }, + warningsBeforeKick: { + type: 'number', + title: 'Kick warnings', + description: 'Number of warnings before a player is kicked.', + default: 3, + minimum: 0, + }, }, - warningsBeforeKick: { - type: 'number', - title: 'Kick warnings', - description: 'Number of warnings before a player is kicked.', - default: 3, - minimum: 0, - }, - }, - required: [], - }), - ); - - this.cronJobs = [ - new ICronJob({ - name: 'Ping check', - temporalValue: '*/5 * * * *', - function: this.loadFn('cronJobs', 'Ping check'), + required: [], + }), + cronJobs: [ + new ICronJob({ + name: 'Ping check', + temporalValue: '*/5 * * * *', + function: this.loadFn('cronJobs', 'Ping check'), + }), + ], }), ]; } diff --git a/packages/lib-modules/src/modules/lottery/index.ts b/packages/lib-modules/src/modules/lottery/index.ts index 3b5083a8e2..0b461d9361 100644 --- a/packages/lib-modules/src/modules/lottery/index.ts +++ b/packages/lib-modules/src/modules/lottery/index.ts @@ -1,80 +1,81 @@ -import { BuiltinModule, ICommand, ICronJob, IPermission } from '../../BuiltinModule.js'; +import { ModuleTransferDTO, ICommand, ICronJob, IPermission, ModuleTransferVersionDTO } from '../../BuiltinModule.js'; -export class Lottery extends BuiltinModule { +export class Lottery extends ModuleTransferDTO { constructor() { - super( - 'lottery', - 'Players can buy tickets for a lottery, and the winner is chosen at random.', - '0.0.1', - JSON.stringify({ - $schema: 'http://json-schema.org/draft-07/schema#', - type: 'object', - properties: { - profitMargin: { - type: 'number', - maximum: 1, - minimum: 0, - description: 'The profit margin the server takes from the lottery.', - default: 0.1, - }, - }, - required: [], - additionalProperties: false, - }), - ); + super(); - this.permissions = [ - new IPermission({ - permission: 'LOTTERY_BUY', - friendlyName: 'Buy Lottery Tickets', - canHaveCount: false, - description: 'Allows the player to buy lottery tickets.', - }), - new IPermission({ - permission: 'LOTTERY_VIEW_TICKETS', - friendlyName: 'View Lottery Tickets', - description: 'Allows the player to view his lottery tickets.', - canHaveCount: false, - }), - ]; - - this.cronJobs = [ - new ICronJob({ - name: 'drawLottery', - temporalValue: '0 0 * * *', - function: this.loadFn('cronJobs', 'drawLottery'), - }), - ]; - - this.commands = [ - new ICommand({ - function: this.loadFn('commands', 'buyTicket'), - name: 'buyTicket', - trigger: 'buyTicket', - helpText: 'Buy a lottery ticket.', - arguments: [ - { - name: 'amount', - type: 'number', - helpText: 'The amount of tickets to buy.', - position: 0, - defaultValue: null, + this.name = 'lottery'; + this.versions = [ + new ModuleTransferVersionDTO({ + tag: '0.0.1', + description: 'Players can buy tickets for a lottery, and the winner is chosen at random.', + configSchema: JSON.stringify({ + $schema: 'http://json-schema.org/draft-07/schema#', + type: 'object', + properties: { + profitMargin: { + type: 'number', + maximum: 1, + minimum: 0, + description: 'The profit margin the server takes from the lottery.', + default: 0.1, + }, }, + required: [], + additionalProperties: false, + }), + permissions: [ + new IPermission({ + permission: 'LOTTERY_BUY', + friendlyName: 'Buy Lottery Tickets', + canHaveCount: false, + description: 'Allows the player to buy lottery tickets.', + }), + new IPermission({ + permission: 'LOTTERY_VIEW_TICKETS', + friendlyName: 'View Lottery Tickets', + description: 'Allows the player to view his lottery tickets.', + canHaveCount: false, + }), + ], + cronJobs: [ + new ICronJob({ + name: 'drawLottery', + temporalValue: '0 0 * * *', + function: this.loadFn('cronJobs', 'drawLottery'), + }), + ], + commands: [ + new ICommand({ + function: this.loadFn('commands', 'buyTicket'), + name: 'buyTicket', + trigger: 'buyTicket', + helpText: 'Buy a lottery ticket.', + arguments: [ + { + name: 'amount', + type: 'number', + helpText: 'The amount of tickets to buy.', + position: 0, + defaultValue: null, + }, + ], + }), + new ICommand({ + function: this.loadFn('commands', 'viewTickets'), + name: 'viewTickets', + trigger: 'viewTickets', + helpText: 'View your lottery tickets.', + arguments: [], + }), + new ICommand({ + function: this.loadFn('commands', 'nextDraw'), + name: 'nextDraw', + trigger: 'nextDraw', + helpText: 'View when the next draw is.', + arguments: [], + }), ], - }), - new ICommand({ - function: this.loadFn('commands', 'viewTickets'), - name: 'viewTickets', - trigger: 'viewTickets', - helpText: 'View your lottery tickets.', - arguments: [], - }), - new ICommand({ - function: this.loadFn('commands', 'nextDraw'), - name: 'nextDraw', - trigger: 'nextDraw', - helpText: 'View when the next draw is.', - arguments: [], }), ]; } diff --git a/packages/lib-modules/src/modules/playerOnboarding/index.ts b/packages/lib-modules/src/modules/playerOnboarding/index.ts index 30ab436187..bbc732cf9e 100644 --- a/packages/lib-modules/src/modules/playerOnboarding/index.ts +++ b/packages/lib-modules/src/modules/playerOnboarding/index.ts @@ -1,80 +1,83 @@ -import { BuiltinModule, ICommand, IHook } from '../../BuiltinModule.js'; +import { ModuleTransferDTO, ICommand, IHook, ModuleTransferVersionDTO } from '../../BuiltinModule.js'; import { HookEvents } from '../../dto/index.js'; -export class PlayerOnboarding extends BuiltinModule { +export class PlayerOnboarding extends ModuleTransferDTO { constructor() { - super( - 'playerOnboarding', - 'Collection of functions that are executed when a player joins the server. Helps with onboarding new players, like sending a welcome message.', - '0.0.1', - JSON.stringify({ - $schema: 'http://json-schema.org/draft-07/schema#', - type: 'object', - properties: { - message: { - title: 'Message', - description: 'The message to send to the player when they join the server.', - type: 'string', - minLength: 1, - maxLength: 256, - default: 'Welcome {player} to the server!', - }, - starterKitItems: { - type: 'array', - title: 'Starter kit items', - 'x-component': 'item', - description: - 'List of items a player will receive when they execute the starterkit command for the first time.', - uniqueItems: true, - items: { - type: 'object', - title: 'Item', - properties: { - item: { - type: 'string', - title: 'Item', - }, - amount: { - type: 'number', - title: 'Amount', - }, - quality: { - type: 'string', - title: 'Quality', + super(); + + this.name = 'playerOnboarding'; + this.versions = [ + new ModuleTransferVersionDTO({ + tag: '0.0.1', + description: + 'Collection of functions that are executed when a player joins the server. Helps with onboarding new players, like sending a welcome message.', + configSchema: JSON.stringify({ + $schema: 'http://json-schema.org/draft-07/schema#', + type: 'object', + properties: { + message: { + title: 'Message', + description: 'The message to send to the player when they join the server.', + type: 'string', + minLength: 1, + maxLength: 256, + default: 'Welcome {player} to the server!', + }, + starterKitItems: { + type: 'array', + title: 'Starter kit items', + 'x-component': 'item', + description: + 'List of items a player will receive when they execute the starterkit command for the first time.', + uniqueItems: true, + items: { + type: 'object', + title: 'Item', + properties: { + item: { + type: 'string', + title: 'Item', + }, + amount: { + type: 'number', + title: 'Amount', + }, + quality: { + type: 'string', + title: 'Quality', + }, }, }, }, }, - }, - required: [], - additionalProperties: false, - }), - JSON.stringify({ - starterKitItems: { - items: { - item: { - 'ui:widget': 'item', + required: [], + additionalProperties: false, + }), + uiSchema: JSON.stringify({ + starterKitItems: { + items: { + item: { + 'ui:widget': 'item', + }, }, }, - }, - }), - ); - - this.hooks = [ - new IHook({ - eventType: HookEvents.PLAYER_CONNECTED, - name: 'playerConnected', - function: this.loadFn('hooks', 'playerConnected'), - }), - ]; - - this.commands = [ - new ICommand({ - name: 'starterkit', - function: this.loadFn('commands', 'starterkit'), - trigger: 'starterkit', - helpText: 'Get a starter kit, you can only execute this once on a server!', - arguments: [], + }), + hooks: [ + new IHook({ + eventType: HookEvents.PLAYER_CONNECTED, + name: 'playerConnected', + function: this.loadFn('hooks', 'playerConnected'), + }), + ], + commands: [ + new ICommand({ + name: 'starterkit', + function: this.loadFn('commands', 'starterkit'), + trigger: 'starterkit', + helpText: 'Get a starter kit, you can only execute this once on a server!', + arguments: [], + }), + ], }), ]; } diff --git a/packages/lib-modules/src/modules/serverMessages/index.ts b/packages/lib-modules/src/modules/serverMessages/index.ts index e3b548146e..257504c3b5 100644 --- a/packages/lib-modules/src/modules/serverMessages/index.ts +++ b/packages/lib-modules/src/modules/serverMessages/index.ts @@ -1,40 +1,43 @@ -import { BuiltinModule, ICronJob } from '../../BuiltinModule.js'; +import { ModuleTransferDTO, ICronJob, ModuleTransferVersionDTO } from '../../BuiltinModule.js'; -export class ServerMessages extends BuiltinModule { +export class ServerMessages extends ModuleTransferDTO { constructor() { - super( - 'serverMessages', - 'Send automated, rotated, configurable messages to players on the server.', - '0.0.1', - JSON.stringify({ - $schema: 'http://json-schema.org/draft-07/schema#', - type: 'object', - properties: { - messages: { - type: 'array', - title: 'Messages', - description: 'List of messages that will be sent to players on the server.', - default: [ - // prettier-ignore - 'This is an automated message, don\'t forget to read the server rules!', - ], - items: { - type: 'string', - minLength: 5, - maxLength: 1024, + super(); + + this.name = 'serverMessages'; + this.versions = [ + new ModuleTransferVersionDTO({ + tag: '0.0.1', + description: 'Send automated, rotated, configurable messages to players on the server.', + configSchema: JSON.stringify({ + $schema: 'http://json-schema.org/draft-07/schema#', + type: 'object', + properties: { + messages: { + type: 'array', + title: 'Messages', + description: 'List of messages that will be sent to players on the server.', + default: [ + // prettier-ignore + 'This is an automated message, don\'t forget to read the server rules!', + ], + items: { + type: 'string', + minLength: 5, + maxLength: 1024, + }, + minItems: 1, }, - minItems: 1, }, - }, - required: ['messages'], - }), - ); - - this.cronJobs = [ - new ICronJob({ - name: 'Automated message', - temporalValue: '*/30 * * * *', - function: this.loadFn('cronJobs', 'Automated message'), + required: ['messages'], + }), + cronJobs: [ + new ICronJob({ + name: 'Automated message', + temporalValue: '*/30 * * * *', + function: this.loadFn('cronJobs', 'Automated message'), + }), + ], }), ]; } diff --git a/packages/lib-modules/src/modules/teleports/index.ts b/packages/lib-modules/src/modules/teleports/index.ts index f9f9b7a1e2..d87464135d 100644 --- a/packages/lib-modules/src/modules/teleports/index.ts +++ b/packages/lib-modules/src/modules/teleports/index.ts @@ -1,194 +1,195 @@ -import { BuiltinModule, ICommand, IFunction, IPermission } from '../../BuiltinModule.js'; +import { ModuleTransferDTO, ICommand, IFunction, IPermission, ModuleTransferVersionDTO } from '../../BuiltinModule.js'; import { Duration } from 'luxon'; -export class Teleports extends BuiltinModule { +export class Teleports extends ModuleTransferDTO { constructor() { - super( - 'teleports', - 'A set of commands to allow players to set their own teleport points and teleport to them.', - '0.0.1', - JSON.stringify({ - $schema: 'http://json-schema.org/draft-07/schema#', - type: 'object', - properties: { - timeout: { - title: 'Timeout', - description: 'The time one has to wait before teleporting again.', - 'x-component': 'duration', - type: 'number', - minimum: 0, - default: Duration.fromObject({ second: 1 }).as('milliseconds'), - }, - allowPublicTeleports: { - type: 'boolean', - description: 'Players can create public teleports.', - default: false, - }, - }, - required: [], - additionalProperties: false, - }), - JSON.stringify({ - timeout: { 'ui:widget': 'duration' }, - }), - ); - - this.functions = [ - new IFunction({ - name: 'utils', - function: this.loadFn('functions', 'utils'), - }), - ]; - - this.permissions = [ - new IPermission({ - permission: 'TELEPORTS_CREATE_PUBLIC', - friendlyName: 'Create Public Teleports', - description: 'Allows the player to create public teleports.', - canHaveCount: true, - }), - new IPermission({ - permission: 'TELEPORTS_USE', - friendlyName: 'Use Teleports', - description: 'Allows the player to use teleports modules.', - canHaveCount: true, - }), - new IPermission({ - permission: 'TELEPORTS_MANAGE_WAYPOINTS', - friendlyName: 'Manage waypoints', - description: 'Allows creating, deleting, and managing waypoints.', - canHaveCount: false, - }), - ]; + super(); - this.commands = [ - new ICommand({ - function: this.loadFn('commands', 'teleport'), - name: 'teleport', - trigger: 'tp', - helpText: 'Teleports to one of your set locations.', - arguments: [ - { - name: 'tp', - type: 'string', - defaultValue: null, - helpText: 'The location to teleport to.', - position: 0, + this.name = 'teleports'; + this.versions = [ + new ModuleTransferVersionDTO({ + tag: '0.0.1', + description: 'A set of commands to allow players to set their own teleport points and teleport to them.', + configSchema: JSON.stringify({ + $schema: 'http://json-schema.org/draft-07/schema#', + type: 'object', + properties: { + timeout: { + title: 'Timeout', + description: 'The time one has to wait before teleporting again.', + 'x-component': 'duration', + type: 'number', + minimum: 0, + default: Duration.fromObject({ second: 1 }).as('milliseconds'), + }, + allowPublicTeleports: { + type: 'boolean', + description: 'Players can create public teleports.', + default: false, + }, }, + required: [], + additionalProperties: false, + }), + uiSchema: JSON.stringify({ + timeout: { 'ui:widget': 'duration' }, + }), + functions: [ + new IFunction({ + name: 'utils', + function: this.loadFn('functions', 'utils'), + }), ], - }), - new ICommand({ - function: this.loadFn('commands', 'tplist'), - name: 'tplist', - trigger: 'tplist', - helpText: 'Lists all your set locations.', - arguments: [], - }), - new ICommand({ - function: this.loadFn('commands', 'settp'), - name: 'settp', - trigger: 'settp', - helpText: 'Sets a location to teleport to.', - arguments: [ - { - name: 'tp', - type: 'string', - defaultValue: null, - helpText: 'The location name.', - position: 0, - }, + permissions: [ + new IPermission({ + permission: 'TELEPORTS_CREATE_PUBLIC', + friendlyName: 'Create Public Teleports', + description: 'Allows the player to create public teleports.', + canHaveCount: true, + }), + new IPermission({ + permission: 'TELEPORTS_USE', + friendlyName: 'Use Teleports', + description: 'Allows the player to use teleports modules.', + canHaveCount: true, + }), + new IPermission({ + permission: 'TELEPORTS_MANAGE_WAYPOINTS', + friendlyName: 'Manage waypoints', + description: 'Allows creating, deleting, and managing waypoints.', + canHaveCount: false, + }), ], - }), - new ICommand({ - function: this.loadFn('commands', 'deletetp'), - name: 'deletetp', - trigger: 'deletetp', - helpText: 'Deletes a location.', - arguments: [ - { - name: 'tp', - type: 'string', - defaultValue: null, - helpText: 'The location name.', - position: 0, - }, - ], - }), - new ICommand({ - function: this.loadFn('commands', 'setpublic'), - name: 'setpublic', - trigger: 'setpublic', - helpText: 'Sets a teleport to be public, allowing other players to teleport to it.', - arguments: [ - { - name: 'tp', - type: 'string', - defaultValue: null, - helpText: 'The location name.', - position: 0, - }, + commands: [ + new ICommand({ + function: this.loadFn('commands', 'teleport'), + name: 'teleport', + trigger: 'tp', + helpText: 'Teleports to one of your set locations.', + arguments: [ + { + name: 'tp', + type: 'string', + defaultValue: null, + helpText: 'The location to teleport to.', + position: 0, + }, + ], + }), + new ICommand({ + function: this.loadFn('commands', 'tplist'), + name: 'tplist', + trigger: 'tplist', + helpText: 'Lists all your set locations.', + arguments: [], + }), + new ICommand({ + function: this.loadFn('commands', 'settp'), + name: 'settp', + trigger: 'settp', + helpText: 'Sets a location to teleport to.', + arguments: [ + { + name: 'tp', + type: 'string', + defaultValue: null, + helpText: 'The location name.', + position: 0, + }, + ], + }), + new ICommand({ + function: this.loadFn('commands', 'deletetp'), + name: 'deletetp', + trigger: 'deletetp', + helpText: 'Deletes a location.', + arguments: [ + { + name: 'tp', + type: 'string', + defaultValue: null, + helpText: 'The location name.', + position: 0, + }, + ], + }), + new ICommand({ + function: this.loadFn('commands', 'setpublic'), + name: 'setpublic', + trigger: 'setpublic', + helpText: 'Sets a teleport to be public, allowing other players to teleport to it.', + arguments: [ + { + name: 'tp', + type: 'string', + defaultValue: null, + helpText: 'The location name.', + position: 0, + }, + ], + }), + new ICommand({ + function: this.loadFn('commands', 'setprivate'), + name: 'setprivate', + trigger: 'setprivate', + helpText: 'Sets a teleport to be private, only the teleport owner can teleport to it.', + arguments: [ + { + name: 'tp', + type: 'string', + defaultValue: null, + helpText: 'The location name.', + position: 0, + }, + ], + }), + new ICommand({ + function: this.loadFn('commands', 'setwaypoint'), + name: 'setwaypoint', + trigger: 'setwaypoint', + helpText: 'Creates a new waypoint.', + arguments: [ + { + name: 'waypoint', + type: 'string', + defaultValue: null, + helpText: 'The location name.', + position: 0, + }, + ], + }), + new ICommand({ + function: this.loadFn('commands', 'deletewaypoint'), + name: 'deletewaypoint', + trigger: 'deletewaypoint', + helpText: 'Deletes a waypoint.', + arguments: [ + { + name: 'waypoint', + type: 'string', + defaultValue: null, + helpText: 'The location name.', + position: 0, + }, + ], + }), + new ICommand({ + function: this.loadFn('commands', 'listwaypoints'), + name: 'listwaypoints', + trigger: 'waypoints', + helpText: 'Lists all waypoints.', + arguments: [], + }), + new ICommand({ + function: this.loadFn('commands', 'teleportwaypoint'), + name: 'teleportwaypoint', + trigger: 'teleportwaypoint', + arguments: [], + helpText: + 'Placeholder command, this will not be used directly. The module will install aliases for this command corresponding to the waypoint names.', + }), ], }), - new ICommand({ - function: this.loadFn('commands', 'setprivate'), - name: 'setprivate', - trigger: 'setprivate', - helpText: 'Sets a teleport to be private, only the teleport owner can teleport to it.', - arguments: [ - { - name: 'tp', - type: 'string', - defaultValue: null, - helpText: 'The location name.', - position: 0, - }, - ], - }), - new ICommand({ - function: this.loadFn('commands', 'setwaypoint'), - name: 'setwaypoint', - trigger: 'setwaypoint', - helpText: 'Creates a new waypoint.', - arguments: [ - { - name: 'waypoint', - type: 'string', - defaultValue: null, - helpText: 'The location name.', - position: 0, - }, - ], - }), - new ICommand({ - function: this.loadFn('commands', 'deletewaypoint'), - name: 'deletewaypoint', - trigger: 'deletewaypoint', - helpText: 'Deletes a waypoint.', - arguments: [ - { - name: 'waypoint', - type: 'string', - defaultValue: null, - helpText: 'The location name.', - position: 0, - }, - ], - }), - new ICommand({ - function: this.loadFn('commands', 'listwaypoints'), - name: 'listwaypoints', - trigger: 'waypoints', - helpText: 'Lists all waypoints.', - arguments: [], - }), - new ICommand({ - function: this.loadFn('commands', 'teleportwaypoint'), - name: 'teleportwaypoint', - trigger: 'teleportwaypoint', - arguments: [], - helpText: - 'Placeholder command, this will not be used directly. The module will install aliases for this command corresponding to the waypoint names.', - }), ]; } } diff --git a/packages/lib-modules/src/modules/timedShutdown/index.ts b/packages/lib-modules/src/modules/timedShutdown/index.ts index 32490c760d..cdeb6d519b 100644 --- a/packages/lib-modules/src/modules/timedShutdown/index.ts +++ b/packages/lib-modules/src/modules/timedShutdown/index.ts @@ -1,38 +1,42 @@ -import { BuiltinModule, ICronJob } from '../../BuiltinModule.js'; +import { ModuleTransferDTO, ICronJob, ModuleTransferVersionDTO } from '../../BuiltinModule.js'; -export class TimedShutdown extends BuiltinModule { +export class TimedShutdown extends ModuleTransferDTO { constructor() { - super( - 'timedShutdown', - 'Automatically shut down the server at a specific time.', - '0.0.1', - JSON.stringify({ - $schema: 'http://json-schema.org/draft-07/schema#', - type: 'object', - properties: { - warningMessage: { - type: 'string', - title: 'Warning message', - description: 'Message to send to players before the server shuts down.', - default: 'Server is shutting down in 5 minutes!', - minLength: 1, - maxLength: 1024, + super(); + + this.name = 'timedShutdown'; + this.versions = [ + new ModuleTransferVersionDTO({ + tag: '0.0.1', + description: 'Automatically shut down the server at a specific time.', + configSchema: JSON.stringify({ + $schema: 'http://json-schema.org/draft-07/schema#', + type: 'object', + properties: { + warningMessage: { + type: 'string', + title: 'Warning message', + description: 'Message to send to players before the server shuts down.', + default: 'Server is shutting down in 5 minutes!', + minLength: 1, + maxLength: 1024, + }, }, - }, - required: ['warningMessage'], - }), - ); + required: ['warningMessage'], + }), - this.cronJobs = [ - new ICronJob({ - name: 'Shutdown', - temporalValue: '3 30 * * *', - function: this.loadFn('cronJobs', 'Shutdown'), - }), - new ICronJob({ - name: 'warning', - temporalValue: '3 25 * * *', - function: this.loadFn('cronJobs', 'warning'), + cronJobs: [ + new ICronJob({ + name: 'Shutdown', + temporalValue: '3 30 * * *', + function: this.loadFn('cronJobs', 'Shutdown'), + }), + new ICronJob({ + name: 'warning', + temporalValue: '3 25 * * *', + function: this.loadFn('cronJobs', 'warning'), + }), + ], }), ]; } diff --git a/packages/lib-modules/src/modules/utils/index.ts b/packages/lib-modules/src/modules/utils/index.ts index 2e733cd97a..e8fc90d47c 100644 --- a/packages/lib-modules/src/modules/utils/index.ts +++ b/packages/lib-modules/src/modules/utils/index.ts @@ -1,39 +1,42 @@ -import { BuiltinModule, ICommand } from '../../BuiltinModule.js'; +import { ModuleTransferDTO, ICommand, ModuleTransferVersionDTO } from '../../BuiltinModule.js'; -export class Utils extends BuiltinModule { +export class Utils extends ModuleTransferDTO { constructor() { - super( - 'utils', - 'A collection of useful commands', - '0.0.1', - JSON.stringify({ - $schema: 'http://json-schema.org/draft-07/schema#', - type: 'object', - additionalProperties: false, - }), - ); + super(); - this.commands = [ - new ICommand({ - function: this.loadFn('commands', 'ping'), - name: 'ping', - trigger: 'ping', - helpText: 'Replies with pong, useful for testing if the connection works.', - arguments: [], - }), - new ICommand({ - function: this.loadFn('commands', 'help'), - name: 'help', - trigger: 'help', - helpText: 'The text you are reading right now, displays information about commands.', - arguments: [ - { - name: 'command', - type: 'string', - defaultValue: 'all', - helpText: 'The command to get help for', - position: 0, - }, + this.name = 'utils'; + this.versions = [ + new ModuleTransferVersionDTO({ + tag: '0.0.1', + description: 'A collection of useful commands', + configSchema: JSON.stringify({ + $schema: 'http://json-schema.org/draft-07/schema#', + type: 'object', + additionalProperties: false, + }), + commands: [ + new ICommand({ + function: this.loadFn('commands', 'ping'), + name: 'ping', + trigger: 'ping', + helpText: 'Replies with pong, useful for testing if the connection works.', + arguments: [], + }), + new ICommand({ + function: this.loadFn('commands', 'help'), + name: 'help', + trigger: 'help', + helpText: 'The text you are reading right now, displays information about commands.', + arguments: [ + { + name: 'command', + type: 'string', + defaultValue: 'all', + helpText: 'The command to get help for', + position: 0, + }, + ], + }), ], }), ]; diff --git a/packages/test/src/__snapshots__/Module Assignments/discordChannelId is required when hook event-type is discord-message, happy path.json b/packages/test/src/__snapshots__/Module Assignments/discordChannelId is required when hook event-type is discord-message, happy path.json index c61cdddb0c..f1bf4af85f 100644 --- a/packages/test/src/__snapshots__/Module Assignments/discordChannelId is required when hook event-type is discord-message, happy path.json +++ b/packages/test/src/__snapshots__/Module Assignments/discordChannelId is required when hook event-type is discord-message, happy path.json @@ -23,7 +23,7 @@ "tag": "latest", "description": null, "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{},\"required\":[],\"additionalProperties\":false}", - "uiSchema": null, + "uiSchema": "{}", "cronJobs": [], "hooks": [ { diff --git a/packages/test/src/__snapshots__/ModuleConfig/Installing a module with correct config.json b/packages/test/src/__snapshots__/ModuleConfig/Installing a module with correct config.json index 735f4f4018..da54a2bc21 100644 --- a/packages/test/src/__snapshots__/ModuleConfig/Installing a module with correct config.json +++ b/packages/test/src/__snapshots__/ModuleConfig/Installing a module with correct config.json @@ -19,7 +19,7 @@ "tag": "latest", "description": "Test description", "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{\"foo\":{\"type\":\"string\",\"minLength\":3,\"maxLength\":10}},\"required\":[\"foo\"],\"additionalProperties\":false}", - "uiSchema": null, + "uiSchema": "{}", "cronJobs": [], "hooks": [], "commands": [], diff --git a/packages/test/src/__snapshots__/ModuleConfig/Installing with correct system config - multiple cron jobs.json b/packages/test/src/__snapshots__/ModuleConfig/Installing with correct system config - multiple cron jobs.json index 8d2ab09190..47aefb5e0c 100644 --- a/packages/test/src/__snapshots__/ModuleConfig/Installing with correct system config - multiple cron jobs.json +++ b/packages/test/src/__snapshots__/ModuleConfig/Installing with correct system config - multiple cron jobs.json @@ -27,7 +27,7 @@ "tag": "latest", "description": "Test description", "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{},\"required\":[],\"additionalProperties\":false}", - "uiSchema": null, + "uiSchema": "{}", "cronJobs": [ { "createdAt": "2024-12-07T17:36:18.873Z", diff --git a/packages/test/src/__snapshots__/ModuleConfig/Installing with correct system config - should default cronjob values.json b/packages/test/src/__snapshots__/ModuleConfig/Installing with correct system config - should default cronjob values.json index f32c6d4c70..d996c7a18e 100644 --- a/packages/test/src/__snapshots__/ModuleConfig/Installing with correct system config - should default cronjob values.json +++ b/packages/test/src/__snapshots__/ModuleConfig/Installing with correct system config - should default cronjob values.json @@ -23,7 +23,7 @@ "tag": "latest", "description": "Test description", "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{},\"required\":[],\"additionalProperties\":false}", - "uiSchema": null, + "uiSchema": "{}", "cronJobs": [ { "createdAt": "2024-12-07T17:36:20.969Z", diff --git a/packages/test/src/__snapshots__/ModuleConfig/Installing with correct system config.json b/packages/test/src/__snapshots__/ModuleConfig/Installing with correct system config.json index 2aea30b378..179d74e3cb 100644 --- a/packages/test/src/__snapshots__/ModuleConfig/Installing with correct system config.json +++ b/packages/test/src/__snapshots__/ModuleConfig/Installing with correct system config.json @@ -23,7 +23,7 @@ "tag": "latest", "description": "Test description", "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{},\"required\":[],\"additionalProperties\":false}", - "uiSchema": null, + "uiSchema": "{}", "cronJobs": [ { "createdAt": "2024-12-07T17:36:16.546Z", diff --git a/packages/test/src/__snapshots__/ModuleController/Allows passing an array of permissions when creating a module.json b/packages/test/src/__snapshots__/ModuleController/Allows passing an array of permissions when creating a module.json index f37d873b2e..0daa5d49e9 100644 --- a/packages/test/src/__snapshots__/ModuleController/Allows passing an array of permissions when creating a module.json +++ b/packages/test/src/__snapshots__/ModuleController/Allows passing an array of permissions when creating a module.json @@ -15,7 +15,7 @@ "tag": "latest", "description": null, "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{},\"required\":[],\"additionalProperties\":false}", - "uiSchema": null, + "uiSchema": "{}", "cronJobs": [], "hooks": [], "commands": [], diff --git a/packages/test/src/__snapshots__/ModuleController/Allows passing an array of permissions when updating a module.json b/packages/test/src/__snapshots__/ModuleController/Allows passing an array of permissions when updating a module.json index b4f77473eb..da470eb9f2 100644 --- a/packages/test/src/__snapshots__/ModuleController/Allows passing an array of permissions when updating a module.json +++ b/packages/test/src/__snapshots__/ModuleController/Allows passing an array of permissions when updating a module.json @@ -7,7 +7,7 @@ "id": "828e664f-6ef4-4cd2-ade3-605b0cefdbfb", "description": null, "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{},\"required\":[],\"additionalProperties\":false}", - "uiSchema": null, + "uiSchema": "{}", "cronJobs": [], "hooks": [], "commands": [], diff --git a/packages/test/src/__snapshots__/ModuleController/Create.json b/packages/test/src/__snapshots__/ModuleController/Create.json index 660349e230..3cb932793e 100644 --- a/packages/test/src/__snapshots__/ModuleController/Create.json +++ b/packages/test/src/__snapshots__/ModuleController/Create.json @@ -15,7 +15,7 @@ "tag": "latest", "description": null, "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{},\"required\":[],\"additionalProperties\":false}", - "uiSchema": null, + "uiSchema": "{}", "cronJobs": [], "hooks": [], "commands": [], diff --git a/packages/test/src/__snapshots__/ModuleController/Get by ID.json b/packages/test/src/__snapshots__/ModuleController/Get by ID.json index aa0c4f1701..8fcf91b50d 100644 --- a/packages/test/src/__snapshots__/ModuleController/Get by ID.json +++ b/packages/test/src/__snapshots__/ModuleController/Get by ID.json @@ -15,7 +15,7 @@ "tag": "latest", "description": null, "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{},\"required\":[],\"additionalProperties\":false}", - "uiSchema": null, + "uiSchema": "{}", "cronJobs": [], "hooks": [], "commands": [], diff --git a/packages/test/src/__snapshots__/ModuleController/Updating permission returns updated permission.json b/packages/test/src/__snapshots__/ModuleController/Updating permission returns updated permission.json index 611cd046b4..10793b8a16 100644 --- a/packages/test/src/__snapshots__/ModuleController/Updating permission returns updated permission.json +++ b/packages/test/src/__snapshots__/ModuleController/Updating permission returns updated permission.json @@ -15,7 +15,7 @@ "tag": "latest", "description": null, "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{},\"required\":[],\"additionalProperties\":false}", - "uiSchema": null, + "uiSchema": "{}", "cronJobs": [], "hooks": [], "commands": [], diff --git a/packages/test/src/__snapshots__/ModuleController/Updating permissions can remove permissions.json b/packages/test/src/__snapshots__/ModuleController/Updating permissions can remove permissions.json index 9f0cbd8b85..bc282f0b95 100644 --- a/packages/test/src/__snapshots__/ModuleController/Updating permissions can remove permissions.json +++ b/packages/test/src/__snapshots__/ModuleController/Updating permissions can remove permissions.json @@ -15,7 +15,7 @@ "tag": "latest", "description": null, "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{},\"required\":[],\"additionalProperties\":false}", - "uiSchema": null, + "uiSchema": "{}", "cronJobs": [], "hooks": [], "commands": [], diff --git a/packages/test/src/__snapshots__/ModuleController/Updating permissions keeps IDs static of already-existing permissions.json b/packages/test/src/__snapshots__/ModuleController/Updating permissions keeps IDs static of already-existing permissions.json index d9acbc23d1..2c40a96ff6 100644 --- a/packages/test/src/__snapshots__/ModuleController/Updating permissions keeps IDs static of already-existing permissions.json +++ b/packages/test/src/__snapshots__/ModuleController/Updating permissions keeps IDs static of already-existing permissions.json @@ -7,7 +7,7 @@ "id": "eee2696e-d240-4f31-bac4-00994dd9d0e9", "description": null, "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{},\"required\":[],\"additionalProperties\":false}", - "uiSchema": null, + "uiSchema": "{}", "cronJobs": [], "hooks": [], "commands": [], diff --git a/packages/test/src/__snapshots__/ModuleController/versioning: Can tag a version.json b/packages/test/src/__snapshots__/ModuleController/versioning: Can tag a version.json index 05a74fcba9..e8e98a1517 100644 --- a/packages/test/src/__snapshots__/ModuleController/versioning: Can tag a version.json +++ b/packages/test/src/__snapshots__/ModuleController/versioning: Can tag a version.json @@ -9,7 +9,7 @@ "tag": "1.0.0", "description": null, "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{},\"required\":[],\"additionalProperties\":false}", - "uiSchema": null, + "uiSchema": "{}", "hooks": [], "commands": [], "cronJobs": [],