Skip to content

Commit 6142478

Browse files
Phase business logic
1 parent c60d0a5 commit 6142478

31 files changed

+4074
-1058
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Go to `mock-api` folder and run commands `npm i` and `npm start` to start the mo
108108
- Clear and init db `npm run init-db`
109109
- Start app `npm start`
110110
- App is running at `http://localhost:3000`
111-
- Start mock-api, go to `mock-api` folder and `npm start`, mock api is running at `http://localhost:4000`
111+
- Start mock-api, go to `mock-api` folder, run `npm i` and `npm start`, mock api is running at `http://localhost:4000`
112112

113113
## Running tests
114114

Verification.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- You need to run command `npm run sync-es` before you run `Challenges/get challenge` and `Challenges/search challenge` test case.
88

99
## DynamoDB Verification
10-
Run command `npm run view-data <ModelName>` to view table data, ModelName can be `Challenge`, `ChallengeType`, `ChallengeSetting`, `AuditLog`, `Phase`, `TimelineTemplate`or `Attachment`
10+
Run command `npm run view-data <ModelName>` to view table data, ModelName can be `Challenge`, `ChallengeType`, `ChallengeSetting`, `AuditLog`, `Phase`, `TimelineTemplate`, `Attachment` or `ChallengeTypeTimelineTemplate`
1111

1212
## S3 Verification
1313

app-constants.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ const Topics = {
3737
ChallengePhaseDeleted: 'test.new.bus.events', // 'challenge.action.phase.deleted',
3838
TimelineTemplateCreated: 'test.new.bus.events', // 'challenge.action.timeline.template.created',
3939
TimelineTemplateUpdated: 'test.new.bus.events', // 'challenge.action.timeline.template.updated',
40-
TimelineTemplateDeleted: 'test.new.bus.events' // 'challenge.action.timeline.template.deleted'
40+
TimelineTemplateDeleted: 'test.new.bus.events', // 'challenge.action.timeline.template.deleted',
41+
ChallengeTypeTimelineTemplateCreated: 'test.new.bus.events', // 'challenge.action.type.timeline.template.created',
42+
ChallengeTypeTimelineTemplateUpdated: 'test.new.bus.events', // 'challenge.action.type.timeline.template.updated',
43+
ChallengeTypeTimelineTemplateDeleted: 'test.new.bus.events' // 'challenge.action.type.timeline.template.deleted'
4144
}
4245

