Skip to content

Commit

Permalink
Merge branch 'main' into PIMS-2000-MandatoryCheckboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
LawrenceLau2020 authored Sep 4, 2024
2 parents ee3af03 + a480e5a commit da5f2d1
Show file tree
Hide file tree
Showing 41 changed files with 327 additions and 239 deletions.
32 changes: 0 additions & 32 deletions express-api/.eslintrc.cjs

This file was deleted.

1 change: 1 addition & 0 deletions express-api/.prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-undef */
module.exports = {
semi: true,
trailingComma: 'all',
Expand Down
36 changes: 36 additions & 0 deletions express-api/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import prettierPlugin from 'eslint-plugin-prettier';
import tseslint from 'typescript-eslint';
import eslint from '@eslint/js';

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
{
// Specify the parser for TypeScript
languageOptions: {
parser: tseslint.parser,
},
plugins: {
prettier: prettierPlugin,
},
// Define your ESLint rules
rules: {
'prettier/prettier': 'warn',
'no-extra-boolean-cast': 'off',
'no-unsafe-optional-chaining': 'off',
'no-prototype-builtins': 'off',
'no-console': 'error', // Use logger instead
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-duplicate-enum-values': 'error',
},
// Include these files in linting
files: ['**/*.ts', '**/*.js'],
},
{
// Ignore specific files and directories. node_modules ignored by default
ignores: ['package-lock.json', 'dist/', 'coverage/'],
},
);
10 changes: 5 additions & 5 deletions express-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"dev": "nodemon --exec ts-node -r tsconfig-paths/register -r dotenv/config ./src/server.ts dotenv_config_path=../.env",
"build": "tsc && tsc-alias",
"lint": "eslint './' --ext .ts,.js",
"lint": "eslint",
"lint:fix": "npm run lint -- --fix",
"format": "prettier --write \"./**/*.{js,ts,json}\"",
"check": "prettier --check \"./**/*.{js,ts,json}\"",
Expand Down Expand Up @@ -46,6 +46,7 @@
"zod": "3.23.3"
},
"devDependencies": {
"@eslint/js": "9.9.1",
"@faker-js/faker": "8.4.0",
"@types/compression": "1.7.4",
"@types/cookie-parser": "1.4.5",
Expand All @@ -60,10 +61,8 @@
"@types/supertest": "6.0.2",
"@types/swagger-jsdoc": "6.0.4",
"@types/swagger-ui-express": "4.1.6",
"@typescript-eslint/eslint-plugin": "8.1.0",
"@typescript-eslint/parser": "8.1.0",
"cross-env": "7.0.3",
"eslint": "8.57.0",
"eslint": "9.9.1",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"jest": "29.7.0",
Expand All @@ -72,6 +71,7 @@
"supertest": "7.0.0",
"ts-jest": "29.2.0",
"tsc-alias": "1.8.8",
"typescript": "5.5.2"
"typescript": "5.5.2",
"typescript-eslint": "8.3.0"
}
}
6 changes: 0 additions & 6 deletions express-api/src/controllers/projects/projectsSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const BuildingSchema = z.object({
description: z.string(),
classificationId: z.number(),
classification: z.string(),
encumbranceReason: z.string(),
agencyId: z.number(),
subAgency: z.string(),
agency: z.string(),
Expand All @@ -72,7 +71,6 @@ const BuildingSchema = z.object({
latitude: z.number(),
longitude: z.number(),
isSensitive: z.boolean(),
isVisibleToOtherAgencies: z.boolean(),
parcelId: z.number(),
buildingConstructionTypeId: z.number(),
buildingConstructionType: z.string(),
Expand All @@ -81,13 +79,9 @@ const BuildingSchema = z.object({
buildingPredominateUse: z.string(),
buildingOccupantTypeId: z.number(),
buildingOccupantType: z.string(),
leaseExpiry: z.string(),
occupantName: z.string(),
buildingTenancy: z.string(),
rentableArea: z.number(),
landArea: z.number(),
zoning: z.string(),
zoningPotential: z.string(),
evaluations: z.array(EvaluationSchema),
fiscals: z.array(FiscalSchema),
});
Expand Down
7 changes: 0 additions & 7 deletions express-api/src/services/buildings/buildingServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,6 @@ export const updateBuildingById = async (building: DeepPartial<Building>, ssoUse
}),
);
}
// Rebuild metadata to avoid overwriting the whole field.
if (existingBuilding.LeasedLandMetadata) {
building.LeasedLandMetadata = {
...existingBuilding.LeasedLandMetadata,
...building.LeasedLandMetadata,
};
}

const updatedBuilding = await buildingRepo.save(building);
return updatedBuilding;
Expand Down
4 changes: 0 additions & 4 deletions express-api/src/services/keycloak/keycloakService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ const syncKeycloakRoles = async () => {
Name: role.name,
IsDisabled: false,
SortOrder: 0,
KeycloakGroupId: null,
Description: undefined,
IsPublic: false,
CreatedById: systemId,
CreatedBy: undefined,
CreatedOn: undefined,
Expand All @@ -67,9 +65,7 @@ const syncKeycloakRoles = async () => {
Name: role.name,
IsDisabled: false,
SortOrder: 0,
KeycloakGroupId: null,
Description: undefined,
IsPublic: false,
CreatedById: undefined,
CreatedOn: undefined,
UpdatedById: systemId,
Expand Down
20 changes: 15 additions & 5 deletions express-api/src/services/projects/projectsServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ const addProject = async (

// If drafts become possible, this can't always be SPP.
project.ProjectNumber = `SPP-${nextval}`;
project.SubmittedOn = new Date();
const queryRunner = AppDataSource.createQueryRunner();
await queryRunner.startTransaction();
try {
Expand Down Expand Up @@ -687,10 +688,6 @@ const updateProject = async (
const queryRunner = AppDataSource.createQueryRunner();
await queryRunner.startTransaction();
try {
// Metadata field is not preserved if a metadata property is set. It is overwritten.
// Construct the proper metadata before continuing.
const newMetadata = { ...originalProject.Metadata, ...project.Metadata };

await handleProjectTasks({ ...project, CreatedById: project.UpdatedById }, queryRunner);
await handleProjectAgencyResponses(
{ ...project, CreatedById: project.UpdatedById },
Expand All @@ -700,10 +697,23 @@ const updateProject = async (
await handleProjectMonetary({ ...project, CreatedById: project.UpdatedById }, queryRunner);
await handleProjectTimestamps({ ...project, CreatedById: project.UpdatedById }, queryRunner);

// Handle timestamps
if (project.StatusId === ProjectStatus.CANCELLED) project.CancelledOn = new Date();
else if (project.StatusId === ProjectStatus.DENIED) project.DeniedOn = new Date();
else if (
[ProjectStatus.DISPOSED, ProjectStatus.TRANSFERRED_WITHIN_GRE].includes(project.StatusId)
)
project.CompletedOn = new Date();
else if (
[ProjectStatus.APPROVED_FOR_ERP, ProjectStatus.APPROVED_FOR_EXEMPTION].includes(
project.StatusId,
)
)
project.ApprovedOn = new Date();

// Update Project
await queryRunner.manager.save(Project, {
...project,
Metadata: newMetadata,
Tasks: undefined,
AgencyResponses: undefined,
Notes: undefined,
Expand Down
18 changes: 2 additions & 16 deletions express-api/src/services/properties/propertiesServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,7 @@ const makeParcelUpsertObject = async (
const pin = numberOrNull(row.PIN) ?? existentParcel?.PIN;
const description = row.Description ?? (existentParcel ? existentParcel.Description : '');
const isSensitive = setNewBool(row.IsSensitive, existentParcel?.IsSensitive, false);
const isVisibleToOtherAgencies = setNewBool(
row.IsVisibleToOtherAgencies,
existentParcel?.IsVisibleToOtherAgencies,
false,
);

return {
Id: existentParcel?.Id,
AgencyId: getAgencyOrThrowIfMismatched(row, lookups, roles).Id,
Expand All @@ -435,7 +431,6 @@ const makeParcelUpsertObject = async (
Address1: row.Address ?? existentParcel?.Address1 ?? null,
AdministrativeAreaId: adminAreaId,
IsSensitive: isSensitive,
IsVisibleToOtherAgencies: isVisibleToOtherAgencies,
PropertyTypeId: 0,
Description: description,
LandArea: numberOrNull(row.LandArea) ?? existentParcel ? existentParcel.LandArea : null,
Expand Down Expand Up @@ -502,11 +497,7 @@ const makeBuildingUpsertObject = async (
const description = row.Description ?? (existentBuilding ? existentBuilding.Description : '');
const rentableArea = row.NetUsableArea ?? (existentBuilding ? existentBuilding.RentableArea : 0);
const isSensitive = setNewBool(row.IsSensitive, existentBuilding?.IsSensitive, false);
const isVisibleToOtherAgencies = setNewBool(
row.IsVisibleToOtherAgencies,
existentBuilding?.IsVisibleToOtherAgencies,
false,
);

const buildingFloorCount =
row.BuildingFloorCount ?? (existentBuilding ? existentBuilding.BuildingFloorCount : 0);
const tenancy = row.BuildingTenancy ?? (existentBuilding ? existentBuilding.BuildingTenancy : '');
Expand All @@ -533,7 +524,6 @@ const makeBuildingUpsertObject = async (
IsSensitive: isSensitive,
Description: description,
Address1: row.Address ?? existentBuilding?.Address1 ?? null,
IsVisibleToOtherAgencies: isVisibleToOtherAgencies,
PropertyTypeId: 1,
RentableArea: rentableArea,
BuildingTenancy: tenancy,
Expand Down Expand Up @@ -605,14 +595,11 @@ export interface ImportRow {
FiscalYear?: number;
AssessedYear?: number;
IsSensitive?: boolean;
IsVisibleToOtherAgencies?: boolean; // TODO: Removed in other PR.
LandArea?: number;
BuildingTenancy?: number;
NetUsableArea?: number;
BuildingFloorCount?: number;
TotalArea?: number;
// Not displayed in UI
LocalId?: string;
}

/**
Expand Down Expand Up @@ -818,7 +805,6 @@ const getPropertiesUnion = async (filter: PropertyUnionFilter) => {

// Add quickfilter part
if (filter.quickFilter) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const quickFilterOptions: FindOptionsWhere<any>[] = [];
const quickfilterFields = [
'Agency',
Expand Down
2 changes: 0 additions & 2 deletions express-api/src/services/users/usersServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ const addKeycloakUserOnHold = async (
KeycloakUserId: normalizedKc.guid,
Username: normalizedKc.username,
Status: UserStatus.OnHold,
IsSystem: false,
EmailVerified: false,
IsDisabled: false,
AgencyId: agencyId,
Position: position,
Expand Down
12 changes: 0 additions & 12 deletions express-api/src/typeorm/Entities/Building.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,9 @@ export class Building extends Property {
@Index()
BuildingOccupantType: BuildingOccupantType;

@Column({ type: 'timestamp', nullable: true })
LeaseExpiry: Date;

@Column({ type: 'character varying', length: 100, nullable: true })
OccupantName: string;

@Column({ type: 'timestamp', nullable: true })
BuildingTenancyUpdatedOn: Date;

@Column({ type: 'character varying', length: 500, nullable: true })
EncumbranceReason: string;

@Column({ type: 'jsonb', nullable: true })
LeasedLandMetadata: LeasedLandMetadata;

@Column({ type: 'real' })
TotalArea: number;

Expand Down
6 changes: 0 additions & 6 deletions express-api/src/typeorm/Entities/Parcel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ export class Parcel extends Property {
@Column({ type: 'real', nullable: true })
LandArea: number;

@Column({ type: 'character varying', length: 50, nullable: true })
Zoning: string;

@Column({ type: 'character varying', length: 50, nullable: true })
ZoningPotential: string;

@Column({ name: 'parent_parcel_id', type: 'int', nullable: true })
ParentParcelId: number;

Expand Down
5 changes: 0 additions & 5 deletions express-api/src/typeorm/Entities/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ export class Project extends SoftDeleteEntity {
@Column('text', { nullable: true })
Description: string;

@Column('jsonb', {
nullable: true,
})
Metadata: ProjectMetadata;

@Column('timestamp', { nullable: true })
SubmittedOn: Date;

Expand Down
6 changes: 0 additions & 6 deletions express-api/src/typeorm/Entities/Role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,9 @@ export class Role extends BaseEntity {
@Column('int', { default: 0 })
SortOrder: number;

@Column('uuid', { nullable: true })
KeycloakGroupId: string;

@Column('text', { nullable: true })
Description: string;

@Column('boolean')
IsPublic: boolean;

@OneToMany(() => User, (user) => user.Role)
Users: Relation<User>[];
}
9 changes: 1 addition & 8 deletions express-api/src/typeorm/Entities/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class User extends BaseEntity {
LastName: string;

@Column({ type: 'character varying', length: 100 })
@Index({ unique: true })
@Index()
Email: string;

@Column({ type: 'character varying', length: 100, nullable: true })
Expand All @@ -50,12 +50,6 @@ export class User extends BaseEntity {
@Column('boolean', { default: false })
IsDisabled: boolean;

@Column('boolean')
EmailVerified: boolean;

@Column('boolean')
IsSystem: boolean;

@Column({ type: 'character varying', length: 1000, nullable: true })
Note: string;

Expand All @@ -73,7 +67,6 @@ export class User extends BaseEntity {
ApprovedOn: Date;

@Column({ type: 'uuid', nullable: true })
@Index({ unique: true })
KeycloakUserId: string;

// Agency Relations
Expand Down
Loading

0 comments on commit da5f2d1

Please sign in to comment.