Skip to content

Commit

Permalink
Merge pull request #8774 from ever-co/fix/packages-build
Browse files Browse the repository at this point in the history
[Fix] Packages Build
  • Loading branch information
rahul-rocket authored Feb 12, 2025
2 parents 9f17ba7 + dbde84c commit bd6937d
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 33 deletions.
7 changes: 5 additions & 2 deletions apps/desktop-api/src/app/database.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const dbPath = process.env.GAUZY_USER_PATH ? `${process.env.GAUZY_USER_PATH}/gau
logger: 'file', //Removes console logging, instead logs all queries in a file ormlogs.log
synchronize: true,
entities: coreEntities
})
}),
inject: []
}),
// MikroORM DB Config (SQLite3)
MikroOrmModule.forRootAsync({
Expand All @@ -30,7 +31,9 @@ const dbPath = process.env.GAUZY_USER_PATH ? `${process.env.GAUZY_USER_PATH}/gau
entities: coreEntities,
namingStrategy: EntityCaseNamingStrategy,
debug: ['query'] // by default set to false only
})
}),
driver: BetterSqliteDriver,
inject: []
})
]
})
Expand Down
6 changes: 3 additions & 3 deletions packages/config/src/lib/database.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as path from 'path';
import * as chalk from 'chalk';
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
import { MikroOrmModuleOptions } from '@mikro-orm/nestjs';
import { EntityCaseNamingStrategy } from '@mikro-orm/core';
Expand All @@ -8,9 +6,11 @@ import { BetterSqliteDriver, Options as MikroOrmBetterSqliteOptions } from '@mik
import { PostgreSqlDriver, Options as MikroOrmPostgreSqlOptions } from '@mikro-orm/postgresql';
import { Options as MikroOrmMySqlOptions, MySqlDriver } from '@mikro-orm/mysql';
import { DataSourceOptions } from 'typeorm';
import { KnexModuleOptions } from 'nest-knexjs';
import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions';
import { MysqlConnectionOptions } from 'typeorm/driver/mysql/MysqlConnectionOptions';
import { KnexModuleOptions } from 'nest-knexjs';
import * as path from 'path';
import * as chalk from 'chalk';
import { DatabaseTypeEnum, getLoggingMikroOptions, getLoggingOptions, getTlsOptions } from './database-helpers';

