mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
adjustment: removed artificial limiting of pit versions
This commit is contained in:
@@ -4,7 +4,6 @@ import { TableName, TSecretTagJunctionInsert } from "@app/db/schemas";
|
||||
import { BadRequestError, InternalServerError } from "@app/lib/errors";
|
||||
import { groupBy } from "@app/lib/fn";
|
||||
import { logger } from "@app/lib/logger";
|
||||
import { TProjectDALFactory } from "@app/services/project/project-dal";
|
||||
import { TSecretDALFactory } from "@app/services/secret/secret-dal";
|
||||
import { TSecretVersionDALFactory } from "@app/services/secret/secret-version-dal";
|
||||
import { TSecretVersionTagDALFactory } from "@app/services/secret/secret-version-tag-dal";
|
||||
@@ -38,7 +37,6 @@ type TSecretSnapshotServiceFactoryDep = {
|
||||
folderDAL: Pick<TSecretFolderDALFactory, "findById" | "findBySecretPath" | "delete" | "insertMany" | "find">;
|
||||
permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;
|
||||
licenseService: Pick<TLicenseServiceFactory, "isValidLicense">;
|
||||
projectDAL: Pick<TProjectDALFactory, "findById">;
|
||||
};
|
||||
|
||||
export type TSecretSnapshotServiceFactory = ReturnType<typeof secretSnapshotServiceFactory>;
|
||||
@@ -50,7 +48,6 @@ export const secretSnapshotServiceFactory = ({
|
||||
snapshotSecretDAL,
|
||||
snapshotFolderDAL,
|
||||
folderDAL,
|
||||
projectDAL,
|
||||
secretDAL,
|
||||
permissionService,
|
||||
licenseService,
|
||||
@@ -84,9 +81,7 @@ export const secretSnapshotServiceFactory = ({
|
||||
const folder = await folderDAL.findBySecretPath(projectId, environment, path);
|
||||
if (!folder) throw new BadRequestError({ message: "Folder not found" });
|
||||
|
||||
const project = await projectDAL.findById(projectId);
|
||||
const count = await snapshotDAL.countOfSnapshotsByFolderId(folder.id);
|
||||
return Math.min(count, project.pitVersionLimit);
|
||||
return snapshotDAL.countOfSnapshotsByFolderId(folder.id);
|
||||
};
|
||||
|
||||
const listSnapshots = async ({
|
||||
@@ -118,16 +113,7 @@ export const secretSnapshotServiceFactory = ({
|
||||
const folder = await folderDAL.findBySecretPath(projectId, environment, path);
|
||||
if (!folder) throw new BadRequestError({ message: "Folder not found" });
|
||||
|
||||
const { pitVersionLimit } = await projectDAL.findById(projectId);
|
||||
const computedQueryLimit = Math.min(pitVersionLimit - offset, limit);
|
||||
if (offset > pitVersionLimit || computedQueryLimit <= 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const snapshots = await snapshotDAL.find(
|
||||
{ folderId: folder.id },
|
||||
{ limit: computedQueryLimit, offset, sort: [["createdAt", "desc"]] }
|
||||
);
|
||||
const snapshots = await snapshotDAL.find({ folderId: folder.id }, { limit, offset, sort: [["createdAt", "desc"]] });
|
||||
return snapshots;
|
||||
};
|
||||
|
||||
|
||||
@@ -341,7 +341,6 @@ export const snapshotDALFactory = (db: TDbClient) => {
|
||||
.select("id");
|
||||
|
||||
const batchEntries = folderBatch.map((folder) => folder.id);
|
||||
logger.info("UUID offset:", uuidOffset);
|
||||
|
||||
if (folderBatch.length) {
|
||||
try {
|
||||
|
||||
@@ -535,7 +535,6 @@ export const registerRoutes = async (
|
||||
licenseService,
|
||||
folderDAL,
|
||||
secretDAL,
|
||||
projectDAL,
|
||||
snapshotDAL,
|
||||
snapshotFolderDAL,
|
||||
snapshotSecretDAL,
|
||||
|
||||
@@ -72,7 +72,7 @@ type TSecretServiceFactoryDep = {
|
||||
secretDAL: TSecretDALFactory;
|
||||
secretTagDAL: TSecretTagDALFactory;
|
||||
secretVersionDAL: TSecretVersionDALFactory;
|
||||
projectDAL: Pick<TProjectDALFactory, "checkProjectUpgradeStatus" | "findProjectBySlug" | "findById">;
|
||||
projectDAL: Pick<TProjectDALFactory, "checkProjectUpgradeStatus" | "findProjectBySlug">;
|
||||
projectEnvDAL: Pick<TProjectEnvDALFactory, "findOne">;
|
||||
folderDAL: Pick<
|
||||
TSecretFolderDALFactory,
|
||||
@@ -1354,16 +1354,7 @@ export const secretServiceFactory = ({
|
||||
);
|
||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.SecretRollback);
|
||||
|
||||
const { pitVersionLimit } = await projectDAL.findById(folder.projectId);
|
||||
const computedQueryLimit = Math.min(pitVersionLimit - offset, limit);
|
||||
if (offset > pitVersionLimit || computedQueryLimit <= 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const secretVersions = await secretVersionDAL.find(
|
||||
{ secretId },
|
||||
{ offset, limit: computedQueryLimit, sort: [["createdAt", "desc"]] }
|
||||
);
|
||||
const secretVersions = await secretVersionDAL.find({ secretId }, { offset, limit, sort: [["createdAt", "desc"]] });
|
||||
return secretVersions;
|
||||
};
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ export const PointInTimeVersionLimitSection = () => {
|
||||
|
||||
const {
|
||||
control,
|
||||
formState: { isSubmitting },
|
||||
formState: { isSubmitting, isDirty },
|
||||
handleSubmit
|
||||
} = useForm<TForm>({
|
||||
resolver: zodResolver(formSchema),
|
||||
@@ -79,7 +79,12 @@ export const PointInTimeVersionLimitSection = () => {
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<Button colorSchema="secondary" type="submit" isLoading={isSubmitting} disabled={!isAdmin}>
|
||||
<Button
|
||||
colorSchema="secondary"
|
||||
type="submit"
|
||||
isLoading={isSubmitting}
|
||||
disabled={!isAdmin || !isDirty}
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user