Browse Source

Merge pull request #8542 from nocodb/nc-refactor/modules

refactor: merge core modules into single noco module
pull/8557/head
Pranav C 6 months ago committed by GitHub
parent
commit
6a31b3777e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 22
      packages/nocodb/src/app.module.ts
  2. 2
      packages/nocodb/src/controllers/data-alias-export.controller.ts
  3. 2
      packages/nocodb/src/controllers/old-datas/old-datas.service.ts
  4. 2
      packages/nocodb/src/controllers/public-datas-export.controller.ts
  5. 0
      packages/nocodb/src/helpers/dataHelpers.ts
  6. 13
      packages/nocodb/src/modules/auth/auth.controller.ts
  7. 33
      packages/nocodb/src/modules/auth/auth.module.ts
  8. 0
      packages/nocodb/src/modules/auth/auth.service.spec.ts
  9. 0
      packages/nocodb/src/modules/auth/auth.service.ts
  10. 0
      packages/nocodb/src/modules/auth/ui/auth/emailVerify.ts
  11. 0
      packages/nocodb/src/modules/auth/ui/auth/resetPassword.ts
  12. 0
      packages/nocodb/src/modules/auth/ui/emailTemplates/forgotPassword.ts
  13. 0
      packages/nocodb/src/modules/auth/ui/emailTemplates/invite.ts
  14. 0
      packages/nocodb/src/modules/auth/ui/emailTemplates/verify.ts
  15. 71
      packages/nocodb/src/modules/datas/datas.module.ts
  16. 67
      packages/nocodb/src/modules/global/global.module.ts
  17. 8
      packages/nocodb/src/modules/jobs/jobs.module.ts
  18. 2
      packages/nocodb/src/modules/jobs/jobs/export-import/export.service.ts
  19. 111
      packages/nocodb/src/modules/noco.module.ts
  20. 15
      packages/nocodb/src/modules/users/users.module.ts
  21. 0
      packages/nocodb/src/providers/init-meta-service.provider.ts
  22. 27
      packages/nocodb/src/providers/jwt-strategy.provider.ts
  23. 4
      packages/nocodb/src/services/base-users/base-users.service.ts
  24. 4
      packages/nocodb/src/services/bulk-data-alias.service.ts
  25. 4
      packages/nocodb/src/services/data-alias-nested.service.ts
  26. 4
      packages/nocodb/src/services/datas.service.ts
  27. 2
      packages/nocodb/src/services/public-datas.service.ts
  28. 7
      packages/nocodb/src/services/users/users.service.ts
  29. 2
      packages/nocodb/src/strategies/local.strategy.ts

22
packages/nocodb/src/app.module.ts

