@internetderdinge/api 1.229.1 → 1.229.2
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.validation.js +2 -2
- package/dist/src/devices/devices.schemas.js +2 -2
- package/dist/src/devices/devices.validation.js +9 -9
- package/dist/src/middlewares/validateZod.js +1 -1
- package/dist/src/organizations/organizations.validation.js +1 -1
- package/dist/src/tokens/tokens.model.js +1 -2
- package/dist/src/utils/buildRouterAndDocs.js +1 -1
- package/dist/src/utils/registerOpenApi.js +62 -23
- package/dist/src/utils/zValidations.js +22 -3
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +93 -86
- package/scripts/release-and-sync-paperless.mjs +3 -1
- package/src/accounts/accounts.validation.ts +2 -2
- package/src/devices/devices.schemas.ts +2 -2
- package/src/devices/devices.validation.ts +9 -10
- package/src/middlewares/validateZod.ts +5 -5
- package/src/organizations/organizations.validation.ts +1 -1
- package/src/utils/buildRouterAndDocs.ts +1 -1
- package/src/utils/registerOpenApi.ts +75 -24
- package/src/utils/zValidations.ts +22 -3
|
@@ -12,7 +12,7 @@ export const createAccountSchema = {
|
|
|
12
12
|
organization: zObjectId.openapi({ description: "Organization ObjectId" }),
|
|
13
13
|
patient: zObjectId.openapi({ description: "Patient ObjectId" }),
|
|
14
14
|
meta: z
|
|
15
|
-
.record(z.any())
|
|
15
|
+
.record(z.string(), z.any())
|
|
16
16
|
.openapi({
|
|
17
17
|
example: { key: "value" },
|
|
18
18
|
description: "Additional metadata for the entry",
|
|
@@ -67,7 +67,7 @@ export const updateAccountSchema = {
|
|
|
67
67
|
debug: z.boolean().optional(),
|
|
68
68
|
demo: z.boolean().optional(),
|
|
69
69
|
notification: z
|
|
70
|
-
.record(z.any())
|
|
70
|
+
.record(z.string(), z.any())
|
|
71
71
|
.optional()
|
|
72
72
|
.openapi({ description: "Notification settings object" }),
|
|
73
73
|
}),
|
|
@@ -14,12 +14,12 @@ export const eventResponseSchema = z.object({
|
|
|
14
14
|
id: z.string(),
|
|
15
15
|
deviceId: z.string(),
|
|
16
16
|
type: z.string(),
|
|
17
|
-
payload: z.record(z.any()),
|
|
17
|
+
payload: z.record(z.string(), z.any()),
|
|
18
18
|
timestamp: z.string(), // ISO timestamp
|
|
19
19
|
// ...other event fields...
|
|
20
20
|
});
|
|
21
21
|
export const genericResponseSchema = z
|
|
22
|
-
.record(z.any())
|
|
22
|
+
.record(z.string(), z.any())
|
|
23
23
|
.openapi({ description: "Generic response payload" });
|
|
24
24
|
export const imageResponseSchema = z.object({
|
|
25
25
|
uuid: z.string(),
|
|
@@ -8,7 +8,7 @@ export const createEntrySchema = {
|
|
|
8
8
|
name: z.string().optional(),
|
|
9
9
|
deviceId: z.string().optional(),
|
|
10
10
|
kind: z.string().optional(),
|
|
11
|
-
meta: z.record(z.any()).optional(),
|
|
11
|
+
meta: z.record(z.string(), z.any()).optional(),
|
|
12
12
|
organization: zObjectId,
|
|
13
13
|
patient: zObjectId.optional(),
|
|
14
14
|
paper: zObjectId.optional().nullable(),
|
|
@@ -37,14 +37,14 @@ export const updateEntrySchema = {
|
|
|
37
37
|
organization: zObjectId.optional(),
|
|
38
38
|
patient: zObjectId.optional().nullable(),
|
|
39
39
|
paper: zObjectId.optional().nullable(),
|
|
40
|
-
meta: z.record(z.any()).optional(),
|
|
41
|
-
iotDevice: z.record(z.any()).optional(),
|
|
40
|
+
meta: z.record(z.string(), z.any()).optional(),
|
|
41
|
+
iotDevice: z.record(z.string(), z.any()).optional(),
|
|
42
42
|
shadow: z.union([z.string(), z.number()]).optional(),
|
|
43
43
|
alarmEnable: z.number().int().optional(),
|
|
44
44
|
takeOffsetTime: z.number().int().optional(),
|
|
45
45
|
updatedAt: z.string().datetime().optional(),
|
|
46
46
|
createdAt: z.string().datetime().optional(),
|
|
47
|
-
payment: z.record(z.any()).optional(),
|
|
47
|
+
payment: z.record(z.string(), z.any()).optional(),
|
|
48
48
|
lut: z.string().optional(),
|
|
49
49
|
sleepTime: z.string().optional(),
|
|
50
50
|
clearScreen: z.boolean().optional(),
|
|
@@ -212,8 +212,8 @@ export const uploadSingleImageFromWebsiteSchema = {};
|
|
|
212
212
|
export const updateDeviceSchema = {
|
|
213
213
|
...zUpdate("deviceId"),
|
|
214
214
|
body: zPatchBody({
|
|
215
|
-
intake: z.record(z.any()).optional(),
|
|
216
|
-
meta: z.record(z.any()).optional(),
|
|
215
|
+
intake: z.record(z.string(), z.any()).optional(),
|
|
216
|
+
meta: z.record(z.string(), z.any()).optional(),
|
|
217
217
|
organization: zObjectId.optional(),
|
|
218
218
|
patient: zObjectId.optional().nullable(),
|
|
219
219
|
paper: zObjectId.optional().nullable(),
|
|
@@ -221,8 +221,8 @@ export const updateDeviceSchema = {
|
|
|
221
221
|
deviceId: z.string().optional(),
|
|
222
222
|
alarmEnable: z.number().int().optional(),
|
|
223
223
|
takeOffsetTime: z.number().int().optional(),
|
|
224
|
-
iotDevice: z.record(z.any()).optional(),
|
|
225
|
-
payment: z.record(z.any()).optional(),
|
|
224
|
+
iotDevice: z.record(z.string(), z.any()).optional(),
|
|
225
|
+
payment: z.record(z.string(), z.any()).optional(),
|
|
226
226
|
}),
|
|
227
227
|
};
|
|
228
228
|
export const updateSingleImageMetaSchema = {
|
|
@@ -233,7 +233,7 @@ export const updateSingleImageMetaSchema = {
|
|
|
233
233
|
}),
|
|
234
234
|
body: z
|
|
235
235
|
.object({
|
|
236
|
-
meta: z.record(z.any()).optional(),
|
|
236
|
+
meta: z.record(z.string(), z.any()).optional(),
|
|
237
237
|
})
|
|
238
238
|
.openapi({ description: "Image metadata updates" }),
|
|
239
239
|
};
|
|
@@ -13,6 +13,5 @@ const tokenSchema = new mongoose.Schema({
|
|
|
13
13
|
});
|
|
14
14
|
tokenSchema.plugin(toJSON, true);
|
|
15
15
|
tokenSchema.plugin(paginate);
|
|
16
|
-
const Token = mongoose.models.Token ||
|
|
17
|
-
mongoose.model("Token", tokenSchema);
|
|
16
|
+
const Token = mongoose.models.Token || mongoose.model("Token", tokenSchema);
|
|
18
17
|
export default Token;
|
|
@@ -33,7 +33,7 @@ export default function buildAiRouterAndDocs(router, routeSpecs, basePath = "/",
|
|
|
33
33
|
},
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
console.log("spec.requestScbn");
|
|
37
37
|
if (spec.responseSchema &&
|
|
38
38
|
!hasRoleValidation(spec.validate) &&
|
|
39
39
|
spec.privateDocs !== true &&
|
|
@@ -1,28 +1,67 @@
|
|
|
1
|
-
import { OpenAPIRegistry } from
|
|
1
|
+
import { OpenAPIRegistry } from "@asteasolutions/zod-to-openapi";
|
|
2
|
+
import { extendZodWithOpenApi } from "@asteasolutions/zod-to-openapi";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
extendZodWithOpenApi(z);
|
|
2
5
|
export const registry = new OpenAPIRegistry();
|
|
3
6
|
// add Bearer JWT auth
|
|
4
|
-
export const bearerAuth = registry.registerComponent(
|
|
5
|
-
type:
|
|
6
|
-
scheme:
|
|
7
|
-
bearerFormat:
|
|
8
|
-
description:
|
|
7
|
+
export const bearerAuth = registry.registerComponent("securitySchemes", "bearerAuth", {
|
|
8
|
+
type: "http",
|
|
9
|
+
scheme: "bearer",
|
|
10
|
+
bearerFormat: "JWT",
|
|
11
|
+
description: "JWT Bearer authentication",
|
|
9
12
|
});
|
|
10
|
-
export const xApiKey = registry.registerComponent(
|
|
11
|
-
type:
|
|
12
|
-
in:
|
|
13
|
-
name:
|
|
14
|
-
description:
|
|
13
|
+
export const xApiKey = registry.registerComponent("securitySchemes", "x-api-key", {
|
|
14
|
+
type: "apiKey",
|
|
15
|
+
in: "header",
|
|
16
|
+
name: "x-api-key",
|
|
17
|
+
description: "API key for authentication",
|
|
15
18
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
const UserSchema = z
|
|
20
|
+
.object({
|
|
21
|
+
id: z.string().openapi({ example: "1212121" }),
|
|
22
|
+
name: z.string().openapi({ example: "John Doe" }),
|
|
23
|
+
age: z.number().openapi({ example: 42 }),
|
|
24
|
+
})
|
|
25
|
+
.openapi("User");
|
|
26
|
+
registry.registerPath({
|
|
27
|
+
method: "get",
|
|
28
|
+
path: "/usersnnn/{id}",
|
|
29
|
+
summary: "Get a single user",
|
|
30
|
+
request: {
|
|
31
|
+
params: z.object({ id: z.string() }),
|
|
32
|
+
},
|
|
33
|
+
responses: {
|
|
34
|
+
200: {
|
|
35
|
+
description: "Object with user data.",
|
|
36
|
+
content: {
|
|
37
|
+
"application/json": {
|
|
38
|
+
schema: UserSchema,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
registry.registerPath({
|
|
45
|
+
method: "get",
|
|
46
|
+
path: "/users/{id}",
|
|
47
|
+
description: "Get user data by its id",
|
|
48
|
+
summary: "Get a single user",
|
|
49
|
+
request: {
|
|
50
|
+
params: z.object({
|
|
51
|
+
id: z.string().openapi({ example: "1212121" }),
|
|
52
|
+
}),
|
|
53
|
+
},
|
|
54
|
+
responses: {
|
|
55
|
+
200: {
|
|
56
|
+
description: "Object with user data.",
|
|
57
|
+
content: {
|
|
58
|
+
"application/json": {
|
|
59
|
+
schema: UserSchema,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
204: {
|
|
64
|
+
description: "No content - successful operation",
|
|
65
|
+
},
|
|
66
|
+
},
|
|
27
67
|
});
|
|
28
|
-
*/
|
|
@@ -3,20 +3,36 @@ import { z } from "zod";
|
|
|
3
3
|
import mongoose from "mongoose";
|
|
4
4
|
export const zPagination = {
|
|
5
5
|
query: z.object({
|
|
6
|
-
name: z
|
|
6
|
+
name: z
|
|
7
|
+
.string()
|
|
8
|
+
.openapi({
|
|
9
|
+
example: "John",
|
|
10
|
+
description: "Name to filter by",
|
|
11
|
+
param: { name: "name", in: "query" },
|
|
12
|
+
})
|
|
13
|
+
.optional(),
|
|
7
14
|
role: z
|
|
8
15
|
.string()
|
|
9
|
-
.openapi({
|
|
16
|
+
.openapi({
|
|
17
|
+
example: "admin",
|
|
18
|
+
description: "Role to filter by",
|
|
19
|
+
param: { name: "role", in: "query" },
|
|
20
|
+
})
|
|
10
21
|
.optional(),
|
|
11
22
|
sortBy: z
|
|
12
23
|
.string()
|
|
13
|
-
.openapi({
|
|
24
|
+
.openapi({
|
|
25
|
+
example: "createdAt",
|
|
26
|
+
description: "Field to sort by",
|
|
27
|
+
param: { name: "sortBy", in: "query" },
|
|
28
|
+
})
|
|
14
29
|
.optional(),
|
|
15
30
|
search: z
|
|
16
31
|
.string()
|
|
17
32
|
.openapi({
|
|
18
33
|
example: process.env.SCHEMA_EXAMPLE_SEARCH || "",
|
|
19
34
|
description: "Search term to filter results",
|
|
35
|
+
param: { name: "search", in: "query" },
|
|
20
36
|
})
|
|
21
37
|
.optional(),
|
|
22
38
|
limit: z.coerce
|
|
@@ -24,6 +40,7 @@ export const zPagination = {
|
|
|
24
40
|
.openapi({
|
|
25
41
|
example: 10,
|
|
26
42
|
description: "Number of items per page",
|
|
43
|
+
param: { name: "limit", in: "query" },
|
|
27
44
|
})
|
|
28
45
|
.int()
|
|
29
46
|
.min(1)
|
|
@@ -34,6 +51,7 @@ export const zPagination = {
|
|
|
34
51
|
.openapi({
|
|
35
52
|
example: 0,
|
|
36
53
|
description: "Offset for pagination, used to skip a number of items",
|
|
54
|
+
param: { name: "offset", in: "query" },
|
|
37
55
|
})
|
|
38
56
|
.int()
|
|
39
57
|
.min(0)
|
|
@@ -45,6 +63,7 @@ export const zPagination = {
|
|
|
45
63
|
.openapi({
|
|
46
64
|
example: 1,
|
|
47
65
|
description: "Page number for pagination",
|
|
66
|
+
param: { name: "page", in: "query" },
|
|
48
67
|
})
|
|
49
68
|
.min(1)
|
|
50
69
|
.max(100000)
|