-
Notifications
You must be signed in to change notification settings - Fork 256
Expand file tree
/
Copy pathinject-chat-data.ts
More file actions
86 lines (76 loc) · 2.7 KB
/
inject-chat-data.ts
File metadata and controls
86 lines (76 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { Script } from "../scriptRunner";
import { PrismaClient } from "../../dist";
import { confirmAction } from "../utils";
const chatNames = [
"How does the auth middleware work?",
"Explain the search indexing pipeline",
"Where are API routes defined?",
"How to add a new database migration",
"What is the repo sync process?",
"Understanding the chat architecture",
"How does SSO integration work?",
"Explain the permission model",
"Where is the webhook handler?",
"How to configure environment variables",
"Understanding the billing system",
"How does the worker process jobs?",
"Explain the caching strategy",
"Where are the shared types defined?",
"How does code search ranking work?",
"Understanding the notification system",
"How to add a new API endpoint",
"Explain the deployment pipeline",
"Where is error handling centralized?",
"How does real-time updates work?",
"Understanding the plugin system",
"How to write integration tests",
"Explain the file indexing process",
"Where are the email templates?",
"How does rate limiting work?",
"Understanding the monorepo structure",
"How to add a new feature flag",
"Explain the logging setup",
"Where is the GraphQL schema?",
"How does the sidebar component work?",
];
export const injectChatData: Script = {
run: async (prisma: PrismaClient) => {
const orgId = 1;
const org = await prisma.org.findUnique({
where: { id: orgId }
});
if (!org) {
console.error(`Organization with id ${orgId} not found.`);
return;
}
const userIdArg = process.argv.find(arg => arg.startsWith("--user-id="))?.split("=")[1];
const user = userIdArg
? await prisma.user.findUnique({ where: { id: userIdArg } })
: await prisma.user.findFirst({
where: {
orgs: {
some: { orgId }
}
}
});
if (!user) {
console.error(userIdArg
? `User with id "${userIdArg}" not found.`
: `No user found in org ${orgId}.`
);
return;
}
await confirmAction(`This will create ${chatNames.length} chats for user "${user.name ?? user.email}" in org ${orgId}.`);
for (const name of chatNames) {
await prisma.chat.create({
data: {
name,
orgId,
createdById: user.id,
messages: [],
}
});
}
console.log(`Created ${chatNames.length} chats.`);
}
};