Skip to content

Commit

Permalink
Merge pull request #8661 from ever-co/develop
Browse files Browse the repository at this point in the history
Stage
  • Loading branch information
rahul-rocket authored Dec 31, 2024
2 parents 5e6087d + 7165390 commit eeb4720
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 62 deletions.
25 changes: 0 additions & 25 deletions packages/plugins/integration-github/.eslintrc.json

This file was deleted.

3 changes: 3 additions & 0 deletions packages/plugins/integration-github/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @gauzy/integration-github

## [Unreleased]
19 changes: 19 additions & 0 deletions packages/plugins/integration-github/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const baseConfig = require('../../../.eslintrc.json');

module.exports = [
...baseConfig,
{
files: ['**/*.json'],
rules: {
'@nx/dependency-checks': [
'error',
{
ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}']
}
]
},
languageOptions: {
parser: require('jsonc-eslint-parser')
}
}
];
1 change: 0 additions & 1 deletion packages/plugins/integration-github/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
export default {
displayName: 'plugin-integration-github',
preset: '../../../jest.preset.js',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Controller, Get, HttpException, HttpStatus, Query, Res } from '@nestjs/common';
import { Response } from 'express';
import { IGithubIntegrationConfig, Public } from '@gauzy/common';
import { ConfigService } from '@gauzy/config';
import { IGithubAppInstallInput } from '@gauzy/contracts';
import { IGithubIntegrationConfig, Public } from '@gauzy/common';

@Controller('/integration/github')
export class GitHubAuthorizationController {
Expand Down
44 changes: 28 additions & 16 deletions packages/plugins/integration-github/src/lib/github/github.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MiddlewareConsumer, Module, NestModule, RequestMethod, forwardRef } from '@nestjs/common';
import { HttpModule } from '@nestjs/axios';
import { MiddlewareConsumer, Module, NestModule, RequestMethod, forwardRef } from '@nestjs/common';
import { CqrsModule } from '@nestjs/cqrs';
import { TypeOrmModule } from '@nestjs/typeorm';
import { MikroOrmModule } from '@mikro-orm/nestjs';
Expand All @@ -12,7 +12,7 @@ import {
PluginCommonModule,
RolePermissionModule
} from '@gauzy/core';
import { environment } from '@gauzy/config';
import { ConfigModule, environment } from '@gauzy/config';
import { ProbotModule } from '../probot/probot.module';
import { CommandHandlers } from './commands/handlers';
import { GithubEventSubscriber } from './github-event.subscriber';
Expand All @@ -30,25 +30,26 @@ import { GithubRepositoryService } from './repository/github-repository.service'
import { OrganizationGithubRepository } from './repository/github-repository.entity';
import { OrganizationGithubRepositoryIssue } from './repository/issue/github-repository-issue.entity';
import { GithubRepositoryIssueService } from './repository/issue/github-repository-issue.service';
import { TypeOrmOrganizationGithubRepositoryRepository } from './repository/repository';
import { TypeOrmOrganizationGithubRepositoryIssueRepository } from './repository/issue/repository';
import { TypeOrmOrganizationGithubRepositoryRepository } from './repository/repository/type-orm-organization-github-repository.repository';
import { TypeOrmOrganizationGithubRepositoryIssueRepository } from './repository/issue/repository/type-orm-github-repository-issue.repository';
import { MikroOrmOrganizationGithubRepositoryRepository } from './repository/repository/mikro-orm-organization-github-repository.repository';
import { MikroOrmOrganizationGithubRepositoryIssueRepository } from './repository/issue/repository/mikro-orm-github-repository-issue.repository';

//
// Import the Probot configuration module
const { github } = environment;

@Module({
imports: [
HttpModule,
CqrsModule,
TypeOrmModule.forFeature([OrganizationGithubRepository, OrganizationGithubRepositoryIssue]),
MikroOrmModule.forFeature([OrganizationGithubRepository, OrganizationGithubRepositoryIssue]),
PluginCommonModule,
RolePermissionModule,
forwardRef(() => OrganizationProjectModule),
forwardRef(() => IntegrationModule),
forwardRef(() => IntegrationTenantModule),
forwardRef(() => IntegrationSettingModule),
forwardRef(() => IntegrationMapModule),
ConfigModule,
TypeOrmModule.forFeature([
OrganizationGithubRepository,
OrganizationGithubRepositoryIssue
]),
MikroOrmModule.forFeature([
OrganizationGithubRepository,
OrganizationGithubRepositoryIssue
]),
// Probot Configuration
ProbotModule.forRoot({
isGlobal: true,
Expand All @@ -62,7 +63,16 @@ const { github } = environment;
privateKey: github.appPrivateKey,
webhookSecret: github.webhookSecret
}
})
}),
PluginCommonModule,
RolePermissionModule,
CqrsModule,
forwardRef(() => OrganizationProjectModule),
forwardRef(() => IntegrationModule),
forwardRef(() => IntegrationTenantModule),
forwardRef(() => IntegrationSettingModule),
forwardRef(() => IntegrationMapModule),

],
controllers: [
GitHubAuthorizationController,
Expand All @@ -84,7 +94,9 @@ const { github } = environment;
GithubRepositoryIssueService,
// Define repositories heres
TypeOrmOrganizationGithubRepositoryRepository,
MikroOrmOrganizationGithubRepositoryRepository,
TypeOrmOrganizationGithubRepositoryIssueRepository,
MikroOrmOrganizationGithubRepositoryIssueRepository,
// Define handlers heres
...CommandHandlers
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
import { IntegrationService, IntegrationTenantUpdateOrCreateCommand, RequestContext } from '@gauzy/core';
import { DEFAULT_ENTITY_SETTINGS, ISSUE_TIED_ENTITIES } from './github-entity-settings';
import { GITHUB_ACCESS_TOKEN_URL } from './github.config';

// Import the Probot configuration module
const { github } = environment;

@Injectable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
MultiORMOneToMany,
ColumnNumericTransformerPipe
} from '@gauzy/core';
import { MikroOrmOrganizationGithubRepositoryRepository } from './repository/mikro-orm-organization-github-repository.repository';
import { OrganizationGithubRepositoryIssue } from './issue/github-repository-issue.entity';
import { MikroOrmOrganizationGithubRepositoryRepository } from './repository/mikro-orm-organization-github-repository.repository';

