mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
refactor(server): use feature model (#9932)
This commit is contained in:
@@ -478,6 +478,10 @@ export const USER_FRIENDLY_ERRORS = {
|
||||
type: 'internal_server_error',
|
||||
message: 'Failed to store doc snapshot.',
|
||||
},
|
||||
action_forbidden_on_non_team_workspace: {
|
||||
type: 'action_forbidden',
|
||||
message: 'A Team workspace is required to perform this action.',
|
||||
},
|
||||
|
||||
// Subscription Errors
|
||||
unsupported_subscription_plan: {
|
||||
|
||||
@@ -399,6 +399,12 @@ export class FailedToUpsertSnapshot extends UserFriendlyError {
|
||||
super('internal_server_error', 'failed_to_upsert_snapshot', message);
|
||||
}
|
||||
}
|
||||
|
||||
export class ActionForbiddenOnNonTeamWorkspace extends UserFriendlyError {
|
||||
constructor(message?: string) {
|
||||
super('action_forbidden', 'action_forbidden_on_non_team_workspace', message);
|
||||
}
|
||||
}
|
||||
@ObjectType()
|
||||
class UnsupportedSubscriptionPlanDataType {
|
||||
@Field() plan!: string
|
||||
@@ -754,6 +760,7 @@ export enum ErrorNames {
|
||||
PAGE_IS_NOT_PUBLIC,
|
||||
FAILED_TO_SAVE_UPDATES,
|
||||
FAILED_TO_UPSERT_SNAPSHOT,
|
||||
ACTION_FORBIDDEN_ON_NON_TEAM_WORKSPACE,
|
||||
UNSUPPORTED_SUBSCRIPTION_PLAN,
|
||||
FAILED_TO_CHECKOUT,
|
||||
INVALID_CHECKOUT_PARAMETERS,
|
||||
|
||||
@@ -35,10 +35,4 @@ export { Runtime } from './runtime';
|
||||
export * from './storage';
|
||||
export { type StorageProvider, StorageProviderFactory } from './storage';
|
||||
export { CloudThrottlerGuard, SkipThrottle, Throttle } from './throttler';
|
||||
export {
|
||||
getRequestFromHost,
|
||||
getRequestResponseFromContext,
|
||||
getRequestResponseFromHost,
|
||||
parseCookies,
|
||||
} from './utils/request';
|
||||
export * from './utils/types';
|
||||
export * from './utils';
|
||||
|
||||
@@ -126,14 +126,19 @@ export class Runtime implements OnModuleInit {
|
||||
V = FlattenedAppRuntimeConfig[K],
|
||||
>(key: K, value: V) {
|
||||
validateConfigType(key, value);
|
||||
const config = await this.db.runtimeConfig.update({
|
||||
const config = await this.db.runtimeConfig.upsert({
|
||||
where: {
|
||||
id: key,
|
||||
deletedAt: null,
|
||||
},
|
||||
data: {
|
||||
create: {
|
||||
...defaultRuntimeConfig[key],
|
||||
value: value as any,
|
||||
},
|
||||
update: {
|
||||
value: value as any,
|
||||
deletedAt: null,
|
||||
},
|
||||
});
|
||||
|
||||
await this.setCache(key, config.value as FlattenedAppRuntimeConfig[K]);
|
||||
|
||||
4
packages/backend/server/src/base/utils/index.ts
Normal file
4
packages/backend/server/src/base/utils/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from './promise';
|
||||
export * from './request';
|
||||
export * from './types';
|
||||
export * from './unit';
|
||||
4
packages/backend/server/src/base/utils/unit.ts
Normal file
4
packages/backend/server/src/base/utils/unit.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export const OneKB = 1024;
|
||||
export const OneMB = OneKB * OneKB;
|
||||
export const OneGB = OneKB * OneMB;
|
||||
export const OneDay = 1000 * 60 * 60 * 24;
|
||||
Reference in New Issue
Block a user