@internetderdinge/api 1.229.1 → 1.229.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetderdinge/api",
3
- "version": "1.229.1",
3
+ "version": "1.229.3",
4
4
  "description": "Shared OpenIoT API modules",
5
5
  "main": "dist/src/index.js",
6
6
  "type": "module",
@@ -9,113 +9,120 @@
9
9
  },
10
10
  "scripts": {
11
11
  "build": "tsc -p tsconfig.json",
12
+ "dev:watch": "tsc -p tsconfig.json --watch --incremental --preserveWatchOutput",
13
+ "dev:yalc": "nodemon --watch src --watch package.json --ext ts,json --exec \"yarn build && yalc publish --push\"",
14
+ "yalc:publish": "yalc publish --push",
15
+ "deps:versions": "node --input-type=module -e \"import { createRequire } from 'node:module'; const require = createRequire(import.meta.url); const out = (name) => { const pkgPath = require.resolve(name + '/package.json'); const version = require(pkgPath).version; console.log(name + '@' + version + ' -> ' + pkgPath); }; out('zod'); out('@asteasolutions/zod-to-openapi');\"",
12
16
  "deploy:version": "node ./scripts/release-version.mjs",
13
17
  "release:paperless": "node ./scripts/release-and-sync-paperless.mjs",
14
18
  "lint": "eslint .",
15
19
  "lint:fix": "eslint . --fix"
16
20
  },
