Skip to content

Commit

Permalink
Merge pull request #8656 from ever-co/fix/job-proposal-plugin
Browse files Browse the repository at this point in the history
[Fix] Job Proposal Plugin
  • Loading branch information
rahul-rocket authored Dec 31, 2024
2 parents 31646a1 + b954548 commit d18ae2a
Show file tree
Hide file tree
Showing 20 changed files with 288 additions and 119 deletions.
4 changes: 2 additions & 2 deletions packages/contracts/src/lib/proposal.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export enum ProposalStatusEnum {
export interface IProposalBase extends IBasePerTenantAndOrganizationEntityModel, ITaggable {
jobPostUrl?: string;
valueDate?: Date;
jobPostContent?: string;
proposalContent?: string;
jobPostContent: string;
proposalContent: string;
status?: ProposalStatusEnum;
}

Expand Down
25 changes: 0 additions & 25 deletions packages/plugins/integration-ai/.eslintrc.json

This file was deleted.

19 changes: 19 additions & 0 deletions packages/plugins/integration-ai/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-ai/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
export default {
displayName: 'plugin-integration-ai',
preset: '../../../jest.preset.js',
Expand Down
5 changes: 2 additions & 3 deletions packages/plugins/integration-ai/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
25 changes: 0 additions & 25 deletions packages/plugins/job-proposal/.eslintrc.json

This file was deleted.

19 changes: 19 additions & 0 deletions packages/plugins/job-proposal/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/job-proposal/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
export default {
displayName: 'plugin-job-proposal',
preset: '../../../jest.preset.js',
Expand Down
18 changes: 18 additions & 0 deletions packages/plugins/job-proposal/src/lib/job-proposal.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,26 @@ import { EmployeeProposalTemplate } from './proposal-template/employee-proposal-
import { ProposalSeederService } from './proposal/proposal-seeder.service';

@Plugin({
/**
* An array of modules that will be imported and registered with the plugin.
*/
imports: [ProposalModule, EmployeeProposalTemplateModule],
/**
* An array of Entity classes. The plugin (or ORM) will
* register these entities for use within the application.
*/
entities: [Proposal, EmployeeProposalTemplate],
/**
* 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 new 'proposals' tag to the 'Tag' entity
config.customFields.Tag.push({
name: 'proposals',
type: 'relation',
Expand All @@ -21,6 +38,7 @@ import { ProposalSeederService } from './proposal/proposal-seeder.service';
entity: Proposal,
inverseSide: (it: Proposal) => it.tags
});

return config;
}
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Body, Controller, Get, HttpStatus, Param, Patch, Post, Put, Query, UseGuards } from '@nestjs/common';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBody, ApiResponse, ApiTags, ApiOperation, ApiQuery, ApiParam } from '@nestjs/swagger';
import { UpdateResult } from 'typeorm';
import { ID, IEmployeeProposalTemplate, IPagination, PermissionsEnum } from '@gauzy/contracts';
import {
Expand All @@ -26,11 +26,35 @@ export class EmployeeProposalTemplateController extends CrudController<EmployeeP
}

/**
* GET employee proposal template via pagination
* GET employee proposal template via pagination.
*
* @param params
* @returns
* Retrieves a paginated list of employee proposal templates from the database.
*
* @param params Pagination parameters (e.g., `skip`, `take`, filters).
* @returns A paginated result containing an array of `IEmployeeProposalTemplate`.
*/
@ApiOperation({
summary: 'Get paginated employee proposal templates',
description: 'Retrieves a paginated list of employee proposal templates.'
})
@ApiQuery({
name: 'skip',
type: Number,
required: false,
description: 'Number of records to skip.'
})
@ApiQuery({
name: 'take',
type: Number,
required: false,
description: 'Number of records to retrieve.'
})
@ApiResponse({
status: HttpStatus.OK,
description: 'Successful retrieval of paginated results.',
type: EmployeeProposalTemplate,
isArray: true
})
@Permissions(PermissionsEnum.ORG_PROPOSAL_TEMPLATES_VIEW)
@Get('/pagination')
@UseValidationPipe({ transform: true })
Expand All @@ -41,15 +65,28 @@ export class EmployeeProposalTemplateController extends CrudController<EmployeeP
}

/**
* CREATE make default template by id
* CREATE make default template by ID.
*
* @param id
* @returns
* Marks an existing proposal template as the default template by its ID.
*
* @param id The UUID of the proposal template to set as default.
* @param input The DTO containing extra data needed for the operation (if any).
* @returns The updated `IEmployeeProposalTemplate`.
*/
@ApiOperation({ summary: 'Make Default' })
@ApiResponse({
status: HttpStatus.OK,
description: 'Record Updated'
description: 'Record updated successfully.'
})
@ApiParam({
name: 'id',
type: 'string',
description: 'The UUID of the proposal template to be marked default.'
})
@ApiBody({
type: ProposalTemplateDTO,
required: false,
description: 'Optional data to process while making the template default.'
})
@Patch('/:id/make-default')
async makeDefault(
Expand All @@ -60,15 +97,35 @@ export class EmployeeProposalTemplateController extends CrudController<EmployeeP
}

/**
* GET all employee proposal templates
* GET all employee proposal templates.
*
* @param params
* @returns
* Retrieves all employee proposal templates from the database.
* Optionally supports pagination parameters or query filters.
*
* @param params Optional pagination parameters or query filters.
* @returns A paginated result containing an array of `IEmployeeProposalTemplate`.
*/
@ApiOperation({ summary: 'find all employee proposal templates' })
@ApiOperation({
summary: 'Find all employee proposal templates',
description: 'Retrieves all existing employee proposal templates, optionally paginated.'
})
@ApiQuery({
name: 'skip',
type: Number,
required: false,
description: 'Number of records to skip.'
})
@ApiQuery({
name: 'take',
type: Number,
required: false,
description: 'Number of records to retrieve.'
})
@ApiResponse({
status: HttpStatus.OK,
description: 'Found records'
description: 'Found records successfully.',
type: EmployeeProposalTemplate,
isArray: true
})
@Permissions(PermissionsEnum.ORG_PROPOSAL_TEMPLATES_VIEW)
@Get('/')
Expand All @@ -82,21 +139,56 @@ export class EmployeeProposalTemplateController extends CrudController<EmployeeP
/**
* CREATE employee proposal template
*
* @param entity
* @returns
* Creates a new `EmployeeProposalTemplate` entity in the database.
*
* @param {CreateProposalTemplateDTO} entity - The DTO containing creation data.
* @returns {Promise<IEmployeeProposalTemplate>} The newly created proposal template.
*/
@ApiOperation({
summary: 'Create employee proposal template',
description: 'Creates a new employee proposal template in the database.'
})
@ApiResponse({
status: 201,
description: 'The proposal template has been successfully created.',
type: () => CreateProposalTemplateDTO
})
@ApiBody({
type: CreateProposalTemplateDTO,
required: true,
description: 'Payload to create a new proposal template.'
})
@Post('/')
@UseValidationPipe({ whitelist: true, transform: true })
async create(@Body() entity: CreateProposalTemplateDTO): Promise<IEmployeeProposalTemplate> {
async create(
@Body() entity: CreateProposalTemplateDTO
): Promise<IEmployeeProposalTemplate> {
return await this.employeeProposalTemplateService.create(entity);
}

/**
* UPDATE employee proposal template
*
* @param entity
* @returns
* Updates an existing `EmployeeProposalTemplate` in the database.
*
* @param {ID} id - The unique identifier of the proposal template.
* @param {UpdateProposalTemplateDTO} entity - The DTO containing updated data.
* @returns {Promise<IEmployeeProposalTemplate | UpdateResult>} The updated proposal template or a TypeORM UpdateResult.
*/
@ApiOperation({
summary: 'Update employee proposal template',
description: 'Updates an existing employee proposal template by ID.'
})
@ApiBody({
type: UpdateProposalTemplateDTO,
required: true,
description: 'Payload to update a proposal template.'
})
@ApiResponse({
status: 200,
description: 'The proposal template has been successfully updated.',
type: () => UpdateProposalTemplateDTO
})
@Put('/:id')
@UseValidationPipe({ whitelist: true, transform: true })
async update(
Expand Down
Loading

0 comments on commit d18ae2a

Please sign in to comment.