@ -5,34 +5,23 @@ import { ConfigModule } from '@nestjs/config';
import { EventEmitterModule as NestJsEventEmitter } from '@nestjs/event-emitter'; import { EventEmitterModule as NestJsEventEmitter } from '@nestjs/event-emitter';
import { SentryModule } from '@ntegral/nestjs-sentry'; import { SentryModule } from '@ntegral/nestjs-sentry';
import type { MiddlewareConsumer } from '@nestjs/common'; import type { MiddlewareConsumer } from '@nestjs/common';
import { NocoModule } from '~/modules/noco.module';
import { AuthModule } from '~/modules/auth/auth.module';
import { GlobalExceptionFilter } from '~/filters/global-exception/global-exception.filter'; import { GlobalExceptionFilter } from '~/filters/global-exception/global-exception.filter';
import { GlobalMiddleware } from '~/middlewares/global/global.middleware'; import { GlobalMiddleware } from '~/middlewares/global/global.middleware';
import { GuiMiddleware } from '~/middlewares/gui/gui.middleware'; import { GuiMiddleware } from '~/middlewares/gui/gui.middleware';
import { DatasModule } from '~/modules/datas/datas.module';
import { EventEmitterModule } from '~/modules/event-emitter/event-emitter.module'; import { EventEmitterModule } from '~/modules/event-emitter/event-emitter.module';
import { AuthService } from '~/services/auth.service';
import { GlobalModule } from '~/modules/global/global.module';
import { LocalStrategy } from '~/strategies/local.strategy';
import { AuthTokenStrategy } from '~/strategies/authtoken.strategy/authtoken.strategy';
import { BaseViewStrategy } from '~/strategies/base-view.strategy/base-view.strategy';
import { MetasModule } from '~/modules/metas/metas.module';
import { JobsModule } from '~/modules/jobs/jobs.module'; import { JobsModule } from '~/modules/jobs/jobs.module';
import appConfig from '~/app.config'; import appConfig from '~/app.config';
import { ExtractIdsMiddleware } from '~/middlewares/extract-ids/extract-ids.middleware'; import { ExtractIdsMiddleware } from '~/middlewares/extract-ids/extract-ids.middleware';
import { BasicStrategy } from '~/strategies/basic.strategy/basic.strategy';
import { UsersModule } from '~/modules/users/users.module';
import { AuthModule } from '~/modules/auth/auth.module';
import { packageInfo } from '~/utils/packageVersion'; import { packageInfo } from '~/utils/packageVersion';
export const ceModuleConfig = { export const ceModuleConfig = {
imports: [ imports: [
GlobalModule,
UsersModule,
AuthModule, AuthModule,
MetasModule, NocoModule,
DatasModule,
EventEmitterModule, EventEmitterModule,
JobsModule, JobsModule,
NestJsEventEmitter.forRoot(), NestJsEventEmitter.forRoot(),
@ -53,7 +42,6 @@ export const ceModuleConfig = {
: []), : []),
], ],
providers: [ providers: [
AuthService,
{ {
provide: APP_FILTER, provide: APP_FILTER,
useClass: GlobalExceptionFilter, useClass: GlobalExceptionFilter,
@ -62,10 +50,6 @@ export const ceModuleConfig = {
provide: APP_GUARD, provide: APP_GUARD,
useClass: ExtractIdsMiddleware, useClass: ExtractIdsMiddleware,
}, },
LocalStrategy,
AuthTokenStrategy,
BaseViewStrategy,
BasicStrategy,
], ],
}; };

2
packages/nocodb/src/controllers/data-alias-export.controller.ts

@ -3,7 +3,7 @@ import { Request, Response } from 'express';
import * as XLSX from 'xlsx'; import * as XLSX from 'xlsx';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { DatasService } from '~/services/datas.service'; import { DatasService } from '~/services/datas.service';
import { extractCsvData, extractXlsxData } from '~/modules/datas/helpers'; import { extractCsvData, extractXlsxData } from '~/helpers/dataHelpers';
import { View } from '~/models'; import { View } from '~/models';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { DataApiLimiterGuard } from '~/guards/data-api-limiter.guard'; import { DataApiLimiterGuard } from '~/guards/data-api-limiter.guard';

2
packages/nocodb/src/controllers/old-datas/old-datas.service.ts

@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { nocoExecute } from 'nc-help'; import { nocoExecute } from 'nc-help';
import type { OldPathParams } from '~/modules/datas/helpers'; import type { OldPathParams } from '~/helpers/dataHelpers';
import getAst from '~/helpers/getAst'; import getAst from '~/helpers/getAst';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { Base, Model, Source, View } from '~/models'; import { Base, Model, Source, View } from '~/models';

2
packages/nocodb/src/controllers/public-datas-export.controller.ts

@ -12,7 +12,7 @@ import { nocoExecute } from 'nc-help';
import papaparse from 'papaparse'; import papaparse from 'papaparse';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import getAst from '~/helpers/getAst'; import getAst from '~/helpers/getAst';
import { serializeCellValue } from '~/modules/datas/helpers'; import { serializeCellValue } from '~/helpers/dataHelpers';
import { PublicDatasExportService } from '~/services/public-datas-export.service'; import { PublicDatasExportService } from '~/services/public-datas-export.service';
import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2'; import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2';
import { Column, Model, Source, View } from '~/models'; import { Column, Model, Source, View } from '~/models';

0
packages/nocodb/src/modules/datas/helpers.ts → packages/nocodb/src/helpers/dataHelpers.ts

13
packages/nocodb/src/controllers/auth/auth.controller.ts → packages/nocodb/src/modules/auth/auth.controller.ts

