@kohost/api-client 1.0.0-alpha.3 → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commands/CheckInReservationCommand.js +23 -0
- package/commands/DiscoverReservationsCommand.js +24 -0
- package/commands/DiscoverRoomsCommand.js +21 -0
- package/commands/DiscoverUsersCommand.js +21 -0
- package/commands/{VerifyDocumentCommand.js → OCRDocumentCommand.js} +4 -8
- package/commands/SendEmailCommand.js +24 -0
- package/commands/SendSMSCommand.js +21 -0
- package/commands/index.js +12 -2
- package/defs/http.js +1 -1
- package/events/EmailSentEvent.js +17 -0
- package/events/Event.js +20 -1
- package/events/SMSSentEvent.js +17 -0
- package/events/ShortLinkCreatedEvent.js +17 -0
- package/events/index.js +7 -0
- package/http/handleResponseError.js +9 -29
- package/http/handleResponseSuccess.js +2 -2
- package/http/index.js +53 -43
- package/index.js +2 -2
- package/models/credential.js +29 -0
- package/models/gateway.js +0 -8
- package/models/identification.js +32 -0
- package/models/index.js +9 -9
- package/models/kohost.js +4 -3
- package/models/product.js +30 -0
- package/models/reservation.js +47 -0
- package/models/room.js +1 -12
- package/models/shortLink.js +29 -0
- package/models/space.js +1 -1
- package/models/thermostat.js +3 -3
- package/models/user.js +0 -2
- package/models/windowCovering.js +1 -1
- package/package.json +11 -10
- package/schemas/admin/property.json +127 -1
- package/schemas/camera.json +3 -3
- package/schemas/courtesy.json +3 -3
- package/schemas/credential.json +28 -0
- package/schemas/definitions/common.json +53 -0
- package/schemas/definitions/device.json +13 -2
- package/schemas/dimmer.json +3 -3
- package/schemas/gateway.json +16 -47
- package/schemas/identification.json +18 -4
- package/schemas/lock.json +6 -3
- package/schemas/mediaSource.json +3 -3
- package/schemas/motionSensor.json +3 -3
- package/schemas/payment.json +3 -1
- package/schemas/product.json +36 -0
- package/schemas/reservation.json +11 -6
- package/schemas/room.json +1 -8
- package/schemas/shortLink.json +30 -0
- package/schemas/switch.json +3 -3
- package/schemas/thermostat.json +11 -10
- package/schemas/user.json +65 -13
- package/schemas/windowCovering.json +3 -3
- package/tests/unit/models/user.test.js +28 -0
- package/useCases/http.json +345 -41
- package/utils/schema.js +2 -2
- package/vite.config.js +22 -0
- package/models/iotGateway.js +0 -29
- package/models/sceneController.js +0 -29
- package/schemas/iotGateway.json +0 -29
- package/schemas/sceneController.json +0 -58
package/schemas/gateway.json
CHANGED
|
@@ -1,61 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
-
"$id": "https://api.kohost.app/schemas/v3/
|
|
4
|
-
"title": "Gateway",
|
|
5
|
-
"description": "Any
|
|
3
|
+
"$id": "https://api.kohost.app/schemas/v3/iotGateway.json",
|
|
4
|
+
"title": "IoT Gateway",
|
|
5
|
+
"description": "Any smart gateway that is an entrypoint for controlling devices",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"properties": {
|
|
8
8
|
"id": {
|
|
9
|
-
"$ref": "https://api.kohost.app/schemas/v3/definitions/
|
|
9
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/id"
|
|
10
10
|
},
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
},
|
|
14
|
-
"hashedAuthKey": {
|
|
15
|
-
"type": "string"
|
|
11
|
+
"type": {
|
|
12
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/type"
|
|
16
13
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"oneOf": [
|
|
21
|
-
{
|
|
22
|
-
"$ref": "https://api.kohost.app/schemas/v3/integration.json"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
|
|
26
|
-
}
|
|
27
|
-
]
|
|
28
|
-
},
|
|
29
|
-
"default": []
|
|
14
|
+
|
|
15
|
+
"supportedNotifications": {
|
|
16
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
|
|
30
17
|
},
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"properties": {
|
|
34
|
-
"upSince": {
|
|
35
|
-
"type": "string",
|
|
36
|
-
"format": "date-time"
|
|
37
|
-
},
|
|
38
|
-
"lastSeen": {
|
|
39
|
-
"type": "string",
|
|
40
|
-
"format": "date-time"
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
"additionalProperties": false
|
|
18
|
+
"notification": {
|
|
19
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/notification"
|
|
44
20
|
},
|
|
45
|
-
"
|
|
46
|
-
"type": "
|
|
47
|
-
"items": {
|
|
48
|
-
"type": "string"
|
|
49
|
-
},
|
|
50
|
-
"default": ["Gateway"]
|
|
51
|
-
},
|
|
52
|
-
"createdAt": {
|
|
53
|
-
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
|
|
21
|
+
"status": {
|
|
22
|
+
"type": "string"
|
|
54
23
|
},
|
|
55
|
-
"
|
|
56
|
-
"$ref": "https://api.kohost.app/schemas/v3/definitions/
|
|
24
|
+
"systemData": {
|
|
25
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
57
26
|
}
|
|
58
27
|
},
|
|
59
28
|
"additionalProperties": false,
|
|
60
|
-
"required": ["id", "
|
|
29
|
+
"required": ["id", "type", "systemData", "status"]
|
|
61
30
|
}
|
|
@@ -3,26 +3,40 @@
|
|
|
3
3
|
"$id": "https://api.kohost.app/schemas/v3/identification.json",
|
|
4
4
|
"title": "Identification",
|
|
5
5
|
"type": "object",
|
|
6
|
-
"required": ["type", "number", "expires"
|
|
6
|
+
"required": ["type", "number", "expires"],
|
|
7
7
|
"properties": {
|
|
8
8
|
"id": {
|
|
9
9
|
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
|
|
10
10
|
},
|
|
11
11
|
"type": {
|
|
12
12
|
"type": "string",
|
|
13
|
-
"enum": ["driversLicense", "passport", "identityCard"]
|
|
13
|
+
"enum": ["driversLicense", "passport", "identityCard", "visa"]
|
|
14
14
|
},
|
|
15
15
|
"number": {
|
|
16
16
|
"string": "string"
|
|
17
17
|
},
|
|
18
18
|
"issued": {
|
|
19
|
-
"
|
|
19
|
+
"type": ["string", "object"],
|
|
20
20
|
"format": "date-time"
|
|
21
21
|
},
|
|
22
22
|
"expires": {
|
|
23
|
-
"
|
|
23
|
+
"type": ["string", "object"],
|
|
24
24
|
"format": "date-time"
|
|
25
25
|
},
|
|
26
|
+
"verified": {
|
|
27
|
+
"type": "boolean",
|
|
28
|
+
"default": false
|
|
29
|
+
},
|
|
30
|
+
"matched": {
|
|
31
|
+
"type": "boolean",
|
|
32
|
+
"default": false
|
|
33
|
+
},
|
|
34
|
+
"firstName": {
|
|
35
|
+
"type": "string"
|
|
36
|
+
},
|
|
37
|
+
"lastName": {
|
|
38
|
+
"type": "string"
|
|
39
|
+
},
|
|
26
40
|
"issuingCountry": {
|
|
27
41
|
"string": "string",
|
|
28
42
|
"minLength": 2,
|
package/schemas/lock.json
CHANGED
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
"id": {
|
|
9
9
|
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/id"
|
|
10
10
|
},
|
|
11
|
+
"name": {
|
|
12
|
+
"type": "string"
|
|
13
|
+
},
|
|
11
14
|
"type": {
|
|
12
15
|
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/type"
|
|
13
16
|
},
|
|
14
17
|
"subType": {
|
|
15
18
|
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/subType"
|
|
16
19
|
},
|
|
17
|
-
"systemData": {
|
|
18
|
-
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
19
|
-
},
|
|
20
20
|
"supportedNotifications": {
|
|
21
21
|
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
|
|
22
22
|
},
|
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
"state": {
|
|
27
27
|
"type": "string",
|
|
28
28
|
"enum": ["locked", "unlocked"]
|
|
29
|
+
},
|
|
30
|
+
"systemData": {
|
|
31
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
29
32
|
}
|
|
30
33
|
},
|
|
31
34
|
"additionalProperties": false,
|
package/schemas/mediaSource.json
CHANGED
|
@@ -136,14 +136,14 @@
|
|
|
136
136
|
"mtsSap"
|
|
137
137
|
]
|
|
138
138
|
},
|
|
139
|
-
"systemData": {
|
|
140
|
-
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
141
|
-
},
|
|
142
139
|
"supportedNotifications": {
|
|
143
140
|
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
|
|
144
141
|
},
|
|
145
142
|
"notification": {
|
|
146
143
|
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/notification"
|
|
144
|
+
},
|
|
145
|
+
"systemData": {
|
|
146
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
147
147
|
}
|
|
148
148
|
},
|
|
149
149
|
"additionalProperties": false,
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/type"
|
|
13
13
|
},
|
|
14
14
|
"systemData": {
|
|
15
|
-
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
16
|
-
},
|
|
17
15
|
"supportedNotifications": {
|
|
18
16
|
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
|
|
19
17
|
},
|
|
20
18
|
"notification": {
|
|
21
19
|
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/notification"
|
|
22
|
-
}
|
|
20
|
+
},
|
|
21
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
22
|
+
}
|
|
23
23
|
},
|
|
24
24
|
"additionalProperties": false,
|
|
25
25
|
"required": ["id", "type", "systemData"]
|
package/schemas/payment.json
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "https://api.kohost.app/schemas/v3/product.json",
|
|
4
|
+
"title": "Product",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["name", "description", "price", "currency"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"id": {
|
|
9
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
|
|
10
|
+
},
|
|
11
|
+
"type": {
|
|
12
|
+
"type": "string"
|
|
13
|
+
},
|
|
14
|
+
"name": {
|
|
15
|
+
"type": "string"
|
|
16
|
+
},
|
|
17
|
+
"description": {
|
|
18
|
+
"string": "string"
|
|
19
|
+
},
|
|
20
|
+
"price": {
|
|
21
|
+
"type": "number"
|
|
22
|
+
},
|
|
23
|
+
"currency": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "ISO 4217 format",
|
|
26
|
+
"minLength": 3,
|
|
27
|
+
"maxLength": 3
|
|
28
|
+
},
|
|
29
|
+
"image": {
|
|
30
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/file"
|
|
31
|
+
},
|
|
32
|
+
"systemData": {
|
|
33
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
package/schemas/reservation.json
CHANGED
|
@@ -20,23 +20,24 @@
|
|
|
20
20
|
"type": "string"
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
|
-
"
|
|
23
|
+
"space": {
|
|
24
24
|
"type": "string"
|
|
25
25
|
},
|
|
26
26
|
"status": {
|
|
27
|
-
"type": "string",
|
|
28
|
-
"enum": ["reserved", "checkedIn", "checkedOut", "cancelled", "noShow"]
|
|
27
|
+
"type": "string",
|
|
28
|
+
"enum": ["reserved", "checkedIn", "checkedOut", "cancelled", "noShow", "enquired", "requested", "optional"],
|
|
29
|
+
"description": " reserved - confirmed by both parties, before check-in\n checkedIn - checked in\n checkedOut - checked out\n cancelled - Cancelled\n noShow - No show\n enquired - Confirmed neither by the customer nor enterprise\n requested - Confirmed by the customer but not the enterprise (waitlist)\n optional - Confirmed by the enterprise but not the customer (holding)"
|
|
29
30
|
},
|
|
30
31
|
"confirmationNumber": {
|
|
31
32
|
"type": "string"
|
|
32
33
|
},
|
|
33
34
|
"checkInDateTime": {
|
|
34
|
-
"type": "string",
|
|
35
|
+
"type": ["string", "object"],
|
|
35
36
|
"format": "date-time"
|
|
36
37
|
},
|
|
37
38
|
"checkOutDateTime": {
|
|
38
|
-
"type": "string",
|
|
39
|
-
"format": "date-time"
|
|
39
|
+
"type": ["string", "object"],
|
|
40
|
+
"format": "date-time"
|
|
40
41
|
},
|
|
41
42
|
"adultCount": {
|
|
42
43
|
"type": "number",
|
|
@@ -61,6 +62,10 @@
|
|
|
61
62
|
},
|
|
62
63
|
"systemData": {
|
|
63
64
|
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
|
|
65
|
+
},
|
|
66
|
+
"metadata": {
|
|
67
|
+
"ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/metadata"
|
|
64
68
|
}
|
|
65
69
|
}
|
|
66
70
|
}
|
|
71
|
+
|
package/schemas/room.json
CHANGED
|
@@ -56,18 +56,11 @@
|
|
|
56
56
|
"$ref": "https://api.kohost.app/schemas/v3/courtesy.json"
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
|
-
"sceneControllers": {
|
|
60
|
-
"type": "array",
|
|
61
|
-
"default": [],
|
|
62
|
-
"items": {
|
|
63
|
-
"$ref": "https://api.kohost.app/schemas/v3/sceneController.json"
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
59
|
"cameras": {
|
|
67
60
|
"type": "array",
|
|
68
61
|
"default": [],
|
|
69
62
|
"items": {
|
|
70
|
-
"$ref": "https://api.kohost.app/schemas/v3/camera.json"
|
|
63
|
+
"$ref": "https://api.kohost.app/schemas/v3/camera.json"
|
|
71
64
|
}
|
|
72
65
|
},
|
|
73
66
|
"sources": {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "https://api.kohost.app/schemas/v3/shortLink.json",
|
|
4
|
+
"title": "Short Link",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["destination", "url"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"id": {
|
|
9
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
|
|
10
|
+
},
|
|
11
|
+
"type": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"default": "shortLink"
|
|
14
|
+
},
|
|
15
|
+
"title": {
|
|
16
|
+
"type": "string"
|
|
17
|
+
},
|
|
18
|
+
"destination": {
|
|
19
|
+
"string": "string",
|
|
20
|
+
"format": "uri"
|
|
21
|
+
},
|
|
22
|
+
"url": {
|
|
23
|
+
"string": "string",
|
|
24
|
+
"format": "uri"
|
|
25
|
+
},
|
|
26
|
+
"systemData": {
|
|
27
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
package/schemas/switch.json
CHANGED
|
@@ -14,9 +14,6 @@
|
|
|
14
14
|
"subType": {
|
|
15
15
|
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/subType"
|
|
16
16
|
},
|
|
17
|
-
"systemData": {
|
|
18
|
-
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
19
|
-
},
|
|
20
17
|
"supportedNotifications": {
|
|
21
18
|
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
|
|
22
19
|
},
|
|
@@ -26,6 +23,9 @@
|
|
|
26
23
|
"state": {
|
|
27
24
|
"type": "string",
|
|
28
25
|
"enum": ["on", "off"]
|
|
26
|
+
},
|
|
27
|
+
"systemData": {
|
|
28
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"additionalProperties": false,
|
package/schemas/thermostat.json
CHANGED
|
@@ -18,10 +18,6 @@
|
|
|
18
18
|
"subType": {
|
|
19
19
|
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/subType"
|
|
20
20
|
},
|
|
21
|
-
"systemData": {
|
|
22
|
-
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData",
|
|
23
|
-
"default": {}
|
|
24
|
-
},
|
|
25
21
|
"supportedNotifications": {
|
|
26
22
|
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
|
|
27
23
|
},
|
|
@@ -29,12 +25,10 @@
|
|
|
29
25
|
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/notification"
|
|
30
26
|
},
|
|
31
27
|
"currentTemperature": {
|
|
32
|
-
"type": "number"
|
|
33
|
-
"minimum": 0,
|
|
34
|
-
"maximum": 130
|
|
28
|
+
"type": "number"
|
|
35
29
|
},
|
|
36
30
|
"currentHumidity": {
|
|
37
|
-
"type":
|
|
31
|
+
"type": "number",
|
|
38
32
|
"minimum": 0,
|
|
39
33
|
"maximum": 99
|
|
40
34
|
},
|
|
@@ -80,6 +74,7 @@
|
|
|
80
74
|
},
|
|
81
75
|
"setpoints": {
|
|
82
76
|
"type": "object",
|
|
77
|
+
"additionalProperties": false,
|
|
83
78
|
"properties": {
|
|
84
79
|
"cool": {
|
|
85
80
|
"$ref": "#/$defs/setpoint"
|
|
@@ -91,6 +86,13 @@
|
|
|
91
86
|
"$ref": "#/$defs/setpoint"
|
|
92
87
|
}
|
|
93
88
|
}
|
|
89
|
+
},
|
|
90
|
+
"batteryLevel": {
|
|
91
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/batteryLevel"
|
|
92
|
+
},
|
|
93
|
+
"systemData": {
|
|
94
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData",
|
|
95
|
+
"default": {}
|
|
94
96
|
}
|
|
95
97
|
},
|
|
96
98
|
"additionalProperties": false,
|
|
@@ -125,7 +127,6 @@
|
|
|
125
127
|
"id",
|
|
126
128
|
"type",
|
|
127
129
|
"systemData",
|
|
128
|
-
"currentTemperature",
|
|
129
130
|
"hvacMode",
|
|
130
131
|
"fanMode",
|
|
131
132
|
"hvacState",
|
|
@@ -133,6 +134,6 @@
|
|
|
133
134
|
"setpoints",
|
|
134
135
|
"temperatureScale",
|
|
135
136
|
"supportedHvacModes",
|
|
136
|
-
"supportedFanModes"
|
|
137
|
+
"supportedFanModes"
|
|
137
138
|
]
|
|
138
139
|
}
|
package/schemas/user.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"default": "user"
|
|
14
14
|
},
|
|
15
15
|
"active": {
|
|
16
|
-
"type": "boolean",
|
|
16
|
+
"type": "boolean",
|
|
17
17
|
"default": true
|
|
18
18
|
},
|
|
19
19
|
"firstName": {
|
|
@@ -23,14 +23,23 @@
|
|
|
23
23
|
"type": "string"
|
|
24
24
|
},
|
|
25
25
|
"phone": {
|
|
26
|
-
"type": "string",
|
|
27
|
-
"pattern": "
|
|
26
|
+
"type": ["string", "null"],
|
|
27
|
+
"pattern": "^\\+[0-9]{1,14}$"
|
|
28
|
+
},
|
|
29
|
+
"phoneVerified": {
|
|
30
|
+
"type": "boolean"
|
|
28
31
|
},
|
|
29
32
|
"email": {
|
|
30
|
-
"type": "string",
|
|
33
|
+
"type": ["string", "null"],
|
|
31
34
|
"format": "email"
|
|
32
35
|
},
|
|
33
|
-
"
|
|
36
|
+
"emailVerified": {
|
|
37
|
+
"type": "boolean"
|
|
38
|
+
},
|
|
39
|
+
"address": {
|
|
40
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/address"
|
|
41
|
+
},
|
|
42
|
+
"secretKey": {
|
|
34
43
|
"type": "string"
|
|
35
44
|
},
|
|
36
45
|
"photo": {
|
|
@@ -43,7 +52,25 @@
|
|
|
43
52
|
"type": "string"
|
|
44
53
|
},
|
|
45
54
|
"gender": {
|
|
46
|
-
"type": "string"
|
|
55
|
+
"type": "string",
|
|
56
|
+
"enum": ["male", "female"]
|
|
57
|
+
},
|
|
58
|
+
"nationality": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"minLength": 2,
|
|
61
|
+
"maxLength": 2
|
|
62
|
+
},
|
|
63
|
+
"notes": {
|
|
64
|
+
"type": "array",
|
|
65
|
+
"items": {
|
|
66
|
+
"type": "string"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"files": {
|
|
70
|
+
"type": "array",
|
|
71
|
+
"items": {
|
|
72
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/file"
|
|
73
|
+
}
|
|
47
74
|
},
|
|
48
75
|
"roles": {
|
|
49
76
|
"type": "array",
|
|
@@ -62,20 +89,20 @@
|
|
|
62
89
|
}
|
|
63
90
|
},
|
|
64
91
|
"identifications": {
|
|
65
|
-
"type":"array",
|
|
92
|
+
"type": "array",
|
|
66
93
|
"items": {
|
|
67
|
-
"$ref": "https://api.kohost.app/schemas/v3/identification.json"
|
|
94
|
+
"$ref": "https://api.kohost.app/schemas/v3/identification.json#"
|
|
68
95
|
}
|
|
69
|
-
},
|
|
96
|
+
},
|
|
70
97
|
"payments": {
|
|
71
|
-
"type":"array",
|
|
98
|
+
"type": "array",
|
|
72
99
|
"items": {
|
|
73
|
-
"$ref": "https://api.kohost.app/schemas/v3/payment.json"
|
|
100
|
+
"$ref": "https://api.kohost.app/schemas/v3/payment.json#"
|
|
74
101
|
}
|
|
75
102
|
},
|
|
76
103
|
"preferences": {
|
|
77
104
|
"type": "object",
|
|
78
|
-
"additionalProperties": false,
|
|
105
|
+
"additionalProperties": false,
|
|
79
106
|
"properties": {
|
|
80
107
|
"notifications": {
|
|
81
108
|
"type": "array",
|
|
@@ -110,7 +137,32 @@
|
|
|
110
137
|
"type": ["number", "null"]
|
|
111
138
|
}
|
|
112
139
|
}
|
|
113
|
-
},
|
|
140
|
+
},
|
|
141
|
+
"registeredDevices": {
|
|
142
|
+
"type": "array",
|
|
143
|
+
"items": {
|
|
144
|
+
"type": "object",
|
|
145
|
+
"properties": {
|
|
146
|
+
"userAgent": {
|
|
147
|
+
"type": "string"
|
|
148
|
+
},
|
|
149
|
+
"fingerPrint": {
|
|
150
|
+
"type": "string"
|
|
151
|
+
},
|
|
152
|
+
"ip": {
|
|
153
|
+
"type": "string"
|
|
154
|
+
},
|
|
155
|
+
"registeredAt": {
|
|
156
|
+
"type": "string",
|
|
157
|
+
"format": "date-time"
|
|
158
|
+
},
|
|
159
|
+
"expiresAt": {
|
|
160
|
+
"type": "string",
|
|
161
|
+
"format": "date-time"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
},
|
|
114
166
|
"createdAt": {
|
|
115
167
|
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
|
|
116
168
|
},
|
|
@@ -14,9 +14,6 @@
|
|
|
14
14
|
"subType": {
|
|
15
15
|
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/subType"
|
|
16
16
|
},
|
|
17
|
-
"systemData": {
|
|
18
|
-
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
19
|
-
},
|
|
20
17
|
"supportedNotifications": {
|
|
21
18
|
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
|
|
22
19
|
},
|
|
@@ -27,6 +24,9 @@
|
|
|
27
24
|
"type": "number",
|
|
28
25
|
"minimum": 0,
|
|
29
26
|
"maximum": 100
|
|
27
|
+
},
|
|
28
|
+
"systemData": {
|
|
29
|
+
"$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"additionalProperties": false,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const User = require("../../../models/user");
|
|
2
|
+
|
|
3
|
+
const valid = {
|
|
4
|
+
firstName: "Ian",
|
|
5
|
+
lastName: "Rogers",
|
|
6
|
+
active: true,
|
|
7
|
+
type: "user",
|
|
8
|
+
email: "a3@bc.com",
|
|
9
|
+
phone: "+15555555555",
|
|
10
|
+
roles: ["Guest"],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
test("does not throw error if invalid name provided ", () => {
|
|
14
|
+
const data = { ...valid };
|
|
15
|
+
expect(() => new User(data)).not.toThrow();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("allows email to be empty", () => {
|
|
19
|
+
const data = { ...valid };
|
|
20
|
+
delete data.email;
|
|
21
|
+
expect(() => new User(data)).not.toThrow();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test("allows phone to be empty", () => {
|
|
25
|
+
const data = { ...valid };
|
|
26
|
+
delete data.phone;
|
|
27
|
+
expect(() => new User(data)).not.toThrow();
|
|
28
|
+
});
|