17
21
  "dependencies": {
18
- "@asteasolutions/zod-to-openapi": "^7.3.2",
19
- "@aws-sdk/client-cloudwatch-events": "^3.216.0",
20
- "@aws-sdk/client-s3": "^3.216.0",
21
- "@aws-sdk/client-sesv2": "^3.328.0",
22
- "@aws-sdk/credential-provider-node": "^3.830.0",
23
- "@aws-sdk/lib-storage": "^3.216.0",
24
- "@aws-sdk/s3-request-presigner": "^3.216.0",
25
- "@aws-sdk/util-endpoints": "^3.216.0",
26
- "@sentry/node": "^10.25.0",
27
- "@sentry/profiling-node": "^10.25.0",
28
- "agenda": "^5.0.0",
29
- "agendash": "^4.0.0",
30
- "auth0": "^4.23.1",
31
- "aws-crt": "^1.27.3",
32
- "aws-iot-device-sdk-v2": "^1.22.0",
33
- "aws-sdk": "^2.1261.0",
34
- "aws4": "^1.11.0",
35
- "axios": "^1.9.0",
36
- "body-parser": "~1.15.0",
37
- "body-parser-xml": "~1.1.0",
38
- "canvas": "^3.1.0",
39
- "compression": "^1.8.0",
40
- "config": "^4.0.0",
41
- "cors": "^2.8.5",
42
- "cron": "^4.3.1",
43
- "date-fns": "^2.28.0",
44
- "date-fns-tz": "2.0.0",
45
- "dotenv": "^10.0.0",
46
- "elevenlabs": "^0.5.0",
47
- "express": "^5.1.0",
22
+ "@aws-sdk/client-cloudwatch-events": "^3.990.0",
23
+ "@aws-sdk/client-s3": "^3.990.0",
24
+ "@aws-sdk/client-sesv2": "^3.990.0",
25
+ "@aws-sdk/credential-provider-node": "^3.972.9",
26
+ "@aws-sdk/lib-storage": "^3.990.0",
27
+ "@aws-sdk/s3-request-presigner": "^3.990.0",
28
+ "@aws-sdk/util-endpoints": "^3.990.0",
29
+ "@sentry/node": "^10.38.0",
30
+ "@sentry/profiling-node": "^10.38.0",
31
+ "agenda": "^6.2.2",
32
+ "agendash": "^8.1.1",
33
+ "auth0": "^5.3.1",
34
+ "aws-crt": "^1.29.0",
35
+ "aws-iot-device-sdk-v2": "^1.25.0",
36
+ "aws-sdk": "^2.1693.0",
37
+ "aws4": "^1.13.2",
38
+ "axios": "^1.13.5",
39
+ "body-parser": "~2.2.2",
40
+ "body-parser-xml": "~2.0.5",
41
+ "canvas": "^3.2.1",
42
+ "compression": "^1.8.1",
43
+ "config": "^4.3.0",
44
+ "cors": "^2.8.6",
45
+ "cron": "^4.4.0",
46
+ "date-fns": "^4.1.0",
47
+ "date-fns-tz": "3.2.0",
48
+ "dotenv": "^17.3.1",
49
+ "elevenlabs": "^1.59.0",
50
+ "express": "^5.2.1",
48
51
  "express-jwt": "^8.5.1",
49
52
  "express-mongo-sanitize": "^2.2.0",
50
- "express-rate-limit": "^7.5.0",
53
+ "express-rate-limit": "^8.2.1",
51
54
  "express-ws": "^5.0.2",
52
- "firebase-admin": "^11.0.0",
53
- "googleapis": "^144.0.0",
55
+ "file-type": "^21.3.0",
56
+ "firebase-admin": "^13.6.1",
57
+ "googleapis": "^171.4.0",
54
58
  "he": "^1.2.0",
55
- "helmet": "^4.1.0",
56
- "http-status": "^1.4.0",
59
+ "helmet": "^8.1.0",
60
+ "http-status": "^2.1.0",
57
61
  "https": "^1.0.0",
58
- "i18next": "^23.10.1",
59
- "joi": "^17.3.0",
60
- "js-yaml": "^3.8.4",
61
- "jsonwebtoken": "^8.5.1",
62
- "jwks-rsa": "^2.0.3",
63
- "moment": "^2.24.0",
64
- "moment-timezone": "^0.5.34",
65
- "morgan": "^1.9.1",
66
- "multer": "^1.4.5-lts.1",
62
+ "i18next": "^25.8.7",
63
+ "joi": "^18.0.2",
64
+ "js-yaml": "^4.1.1",
65
+ "jsonwebtoken": "^9.0.3",
66
+ "jwks-rsa": "^3.2.2",
67
+ "moment": "^2.30.1",
68
+ "moment-timezone": "^0.6.0",
69
+ "morgan": "^1.10.1",
70
+ "multer": "^2.0.2",
67
71
  "multer-s3": "^3.0.1",
68
- "multiparty": "~4.1.2",
69
- "node-uuid": "~1.4.7",
70
- "nodemailer": "^6.3.1",
71
- "openai": "^5.0.1",
72
- "passport": "^0.4.0",
73
- "passport-jwt": "^4.0.0",
72
+ "multiparty": "~4.2.3",
73
+ "node-uuid": "~1.4.8",
74
+ "nodemailer": "^8.0.1",
75
+ "openai": "^6.22.0",
76
+ "passport": "^0.7.0",
77
+ "passport-jwt": "^4.0.1",
74
78
  "path": "~0.12.7",
75
79
  "pixelmatch": "^7.1.0",
76
80
  "promise": "~8.3.0",
77
- "puppeteer": "^24.9.0",
78
- "qs": "^6.14.0",
79
- "request": "^2.81.0",
80
- "rrule": "^2.7.1",
81
- "sharp": "^0.33.5",
82
- "semver": "^7.7.1",
83
- "stripe": "^12.6.0",
81
+ "puppeteer": "^24.37.3",
82
+ "qs": "^6.14.2",
83
+ "request": "^2.88.2",
84
+ "rrule": "^2.8.1",
85
+ "semver": "^7.7.4",
86
+ "sharp": "^0.34.5",
87
+ "stripe": "^20.3.1",
84
88
  "swagger-ui-express": "^5.0.1",
85
89
  "ts-node": "^10.9.2",
86
- "typescript": "^5.8.3",
87
- "uuid": "^9.0.1",
88
- "validator": "^13.0.0",
89
- "winston": "^3.2.1",
90
- "xss-clean": "^0.1.4",
91
- "zod": "^3.20.2"
90
+ "typescript": "^5.9.3",
91
+ "uuid": "^13.0.0",
92
+ "validator": "^13.15.26",
93
+ "winston": "^3.19.0",
94
+ "xss-clean": "^0.1.4"
92
95
  },