@ -232,11 +232,14 @@ export class AuthController {
): Promise<any> { ): Promise<any> {
try { try {
res.send( res.send(
ejs.render((await import('./ui/auth/resetPassword')).default, { ejs.render(
ncPublicUrl: process.env.NC_PUBLIC_URL || '', (await import('~/modules/auth/ui/auth/resetPassword')).default,
token: JSON.stringify(tokenId), {
baseUrl: `/`, ncPublicUrl: process.env.NC_PUBLIC_URL || '',
}), token: JSON.stringify(tokenId),
baseUrl: `/`,
},
),
); );
} catch (e) { } catch (e) {
return res.status(400).json({ msg: e.message }); return res.status(400).json({ msg: e.message });

33
packages/nocodb/src/modules/auth/auth.module.ts

@ -1,16 +1,31 @@
import { forwardRef, Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { PassportModule } from '@nestjs/passport'; import { PassportModule } from '@nestjs/passport';
import { NocoModule } from '~/modules/noco.module';
import { BasicStrategy } from '~/strategies/basic.strategy/basic.strategy';
import { LocalStrategy } from '~/strategies/local.strategy';
import { AuthTokenStrategy } from '~/strategies/authtoken.strategy/authtoken.strategy';
import { BaseViewStrategy } from '~/strategies/base-view.strategy/base-view.strategy';
import { GoogleStrategyProvider } from '~/strategies/google.strategy/google.strategy'; import { GoogleStrategyProvider } from '~/strategies/google.strategy/google.strategy';
import { UsersService } from '~/services/users/users.service'; import { AuthService } from '~/modules/auth/auth.service';
import { AuthController } from '~/controllers/auth/auth.controller'; import { AuthController } from '~/modules/auth/auth.controller';
import { MetasModule } from '~/modules/metas/metas.module';
@Module({ export const authModuleMetadata = {
imports: [PassportModule, forwardRef(() => MetasModule)], imports: [PassportModule, NocoModule],
controllers: [ controllers: [
...(process.env.NC_WORKER_CONTAINER !== 'true' ? [AuthController] : []), ...(process.env.NC_WORKER_CONTAINER !== 'true' ? [AuthController] : []),
], ],
providers: [UsersService, GoogleStrategyProvider], providers: [
exports: [UsersService], AuthService,
}) LocalStrategy,
AuthTokenStrategy,
BaseViewStrategy,
BasicStrategy,
GoogleStrategyProvider,
],
exports: [],
};
@Module(authModuleMetadata)
export class AuthModule {} export class AuthModule {}

0
packages/nocodb/src/services/auth.service.spec.ts → packages/nocodb/src/modules/auth/auth.service.spec.ts

0
packages/nocodb/src/services/auth.service.ts → packages/nocodb/src/modules/auth/auth.service.ts

0
packages/nocodb/src/controllers/auth/ui/auth/emailVerify.ts → packages/nocodb/src/modules/auth/ui/auth/emailVerify.ts

0
packages/nocodb/src/controllers/auth/ui/auth/resetPassword.ts → packages/nocodb/src/modules/auth/ui/auth/resetPassword.ts

0
packages/nocodb/src/controllers/auth/ui/emailTemplates/forgotPassword.ts → packages/nocodb/src/modules/auth/ui/emailTemplates/forgotPassword.ts

0
packages/nocodb/src/controllers/auth/ui/emailTemplates/invite.ts → packages/nocodb/src/modules/auth/ui/emailTemplates/invite.ts

0
packages/nocodb/src/controllers/auth/ui/emailTemplates/verify.ts → packages/nocodb/src/modules/auth/ui/emailTemplates/verify.ts

71
packages/nocodb/src/modules/datas/datas.module.ts

@ -1,71 +0,0 @@
import { Module } from '@nestjs/common';
import { MulterModule } from '@nestjs/platform-express';
import multer from 'multer';
import { NC_ATTACHMENT_FIELD_SIZE } from '~/constants';
import { DataTableController } from '~/controllers/data-table.controller';
import { DataTableService } from '~/services/data-table.service';
import { DataAliasController } from '~/controllers/data-alias.controller';
import { PublicDatasExportController } from '~/controllers/public-datas-export.controller';
import { PublicDatasController } from '~/controllers/public-datas.controller';
import { DatasService } from '~/services/datas.service';
import { DatasController } from '~/controllers/datas.controller';
import { BulkDataAliasController } from '~/controllers/bulk-data-alias.controller';
import { DataAliasExportController } from '~/controllers/data-alias-export.controller';
import { DataAliasNestedController } from '~/controllers/data-alias-nested.controller';
import { OldDatasController } from '~/controllers/old-datas/old-datas.controller';
import { BulkDataAliasService } from '~/services/bulk-data-alias.service';
import { DataAliasNestedService } from '~/services/data-alias-nested.service';
import { OldDatasService } from '~/controllers/old-datas/old-datas.service';
import { PublicDatasExportService } from '~/services/public-datas-export.service';
import { PublicDatasService } from '~/services/public-datas.service';
import { CalendarDatasController } from '~/controllers/calendars-datas.controller';
import { CalendarDatasService } from '~/services/calendar-datas.service';
export const dataModuleMetadata = {
imports: [
MulterModule.register({
storage: multer.diskStorage({}),
limits: {
fieldSize: NC_ATTACHMENT_FIELD_SIZE,
},
}),
],
controllers: [
...(process.env.NC_WORKER_CONTAINER !== 'true'
? [
DataTableController,
DatasController,
CalendarDatasController,
BulkDataAliasController,
DataAliasController,
DataAliasNestedController,
DataAliasExportController,
OldDatasController,
PublicDatasController,
PublicDatasExportController,
]
: []),
],
providers: [
DataTableService,
DatasService,
BulkDataAliasService,
DataAliasNestedService,
CalendarDatasService,
OldDatasService,
PublicDatasService,
PublicDatasExportService,
],
exports: [
DatasService,
BulkDataAliasService,
CalendarDatasService,
DataAliasNestedService,
OldDatasService,
PublicDatasService,
PublicDatasExportService,
],
};
@Module(dataModuleMetadata)
export class DatasModule {}

67
packages/nocodb/src/modules/global/global.module.ts

@ -1,67 +0,0 @@
import { forwardRef, Global, Module } from '@nestjs/common';
import { ExtractJwt } from 'passport-jwt';
import type { Provider } from '@nestjs/common';
import { InitMetaServiceProvider } from '~/modules/global/init-meta-service.provider';
import { EventEmitterModule } from '~/modules/event-emitter/event-emitter.module';
import { SocketGateway } from '~/gateways/socket.gateway';
import { GlobalGuard } from '~/guards/global/global.guard';
import { MetaService } from '~/meta/meta.service';
import Noco from '~/Noco';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { JwtStrategy } from '~/strategies/jwt.strategy';
import { UsersService } from '~/services/users/users.service';
import { TelemetryService } from '~/services/telemetry.service';
import { AppHooksListenerService } from '~/services/app-hooks-listener.service';
import { HookHandlerService } from '~/services/hook-handler.service';
import { UsersModule } from '~/modules/users/users.module';
import { JobsModule } from '~/modules/jobs/jobs.module';
export const JwtStrategyProvider: Provider = {
provide: JwtStrategy,
useFactory: async (usersService: UsersService, metaService: MetaService) => {
const config = metaService.config;
await Noco.initJwt();
const options = {
// ignoreExpiration: false,
jwtFromRequest: ExtractJwt.fromHeader('xc-auth'),
// expiresIn: '10h',
passReqToCallback: true,
secretOrKey: config.auth.jwt.secret,
...config.auth.jwt.options,
};
return new JwtStrategy(options, usersService);
},
inject: [UsersService, MetaService],
};
export const globalModuleMetadata = {
imports: [EventEmitterModule, forwardRef(() => UsersModule), JobsModule],
providers: [
InitMetaServiceProvider,
AppHooksService,
JwtStrategyProvider,
GlobalGuard,
SocketGateway,
AppHooksService,
AppHooksListenerService,
TelemetryService,
HookHandlerService,
],
exports: [
MetaService,
JwtStrategyProvider,
GlobalGuard,
AppHooksService,
AppHooksListenerService,
TelemetryService,
HookHandlerService,
...(process.env.NC_WORKER_CONTAINER !== 'true' ? [SocketGateway] : []),
],
};
@Global()
@Module(globalModuleMetadata)
export class GlobalModule {}

8
packages/nocodb/src/modules/jobs/jobs.module.ts

@ -1,5 +1,6 @@
import { Module } from '@nestjs/common'; import { forwardRef, Module } from '@nestjs/common';
import { BullModule } from '@nestjs/bull'; import { BullModule } from '@nestjs/bull';
import { NocoModule } from '~/modules/noco.module';
// Jobs // Jobs
import { ExportService } from '~/modules/jobs/jobs/export-import/export.service'; import { ExportService } from '~/modules/jobs/jobs/export-import/export.service';
@ -29,13 +30,10 @@ import { JobsService as FallbackJobsService } from '~/modules/jobs/fallback/jobs
import { QueueService as FallbackQueueService } from '~/modules/jobs/fallback/fallback-queue.service'; import { QueueService as FallbackQueueService } from '~/modules/jobs/fallback/fallback-queue.service';
import { JobsEventService as FallbackJobsEventService } from '~/modules/jobs/fallback/jobs-event.service'; import { JobsEventService as FallbackJobsEventService } from '~/modules/jobs/fallback/jobs-event.service';
import { JOBS_QUEUE } from '~/interface/Jobs'; import { JOBS_QUEUE } from '~/interface/Jobs';
import { MetasModule } from '~/modules/metas/metas.module';
import { DatasModule } from '~/modules/datas/datas.module';
export const JobsModuleMetadata = { export const JobsModuleMetadata = {
imports: [ imports: [
DatasModule, forwardRef(() => NocoModule),
MetasModule,
...(process.env.NC_REDIS_JOB_URL ...(process.env.NC_REDIS_JOB_URL
? [ ? [
BullModule.forRoot({ BullModule.forRoot({

2
packages/nocodb/src/modules/jobs/jobs/export-import/export.service.ts

@ -8,7 +8,7 @@ import type { BaseModelSqlv2 } from '~/db/BaseModelSqlv2';
import type { View } from '~/models'; import type { View } from '~/models';
import { Base, Hook, Model, Source } from '~/models'; import { Base, Hook, Model, Source } from '~/models';
import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2'; import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2';
import { getViewAndModelByAliasOrId } from '~/modules/datas/helpers'; import { getViewAndModelByAliasOrId } from '~/helpers/dataHelpers';
import { clearPrefix, generateBaseIdMap } from '~/helpers/exportImportHelpers'; import { clearPrefix, generateBaseIdMap } from '~/helpers/exportImportHelpers';
import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2'; import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';

111
packages/nocodb/src/modules/metas/metas.module.ts → packages/nocodb/src/modules/noco.module.ts

@ -1,7 +1,29 @@
import multer from 'multer';
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { MulterModule } from '@nestjs/platform-express'; import { MulterModule } from '@nestjs/platform-express';
import multer from 'multer';
/* Modules */
import { EventEmitterModule } from '~/modules/event-emitter/event-emitter.module';
import { JobsModule } from '~/modules/jobs/jobs.module';
/* Generic */
import { InitMetaServiceProvider } from '~/providers/init-meta-service.provider';
import { JwtStrategyProvider } from '~/providers/jwt-strategy.provider';
import { JwtStrategy } from '~/strategies/jwt.strategy';
import { SocketGateway } from '~/gateways/socket.gateway';
import { GlobalGuard } from '~/guards/global/global.guard';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { TelemetryService } from '~/services/telemetry.service';
import { AppHooksListenerService } from '~/services/app-hooks-listener.service';
import { HookHandlerService } from '~/services/hook-handler.service';
/* User */
import { UsersController } from '~/controllers/users/users.controller';
import { UsersService } from '~/services/users/users.service';
/* Metas */
import { NC_ATTACHMENT_FIELD_SIZE } from '~/constants'; import { NC_ATTACHMENT_FIELD_SIZE } from '~/constants';
import { MetaService } from '~/meta/meta.service';
import { ApiDocsController } from '~/controllers/api-docs/api-docs.controller'; import { ApiDocsController } from '~/controllers/api-docs/api-docs.controller';
import { ApiTokensController } from '~/controllers/api-tokens.controller'; import { ApiTokensController } from '~/controllers/api-tokens.controller';
import { AttachmentsController } from '~/controllers/attachments.controller'; import { AttachmentsController } from '~/controllers/attachments.controller';
@ -39,7 +61,6 @@ import { ApiTokensService } from '~/services/api-tokens.service';
import { AttachmentsService } from '~/services/attachments.service'; import { AttachmentsService } from '~/services/attachments.service';
import { AuditsService } from '~/services/audits.service'; import { AuditsService } from '~/services/audits.service';
import { SourcesService } from '~/services/sources.service'; import { SourcesService } from '~/services/sources.service';
import { BulkDataAliasService } from '~/services/bulk-data-alias.service';
import { CachesService } from '~/services/caches.service'; import { CachesService } from '~/services/caches.service';
import { CalendarsService } from '~/services/calendars.service'; import { CalendarsService } from '~/services/calendars.service';
import { ColumnsService } from '~/services/columns.service'; import { ColumnsService } from '~/services/columns.service';
@ -79,8 +100,30 @@ import { CommandPaletteController } from '~/controllers/command-palette.controll
import { ExtensionsService } from '~/services/extensions.service'; import { ExtensionsService } from '~/services/extensions.service';
import { ExtensionsController } from '~/controllers/extensions.controller'; import { ExtensionsController } from '~/controllers/extensions.controller';
export const metaModuleMetadata = { /* Datas */
import { DataTableController } from '~/controllers/data-table.controller';
import { DataTableService } from '~/services/data-table.service';
import { DataAliasController } from '~/controllers/data-alias.controller';
import { PublicDatasExportController } from '~/controllers/public-datas-export.controller';
import { PublicDatasController } from '~/controllers/public-datas.controller';
import { DatasService } from '~/services/datas.service';
import { DatasController } from '~/controllers/datas.controller';
import { BulkDataAliasController } from '~/controllers/bulk-data-alias.controller';
import { DataAliasExportController } from '~/controllers/data-alias-export.controller';
import { DataAliasNestedController } from '~/controllers/data-alias-nested.controller';
import { OldDatasController } from '~/controllers/old-datas/old-datas.controller';
import { BulkDataAliasService } from '~/services/bulk-data-alias.service';
import { DataAliasNestedService } from '~/services/data-alias-nested.service';
import { OldDatasService } from '~/controllers/old-datas/old-datas.service';
import { PublicDatasExportService } from '~/services/public-datas-export.service';
import { PublicDatasService } from '~/services/public-datas.service';
import { CalendarDatasController } from '~/controllers/calendars-datas.controller';
import { CalendarDatasService } from '~/services/calendar-datas.service';
export const nocoModuleMetadata = {
imports: [ imports: [
EventEmitterModule,
JobsModule,
MulterModule.register({ MulterModule.register({
storage: multer.diskStorage({}), storage: multer.diskStorage({}),
limits: { limits: {
@ -91,6 +134,10 @@ export const metaModuleMetadata = {
controllers: [ controllers: [
...(process.env.NC_WORKER_CONTAINER !== 'true' ...(process.env.NC_WORKER_CONTAINER !== 'true'
? [ ? [
/* Users */
UsersController,
/* Metas */
ApiDocsController, ApiDocsController,
ApiTokensController, ApiTokensController,
...(process.env.NC_SECURE_ATTACHMENTS === 'true' ...(process.env.NC_SECURE_ATTACHMENTS === 'true'
@ -129,11 +176,36 @@ export const metaModuleMetadata = {
NotificationsController, NotificationsController,
CommandPaletteController, CommandPaletteController,
ExtensionsController, ExtensionsController,
/* Datas */
DataTableController,
DatasController,
CalendarDatasController,
BulkDataAliasController,
DataAliasController,
DataAliasNestedController,
DataAliasExportController,
OldDatasController,
PublicDatasController,
PublicDatasExportController,
] ]
: []), : []),
], ],
providers: [ providers: [
/** Services */ /* Generic */
InitMetaServiceProvider,
JwtStrategyProvider,
GlobalGuard,
SocketGateway,
AppHooksService,
AppHooksListenerService,
TelemetryService,
HookHandlerService,
/* Users */
UsersService,
/* Metas */
ApiDocsService, ApiDocsService,
ApiTokensService, ApiTokensService,
AttachmentsService, AttachmentsService,
@ -168,13 +240,33 @@ export const metaModuleMetadata = {
SyncService, SyncService,
SortsService, SortsService,
SharedBasesService, SharedBasesService,
BulkDataAliasService,
NotificationsService, NotificationsService,
NotificationsGateway, NotificationsGateway,
CommandPaletteService, CommandPaletteService,
ExtensionsService, ExtensionsService,
/* Datas */
DataTableService,
DatasService,
BulkDataAliasService,
DataAliasNestedService,
CalendarDatasService,
OldDatasService,
PublicDatasService,
PublicDatasExportService,
], ],
exports: [ exports: [
/* Generic */
AppHooksService,
TelemetryService,
HookHandlerService,
JwtStrategy,
/* Users */
UsersService,
/* Metas */
MetaService,
TablesService, TablesService,
ColumnsService, ColumnsService,
FiltersService, FiltersService,
@ -193,11 +285,14 @@ export const metaModuleMetadata = {
BaseUsersService, BaseUsersService,
HooksService, HooksService,
MetaDiffsService, MetaDiffsService,
BasesService,
SourcesService, SourcesService,
UtilsService, UtilsService,
/* Datas */
DatasService,
BulkDataAliasService,
], ],
}; };
@Module(metaModuleMetadata) @Module(nocoModuleMetadata)
export class MetasModule {} export class NocoModule {}

15
packages/nocodb/src/modules/users/users.module.ts

@ -1,15 +0,0 @@
import { forwardRef, Module } from '@nestjs/common';
import { PassportModule } from '@nestjs/passport';
import { UsersService } from '~/services/users/users.service';
import { UsersController } from '~/controllers/users/users.controller';
import { MetasModule } from '~/modules/metas/metas.module';
@Module({
imports: [PassportModule, forwardRef(() => MetasModule)],
controllers: [
...(process.env.NC_WORKER_CONTAINER !== 'true' ? [UsersController] : []),
],
providers: [UsersService],
exports: [UsersService],
})
export class UsersModule {}

0
packages/nocodb/src/modules/global/init-meta-service.provider.ts → packages/nocodb/src/providers/init-meta-service.provider.ts

27
packages/nocodb/src/providers/jwt-strategy.provider.ts

@ -0,0 +1,27 @@
import { ExtractJwt } from 'passport-jwt';
import type { Provider } from '@nestjs/common';
import { MetaService } from '~/meta/meta.service';
import { UsersService } from '~/services/users/users.service';
import { JwtStrategy } from '~/strategies/jwt.strategy';
import Noco from '~/Noco';
export const JwtStrategyProvider: Provider = {
provide: JwtStrategy,
useFactory: async (usersService: UsersService, metaService: MetaService) => {
const config = metaService.config;
await Noco.initJwt();
const options = {
// ignoreExpiration: false,
jwtFromRequest: ExtractJwt.fromHeader('xc-auth'),
// expiresIn: '10h',
passReqToCallback: true,
secretOrKey: config.auth.jwt.secret,
...config.auth.jwt.options,
};
return new JwtStrategy(options, usersService);
},
inject: [UsersService, MetaService],
};

4
packages/nocodb/src/services/base-users/base-users.service.ts

@ -350,7 +350,9 @@ export class BaseUsersService {
// todo: refactor the whole function // todo: refactor the whole function
async sendInviteEmail(email: string, token: string, req: any): Promise<any> { async sendInviteEmail(email: string, token: string, req: any): Promise<any> {
try { try {
const template = (await import('./ui/emailTemplates/invite')).default; const template = (
await import('~/services/base-users/ui/emailTemplates/invite')
).default;
const emailAdapter = await NcPluginMgrv2.emailAdapter(); const emailAdapter = await NcPluginMgrv2.emailAdapter();

4
packages/nocodb/src/services/bulk-data-alias.service.ts

@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import type { PathParams } from '~/modules/datas/helpers'; import type { PathParams } from '~/helpers/dataHelpers';
import type { BaseModelSqlv2 } from '~/db/BaseModelSqlv2'; import type { BaseModelSqlv2 } from '~/db/BaseModelSqlv2';
import { getViewAndModelByAliasOrId } from '~/modules/datas/helpers'; import { getViewAndModelByAliasOrId } from '~/helpers/dataHelpers';
import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2'; import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2';
import { Model, Source } from '~/models'; import { Model, Source } from '~/models';

4
packages/nocodb/src/services/data-alias-nested.service.ts

@ -1,12 +1,12 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { UITypes } from 'nocodb-sdk'; import { UITypes } from 'nocodb-sdk';
import type { PathParams } from '~/modules/datas/helpers'; import type { PathParams } from '~/helpers/dataHelpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { PagedResponseImpl } from '~/helpers/PagedResponse';
import { import {
getColumnByIdOrName, getColumnByIdOrName,
getViewAndModelByAliasOrId, getViewAndModelByAliasOrId,
} from '~/modules/datas/helpers'; } from '~/helpers/dataHelpers';
import { Model, Source } from '~/models'; import { Model, Source } from '~/models';
import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2'; import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2';

4
packages/nocodb/src/services/datas.service.ts

@ -4,8 +4,8 @@ import * as XLSX from 'xlsx';
import papaparse from 'papaparse'; import papaparse from 'papaparse';
import { nocoExecute } from 'nc-help'; import { nocoExecute } from 'nc-help';
import type { BaseModelSqlv2 } from '~/db/BaseModelSqlv2'; import type { BaseModelSqlv2 } from '~/db/BaseModelSqlv2';
import type { PathParams } from '~/modules/datas/helpers'; import type { PathParams } from '~/helpers/dataHelpers';
import { getDbRows, getViewAndModelByAliasOrId } from '~/modules/datas/helpers'; import { getDbRows, getViewAndModelByAliasOrId } from '~/helpers/dataHelpers';
import { Base, Column, Model, Source, View } from '~/models'; import { Base, Column, Model, Source, View } from '~/models';
import { NcBaseError, NcError } from '~/helpers/catchError'; import { NcBaseError, NcError } from '~/helpers/catchError';
import getAst from '~/helpers/getAst'; import getAst from '~/helpers/getAst';

2
packages/nocodb/src/services/public-datas.service.ts

@ -11,7 +11,7 @@ import { NcError } from '~/helpers/catchError';
import getAst from '~/helpers/getAst'; import getAst from '~/helpers/getAst';
import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2'; import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2';
import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { PagedResponseImpl } from '~/helpers/PagedResponse';
import { getColumnByIdOrName } from '~/modules/datas/helpers'; import { getColumnByIdOrName } from '~/helpers/dataHelpers';
import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2'; import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2';
import { mimeIcons } from '~/utils/mimeTypes'; import { mimeIcons } from '~/utils/mimeTypes';
import { utf8ify } from '~/helpers/stringHelpers'; import { utf8ify } from '~/helpers/stringHelpers';

7
packages/nocodb/src/services/users/users.service.ts

@ -229,7 +229,7 @@ export class UsersService {
}); });
try { try {
const template = ( const template = (
await import('~/controllers/auth/ui/emailTemplates/forgotPassword') await import('~/modules/auth/ui/emailTemplates/forgotPassword')
).default; ).default;
await NcPluginMgrv2.emailAdapter().then((adapter) => await NcPluginMgrv2.emailAdapter().then((adapter) =>
adapter.mailSend({ adapter.mailSend({
@ -475,9 +475,8 @@ export class UsersService {
user = await User.getByEmail(email); user = await User.getByEmail(email);
try { try {
const template = ( const template = (await import('~/modules/auth/ui/emailTemplates/verify'))
await import('~/controllers/auth/ui/emailTemplates/verify') .default;
).default;
await ( await (
await NcPluginMgrv2.emailAdapter() await NcPluginMgrv2.emailAdapter()
).mailSend({ ).mailSend({

2
packages/nocodb/src/strategies/local.strategy.ts

@ -4,7 +4,7 @@ import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config'; import { ConfigService } from '@nestjs/config';
import { extractRolesObj } from 'nocodb-sdk'; import { extractRolesObj } from 'nocodb-sdk';
import type { AppConfig } from '~/interface/config'; import type { AppConfig } from '~/interface/config';
import { AuthService } from '~/services/auth.service'; import { AuthService } from '~/modules/auth/auth.service';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@Injectable() @Injectable()

Loading…
Cancel
Save