refactor(base): rename baseId methods to pageId in repos and BasePropertyService

This commit is contained in:
Philipinho
2026-04-27 01:18:32 +01:00
parent a2917bad6d
commit 2b4a9b8a00
4 changed files with 17 additions and 17 deletions
@@ -96,7 +96,7 @@ export class BasePropertyService {
if (typeof sourceCandidate !== 'string') { if (typeof sourceCandidate !== 'string') {
throw new BadRequestException('formula.source is required'); 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 compiled = this.formulaService.compile(sourceCandidate, existing);
const candidate = { const candidate = {
id: 'pending', id: 'pending',
@@ -120,7 +120,7 @@ export class BasePropertyService {
const created = await executeTx(this.db, async (trx) => { const created = await executeTx(this.db, async (trx) => {
const row = await this.basePropertyRepo.insertProperty( const row = await this.basePropertyRepo.insertProperty(
{ {
baseId: dto.baseId, pageId: dto.baseId,
name: dto.name, name: dto.name,
type: dto.type, type: dto.type,
position, position,
@@ -144,7 +144,7 @@ export class BasePropertyService {
if (created.type === 'formula') { if (created.type === 'formula') {
await this.formulaService.enqueueRecompute({ await this.formulaService.enqueueRecompute({
baseId: created.baseId, baseId: created.pageId,
workspaceId, workspaceId,
propertyIds: [created.id], propertyIds: [created.id],
reason: 'formula_created', reason: 'formula_created',
@@ -190,7 +190,7 @@ export class BasePropertyService {
throw new NotFoundException('Property not found'); 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'); throw new BadRequestException('Property does not belong to this base');
} }
@@ -227,7 +227,7 @@ export class BasePropertyService {
if (typeof sourceCandidate !== 'string') { if (typeof sourceCandidate !== 'string') {
throw new BadRequestException('formula.source is required'); 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 compiled = this.formulaService.compile(sourceCandidate, allProps);
const candidate = { const candidate = {
id: property.id, id: property.id,
@@ -287,7 +287,7 @@ export class BasePropertyService {
} }
if (isTypeChange && newType !== 'formula') { 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 graph = new BaseFormulaGraph(allProps);
const affected = graph.affectedFormulas([dto.propertyId]); const affected = graph.affectedFormulas([dto.propertyId]);
if (affected.length > 0) { if (affected.length > 0) {
@@ -425,13 +425,13 @@ export class BasePropertyService {
* never race ahead of visibility. * never race ahead of visibility.
*/ */
private async ensureNameUnique( private async ensureNameUnique(
baseId: string, pageId: string,
candidate: string, candidate: string,
excludePropertyId?: string, excludePropertyId?: string,
): Promise<void> { ): Promise<void> {
const trimmed = candidate.trim(); const trimmed = candidate.trim();
if (!trimmed) return; if (!trimmed) return;
const existing = await this.basePropertyRepo.findByBaseId(baseId); const existing = await this.basePropertyRepo.findByPageId(pageId);
const lower = trimmed.toLowerCase(); const lower = trimmed.toLowerCase();
const clash = existing.find( const clash = existing.find(
(p) => (p) =>
@@ -467,14 +467,14 @@ export class BasePropertyService {
} }
private async countRowsToConvert( private async countRowsToConvert(
baseId: string, pageId: string,
workspaceId: string, workspaceId: string,
propertyId: string, propertyId: string,
): Promise<number> { ): Promise<number> {
const row = await this.db const row = await this.db
.selectFrom('baseRows') .selectFrom('baseRows')
.select(sql<string>`count(*)`.as('n')) .select(sql<string>`count(*)`.as('n'))
.where('baseId', '=', baseId) .where('pageId', '=', pageId)
.where('workspaceId', '=', workspaceId) .where('workspaceId', '=', workspaceId)
.where('deletedAt', 'is', null) .where('deletedAt', 'is', null)
.where(sql<SqlBool>`cells ? ${propertyId}`) .where(sql<SqlBool>`cells ? ${propertyId}`)
@@ -492,7 +492,7 @@ export class BasePropertyService {
throw new NotFoundException('Property not found'); 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'); 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 // Compute dependents BEFORE the delete — once soft-deleted the graph
// wouldn't include them. // 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 graph = new BaseFormulaGraph(allProps);
const affected = graph.affectedFormulas([dto.propertyId]); const affected = graph.affectedFormulas([dto.propertyId]);
@@ -571,7 +571,7 @@ export class BasePropertyService {
throw new NotFoundException('Property not found'); 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'); throw new BadRequestException('Property does not belong to this base');
} }
@@ -26,7 +26,7 @@ export class BasePropertyRepo {
return qb.executeTakeFirst() as Promise<BaseProperty | undefined>; return qb.executeTakeFirst() as Promise<BaseProperty | undefined>;
} }
async findByBaseId( async findByPageId(
pageId: string, pageId: string,
opts?: { trx?: KyselyTransaction }, opts?: { trx?: KyselyTransaction },
): Promise<BaseProperty[]> { ): Promise<BaseProperty[]> {
@@ -383,7 +383,7 @@ export class BaseRowRepo {
* that top-level key. Type-conversion callers pass the property ID so * 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. * we don't drag 100k empty rows through Node just to rewrite a dozen.
*/ */
async *streamByBaseId( async *streamByPageId(
pageId: string, pageId: string,
opts: { opts: {
workspaceId: string; workspaceId: string;
@@ -29,7 +29,7 @@ export class BaseViewRepo {
.executeTakeFirst() as Promise<BaseView | undefined>; .executeTakeFirst() as Promise<BaseView | undefined>;
} }
async findByBaseId( async findByPageId(
pageId: string, pageId: string,
opts: WorkspaceOpts, opts: WorkspaceOpts,
): Promise<BaseView[]> { ): Promise<BaseView[]> {
@@ -43,7 +43,7 @@ export class BaseViewRepo {
.execute() as Promise<BaseView[]>; .execute() as Promise<BaseView[]>;
} }
async countByBaseId( async countByPageId(
pageId: string, pageId: string,
opts: WorkspaceOpts, opts: WorkspaceOpts,
): Promise<number> { ): Promise<number> {