93
96
  "peerDependencies": {
94
- "mongoose": "^8.15.1"
97
+ "@asteasolutions/zod-to-openapi": "^8.0.0",
98
+ "mongoose": "^8.15.1",
99
+ "zod": "^4.3.6"
95
100
  },
96
101
  "devDependencies": {
97
- "@types/glob": "^8.1.0",
98
- "@types/uuid": "^9.0.8",
99
- "@types/validator": "^13.11.10",
100
- "@types/passport": "^1.0.12",
101
- "@types/file-type": "^16.5.1",
102
- "@vitest/coverage-v8": "^2.1.9",
102
+ "@asteasolutions/zod-to-openapi": "^8.0.0",
103
+ "@types/file-type": "^10.9.3",
104
+ "@types/glob": "^9.0.0",
105
+ "@types/passport": "^1.0.17",
106
+ "@types/uuid": "^11.0.0",
107
+ "@types/validator": "^13.15.10",
108
+ "@vitest/coverage-v8": "^4.0.18",
103
109
  "coveralls": "^3.1.1",
104
- "eslint": "^7.0.0",
105
- "eslint-config-airbnb-base": "^14.0.0",
106
- "eslint-config-prettier": "^8.1.0",
107
- "eslint-plugin-import": "^2.18.2",
108
- "eslint-plugin-prettier": "^3.1.1",
109
- "eslint-plugin-security": "^1.4.0",
110
- "faker": "^5.1.0",
111
- "husky": "^5.1.2",
112
- "lint-staged": "^10.0.7",
113
- "node-mocks-http": "^1.8.0",
114
- "nodemon": "^3.1.10",
115
- "prettier": "^3.5.3",
116
- "mongoose": "^8.15.1",
117
- "supertest": "^7.1.1",
118
- "vitest": "^2.1.9"
110
+ "eslint": "^10.0.0",
111
+ "eslint-config-airbnb-base": "^15.0.0",
112
+ "eslint-config-prettier": "^10.1.8",
113
+ "eslint-plugin-import": "^2.32.0",
114
+ "eslint-plugin-prettier": "^5.5.5",
115
+ "eslint-plugin-security": "^3.0.1",
116
+ "faker": "^6.6.6",
117
+ "husky": "^9.1.7",
118
+ "lint-staged": "^16.2.7",
119
+ "mongoose": "^9.2.1",
120
+ "node-mocks-http": "^1.17.2",
121
+ "nodemon": "^3.1.11",
122
+ "prettier": "^3.8.1",
123
+ "supertest": "^7.2.2",
124
+ "vitest": "^4.0.18",
125
+ "zod": "^4.3.6"
119
126
  },
120
127
  "gitHead": "9556e8e376045c1e532aded7ec7132818190fa91"
121
128
  }
@@ -132,4 +132,6 @@ const paperlessUpdate = updateDependencyVersion(
132
132
  );
133
133
 
134
134
  console.log(`Updated @internetderdinge/api to ${nextVersion}`);
135
- console.log(`paperlesspaper-api: ${paperlessUpdate.previous} -> ${paperlessUpdate.next}`);
135
+ console.log(
136
+ `paperlesspaper-api: ${paperlessUpdate.previous} -> ${paperlessUpdate.next}`,
137
+ );
@@ -10,7 +10,7 @@ type Stock = any; // Replace with the actual Stock type if available
10
10
  * @returns {Promise<Stock>}
11
11
  */
12
12
  export const getAccountById = async (id: ObjectId): Promise<Stock> => {
13
- return auth0.users.get({ id });
13
+ return auth0.users.get(id);
14
14
  };
