Skip to content

Commit 92d4ae7

Browse files
atrakhConvex, Inc.
authored andcommitted
Add support for paginating project list (#43727)
GitOrigin-RevId: 324af62ea244a584440a9278b6f7862d6c31acce
1 parent f81fe30 commit 92d4ae7

File tree

3 files changed

+84
-6
lines changed

3 files changed

+84
-6
lines changed

npm-packages/dashboard/dashboard-management-openapi.json

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,18 @@
492492
"in": "path",
493493
"description": "",
494494
"required": true
495+
},
496+
{
497+
"name": "cursor",
498+
"in": "query",
499+
"description": "Cursor for pagination (optional)",
500+
"required": true
501+
},
502+
{
503+
"name": "limit",
504+
"in": "query",
505+
"description": "Maximum number of projects to return (optional, defaults to 100)",
506+
"required": true
495507
}
496508
],
497509
"responses": {
@@ -500,10 +512,7 @@
500512
"content": {
501513
"application/json": {
502514
"schema": {
503-
"type": "array",
504-
"items": {
505-
"$ref": "#/components/schemas/ProjectDetails"
506-
}
515+
"$ref": "#/components/schemas/ProjectsResponse"
507516
}
508517
}
509518
}
@@ -4798,6 +4807,41 @@
47984807
}
47994808
}
48004809
},
4810+
"PaginatedProjectsResponse": {
4811+
"type": "object",
4812+
"required": [
4813+
"items",
4814+
"pagination"
4815+
],
4816+
"properties": {
4817+
"items": {
4818+
"type": "array",
4819+
"items": {
4820+
"$ref": "#/components/schemas/ProjectDetails"
4821+
}
4822+
},
4823+
"pagination": {
4824+
"$ref": "#/components/schemas/PaginationMetadata"
4825+
}
4826+
}
4827+
},
4828+
"PaginationMetadata": {
4829+
"type": "object",
4830+
"required": [
4831+
"hasMore"
4832+
],
4833+
"properties": {
4834+
"hasMore": {
4835+
"type": "boolean"
4836+
},
4837+
"nextCursor": {
4838+
"type": [
4839+
"string",
4840+
"null"
4841+
]
4842+
}
4843+
}
4844+
},
48014845
"PaymentMethodResponse": {
48024846
"type": "object",
48034847
"required": [
@@ -5039,6 +5083,19 @@
50395083
"ProjectSlug": {
50405084
"type": "string"
50415085
},
5086+
"ProjectsResponse": {
5087+
"oneOf": [
5088+
{
5089+
"$ref": "#/components/schemas/PaginatedProjectsResponse"
5090+
},
5091+
{
5092+
"type": "array",
5093+
"items": {
5094+
"$ref": "#/components/schemas/ProjectDetails"
5095+
}
5096+
}
5097+
]
5098+
},
50425099
"ProposedTeamName": {
50435100
"type": "string"
50445101
},

npm-packages/dashboard/src/api/projects.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ export function useProjects(
3535
// If initial data has been loaded via SSR, we don't need to load projects.
3636
swrOptions: { refreshInterval, revalidateOnMount: !initialData },
3737
});
38+
39+
if (data !== undefined && !Array.isArray(data)) {
40+
throw new Error("Expected array of projects");
41+
}
3842
return data;
3943
}
4044

npm-packages/dashboard/src/generatedApi.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,6 +2160,14 @@ export interface components {
21602160
plan: components["schemas"]["PlanResponse"];
21612161
status: string;
21622162
};
2163+
PaginatedProjectsResponse: {
2164+
items: components["schemas"]["ProjectDetails"][];
2165+
pagination: components["schemas"]["PaginationMetadata"];
2166+
};
2167+
PaginationMetadata: {
2168+
hasMore: boolean;
2169+
nextCursor?: string | null;
2170+
};
21632171
PaymentMethodResponse: {
21642172
display: string;
21652173
kind: string;
@@ -2225,6 +2233,7 @@ export interface components {
22252233
role?: null | components["schemas"]["ProjectRole"];
22262234
};
22272235
ProjectSlug: string;
2236+
ProjectsResponse: components["schemas"]["PaginatedProjectsResponse"] | components["schemas"]["ProjectDetails"][];
22282237
ProposedTeamName: string;
22292238
ProvisionDeploymentDashboardArgs: {
22302239
deploymentType: components["schemas"]["DeploymentType"];
@@ -2576,6 +2585,8 @@ export type OauthAppResponse = components['schemas']['OauthAppResponse'];
25762585
export type OptIn = components['schemas']['OptIn'];
25772586
export type OptInToAccept = components['schemas']['OptInToAccept'];
25782587
export type OrbSubscriptionResponse = components['schemas']['OrbSubscriptionResponse'];
2588+
export type PaginatedProjectsResponse = components['schemas']['PaginatedProjectsResponse'];
2589+
export type PaginationMetadata = components['schemas']['PaginationMetadata'];
25792590
export type PaymentMethodResponse = components['schemas']['PaymentMethodResponse'];
25802591
export type PeriodicBackupConfig = components['schemas']['PeriodicBackupConfig'];
25812592
export type PlanResponse = components['schemas']['PlanResponse'];
@@ -2590,6 +2601,7 @@ export type ProjectName = components['schemas']['ProjectName'];
25902601
export type ProjectRole = components['schemas']['ProjectRole'];
25912602
export type ProjectRoleUpdateArg = components['schemas']['ProjectRoleUpdateArg'];
25922603
export type ProjectSlug = components['schemas']['ProjectSlug'];
2604+
export type ProjectsResponse = components['schemas']['ProjectsResponse'];
25932605
export type ProposedTeamName = components['schemas']['ProposedTeamName'];
25942606
export type ProvisionDeploymentDashboardArgs = components['schemas']['ProvisionDeploymentDashboardArgs'];
25952607
export type ProvisionDeploymentDashboardResponse = components['schemas']['ProvisionDeploymentDashboardResponse'];
@@ -3101,7 +3113,12 @@ export interface operations {
31013113
};
31023114
get_projects_for_team: {
31033115
parameters: {
3104-
query?: never;
3116+
query: {
3117+
/** @description Cursor for pagination (optional) */
3118+
cursor: string;
3119+
/** @description Maximum number of projects to return (optional, defaults to 100) */
3120+
limit: string;
3121+
};
31053122
header?: never;
31063123
path: {
31073124
team_id: string;
@@ -3115,7 +3132,7 @@ export interface operations {
31153132
[name: string]: unknown;
31163133
};
31173134
content: {
3118-
"application/json": components["schemas"]["ProjectDetails"][];
3135+
"application/json": components["schemas"]["ProjectsResponse"];
31193136
};
31203137
};
31213138
};

0 commit comments

Comments
 (0)