Skip to content

Commit a9c9b94

Browse files
authored
Merge pull request #686 from trycompai/main
[comp] Production Deploy
2 parents e6b4a44 + 71e3df0 commit a9c9b94

File tree

9 files changed

+441
-84
lines changed

9 files changed

+441
-84
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
on:
2+
release:
3+
types: [published]
4+
5+
jobs:
6+
github-releases-to-discord:
7+
permissions:
8+
contents: read
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v3
13+
- name: Github Releases To Discord
14+
uses: SethCohen/github-releases-to-discord@v1.16.2
15+
with:
16+
webhook_url: ${{ secrets.DISCORD_WEBHOOK_URL }}

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/components/comments/CommentForm.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ export function CommentForm({ entityId, entityType }: CommentFormProps) {
325325
) : (
326326
<Paperclip className="h-4 w-4" />
327327
)}
328-
<span className="sr-only">Attach file</span>
329328
</Button>
330329
)}
331330

apps/framework-editor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@radix-ui/react-checkbox": "latest",
2020
"@radix-ui/react-collapsible": "latest",
2121
"@radix-ui/react-context-menu": "2.2.4",
22-
"@radix-ui/react-dialog": "1.1.4",
22+
"@radix-ui/react-dialog": "1.1.14",
2323
"@radix-ui/react-dropdown-menu": "2.1.4",
2424
"@radix-ui/react-hover-card": "1.1.4",
2525
"@radix-ui/react-label": "2.1.1",

apps/trust/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@radix-ui/react-checkbox": "latest",
2020
"@radix-ui/react-collapsible": "latest",
2121
"@radix-ui/react-context-menu": "2.2.4",
22-
"@radix-ui/react-dialog": "1.1.4",
22+
"@radix-ui/react-dialog": "1.1.14",
2323
"@radix-ui/react-dropdown-menu": "2.1.4",
2424
"@radix-ui/react-hover-card": "1.1.4",
2525
"@radix-ui/react-label": "2.1.1",

bun.lock

