diff --git a/apps/backend/schema.gql b/apps/backend/schema.gql index 9b73aac22..f2903aeab 100644 --- a/apps/backend/schema.gql +++ b/apps/backend/schema.gql @@ -175,10 +175,6 @@ type Mutation { admin__core_main_settings__edit(site_copyright: [TextLanguageInput!]!, site_description: [TextLanguageInput!]!, site_name: String!, site_short_name: String!): EditAdminSettingsObj! admin__core_manifest_metadata__edit(background_color: String!, display: String!, start_url: String!, theme_color: String!): ShowAdminManifestMetadataObj! admin__core_members__edit(birthday: DateTime!, email: String!, first_name: String!, id: Int!, last_name: String!, name: String!, newsletter: Boolean!): EditAdminMembersObj! - admin__core_nav__change_position(id: Int!, index_to_move: Int!, parent_id: Int!): String! - admin__core_nav__create(description: [TextLanguageInput!]!, external: Boolean!, href: String!, icon: String, name: [TextLanguageInput!]!): ShowCoreNav! - admin__core_nav__delete(id: Int!): String! - admin__core_nav__edit(description: [TextLanguageInput!]!, external: Boolean!, href: String!, icon: String, id: Int!, name: [TextLanguageInput!]!): ShowCoreNav! admin__core_plugins__create(author: String!, author_url: String, code: String!, description: String, name: String!, support_url: String!): ShowAdminPlugins! admin__core_plugins__delete(code: String!): String! admin__core_plugins__download(code: String!, version: String, version_code: Int): String! diff --git a/apps/backend/src/app.module.ts b/apps/backend/src/app.module.ts index 2e26519fa..4b6521118 100644 --- a/apps/backend/src/app.module.ts +++ b/apps/backend/src/app.module.ts @@ -5,6 +5,7 @@ import { VitNodeCoreModule } from "vitnode-backend"; import { PluginsModule } from "./plugins/plugins.module"; import { DATABASE_ENVS } from "./database/client"; +import { schemaDatabase } from "./database/schema"; @Module({ imports: [ @@ -13,7 +14,8 @@ import { DATABASE_ENVS } from "./database/client"; envFile: join(process.cwd(), "..", "..", ".env") }, database: { - config: DATABASE_ENVS + config: DATABASE_ENVS, + schemaDatabase } }), PluginsModule diff --git a/apps/backend/src/plugins/core/admin/admin.module.ts b/apps/backend/src/plugins/core/admin/admin.module.ts index d1d08438c..e90e43b5c 100644 --- a/apps/backend/src/plugins/core/admin/admin.module.ts +++ b/apps/backend/src/plugins/core/admin/admin.module.ts @@ -12,7 +12,7 @@ import { AdminFilesModule } from "./files/files.module"; import { AdminGroupsModule } from "./groups/groups.module"; import { AdminLanguagesModule } from "./languages/languages.module"; import { AdminMembersModule } from "./members/members.module"; -import { AdminNavModule } from "./nav/nav.module"; +// import { AdminNavModule } from "./nav/nav.module"; import { AdminStaffModule } from "./staff/staff.module"; import { AdminThemeEditorModule } from "./theme_editor/theme_editor.module"; import { AdminEmailModule } from "./email/email.module"; @@ -29,7 +29,7 @@ import { AdminEmailModule } from "./email/email.module"; AdminGroupsModule, AdminLanguagesModule, AdminMembersModule, - AdminNavModule, + // AdminNavModule, AdminStaffModule, AdminThemeEditorModule, AdminEmailModule diff --git a/apps/backend/src/plugins/core/core.module.ts b/apps/backend/src/plugins/core/core.module.ts index 2be409614..70a55f6e5 100644 --- a/apps/backend/src/plugins/core/core.module.ts +++ b/apps/backend/src/plugins/core/core.module.ts @@ -12,7 +12,6 @@ import { GlobalCoreHelpersModule } from "./helpers/helpers.module"; import { CoreLanguagesModule } from "./languages/languages.module"; import { CoreMembersModule } from "./members/members.module"; import { CoreMiddlewareModule } from "./middleware/middleware.module"; -import { CoreNavModule } from "./nav/nav.module"; import { CorePluginsModule } from "./plugins/plugins.module"; import { CoreThemeEditorModule } from "./theme_editor/theme_editor.module"; @@ -29,7 +28,6 @@ import { CoreThemeEditorModule } from "./theme_editor/theme_editor.module"; CoreLanguagesModule, CoreMembersModule, CoreMiddlewareModule, - CoreNavModule, CorePluginsModule, CoreThemeEditorModule ] diff --git a/packages/backend/package.json b/packages/backend/package.json index 44816ae4b..40eb35285 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -33,6 +33,7 @@ "@types/object-path": "^0.11.4", "@types/pg": "^8.11.6", "busboy": "^1.6.0", + "class-transformer": "^0.5.1", "eslint-config-vitnode": "workspace:*", "http-errors": "^2.0.0", "object-path": "^0.11.8", diff --git a/packages/backend/src/core/core.module.ts b/packages/backend/src/core/core.module.ts index e1302b80d..ed1927779 100644 --- a/packages/backend/src/core/core.module.ts +++ b/packages/backend/src/core/core.module.ts @@ -1,6 +1,8 @@ import { Module } from "@nestjs/common"; +import { CoreNavModule } from "./nav/nav.module"; + @Module({ - imports: [] + imports: [CoreNavModule] }) export class CoreModule {} diff --git a/apps/backend/src/plugins/core/nav/nav.module.ts b/packages/backend/src/core/nav/nav.module.ts similarity index 100% rename from apps/backend/src/plugins/core/nav/nav.module.ts rename to packages/backend/src/core/nav/nav.module.ts diff --git a/apps/backend/src/plugins/core/nav/show/dto/show.args.ts b/packages/backend/src/core/nav/show/dto/show.args.ts similarity index 67% rename from apps/backend/src/plugins/core/nav/show/dto/show.args.ts rename to packages/backend/src/core/nav/show/dto/show.args.ts index 91e3eb231..6d83678f2 100644 --- a/apps/backend/src/plugins/core/nav/show/dto/show.args.ts +++ b/packages/backend/src/core/nav/show/dto/show.args.ts @@ -1,5 +1,6 @@ import { ArgsType } from "@nestjs/graphql"; -import { PaginationArgs } from "vitnode-backend"; + +import { PaginationArgs } from "../../../../utils"; @ArgsType() export class ShowCoreNavArgs extends PaginationArgs {} diff --git a/apps/backend/src/plugins/core/nav/show/dto/show.obj.ts b/packages/backend/src/core/nav/show/dto/show.obj.ts similarity index 92% rename from apps/backend/src/plugins/core/nav/show/dto/show.obj.ts rename to packages/backend/src/core/nav/show/dto/show.obj.ts index 8b31bfb50..405d123fd 100644 --- a/apps/backend/src/plugins/core/nav/show/dto/show.obj.ts +++ b/packages/backend/src/core/nav/show/dto/show.obj.ts @@ -1,5 +1,6 @@ import { Field, Int, ObjectType } from "@nestjs/graphql"; -import { PageInfo, TextLanguage } from "vitnode-backend"; + +import { PageInfo, TextLanguage } from "../../../../utils"; @ObjectType() class ShowCoreNavItem { diff --git a/apps/backend/src/plugins/core/nav/show/show.resolver.ts b/packages/backend/src/core/nav/show/show.resolver.ts similarity index 100% rename from apps/backend/src/plugins/core/nav/show/show.resolver.ts rename to packages/backend/src/core/nav/show/show.resolver.ts diff --git a/apps/backend/src/plugins/core/nav/show/show.service.ts b/packages/backend/src/core/nav/show/show.service.ts similarity index 86% rename from apps/backend/src/plugins/core/nav/show/show.service.ts rename to packages/backend/src/core/nav/show/show.service.ts index 98e08d2d3..e3d252408 100644 --- a/apps/backend/src/plugins/core/nav/show/show.service.ts +++ b/packages/backend/src/core/nav/show/show.service.ts @@ -1,16 +1,12 @@ import { Injectable } from "@nestjs/common"; import { and, count, eq } from "drizzle-orm"; -import { - inputPaginationCursor, - outputPagination, - SortDirectionEnum, - DatabaseService -} from "vitnode-backend"; import { ShowCoreNavArgs } from "./dto/show.args"; import { ShowCoreNavObj } from "./dto/show.obj"; - -import { core_nav } from "@/plugins/core/admin/database/schema/nav"; +import { DatabaseService } from "../../../database"; +import { inputPaginationCursor, outputPagination } from "../../../functions"; +import { core_nav } from "../../../templates/core/admin/database/schema/nav"; +import { SortDirectionEnum } from "../../../utils"; @Injectable() export class ShowCoreNavService { diff --git a/packages/backend/src/database/database.module.ts b/packages/backend/src/database/database.module.ts index 190f1df11..375816d7f 100644 --- a/packages/backend/src/database/database.module.ts +++ b/packages/backend/src/database/database.module.ts @@ -12,6 +12,7 @@ registerEnumType(SortDirectionEnum, { export interface DatabaseModuleArgs { config: PoolConfig; + schemaDatabase: Record; } @Global() diff --git a/packages/backend/src/database/database.service.ts b/packages/backend/src/database/database.service.ts index 8af9cbfc2..cad217b10 100644 --- a/packages/backend/src/database/database.service.ts +++ b/packages/backend/src/database/database.service.ts @@ -3,8 +3,7 @@ import { NodePgDatabase } from "drizzle-orm/node-postgres"; import { DatabaseModuleArgs } from "./database.module"; import { createClientDatabase } from "./client"; - -import coreSchemaDatabase from "@/templates/core/admin/database"; +import coreSchemaDatabase from "../templates/core/admin/database"; @Injectable() export class DatabaseService { @@ -15,7 +14,7 @@ export class DatabaseService { private readonly options: DatabaseModuleArgs ) { const client = createClientDatabase({ - schemaDatabase: {}, + schemaDatabase: this.options.schemaDatabase, config: this.options.config }); diff --git a/packages/backend/tsconfig.json b/packages/backend/tsconfig.json index ccf0ad3f9..7b285e14d 100644 --- a/packages/backend/tsconfig.json +++ b/packages/backend/tsconfig.json @@ -8,9 +8,7 @@ "declaration": true, "experimentalDecorators": true, "strictNullChecks": false, - "paths": { - "@/*": ["./src/*"] - } + "emitDecoratorMetadata": true }, "include": ["src/**/*"] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8bd635b57..ff37cd56e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -101,7 +101,7 @@ importers: version: 4.2.1(graphql@16.8.2) '@nestjs/cli': specifier: ^10.3.2 - version: 10.3.2(@swc/cli@0.3.12(@swc/core@1.6.3(@swc/helpers@0.5.11))(chokidar@3.6.0))(@swc/core@1.6.3(@swc/helpers@0.5.11))(esbuild@0.19.12) + version: 10.3.2(@swc/cli@0.3.12(@swc/core@1.6.3(@swc/helpers@0.5.11))(chokidar@3.6.0))(@swc/core@1.6.3(@swc/helpers@0.5.11)) '@nestjs/schematics': specifier: ^10.1.1 version: 10.1.1(chokidar@3.6.0)(typescript@5.5.2) @@ -545,6 +545,9 @@ importers: busboy: specifier: ^1.6.0 version: 1.6.0 + class-transformer: + specifier: ^0.5.1 + version: 0.5.1 eslint-config-vitnode: specifier: workspace:* version: link:../eslint-config-vitnode @@ -10412,7 +10415,7 @@ snapshots: lodash.omit: 4.5.0 tslib: 2.6.2 - '@nestjs/cli@10.3.2(@swc/cli@0.3.12(@swc/core@1.6.3(@swc/helpers@0.5.11))(chokidar@3.6.0))(@swc/core@1.6.3(@swc/helpers@0.5.11))(esbuild@0.19.12)': + '@nestjs/cli@10.3.2(@swc/cli@0.3.12(@swc/core@1.6.3(@swc/helpers@0.5.11))(chokidar@3.6.0))(@swc/core@1.6.3(@swc/helpers@0.5.11))': dependencies: '@angular-devkit/core': 17.1.2(chokidar@3.6.0) '@angular-devkit/schematics': 17.1.2(chokidar@3.6.0) @@ -10422,7 +10425,7 @@ snapshots: chokidar: 3.6.0 cli-table3: 0.6.3 commander: 4.1.1 - fork-ts-checker-webpack-plugin: 9.0.2(typescript@5.3.3)(webpack@5.90.1(@swc/core@1.6.3(@swc/helpers@0.5.11))(esbuild@0.19.12)) + fork-ts-checker-webpack-plugin: 9.0.2(typescript@5.3.3)(webpack@5.90.1(@swc/core@1.6.3(@swc/helpers@0.5.11))) glob: 10.3.10 inquirer: 8.2.6 node-emoji: 1.11.0 @@ -10434,7 +10437,7 @@ snapshots: tsconfig-paths: 4.2.0 tsconfig-paths-webpack-plugin: 4.1.0 typescript: 5.3.3 - webpack: 5.90.1(@swc/core@1.6.3(@swc/helpers@0.5.11))(esbuild@0.19.12) + webpack: 5.90.1(@swc/core@1.6.3(@swc/helpers@0.5.11)) webpack-node-externals: 3.0.0 optionalDependencies: '@swc/cli': 0.3.12(@swc/core@1.6.3(@swc/helpers@0.5.11))(chokidar@3.6.0) @@ -12439,7 +12442,7 @@ snapshots: dependencies: '@types/node': 20.14.7 tapable: 2.2.1 - webpack: 5.92.1(@swc/core@1.6.3(@swc/helpers@0.5.11))(esbuild@0.19.12) + webpack: 5.92.1(@swc/core@1.3.101(@swc/helpers@0.5.11))(esbuild@0.19.11) transitivePeerDependencies: - '@swc/core' - esbuild @@ -14482,7 +14485,7 @@ snapshots: cross-spawn: 7.0.3 signal-exit: 4.1.0 - fork-ts-checker-webpack-plugin@9.0.2(typescript@5.3.3)(webpack@5.90.1(@swc/core@1.6.3(@swc/helpers@0.5.11))(esbuild@0.19.12)): + fork-ts-checker-webpack-plugin@9.0.2(typescript@5.3.3)(webpack@5.90.1(@swc/core@1.6.3(@swc/helpers@0.5.11))): dependencies: '@babel/code-frame': 7.24.7 chalk: 4.1.2 @@ -14497,7 +14500,7 @@ snapshots: semver: 7.6.2 tapable: 2.2.1 typescript: 5.3.3 - webpack: 5.90.1(@swc/core@1.6.3(@swc/helpers@0.5.11))(esbuild@0.19.12) + webpack: 5.90.1(@swc/core@1.6.3(@swc/helpers@0.5.11)) form-data@4.0.0: dependencies: @@ -17140,29 +17143,27 @@ snapshots: mkdirp: 3.0.1 yallist: 5.0.0 - terser-webpack-plugin@5.3.10(@swc/core@1.6.3(@swc/helpers@0.5.11))(esbuild@0.19.12)(webpack@5.90.1(@swc/core@1.6.3(@swc/helpers@0.5.11))(esbuild@0.19.12)): + terser-webpack-plugin@5.3.10(@swc/core@1.6.3(@swc/helpers@0.5.11))(webpack@5.90.1(@swc/core@1.6.3(@swc/helpers@0.5.11))): dependencies: '@jridgewell/trace-mapping': 0.3.25 jest-worker: 27.5.1 schema-utils: 3.3.0 serialize-javascript: 6.0.2 terser: 5.31.1 - webpack: 5.90.1(@swc/core@1.6.3(@swc/helpers@0.5.11))(esbuild@0.19.12) + webpack: 5.90.1(@swc/core@1.6.3(@swc/helpers@0.5.11)) optionalDependencies: '@swc/core': 1.6.3(@swc/helpers@0.5.11) - esbuild: 0.19.12 - terser-webpack-plugin@5.3.10(@swc/core@1.6.3(@swc/helpers@0.5.11))(esbuild@0.19.12)(webpack@5.92.1(@swc/core@1.3.101(@swc/helpers@0.5.11))(esbuild@0.19.11)): + terser-webpack-plugin@5.3.10(@swc/core@1.6.3(@swc/helpers@0.5.11))(webpack@5.92.1(@swc/core@1.3.101(@swc/helpers@0.5.11))(esbuild@0.19.11)): dependencies: '@jridgewell/trace-mapping': 0.3.25 jest-worker: 27.5.1 schema-utils: 3.3.0 serialize-javascript: 6.0.2 terser: 5.31.1 - webpack: 5.92.1(@swc/core@1.6.3(@swc/helpers@0.5.11))(esbuild@0.19.12) + webpack: 5.92.1(@swc/core@1.3.101(@swc/helpers@0.5.11))(esbuild@0.19.11) optionalDependencies: '@swc/core': 1.6.3(@swc/helpers@0.5.11) - esbuild: 0.19.12 terser@5.31.1: dependencies: @@ -17535,7 +17536,7 @@ snapshots: webpack-sources@3.2.3: {} - webpack@5.90.1(@swc/core@1.6.3(@swc/helpers@0.5.11))(esbuild@0.19.12): + webpack@5.90.1(@swc/core@1.6.3(@swc/helpers@0.5.11)): dependencies: '@types/eslint-scope': 3.7.7 '@types/estree': 1.0.5 @@ -17558,7 +17559,7 @@ snapshots: neo-async: 2.6.2 schema-utils: 3.3.0 tapable: 2.2.1 - terser-webpack-plugin: 5.3.10(@swc/core@1.6.3(@swc/helpers@0.5.11))(esbuild@0.19.12)(webpack@5.90.1(@swc/core@1.6.3(@swc/helpers@0.5.11))(esbuild@0.19.12)) + terser-webpack-plugin: 5.3.10(@swc/core@1.6.3(@swc/helpers@0.5.11))(webpack@5.90.1(@swc/core@1.6.3(@swc/helpers@0.5.11))) watchpack: 2.4.1 webpack-sources: 3.2.3 transitivePeerDependencies: @@ -17566,7 +17567,7 @@ snapshots: - esbuild - uglify-js - webpack@5.92.1(@swc/core@1.6.3(@swc/helpers@0.5.11))(esbuild@0.19.12): + webpack@5.92.1(@swc/core@1.3.101(@swc/helpers@0.5.11))(esbuild@0.19.11): dependencies: '@types/eslint-scope': 3.7.7 '@types/estree': 1.0.5 @@ -17589,7 +17590,7 @@ snapshots: neo-async: 2.6.2 schema-utils: 3.3.0 tapable: 2.2.1 - terser-webpack-plugin: 5.3.10(@swc/core@1.6.3(@swc/helpers@0.5.11))(esbuild@0.19.12)(webpack@5.92.1(@swc/core@1.3.101(@swc/helpers@0.5.11))(esbuild@0.19.11)) + terser-webpack-plugin: 5.3.10(@swc/core@1.6.3(@swc/helpers@0.5.11))(webpack@5.92.1(@swc/core@1.3.101(@swc/helpers@0.5.11))(esbuild@0.19.11)) watchpack: 2.4.1 webpack-sources: 3.2.3 transitivePeerDependencies: