Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@nestjs/swagger": "^11.4.4",
"@nestjs/terminus": "^11.1.1",
"@nestjs/throttler": "^6.5.0",
"@nestjs/typeorm": "^11.0.0",
"@nestjs/typeorm": "^11.0.1",
"@nestjs/websockets": "^11.1.24",
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/auto-instrumentations-node": "^0.76.0",
Expand Down Expand Up @@ -107,7 +107,7 @@
"rxjs": "^7.8.1",
"semver": "^7.8.1",
"socket.io": "^4.8.3",
"typeorm": "^0.3.29",
"typeorm": "^1.0.0",
"winston": "^3.19.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe("MigrationLockService", () => {

it("is a no-op when the database type is not postgres", async () => {
const ds = buildMockDataSource({});
const svc = await build("sqlite", ds);
const svc = await build("better-sqlite3", ds);
await svc.onModuleInit();
expect(ds.query).not.toHaveBeenCalled();
expect(ds.showMigrations).not.toHaveBeenCalled();
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/config/configuration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe("configuration", () => {
process.env.NODE_ENV = "production";
process.env.PORT = "8080";
process.env.LOG_LEVEL = "warn";
process.env.DATABASE_TYPE = "sqlite";
process.env.DATABASE_TYPE = "better-sqlite3";
Comment thread
weyderfs marked this conversation as resolved.
process.env.DATABASE_HOST = "db.example.com";
process.env.DATABASE_PORT = "5433";
process.env.DATABASE_USER = "myuser";
Expand Down Expand Up @@ -144,7 +144,7 @@ describe("configuration", () => {
expect(config.env).toBe("production");
expect(config.port).toBe(8080);
expect(config.log.level).toBe("warn");
expect(config.database.type).toBe("sqlite");
expect(config.database.type).toBe("better-sqlite3");
expect(config.database.host).toBe("db.example.com");
expect(config.database.port).toBe(5433);
expect(config.database.username).toBe("myuser");
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/database/seeds/initial-seed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ describe("seedServiceTemplates", () => {
expect.objectContaining({
key: "databaseType",
type: "enum",
options: ["postgresql", "sqlite", "mysql"],
options: ["postgresql", "better-sqlite3", "mysql"],
}),
]),
);
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/database/seeds/initial-seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export async function seedUsers(
for (const teamSlug of persona.teamSlugs) {
const team = await teamRepo.findOne({
where: { name: teamSlug },
relations: ["members"],
relations: { members: true },
});
if (!team) continue;
const members = Array.isArray(team.members) ? team.members : [];
Expand Down Expand Up @@ -867,7 +867,7 @@ export async function seedServiceTemplates(
description: "Database backend to use",
required: false,
type: "enum" as const,
options: ["postgresql", "sqlite", "mysql"],
options: ["postgresql", "better-sqlite3", "mysql"],
default: "postgresql",
},
],
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/migrations/1774700000002-AddKedaBindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class AddKedaBindings1774700000002 implements MigrationInterface {
await queryRunner.query(
`CREATE INDEX "IDX_keda_bindings_organizationId" ON "keda_bindings" ("organizationId")`,
);
} else if (databaseType === "sqlite" || databaseType === "better-sqlite3") {
} else if (databaseType === "better-sqlite3") {
await queryRunner.query(`
CREATE TABLE "keda_bindings" (
"id" varchar PRIMARY KEY NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ describe("ApiSpecsService", () => {

expect(mockApiConsumerRepo.find).toHaveBeenCalledWith({
where: { consumerComponentId: "comp-uuid-2" },
relations: ["apiSpec"],
relations: { apiSpec: true },
});
expect(result).toEqual([mockApiSpec]);
});
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/modules/api-specs/api-specs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export class ApiSpecsService {
async findConsumedApis(componentId: string): Promise<ApiSpec[]> {
const consumers = await this.apiConsumerRepo.find({
where: { consumerComponentId: componentId },
relations: ["apiSpec"],
relations: { apiSpec: true },
});

const seen = new Set<string>();
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/modules/auth/keycloak-sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export class KeycloakSyncService {
// Find or create the Farm Team for this group.
let team = await this.teamRepository.findOne({
where: { organizationId: orgId, externalId: group.id },
relations: ["members"],
relations: { members: true },
});

if (!team) {
Expand Down Expand Up @@ -277,7 +277,7 @@ export class KeycloakSyncService {
async scheduleAllOrgs(): Promise<void> {
const credentials = await this.credentialRepository.find({
where: { type: IntegrationType.KEYCLOAK },
select: ["orgId"],
select: { orgId: true },
});

// Deduplicate orgIds (an org may theoretically have multiple credentials).
Expand Down
10 changes: 5 additions & 5 deletions apps/api/src/modules/catalog/catalog.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ spec:
expect(total).toBe(1);
expect(mockRepository.findAndCount).toHaveBeenCalledWith({
where: {},
relations: ["dependencies"],
relations: { dependencies: true },
skip: 0,
take: 20,
});
Expand Down Expand Up @@ -275,7 +275,7 @@ spec:
expect(data).toEqual([mockComponent]);
expect(total).toBe(1);
expect(mockRepository.findAndCount).toHaveBeenCalledWith(
expect.objectContaining({ relations: ["dependencies"] }),
expect.objectContaining({ relations: { dependencies: true } }),
);
});

Expand Down Expand Up @@ -318,7 +318,7 @@ spec:
await service.findAll(0, 20, undefined, "org-uuid-1");
expect(mockRepository.findAndCount).toHaveBeenCalledWith({
where: { organizationId: "org-uuid-1" },
relations: ["dependencies"],
relations: { dependencies: true },
skip: 0,
take: 20,
});
Expand All @@ -329,7 +329,7 @@ spec:
await service.findAll(0, 20, undefined, undefined, "team-uuid-1");
expect(mockRepository.findAndCount).toHaveBeenCalledWith({
where: { teamId: "team-uuid-1" },
relations: ["dependencies"],
relations: { dependencies: true },
skip: 0,
take: 20,
});
Expand All @@ -340,7 +340,7 @@ spec:
await service.findAll(0, 20, undefined, "org-uuid-1", "team-uuid-1");
expect(mockRepository.findAndCount).toHaveBeenCalledWith({
where: { organizationId: "org-uuid-1", teamId: "team-uuid-1" },
relations: ["dependencies"],
relations: { dependencies: true },
skip: 0,
take: 20,
});
Expand Down
8 changes: 4 additions & 4 deletions apps/api/src/modules/catalog/catalog.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ export class CatalogService {
...(organizationId ? { organizationId } : {}),
...(teamId ? { teamId } : {}),
})),
relations: ["dependencies"],
relations: { dependencies: true },
skip,
take,
});
Expand All @@ -361,7 +361,7 @@ export class CatalogService {
...(organizationId ? { organizationId } : {}),
...(teamId ? { teamId } : {}),
},
relations: ["dependencies"],
relations: { dependencies: true },
skip,
take,
});
Expand All @@ -379,7 +379,7 @@ export class CatalogService {
if (organizationId) where.organizationId = organizationId;
const component = await this.componentRepository.findOne({
where,
relations: ["dependencies"],
relations: { dependencies: true },
});
if (!component) {
throw new NotFoundException(`Component with ID "${id}" not found`);
Expand Down Expand Up @@ -509,7 +509,7 @@ export class CatalogService {

return (await this.componentRepository.findOne({
where: { id },
relations: ["dependencies"],
relations: { dependencies: true },
})) as Component;
}

Expand Down
15 changes: 7 additions & 8 deletions apps/api/src/modules/dashboard/dashboard.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Test, TestingModule } from "@nestjs/testing";
import { getRepositoryToken } from "@nestjs/typeorm";
import { getRepositoryToken, getDataSourceToken } from "@nestjs/typeorm";
import { NotFoundException, BadRequestException } from "@nestjs/common";
import { DataSource } from "typeorm";
import { DashboardService } from "./dashboard.service";
import { Dashboard, DashboardVisibility } from "./entities/dashboard.entity";
import { DashboardWidget } from "./entities/dashboard-widget.entity";
Expand Down Expand Up @@ -59,7 +58,7 @@ describe("DashboardService", () => {
useValue: mockWidgetRepository,
},
{
provide: DataSource,
provide: getDataSourceToken(),
useValue: mockDataSource,
},
],
Expand Down Expand Up @@ -126,7 +125,7 @@ describe("DashboardService", () => {
expect(result).toEqual([dashboards, 1]);
expect(mockDashboardRepository.findAndCount).toHaveBeenCalledWith({
where: {},
relations: ["widgets"],
relations: { widgets: true },
order: { createdAt: "DESC" },
skip: 0,
take: 20,
Expand All @@ -146,7 +145,7 @@ describe("DashboardService", () => {
expect(result).toEqual([dashboards, 1]);
expect(mockDashboardRepository.findAndCount).toHaveBeenCalledWith({
where: { ownerId: "owner-uuid-1" },
relations: ["widgets"],
relations: { widgets: true },
order: { createdAt: "DESC" },
skip: 0,
take: 20,
Expand All @@ -166,7 +165,7 @@ describe("DashboardService", () => {
expect(result).toEqual([dashboards, 1]);
expect(mockDashboardRepository.findAndCount).toHaveBeenCalledWith({
where: { visibility: DashboardVisibility.WORKSPACE },
relations: ["widgets"],
relations: { widgets: true },
order: { createdAt: "DESC" },
skip: 0,
take: 20,
Expand All @@ -187,7 +186,7 @@ describe("DashboardService", () => {
expect(result.widgets).toEqual([]);
expect(mockDashboardRepository.findOne).toHaveBeenCalledWith({
where: { id: "dash-uuid-1" },
relations: ["widgets"],
relations: { widgets: true },
});
});

Expand Down Expand Up @@ -323,7 +322,7 @@ describe("DashboardService", () => {

expect(mockDashboardRepository.findOne).toHaveBeenCalledWith({
where: { id: "dash-uuid-1" },
relations: ["widgets"],
relations: { widgets: true },
});
expect(mockDashboardRepository.remove).toHaveBeenCalledWith(
existingDashboard,
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/modules/dashboard/dashboard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class DashboardService {

return await this.dashboardRepository.findAndCount({
where,
relations: ["widgets"],
relations: { widgets: true },
order: { createdAt: "DESC" },
skip,
take,
Expand All @@ -89,7 +89,7 @@ export class DashboardService {
if (orgId) where.organizationId = orgId;
const dashboard = await this.dashboardRepository.findOne({
where,
relations: ["widgets"],
relations: { widgets: true },
});
if (!dashboard) {
throw new NotFoundException(`Dashboard with ID "${id}" not found`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe("ComponentElasticsearchIndexService.findAllGroupedByComponent", () => {
expect(result).toEqual([]);
expect(repo.find).toHaveBeenCalledWith({
where: undefined,
relations: ["component"],
relations: { component: true },
order: { indexPattern: "ASC" },
});
});
Expand Down Expand Up @@ -111,7 +111,7 @@ describe("ComponentElasticsearchIndexService.findAllGroupedByComponent", () => {
await service.findAllGroupedByComponent("org-42");
expect(repo.find).toHaveBeenCalledWith({
where: { organizationId: "org-42" },
relations: ["component"],
relations: { component: true },
order: { indexPattern: "ASC" },
});
});
Expand All @@ -121,7 +121,7 @@ describe("ComponentElasticsearchIndexService.findAllGroupedByComponent", () => {
await service.findAllGroupedByComponent(null);
expect(repo.find).toHaveBeenCalledWith({
where: undefined,
relations: ["component"],
relations: { component: true },
order: { indexPattern: "ASC" },
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class ComponentElasticsearchIndexService {

const records = await this.repository.find({
where,
relations: ["component"],
relations: { component: true },
order: { indexPattern: "ASC" },
});

Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/modules/environments/deployments.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class DeploymentsService {

return await this.deploymentRepository.findAndCount({
where,
relations: ["component", "environment"],
relations: { component: true, environment: true },
order: { createdAt: "DESC" },
skip,
take,
Expand All @@ -137,7 +137,7 @@ export class DeploymentsService {
async findOne(id: string): Promise<Deployment> {
const deployment = await this.deploymentRepository.findOne({
where: { id },
relations: ["component", "environment"],
relations: { component: true, environment: true },
});
if (!deployment) {
throw new NotFoundException(`Deployment with ID "${id}" not found`);
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/modules/finops/cost.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class CostController {
// Resolve component IDs via the teamId FK on Component.
const components = await this.componentRepo.find({
where: { teamId: id },
select: ["id"],
select: { id: true },
});
const componentIds = components.map((c) => c.id);

Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/modules/iac/iac-module-sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class IacModuleSyncService {

const existingVersions = await this.versionRepository.find({
where: { moduleId: module.id },
select: ["version"],
select: { version: true },
});
const existingSet = new Set(existingVersions.map((v) => v.version));

Expand Down
6 changes: 5 additions & 1 deletion apps/api/src/modules/incident/incident.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,11 @@ describe("IncidentService", () => {
expect(result).toEqual(mockIncident);
expect(mockIncidentRepo.findOne).toHaveBeenCalledWith({
where: { id: "incident-uuid-1" },
relations: ["affectedComponents", "affectedEnvironments", "updates"],
relations: {
affectedComponents: true,
affectedEnvironments: true,
updates: true,
},
});
});

Expand Down
6 changes: 5 additions & 1 deletion apps/api/src/modules/incident/incident.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ export class IncidentService {
if (orgId) where.organizationId = orgId;
const incident = await this.incidentRepository.findOne({
where,
relations: ["affectedComponents", "affectedEnvironments", "updates"],
relations: {
affectedComponents: true,
affectedEnvironments: true,
updates: true,
},
});
if (!incident) {
throw new NotFoundException(`Incident with ID "${id}" not found`);
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/modules/incident/post-mortem.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe("PostMortemService", () => {
expect(result).toEqual(mockPostMortem);
expect(mockPostMortemRepo.findOne).toHaveBeenCalledWith({
where: { id: "pm-uuid-1" },
relations: ["incident"],
relations: { incident: true },
});
});

Expand All @@ -159,7 +159,7 @@ describe("PostMortemService", () => {
expect(result).toEqual(mockPostMortem);
expect(mockPostMortemRepo.findOne).toHaveBeenCalledWith({
where: { incidentId: "incident-uuid-1" },
relations: ["incident"],
relations: { incident: true },
});
});

Expand Down
Loading
Loading