fix: fix project MI pagination, search and org identity name search regex

This commit is contained in:
Scott Wilson
2025-12-19 16:59:36 -08:00
parent b121a85b9d
commit fe5b8cd124
3 changed files with 19 additions and 13 deletions

View File

@@ -20,7 +20,10 @@ const searchResourceZodValidate = zodValidateCharacters([
CharacterType.AlphaNumeric,
CharacterType.Spaces,
CharacterType.Underscore,
CharacterType.Hyphen
CharacterType.Hyphen,
CharacterType.ForwardSlash
// TODO: scott - adding forwardslash for quick fix but we don't constrain identity name creation - not sure why we added this but we should evaluate if needed and if so make consistent with
// the actual name limitations
]);
export const registerIdentityRouter = async (server: FastifyZodProvider) => {

View File

@@ -253,15 +253,12 @@ export const membershipIdentityDALFactory = (db: TDbClient) => {
}
});
if (filter.limit) void paginatedIdentitys.limit(filter.limit);
if (filter.offset) void paginatedIdentitys.offset(filter.offset);
if (filter.name || filter.role) {
buildKnexFilterForSearchResource(
paginatedIdentitys,
{
name: filter.name!,
role: filter.role!
...(filter.name && { name: filter.name }),
...(filter.role && { role: filter.role })
},
(attr) => {
switch (attr) {
@@ -276,6 +273,17 @@ export const membershipIdentityDALFactory = (db: TDbClient) => {
);
}
const countQuery = await paginatedIdentitys
.clone()
.select(
db.raw(
`count(${TableName.Membership}."actorIdentityId") OVER(PARTITION BY ${TableName.Membership}."scopeOrgId") as total`
)
);
if (filter.limit) void paginatedIdentitys.limit(filter.limit);
if (filter.offset) void paginatedIdentitys.offset(filter.offset);
const docs = await (tx || db.replicaNode())(TableName.Membership)
.whereNotNull(`${TableName.Membership}.actorIdentityId`)
.join(TableName.Identity, `${TableName.Identity}.id`, `${TableName.Membership}.actorIdentityId`)
@@ -308,11 +316,6 @@ export const membershipIdentityDALFactory = (db: TDbClient) => {
.as("membershipRoleTemporaryAccessEndTime"),
db.ref("createdAt").withSchema(TableName.MembershipRole).as("membershipRoleCreatedAt"),
db.ref("updatedAt").withSchema(TableName.MembershipRole).as("membershipRoleUpdatedAt")
)
.select(
db.raw(
`count(${TableName.Membership}."actorIdentityId") OVER(PARTITION BY ${TableName.Membership}."scopeOrgId") as total`
)
);
const data = sqlNestRelationships({
@@ -368,7 +371,7 @@ export const membershipIdentityDALFactory = (db: TDbClient) => {
}
]
});
return { data, totalCount: Number((data?.[0] as unknown as { total: number })?.total ?? 0) };
return { data, totalCount: Number((countQuery?.[0] as unknown as { total: number })?.total ?? 0) };
} catch (error) {
throw new DatabaseError({ error, name: "MembershipfindIdentity" });
}

View File

@@ -71,7 +71,7 @@ export const useListProjectIdentityMemberships = (
limit: String(limit),
orderBy: String(orderBy),
orderDirection: String(orderDirection),
search: String(search)
identityName: String(search)
});
const { data } = await apiRequest.get<TProjectIdentityMembershipsListV2>(