@internetderdinge/api 1.229.39 → 1.229.41
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/dist/src/accounts/accounts.schemas.js +40 -10
- package/dist/src/accounts/accounts.validation.js +47 -10
- package/dist/src/admin/adminSearch.route.js +4 -0
- package/dist/src/devices/devices.route.js +6 -2
- package/dist/src/devices/devices.schemas.js +54 -14
- package/dist/src/devices/devices.validation.js +80 -13
- package/dist/src/index.js +1 -0
- package/dist/src/iotdevice/iotdevice.schemas.js +117 -33
- package/dist/src/iotdevice/iotdevice.validation.js +27 -5
- package/dist/src/organizations/organizations.schemas.js +28 -5
- package/dist/src/organizations/organizations.validation.js +22 -11
- package/dist/src/tokens/tokens.schemas.js +35 -12
- package/dist/src/tokens/tokens.validation.js +8 -2
- package/dist/src/users/users.schemas.js +40 -11
- package/dist/src/users/users.validation.js +70 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/accounts/accounts.schemas.ts +40 -10
- package/src/accounts/accounts.validation.ts +64 -26
- package/src/admin/adminSearch.route.ts +4 -0
- package/src/devices/devices.route.ts +10 -2
- package/src/devices/devices.schemas.ts +55 -14
- package/src/devices/devices.validation.ts +97 -28
- package/src/index.ts +4 -0
- package/src/iotdevice/iotdevice.schemas.ts +117 -33
- package/src/iotdevice/iotdevice.validation.ts +38 -16
- package/src/organizations/organizations.schemas.ts +28 -5
- package/src/organizations/organizations.validation.ts +49 -37
- package/src/tokens/tokens.schemas.ts +35 -12
- package/src/tokens/tokens.validation.ts +9 -3
- package/src/users/users.schemas.ts +40 -11
- package/src/users/users.validation.ts +88 -21
|
@@ -5,67 +5,151 @@ extendZodWithOpenApi(z);
|
|
|
5
5
|
|
|
6
6
|
// Represents a device in the system
|
|
7
7
|
export const iotDeviceResponseSchema = z.object({
|
|
8
|
-
deviceId: z.string(),
|
|
9
|
-
name: z.string(),
|
|
10
|
-
model: z.string().optional(),
|
|
11
|
-
firmwareVersion: z.string().optional(),
|
|
12
|
-
registeredAt: z
|
|
13
|
-
|
|
8
|
+
deviceId: z.string().openapi({ example: 'nrf-352656106701140' }),
|
|
9
|
+
name: z.string().openapi({ example: 'Kitchen Display' }),
|
|
10
|
+
model: z.string().optional().openapi({ example: 'OpenPaper 7' }),
|
|
11
|
+
firmwareVersion: z.string().optional().openapi({ example: '1.2.3' }),
|
|
12
|
+
registeredAt: z
|
|
13
|
+
.string()
|
|
14
|
+
.datetime()
|
|
15
|
+
.openapi({ example: '2026-05-21T09:30:00.000Z' }),
|
|
16
|
+
lastSeenAt: z
|
|
17
|
+
.string()
|
|
18
|
+
.datetime()
|
|
19
|
+
.optional()
|
|
20
|
+
.openapi({ example: '2026-05-21T10:15:00.000Z' }),
|
|
21
|
+
}).openapi({
|
|
22
|
+
example: {
|
|
23
|
+
deviceId: 'nrf-352656106701140',
|
|
24
|
+
name: 'Kitchen Display',
|
|
25
|
+
model: 'OpenPaper 7',
|
|
26
|
+
firmwareVersion: '1.2.3',
|
|
27
|
+
registeredAt: '2026-05-21T09:30:00.000Z',
|
|
28
|
+
lastSeenAt: '2026-05-21T10:15:00.000Z',
|
|
29
|
+
},
|
|
14
30
|
});
|
|
15
31
|
|
|
16
32
|
// An event generated by a device
|
|
17
33
|
export const eventResponseSchema = z.object({
|
|
18
|
-
eventId: z.string(),
|
|
19
|
-
deviceId: z.string(),
|
|
20
|
-
timestamp: z
|
|
21
|
-
|
|
22
|
-
|
|
34
|
+
eventId: z.string().openapi({ example: 'evt_01HX0000000000000000000000' }),
|
|
35
|
+
deviceId: z.string().openapi({ example: 'nrf-352656106701140' }),
|
|
36
|
+
timestamp: z
|
|
37
|
+
.string()
|
|
38
|
+
.datetime()
|
|
39
|
+
.openapi({ example: '2026-05-21T10:15:00.000Z' }),
|
|
40
|
+
type: z.string().openapi({ example: 'state' }),
|
|
41
|
+
payload: z.any().openapi({ example: { battery: 87, online: true } }),
|
|
42
|
+
}).openapi({
|
|
43
|
+
example: {
|
|
44
|
+
eventId: 'evt_01HX0000000000000000000000',
|
|
45
|
+
deviceId: 'nrf-352656106701140',
|
|
46
|
+
timestamp: '2026-05-21T10:15:00.000Z',
|
|
47
|
+
type: 'state',
|
|
48
|
+
payload: {
|
|
49
|
+
battery: 87,
|
|
50
|
+
online: true,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
23
53
|
});
|
|
24
54
|
|
|
25
55
|
// A single device fetched by criteria
|
|
26
56
|
export const deviceResponseSchema = z.object({
|
|
27
|
-
deviceId: z.string(),
|
|
28
|
-
serialNumber: z.string(),
|
|
29
|
-
type: z.string(),
|
|
30
|
-
owner: z.string(),
|
|
31
|
-
registeredAt: z
|
|
57
|
+
deviceId: z.string().openapi({ example: 'nrf-352656106701140' }),
|
|
58
|
+
serialNumber: z.string().openapi({ example: 'nrf-352656106701140' }),
|
|
59
|
+
type: z.string().openapi({ example: 'paper-display' }),
|
|
60
|
+
owner: z.string().openapi({ example: '682fd0d7d4a6325d9d45b86e' }),
|
|
61
|
+
registeredAt: z
|
|
62
|
+
.string()
|
|
63
|
+
.datetime()
|
|
64
|
+
.openapi({ example: '2026-05-21T09:30:00.000Z' }),
|
|
65
|
+
}).openapi({
|
|
66
|
+
example: {
|
|
67
|
+
deviceId: 'nrf-352656106701140',
|
|
68
|
+
serialNumber: 'nrf-352656106701140',
|
|
69
|
+
type: 'paper-display',
|
|
70
|
+
owner: '682fd0d7d4a6325d9d45b86e',
|
|
71
|
+
registeredAt: '2026-05-21T09:30:00.000Z',
|
|
72
|
+
},
|
|
32
73
|
});
|
|
33
74
|
|
|
34
75
|
// Shadow alarm settings
|
|
35
76
|
export const shadowAlarmSchema = z.object({
|
|
36
|
-
enabled: z.boolean(),
|
|
37
|
-
threshold: z.number(),
|
|
38
|
-
mode: z.enum(['auto', 'manual']).optional(),
|
|
77
|
+
enabled: z.boolean().openapi({ example: true }),
|
|
78
|
+
threshold: z.number().openapi({ example: 80 }),
|
|
79
|
+
mode: z.enum(['auto', 'manual']).optional().openapi({ example: 'auto' }),
|
|
80
|
+
}).openapi({
|
|
81
|
+
example: {
|
|
82
|
+
enabled: true,
|
|
83
|
+
threshold: 80,
|
|
84
|
+
mode: 'auto',
|
|
85
|
+
},
|
|
39
86
|
});
|
|
40
87
|
|
|
41
88
|
// Ping / LED light response
|
|
42
89
|
export const pingResponseSchema = z.object({
|
|
43
|
-
success: z.boolean(),
|
|
44
|
-
message: z.string().optional(),
|
|
45
|
-
timestamp: z
|
|
90
|
+
success: z.boolean().openapi({ example: true }),
|
|
91
|
+
message: z.string().optional().openapi({ example: 'Device responded' }),
|
|
92
|
+
timestamp: z
|
|
93
|
+
.string()
|
|
94
|
+
.datetime()
|
|
95
|
+
.openapi({ example: '2026-05-21T10:15:00.000Z' }),
|
|
96
|
+
}).openapi({
|
|
97
|
+
example: {
|
|
98
|
+
success: true,
|
|
99
|
+
message: 'Device responded',
|
|
100
|
+
timestamp: '2026-05-21T10:15:00.000Z',
|
|
101
|
+
},
|
|
46
102
|
});
|
|
47
103
|
|
|
48
104
|
// Current status of a device
|
|
49
105
|
export const deviceStatusSchema = z.object({
|
|
50
|
-
deviceId: z.string(),
|
|
51
|
-
online: z.boolean(),
|
|
52
|
-
batteryLevel: z.number().min(0).max(100).optional(),
|
|
53
|
-
lastSeenAt: z
|
|
106
|
+
deviceId: z.string().openapi({ example: 'nrf-352656106701140' }),
|
|
107
|
+
online: z.boolean().openapi({ example: true }),
|
|
108
|
+
batteryLevel: z.number().min(0).max(100).optional().openapi({ example: 87 }),
|
|
109
|
+
lastSeenAt: z
|
|
110
|
+
.string()
|
|
111
|
+
.datetime()
|
|
112
|
+
.openapi({ example: '2026-05-21T10:15:00.000Z' }),
|
|
113
|
+
}).openapi({
|
|
114
|
+
example: {
|
|
115
|
+
deviceId: 'nrf-352656106701140',
|
|
116
|
+
online: true,
|
|
117
|
+
batteryLevel: 87,
|
|
118
|
+
lastSeenAt: '2026-05-21T10:15:00.000Z',
|
|
119
|
+
},
|
|
54
120
|
});
|
|
55
121
|
|
|
56
122
|
// API status by kind
|
|
57
123
|
export const apiStatusSchema = z.object({
|
|
58
|
-
kind: z.string(),
|
|
59
|
-
status: z.enum(['ok', 'degraded', 'down']),
|
|
60
|
-
uptimeSeconds: z.number(),
|
|
124
|
+
kind: z.string().openapi({ example: 'iot' }),
|
|
125
|
+
status: z.enum(['ok', 'degraded', 'down']).openapi({ example: 'ok' }),
|
|
126
|
+
uptimeSeconds: z.number().openapi({ example: 86400 }),
|
|
127
|
+
}).openapi({
|
|
128
|
+
example: {
|
|
129
|
+
kind: 'iot',
|
|
130
|
+
status: 'ok',
|
|
131
|
+
uptimeSeconds: 86400,
|
|
132
|
+
},
|
|
61
133
|
});
|
|
62
134
|
|
|
63
135
|
// Single entry for a device
|
|
64
136
|
export const entryResponseSchema = z.object({
|
|
65
|
-
entryId: z.string(),
|
|
66
|
-
deviceId: z.string(),
|
|
67
|
-
timestamp: z
|
|
68
|
-
|
|
137
|
+
entryId: z.string().openapi({ example: 'entry_01HX0000000000000000000000' }),
|
|
138
|
+
deviceId: z.string().openapi({ example: 'nrf-352656106701140' }),
|
|
139
|
+
timestamp: z
|
|
140
|
+
.string()
|
|
141
|
+
.datetime()
|
|
142
|
+
.openapi({ example: '2026-05-21T10:15:00.000Z' }),
|
|
143
|
+
data: z.any().openapi({ example: { state: 'active' } }),
|
|
144
|
+
}).openapi({
|
|
145
|
+
example: {
|
|
146
|
+
entryId: 'entry_01HX0000000000000000000000',
|
|
147
|
+
deviceId: 'nrf-352656106701140',
|
|
148
|
+
timestamp: '2026-05-21T10:15:00.000Z',
|
|
149
|
+
data: {
|
|
150
|
+
state: 'active',
|
|
151
|
+
},
|
|
152
|
+
},
|
|
69
153
|
});
|
|
70
154
|
|
|
71
155
|
// Optionally infer TS types
|
|
@@ -9,9 +9,17 @@ export const getDevice = {
|
|
|
9
9
|
params: z.object({
|
|
10
10
|
deviceId: zObjectId.openapi({ description: 'Device ObjectId' }),
|
|
11
11
|
}),
|
|
12
|
-
body: z
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
body: z
|
|
13
|
+
.object({
|
|
14
|
+
deviceId: z
|
|
15
|
+
.array(zObjectId)
|
|
16
|
+
.openapi({ description: 'Array of device IDs' }),
|
|
17
|
+
})
|
|
18
|
+
.openapi({
|
|
19
|
+
example: {
|
|
20
|
+
deviceId: ['682fd0d7d4a6325d9d45b86f'],
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
15
23
|
};
|
|
16
24
|
export const iotDevicesSchema = {
|
|
17
25
|
...zPagination,
|
|
@@ -30,19 +38,33 @@ export const getEventsSchema = {
|
|
|
30
38
|
params: z.object({
|
|
31
39
|
deviceId: zObjectId.openapi({ description: 'Device ObjectId' }),
|
|
32
40
|
}),
|
|
33
|
-
query: z
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
query: z
|
|
42
|
+
.object({
|
|
43
|
+
DateStart: z
|
|
44
|
+
.string()
|
|
45
|
+
.datetime()
|
|
46
|
+
.openapi({
|
|
47
|
+
description: 'Start date (ISO‐string)',
|
|
48
|
+
example: '2026-05-01T00:00:00Z',
|
|
49
|
+
})
|
|
50
|
+
.optional(),
|
|
51
|
+
DateEnd: z
|
|
52
|
+
.string()
|
|
53
|
+
.datetime()
|
|
54
|
+
.openapi({
|
|
55
|
+
description: 'End date (ISO‐string)',
|
|
56
|
+
example: '2026-05-21T23:59:59Z',
|
|
57
|
+
})
|
|
58
|
+
.optional(),
|
|
59
|
+
TypeFilter: zTypeFilter.default(''),
|
|
60
|
+
})
|
|
61
|
+
.openapi({
|
|
62
|
+
example: {
|
|
63
|
+
DateStart: '2026-05-01T00:00:00Z',
|
|
64
|
+
DateEnd: '2026-05-21T23:59:59Z',
|
|
65
|
+
TypeFilter: 'state',
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
46
68
|
};
|
|
47
69
|
export const updateEntrySchema = {};
|
|
48
70
|
|
|
@@ -1,8 +1,31 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
3
|
export const organizationResponseSchema = z.object({
|
|
4
|
-
id: z
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
id: z
|
|
5
|
+
.string()
|
|
6
|
+
.openapi({ example: "682fd0d7d4a6325d9d45b86e" }),
|
|
7
|
+
name: z
|
|
8
|
+
.string()
|
|
9
|
+
.openapi({ example: "Acme Inc.", description: "Organization name" }),
|
|
10
|
+
email: z
|
|
11
|
+
.string()
|
|
12
|
+
.email()
|
|
13
|
+
.openapi({
|
|
14
|
+
example: "contact@acme.example",
|
|
15
|
+
description: "Primary contact email",
|
|
16
|
+
}),
|
|
17
|
+
kind: z
|
|
18
|
+
.string()
|
|
19
|
+
.optional()
|
|
20
|
+
.openapi({
|
|
21
|
+
example: "private",
|
|
22
|
+
description: "The type or category of the organization",
|
|
23
|
+
}),
|
|
24
|
+
}).openapi({
|
|
25
|
+
example: {
|
|
26
|
+
id: "682fd0d7d4a6325d9d45b86e",
|
|
27
|
+
name: "Acme Inc.",
|
|
28
|
+
email: "contact@acme.example",
|
|
29
|
+
kind: "private",
|
|
30
|
+
},
|
|
8
31
|
});
|
|
@@ -13,20 +13,18 @@ import {
|
|
|
13
13
|
extendZodWithOpenApi(z);
|
|
14
14
|
|
|
15
15
|
export const createOrganizationSchema = {
|
|
16
|
-
body: z
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
description: "The type or category of the organization",
|
|
16
|
+
body: z
|
|
17
|
+
.object({
|
|
18
|
+
kind: z.string().openapi({
|
|
19
|
+
example: "private",
|
|
20
|
+
description: "The type or category of the organization",
|
|
21
|
+
}),
|
|
22
|
+
})
|
|
23
|
+
.openapi({
|
|
24
|
+
example: {
|
|
25
|
+
kind: "private",
|
|
26
|
+
},
|
|
28
27
|
}),
|
|
29
|
-
}),
|
|
30
28
|
};
|
|
31
29
|
|
|
32
30
|
export const queryOrganizationsSchema = zPagination;
|
|
@@ -35,30 +33,44 @@ export const getOrganizationByIdSchema = zGet("organizationId");
|
|
|
35
33
|
|
|
36
34
|
export const updateOrganizationSchema = {
|
|
37
35
|
...zUpdate("organizationId"),
|
|
38
|
-
body: z
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
36
|
+
body: z
|
|
37
|
+
.object({
|
|
38
|
+
name: z
|
|
39
|
+
.string()
|
|
40
|
+
.openapi({
|
|
41
|
+
example: "Acme Inc.",
|
|
42
|
+
description: "The name of the organization",
|
|
43
|
+
})
|
|
44
|
+
.optional(),
|
|
45
|
+
organization: zObjectId, // Legacy field, to be removed later
|
|
46
|
+
kind: z
|
|
47
|
+
.string()
|
|
48
|
+
.openapi({
|
|
49
|
+
example: "private",
|
|
50
|
+
description: "The type or category of the organization",
|
|
51
|
+
})
|
|
52
|
+
.optional(),
|
|
53
|
+
meta: z
|
|
54
|
+
.record(z.string(), z.any())
|
|
55
|
+
.openapi({
|
|
56
|
+
example: { billingId: "cus_123", region: "eu" },
|
|
57
|
+
description: "Additional metadata for the entry",
|
|
58
|
+
})
|
|
59
|
+
.optional(),
|
|
60
|
+
})
|
|
61
|
+
.openapi({
|
|
62
|
+
example: {
|
|
63
|
+
name: "Acme Inc.",
|
|
64
|
+
organization:
|
|
65
|
+
process.env.SCHEMA_EXAMPLE_ORGANIZATION_ID ||
|
|
66
|
+
"682fd0d7d4a6325d9d45b86d",
|
|
67
|
+
kind: "private",
|
|
68
|
+
meta: {
|
|
69
|
+
billingId: "cus_123",
|
|
70
|
+
region: "eu",
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
62
74
|
//...zUpdate('organizationId'),
|
|
63
75
|
/* body: z.object({
|
|
64
76
|
meta: z.any,
|
|
@@ -1,15 +1,38 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
3
|
export const tokenResponseSchema = z.object({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
tokenId: z
|
|
5
|
+
.string()
|
|
6
|
+
.openapi({
|
|
7
|
+
example: "682fd0d7d4a6325d9d45b872",
|
|
8
|
+
description: "Token ObjectId",
|
|
9
|
+
}),
|
|
10
|
+
userId: z
|
|
11
|
+
.string()
|
|
12
|
+
.openapi({
|
|
13
|
+
example: "682fd0d7d4a6325d9d45b86d",
|
|
14
|
+
description: "Owning user ObjectId",
|
|
15
|
+
}),
|
|
16
|
+
name: z.string().optional().openapi({ example: "Admin integration token" }),
|
|
17
|
+
token: z.string().openapi({
|
|
18
|
+
example: "idt_live_1234567890abcdef",
|
|
19
|
+
description: "Token secret. Usually only returned immediately after creation.",
|
|
20
|
+
}),
|
|
21
|
+
createdAt: z
|
|
22
|
+
.string()
|
|
23
|
+
.datetime()
|
|
24
|
+
.openapi({ example: "2026-05-21T09:30:00.000Z" }),
|
|
25
|
+
updatedAt: z
|
|
26
|
+
.string()
|
|
27
|
+
.datetime()
|
|
28
|
+
.openapi({ example: "2026-05-21T10:15:00.000Z" }),
|
|
29
|
+
}).openapi({
|
|
30
|
+
example: {
|
|
31
|
+
tokenId: "682fd0d7d4a6325d9d45b872",
|
|
32
|
+
userId: "682fd0d7d4a6325d9d45b86d",
|
|
33
|
+
name: "Admin integration token",
|
|
34
|
+
token: "idt_live_1234567890abcdef",
|
|
35
|
+
createdAt: "2026-05-21T09:30:00.000Z",
|
|
36
|
+
updatedAt: "2026-05-21T10:15:00.000Z",
|
|
37
|
+
},
|
|
15
38
|
});
|
|
@@ -3,9 +3,15 @@ import { z } from "zod";
|
|
|
3
3
|
import { zGet, zDelete } from "../utils/zValidations.js";
|
|
4
4
|
|
|
5
5
|
export const createTokenSchema = {
|
|
6
|
-
body: z
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
body: z
|
|
7
|
+
.object({
|
|
8
|
+
name: z.string().openapi({ example: "Admin integration token" }),
|
|
9
|
+
})
|
|
10
|
+
.openapi({
|
|
11
|
+
example: {
|
|
12
|
+
name: "Admin integration token",
|
|
13
|
+
},
|
|
14
|
+
}),
|
|
9
15
|
};
|
|
10
16
|
|
|
11
17
|
export const getTokenSchema = zGet("tokenId");
|
|
@@ -3,18 +3,37 @@ import { extendZodWithOpenApi } from "@asteasolutions/zod-to-openapi";
|
|
|
3
3
|
extendZodWithOpenApi(z);
|
|
4
4
|
|
|
5
5
|
export const createUserResponseSchema = z.object({
|
|
6
|
-
id: z.string(),
|
|
7
|
-
name: z.string(),
|
|
8
|
-
email: z.string(),
|
|
6
|
+
id: z.string().openapi({ example: "682fd0d7d4a6325d9d45b86d" }),
|
|
7
|
+
name: z.string().openapi({ example: "Jane Doe" }),
|
|
8
|
+
email: z.string().email().openapi({ example: "jane.doe@example.com" }),
|
|
9
|
+
}).openapi({
|
|
10
|
+
example: {
|
|
11
|
+
id: "682fd0d7d4a6325d9d45b86d",
|
|
12
|
+
name: "Jane Doe",
|
|
13
|
+
email: "jane.doe@example.com",
|
|
14
|
+
},
|
|
9
15
|
});
|
|
10
16
|
|
|
11
17
|
export const getUsersResponseSchema = z.array(
|
|
12
18
|
z.object({
|
|
13
|
-
id: z.string(),
|
|
14
|
-
name: z.string(),
|
|
15
|
-
email: z.string(),
|
|
19
|
+
id: z.string().openapi({ example: "682fd0d7d4a6325d9d45b86d" }),
|
|
20
|
+
name: z.string().openapi({ example: "Jane Doe" }),
|
|
21
|
+
email: z.string().email().openapi({ example: "jane.doe@example.com" }),
|
|
16
22
|
}),
|
|
17
|
-
)
|
|
23
|
+
).openapi({
|
|
24
|
+
example: [
|
|
25
|
+
{
|
|
26
|
+
id: "682fd0d7d4a6325d9d45b86d",
|
|
27
|
+
name: "Jane Doe",
|
|
28
|
+
email: "jane.doe@example.com",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "682fd0d7d4a6325d9d45b86f",
|
|
32
|
+
name: "John Smith",
|
|
33
|
+
email: "john.smith@example.com",
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
});
|
|
18
37
|
|
|
19
38
|
export const updateUserSchema = z.object({
|
|
20
39
|
name: z.string().optional(),
|
|
@@ -22,11 +41,21 @@ export const updateUserSchema = z.object({
|
|
|
22
41
|
});
|
|
23
42
|
|
|
24
43
|
export const updateUserResponseSchema = z.object({
|
|
25
|
-
id: z.string(),
|
|
26
|
-
name: z.string(),
|
|
27
|
-
email: z.string(),
|
|
44
|
+
id: z.string().openapi({ example: "682fd0d7d4a6325d9d45b86d" }),
|
|
45
|
+
name: z.string().openapi({ example: "Jane Doe" }),
|
|
46
|
+
email: z.string().email().openapi({ example: "jane.doe@example.com" }),
|
|
47
|
+
}).openapi({
|
|
48
|
+
example: {
|
|
49
|
+
id: "682fd0d7d4a6325d9d45b86d",
|
|
50
|
+
name: "Jane Doe",
|
|
51
|
+
email: "jane.doe@example.com",
|
|
52
|
+
},
|
|
28
53
|
});
|
|
29
54
|
|
|
30
55
|
export const deleteUserResponseSchema = z.object({
|
|
31
|
-
success: z.boolean(),
|
|
56
|
+
success: z.boolean().openapi({ example: true }),
|
|
57
|
+
}).openapi({
|
|
58
|
+
example: {
|
|
59
|
+
success: true,
|
|
60
|
+
},
|
|
32
61
|
});
|
|
@@ -36,6 +36,10 @@ export const createUserBodyShape = {
|
|
|
36
36
|
example: "user@example.com",
|
|
37
37
|
description: "User email address",
|
|
38
38
|
}),
|
|
39
|
+
category: z.string().optional().openapi({
|
|
40
|
+
example: "random",
|
|
41
|
+
description: "LEGACY: User category",
|
|
42
|
+
}),
|
|
39
43
|
timezone: z.string().optional().openapi({
|
|
40
44
|
example: "Europe/Berlin",
|
|
41
45
|
description: "IANA timezone string",
|
|
@@ -46,7 +50,19 @@ export const createUserBodyShape = {
|
|
|
46
50
|
};
|
|
47
51
|
|
|
48
52
|
export const createUserSchema = {
|
|
49
|
-
body: z.object(createUserBodyShape)
|
|
53
|
+
body: z.object(createUserBodyShape).openapi({
|
|
54
|
+
example: {
|
|
55
|
+
organization:
|
|
56
|
+
process.env.SCHEMA_EXAMPLE_ORGANIZATION_ID ||
|
|
57
|
+
"682fd0d7d4a6325d9d45b86e",
|
|
58
|
+
email: "user@example.com",
|
|
59
|
+
timezone: "Europe/Berlin",
|
|
60
|
+
role: "user",
|
|
61
|
+
meta: {
|
|
62
|
+
externalId: "crm-123",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
}),
|
|
50
66
|
};
|
|
51
67
|
|
|
52
68
|
export const createCurrentUserSchema = createUserSchema;
|
|
@@ -67,7 +83,10 @@ export const getUserSchema = zGet("userId");
|
|
|
67
83
|
|
|
68
84
|
export const getCurrentUserSchema = {
|
|
69
85
|
query: z.object({
|
|
70
|
-
organization: zObjectId
|
|
86
|
+
organization: zObjectId.openapi({
|
|
87
|
+
description: "Organization ObjectId",
|
|
88
|
+
param: { name: "organization", in: "query" },
|
|
89
|
+
}),
|
|
71
90
|
}),
|
|
72
91
|
};
|
|
73
92
|
|
|
@@ -75,6 +94,10 @@ export const updateUserBodyShape = {
|
|
|
75
94
|
name: z.string().optional().openapi({ description: "User full name" }),
|
|
76
95
|
timezone: z.string().optional().openapi({ description: "IANA timezone" }),
|
|
77
96
|
avatar: z.string().optional().openapi({ description: "Avatar URL" }),
|
|
97
|
+
category: z.string().optional().openapi({
|
|
98
|
+
example: "random",
|
|
99
|
+
description: "LEGACY: User category",
|
|
100
|
+
}),
|
|
78
101
|
meta: z
|
|
79
102
|
.object({})
|
|
80
103
|
.passthrough()
|
|
@@ -103,36 +126,80 @@ export const updateUserBodyShape = {
|
|
|
103
126
|
|
|
104
127
|
export const updateUserSchema = {
|
|
105
128
|
...zUpdate("userId"),
|
|
106
|
-
body: zPatchBody(updateUserBodyShape)
|
|
129
|
+
body: zPatchBody(updateUserBodyShape).openapi({
|
|
130
|
+
example: {
|
|
131
|
+
name: "Jane Doe",
|
|
132
|
+
timezone: "Europe/Berlin",
|
|
133
|
+
email: "jane.doe@example.com",
|
|
134
|
+
role: "patient",
|
|
135
|
+
meta: {
|
|
136
|
+
carePlan: "standard",
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
}),
|
|
107
140
|
};
|
|
108
141
|
|
|
109
142
|
export const deleteUserSchema = zDelete("userId");
|
|
110
143
|
|
|
111
144
|
export const organizationInviteSchema = {
|
|
112
|
-
body: z
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
145
|
+
body: z
|
|
146
|
+
.object({
|
|
147
|
+
organizationId: zObjectId.openapi({
|
|
148
|
+
description: "Organization ObjectId",
|
|
149
|
+
}),
|
|
150
|
+
action: z.string().optional().openapi({ description: "Invite action" }),
|
|
151
|
+
role: z.string().optional().openapi({ description: "Role on invite" }),
|
|
152
|
+
})
|
|
153
|
+
.openapi({
|
|
154
|
+
example: {
|
|
155
|
+
organizationId:
|
|
156
|
+
process.env.SCHEMA_EXAMPLE_ORGANIZATION_ID ||
|
|
157
|
+
"682fd0d7d4a6325d9d45b86e",
|
|
158
|
+
action: "accept",
|
|
159
|
+
role: "user",
|
|
160
|
+
},
|
|
161
|
+
}),
|
|
117
162
|
};
|
|
118
163
|
|
|
119
164
|
export const updateInviteSchema = {
|
|
120
|
-
body: z
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
165
|
+
body: z
|
|
166
|
+
.object({
|
|
167
|
+
organization: zObjectId.openapi({ description: "Organization ObjectId" }),
|
|
168
|
+
status: z.enum(["accepted"]).openapi({ description: "Invite status" }),
|
|
169
|
+
inviteCode: z
|
|
170
|
+
.string()
|
|
171
|
+
.nullable()
|
|
172
|
+
.optional()
|
|
173
|
+
.openapi({ description: "Invite code" }),
|
|
174
|
+
})
|
|
175
|
+
.openapi({
|
|
176
|
+
example: {
|
|
177
|
+
organization:
|
|
178
|
+
process.env.SCHEMA_EXAMPLE_ORGANIZATION_ID ||
|
|
179
|
+
"682fd0d7d4a6325d9d45b86e",
|
|
180
|
+
status: "accepted",
|
|
181
|
+
inviteCode: "INVITE-123",
|
|
182
|
+
},
|
|
183
|
+
}),
|
|
129
184
|
};
|
|
130
185
|
|
|
131
186
|
export const organizationRemoveSchema = {
|
|
132
|
-
body: z
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
187
|
+
body: z
|
|
188
|
+
.object({
|
|
189
|
+
userId: zObjectId.openapi({ description: "User ObjectId" }),
|
|
190
|
+
organizationId: zObjectId.openapi({
|
|
191
|
+
description: "Organization ObjectId",
|
|
192
|
+
}),
|
|
193
|
+
})
|
|
194
|
+
.openapi({
|
|
195
|
+
example: {
|
|
196
|
+
userId:
|
|
197
|
+
process.env.SCHEMA_EXAMPLE_USER_ID || "682fd0d7d4a6325d9d45b86d",
|
|
198
|
+
organizationId:
|
|
199
|
+
process.env.SCHEMA_EXAMPLE_ORGANIZATION_ID ||
|
|
200
|
+
"682fd0d7d4a6325d9d45b86e",
|
|
201
|
+
},
|
|
202
|
+
}),
|
|
136
203
|
};
|
|
137
204
|
|
|
138
205
|
export const updateTimesByIdSchema = {
|