mirror of
https://github.com/Infisical/infisical.git
synced 2026-01-07 22:53:55 -05:00
fix: fix project MI pagination, search and org identity name search regex
This commit is contained in:
@@ -20,7 +20,10 @@ const searchResourceZodValidate = zodValidateCharacters([
|
|||||||
CharacterType.AlphaNumeric,
|
CharacterType.AlphaNumeric,
|
||||||
CharacterType.Spaces,
|
CharacterType.Spaces,
|
||||||
CharacterType.Underscore,
|
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) => {
|
export const registerIdentityRouter = async (server: FastifyZodProvider) => {
|
||||||
|
|||||||
@@ -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) {
|
if (filter.name || filter.role) {
|
||||||
buildKnexFilterForSearchResource(
|
buildKnexFilterForSearchResource(
|
||||||
paginatedIdentitys,
|
paginatedIdentitys,
|
||||||
{
|
{
|
||||||
name: filter.name!,
|
...(filter.name && { name: filter.name }),
|
||||||
role: filter.role!
|
...(filter.role && { role: filter.role })
|
||||||
},
|
},
|
||||||
(attr) => {
|
(attr) => {
|
||||||
switch (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)
|
const docs = await (tx || db.replicaNode())(TableName.Membership)
|
||||||
.whereNotNull(`${TableName.Membership}.actorIdentityId`)
|
.whereNotNull(`${TableName.Membership}.actorIdentityId`)
|
||||||
.join(TableName.Identity, `${TableName.Identity}.id`, `${TableName.Membership}.actorIdentityId`)
|
.join(TableName.Identity, `${TableName.Identity}.id`, `${TableName.Membership}.actorIdentityId`)
|
||||||
@@ -308,11 +316,6 @@ export const membershipIdentityDALFactory = (db: TDbClient) => {
|
|||||||
.as("membershipRoleTemporaryAccessEndTime"),
|
.as("membershipRoleTemporaryAccessEndTime"),
|
||||||
db.ref("createdAt").withSchema(TableName.MembershipRole).as("membershipRoleCreatedAt"),
|
db.ref("createdAt").withSchema(TableName.MembershipRole).as("membershipRoleCreatedAt"),
|
||||||
db.ref("updatedAt").withSchema(TableName.MembershipRole).as("membershipRoleUpdatedAt")
|
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({
|
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) {
|
} catch (error) {
|
||||||
throw new DatabaseError({ error, name: "MembershipfindIdentity" });
|
throw new DatabaseError({ error, name: "MembershipfindIdentity" });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export const useListProjectIdentityMemberships = (
|
|||||||
limit: String(limit),
|
limit: String(limit),
|
||||||
orderBy: String(orderBy),
|
orderBy: String(orderBy),
|
||||||
orderDirection: String(orderDirection),
|
orderDirection: String(orderDirection),
|
||||||
search: String(search)
|
identityName: String(search)
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data } = await apiRequest.get<TProjectIdentityMembershipsListV2>(
|
const { data } = await apiRequest.get<TProjectIdentityMembershipsListV2>(
|
||||||
|
|||||||
Reference in New Issue
Block a user