Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
46 changes: 1 addition & 45 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
"pg": "8.22.0",
"proj4": "2.20.9",
"tsx": "4.23.0",
"uuid": "11.1.1",
"winston-transport": "4.9.0"
Comment thread
sanjaytkbabu marked this conversation as resolved.
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions app/src/controllers/contact.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { v4 as uuidv4 } from 'uuid';
import { randomUUID } from 'node:crypto';

import {
deleteContactService,
Expand Down Expand Up @@ -76,7 +76,7 @@ export const upsertContactController = async (
req: Request<never, never, Contact, never>,
res: Response<Contact, LocalContext>
) => {
const contact = { ...req.body, contactId: req.body.contactId ?? uuidv4() };
const contact = { ...req.body, contactId: req.body.contactId ?? randomUUID() };
const response = await upsertContactsService([contact]);
res.status(200).json(response[0]);
};
10 changes: 6 additions & 4 deletions app/src/db/migrations/20231212000000_init.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/* eslint-disable max-len */
import { NIL, v4 as uuidv4 } from 'uuid';
import { randomUUID } from 'node:crypto';

import { addAuditStamps } from '../utils/migrations/helpers.ts';

import type { Knex } from 'knex';

const NIL_UUID = '00000000-0000-0000-0000-000000000000';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be a app wide constant

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a holdover from when the system id was nil. We shouldn't be using nil elsewhere anymore.


export async function up(knex: Knex): Promise<void> {
return (
Promise.resolve()
Expand Down Expand Up @@ -421,18 +423,18 @@ export async function up(knex: Knex): Promise<void> {
.then(() => {
const users = ['system'];
const items = users.map((user) => ({
user_id: NIL,
user_id: NIL_UUID,
username: user,
active: true,
created_by: NIL
created_by: NIL_UUID
}));
return knex('user').insert(items);
})

.then(() => {
const items = [
{
initiative_id: uuidv4(),
initiative_id: randomUUID(),
code: 'HOUSING',
label: 'Housing'
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/db/migrations/20240904000000_009-rbac.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable max-len */
import { v4 as uuidv4 } from 'uuid';
import { randomUUID } from 'node:crypto';

import { addAuditStamps } from '../utils/migrations/helpers.ts';
import { Action, GroupName, Initiative, Resource, ResourceLegacy } from '../../utils/enums/application.ts';
Expand Down Expand Up @@ -420,7 +420,7 @@ export async function up(knex: Knex): Promise<void> {
if (exists.length === 0) {
const items = [
{
initiative_id: uuidv4(),
initiative_id: randomUUID(),
code: Initiative.PCNS,
label: 'Permit Connect Navigator Service'
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/db/migrations/20241125000000_014-user-contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

/* eslint-disable max-len */
import { v4 as uuidv4 } from 'uuid';
import { randomUUID } from 'node:crypto';

import { addAuditStamps } from '../utils/migrations/helpers.ts';

Expand Down Expand Up @@ -117,7 +117,7 @@ export async function up(knex: Knex): Promise<void> {
.from({ s: 'public.submission' });

submissions = submissions.map((x) => ({
contact_id: uuidv4(),
contact_id: randomUUID(),
...x
}));

Expand All @@ -134,7 +134,7 @@ export async function up(knex: Knex): Promise<void> {
.from({ e: 'public.enquiry' });

enquiries = enquiries.map((x) => ({
contact_id: uuidv4(),
contact_id: randomUUID(),
...x
}));

Expand Down
4 changes: 2 additions & 2 deletions app/src/db/migrations/20250514000000_031-electrification.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable max-len */
import { v4 as uuidv4 } from 'uuid';
import { randomUUID } from 'node:crypto';

import { addAuditStamps } from '../utils/migrations/helpers.ts';
import { Action, GroupName, Initiative, Resource } from '../../utils/enums/application.ts';
Expand Down Expand Up @@ -186,7 +186,7 @@ export async function up(knex: Knex): Promise<void> {
.then(() => {
const items = [
{
initiative_id: uuidv4(),
initiative_id: randomUUID(),
code: 'ELECTRIFICATION',
label: 'Electrification'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { NIL } from 'uuid';

import { SYSTEM_ID } from '../../utils/constants/application.ts';

import type { Knex } from 'knex';

const NIL_UUID = '00000000-0000-0000-0000-000000000000';

export async function up(knex: Knex): Promise<void> {
return Promise.resolve()
.then(() => {
return knex('user').where('user_id', NIL).update({ user_id: SYSTEM_ID });
return knex('user').where('user_id', NIL_UUID).update({ user_id: SYSTEM_ID });
})

.then(() =>
Expand Down Expand Up @@ -118,6 +118,6 @@ export async function down(knex: Knex): Promise<void> {
)

.then(() => {
return knex('user').where('user_id', SYSTEM_ID).update({ user_id: NIL });
return knex('user').where('user_id', SYSTEM_ID).update({ user_id: NIL_UUID });
});
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable max-len */
import { v4 as uuidv4 } from 'uuid';
import { randomUUID } from 'node:crypto';

import {
addAuditStamps,
Expand Down Expand Up @@ -35,7 +35,7 @@ export async function up(knex: Knex): Promise<void> {
.then(() => {
return knex('initiative').insert([
{
initiative_id: uuidv4(),
initiative_id: randomUUID(),
code: Initiative.GENERAL,
label: 'Generic'
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/domains/activity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { v4 as uuidv4 } from 'uuid';
import { randomUUID } from 'node:crypto';

import { Initiative } from '../utils/enums/application.ts';

Expand All @@ -19,7 +19,7 @@ export const createActivity = async (
let id, queryResult;

do {
id = uuidv4().substring(0, 8).toUpperCase();
id = randomUUID().substring(0, 8).toUpperCase();
queryResult = await repositories.activity.findUnique({
where: { activityId: id },
select: { activityId: true }
Expand Down
4 changes: 2 additions & 2 deletions app/src/domains/electrificationProject.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { v4 as uuidv4 } from 'uuid';
import { randomUUID } from 'node:crypto';

import { createActivity } from './activity';
import { Initiative } from '../utils/enums/application';
Expand Down Expand Up @@ -43,7 +43,7 @@ export const generateElectrificationProjectData = async (
if (!activityId) throw new Error('Failed to generate activity ID');

// Put new electrification project together
const UUID = uuidv4();
const UUID = randomUUID();

const electrificationProjectData: ElectrificationProjectBase = {
companyIdRegistered: data.basic?.registeredId ?? null,
Expand Down
4 changes: 2 additions & 2 deletions app/src/domains/enquiry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import config from 'config';
import { v4 as uuidv4 } from 'uuid';
import { randomUUID } from 'node:crypto';

import { createActivity } from './activity';
import { getProjectByActivityId } from './project';
Expand Down Expand Up @@ -118,7 +118,7 @@ export const generateEnquiryData = async (

// Put new enquiry together
return {
enquiryId: data.enquiryId ?? uuidv4(),
enquiryId: data.enquiryId ?? randomUUID(),
activityId: activityId,
relatedActivityId: data.relatedActivityId,
enquiryDescription: data.enquiryDescription,
Expand Down
8 changes: 4 additions & 4 deletions app/src/domains/generalProject.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { v4 as uuidv4 } from 'uuid';
import { randomUUID } from 'node:crypto';

import { createActivity } from './activity';
import { PermitStage, PermitState } from '../db/codes/enums';
Expand Down Expand Up @@ -82,7 +82,7 @@ export const generateGeneralProjectData = async (

if (data.permits.appliedPermits?.length) {
appliedPermits = data.permits.appliedPermits.map((x: Permit) => {
const permitId = x.permitId ?? uuidv4();
const permitId = x.permitId ?? randomUUID();

// Add each tracker for this permit with the proper permitId
x.permitTracking?.forEach((pt) => appliedPermitTrackers.push({ ...pt, permitId }));
Expand Down Expand Up @@ -113,7 +113,7 @@ export const generateGeneralProjectData = async (

if (data.permits.investigatePermits?.length) {
investigatePermits = data.permits.investigatePermits.map((x: Permit) => ({
permitId: x.permitId ?? uuidv4(),
permitId: x.permitId ?? randomUUID(),
permitTypeId: x.permitTypeId,
activityId: activityId,
stage: PermitStage.PRE_SUBMISSION,
Expand Down Expand Up @@ -142,7 +142,7 @@ export const generateGeneralProjectData = async (
...basic,
...location,
...permits,
generalProjectId: uuidv4(),
generalProjectId: randomUUID(),
activityId: activityId,
submittedAt: data.submittedAt ? new Date(data.submittedAt) : new Date(),
applicationStatus: data.applicationStatus ?? ApplicationStatus.NEW,
Expand Down
Loading
Loading