mirror of
https://github.com/freedbygrace/ActiveDirectoryManager.git
synced 2026-08-27 19:17:07 +00:00
Update API response structure to include pagination metadata.
Replit-Commit-Author: Agent Replit-Commit-Session-Id: 705f2157-ef97-4fbd-89e4-8c7f2ecaea90 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7ed01c5f-a82d-405a-b728-b2e3d127c60c/c818a471-e356-4d5e-8f68-50e8c07bc1d5.jpg
This commit is contained in:
@@ -269,7 +269,7 @@ export function generatePaginationMetadata(
|
|||||||
// If no pagination params were specified
|
// If no pagination params were specified
|
||||||
if (limit === undefined) {
|
if (limit === undefined) {
|
||||||
return {
|
return {
|
||||||
pagination: {
|
metadata: {
|
||||||
totalRecords,
|
totalRecords,
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
totalPages: 1,
|
totalPages: 1,
|
||||||
@@ -284,7 +284,7 @@ export function generatePaginationMetadata(
|
|||||||
const totalPages = Math.ceil(totalRecords / limit);
|
const totalPages = Math.ceil(totalRecords / limit);
|
||||||
|
|
||||||
// Prepare pagination metadata
|
// Prepare pagination metadata
|
||||||
const pagination = {
|
const metadata = {
|
||||||
totalRecords,
|
totalRecords,
|
||||||
currentPage,
|
currentPage,
|
||||||
totalPages,
|
totalPages,
|
||||||
@@ -305,7 +305,7 @@ export function generatePaginationMetadata(
|
|||||||
|
|
||||||
const nextUrl = new URL(url.pathname, url.origin);
|
const nextUrl = new URL(url.pathname, url.origin);
|
||||||
nextUrl.search = params.toString();
|
nextUrl.search = params.toString();
|
||||||
pagination.nextPage = nextUrl.toString();
|
metadata.nextPage = nextUrl.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Previous page
|
// Previous page
|
||||||
@@ -316,11 +316,11 @@ export function generatePaginationMetadata(
|
|||||||
|
|
||||||
const prevUrl = new URL(url.pathname, url.origin);
|
const prevUrl = new URL(url.pathname, url.origin);
|
||||||
prevUrl.search = params.toString();
|
prevUrl.search = params.toString();
|
||||||
pagination.previousPage = prevUrl.toString();
|
metadata.previousPage = prevUrl.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { pagination };
|
return { metadata };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -419,7 +419,7 @@ The response will include pagination metadata with the following structure:
|
|||||||
\`\`\`json
|
\`\`\`json
|
||||||
{
|
{
|
||||||
"data": [...], // The actual records
|
"data": [...], // The actual records
|
||||||
"pagination": {
|
"metadata": {
|
||||||
"totalRecords": 100, // Total number of records
|
"totalRecords": 100, // Total number of records
|
||||||
"currentPage": 3, // Current page number (1-based)
|
"currentPage": 3, // Current page number (1-based)
|
||||||
"totalPages": 10, // Total number of pages
|
"totalPages": 10, // Total number of pages
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ const swaggerOptions = {
|
|||||||
lastLogon: { type: "string", format: "date-time" },
|
lastLogon: { type: "string", format: "date-time" },
|
||||||
memberOf: { type: "array", items: { type: "string" } },
|
memberOf: { type: "array", items: { type: "string" } },
|
||||||
adProperties: { type: "object" },
|
adProperties: { type: "object" },
|
||||||
|
objectType: { type: "string", enum: ["user"] },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
AdGroup: {
|
AdGroup: {
|
||||||
@@ -122,6 +123,7 @@ const swaggerOptions = {
|
|||||||
description: { type: "string" },
|
description: { type: "string" },
|
||||||
members: { type: "array", items: { type: "string" } },
|
members: { type: "array", items: { type: "string" } },
|
||||||
adProperties: { type: "object" },
|
adProperties: { type: "object" },
|
||||||
|
objectType: { type: "string", enum: ["group"] },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
AdOrgUnit: {
|
AdOrgUnit: {
|
||||||
@@ -136,6 +138,7 @@ const swaggerOptions = {
|
|||||||
name: { type: "string" },
|
name: { type: "string" },
|
||||||
description: { type: "string" },
|
description: { type: "string" },
|
||||||
adProperties: { type: "object" },
|
adProperties: { type: "object" },
|
||||||
|
objectType: { type: "string", enum: ["organizationalUnit"] },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
AdComputer: {
|
AdComputer: {
|
||||||
@@ -154,6 +157,7 @@ const swaggerOptions = {
|
|||||||
lastLogon: { type: "string", format: "date-time" },
|
lastLogon: { type: "string", format: "date-time" },
|
||||||
enabled: { type: "boolean" },
|
enabled: { type: "boolean" },
|
||||||
adProperties: { type: "object" },
|
adProperties: { type: "object" },
|
||||||
|
objectType: { type: "string", enum: ["computer"] },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
AdDomain: {
|
AdDomain: {
|
||||||
@@ -170,6 +174,7 @@ const swaggerOptions = {
|
|||||||
forestName: { type: "string" },
|
forestName: { type: "string" },
|
||||||
domainFunctionality: { type: "string" },
|
domainFunctionality: { type: "string" },
|
||||||
adProperties: { type: "object" },
|
adProperties: { type: "object" },
|
||||||
|
objectType: { type: "string", enum: ["domain"] },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
LdapAttribute: {
|
LdapAttribute: {
|
||||||
@@ -312,6 +317,34 @@ const swaggerOptions = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
PaginatedResponse: {
|
||||||
|
description: "Successful response with pagination metadata",
|
||||||
|
content: {
|
||||||
|
"application/json": {
|
||||||
|
schema: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
data: {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "object"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
metadata: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
currentPage: { type: "integer" },
|
||||||
|
totalPages: { type: "integer" },
|
||||||
|
totalRecords: { type: "integer" },
|
||||||
|
nextPage: { type: "string", nullable: true },
|
||||||
|
previousPage: { type: "string", nullable: true }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
security: [
|
security: [
|
||||||
|
|||||||
Reference in New Issue
Block a user