mirror of
https://github.com/fosrl/pangolin.git
synced 2026-06-25 00:31:58 +00:00
Merge branch 'main' into dev
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user