Lines changed: 97 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.frameworkEditorModelSchemas = exports.FrameworkEditorControlTemplateSchema = exports.FrameworkEditorTaskTemplateSchema = exports.FrameworkEditorPolicyTemplateSchema = exports.FrameworkEditorRequirementSchema = exports.FrameworkEditorFrameworkSchema = exports.FrameworkEditorVideoSchema = void 0;
4+
const zod_1 = require("zod");
5+
// Assuming Frequency and Departments enums are defined elsewhere and imported
6+
// For now, we'll use z.string() as a placeholder if their definitions aren't available.
7+
// import { Frequency, Departments } from './path-to-shared-enums'; // Example import
8+
const datePreprocess = (arg) => {
9+
if (typeof arg === 'string' && /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}$/.test(arg)) {
10+
return arg.replace(' ', 'T') + 'Z';
11+
}
12+
return arg;
13+
};
14+
exports.FrameworkEditorVideoSchema = zod_1.z.object({
15+
id: zod_1.z.string().optional(), // @id @default
16+
title: zod_1.z.string(),
17+
description: zod_1.z.string(),
18+
youtubeId: zod_1.z.string(),
19+
url: zod_1.z.string(),
20+
createdAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for createdAt. Expected ISO 8601 format." })).optional(), // @default(now())
21+
updatedAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for updatedAt. Expected ISO 8601 format." })).optional(), // @default(now()) @updatedAt
22+
});
23+
exports.FrameworkEditorFrameworkSchema = zod_1.z.object({
24+
id: zod_1.z.string().optional(), // @id @default
25+
name: zod_1.z.string(),
26+
version: zod_1.z.string(),
27+
description: zod_1.z.string(),
28+
// requirements: FrameworkEditorRequirement[] - relational, omitted
29+
// frameworkInstances: FrameworkInstance[] - relational, omitted
30+
createdAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for createdAt. Expected ISO 8601 format." })).optional(), // @default(now())
31+
updatedAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for updatedAt. Expected ISO 8601 format." })).optional(), // @default(now()) @updatedAt
32+
});
33+
exports.FrameworkEditorRequirementSchema = zod_1.z.object({
34+
id: zod_1.z.string().optional(), // @id @default
35+
frameworkId: zod_1.z.string(),
36+
// framework: FrameworkEditorFramework - relational, omitted
37+
name: zod_1.z.string(),
38+
identifier: zod_1.z.string().optional(), // @default("")
39+
description: zod_1.z.string(),
40+
// controlTemplates: FrameworkEditorControlTemplate[] - relational, omitted
41+
// requirementMaps: RequirementMap[] - relational, omitted
42+
createdAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for createdAt. Expected ISO 8601 format." })).optional(), // @default(now())
43+
updatedAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for updatedAt. Expected ISO 8601 format." })).optional(), // @default(now()) @updatedAt
44+
});
45+
exports.FrameworkEditorPolicyTemplateSchema = zod_1.z.object({
46+
id: zod_1.z.string().optional(), // @id @default
47+
name: zod_1.z.string(),
48+
description: zod_1.z.string(),
49+
frequency: zod_1.z.string(), // Placeholder for Frequency enum
50+
department: zod_1.z.string(), // Placeholder for Departments enum
51+
content: zod_1.z.any(), // Json
52+
// controlTemplates: FrameworkEditorControlTemplate[] - relational, omitted
53+
createdAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for createdAt. Expected ISO 8601 format." })).optional(), // @default(now())
54+
updatedAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for updatedAt. Expected ISO 8601 format." })).optional(), // @default(now()) @updatedAt
55+
// policies: Policy[] - relational, omitted
56+
});
57+
exports.FrameworkEditorTaskTemplateSchema = zod_1.z.object({
58+
id: zod_1.z.string().optional(), // @id @default
59+
name: zod_1.z.string(),
60+
description: zod_1.z.string(),
61+
frequency: zod_1.z.string(), // Placeholder for Frequency enum
62+
department: zod_1.z.string(), // Placeholder for Departments enum
63+
// controlTemplates: FrameworkEditorControlTemplate[] - relational, omitted
64+
createdAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for createdAt. Expected ISO 8601 format." })).optional(), // @default(now())
65+
updatedAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for updatedAt. Expected ISO 8601 format." })).optional(), // @default(now()) @updatedAt
66+
// tasks: Task[] - relational, omitted
67+
});
68+
exports.FrameworkEditorControlTemplateSchema = zod_1.z.object({
69+
id: zod_1.z.string().optional(), // @id @default
70+
name: zod_1.z.string(),
71+
description: zod_1.z.string(),
72+
// policyTemplates: FrameworkEditorPolicyTemplate[] - relational, omitted
73+
// requirements: FrameworkEditorRequirement[] - relational, omitted
74+
// taskTemplates: FrameworkEditorTaskTemplate[] - relational, omitted
75+
createdAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for createdAt. Expected ISO 8601 format." })).optional(), // @default(now())
76+
updatedAt: zod_1.z.preprocess(datePreprocess, zod_1.z.string().datetime({ message: "Invalid datetime string for updatedAt. Expected ISO 8601 format." })).optional(), // @default(now()) @updatedAt
77+
// controls: Control[] - relational, omitted
78+
});
79+
// For use in seed script validation
80+
exports.frameworkEditorModelSchemas = {
81+
FrameworkEditorVideo: exports.FrameworkEditorVideoSchema,
82+
FrameworkEditorFramework: exports.FrameworkEditorFrameworkSchema,
83+
FrameworkEditorRequirement: exports.FrameworkEditorRequirementSchema,
84+
FrameworkEditorPolicyTemplate: exports.FrameworkEditorPolicyTemplateSchema,
85+
FrameworkEditorTaskTemplate: exports.FrameworkEditorTaskTemplateSchema,
86+
FrameworkEditorControlTemplate: exports.FrameworkEditorControlTemplateSchema,
87+
};