15
15
 
16
16
  /**
@@ -54,7 +54,7 @@ export const updateMetaDataById = async (
54
54
  updateBody: Record<string, any>,
55
55
  ): Promise<Stock> => {
56
56
  // now use the generic update and pass app_metadata
57
- return auth0.users.update({ id }, { app_metadata: updateBody });
57
+ return auth0.users.update(id, { app_metadata: updateBody });
58
58
  };
59
59
 
60
60
  /**
@@ -65,14 +65,14 @@ export const updateUserById = async (
65
65
  updateBody: Record<string, any>,
66
66
  ): Promise<Stock> => {
67
67
  // switch to the v3 ManagementClient users.update
68
- return auth0.users.update({ id }, updateBody);
68
+ return auth0.users.update(id, updateBody);
69
69
  };
70
70
 
71
71
  /**
72
72
  * Delete user by id
73
73
  */
74
74
  export const deleteById = async (userId: ObjectId): Promise<Stock> => {
75
- return auth0.users.delete({ id: userId });
75
+ return auth0.users.delete(userId);
76
76
  };
77
77
 
78
78
  export default {
@@ -22,7 +22,7 @@ export const createAccountSchema = {
22
22
  organization: zObjectId.openapi({ description: "Organization ObjectId" }),
23
23
  patient: zObjectId.openapi({ description: "Patient ObjectId" }),
24
24
  meta: z
25
- .record(z.any())
25
+ .record(z.string(), z.any())
26
26
  .openapi({
27
27
  example: { key: "value" },
28
28
  description: "Additional metadata for the entry",
@@ -82,7 +82,7 @@ export const updateAccountSchema = {
82
82
  debug: z.boolean().optional(),
83
83
  demo: z.boolean().optional(),
84
84
  notification: z
85
- .record(z.any())
85
+ .record(z.string(), z.any())
86
86
  .optional()
87
87
  .openapi({ description: "Notification settings object" }),
88
88
  }),
@@ -192,27 +192,26 @@ export const auth0 = new ManagementClient({
192
192
  });
193
193
 
194
194
  export const getUserIdByEmail = async (email: string): Promise<User[]> => {
195
- // use the users resource to look up by email
196
- return auth0.usersByEmail.getByEmail({ email });
195
+ return auth0.users.listUsersByEmail({ email });
197
196
  };
198
197
 
199
198
  export const sendVerificationEmail = async (userID: string): Promise<any> => {
200
- return auth0.jobs.verifyEmail({ user_id: userID });
199
+ return auth0.tickets.verifyEmail({ user_id: userID });
201
200
  };
202
201
 
203
202
  export const getUserById = async (userId: string): Promise<User> => {
204
- return auth0.users.get({ id: userId });
203
+ return auth0.users.get(userId);
205
204
  };
206
205
 
207
206
  export const avatar = async (userId: string): Promise<User> => {
208
- return auth0.users.get({ id: userId });
207
+ return auth0.users.get(userId);
209
208
  };
210
209
 
211
210
  export const mfaEnrollAccount = async (
212
211
  userId: string,
213
212
  mfaToken: string,
214
213
  ): Promise<any> => {
215
- const ticketResponse = await auth0.guardian.createEnrollmentTicket({
214
+ const ticketResponse = await auth0.guardian.enrollments.createTicket({
216
215
  user_id: userId,
217
216
  send_mail: false,
218
217
  });
@@ -221,15 +220,15 @@ export const mfaEnrollAccount = async (
221
220
  };
222
221
 
223
222
  export const mfaDisableAccount = async (userId: string): Promise<any> => {
224
- await auth0.users.deleteAuthenticationMethods({ id: userId });
223
+ await auth0.users.authenticationMethods.deleteAll(userId);
225
224
  return { success: true };
226
225
  };
227
226
 
228
227
  export const getUsersByIds = async (postIDs: string[]): Promise<User[]> => {
229
- let q = "";
230
- postIDs.forEach((e, i) => {
231
- if (e) q = `${q} ${i >= 2 ? " OR " : ""} user_id:"${e}"`;
232
- });
228
+ const userIds = postIDs.filter(Boolean);
229
+ if (!userIds.length) return [];
230
+
231
+ const q = userIds.map((id) => `user_id:"${id}"`).join(" OR ");
233
232
 
234
233
  const params = {
235
234
  search_engine: "v3",
@@ -238,7 +237,8 @@ export const getUsersByIds = async (postIDs: string[]): Promise<User[]> => {
238
237
  page: 0,
239
238
  };
240
239
 
241
- return auth0.users.getAll(params);
240
+ const page = await auth0.users.list(params);
241
+ return page.data || [];
242
242
  };
243
243
 
244
244
  export default {
@@ -17,13 +17,13 @@ export const eventResponseSchema = z.object({
17
17
  id: z.string(),
18
18
  deviceId: z.string(),
19
19
  type: z.string(),
20
- payload: z.record(z.any()),
20
+ payload: z.record(z.string(), z.any()),
21
21
  timestamp: z.string(), // ISO timestamp
22
22
  // ...other event fields...
23
23
  });
24
24
 
25
25
  export const genericResponseSchema = z
26
- .record(z.any())
26
+ .record(z.string(), z.any())
27
27
  .openapi({ description: "Generic response payload" });
28
28
 
29
29
  export const imageResponseSchema = z.object({
@@ -10,7 +10,6 @@ import {
10
10
  zDelete,
11
11
  zPagination,
12
12
  } from "../utils/zValidations.js";
13
- import { enable } from "agenda/dist/job/enable";
14
13
 
15
14
  extendZodWithOpenApi(z);
16
15
 
@@ -20,7 +19,7 @@ export const createEntrySchema = {
20
19
  name: z.string().optional(),
21
20
  deviceId: z.string().optional(),
22
21
  kind: z.string().optional(),
23
- meta: z.record(z.any()).optional(),
22
+ meta: z.record(z.string(), z.any()).optional(),
24
23
  organization: zObjectId,
25
24
  patient: zObjectId.optional(),
26
25
  paper: zObjectId.optional().nullable(),
@@ -52,14 +51,14 @@ export const updateEntrySchema = {
52
51
  organization: zObjectId.optional(),
53
52
  patient: zObjectId.optional().nullable(),
54
53
  paper: zObjectId.optional().nullable(),
55
- meta: z.record(z.any()).optional(),
56
- iotDevice: z.record(z.any()).optional(),
54
+ meta: z.record(z.string(), z.any()).optional(),
55
+ iotDevice: z.record(z.string(), z.any()).optional(),
57
56
  shadow: z.union([z.string(), z.number()]).optional(),
58
57
  alarmEnable: z.number().int().optional(),
59
58
  takeOffsetTime: z.number().int().optional(),
60
59
  updatedAt: z.string().datetime().optional(),
61
60
  createdAt: z.string().datetime().optional(),
62
- payment: z.record(z.any()).optional(),
61
+ payment: z.record(z.string(), z.any()).optional(),
63
62
  lut: z.string().optional(),
64
63
  sleepTime: z.string().optional(),
65
64
  clearScreen: z.boolean().optional(),
@@ -237,8 +236,8 @@ export const uploadSingleImageFromWebsiteSchema = {};
237
236
  export const updateDeviceSchema = {
238
237
  ...zUpdate("deviceId"),
239
238
  body: zPatchBody({
240
- intake: z.record(z.any()).optional(),
241
- meta: z.record(z.any()).optional(),
239
+ intake: z.record(z.string(), z.any()).optional(),
240
+ meta: z.record(z.string(), z.any()).optional(),
242
241
  organization: zObjectId.optional(),
243
242
  patient: zObjectId.optional().nullable(),
244
243
  paper: zObjectId.optional().nullable(),
@@ -246,8 +245,8 @@ export const updateDeviceSchema = {
246
245
  deviceId: z.string().optional(),
247
246
  alarmEnable: z.number().int().optional(),
248
247
  takeOffsetTime: z.number().int().optional(),
249
- iotDevice: z.record(z.any()).optional(),
250
- payment: z.record(z.any()).optional(),
248
+ iotDevice: z.record(z.string(), z.any()).optional(),
249
+ payment: z.record(z.string(), z.any()).optional(),
251
250
  }),
252
251
  };
253
252
 
@@ -259,7 +258,7 @@ export const updateSingleImageMetaSchema = {
259
258
  }),
260
259
  body: z
261
260
  .object({
262
- meta: z.record(z.any()).optional(),
261
+ meta: z.record(z.string(), z.any()).optional(),
263
262
  })
264
263
  .openapi({ description: "Image metadata updates" }),
265
264
  };
@@ -1,13 +1,13 @@
1
1
  import type { Request, Response, NextFunction } from 'express';
2
- import type { AnyZodObject } from 'zod';
2
+ import type { ZodObject, ZodRawShape } from 'zod';
3
3
  import ApiError from '../utils/ApiError';
4
4
  import httpStatus from 'http-status';
5
- import z from 'zod';
5
+ import { z } from 'zod';
6
6
 
7
7
  interface Schema {
8
- body?: AnyZodObject;
9
- query?: AnyZodObject;
10
- params?: AnyZodObject;
8
+ body?: ZodObject<ZodRawShape>;
9
+ query?: ZodObject<ZodRawShape>;
10
+ params?: ZodObject<ZodRawShape>;
11
11
  }
12
12
 
13
13
  export const validateZod = (schema: Schema) => (req: Request, res: Response, next: NextFunction) => {
@@ -52,7 +52,7 @@ export const updateOrganizationSchema = {
52
52
  })
53
53
  .optional(),
54
54
  meta: z
55
- .record(z.any())
55
+ .record(z.string(), z.any())
56
56
  .openapi({
57
57
  example: { key: "value" },
58
58
  description: "Additional metadata for the entry",
@@ -69,8 +69,6 @@ export default function buildAiRouterAndDocs(
69
69
  };
70
70
  }
71
71
 
72
- // console.log('spec.requestSchema', body);
73
-
74
72
  if (
75
73
  spec.responseSchema &&
76
74
  !hasRoleValidation(spec.validate) &&
@@ -1,32 +1,83 @@
1
- import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
1
+ import { OpenAPIRegistry } from "@asteasolutions/zod-to-openapi";
2
+ import { extendZodWithOpenApi } from "@asteasolutions/zod-to-openapi";
3
+ import { z } from "zod";
4
+
5
+ extendZodWithOpenApi(z);
2
6
 
3
7
  export const registry = new OpenAPIRegistry();
4
8
 
5
9
  // add Bearer JWT auth
6
- export const bearerAuth = registry.registerComponent('securitySchemes', 'bearerAuth', {
7
- type: 'http',
8
- scheme: 'bearer',
9
- bearerFormat: 'JWT',
10
- description: 'JWT Bearer authentication',
11
- });
10
+ export const bearerAuth = registry.registerComponent(
11
+ "securitySchemes",
12
+ "bearerAuth",
13
+ {
14
+ type: "http",
15
+ scheme: "bearer",
16
+ bearerFormat: "JWT",
17
+ description: "JWT Bearer authentication",
18
+ },
19
+ );
20
+
21
+ export const xApiKey = registry.registerComponent(
22
+ "securitySchemes",
23
+ "x-api-key",
24
+ {
25
+ type: "apiKey",
26
+ in: "header",
27
+ name: "x-api-key",
28
+ description: "API key for authentication",
29
+ },
30
+ );
31
+
32
+ const UserSchema = z
33
+ .object({
34
+ id: z.string().openapi({ example: "1212121" }),
35
+ name: z.string().openapi({ example: "John Doe" }),
36
+ age: z.number().openapi({ example: 42 }),
37
+ })
38
+ .openapi("User");
39
+
40
+ registry.registerPath({
41
+ method: "get",
42
+ path: "/usersnnn/{id}",
43
+ summary: "Get a single user",
44
+ request: {
45
+ params: z.object({ id: z.string() }),
46
+ },
12
47
 
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',
48
+ responses: {
49
+ 200: {
50
+ description: "Object with user data.",
51
+ content: {
52
+ "application/json": {
53
+ schema: UserSchema,
54
+ },
55
+ },
56
+ },
57
+ },
18
58
  });
19
59
 
20
- /*
21
- registry.registerComponent('global', 'wwww', [
22
- { name: 'ai', description: 'All AI-powered endpoints.' },
23
- { name: 'auth', description: 'Authentication and authorization.' },
24
- { name: 'Users', description: 'User management (create, read, update, delete).' },
25
- // add more as needed
26
- ]);
27
-
28
- registry.registerComponent('tag', 'users', {
29
- name: 'users',
30
- description: 'Operations about users',
60
+ registry.registerPath({
61
+ method: "get",
62
+ path: "/users/{id}",
63
+ description: "Get user data by its id",
64
+ summary: "Get a single user",
65
+ request: {
66
+ params: z.object({
67
+ id: z.string().openapi({ example: "1212121" }),
68
+ }),
69
+ },
70
+ responses: {
71
+ 200: {
72
+ description: "Object with user data.",
73
+ content: {
74
+ "application/json": {
75
+ schema: UserSchema,
76
+ },
77
+ },
78
+ },
79
+ 204: {
80
+ description: "No content - successful operation",
81
+ },
82
+ },
31
83
  });
32
- */
@@ -5,20 +5,36 @@ import mongoose from "mongoose";
5
5
 
6
6
  export const zPagination = {
7
7
  query: z.object({
8
- name: z.string().optional(),
8
+ name: z
9
+ .string()
10
+ .openapi({
11
+ example: "John",
12
+ description: "Name to filter by",
13
+ param: { name: "name", in: "query" },
14
+ })
15
+ .optional(),
9
16
  role: z
10
17
  .string()
11
- .openapi({ example: "admin", description: "Role to filter by" })
18
+ .openapi({
19
+ example: "admin",
20
+ description: "Role to filter by",
21
+ param: { name: "role", in: "query" },
22
+ })
12
23
  .optional(),
13
24
  sortBy: z
14
25
  .string()
15
- .openapi({ example: "createdAt", description: "Field to sort by" })
26
+ .openapi({
27
+ example: "createdAt",
28
+ description: "Field to sort by",
29
+ param: { name: "sortBy", in: "query" },
30
+ })
16
31
  .optional(),
17
32
  search: z
18
33
  .string()
19
34
  .openapi({
20
35
  example: process.env.SCHEMA_EXAMPLE_SEARCH || "",
21
36
  description: "Search term to filter results",
37
+ param: { name: "search", in: "query" },
22
38
  })
23
39
  .optional(),
24
40
  limit: z.coerce
@@ -26,6 +42,7 @@ export const zPagination = {
26
42
  .openapi({
27
43
  example: 10,
28
44
  description: "Number of items per page",
45
+ param: { name: "limit", in: "query" },
29
46
  })
30
47
  .int()
31
48
  .min(1)
@@ -36,6 +53,7 @@ export const zPagination = {
36
53
  .openapi({
37
54
  example: 0,
38
55
  description: "Offset for pagination, used to skip a number of items",
56
+ param: { name: "offset", in: "query" },
39
57
  })
40
58
  .int()
41
59
  .min(0)
@@ -47,6 +65,7 @@ export const zPagination = {
47
65
  .openapi({
48
66
  example: 1,
49
67
  description: "Page number for pagination",
68
+ param: { name: "page", in: "query" },
50
69
  })
51
70
  .min(1)
52
71
  .max(100000)