Skip to content

Commit

Permalink
ORV2-1217 Refactor Notification and Document Generation functionality (
Browse files Browse the repository at this point in the history
  • Loading branch information
praju-aot authored Mar 19, 2024
1 parent 09a8140 commit 4741593
Show file tree
Hide file tree
Showing 65 changed files with 817 additions and 654 deletions.
6 changes: 3 additions & 3 deletions charts/onroutebc/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ vehicles:
command:
- "sh"
- "-c"
- "source /vault/secrets/keycloak-{{.Values.global.vault.zone}} && source /vault/secrets/ches-{{.Values.global.vault.zone}} && source /vault/secrets/mssql-{{.Values.global.vault.zone}} && source /vault/secrets/payment-{{.Values.global.vault.zone}} && source /vault/secrets/vehicles-{{.Values.global.vault.zone}} && npm run start:prod"
- "source /vault/secrets/keycloak-{{.Values.global.vault.zone}} && source /vault/secrets/mssql-{{.Values.global.vault.zone}} && source /vault/secrets/payment-{{.Values.global.vault.zone}} && source /vault/secrets/vehicles-{{.Values.global.vault.zone}} && npm run start:prod"
registry: '{{ .Values.global.registry }}'
repository: '{{ .Values.global.repository }}' # example, it includes registry and repository
image: vehicles
Expand Down Expand Up @@ -251,7 +251,6 @@ vehicles:
license: "{{.Values.global.license}}"
secretPaths:
- "keycloak-{{tpl $.Values.vault.zone $}}"
- "ches-{{tpl $.Values.vault.zone $}}"
- "mssql-{{tpl $.Values.vault.zone $}}"
- "payment-{{tpl $.Values.vault.zone $}}"
- "vehicles-{{tpl $.Values.vault.zone $}}"
Expand All @@ -276,7 +275,7 @@ dops:
command:
- "sh"
- "-c"
- "source /vault/secrets/keycloak-{{.Values.global.vault.zone}} && source /vault/secrets/mssql-{{.Values.global.vault.zone}} && source /vault/secrets/cdogs-{{.Values.global.vault.zone}} && source /vault/secrets/dops-{{.Values.global.vault.zone}} && source /vault/secrets/s3-{{.Values.global.vault.zone}} && npm run start:prod"
- "source /vault/secrets/keycloak-{{.Values.global.vault.zone}} && source /vault/secrets/mssql-{{.Values.global.vault.zone}} && source /vault/secrets/ches-{{.Values.global.vault.zone}} && source /vault/secrets/cdogs-{{.Values.global.vault.zone}} && source /vault/secrets/dops-{{.Values.global.vault.zone}} && source /vault/secrets/s3-{{.Values.global.vault.zone}} && npm run start:prod"
registry: '{{ .Values.global.registry }}'
repository: '{{ .Values.global.repository }}' # example, it includes registry and repository
image: dops
Expand Down Expand Up @@ -385,6 +384,7 @@ dops:
secretPaths:
- "keycloak-{{tpl $.Values.vault.zone $}}"
- "mssql-{{tpl $.Values.vault.zone $}}"
- "ches-{{tpl $.Values.vault.zone $}}"
- "cdogs-{{tpl $.Values.vault.zone $}}"
- "dops-{{tpl $.Values.vault.zone $}}"
- "s3-{{tpl $.Values.vault.zone $}}"
Expand Down
43 changes: 43 additions & 0 deletions database/mssql/scripts/versions/revert/v_25_ddl_revert.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET NOCOUNT ON
GO

SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
BEGIN TRANSACTION
GO

IF @@ERROR <> 0 SET NOEXEC ON
GO
DELETE FROM [access].[ORBC_GROUP_ROLE] WHERE ROLE_TYPE IN ('ORBC-SEND-NOTIFICATION')

IF @@ERROR <> 0 SET NOEXEC ON
GO
DELETE FROM [access].[ORBC_ROLE_TYPE] WHERE ROLE_TYPE IN ('ORBC-SEND-NOTIFICATION')

DECLARE @VersionDescription VARCHAR(255)
SET @VersionDescription = 'Revert ORBC-SEND-NOTIFICATION role'

INSERT [dbo].[ORBC_SYS_VERSION] ([VERSION_ID], [DESCRIPTION], [RELEASE_DATE]) VALUES (24, @VersionDescription, getutcdate())
IF @@ERROR <> 0 SET NOEXEC ON
GO

COMMIT TRANSACTION
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
DECLARE @Success AS BIT
SET @Success = 1
SET NOEXEC OFF
IF (@Success = 1) PRINT 'The database update succeeded'
ELSE BEGIN
IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION
PRINT 'The database update failed'
END
GO

70 changes: 70 additions & 0 deletions database/mssql/scripts/versions/v_25_ddl.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET NOCOUNT ON
GO

SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
BEGIN TRANSACTION
GO

IF @@ERROR <> 0 SET NOEXEC ON
GO
-- Add new auth roles
INSERT [access].[ORBC_ROLE_TYPE] ([ROLE_TYPE], [ROLE_DESCRIPTION]) VALUES (N'ORBC-SEND-NOTIFICATION', NULL)

IF @@ERROR <> 0 SET NOEXEC ON
GO
INSERT [access].[ORBC_GROUP_ROLE] ([USER_AUTH_GROUP_TYPE], [ROLE_TYPE]) VALUES (N'ORGADMIN', N'ORBC-SEND-NOTIFICATION')

IF @@ERROR <> 0 SET NOEXEC ON
GO
INSERT [access].[ORBC_GROUP_ROLE] ([USER_AUTH_GROUP_TYPE], [ROLE_TYPE]) VALUES (N'PAPPLICANT', N'ORBC-SEND-NOTIFICATION')

IF @@ERROR <> 0 SET NOEXEC ON
GO
INSERT [access].[ORBC_GROUP_ROLE] ([USER_AUTH_GROUP_TYPE], [ROLE_TYPE]) VALUES (N'FINANCE', N'ORBC-SEND-NOTIFICATION')

IF @@ERROR <> 0 SET NOEXEC ON
GO
INSERT [access].[ORBC_GROUP_ROLE] ([USER_AUTH_GROUP_TYPE], [ROLE_TYPE]) VALUES (N'SYSADMIN', N'ORBC-SEND-NOTIFICATION')

IF @@ERROR <> 0 SET NOEXEC ON
GO
INSERT [access].[ORBC_GROUP_ROLE] ([USER_AUTH_GROUP_TYPE], [ROLE_TYPE]) VALUES (N'PPCCLERK', N'ORBC-SEND-NOTIFICATION')

IF @@ERROR <> 0 SET NOEXEC ON
GO
INSERT [access].[ORBC_GROUP_ROLE] ([USER_AUTH_GROUP_TYPE], [ROLE_TYPE]) VALUES (N'CTPO', N'ORBC-SEND-NOTIFICATION')

IF @@ERROR <> 0 SET NOEXEC ON
GO
INSERT [access].[ORBC_GROUP_ROLE] ([USER_AUTH_GROUP_TYPE], [ROLE_TYPE]) VALUES (N'HQADMIN', N'ORBC-SEND-NOTIFICATION')

IF @@ERROR <> 0 SET NOEXEC ON
GO

DECLARE @VersionDescription VARCHAR(255)
SET @VersionDescription = 'Add ORBC-SEND-NOTIFICATION role'

INSERT [dbo].[ORBC_SYS_VERSION] ([VERSION_ID], [DESCRIPTION], [UPDATE_SCRIPT], [REVERT_SCRIPT], [RELEASE_DATE]) VALUES (25, @VersionDescription, '$(UPDATE_SCRIPT)', '$(REVERT_SCRIPT)', getutcdate())
IF @@ERROR <> 0 SET NOEXEC ON
GO

COMMIT TRANSACTION
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
DECLARE @Success AS BIT
SET @Success = 1
SET NOEXEC OFF
IF (@Success = 1) PRINT 'The database update succeeded'
ELSE BEGIN
IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION
PRINT 'The database update failed'
END
GO
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ services:
KEYCLOAK_ISSUER_URL: ${KEYCLOAK_ISSUER_URL}
KEYCLOAK_AUDIENCE: ${KEYCLOAK_AUDIENCE}
KEYCLOAK_IGNORE_EXP: ${KEYCLOAK_IGNORE_EXP}
CHES_TOKEN_URL: ${CHES_TOKEN_URL}
CHES_CLIENT_ID: ${CHES_CLIENT_ID}
CHES_CLIENT_SECRET: ${CHES_CLIENT_SECRET}
CHES_URL: ${CHES_URL}
ACCESS_API_URL: "http://vehicles-api:5000"
DOPS_URL: "http://dops-api:5001"
FRONTEND_URL: "http://frontend:3000"
Expand Down Expand Up @@ -114,6 +110,10 @@ services:
OCIO_S3_ENDPOINT: ${OCIO_S3_ENDPOINT}
OCIO_S3_KEY: ${OCIO_S3_KEY}
OCIO_S3_SECRETACCESSKEY: ${OCIO_S3_SECRETACCESSKEY}
CHES_TOKEN_URL: ${CHES_TOKEN_URL}
CHES_CLIENT_ID: ${CHES_CLIENT_ID}
CHES_CLIENT_SECRET: ${CHES_CLIENT_SECRET}
CHES_URL: ${CHES_URL}
CDOGS_TOKEN_URL: ${CDOGS_TOKEN_URL}
CDOGS_CLIENT_ID: ${CDOGS_CLIENT_ID}
CDOGS_CLIENT_SECRET: ${CDOGS_CLIENT_SECRET}
Expand Down
4 changes: 4 additions & 0 deletions dops/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ ENV OCIO_S3_PRESIGNED_URL_EXPIRY ${OCIO_S3_PRESIGNED_URL_EXPIRY}
ENV OCIO_S3_ENDPOINT ${OCIO_S3_ENDPOINT}
ENV OCIO_S3_KEY ${OCIO_S3_KEY}
ENV OCIO_S3_SECRETACCESSKEY ${OCIO_S3_SECRETACCESSKEY}
ENV CHES_TOKEN_URL ${CHES_TOKEN_URL}
ENV CHES_CLIENT_ID ${CHES_CLIENT_ID}
ENV CHES_CLIENT_SECRET ${CHES_CLIENT_SECRET}
ENV CHES_URL ${CHES_URL}
ENV CDOGS_TOKEN_URL ${CDOGS_TOKEN_URL}
ENV CDOGS_CLIENT_ID ${CDOGS_CLIENT_ID}
ENV CDOGS_CLIENT_SECRET ${CDOGS_CLIENT_SECRET}
Expand Down
2 changes: 1 addition & 1 deletion dops/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"format": "prettier --write \"src/**/*.hbs\" \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
Expand Down
2 changes: 2 additions & 0 deletions dops/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { getTypeormLogLevel } from './helper/logger.helper';
import { ClsModule } from 'nestjs-cls';
import { Request } from 'express';
import { v4 as uuidv4 } from 'uuid';
import { NotificationModule } from './modules/notification/notification.module';

const envPath = path.resolve(process.cwd() + '/../');

Expand Down Expand Up @@ -75,6 +76,7 @@ const envPath = path.resolve(process.cwd() + '/../');
AuthModule,
DmsModule,
DgenModule,
NotificationModule,
FeatureFlagsModule,
],
controllers: [AppController],
Expand Down
27 changes: 27 additions & 0 deletions dops/src/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,33 @@ export class AppService {
),
);