packages/db/prisma/seed/seed.js

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
const client_1 = require("@prisma/client");
7+
const promises_1 = __importDefault(require("fs/promises"));
8+
const path_1 = __importDefault(require("path"));
9+
const frameworkEditorSchemas_1 = require("./frameworkEditorSchemas");
10+
const prisma = new client_1.PrismaClient();
11+
async function seedJsonFiles(subDirectory) {
12+
const directoryPath = path_1.default.join(__dirname, subDirectory);
13+
console.log(`Starting to seed files from: ${directoryPath}`);
14+
const files = await promises_1.default.readdir(directoryPath);
15+
const jsonFiles = files.filter((file) => file.endsWith(".json"));
16+
for (const jsonFile of jsonFiles) {
17+
try {
18+
const filePath = path_1.default.join(directoryPath, jsonFile);
19+
const jsonContent = await promises_1.default.readFile(filePath, "utf-8");
20+
const jsonData = JSON.parse(jsonContent);
21+
if (!Array.isArray(jsonData) || jsonData.length === 0) {
22+
console.log(`Skipping empty or invalid JSON file: ${jsonFile}`);
23+
continue;
24+
}
25+
if (subDirectory === "primitives") {
26+
const modelNameForPrisma = jsonFile.replace(".json", "");
27+
const prismaModelKey = modelNameForPrisma.charAt(0).toLowerCase() + modelNameForPrisma.slice(1);
28+
const zodModelKey = modelNameForPrisma;
29+
const prismaAny = prisma;
30+
if (!prismaAny[prismaModelKey] || typeof prismaAny[prismaModelKey].createMany !== 'function') {
31+
console.warn(`Model ${prismaModelKey} not found on Prisma client or does not support createMany. Skipping ${jsonFile}.`);
32+
continue;
33+
}
34+
const zodSchema = frameworkEditorSchemas_1.frameworkEditorModelSchemas[zodModelKey];
35+
if (!zodSchema) {
36+
console.warn(`Zod schema not found for model ${String(zodModelKey)}. Skipping validation for ${jsonFile}.`);
37+
}
38+
else {
39+
console.log(`Validating ${jsonData.length} records from ${jsonFile} against ${String(zodModelKey)} schema...`);
40+
for (const item of jsonData) {
41+
try {
42+
zodSchema.parse(item);
43+
}
44+
catch (validationError) {
45+
console.error(`Validation failed for an item in ${jsonFile} for model ${String(zodModelKey)}:`, item);
46+
console.error("Validation errors:", validationError);
47+
throw new Error(`Data validation failed for ${jsonFile}.`);
48+
}
49+
}
50+
console.log(`Validation successful for ${jsonFile}.`);
51+
}
52+
const processedData = jsonData.map(item => {
53+
const newItem = { ...item };
54+
if (newItem.createdAt && typeof newItem.createdAt === 'string') {
55+
newItem.createdAt = new Date(newItem.createdAt);
56+
}
57+
if (newItem.updatedAt && typeof newItem.updatedAt === 'string') {
58+
newItem.updatedAt = new Date(newItem.updatedAt);
59+
}
60+
return newItem;
61+
});
62+
console.log(`Seeding ${processedData.length} records from ${jsonFile} into ${prismaModelKey}...`);
63+
await prismaAny[prismaModelKey].createMany({
64+
data: processedData,
65+
skipDuplicates: true,
66+
});
67+
console.log(`Finished seeding ${jsonFile} from primitives.`);
68+
}
69+
else if (subDirectory === "relations") {
70+
// Expected filename format: _ModelAToModelB.json
71+
if (!jsonFile.startsWith("_") || !jsonFile.includes("To")) {
72+
console.warn(`Skipping relation file with unexpected format: ${jsonFile}`);
73+
continue;
74+
}
75+
const modelNamesPart = jsonFile.substring(1, jsonFile.indexOf(".json"));
76+
const [modelANamePascal, modelBNamePascal] = modelNamesPart.split("To");
77+
if (!modelANamePascal || !modelBNamePascal) {
78+
console.warn(`Could not parse model names from relation file: ${jsonFile}`);
79+
continue;
80+
}
81+
const prismaModelAName = modelANamePascal.charAt(0).toLowerCase() + modelANamePascal.slice(1);
82+
// Infer relation field name on ModelA: pluralized, camelCased ModelB name
83+
// e.g., if ModelB is FrameworkEditorPolicyTemplate, relation field is frameworkEditorPolicyTemplates
84+
// This is a common convention, but might need adjustment based on actual schema
85+
let relationFieldNameOnModelA = modelBNamePascal.charAt(0).toLowerCase() + modelBNamePascal.slice(1);
86+
if (!relationFieldNameOnModelA.endsWith("s")) { // basic pluralization
87+
relationFieldNameOnModelA += "s";
88+
}
89+
// Special handling for 'Requirement' -> 'requirements' (already plural)
90+
// and other specific cases if 's' isn't the right pluralization.
91+
// For now, using a direct map for known cases from the user's file names.
92+
if (modelBNamePascal === "FrameworkEditorPolicyTemplate") {
93+
relationFieldNameOnModelA = "policyTemplates";
94+
}
95+
else if (modelBNamePascal === "FrameworkEditorRequirement") {
96+
relationFieldNameOnModelA = "requirements";
97+
}
98+
else if (modelBNamePascal === "FrameworkEditorTaskTemplate") {
99+
relationFieldNameOnModelA = "taskTemplates";
100+
}
101+
const prismaAny = prisma;
102+
if (!prismaAny[prismaModelAName] || typeof prismaAny[prismaModelAName].update !== 'function') {
103+
console.warn(`Model ${prismaModelAName} not found on Prisma client or does not support update. Skipping ${jsonFile}.`);
104+
continue;
105+
}
106+
console.log(`Processing relations from ${jsonFile} for ${prismaModelAName} to connect via ${relationFieldNameOnModelA}...`);
107+
let connectionsMade = 0;
108+
for (const relationItem of jsonData) {
109+
if (!relationItem.A || !relationItem.B) {
110+
console.warn(`Skipping invalid relation item in ${jsonFile}:`, relationItem);
111+
continue;
112+
}
113+
const idA = relationItem.A;
114+
const idB = relationItem.B;
115+
try {
116+
await prismaAny[prismaModelAName].update({
117+
where: { id: idA },
118+
data: {
119+
[relationFieldNameOnModelA]: {
120+
connect: { id: idB },
121+
},
122+
},
123+
});
124+
connectionsMade++;
125+
}
126+
catch (error) {
127+
console.error(`Failed to connect ${prismaModelAName} (${idA}) with ${modelBNamePascal} (${idB}) from ${jsonFile}:`, error);
128+
// Decide if one error should stop the whole process for this file or continue
129+
}
130+
}
131+
console.log(`Finished processing ${jsonFile}. Made ${connectionsMade} connections.`);
132+
}
133+
}
134+
catch (error) {
135+
console.error(`Error processing ${jsonFile}:`, error);
136+
throw error;
137+
}
138+
}
139+
}
140+
async function main() {
141+
try {
142+
await seedJsonFiles("primitives");
143+
await seedJsonFiles("relations");
144+
await prisma.$disconnect();
145+
console.log("Seeding completed successfully for primitives and relations.");
146+
}
147+
catch (error) {
148+
console.error("Seeding failed:", error);
149+
await prisma.$disconnect();
150+
process.exit(1);
151+
}
152+
}
153+
main();

packages/ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"@radix-ui/react-checkbox": "^1.1.2",
100100
"@radix-ui/react-collapsible": "^1.1.1",
101101
"@radix-ui/react-context-menu": "^2.2.2",
102-
"@radix-ui/react-dialog": "^1.1.2",
102+
"@radix-ui/react-dialog": "^1.1.14",
103103
"@radix-ui/react-dropdown-menu": "^2.1.2",
104104
"@radix-ui/react-hover-card": "^1.1.2",
105105
"@radix-ui/react-icons": "^1.3.0",

0 commit comments

Comments
 (0)