Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-osch committed Jan 17, 2025
1 parent 68c837c commit dae7404
Show file tree
Hide file tree
Showing 47 changed files with 2,661 additions and 2,677 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20
56 changes: 28 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 31 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,51 @@
"start": "npx tsc && node dist/index.js",
"bot:start": "nodemon --watch \"src/**\" --ext \"ts,json\" --ignore \"src/**/*.spec.ts\" --exec \"ts-node ./src/slackbot/index.ts\"",
"dev": "nodemon src/index.ts",
"lint": "next lint",
"lint": "oxlint",
"test": "jest",
"db:migrate": "prisma migrate dev",
"db:studio": "prisma studio",
"db:deploy": "prisma migrate deploy",
"db:generate": "prisma generate",
"postinstall": "prisma generate",
"vercel-build": "prisma generate && prisma migrate deploy && next build",
"smee": "npx smee-client"
"smee": "npx smee-client",
"lint:fix": "oxlint --fix"
},
"author": "",
"license": "ISC",
"dependencies": {
"@ai-sdk/openai": "^0.0.72",
"@prisma/client": "^5.22.0",
"@slack/bolt": "^4.1.0",
"ai": "^3.4.33",
"axios": "^1.7.9",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"dotenv": "^16.4.5",
"express": "^4.21.1",
"llamaindex": "^0.8.5",
"moment": "^2.30.1",
"next": "^15.0.3",
"node-ts": "^6.1.3",
"octokit": "^3.2.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"reflect-metadata": "^0.2.2",
"typescript": "^5.6.3",
"yaml": "^2.6.0",
"zod": "^3.23.8"
"@ai-sdk/openai": "0.0.72",
"@prisma/client": "5.22.0",
"@slack/bolt": "4.1.0",
"ai": "3.4.33",
"axios": "1.7.9",
"class-transformer": "0.5.1",
"class-validator": "0.14.1",
"dotenv": "16.4.5",
"express": "4.21.1",
"llamaindex": "0.8.5",
"moment": "2.30.1",
"next": "15.0.3",
"node-ts": "6.1.3",
"octokit": "3.2.1",
"react": "18.3.1",
"react-dom": "18.3.1",
"reflect-metadata": "0.2.2",
"typescript": "5.6.3",
"yaml": "2.6.0",
"zod": "3.23.8"
},
"devDependencies": {
"@types/express": "^5.0.0",
"@types/jest": "^29.5.14",
"@types/express": "5.0.0",
"@types/jest": "29.5.14",
"@types/react": "18.3.12",
"concurrently": "^9.1.0",
"jest": "^29.7.0",
"nodemon": "^3.1.7",
"prisma": "^5.22.0",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2"
"concurrently": "9.1.0",
"jest": "29.7.0",
"nodemon": "3.1.7",
"prisma": "5.22.0",
"ts-jest": "29.2.5",
"ts-node": "10.9.2"
},
"name": "srebot",
"version": "1.0.0",
Expand Down
50 changes: 25 additions & 25 deletions scripts/init-assistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@ import { getOpenaiClient } from "../src/ai/openai";
const openai = getOpenaiClient();

function createAssistant(name: string) {
return openai.beta.assistants.create({
model: "gpt-4o",
name,
});
return openai.beta.assistants.create({
model: "gpt-4o",
name,
});
}

async function main() {
const assistants = await openai.beta.assistants.list();
const assistants = await openai.beta.assistants.list();

if (!assistants.data.length) {
console.log("Creating sre-assistant");
await createAssistant("sre-assistant");
} else {
const sreAssistant = assistants.data.find(
(assistant) => assistant.name === "sre-assistant"
);
if (!sreAssistant) {
console.log("Creating sre-assistant");
await createAssistant("sre-assistant");
} else {
console.log("sre-assistant already exists: ", sreAssistant.id);
}
}
if (!assistants.data.length) {
console.log("Creating sre-assistant");
await createAssistant("sre-assistant");
} else {
const sreAssistant = assistants.data.find(
(assistant) => assistant.name === "sre-assistant"
);
if (!sreAssistant) {
console.log("Creating sre-assistant");
await createAssistant("sre-assistant");
} else {
console.log("sre-assistant already exists: ", sreAssistant.id);
}
}
}

main()
.then(() => {
console.log("Done");
})
.catch((error) => {
console.error(error);
});
.then(() => {
console.log("Done");
})
.catch((error) => {
console.error(error);
});
64 changes: 32 additions & 32 deletions src/aggregator/ContextAggregator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,44 @@ import type { $Enums } from "@prisma/client";
import { slackChannelAggregator } from "./slack-channel-aggregator";

export enum ContextKey {
ChecklyScript = "checkly.script",
ChecklyAlert = "checkly.alert",
ChecklyCheck = "checkly.check",
ChecklyResults = "checkly.results",
ChecklyPrometheusStatus = "checkly.prometheusStatus",
ChecklyLogs = "checkly.logs",
GitHubRepoChanges = "github.repoChanges.$repo",
GitHubReleaseSummary = "github.releaseSummary.$repo",
SlackChannelSummary = "slack.channelSummary.$channel",
ChecklyScript = "checkly.script",
ChecklyAlert = "checkly.alert",
ChecklyCheck = "checkly.check",
ChecklyResults = "checkly.results",
ChecklyPrometheusStatus = "checkly.prometheusStatus",
ChecklyLogs = "checkly.logs",
GitHubRepoChanges = "github.repoChanges.$repo",
GitHubReleaseSummary = "github.releaseSummary.$repo",
SlackChannelSummary = "slack.channelSummary.$channel",
}

export interface CheckContext {
checkId: string;
source: $Enums.Source;
key: ContextKey;
value: unknown;
analysis: string;
checkId: string;
source: $Enums.Source;
key: ContextKey;
value: unknown;
analysis: string;
}

export class CheckContextAggregator {
alert: WebhookAlertDto;
plugins = [checklyAggregator, githubAggregator, slackChannelAggregator];
alert: WebhookAlertDto;
plugins = [checklyAggregator, githubAggregator, slackChannelAggregator];

constructor(alert: WebhookAlertDto) {
this.alert = alert;
}
constructor(alert: WebhookAlertDto) {
this.alert = alert;
}

aggregate() {
return Promise.all(
this.plugins.map(async (plugin) => {
return plugin.fetchContext(this.alert).catch((error) => {
console.error(
`Error fetching context from ${plugin.name ?? "unknown plugin"}:`,
error
);
return [];
});
})
).then((results) => results.flat());
}
aggregate() {
return Promise.all(
this.plugins.map(async (plugin) => {
return plugin.fetchContext(this.alert).catch((error) => {
console.error(
`Error fetching context from ${plugin.name ?? "unknown plugin"}:`,
error
);
return [];
});
})
).then((results) => results.flat());
}
}
Loading

0 comments on commit dae7404

Please sign in to comment.