Skip to content

Commit

Permalink
Feat/#7192 jira integration (#7196)
Browse files Browse the repository at this point in the history
* WIP: JIRA Integration

* WIP: JIRA Integration

* Updated Jira Integration

* Removed Unused Code

* fix: Deepscan issues

* Updated Jira config file

---------

Co-authored-by: Ruslan K <[email protected]>
  • Loading branch information
badalkhatri0924 and evereq authored Nov 28, 2023
1 parent a9c84e3 commit 5d01e40
Show file tree
Hide file tree
Showing 15 changed files with 1,623 additions and 121 deletions.
11 changes: 11 additions & 0 deletions packages/common/src/interfaces/IJiraIntegrationConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Configuration options for Jira integration.
*/
export interface IJiraIntegrationConfig {
readonly appName: string;
readonly appDescription: string;
readonly appKey: string;
readonly baseUrl: string;
readonly vendorName: string;
readonly vendorUrl: string;
}
1 change: 1 addition & 0 deletions packages/common/src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ export * from './IUpworkConfig';
export * from './IWasabiConfig';
export * from './IHubstaffConfig';
export * from './IJitsuConfig';
export * from './IJiraIntegrationConfig';
12 changes: 2 additions & 10 deletions packages/config/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,9 @@ import linkedin from './linkedin';
import microsoft from './microsoft';
import setting from './setting';
import twitter from './twitter';
import jira from './jira';

/**
* This array contains individual configuration modules for different social login providers.
*/
export default [
app,
facebook,
github,
google,
linkedin,
microsoft,
setting,
twitter
];
export default [app, facebook, github, google, linkedin, microsoft, setting, twitter, jira];
17 changes: 17 additions & 0 deletions packages/config/src/config/jira.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { registerAs } from '@nestjs/config';
import { IJiraIntegrationConfig } from '@gauzy/common';

/**
* Register Jira configuration using @nestjs/config
*/
export default registerAs(
'jira',
(): IJiraIntegrationConfig => ({
appName: process.env.GAUZY_JIRA_APP_NAME,
appDescription: process.env.GAUZY_JIRA_APP_DESCRIPTION,
appKey: process.env.GAUZY_JIRA_APP_KEY,
baseUrl: process.env.GAUZY_JIRA_APP_BASE_URL,
vendorName: process.env.GAUZY_JIRA_APP_BASE_VENDOR_NAME,
vendorUrl: process.env.GAUZY_JIRA_APP_BASE_VENDOR_URL
})
);
10 changes: 10 additions & 0 deletions packages/config/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ export const environment: IEnvironment = {
webhookUrl: process.env.GAUZY_GITHUB_WEBHOOK_URL || `${process.env.API_BASE_URL}/api/integration/github/webhook`
},

jira: {
/** Jira Integration Configuration */
appName: process.env.GAUZY_JIRA_APP_NAME,
appDescription: process.env.GAUZY_JIRA_APP_DESCRIPTION,
appKey: process.env.GAUZY_JIRA_APP_KEY,
baseUrl: process.env.GAUZY_JIRA_APP_BASE_URL,
vendorName: process.env.GAUZY_JIRA_APP_BASE_VENDOR_NAME,
vendorUrl: process.env.GAUZY_JIRA_APP_BASE_VENDOR_URL
},

