Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated Import #720

Merged
merged 302 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
302 commits
Select commit Hold shift + click to select a range
8b3e8ba
feat: Removed map from TooltipBadge and included it in it`s parent co…
Jul 12, 2024
a2e2c09
feat: Implemented AutoImportPhase3 with code optimiziations
Jul 12, 2024
9178fff
feat: Included INVALID_CRON in TEXTS
Jul 12, 2024
f30e247
feat: Added type ScheduleFormValues
Jul 12, 2024
928ae38
feat: Exported new members TooltipBadge and CronScheduleInputTextBox
Jul 12, 2024
6c4ff58
feat: Implemented this component for showing the input box for indivi…
Jul 12, 2024
47fb263
feat: Optimized this component by adhering code quality standards
Jul 12, 2024
b2fda13
feat: Exported member AutoImportFooter
Jul 12, 2024
486c55e
feat: Basic UI for AutoImportPhase2 implemented
Jul 12, 2024
d724fe3
feat: AUTOIMPORTPHASE2 added in TEXTS
Jul 12, 2024
00498fd
feat: Added Styles
Jul 12, 2024
e90ecd6
feat: Added schema for jobsmapping
Jul 13, 2024
ea632c9
feat: Entity for JobMapping created
Jul 13, 2024
0d28775
feat: Added schema for userjob
Jul 13, 2024
6a8c2c6
feat: UserJobEntity created
Jul 13, 2024
3def4e4
feat: Exported members jobmapping schema and jobmapping entity
Jul 13, 2024
26e5a42
feat: Exported members entity, schema and repository of userjob
Jul 13, 2024
454d8b1
feat: Created UserJobRepository
Jul 13, 2024
a255ac0
feat: Took headings as a array of strings
Jul 13, 2024
428241e
feat: Created JobsMappingRepository
Jul 13, 2024
af68b5e
feat: Updated jobsId as _userJobId
Jul 13, 2024
eea75d9
feat: Updated UserJobs to UserJob
Jul 13, 2024
a8c9c4d
feat: Exported members jobsmapping and userjobs
Jul 13, 2024
2242401
feat: Types defined for the XML-Parser service
Jul 15, 2024
6b29374
feat: Exported MappingHeading
Jul 15, 2024
c3cfd3b
feat: Mapping keys to be omitted from the keys that may present in th…
Jul 15, 2024
5a2b3dd
feat: Exported member parse-xml-servce and keysToOmit
Jul 15, 2024
84127b3
feat: Exported member jobsmapping.repository
Jul 15, 2024
a354be2
feat: Renamed templateId to _templateId
Jul 15, 2024
7a3480a
feat: Added USerJobRepository and JobMappingRepository in shared module
Jul 15, 2024
6aab132
feat: Renamed templateId to _templateId
Jul 15, 2024
98455f2
feat: userjob dto added
Jul 15, 2024
75f5a21
feat: Xml-parser implemented in ts
Jul 15, 2024
3cb991a
feat: Regex for Rss url validation added
Jul 15, 2024
a7cc6d9
Merge branch 'next' into feat/auto-import-feature
Jul 15, 2024
3b678e5
feat: Updated dependencies
Jul 15, 2024
97cf47e
feat: Usecase for creating userjob created
Jul 16, 2024
3869c2b
feat: Added more known keys that can be omitted
Jul 16, 2024
75651ec
feat: Added ImportJobModule
Jul 16, 2024
46c1d7f
feat: Module for ImportJobs added
Jul 16, 2024
21a6d03
feat: Usecase to fetch the column schema
Jul 16, 2024
37772dd
feat: Added interface IUserJob
Jul 16, 2024
e61db76
feat: Added JobInfoContext
Jul 16, 2024
684c78f
feat: Exported member UserJob
Jul 16, 2024
a28b327
feat: Removed _id
Jul 16, 2024
484c252
feat: Feature optimizations
Jul 16, 2024
33cb7ec
feat: Removed _id
Jul 16, 2024
fe926ec
feat: Took id as optional
Jul 16, 2024
14a118d
feat: Took path as array of strings
Jul 16, 2024
04a398f
feat: Added usecases
Jul 16, 2024
e204d80
feat: Read the RSS URL and performed necessary operations
Jul 16, 2024
4999303
feat: Exported member Userjob.interface
Jul 16, 2024
15a9cf6
feat: Streamlined import statements
Jul 16, 2024
8fe0d22
feat: Added Object and Regex to validate the RSS URL
Jul 16, 2024
f2be6cd
feat: Given proper name to members of AUTOIMPORTPHASE2
Jul 16, 2024
6af8bda
feat: Used JobsInfoProvider context here
Jul 16, 2024
a15f39c
feat: Dto fro UpdateJobMapping created
Jul 16, 2024
9119d0e
feat: Steamlined AutoImportPhase3
Jul 16, 2024
5953041
feat: Removed path as string array
Jul 16, 2024
dd18a16
feat: Streamlined jobinfo context
Jul 16, 2024
07bfd20
feat: Custom Hook for AutoImportPhase2 added
Jul 16, 2024
534fff0
feat: Command for CreateJobMapping added
Jul 16, 2024
cc09028
feat: Added IUserJobMapping
Jul 16, 2024
534257d
feat: Added api route updateUserJob
Jul 16, 2024
fa45414
feat: Took * as default cron values
Jul 16, 2024
54e39fe
feat: Exported member UserJobMapping
Jul 16, 2024
0ce2a97
feat: Exported member UserJobMapping and UserJobInformation
Jul 16, 2024
59785f5
feat: AutoImportPhase1 added
Jul 16, 2024
cf70e78
feat: Exported member UserJobInformation
Jul 16, 2024
c767bea
feat: Added interface IUserJobInformation
Jul 16, 2024
38bad21
feat: Styles added
Jul 16, 2024
7227053
feat: UpdateJobInfoDto added
Jul 16, 2024
63a0f18
feat: Usecase UpdateUserJob created
Jul 16, 2024
3e173ff
feat: Usecase CreateJobMapping created
Jul 16, 2024
26917e3
feat: UpdateUserJobCommand added
Jul 16, 2024
54b9b10
feat: MappingHeading added
Jul 16, 2024
0f56804
feat: UpdateUserJobRoute added
Jul 16, 2024
caff51e
feat: Added UpdateUserJob in USECASES
Jul 16, 2024
fa762ad
feat: Added cron in IUserJob
Jul 17, 2024
59db0ef
feat: Custom hook which has api calls for AutoImportPhase3 implemented
Jul 17, 2024
c0cbae6
feat: Streamlined jobinfo context
Jul 17, 2024
2e69e7e
feat: Added export member UserJobInformation
Jul 17, 2024
94486b5
feat: Handled next button click
Jul 17, 2024
25696c6
feat: Added api call updateUserJob
Jul 17, 2024
0d5b86d
feat: Added IsOptional class-validator for all fields
Jul 17, 2024
39c25d1
feat: Added IsOptional class-validator for all fields
Jul 17, 2024
f28afe6
feat: Shown error if url is invalid
Jul 17, 2024
965f891
feat: Added usecase UpdateUserJob
Jul 17, 2024
3e3d835
feat: Renamed updateCronExpression to updateUserJob
Jul 17, 2024
93f7731
feat: Added proper validation message in the validateRssUrl
Jul 17, 2024
7bbd59d
feat: Added dynamic url and cron expression fetching from jobcontext
Jul 17, 2024
ccc04ef
feat: Package json file added
Jul 17, 2024
389bbac
feat: Removed createdOn
Jul 17, 2024
4a5ffa0
feat: Removed createdOn
Jul 17, 2024
b7c2f32
feat: Removed createdOn
Jul 17, 2024
994df35
feat: Removed createdOn
Jul 17, 2024
bca9077
feat: Removed createdOn
Jul 17, 2024
ce66bb1
feat: Added optional checking jobInfo?._id
Jul 17, 2024
3ff85bc
feat: Added onCloseClick to confirm and close the Widget modal
Jul 17, 2024
291bd42
feat: Disabled es-lint warning for null-assertion
Jul 17, 2024
74d8f98
feat: Passed onClose to onCloseClick in AutoImportPhase4
Jul 17, 2024
2a07ae5
feat: Added default cron expression that will run every night on sund…
Jul 17, 2024
1fa20a2
feat: Removed custom styling
Jul 17, 2024
0e70188
feat: Removed static description Every minute
Jul 17, 2024
819afd2
feat: Footer for AutoImportPhases added
Jul 17, 2024
b662ac5
feat: Added BUTTONTEXT in AUTOIMPORTPHASES
Jul 17, 2024
059143f
feat: Files deleted
Jul 17, 2024
1e6459d
feat: Handled invalid MIME type which are other than application/rss+xml
Jul 17, 2024
c3243b9
feat: Given proper information on focusing corresponding cron express…
Jul 17, 2024
e2a93f0
feat: Added an error message for invalid xml rss link
Jul 17, 2024
413aee3
feat: Added a function to check the mimeType of the provided url
Jul 17, 2024
347e9fc
feat: Added information on clicking on the particular cron expression…
Jul 17, 2024
b9df753
feat: Removed custom styling and added onFocus and onBlur
Jul 17, 2024
101e6ff
feat: Added notification upon error
Jul 17, 2024
2e28bd8
feat: Added fieldAllowedValues
Jul 17, 2024
057ce1a
feat: Added application/rss+xml in FileMimeTypesEnum
Jul 17, 2024
dbae76c
feat: Added styling for centering the label and the text in the textbox
Jul 17, 2024
79f2e47
feat: Added dynamic cron expression explanation upon focusing on part…
Jul 17, 2024
7ce2edf
feat: Removed setTableOpened
Jul 17, 2024
9e5947a
feat: Added consiced cronFieldDefinitions and the corresponding value…
Jul 17, 2024
3b25443
feat: Added more keys that were necessary to omit
Jul 18, 2024
4135223
feat: Revised Xml-parser
Jul 18, 2024
350edfc
feat: Added any
Jul 18, 2024
99cc45d
feat: Streamlined AutoImportPhase3
Jul 18, 2024
3287b47
feat: Streamlined import-jobs controller
Jul 20, 2024
c78c4ab
feat: Removed @IsOptional fron _jobId field
Jul 20, 2024
8741756
feat: Renamed jobId to _jobId
Jul 20, 2024
ac3aff0
feat: Streamlined CreateJobMapping
Jul 20, 2024
3664133
feat: Streamlined CreateUserJob
Jul 20, 2024
7bf5653
feat: Renamed jobId to _jobId
Jul 20, 2024
03eed7f
feat: Added QueueService and RSSService
Jul 20, 2024
448d5ff
feat: Exported member rss.service
Jul 20, 2024
fc729e7
feat: Added publishToQueue overload for SEND_RSS_XML_DATA
Jul 20, 2024
6482fd5
feat: Added channel.assertQueue for SEND_RSS_XML_DATA
Jul 20, 2024
6d013a4
feat: Added SEND_RSS_XML_DATA in QueuesEnum
Jul 20, 2024
1c45dba
feat: Renamed _jobId to jobId
Jul 20, 2024
414c89f
feat: Changed _userJobId to _jobId
Jul 20, 2024
3119f88
feat: Exported member import-job-data.consumer
Jul 20, 2024
505cc5a
feat: Renamed jobId to _jobId
Jul 20, 2024
e69968d
feat: Added keysToOmit
Jul 20, 2024
1ca53bc
feat: Imported and used keysToOmit
Jul 20, 2024
04cf225
feat: Unused files deleted
Jul 20, 2024
9ebc7a1
feat: Added TEXTXML to identify MIME type text/xml
Jul 20, 2024
8692abb
feat: Refactored CreateUserJob usecase to improve MIME type validatio…
Jul 20, 2024
1227d2a
feat: Exported member cronjob.service
Jul 20, 2024
ab742ec
feat: New Routes forgetting, pausing, starting, deleting user jobs added
Jul 20, 2024
3274c14
feat: CronJobService added
Jul 20, 2024
fa3f1bc
feat: New keys added in keysToOmit
Jul 20, 2024
ddde7c2
feat: New fields added in UserJobEntity
Jul 20, 2024
c4a8a79
feat: New fields added in userJobSchema
Jul 20, 2024
6f67881
feat: Streamlined usecase GetJobMapping
Jul 20, 2024
77d4c2b
feat: Added files package.json and pnpm-lock.yaml
Jul 20, 2024
4a28df7
feat: Added CronJobService to pause, start and delete cron job
Jul 22, 2024
b0e53a7
feat: Exported member import-job-history
Jul 22, 2024
8db543d
feat: Streamlined and refactored the RSSService class
Jul 22, 2024
a49519d
feat: Entity ImportJobHistory created
Jul 22, 2024
a021759
feat: Repository for ImportJobHistoryRepository added
Jul 22, 2024
8b47b9c
feat: Added importJobHistorySchema
Jul 22, 2024
4cf4b56
feat: Exported members entity, repository and schema of import-job
Jul 22, 2024
11881f9
feat: Exported member send-import-job-data.consumer
Jul 22, 2024
11aa563
feat: Exported members import-job.types and user-job.types from impor…
Jul 22, 2024
ab88047
feat: Added SendImportJobDataConsumer
Jul 22, 2024
72ebd37
feat: Added types SendWebhookCachedData,SendImportJobData and renamed…
Jul 22, 2024
982e45d
feat: Added enum UserJobImportStatusEnum
Jul 22, 2024
becfc35
feat: Exported enum ImportJobHistoryStatusEnum
Jul 22, 2024
404b5ea
feat: Added status in UserJobEntity
Jul 22, 2024
76e529a
feat: Removed validFileId,invalidFileId and renamed _fileId to and al…
Jul 22, 2024
33826cd
feat: Added method getHistoryWithJob
Jul 22, 2024
d7a2c15
feat: Removed validFileId,invalidFileId and renamed allDataFileId to …
Jul 22, 2024
6f433e9
feat: Renamed SEND_RSS_XML_DATA to GET_IMPORT_JOB_DATA
Jul 22, 2024
e4c0dfe
feat: Renamed userID to externalUserId
Jul 23, 2024
9f07bf5
feat: Added statuses MAPPING and SCHEDULING
Jul 23, 2024
23a4432
feat: Routes for getting, pausing, starting and deleting userjob created
Jul 23, 2024
aef479e
feat: Streamlined and Refactored webhook data sending logic
Jul 23, 2024
114401a
feat: Removed = condition to get corrected current page number
Jul 23, 2024
08da552
feat: Given types to fields from Schema.Types
Jul 23, 2024
087fef4
feat: Streamlined and Refactored SendImportJobData to send the data i…
Jul 23, 2024
b6187e5
feat: Removed scheduleData from dependency array
Jul 23, 2024
84032f3
feat: Streamlined SEND_IMPORT_JOB_DATA
Jul 23, 2024
be6330d
feat: Made Dto for body parameters for creating user job route
Jul 23, 2024
96cf59a
feat: Created UserJobDto
Jul 23, 2024
6e6c156
feat: Added status and externalUserId fields
Jul 23, 2024
b543ef5
feat: Added CreateUserJobCommand to be used in the CreateUserJob exec…
Jul 23, 2024
b2c4327
feat: Used CreateUserJobCommand in execute method
Jul 23, 2024
f4a7bbe
feat: Added status in UpdateUserJobCommand
Jul 23, 2024
45fe059
feat: Removed _templateId
Jul 23, 2024
b51a7f2
feat: Updated status to MAPPING
Jul 23, 2024
f1c35a4
feat: Added status in the userjob schema
Jul 24, 2024
486f40b
feat: Added templeteId in getImportConfig and extra fields in getRssX…
Jul 24, 2024
5aaffcf
feat: Added templateId in getImportConfigRoute
Jul 24, 2024
eae5635
feat: Maintained proper statuses while pause and start cron job
Jul 24, 2024
10e3f97
feat: Taking templeteId as parameter in execute method
Jul 24, 2024
3a331b0
feat: Saved extra and externalUserId in database while creating userJob
Jul 24, 2024
1789b8e
feat: Refactored conform to confirm and resolved spelling issue
Jul 24, 2024
4bac63f
feat: Implemented scheduleRssImportJob that will trigger the start cr…
Jul 24, 2024
8d44d8f
feat: Refactored and removed code block of the getImportConfig api call
Jul 24, 2024
a70979a
feat: Refactored conform to confirm and resolved spelling issue
Jul 24, 2024
cf4ed52
feat: Refactored cronExamples to have expression token followed by it…
Jul 24, 2024
3af3597
feat: Refactored SendImportJobDataConsumer for missing callbackUrl ha…
Jul 24, 2024
fd1d077
feat: Refactored conform to confirm and resolved spelling issue
Jul 24, 2024
51bed7b
feat: Renamed schedule to description
Jul 24, 2024
c660c65
feat: Fixed grey background while filling the TextInput with suggeste…
Jul 24, 2024
2dfacd8
feat: Dynamically open Import widget based on importConfig type. Fix …
Jul 24, 2024
a186a9b
feat: Called API getImportConfig with paramaters projectId and templa…
Jul 24, 2024
0d1bcb4
feat: Refactored conform to confirm and resolved spelling issue, adde…
Jul 24, 2024
fdcb9ae
feat: Called refetch in useEffect
Jul 24, 2024
22107f2
feat: Refactored conform to confirm and resolved spelling issue
Jul 24, 2024
f82f6fd
feat: Refactoredand Streamlined proper API calling
Jul 24, 2024
42fd4ba
feat: Added title in IImportConfig
Jul 24, 2024
32c6a29
feat: Renamed GetJobMapping to GetColumnSchemaMapping
Jul 24, 2024
3620364
feat: Added usecase GetUserJob to fetch userJob based on externalUserId
Jul 24, 2024
3158393
feat: Added usecase GetUserJob
Jul 24, 2024
e1a773c
feat: Added TERMINATED in UserJobImportStatusEnum
Jul 24, 2024
3bc4ed9
feat: Added method deleteUserJob and set status TERMINATED
Jul 24, 2024
bbc1181
feat: Added scheduleData as dependency in dependency array of useEffect
Jul 24, 2024
5d79b41
feat: Refactored and streamlined API routes
Jul 24, 2024
54b8a2e
feat: Called publishToQueue only if callbackUrl is found
Jul 24, 2024
2a7caa3
feat: Streamlined pauseJob and resumeJob to handle _jobId not found
Jul 24, 2024
3d8403e
feat: Removed unused dependency jobMappingRepository
Jul 25, 2024
8e966b0
feat: Made Mode toggle stateless and Added externalUserId as email
Jul 25, 2024
d6c3946
feat: Merged next
Jul 25, 2024
ed9f146
feat: Removed injectable
Jul 25, 2024
e806c73
feat: Added missing dependencies
Jul 25, 2024
ebb26e5
feat: Seperate usecases to start,pause,resume,delete,terminate and tr…
Jul 25, 2024
7a9fdcd
feat: Exported usecases to Resume,Start,Delete,Pause,Terminate and Tr…
Jul 25, 2024
7318021
feat: Removed exported membed cronjob.service
Jul 25, 2024
49b5eff
feat: File Deleted
Jul 25, 2024
01ed5ea
refactor: Used new usecases in routes such as pause,start,resume,dele…
Jul 25, 2024
1262b16
feat: Removed Promise<void> as return type of method
Jul 25, 2024
9e2540f
feat: Removed console.log
Jul 25, 2024
59a5840
feat: Called execute method of userJobTriggerService
Jul 25, 2024
c50e3c5
feat: Got _templateId method getUserJobWithTemplate
Jul 25, 2024
958b2d4
feat: Removed try catch block
Jul 25, 2024
f71c2a9
feat: Removed comments
Jul 25, 2024
5c2db04
feat: Retrieved userjob from the database using jobid and populates t…
Jul 25, 2024
fbaa2d0
feat: Added Model
Jul 25, 2024
25ae7ac
test: Debug logs
Jul 25, 2024
3755f58
feat: Debug log
Jul 25, 2024
809d14a
feat: Debugged using useEffect
Jul 25, 2024
45a31ee
feat: Dynamic mode passed as prop in Layout
Jul 25, 2024
2ba4404
feat: Revised fetch import config method
Jul 26, 2024
22c60a7
feat: Optimized app context import
Jul 26, 2024
2954be6
feat: Updated order of data calling in phase0
Jul 26, 2024
a966004
feat: Removed logs
Jul 26, 2024
588d899
feat: Merged next
chavda-bhavik Jul 31, 2024
b733a28
fix: Number value coming empty
chavda-bhavik Aug 1, 2024
6b48854
feat: Removed unused query
chavda-bhavik Aug 1, 2024
9b0cfbe
feat: Removed svg and added webp for image upload
chavda-bhavik Aug 1, 2024
f865264
feat: Updated validate success callback and removed unused loader
chavda-bhavik Aug 1, 2024
060bddb
feat: Code optimizations
chavda-bhavik Aug 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@nestjs/platform-express": "^9.1.2",
"@nestjs/platform-socket.io": "9.4.3",
"@nestjs/platform-ws": "9.4.3",
"@nestjs/schedule": "^4.1.0",
"@nestjs/swagger": "^6.1.2",
"@nestjs/terminus": "^9.1.3",
"@nestjs/websockets": "9.4.3",
Expand All @@ -44,6 +45,7 @@
"class-validator": "^0.14.0",
"compression": "^1.7.4",
"cookie-parser": "^1.4.6",
"cron": "^3.1.7",
"date-fns": "^2.30.0",
"dayjs": "^1.11.11",
"dotenv": "^16.0.2",
Expand All @@ -63,7 +65,8 @@
"source-map-support": "^0.5.21",
"uuid": "^9.0.0",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.1/xlsx-0.20.1.tgz",
"xlsx-populate": "^1.21.0"
"xlsx-populate": "^1.21.0",
"xml2js": "^0.6.2"
},
"devDependencies": {
"@nestjs/cli": "^9.1.5",
Expand Down Expand Up @@ -100,4 +103,4 @@
"main": ".eslintrc.js",
"keywords": [],
"description": ""
}
}
2 changes: 2 additions & 0 deletions apps/api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { AuthModule } from './app/auth/auth.module';
import { EnvironmentModule } from './app/environment/environment.module';
import { ActivityModule } from './app/activity/activity.module';
import { UserModule } from './app/user/user.module';
import { ImportJobsModule } from 'app/import-jobs/import-jobs.module';

const modules: Array<Type | DynamicModule | Promise<DynamicModule> | ForwardReference> = [
ProjectModule,
Expand All @@ -29,6 +30,7 @@ const modules: Array<Type | DynamicModule | Promise<DynamicModule> | ForwardRefe
UserModule,
EnvironmentModule,
ActivityModule,
ImportJobsModule,
];

const providers = [Logger];
Expand Down
7 changes: 5 additions & 2 deletions apps/api/src/app/common/common.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,15 @@ export class CommonController {
@ApiOperation({
summary: 'Get import config',
})
async getImportConfigRoute(@Query('projectId') projectId: string): Promise<ImportConfigResponseDto> {
async getImportConfigRoute(
@Query('projectId') projectId: string,
@Query('templateId') templateId: string
): Promise<ImportConfigResponseDto> {
if (!projectId) {
throw new BadRequestException();
}

return this.getImportConfig.execute(projectId);
return this.getImportConfig.execute(projectId, templateId);
}

@Post('/sheet-names')
Expand Down
9 changes: 8 additions & 1 deletion apps/api/src/app/common/dtos/import-config-response.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsBoolean, IsDefined } from 'class-validator';
import { IsBoolean, IsDefined, IsString } from 'class-validator';

export class ImportConfigResponseDto {
@ApiPropertyOptional({
Expand All @@ -8,4 +8,11 @@ export class ImportConfigResponseDto {
@IsDefined()
@IsBoolean()
showBranding: boolean;

@ApiPropertyOptional({
description: 'Whether the current Import is Manual is Atomatic',
})
@IsDefined()
@IsString()
mode?: string;
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
import { Injectable } from '@nestjs/common';
import { UserRepository } from '@impler/dal';
import { BadRequestException, Injectable } from '@nestjs/common';
import { UserRepository, TemplateRepository, TemplateEntity } from '@impler/dal';
import { IImportConfig } from '@impler/shared';
import { PaymentAPIService } from '@impler/services';
import { APIMessages } from '@shared/constants';

@Injectable()
export class GetImportConfig {
constructor(
private userRepository: UserRepository,
private paymentAPIService: PaymentAPIService
private paymentAPIService: PaymentAPIService,
private templateRepository: TemplateRepository
) {}

async execute(projectId: string): Promise<IImportConfig> {
async execute(projectId: string, templateId?: string): Promise<IImportConfig> {
const userEmail = await this.userRepository.findUserEmailFromProjectId(projectId);

const removeBrandingAvailable = await this.paymentAPIService.checkEvent(userEmail, 'REMOVE_BRANDING');

return { showBranding: !removeBrandingAvailable };
let template: TemplateEntity;
if (templateId) {
template = await this.templateRepository.findOne({
_projectId: projectId,
_id: templateId,
});

if (!template) {
throw new BadRequestException(APIMessages.TEMPLATE_NOT_FOUND);
}
}

return { showBranding: !removeBrandingAvailable, mode: template?.mode, title: template?.name };
}
}
15 changes: 15 additions & 0 deletions apps/api/src/app/import-jobs/dtos/create-userjob.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { IsNotEmpty, IsOptional, IsString } from 'class-validator';

export class CreateUserJobDto {
@IsString()
@IsNotEmpty()
url: string;

@IsString()
@IsOptional()
externalUserId?: string;

@IsString()
@IsOptional()
extra?: string;
}
3 changes: 3 additions & 0 deletions apps/api/src/app/import-jobs/dtos/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './create-userjob.dto';
export * from './update-userjob.dto';
export * from './update-jobmapping.dto';
18 changes: 18 additions & 0 deletions apps/api/src/app/import-jobs/dtos/update-jobmapping.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { IsBoolean, IsString } from 'class-validator';

export class UpdateJobMappingDto {
@IsString()
key: string;

@IsString()
name: string;

@IsBoolean()
isRequired: boolean;

@IsString()
path: string;

@IsString()
_jobId: string;
}
27 changes: 27 additions & 0 deletions apps/api/src/app/import-jobs/dtos/update-userjob.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { IsArray, IsOptional, IsString } from 'class-validator';

export class UpdateJobDto {
@IsString()
@IsOptional()
url: string;

@IsString()
@IsOptional()
_templateId: string;

@IsString()
@IsOptional()
cron: string;

@IsArray()
@IsOptional()
headings: string[];

@IsString()
@IsOptional()
status: string;

@IsString()
@IsOptional()
externalUserId: string;
}
101 changes: 101 additions & 0 deletions apps/api/src/app/import-jobs/import-jobs.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { ApiTags, ApiSecurity, ApiOperation } from '@nestjs/swagger';
import { Body, Controller, Delete, Get, Param, ParseArrayPipe, Post, Put, UseGuards } from '@nestjs/common';
import {
CreateUserJob,
GetColumnSchemaMapping,
CreateJobMapping,
UpdateUserJob,
GetUserJob,
UserJobPause,
UserJobResume,
UserJobTerminate,
UserJobDelete,
} from './usecase';
import { ACCESS_KEY_NAME } from '@impler/shared';
import { JwtAuthGuard } from '@shared/framework/auth.gaurd';
import { UpdateJobDto, CreateUserJobDto, UpdateJobMappingDto } from './dtos';

@ApiTags('Import-Jobs')
@Controller('/import-jobs')
@UseGuards(JwtAuthGuard)
@ApiSecurity(ACCESS_KEY_NAME)
export class ImportJobsController {
constructor(
private createUserJob: CreateUserJob,
private updateJobMapping: CreateJobMapping,
private getColumnSchemaMapping: GetColumnSchemaMapping,
private getUserJob: GetUserJob,
private updateUserJob: UpdateUserJob,
private userJobPause: UserJobPause,
private userJobResume: UserJobResume,
private userJobDelete: UserJobDelete,
private userJobTerminate: UserJobTerminate
) {}

@Post(':templateId')
@ApiOperation({ summary: 'Create User-Job' })
@ApiSecurity(ACCESS_KEY_NAME)
async createUserJobRoute(@Param('templateId') templateId: string, @Body() createUserJobData: CreateUserJobDto) {
return this.createUserJob.execute({
_templateId: templateId,
url: createUserJobData.url,
});
}

@Get(':jobId/mappings')
@ApiOperation({ summary: 'Fetch the User-Job Mapping Information based on jobId' })
@UseGuards(JwtAuthGuard)
@ApiSecurity(ACCESS_KEY_NAME)
async getImportJobInfoRoute(@Param('jobId') _jobId: string) {
return this.getColumnSchemaMapping.execute(_jobId);
}

@Put(':jobId/mappings')
@ApiOperation({ summary: 'Update User-Job Mappings' })
@UseGuards(JwtAuthGuard)
async updateJobMappingRoute(@Body(new ParseArrayPipe({ items: UpdateJobMappingDto })) body: UpdateJobMappingDto[]) {
return this.updateJobMapping.execute(body);
}

@Put(':jobId')
@ApiOperation({ summary: 'Update User-Job Fields' })
@UseGuards(JwtAuthGuard)
async updateUserJobRoute(@Param('jobId') _jobId: string, @Body() userJobData: UpdateJobDto) {
return this.updateUserJob.execute(_jobId, userJobData);
}

@Get('/user/:externalUserId')
@ApiOperation({ summary: 'Get User Jobs' })
@UseGuards(JwtAuthGuard)
async getUserJobs(@Param('externalUserId') externalUserId: string) {
return this.getUserJob.execute(externalUserId);
}

@Put('/user/:jobId/pause')
@ApiOperation({ summary: 'Pause User-Job from Running' })
@UseGuards(JwtAuthGuard)
async pauseCronJob(@Param('jobId') jobId: string) {
return await this.userJobPause.execute(jobId);
}

@Put('/user/:jobId/resume')
@ApiOperation({ summary: 'Resume stopped User-Job' })
@UseGuards(JwtAuthGuard)
async resumeUserJobRoute(@Param('jobId') _jobId: string) {
return await this.userJobResume.execute(_jobId);
}

@Delete('/user/:externalUserId/:jobId')
@ApiOperation({ summary: 'Delete User-Job' })
@UseGuards(JwtAuthGuard)
async deleteJob(@Param('externalUserId') externalUserId: string, @Param('jobId') _jobId: string) {
return await this.userJobDelete.execute({ externalUserId, _jobId });
}

@Delete(':jobId')
@ApiOperation({ summary: 'Delete User-Job and Update the status of UserJob to TERMINATED' })
@UseGuards(JwtAuthGuard)
async deleteJobRoute(@Param('jobId') _jobId: string) {
return await this.userJobTerminate.execute(_jobId);
}
}
11 changes: 11 additions & 0 deletions apps/api/src/app/import-jobs/import-jobs.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';
import { SharedModule } from '@shared/shared.module';
import { USECASES } from './usecase';
import { ImportJobsController } from './import-jobs.controller';

@Module({
imports: [SharedModule],
providers: [...USECASES],
controllers: [ImportJobsController],
})
export class ImportJobsModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export class CreateJobMappingCommand {
key: string;

name: string;

isRequired: boolean;

path: string;

_jobId: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { JobMappingRepository } from '@impler/dal';
import { BadRequestException, Injectable } from '@nestjs/common';
import { CreateJobMappingCommand } from './create-jobmapping.command';

@Injectable()
export class CreateJobMapping {
constructor(private readonly jobMappingRepository: JobMappingRepository) {}

async execute(jobMappingCommand: CreateJobMappingCommand[]) {
jobMappingCommand.filter((command) => !!command.key).map((command) => command.key);

for (const mappingCommand of jobMappingCommand) {
if (mappingCommand.isRequired && !mappingCommand.path) {
throw new BadRequestException(`${mappingCommand.name} is required`);
}
}

return this.jobMappingRepository.createMany(jobMappingCommand);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export class CreateUserJobCommand {
url: string;
_templateId: string;
externalUserId?: string;
extra?: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { BadRequestException, Injectable } from '@nestjs/common';
import { FileMimeTypesEnum } from '@impler/shared';
import { APIMessages } from '@shared/constants';
import { UserJobEntity, UserJobRepository } from '@impler/dal';
import { RSSService } from '@shared/services';
import { CreateUserJobCommand } from './create-userjob.command';

@Injectable()
export class CreateUserJob {
constructor(
private readonly rssService: RSSService,
private readonly userJobRepository: UserJobRepository
) {}

async execute({ _templateId, url, externalUserId, extra }: CreateUserJobCommand): Promise<UserJobEntity> {
const mimeType = await this.rssService.getMimeType(url);
if (mimeType === FileMimeTypesEnum.XML || mimeType === FileMimeTypesEnum.TEXTXML) {
const { rssKeyHeading } = await this.rssService.parseRssFeed(url);
let formattedExtra = extra || '{}';
try {
formattedExtra = JSON.parse(extra);
} catch (_) {}

return await this.userJobRepository.create({
url,
headings: rssKeyHeading,
_templateId: _templateId,
extra,
externalUserId: externalUserId || (formattedExtra as unknown as Record<string, any>)?.externalUserId,
});
} else {
throw new BadRequestException(APIMessages.INVALID_RSS_URL);
}
}
}
Loading
Loading