Skip to content

Commit 2c602ab

Browse files
authored
Merge pull request #388 from trycompai/claudio/comp-84-heal-organizations-with-empty-controlspoliciesartifacts
Claudio/comp 84 heal organizations with empty controlspoliciesartifacts
2 parents e30a073 + b89743e commit 2c602ab

File tree

419 files changed

+7509
-4472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

419 files changed

+7509
-4472
lines changed

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
"[prisma]": {
44
"editor.defaultFormatter": "Prisma.prisma"
55
},
6+
"[javascript]": {
7+
"editor.defaultFormatter": "biomejs.biome"
8+
},
9+
"[typescript]": {
10+
"editor.defaultFormatter": "biomejs.biome"
11+
},
612
"editor.defaultFormatter": "biomejs.biome",
713
"editor.tabSize": 4,
814
"editor.detectIndentation": true,
@@ -11,5 +17,8 @@
1117
},
1218
"[dockercompose]": {
1319
"editor.tabSize": 4
20+
},
21+
"editor.codeActionsOnSave": {
22+
"source.fixAll.biome": "explicit"
1423
}
1524
}

apps/app/.vscode/settings.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

apps/app/src/actions/add-comment.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"use server";
22

3-
import { authActionClient } from "./safe-action";
4-
import { z } from "zod";
5-
import { db } from "@comp/db";
63
import { AppError, appErrors } from "@/lib/errors";
7-
import { headers } from "next/headers";
4+
import { db } from "@comp/db";
85
import { revalidatePath } from "next/cache";
6+
import { headers } from "next/headers";
7+
import { z } from "zod";
8+
import { authActionClient } from "./safe-action";
99

1010
export const addCommentAction = authActionClient
1111
.schema(
@@ -58,7 +58,9 @@ export const addCommentAction = authActionClient
5858

5959
const headersList = await headers();
6060
let path =
61-
headersList.get("x-pathname") || headersList.get("referer") || "";
61+
headersList.get("x-pathname") ||
62+
headersList.get("referer") ||
63+
"";
6264
path = path.replace(/\/[a-z]{2}\//, "/");
6365

6466
if (path) {
@@ -69,7 +71,10 @@ export const addCommentAction = authActionClient
6971
} catch (error) {
7072
return {
7173
success: false,
72-
error: error instanceof AppError ? error : appErrors.UNEXPECTED_ERROR,
74+
error:
75+
error instanceof AppError
76+
? error
77+
: appErrors.UNEXPECTED_ERROR,
7378
};
7479
}
7580
});

apps/app/src/actions/change-organization.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"use server";
22

3-
import { authActionClient } from "./safe-action";
4-
import { z } from "zod";
3+
import { auth } from "@/utils/auth";
54
import { db } from "@comp/db";
65
import { revalidatePath } from "next/cache";
76
import { headers } from "next/headers";
8-
import { auth } from "@/utils/auth";
7+
import { z } from "zod";
8+
import { authActionClient } from "./safe-action";
99

1010
export const changeOrganizationAction = authActionClient
1111
.schema(

apps/app/src/actions/files/delete-file.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ export const deleteFile = authActionClient
8181
where: { id: evidenceId },
8282
data: {
8383
fileUrls: {
84-
set: evidence.fileUrls.filter((url) => url !== fileUrl),
84+
set: evidence.fileUrls.filter(
85+
(url) => url !== fileUrl,
86+
),
8587
},
8688
},
8789
});

apps/app/src/actions/files/get-file-url.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"use server";
22

33
import { authActionClient } from "@/actions/safe-action";
4+
import { UPLOAD_TYPE } from "@/actions/types";
5+
import { GetObjectCommand, S3Client } from "@aws-sdk/client-s3";
6+
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
47
import { db } from "@comp/db";
58
import { z } from "zod";
6-
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
7-
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
8-
import { UPLOAD_TYPE } from "@/actions/types";
99