fiverrConfig: {
clientId: process.env.FIVERR_CLIENT_ID,
clientSecret: process.env.FIVERR_CLIENT_SECRET
Expand Down
10 changes: 10 additions & 0 deletions packages/config/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ export const environment: IEnvironment = {
webhookUrl: process.env.GAUZY_GITHUB_WEBHOOK_URL || `${process.env.API_BASE_URL}/api/integration/github/webhook`
},

jira: {
/** Jira Integration Configuration */
appName: process.env.GAUZY_JIRA_APP_NAME,
appDescription: process.env.GAUZY_JIRA_APP_DESCRIPTION,
appKey: process.env.GAUZY_JIRA_APP_KEY,
baseUrl: process.env.GAUZY_JIRA_APP_BASE_URL,
vendorName: process.env.GAUZY_JIRA_APP_BASE_VENDOR_NAME,
vendorUrl: process.env.GAUZY_JIRA_APP_BASE_VENDOR_URL
},

fiverrConfig: {
clientId: process.env.FIVERR_CLIENT_ID,
clientSecret: process.env.FIVERR_CLIENT_SECRET
Expand Down
2 changes: 2 additions & 0 deletions packages/config/src/environments/ienvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
IUnleashConfig,
IUpworkConfig,
IWasabiConfig,
IJiraIntegrationConfig
} from '@gauzy/common';

export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
Expand Down Expand Up @@ -97,6 +98,7 @@ export interface IEnvironment {
wasabiConfig?: IWasabiConfig;
cloudinaryConfig?: ICloudinaryConfig;
github: IGithubIntegrationConfig /** Github Configuration */;
jira: IJiraIntegrationConfig /** Jira Configuration */;
fiverrConfig: IFiverrConfig;
keycloakConfig: IKeycloakConfig;
auth0Config: IAuth0Config;
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"apollo-server-core": "^3.10.1",
"apollo-server-express": "^3.5.0",
"apollo-server-fastify": "^3.5.0",
"atlassian-connect-express": "^8.5.0",
"app-root-path": "^3.0.0",
"archiver": "^5.3.0",
"aws-sdk": "^2.1082.0",
Expand Down
113 changes: 53 additions & 60 deletions packages/core/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
import { HttpException, Module } from '@nestjs/common';
import { APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core';
import { MulterModule } from '@nestjs/platform-express';
import {
ThrottlerGuard,
ThrottlerModule,
ThrottlerModuleOptions,
} from '@nestjs/throttler';
import { ThrottlerGuard, ThrottlerModule, ThrottlerModuleOptions } from '@nestjs/throttler';
import { SentryInterceptor, SentryModule } from '@ntegral/nestjs-sentry';
import {
ServeStaticModule,
ServeStaticModuleOptions,
} from '@nestjs/serve-static';
import { ServeStaticModule, ServeStaticModuleOptions } from '@nestjs/serve-static';
import { HeaderResolver, I18nModule } from 'nestjs-i18n';
import { Integrations as SentryIntegrations } from '@sentry/node';
import { Integrations as TrackingIntegrations } from '@sentry/tracing';
import {
initialize as initializeUnleash,
InMemStorageProvider,
UnleashConfig,
} from 'unleash-client';
import { initialize as initializeUnleash, InMemStorageProvider, UnleashConfig } from 'unleash-client';
import { LanguagesEnum } from '@gauzy/contracts';
import { ConfigService, environment } from '@gauzy/config';
import * as path from 'path';
import * as moment from 'moment';
import { ProbotModule } from '@gauzy/integration-github';
import { JiraModule } from '@gauzy/integration-jira';
import { CandidateInterviewersModule } from './candidate-interviewers/candidate-interviewers.module';
import { CandidateSkillModule } from './candidate-skill/candidate-skill.module';
import { InvoiceModule } from './invoice/invoice.module';
Expand Down Expand Up @@ -153,7 +143,7 @@ import { TaskLinkedIssueModule } from './tasks/linked-issue/task-linked-issue.mo
import { OrganizationTaskSettingModule } from './organization-task-setting/organization-task-setting.module';
import { TaskEstimationModule } from './tasks/estimation/task-estimation.module';
import { JitsuAnalyticsModule } from './jitsu-analytics/jitsu-analytics.module';
const { unleashConfig, github, jitsu } = environment;
const { unleashConfig, github, jitsu, jira } = environment;

if (unleashConfig.url) {
const unleashInstanceConfig: UnleashConfig = {
Expand All @@ -167,18 +157,16 @@ if (unleashConfig.url) {
disableMetrics: false,

// we may use Redis storage provider instead of in memory
storageProvider: new InMemStorageProvider(),
storageProvider: new InMemStorageProvider()
};

if (unleashConfig.apiKey) {
unleashInstanceConfig.customHeaders = {
Authorization: unleashConfig.apiKey,
Authorization: unleashConfig.apiKey
};
}

console.log(
`Using Unleash Config: ${JSON.stringify(unleashInstanceConfig)}`
);
console.log(`Using Unleash Config: ${JSON.stringify(unleashInstanceConfig)}`);

const instance = initializeUnleash(unleashInstanceConfig);

Expand All @@ -190,9 +178,7 @@ if (unleashConfig.url) {
instance.on('error', console.error);
instance.on('warn', console.log);
} else {
console.log(
'Unleash Client Not Registered. UNLEASH_API_URL configuration is not provided.'
);
console.log('Unleash Client Not Registered. UNLEASH_API_URL configuration is not provided.');
}

const sentryIntegrations = [];
Expand All @@ -215,40 +201,36 @@ if (environment.sentry && environment.sentry.dsn) {
@Module({
imports: [
ServeStaticModule.forRootAsync({
useFactory: async (
configService: ConfigService
): Promise<ServeStaticModuleOptions[]> => {
useFactory: async (configService: ConfigService): Promise<ServeStaticModuleOptions[]> => {
return await resolveServeStaticPath(configService);
},
inject: [ConfigService],
imports: [],
imports: []
}),
MulterModule.register(),
I18nModule.forRoot({
fallbackLanguage: LanguagesEnum.ENGLISH,
loaderOptions: {
path: path.resolve(__dirname, 'i18n/'),
watch: !environment.production,
watch: !environment.production
},
resolvers: [new HeaderResolver(['language'])],
resolvers: [new HeaderResolver(['language'])]
}),
...(environment.sentry && environment.sentry.dsn
? [
SentryModule.forRoot({
dsn: environment.sentry.dsn,
debug: !environment.production,
environment: environment.production
? 'production'
: 'development',
// TODO: we should use some internal function which returns version of Gauzy
release: 'gauzy@' + process.env.npm_package_version,
logLevels: ['error'],
integrations: sentryIntegrations,
tracesSampleRate: process.env.SENTRY_TRACES_SAMPLE_RATE
? parseInt(process.env.SENTRY_TRACES_SAMPLE_RATE)
: 0.01,
}),
]
SentryModule.forRoot({
dsn: environment.sentry.dsn,
debug: !environment.production,
environment: environment.production ? 'production' : 'development',
// TODO: we should use some internal function which returns version of Gauzy
release: 'gauzy@' + process.env.npm_package_version,
logLevels: ['error'],
integrations: sentryIntegrations,
tracesSampleRate: process.env.SENTRY_TRACES_SAMPLE_RATE
? parseInt(process.env.SENTRY_TRACES_SAMPLE_RATE)
: 0.01
})
]
: []),
// Probot Configuration
ProbotModule.forRoot({
Expand All @@ -261,7 +243,18 @@ if (environment.sentry && environment.sentry.dsn) {
appId: github.appId,
privateKey: github.appPrivateKey,
webhookSecret: github.webhookSecret
},
}
}),
JiraModule.forRoot({
isGlobal: true,
config: {
appName: jira.appName,
appDescription: jira.appDescription,
appKey: jira.appKey,
baseUrl: jira.baseUrl,
vendorName: jira.vendorName,
vendorUrl: jira.vendorUrl
}
}),
/** Jitsu Configuration */
JitsuAnalyticsModule.forRoot({
Expand All @@ -275,10 +268,10 @@ if (environment.sentry && environment.sentry.dsn) {
ThrottlerModule.forRootAsync({
inject: [ConfigService],
useFactory: (config: ConfigService): ThrottlerModuleOptions =>
({
ttl: config.get('THROTTLE_TTL'),
limit: config.get('THROTTLE_LIMIT'),
} as ThrottlerModuleOptions),
({
ttl: config.get('THROTTLE_TTL'),
limit: config.get('THROTTLE_LIMIT')
} as ThrottlerModuleOptions)
}),
CoreModule,
AuthModule,
Expand Down Expand Up @@ -403,18 +396,18 @@ if (environment.sentry && environment.sentry.dsn) {
IssueTypeModule,
TaskLinkedIssueModule,
OrganizationTaskSettingModule,
TaskEstimationModule,
TaskEstimationModule
],
controllers: [AppController],
providers: [
AppService,
{
provide: APP_GUARD,
useClass: ThrottlerGuard,
useClass: ThrottlerGuard
},
{
provide: APP_INTERCEPTOR,
useClass: TransformInterceptor,
useClass: TransformInterceptor
},
{
provide: APP_INTERCEPTOR,
Expand All @@ -423,21 +416,21 @@ if (environment.sentry && environment.sentry.dsn) {
filters: [
{
type: HttpException,
filter: (exception: HttpException) => 500 > exception.getStatus(), // Only report 500 errors
},
],
}),
},
filter: (exception: HttpException) => 500 > exception.getStatus() // Only report 500 errors
}
]
})
}
],
exports: [],
exports: []
})
export class AppModule {
constructor() {
// Set Monday as start of the week
moment.locale(LanguagesEnum.ENGLISH, {
week: {
dow: 1,
},
dow: 1
}
});
moment.locale(LanguagesEnum.ENGLISH);
}
Expand Down
Loading

0 comments on commit 5d01e40

Please sign in to comment.