Merge pull request 'feat(editor): page templates — live whole-page embed (MVP)' (#17) from feat/page-templates into develop
Some checks failed
Develop / build (push) Has been cancelled

This commit was merged in pull request #17.
This commit is contained in:
claude_code
2026-06-20 20:34:44 +03:00
46 changed files with 2042 additions and 189 deletions

View File

@@ -0,0 +1,66 @@
import { Injectable } from '@nestjs/common';
import { InjectKysely } from 'nestjs-kysely';
import { KyselyDB, KyselyTransaction } from '@docmost/db/types/kysely.types';
import { dbOrTx } from '@docmost/db/utils';
import {
InsertablePageTemplateReference,
PageTemplateReference,
} from '@docmost/db/types/entity.types';
@Injectable()
export class PageTemplateReferencesRepo {
constructor(@InjectKysely() private readonly db: KyselyDB) {}
async findByReferencePageId(
referencePageId: string,
trx?: KyselyTransaction,
): Promise<PageTemplateReference[]> {
return dbOrTx(this.db, trx)
.selectFrom('pageTemplateReferences')
.selectAll()
.where('referencePageId', '=', referencePageId)
.execute();
}
async findReferencePageIdsBySource(
sourcePageId: string,
workspaceId: string,
trx?: KyselyTransaction,
): Promise<string[]> {
const rows = await dbOrTx(this.db, trx)
.selectFrom('pageTemplateReferences')
.select('referencePageId')
.distinct()
.where('workspaceId', '=', workspaceId)
.where('sourcePageId', '=', sourcePageId)
.execute();
return rows.map((r) => r.referencePageId);
}
async insertMany(
rows: InsertablePageTemplateReference[],
trx?: KyselyTransaction,
): Promise<void> {
if (rows.length === 0) return;
await dbOrTx(this.db, trx)
.insertInto('pageTemplateReferences')
.values(rows)
.onConflict((oc) =>
oc.columns(['referencePageId', 'sourcePageId']).doNothing(),
)
.execute();
}
async deleteByReferenceAndSources(
referencePageId: string,
sourcePageIds: string[],
trx?: KyselyTransaction,
): Promise<void> {
if (sourcePageIds.length === 0) return;
await dbOrTx(this.db, trx)
.deleteFrom('pageTemplateReferences')
.where('referencePageId', '=', referencePageId)
.where('sourcePageId', 'in', sourcePageIds)
.execute();
}
}

View File

@@ -40,6 +40,7 @@ export class PageRepo {
'spaceId',
'workspaceId',
'isLocked',
'isTemplate',
'createdAt',
'updatedAt',
'deletedAt',
@@ -112,6 +113,7 @@ export class PageRepo {
opts?: {
trx?: KyselyTransaction;
workspaceId?: string;
includeContent?: boolean;
},
): Promise<Page[]> {
if (pageIds.length === 0) return [];
@@ -120,6 +122,7 @@ export class PageRepo {
let query = db
.selectFrom('pages')
.select(this.baseFields)
.$if(opts?.includeContent, (qb) => qb.select('content'))
.where('id', 'in', pageIds);
if (opts?.workspaceId) {