Skip to content
Open
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
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"nrwl.angular-console",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"ms-playwright.playwright"
"ms-playwright.playwright",
"firsttris.vscode-jest-runner"
]
}
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
13 changes: 5 additions & 8 deletions apps/backend/src/aws/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,18 @@ import {
UseGuards,
} from "@nestjs/common";
import { AuthService } from "./auth.service";
import { WriteEntryToTable, UserTimesheets } from "../dynamodb";
import TokenClient from './cognito/cognito.keyparser'
import { TimeSheetSchema } from 'src/db/schemas/Timesheet';
import * as frontendTimesheetSchemas from 'src/db/schemas/Timesheet'
import * as frontendTimesheetSchemas from 'src/db/dynamoSchemas/DynamoTimesheet'
import { RolesGuard } from 'src/utils/guards/roles.guard';
import { UploadTimesheet } from 'src/db/timesheets/UploadTimesheet';
import { TimesheetUpdateRequest } from 'src/db/schemas/UpdateTimesheet';
import { OperationRequestHandler } from 'src/db/timesheets/OperationRequestHandler';
import { Formatter } from 'src/db/timesheets/Formatter';


@Controller("auth")
@UseGuards(RolesGuard)
export class AuthController {

uploadApi = new UploadTimesheet();
operationRequestHandler = new OperationRequestHandler();

constructor(private authService: AuthService) {}

Expand All @@ -35,7 +32,7 @@ export class AuthController {
console.log("Update Timesheet Request: Processing")
console.log("Request received:")
console.log(body)
const result = this.uploadApi.updateTimesheet(body, userId);
const result = this.operationRequestHandler.updateTimesheet(body, userId);
//TODO: Do something with this result?
return result;
}
Expand All @@ -44,7 +41,7 @@ export class AuthController {
@Get("timesheet")
//@Roles('breaktime-management-role')

public async grab_timesheets(@Headers() headers: any): Promise<frontendTimesheetSchemas.TimeSheetSchema[]> {
public async grab_timesheets(@Headers() headers: any): Promise<frontendTimesheetSchemas.DynamoTimesheetSchema[]> {
const userId = await TokenClient.grabUserID(headers);

if (userId) {
Expand Down
1 change: 0 additions & 1 deletion apps/backend/src/aws/cognito/cognito.wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export class CognitoWrapper {
clientId: process.env.AWS_ACCESS_KEY,
});

// TODO : uhhhhh does this require no credentials? I think that it may have something to with how we set up credentialproviders, but not sure... Can anyone get our users' attributes if they have our region and user pool id?
serviceProvider = new CognitoIdentityProviderClient({
region: process.env.AWS_USER_POOL_REGION,
});
Expand Down
80 changes: 0 additions & 80 deletions apps/backend/src/db/Timesheet.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { z } from "zod";
export const CompanySchema = z.object({
CompanyID: z.string(),
CompanyName: z.string(),
AssociateIDs: z.array(z.string().nonempty()),
SupervisorIDs: z.array(z.string().nonempty()),
AssociateIDs: z.array(z.string().min(1)),
SupervisorIDs: z.array(z.string().min(1)),
});

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { z } from "zod";

/**
* Represents the database schema for a note. This can be one of the following types:
* -- Comment: a general comment made for an entry or whole timesheet.
* -- Report: a specific report to reflect an incident that happens and requires admin attention, e.g. no-show or late attendance
*/
export const NoteSchema = z.object({
export const DynamoNoteSchema = z.object({
Type: z.enum(["Comment", "Report"]),
EntryID: z.string(),
AuthorUUID: z.string(),
Expand All @@ -13,52 +14,39 @@ export const NoteSchema = z.object({
State: z.enum(["Active", "Deleted"]),
})

/**
* Represents the database schema for a schedule shift entry, made by a supervisor or admin
*/
export const ScheduleEntrySchema = z.object({
EntryID: z.string(),
Date: z.number(),
StartDateTime: z.number().optional(),
EndDateTime: z.number().optional(),
AuthorUUID: z.string()
})

/**
* Represents the database schema for a clockin/clockout pair in epoch
*/
export const TimeEntrySchema = z.object({
export const DynamoTimeEntrySchema = z.object({
StartDateTime: z.number().optional(),
EndDateTime: z.number().optional(),
AuthorUUID: z.string(),
})


/*
Supported type of cells for each row in a timesheet
@REGULAR - a regular cell
@PTO - Cell signifying paid time off (PTO)
*/
export enum CellType {
export enum DynamoCellType {
REGULAR_LEGACY = "Regular", // No longer using this format for data, but some older timesheet entries may have the 'legacy' type
REGULAR = "Time Worked",
PTO = "PTO"
}

/**
* Represents the database schema for a single shift or entry in the weekly timesheet.
* Represents the database schema for a single shift (visually, a row) in the weekly timesheet.
*/
export const TimesheetEntrySchema = z.object({
Type: z.enum([CellType.REGULAR, CellType.REGULAR_LEGACY, CellType.PTO]).transform((cellType) => cellType === CellType.REGULAR_LEGACY ? CellType.REGULAR : cellType),
export const DynamoShiftSchema = z.object({
Type: z.enum([DynamoCellType.REGULAR, DynamoCellType.REGULAR_LEGACY, DynamoCellType.PTO]).transform((cellType) => cellType === DynamoCellType.REGULAR_LEGACY ? DynamoCellType.REGULAR : cellType),
EntryID: z.string(),
Date: z.number(),
AssociateTimes: TimeEntrySchema.optional(),
SupervisorTimes: TimeEntrySchema.optional(),
AdminTimes: TimeEntrySchema.optional(),
Note: z.array(NoteSchema).optional(),
AssociateTimes: DynamoTimeEntrySchema.optional(),
SupervisorTimes: DynamoTimeEntrySchema.optional(),
AdminTimes: DynamoTimeEntrySchema.optional(),
Note: z.array(DynamoNoteSchema).optional(),
})


// The status is either undefined, for not being at that stage yet, or
// contains the date and author of approving this submission
export const StatusEntryType = z.union(
Expand All @@ -69,31 +57,27 @@ export const StatusEntryType = z.union(
z.undefined()]);

// Status type contains the four stages of the pipeline we have defined
export const TimesheetStatus = z.object({
export const DynamoStatusSchema = z.object({
HoursSubmitted: StatusEntryType,
HoursReviewed: StatusEntryType,
Finalized: StatusEntryType
});



/**
* Represents the database schema for a weekly timesheet
*/
export const TimeSheetSchema = z.object({
export const DynamoTimesheetSchema = z.object({
TimesheetID: z.number(),
UserID: z.string(),
StartDate: z.number(),
Status: TimesheetStatus,
Status: DynamoStatusSchema,
CompanyID: z.string(),
HoursData: z.array(TimesheetEntrySchema).default([]),
ScheduleData: z.array(ScheduleEntrySchema).default([]),
WeekNotes: z.array(NoteSchema).default([]),
HoursData: z.array(DynamoShiftSchema).default([]),
WeekNotes: z.array(DynamoNoteSchema).default([]),
})

export type TimesheetStatus = z.infer<typeof TimesheetStatus>
export type TimeEntrySchema = z.infer<typeof TimeEntrySchema>
export type ScheduleEntrySchema = z.infer<typeof ScheduleEntrySchema>
export type NoteSchema = z.infer<typeof NoteSchema>
export type TimesheetEntrySchema = z.infer<typeof TimesheetEntrySchema>
export type TimeSheetSchema = z.infer<typeof TimeSheetSchema>
export type DynamoStatusSchema = z.infer<typeof DynamoStatusSchema>
export type DynamoTimeEntrySchema = z.infer<typeof DynamoTimeEntrySchema>
export type DynamoNoteSchema = z.infer<typeof DynamoNoteSchema>
export type DynamoShiftSchema = z.infer<typeof DynamoShiftSchema>
export type DynamoTimesheetSchema = z.infer<typeof DynamoTimesheetSchema>
28 changes: 0 additions & 28 deletions apps/backend/src/db/frontend/CellTypes.ts

This file was deleted.

51 changes: 0 additions & 51 deletions apps/backend/src/db/frontend/RowSchema.ts

This file was deleted.

36 changes: 0 additions & 36 deletions apps/backend/src/db/frontend/TimesheetSchema.ts

This file was deleted.

Loading