@MultiORMEntity('organization_github_repository', {
mikroOrmRepository: () => MikroOrmOrganizationGithubRepositoryRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@ import { CommandBus } from '@nestjs/cqrs';
import { IIntegrationMapSyncRepository, IOrganizationGithubRepository } from '@gauzy/contracts';
import { TenantAwareCrudService } from '@gauzy/core';
import { OrganizationGithubRepository } from './github-repository.entity';
import { IntegrationSyncGithubRepositoryCommand } from '../commands';
import {
MikroOrmOrganizationGithubRepositoryRepository,
TypeOrmOrganizationGithubRepositoryRepository
} from './repository';
import { IntegrationSyncGithubRepositoryCommand } from '../commands/integration-sync-github-repository.command';
import { MikroOrmOrganizationGithubRepositoryRepository } from './repository/mikro-orm-organization-github-repository.repository';
import { TypeOrmOrganizationGithubRepositoryRepository } from './repository/type-orm-organization-github-repository.repository';

@Injectable()
export class GithubRepositoryService extends TenantAwareCrudService<OrganizationGithubRepository> {
private readonly logger = new Logger('GithubRepositoryService');

constructor(
readonly typeOrmOrganizationGithubRepositoryRepository: TypeOrmOrganizationGithubRepositoryRepository,
readonly mikroOrmOrganizationGithubRepositoryRepository: MikroOrmOrganizationGithubRepositoryRepository,
private readonly _commandBus: CommandBus,
typeOrmOrganizationGithubRepositoryRepository: TypeOrmOrganizationGithubRepositoryRepository,
mikroOrmOrganizationGithubRepositoryRepository: MikroOrmOrganizationGithubRepositoryRepository
) {
super(typeOrmOrganizationGithubRepositoryRepository, mikroOrmOrganizationGithubRepositoryRepository);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Injectable } from '@nestjs/common';
import { TenantAwareCrudService } from '@gauzy/core';
import { OrganizationGithubRepositoryIssue } from './github-repository-issue.entity';
import {
MikroOrmOrganizationGithubRepositoryIssueRepository,
TypeOrmOrganizationGithubRepositoryIssueRepository
} from './repository';
import { MikroOrmOrganizationGithubRepositoryIssueRepository } from './repository/mikro-orm-github-repository-issue.repository';
import { TypeOrmOrganizationGithubRepositoryIssueRepository } from './repository/type-orm-github-repository-issue.repository';

@Injectable()
export class GithubRepositoryIssueService extends TenantAwareCrudService<OrganizationGithubRepositoryIssue> {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,26 @@ import { OrganizationGithubRepository } from './github/repository/github-reposit
import { OrganizationGithubRepositoryIssue } from './github/repository/issue/github-repository-issue.entity';

@Plugin({
/**
* An array of modules that will be imported and registered with the plugin.
*/
imports: [GithubModule],
/**
* An array of Entity classes. The plugin (or ORM) will
* register these entities for use within the application.
*/
entities: [OrganizationGithubRepository, OrganizationGithubRepositoryIssue],
/**
* A callback that receives the main plugin configuration object and allows
* custom modifications before returning the final configuration.
*
* @param {ApplicationPluginConfig} config - The initial plugin configuration object.
* @returns {ApplicationPluginConfig} - The modified plugin configuration object.
*
* In this example, we're adding a custom relation field (`proposals`) to the `Tag` entity.
*/
configuration: (config: ApplicationPluginConfig) => {
// Add a custom field to the OrganizationProject entity
config.customFields.OrganizationProject.push({
name: 'repository',
type: 'relation',
Expand All @@ -17,6 +34,8 @@ import { OrganizationGithubRepositoryIssue } from './github/repository/issue/git
nullable: true, // Determines whether the relation is nullable.
onDelete: 'SET NULL' // Defines the database cascade action on delete.
});

// Add a custom field to the OrganizationProject entity
config.customFields.OrganizationProject.push({
name: 'repositoryId',
type: 'string',
Expand Down
5 changes: 2 additions & 3 deletions packages/plugins/integration-github/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": false,
"noImplicitOverride": false,
"noPropertyAccessFromIndexSignature": false,
"noImplicitReturns": false,
"noFallthroughCasesInSwitch": false
"noFallthroughCasesInSwitch": false,
"noPropertyAccessFromIndexSignature": false
},
"files": [],
"include": [],
Expand Down

0 comments on commit eeb4720

Please sign in to comment.