4346
module.exports = {

config/default.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ module.exports = {
6565
UPDATE: process.env.SCOPE_CHALLENGE_TYPES_UPDATE || 'update:challenge_types',
6666
ALL: process.env.SCOPE_CHALLENGE_TYPES_ALL || 'all:challenge_types'
6767
},
68+
CHALLENGE_TYPE_TIMELINE_TEMPLATES: {
69+
READ: process.env.SCOPE_CHALLENGE_TYPE_TIMELINE_TEMPLATES_READ || 'read:challenge_type_timeline_templates',
70+
CREATE: process.env.SCOPE_CHALLENGE_TYPE_TIMELINE_TEMPLATES_CREATE || 'create:challenge_type_timeline_templates',
71+
UPDATE: process.env.SCOPE_CHALLENGE_TYPE_TIMELINE_TEMPLATES_UPDATE || 'update:challenge_type_timeline_templates',
72+
DELETE: process.env.SCOPE_CHALLENGE_TYPE_TIMELINE_TEMPLATES_DELETE || 'delete:challenge_type_timeline_templates',
73+
ALL: process.env.SCOPE_CHALLENGE_TYPE_TIMELINE_TEMPLATES_ALL || 'all:challenge_type_timeline_templates'
74+
},
6875
CHALLENGE_SETTINGS: {
6976
READ: process.env.SCOPE_CHALLENGE_SETTINGS_READ || 'read:challenge_settings',
7077
CREATE: process.env.SCOPE_CHALLENGE_SETTINGS_CREATE || 'create:challenge_settings',

config/test.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/swagger.yaml

Lines changed: 277 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,232 @@ paths:
14511451
description: Server error
14521452
schema:
14531453
$ref: '#/definitions/ErrorModel'
1454+
/challengeTimelines:
1455+
get:
1456+
tags:
1457+
- ChallengeTypeTimelineTemplates
1458+
description: |
1459+
Retrieve challenge type timeline templates in the system.
1460+
security:
1461+
- bearer: []
1462+
produces:
1463+
- application/json
1464+
parameters:
1465+
- name: typeId
1466+
in: query
1467+
description: Filter by challenge type id
1468+
required: false
1469+
type: string
1470+
- name: timelineTemplateId
1471+
in: query
1472+
description: Filter by timeline template id
1473+
required: false
1474+
type: string
1475+
responses:
1476+
'200':
1477+
description: OK
1478+
schema:
1479+
type: array
1480+
items:
1481+
$ref: '#/definitions/ChallengeTypeTimelineTemplate'
1482+
'400':
1483+
description: Bad request. Request parameters were invalid.
1484+
schema:
1485+
$ref: '#/definitions/ErrorModel'
1486+
'401':
1487+
description: Unauthorized. Fail to authenticate the requester.
1488+
schema:
1489+
$ref: '#/definitions/ErrorModel'
1490+
'403':
1491+
description: >
1492+
Forbidden. The requester does not have the correct permission to
1493+
access the timeline templates
1494+
schema:
1495+
$ref: '#/definitions/ErrorModel'
1496+
'500':
1497+
description: Server error
1498+
schema:
1499+
$ref: '#/definitions/ErrorModel'
1500+
post:
1501+
tags:
1502+
- ChallengeTypeTimelineTemplates
1503+
description: |
1504+
Create a new challenge type timeline template in the system. Only admins can access this endpoint.
1505+
security:
1506+
- bearer: []
1507+
produces:
1508+
- application/json
1509+
parameters:
1510+
- in: body
1511+
name: body
1512+
required: true
1513+
schema:
1514+
$ref: '#/definitions/ChallengeTypeTimelineTemplateData'
1515+
responses:
1516+
'201':
1517+
description: Created - The request was successful and the resource is returned.
1518+
schema:
1519+
$ref: '#/definitions/ChallengeTypeTimelineTemplate'
1520+
'400':
1521+
description: Bad request. Request parameters were invalid.
1522+
schema:
1523+
$ref: '#/definitions/ErrorModel'
1524+
'401':
1525+
description: Unauthorized. Fail to authenticate the requester.
1526+
schema:
1527+
$ref: '#/definitions/ErrorModel'
1528+
'403':
1529+
description: >
1530+
Forbidden. The requester does not have the correct permission to
1531+
create the timeline template
1532+
schema:
1533+
$ref: '#/definitions/ErrorModel'
1534+
'409':
1535+
description: >
1536+
Conflict. Other timeline template has already used the same name.
1537+
schema:
1538+
$ref: '#/definitions/ErrorModel'
1539+
'500':
1540+
description: Server error
1541+
schema:
1542+
$ref: '#/definitions/ErrorModel'
1543+
/challengeTimelines/:challengeTypeTimelineTemplateId:
1544+
get:
1545+
tags:
1546+
- ChallengeTypeTimelineTemplates
1547+
description: Retrieve the challenge type timeline template with provided id.
1548+
security:
1549+
- bearer: []
1550+
produces:
1551+
- application/json
1552+
parameters:
1553+
- name: challengeTypeTimelineTemplateId
1554+
in: path
1555+
required: true
1556+
type: string
1557+
format: UUID
1558+
description: The id of challenge type timeline template to retrieve
1559+
responses:
1560+
'200':
1561+
description: OK
1562+
schema:
1563+
$ref: '#/definitions/ChallengeTypeTimelineTemplate'
1564+
'400':
1565+
description: Bad request. Request parameters were invalid.
1566+
schema:
1567+
$ref: '#/definitions/ErrorModel'
1568+
'401':
1569+
description: Unauthorized. Fail to authenticate the requester.
1570+
schema:
1571+
$ref: '#/definitions/ErrorModel'
1572+
'403':
1573+
description: >
1574+
Forbidden. The requester does not have the correct permission to
1575+
access the timeline template
1576+
schema:
1577+
$ref: '#/definitions/ErrorModel'
1578+
'404':
1579+
description: Entity not found
1580+
schema:
1581+
$ref: '#/definitions/ErrorModel'
1582+
'500':
1583+
description: Server error
1584+
schema:
1585+
$ref: '#/definitions/ErrorModel'
1586+
put:
1587+
tags:
1588+
- ChallengeTypeTimelineTemplates
1589+
description: Update the challenge type timeline template with the specified id. Only admins can access this endpoint.
1590+
security:
1591+
- bearer: []
1592+
produces:
1593+
- application/json
1594+
parameters:
1595+
- name: challengeTypeTimelineTemplateId
1596+
in: path
1597+
required: true
1598+
type: string
1599+
format: UUID
1600+
description: The id of challenge type timeline template to update
1601+
- in: body
1602+
name: body
1603+
required: true
1604+
schema:
1605+
$ref: '#/definitions/ChallengeTypeTimelineTemplateData'
1606+
responses:
1607+
'200':
1608+
description: Updated - The request was successful and the resource is returned.
1609+
schema:
1610+
$ref: '#/definitions/ChallengeTypeTimelineTemplate'
1611+
'400':
1612+
description: Bad request. Request parameters were invalid.
1613+
schema:
1614+
$ref: '#/definitions/ErrorModel'
1615+
'401':
1616+
description: Unauthorized. Fail to authenticate the requester.
1617+
schema:
1618+
$ref: '#/definitions/ErrorModel'
1619+
'403':
1620+
description: >
1621+
Forbidden. The requester does not have the correct permission to
1622+
update the timeline template
1623+
schema:
1624+
$ref: '#/definitions/ErrorModel'
1625+
'404':
1626+
description: Entity not found
1627+
schema:
1628+
$ref: '#/definitions/ErrorModel'
1629+
'409':
1630+
description: >
1631+
Conflict. Other timeline template has already used the same name.
1632+
schema:
1633+
$ref: '#/definitions/ErrorModel'
1634+
'500':
1635+
description: Server error
1636+
schema:
1637+
$ref: '#/definitions/ErrorModel'
1638+
delete:
1639+
tags:
1640+
- ChallengeTypeTimelineTemplates
1641+
description: Delete the challenge type timeline template with provided id. Only admins can access this endpoint.
1642+
security:
1643+
- bearer: []
1644+
produces:
1645+
- application/json
1646+
parameters:
1647+
- name: challengeTypeTimelineTemplateId
1648+
in: path
1649+
required: true
1650+
type: string
1651+
format: UUID
1652+
description: The id of challenge type timeline template to be deleted
1653+
responses:
1654+
'200':
1655+
description: Deleted - The request was successful and the resource is returned.
1656+
schema:
1657+
$ref: '#/definitions/ChallengeTypeTimelineTemplate'
1658+
'400':
1659+
description: Bad request. Request parameters were invalid.
1660+
schema:
1661+
$ref: '#/definitions/ErrorModel'
1662+
'401':
1663+
description: Unauthorized. Fail to authenticate the requester.
1664+
schema:
1665+
$ref: '#/definitions/ErrorModel'
1666+
'403':
1667+
description: >
1668+
Forbidden. The requester does not have the correct permission to
1669+
delete the timeline template
1670+
schema:
1671+
$ref: '#/definitions/ErrorModel'
1672+
'404':
1673+
description: Entity not found
1674+
schema:
1675+
$ref: '#/definitions/ErrorModel'
1676+
'500':
1677+
description: Server error
1678+
schema:
1679+
$ref: '#/definitions/ErrorModel'
14541680
/challengeAuditLogs:
14551681
get:
14561682
tags:
@@ -1725,6 +1951,20 @@ definitions:
17251951
- $ref: '#/definitions/TimelineTemplateData'
17261952
required:
17271953
- id
1954+
ChallengeTypeTimelineTemplate:
1955+
type: object
1956+
allOf:
1957+
- type: object
1958+
properties:
1959+
id:
1960+
type: string
1961+
description: The challenge type timeline template id.
1962+
format: UUID
1963+
- $ref: '#/definitions/ChallengeTypeTimelineTemplateData'
1964+
required:
1965+
- id
1966+
- typeId
1967+
- timelineTemplateId
17281968
ChallengeData:
17291969
type: object
17301970
properties:
@@ -1905,21 +2145,38 @@ definitions:
19052145
PhaseData:
19062146
type: object
19072147
properties:
1908-
name:
1909-
type: string
1910-
description:
2148+
phaseId:
19112149
type: string
2150+
format: UUID
19122151
predecessor:
19132152
type: string
19142153
format: UUID
1915-
isActive:
2154+
name:
2155+
type: string
2156+
description:
2157+
type: string
2158+
isOpen:
19162159
type: boolean
19172160
duration:
19182161
type: number
1919-
required:
1920-
- name
1921-
- isActive
1922-
- duration
2162+
defaultDuration:
2163+
type: number
2164+
scheduledStartDate:
2165+
type: string
2166+
format: date-time
2167+
description: 'ISO-8601 formatted date times (YYYY-MM-DDTHH:mm:ss.sssZ)'
2168+
scheduledEndDate:
2169+
type: string
2170+
format: date-time
2171+
description: 'ISO-8601 formatted date times (YYYY-MM-DDTHH:mm:ss.sssZ)'
2172+
actualStartDate:
2173+
type: string
2174+
format: date-time
2175+
description: 'ISO-8601 formatted date times (YYYY-MM-DDTHH:mm:ss.sssZ)'
2176+
actualEndDate:
2177+
type: string
2178+
format: date-time
2179+
description: 'ISO-8601 formatted date times (YYYY-MM-DDTHH:mm:ss.sssZ)'
19232180
TimelineTemplateData:
19242181
type: object
19252182
properties:
@@ -1937,6 +2194,18 @@ definitions:
19372194
- name
19382195
- isActive
19392196
- phases
2197+
ChallengeTypeTimelineTemplateData:
2198+
type: object
2199+
properties:
2200+
typeId:
2201+
type: string
2202+
format: UUID
2203+
timelineTemplateId:
2204+
type: string
2205+
format: UUID
2206+
required:
2207+
- typeId
2208+
- timelineTemplateId
19402209
AuditLogEntry:
19412210
type: object
19422211
properties:

0 commit comments

Comments
 (0)