Merge branch 'main' into dev

This commit is contained in:
Owen
2026-05-31 11:12:30 -07:00
187 changed files with 2965 additions and 247 deletions

View File

@@ -14,7 +14,7 @@ import { rebuildClientAssociationsFromClient } from "@server/lib/rebuildClientAs
/** Legacy path param order: /role/:roleId/add/:userId */
const addUserRoleLegacyParamsSchema = z.strictObject({
roleId: z.string().transform(stoi).pipe(z.number()),
roleId: z.coerce.number(),
userId: z.string()
});
@@ -27,7 +27,22 @@ registry.registerPath({
request: {
params: addUserRoleLegacyParamsSchema
},
responses: {}
responses: {
200: {
description: "Successful response",
content: {
"application/json": {
schema: z.object({
data: z.unknown().nullable(),
success: z.boolean(),
error: z.boolean(),
message: z.string(),
status: z.number()
})
}
}
}
}
});
export async function addUserRoleLegacy(

View File

@@ -11,7 +11,7 @@ import { fromError } from "zod-validation-error";
const addUserSiteSchema = z.strictObject({
userId: z.string(),
siteId: z.string().transform(Number).pipe(z.int().positive())
siteId: z.coerce.number().int().positive()
});
export async function addUserSite(

View File

@@ -21,7 +21,22 @@ registry.registerPath({
request: {
params: adminGetUserSchema
},
responses: {}
responses: {
200: {
description: "Successful response",
content: {
"application/json": {
schema: z.object({
data: z.unknown().nullable(),
success: z.boolean(),
error: z.boolean(),
message: z.string(),
status: z.number()
})
}
}
}
}
});
async function queryUser(userId: string) {

View File

@@ -137,7 +137,22 @@ registry.registerPath({
request: {
query: listUsersSchema
},
responses: {}
responses: {
200: {
description: "Successful response",
content: {
"application/json": {
schema: z.object({
data: z.unknown().nullable(),
success: z.boolean(),
error: z.boolean(),
message: z.string(),
status: z.number()
})
}
}
}
}
});
export async function adminListUsers(

View File

@@ -1,5 +1,6 @@
import { Request, Response, NextFunction } from "express";
import { z } from "zod";
import { createApiResponseSchema } from "@server/lib/openapi/createApiResponseSchema";
import { db } from "@server/db";
import { users, userOrgs } from "@server/db";
import { eq, and } from "drizzle-orm";
@@ -22,6 +23,11 @@ export type UpdateUser2FAResponse = {
userId: string;
twoFactorRequested: boolean;
};
const UpdateUser2FAResponseDataSchema = z.object({
userId: z.string(),
twoFactorRequested: z.boolean()
});
registry.registerPath({
method: "post",
@@ -38,7 +44,16 @@ registry.registerPath({
}
}
},
responses: {}
responses: {
200: {
description: "Successful response",
content: {
"application/json": {
schema: createApiResponseSchema(UpdateUser2FAResponseDataSchema)
}
}
}
}
});
export async function updateUser2FA(

View File

@@ -1,5 +1,6 @@
import { Request, Response, NextFunction } from "express";
import { z } from "zod";
import { createApiResponseSchema } from "@server/lib/openapi/createApiResponseSchema";
import response from "@server/lib/response";
import HttpCode from "@server/types/HttpCode";
import createHttpError from "http-errors";
@@ -53,6 +54,8 @@ const bodySchema = z
}));
export type CreateOrgUserResponse = {};
const CreateOrgUserResponseDataSchema = z.object({});
registry.registerPath({
method: "put",
@@ -69,7 +72,16 @@ registry.registerPath({
}
}
},
responses: {}
responses: {
200: {
description: "Successful response",
content: {
"application/json": {
schema: createApiResponseSchema(CreateOrgUserResponseDataSchema)
}
}
}
}
});
export async function createOrgUser(

View File

@@ -81,7 +81,22 @@ registry.registerPath({
request: {
params: getOrgUserParamsSchema
},
responses: {}
responses: {
200: {
description: "Successful response",
content: {
"application/json": {
schema: z.object({
data: z.unknown().nullable(),
success: z.boolean(),
error: z.boolean(),
message: z.string(),
status: z.number()
})
}
}
}
}
});
export async function getOrgUser(

View File

@@ -40,7 +40,22 @@ registry.registerPath({
params: getOrgUserByUsernameParamsSchema,
query: getOrgUserByUsernameQuerySchema
},
responses: {}
responses: {
200: {
description: "Successful response",
content: {
"application/json": {
schema: z.object({
data: z.unknown().nullable(),
success: z.boolean(),
error: z.boolean(),
message: z.string(),
status: z.number()
})
}
}
}
}
});
export async function getOrgUserByUsername(

View File

@@ -1,5 +1,6 @@
import { Request, Response, NextFunction } from "express";
import { z } from "zod";
import { createApiResponseSchema } from "@server/lib/openapi/createApiResponseSchema";
import { db } from "@server/db";
import {
orgs,
@@ -67,6 +68,11 @@ export type InviteUserResponse = {
inviteLink: string;
expiresAt: number;
};
const InviteUserResponseDataSchema = z.object({
inviteLink: z.string(),
expiresAt: z.number()
});
registry.registerPath({
method: "post",
@@ -83,7 +89,16 @@ registry.registerPath({
}
}
},
responses: {}
responses: {
200: {
description: "Successful response",
content: {
"application/json": {
schema: createApiResponseSchema(InviteUserResponseDataSchema)
}
}
}
}
});
export async function inviteUser(

View File

@@ -101,7 +101,22 @@ registry.registerPath({
params: listInvitationsParamsSchema,
query: listInvitationsQuerySchema
},
responses: {}
responses: {
200: {
description: "Successful response",
content: {
"application/json": {
schema: z.object({
data: z.unknown().nullable(),
success: z.boolean(),
error: z.boolean(),
message: z.string(),
status: z.number()
})
}
}
}
}
});
export async function listInvitations(

View File

@@ -150,7 +150,22 @@ registry.registerPath({
params: listUsersParamsSchema,
query: listUsersSchema
},
responses: {}
responses: {
200: {
description: "Successful response",
content: {
"application/json": {
schema: z.object({
data: z.unknown().nullable(),
success: z.boolean(),
error: z.boolean(),
message: z.string(),
status: z.number()
})
}
}
}
}
});
export async function listUsers(

View File

@@ -23,7 +23,22 @@ registry.registerPath({
request: {
params: removeInvitationParamsSchema
},
responses: {}
responses: {
200: {
description: "Successful response",
content: {
"application/json": {
schema: z.object({
data: z.unknown().nullable(),
success: z.boolean(),
error: z.boolean(),
message: z.string(),
status: z.number()
})
}
}
}
}
});
export async function removeInvitation(

View File

@@ -38,7 +38,22 @@ registry.registerPath({
request: {
params: removeUserSchema
},
responses: {}
responses: {
200: {
description: "Successful response",
content: {
"application/json": {
schema: z.object({
data: z.unknown().nullable(),
success: z.boolean(),
error: z.boolean(),
message: z.string(),
status: z.number()
})
}
}
}
}
});
export async function removeUserOrg(

View File

@@ -11,7 +11,7 @@ import { fromError } from "zod-validation-error";
const removeUserResourceSchema = z.strictObject({
userId: z.string(),
resourceId: z.string().transform(Number).pipe(z.int().positive())
resourceId: z.coerce.number().int().positive()
});
export async function removeUserResource(

View File

@@ -37,7 +37,22 @@ registry.registerPath({
}
}
},
responses: {}
responses: {
200: {
description: "Successful response",
content: {
"application/json": {
schema: z.object({
data: z.unknown().nullable(),
success: z.boolean(),
error: z.boolean(),
message: z.string(),
status: z.number()
})
}
}
}
}
});
export async function updateOrgUser(