1010
if (!process.env.AWS_ACCESS_KEY_ID || !process.env.AWS_SECRET_ACCESS_KEY) {
1111
throw new Error("AWS credentials are not set");

apps/app/src/actions/files/upload-file.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"use server";
22

33
import { authActionClient } from "@/actions/safe-action";
4-
import { z } from "zod";
5-
import { db } from "@comp/db";
6-
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
7-
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
84
import { UPLOAD_TYPE } from "@/actions/types";
5+
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
6+
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
7+
import { db } from "@comp/db";
8+
import { z } from "zod";
99

1010
if (!process.env.AWS_ACCESS_KEY_ID || !process.env.AWS_SECRET_ACCESS_KEY) {
1111
throw new Error("AWS credentials are not set");
@@ -80,7 +80,10 @@ export const uploadFile = authActionClient
8080
}
8181

8282
const timestamp = Date.now();
83-
const sanitizedFileName = fileName.replace(/[^a-zA-Z0-9.-]/g, "_");
83+
const sanitizedFileName = fileName.replace(
84+
/[^a-zA-Z0-9.-]/g,
85+
"_",
86+
);
8487
key = `${session.activeOrganizationId}/${evidenceId}/${timestamp}-${sanitizedFileName}`;
8588

8689
const command = new PutObjectCommand({

apps/app/src/actions/integrations/update-integration-settings-action.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ export const updateIntegrationSettingsAction = authActionClient
2424
},
2525
})
2626
.action(
27-
async ({ parsedInput: { integration_id, option }, ctx: { session } }) => {
27+
async ({
28+
parsedInput: { integration_id, option },
29+
ctx: { session },
30+
}) => {
2831
try {
2932
if (!session.activeOrganizationId) {
3033
throw new Error("User organization not found");
@@ -65,13 +68,15 @@ export const updateIntegrationSettingsAction = authActionClient
6568
);
6669

6770
const encryptedSettings = await Promise.all(
68-
Object.entries(parsedUserSettings).map(async ([key, value]) => {
69-
if (typeof value === "string") {
70-
const encrypted = await encrypt(value);
71-
return [key, encrypted];
72-
}
73-
return [key, value];
74-
}),
71+
Object.entries(parsedUserSettings).map(
72+
async ([key, value]) => {
73+
if (typeof value === "string") {
74+
const encrypted = await encrypt(value);
75+
return [key, encrypted];
76+
}
77+
return [key, value];
78+
},
79+
),
7580
).then(Object.fromEntries);
7681

7782
await db.integration.update({

apps/app/src/actions/organization/accept-invitation.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ export const completeInvitation = authActionClient
5757
}
5858

5959
try {
60-
const invitation = await validateInviteCode(inviteCode, user.email);
60+
const invitation = await validateInviteCode(
61+
inviteCode,
62+
user.email,
63+
);
6164

6265
if (!invitation) {
6366
throw new Error("Invitation either used or expired");
@@ -71,7 +74,10 @@ export const completeInvitation = authActionClient
7174
});
7275

7376
if (existingMembership) {
74-
if (ctx.session.activeOrganizationId !== invitation.organizationId) {
77+
if (
78+
ctx.session.activeOrganizationId !==
79+
invitation.organizationId
80+
) {
7581
await db.session.update({
7682
where: { id: ctx.session.id },
7783
data: {
@@ -128,7 +134,9 @@ export const completeInvitation = authActionClient
128134
});
129135

130136
revalidatePath(`/${invitation.organization.id}`);
131-
revalidatePath(`/${invitation.organization.id}/settings/members`);
137+
revalidatePath(
138+
`/${invitation.organization.id}/settings/members`,
139+
);
132140
revalidateTag(`user_${user.id}`);
133141

134142
return {

apps/app/src/actions/organization/create-api-key-action.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ export const createApiKeyAction = authActionClient
1818
.action(async ({ parsedInput, ctx }) => {
1919
try {
2020
const { name, expiresAt } = parsedInput;
21-
console.log(`Creating API key "${name}" with expiration: ${expiresAt}`);
21+
console.log(
22+
`Creating API key "${name}" with expiration: ${expiresAt}`,
23+
);
2224

2325
// Generate a new API key and salt
2426
const apiKey = generateApiKey();
@@ -34,16 +36,24 @@ export const createApiKeyAction = authActionClient
3436
const now = new Date();
3537
switch (expiresAt) {
3638
case "30days":
37-
expirationDate = new Date(now.setDate(now.getDate() + 30));
39+
expirationDate = new Date(
40+
now.setDate(now.getDate() + 30),
41+
);
3842
break;
3943
case "90days":
40-
expirationDate = new Date(now.setDate(now.getDate() + 90));
44+
expirationDate = new Date(
45+
now.setDate(now.getDate() + 90),
46+
);
4147
break;
4248
case "1year":
43-
expirationDate = new Date(now.setFullYear(now.getFullYear() + 1));
49+
expirationDate = new Date(
50+
now.setFullYear(now.getFullYear() + 1),
51+
);
4452
break;
4553
}
46-
console.log(`Set expiration date to: ${expirationDate?.toISOString()}`);
54+
console.log(
55+
`Set expiration date to: ${expirationDate?.toISOString()}`,
56+
);
4757
} else {
4858
console.log("No expiration date set for API key");
4959
}
@@ -64,9 +74,13 @@ export const createApiKeyAction = authActionClient
6474
expiresAt: true,
6575
},
6676
});
67-
console.log(`Successfully created API key with ID: ${apiKeyRecord.id}`);
77+
console.log(
78+
`Successfully created API key with ID: ${apiKeyRecord.id}`,
79+
);
6880

69-
revalidatePath(`/${ctx.session.activeOrganizationId}/settings/api-keys`);
81+
revalidatePath(
82+
`/${ctx.session.activeOrganizationId}/settings/api-keys`,
83+
);
7084

7185
return {
7286
success: true,
@@ -112,7 +126,8 @@ export const createApiKeyAction = authActionClient
112126
success: false,
113127
error: {
114128
code: "INTERNAL_ERROR",
115-
message: "An unexpected error occurred while creating the API key",
129+
message:
130+
"An unexpected error occurred while creating the API key",
116131
},
117132
};
118133
}

0 commit comments

Comments
 (0)