/**
Expand Down
8 changes: 3 additions & 5 deletions packages/core/src/lib/bootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ startTracing(); // Start tracing if OTEL is enabled.
import { ConflictException, INestApplication, Type } from '@nestjs/common';
import { NestFactory, Reflector } from '@nestjs/core';
import { NestExpressApplication } from '@nestjs/platform-express';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { EventSubscriber } from '@mikro-orm/core';
import { useContainer } from 'class-validator';
import * as helmet from 'helmet';
Expand All @@ -51,6 +50,7 @@ import { SharedModule } from '../shared/shared.module';
import { AppService } from '../app/app.service';
import { AppModule } from '../app/app.module';
import { configureRedisSession } from './redis-store';
import { setupSwagger } from './swagger';

/**
* Bootstrap the NestJS application, configuring various settings and initializing the server.
Expand Down Expand Up @@ -161,10 +161,8 @@ export async function bootstrap(pluginConfig?: Partial<ApplicationPluginConfig>)
console.log(chalk.green(`Configured Port: ${port}`));

// Configure Swagger for API documentation
const options = new DocumentBuilder().setTitle('Gauzy API').setVersion('1.0').addBearerAuth().build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('swg', app, document);
console.log(chalk.green(`Swagger UI available at http://${host}:${port}/swg`));
const swaggerPath = await setupSwagger(app);
console.log(chalk.green(`Swagger documentation available at http://${host}:${port}/${swaggerPath}`));

// Configure Atlassian Connect Express
// const addon = ac(express());
Expand Down
39 changes: 39 additions & 0 deletions packages/core/src/lib/bootstrap/swagger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { INestApplication } from '@nestjs/common';
import { SwaggerModule, DocumentBuilder, SwaggerDocumentOptions, SwaggerCustomOptions } from '@nestjs/swagger';

/**
* Sets up and configures Swagger API documentation for the given NestJS application.
*
* This function creates a Swagger configuration using the DocumentBuilder by setting the title,
* description, version, and enabling bearer authentication. It then generates the Swagger document
* with any additional options and sets up the Swagger UI at the specified endpoint.
*
* @param {INestApplication} app - The NestJS application instance.
* @returns {Promise<string>} A promise that resolves to the Swagger documentation path.
*/
export const setupSwagger = async (app: INestApplication): Promise<string> => {
const config = new DocumentBuilder()
.setTitle('Gauzy API')
.setDescription('Gauzy API Documentation')
.setVersion('1.0')
.addBearerAuth()
.build();

// Swagger document options (if needed, can add additional options here)
const options: SwaggerDocumentOptions = {};

// Generate the Swagger document from the app instance and configuration
const document = SwaggerModule.createDocument(app, config, options);

// Custom options for the Swagger UI (e.g., custom CSS, custom site title, etc.)
const customOptions: SwaggerCustomOptions = {};

// Define the Swagger endpoint path
const swaggerPath = 'docs';

// Setup Swagger UI at the `/docs` endpoint
SwaggerModule.setup(swaggerPath, app, document, customOptions);

// Return the Swagger path
return swaggerPath;
};
18 changes: 9 additions & 9 deletions packages/core/src/lib/database/database.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,39 @@ import { ConnectionEntityManager } from './connection-entity-manager';
* @type {MikroORMModuleOptions}
*/
MikroOrmModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
// Use useFactory, useClass, or useExisting
useFactory: async (configService: ConfigService) => {
const dbMikroOrmConnectionOptions = configService.getConfigValue('dbMikroOrmConnectionOptions');
return dbMikroOrmConnectionOptions;
}
},
imports: [ConfigModule],
inject: [ConfigService]
}),
/**
* Configuration for TypeORM database connection.
*
* @type {TypeOrmModuleOptions}
*/
TypeOrmModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
// Use useFactory, useClass, or useExisting
useFactory: async (configService: ConfigService) => {
const dbConnectionOptions = configService.getConfigValue('dbConnectionOptions');
return dbConnectionOptions;
}
},
imports: [ConfigModule],
inject: [ConfigService]
}),
/**
* Configure the Knex.js module for the application using asynchronous options.
*/
KnexModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
// Use useFactory, useClass, or useExisting
useFactory: async (configService: ConfigService) => {
const dbKnexConnectionOptions = configService.getConfigValue('dbKnexConnectionOptions');
return dbKnexConnectionOptions;
}
},
imports: [ConfigModule],
inject: [ConfigService]
})
],
providers: [ConnectionEntityManager],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class InputFilterComponent extends DefaultFilter implements OnInit, OnDes
this.subscription = this.inputControl.valueChanges
.pipe(
// Apply a debounce time to reduce the frequency of value changes
debounceTime(this.delay),
debounceTime(this.debounceTime),
// Ensure distinct values to avoid redundant operations
distinctUntilChanged(),
// Use tap to perform a side effect, invoking the filterFunction of the column
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { debounceTime, distinctUntilChanged, tap } from 'rxjs/operators';
import { Subscription } from 'rxjs/internal/Subscription';
Expand Down Expand Up @@ -27,7 +27,7 @@ import { DefaultFilter } from 'angular2-smart-table';
</div>
`
})
export class RangeFilterComponent extends DefaultFilter implements OnInit, OnDestroy, OnChanges {
export class RangeFilterComponent extends DefaultFilter implements OnInit, OnDestroy {
public rangeControl = new FormGroup({
min: new FormControl(),
max: new FormControl()
Expand All @@ -42,7 +42,7 @@ export class RangeFilterComponent extends DefaultFilter implements OnInit, OnDes
// Subscribe to both min and max value changes
this.subscription = this.rangeControl.valueChanges
.pipe(
debounceTime(this.delay), // Reduce unnecessary requests
debounceTime(this.debounceTime), // Reduce unnecessary requests
distinctUntilChanged(), // Avoid redundant filtering
tap(({ min, max }) => {
if (min !== null || max !== null) {
Expand All @@ -53,8 +53,6 @@ export class RangeFilterComponent extends DefaultFilter implements OnInit, OnDes
.subscribe();
}

ngOnChanges(changes: SimpleChanges) {}

ngOnDestroy() {
// Cleanup subscription to avoid memory leaks
this.subscription.unsubscribe();
Expand Down
46 changes: 38 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2042,8 +2042,6 @@
version "7.26.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.26.3.tgz#e29f01b6de302c7c2c794277a48f04a9ca7f03bc"
integrity sha512-7CAHcQ58z2chuXPWblnn1K6rLDnDWieghSOEmqQsrBenH0P9InCUtOJYD89pvngljmZlJcz3fcmgYsXFNGa1ZQ==
dependencies:
"@babel/helper-plugin-utils" "^7.25.9"

"@babel/plugin-transform-export-namespace-from@^7.24.7", "@babel/plugin-transform-export-namespace-from@^7.25.8", "@babel/plugin-transform-export-namespace-from@^7.25.9":
version "7.25.9"
Expand Down Expand Up @@ -3609,9 +3607,9 @@
optionalDependencies:
global-agent "^3.0.0"

"@electron/node-gyp@git+https://github.com/electron/node-gyp.git#06b29aafb7708acef8b3669835c8a7857ebc92d2":
"@electron/node-gyp@https://github.com/electron/node-gyp#06b29aafb7708acef8b3669835c8a7857ebc92d2":
version "10.2.0-electron.1"
resolved "git+https://github.com/electron/node-gyp.git#06b29aafb7708acef8b3669835c8a7857ebc92d2"
resolved "https://github.com/electron/node-gyp#06b29aafb7708acef8b3669835c8a7857ebc92d2"
dependencies:
env-paths "^2.2.0"
exponential-backoff "^3.1.1"
Expand Down Expand Up @@ -11761,7 +11759,14 @@
resolved "https://registry.yarnpkg.com/@types/i18n/-/i18n-0.12.0.tgz#ea4e247c2da05a35002d7535d339c912c4513549"
integrity sha512-3OlOD518lF2IQmZndRvoO5ZJzgUowLPIRMH4T8LTjTkgbZwZlKMR52/KLml0dJN/Bt6e9R10NxzjOQnDG2DDgg==

"@types/ioredis4@npm:@types/ioredis@^4.28.10", "@types/ioredis@^4.27.1":
"@types/ioredis4@npm:@types/ioredis@^4.28.10":
version "4.28.10"
resolved "https://registry.yarnpkg.com/@types/ioredis/-/ioredis-4.28.10.tgz#40ceb157a4141088d1394bb87c98ed09a75a06ff"
integrity sha512-69LyhUgrXdgcNDv7ogs1qXZomnfOEnSmrmMFqKgt1XMJxmoOSG/u3wYy13yACIfKuMJ8IhKgHafDO3sx19zVQQ==
dependencies:
"@types/node" "*"

"@types/ioredis@^4.27.1":
version "4.28.10"
resolved "https://registry.yarnpkg.com/@types/ioredis/-/ioredis-4.28.10.tgz#40ceb157a4141088d1394bb87c98ed09a75a06ff"
integrity sha512-69LyhUgrXdgcNDv7ogs1qXZomnfOEnSmrmMFqKgt1XMJxmoOSG/u3wYy13yACIfKuMJ8IhKgHafDO3sx19zVQQ==
Expand Down Expand Up @@ -34370,7 +34375,7 @@ string-similarity@^4.0.1:
resolved "https://registry.yarnpkg.com/string-similarity/-/string-similarity-4.0.4.tgz#42d01ab0b34660ea8a018da8f56a3309bb8b2a5b"
integrity sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ==

"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand All @@ -34388,6 +34393,15 @@ string-width@^1.0.1:
is-fullwidth-code-point "^1.0.0"
strip-ansi "^3.0.0"

"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^2.0.0, string-width@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e"
Expand Down Expand Up @@ -34493,7 +34507,7 @@ stringify-object@^3.3.0:
is-obj "^1.0.1"
is-regexp "^1.0.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -34521,6 +34535,13 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0:
dependencies:
ansi-regex "^4.1.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1, strip-ansi@^7.1.0:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -37398,7 +37419,7 @@ wordwrap@~0.0.2:
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"
integrity sha512-1tMA907+V4QmxV7dbRvb4/8MaRALK6q9Abid3ndMYnbyo8piisCmeONVqVSXqQA3KaP4SLt5b7ud6E2sqP8TFw==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand Down Expand Up @@ -37433,6 +37454,15 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down

0 comments on commit bd6937d

Please sign in to comment.