await addToCache(
this.cacheManager,
CacheKey.EMAIL_TEMPLATE_PROFILE_REGISTRATION,
this.convertFiletoString(
assetsPath + 'templates/profile-registration.email.hbs',
),
);
await addToCache(
this.cacheManager,
CacheKey.EMAIL_TEMPLATE_ISSUE_PERMIT,
this.convertFiletoString(assetsPath + 'templates/issue-permit.email.hbs'),
);
await addToCache(
this.cacheManager,
CacheKey.EMAIL_TEMPLATE_COMPANY_SUSPEND,
this.convertFiletoString(
assetsPath + 'templates/suspend-company.email.hbs',
),
);
await addToCache(
this.cacheManager,
CacheKey.EMAIL_TEMPLATE_COMPANY_UNSUSPEND,
this.convertFiletoString(
assetsPath + 'templates/unsuspend-company.email.hbs',
),
);

const featureFlags = await this.featureFlagsService.findAll();
await addToCache(
this.cacheManager,
Expand Down
6 changes: 3 additions & 3 deletions dops/src/assets/templates/payment-refund-detailed.report.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
</tr>
</tbody>
</table>
</br>
<br/>
</div>
<!-- End of Header -->

Expand All @@ -239,7 +239,7 @@
{{#if payments}}
<p class="p-normal"><span style='font-size:10.0pt;font-weight:bold;'>Payments</span></p>

</br>
<br/>

<table class="table">
<thead>
Expand Down Expand Up @@ -371,7 +371,7 @@

<p class="p-normal"><span style='font-size:10.0pt;font-weight:bold;'>Refunds</span></p>

</br>
<br/>

<table class="table">
<thead>
Expand Down
6 changes: 3 additions & 3 deletions dops/src/assets/templates/payment-refund-summary.report.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
</tr>
</tbody>
</table>
</br>
<br/>
</div>
<!-- End of Header -->

Expand All @@ -207,7 +207,7 @@
{{#if payments}}
<p class="p-normal"><span style='font-size:10.0pt;font-weight:bold;'>Payments</span></p>

</br>
<br/>

<table class="table">
<thead>
Expand Down Expand Up @@ -277,7 +277,7 @@

<p class="p-normal"><span style='font-size:10.0pt;font-weight:bold;'>Refunds</span></p>

</br>
<br/>

<table class="table">
<thead>
Expand Down
4 changes: 3 additions & 1 deletion dops/src/decorator/roles.decorator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { SetMetadata } from '@nestjs/common';
import { Role } from '../enum/roles.enum';
import { IRole } from '../interface/role.interface';

export const ROLES_KEY = 'roles';
export const Roles = (...roles: Role[]) => SetMetadata(ROLES_KEY, roles);
export const Roles = (...roles: Role[] | IRole[]) =>
SetMetadata(ROLES_KEY, roles);
2 changes: 2 additions & 0 deletions dops/src/enum/cache-key.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export enum CacheKey {
TRAILER_TYPE = 'TRAILER_TYPE',
EMAIL_TEMPLATE_PROFILE_REGISTRATION = 'EMAIL_TEMPLATE_PROFILE_REGISTRATION',
EMAIL_TEMPLATE_ISSUE_PERMIT = 'EMAIL_TEMPLATE_ISSUE_PERMIT',
EMAIL_TEMPLATE_COMPANY_SUSPEND = 'EMAIL_TEMPLATE_COMPANY_SUSPEND',
EMAIL_TEMPLATE_COMPANY_UNSUSPEND = 'EMAIL_TEMPLATE_COMPANY_UNSUSPEND',
EMAIL_TEMPLATE_ORBC_STYLE = 'EMAIL_TEMPLATE_ORBC_STYLE',
CHES_ACCESS_TOKEN = 'CHES_ACCESS_TOKEN',
CDOGS_ACCESS_TOKEN = 'CDOGS_ACCESS_TOKEN',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum EmailTemplate {
export enum NotificationTemplate {
PROFILE_REGISTRATION = 'PROFILE_REGISTRATION',
ISSUE_PERMIT = 'ISSUE_PERMIT',
COMPANY_SUSPEND = 'COMPANY_SUSPEND',
Expand Down
1 change: 1 addition & 0 deletions dops/src/enum/roles.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ export enum Role {
WRITE_LCV_FLAG = 'ORBC-WRITE-LCV-FLAG',
READ_LOA = 'ORBC-READ-LOA',
WRITE_LOA = 'ORBC-WRITE-LOA',
SEND_NOTIFICATION = 'ORBC-SEND-NOTIFICATION',
}
3 changes: 2 additions & 1 deletion dops/src/guard/roles.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import { Role } from '../enum/roles.enum';
import { Request } from 'express';
import { IUserJWT } from '../interface/user-jwt.interface';
import { matchRoles } from '../helper/auth.helper';
import { IRole } from '../interface/role.interface';

@Injectable()
export class RolesGuard implements CanActivate {
constructor(private reflector: Reflector) {}

canActivate(context: ExecutionContext): boolean {
const roles = this.reflector.getAllAndOverride<Role[]>('roles', [
const roles = this.reflector.getAllAndOverride<Role[] | IRole[]>('roles', [
context.getHandler(),
context.getClass(),
]);
Expand Down
Loading

0 comments on commit 4741593

Please sign in to comment.