Task 01 - Typescript
In the first task, we will not be focusing on the frontend yet, but on typescript and writing clean and quality code. We have prepared an npm project in which we have included all the necessary dependencies, which include, among others, typecript, eslint and prettier. Your task will be to add several types and implement four functions.
If any of you are wondering how you can set up the same environment, check out this reference.
Project Overview
In the project you will find the following important files:
-
src/types.ts- a file that contains all the types you will need. This file also describes what each type represents. So there is no need to add any extra type (but it is not forbidden). -
src/index.ts- the file in which you will implement all the functions. The description of each function can be found in the file, each function is annotated with a description of the functionality. -
src/data.ts- the file that contains the data you will be working with. There is ajobslist and apeoplelist. Lastly, thedbobject is used to simulate the database, using the data in theindex.tsfile.
Tasks
- Start by defining the types in the
src/types.tsfile according to the individual descriptions or according to the data in thesrc/data.tsfile or from the attached function call output. - Implement the functions in the
src/index.tsfile according to the individual descriptions. Do not change the typing of parameters and return values. - Use
npm run buildto run thesrc/index.tsfile. The output in the terminal must match the attached output. - Finally, verify that your code meets all linter requirements. The
npm run lintcommand can be used to do this.
Desired output
- getOpenJobs(db)
[
{
"jobId": 101,
"title": "Fix Issue #1",
"description": "...",
"state": {
"stateType": "open"
}
},
{
"jobId": 102,
"title": "Fix Issue #2",
"description": "...",
"state": {
"stateType": "open"
}
},
{
"jobId": 103,
"title": "Fix Issue #3",
"description": "...",
"state": {
"stateType": "open"
}
}
]
------------
- getUnassignedJobPersonPair(db)
[
{
"jobId": 103,
"title": "Fix Issue #3",
"description": "...",
"state": {
"stateType": "open"
}
},
{
"id": 2,
"name": "Eve",
"role": "employee",
"jobs": []
},
]
------------
- getEmployeeWithoutManager(db)
{
"id": 4,
"name": "Mallory",
"role": "employee",
"jobs": []
}
------------
- getAssignedJobs(db)
[
{
"jobId": 101,
"assignedPerson": {
"id": 1,
"name": "Alice",
"role": "employee",
"jobs": [
{
"jobId": 101,
"title": "Fix Issue #1",
"description": "...",
"state": {
"stateType": "open"
}
},
{
"jobId": 102,
"title": "Fix Issue #2",
"description": "...",
"state": {
"stateType": "open"
}
}
]
}
},
{
"jobId": 102,
"assignedPerson": {
"id": 1,
"name": "Alice",
"role": "employee",
"jobs": [
{
"jobId": 101,
"title": "Fix Issue #1",
"description": "...",
"state": {
"stateType": "open"
}
},
{
"jobId": 102,
"title": "Fix Issue #2",
"description": "...",
"state": {
"stateType": "open"
}
}
]
}
},
{
"jobId": 104,
"assignedPerson": {
"id": 3,
"name": "Bob",
"role": "manager",
"jobs": [
{
"jobId": 104,
"title": "Fixing issue #4...",
"description": "...",
"state": {
"stateType": "inProgress",
"startedDate": "2024-02-09T23:00:00.000Z"
}
},
{
"jobId": 105,
"title": "Fixing issue #5...",
"description": "...",
"state": {
"stateType": "inProgress",
"startedDate": "2024-02-10T23:00:00.000Z"
}
}
],
"employees": [
1,
2
]
},
"possibleEmployees": [
{
"id": 2,
"name": "Eve",
"role": "employee",
"jobs": []
}
]
},
{
"jobId": 105,
"assignedPerson": {
"id": 3,
"name": "Bob",
"role": "manager",
"jobs": [
{
"jobId": 104,
"title": "Fixing issue #4...",
"description": "...",
"state": {
"stateType": "inProgress",
"startedDate": "2024-02-09T23:00:00.000Z"
}
},
{
"jobId": 105,
"title": "Fixing issue #5...",
"description": "...",
"state": {
"stateType": "inProgress",
"startedDate": "2024-02-10T23:00:00.000Z"
}
}
],
"employees": [
1,
2
]
},
"possibleEmployees": [
{
"id": 2,
"name": "Eve",
"role": "employee",
"jobs": []
}
]
}
]
------------
Maximum points: 10
Deadline
- Tuesday's group: 23.2. 23:59
- Wednesday's group: 24.2. 23:59