From 2b4a9b8a0025dec10d6f23485647fb896efc92bd Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Mon, 27 Apr 2026 01:18:32 +0100 Subject: [PATCH] refactor(base): rename baseId methods to pageId in repos and BasePropertyService --- .../base/services/base-property.service.ts | 26 +++++++++---------- .../database/repos/base/base-property.repo.ts | 2 +- .../src/database/repos/base/base-row.repo.ts | 2 +- .../src/database/repos/base/base-view.repo.ts | 4 +-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/server/src/core/base/services/base-property.service.ts b/apps/server/src/core/base/services/base-property.service.ts index 3a4342563..1d70e87b8 100644 --- a/apps/server/src/core/base/services/base-property.service.ts +++ b/apps/server/src/core/base/services/base-property.service.ts @@ -96,7 +96,7 @@ export class BasePropertyService { if (typeof sourceCandidate !== 'string') { throw new BadRequestException('formula.source is required'); } - const existing = await this.basePropertyRepo.findByBaseId(dto.baseId); + const existing = await this.basePropertyRepo.findByPageId(dto.baseId); const compiled = this.formulaService.compile(sourceCandidate, existing); const candidate = { id: 'pending', @@ -120,7 +120,7 @@ export class BasePropertyService { const created = await executeTx(this.db, async (trx) => { const row = await this.basePropertyRepo.insertProperty( { - baseId: dto.baseId, + pageId: dto.baseId, name: dto.name, type: dto.type, position, @@ -144,7 +144,7 @@ export class BasePropertyService { if (created.type === 'formula') { await this.formulaService.enqueueRecompute({ - baseId: created.baseId, + baseId: created.pageId, workspaceId, propertyIds: [created.id], reason: 'formula_created', @@ -190,7 +190,7 @@ export class BasePropertyService { throw new NotFoundException('Property not found'); } - if (property.baseId !== dto.baseId) { + if (property.pageId !== dto.baseId) { throw new BadRequestException('Property does not belong to this base'); } @@ -227,7 +227,7 @@ export class BasePropertyService { if (typeof sourceCandidate !== 'string') { throw new BadRequestException('formula.source is required'); } - const allProps = await this.basePropertyRepo.findByBaseId(dto.baseId); + const allProps = await this.basePropertyRepo.findByPageId(dto.baseId); const compiled = this.formulaService.compile(sourceCandidate, allProps); const candidate = { id: property.id, @@ -287,7 +287,7 @@ export class BasePropertyService { } if (isTypeChange && newType !== 'formula') { - const allProps = await this.basePropertyRepo.findByBaseId(dto.baseId); + const allProps = await this.basePropertyRepo.findByPageId(dto.baseId); const graph = new BaseFormulaGraph(allProps); const affected = graph.affectedFormulas([dto.propertyId]); if (affected.length > 0) { @@ -425,13 +425,13 @@ export class BasePropertyService { * never race ahead of visibility. */ private async ensureNameUnique( - baseId: string, + pageId: string, candidate: string, excludePropertyId?: string, ): Promise { const trimmed = candidate.trim(); if (!trimmed) return; - const existing = await this.basePropertyRepo.findByBaseId(baseId); + const existing = await this.basePropertyRepo.findByPageId(pageId); const lower = trimmed.toLowerCase(); const clash = existing.find( (p) => @@ -467,14 +467,14 @@ export class BasePropertyService { } private async countRowsToConvert( - baseId: string, + pageId: string, workspaceId: string, propertyId: string, ): Promise { const row = await this.db .selectFrom('baseRows') .select(sql`count(*)`.as('n')) - .where('baseId', '=', baseId) + .where('pageId', '=', pageId) .where('workspaceId', '=', workspaceId) .where('deletedAt', 'is', null) .where(sql`cells ? ${propertyId}`) @@ -492,7 +492,7 @@ export class BasePropertyService { throw new NotFoundException('Property not found'); } - if (property.baseId !== dto.baseId) { + if (property.pageId !== dto.baseId) { throw new BadRequestException('Property does not belong to this base'); } @@ -502,7 +502,7 @@ export class BasePropertyService { // Compute dependents BEFORE the delete — once soft-deleted the graph // wouldn't include them. - const allProps = await this.basePropertyRepo.findByBaseId(dto.baseId); + const allProps = await this.basePropertyRepo.findByPageId(dto.baseId); const graph = new BaseFormulaGraph(allProps); const affected = graph.affectedFormulas([dto.propertyId]); @@ -571,7 +571,7 @@ export class BasePropertyService { throw new NotFoundException('Property not found'); } - if (property.baseId !== dto.baseId) { + if (property.pageId !== dto.baseId) { throw new BadRequestException('Property does not belong to this base'); } diff --git a/apps/server/src/database/repos/base/base-property.repo.ts b/apps/server/src/database/repos/base/base-property.repo.ts index adc876652..3fb144fcd 100644 --- a/apps/server/src/database/repos/base/base-property.repo.ts +++ b/apps/server/src/database/repos/base/base-property.repo.ts @@ -26,7 +26,7 @@ export class BasePropertyRepo { return qb.executeTakeFirst() as Promise; } - async findByBaseId( + async findByPageId( pageId: string, opts?: { trx?: KyselyTransaction }, ): Promise { diff --git a/apps/server/src/database/repos/base/base-row.repo.ts b/apps/server/src/database/repos/base/base-row.repo.ts index 9c25ae05b..462be8afd 100644 --- a/apps/server/src/database/repos/base/base-row.repo.ts +++ b/apps/server/src/database/repos/base/base-row.repo.ts @@ -383,7 +383,7 @@ export class BaseRowRepo { * that top-level key. Type-conversion callers pass the property ID so * we don't drag 100k empty rows through Node just to rewrite a dozen. */ - async *streamByBaseId( + async *streamByPageId( pageId: string, opts: { workspaceId: string; diff --git a/apps/server/src/database/repos/base/base-view.repo.ts b/apps/server/src/database/repos/base/base-view.repo.ts index a09fc2d77..32b5e3389 100644 --- a/apps/server/src/database/repos/base/base-view.repo.ts +++ b/apps/server/src/database/repos/base/base-view.repo.ts @@ -29,7 +29,7 @@ export class BaseViewRepo { .executeTakeFirst() as Promise; } - async findByBaseId( + async findByPageId( pageId: string, opts: WorkspaceOpts, ): Promise { @@ -43,7 +43,7 @@ export class BaseViewRepo { .execute() as Promise; } - async countByBaseId( + async countByPageId( pageId: string, opts: WorkspaceOpts, ): Promise {