mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-14 16:46:22 +08:00
c53457691d
#### PR Dependency Tree * **PR #14996** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Admin mutations to grant/revoke commercial entitlements. * New Doc comment-update permission. * Realtime user/workspace quota-state endpoints and live-update rooms. * **Bug Fixes** * More accurate readable-doc filtering and permission evaluation. * **Refactor** * Workspace feature management moved to entitlement-based model; permission and quota pipelines redesigned. * Admin workspace UI now edits flags only (feature toggles removed). * **Tests** * Extensive new and updated tests for permissions, entitlements, quota, projection, and backfills. <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/toeverything/AFFiNE/pull/14996?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import { Inject, Logger } from '@nestjs/common';
|
|
import { TransactionHost } from '@nestjs-cls/transactional';
|
|
import type { TransactionalAdapterPrisma } from '@nestjs-cls/transactional-adapter-prisma';
|
|
|
|
import type { Models } from '.';
|
|
import { MODELS_SYMBOL } from './provider';
|
|
|
|
export class BaseModel {
|
|
protected readonly logger = new Logger(this.constructor.name);
|
|
|
|
@Inject(MODELS_SYMBOL)
|
|
protected readonly models!: Models;
|
|
|
|
@Inject(TransactionHost)
|
|
private readonly txHost!: TransactionHost<TransactionalAdapterPrisma>;
|
|
|
|
protected get db() {
|
|
// When a transaction is not active, the Transaction instance refers to the default non-transactional instance.
|
|
// See https://papooch.github.io/nestjs-cls/plugins/available-plugins/transactional#using-the-injecttransaction-decorator
|
|
return this.txHost.tx;
|
|
}
|
|
|
|
protected async withPermissionProjectionMetric<T>(operation: Promise<T>) {
|
|
try {
|
|
return await operation;
|
|
} catch (err) {
|
|
this.models.permissionProjection.recordTriggerErrorMetric(err);
|
|
throw err;
|
|
}
|
|
}
|
|
}
|