refactor(server): use feature model (#9932)

This commit is contained in:
forehalo
2025-02-05 10:27:26 +00:00
parent 0ff8d3af6f
commit 7826e2b7c8
121 changed files with 1723 additions and 3826 deletions

View File

@@ -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: {

View File

@@ -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,

View File

@@ -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';

View File

@@ -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]);

View File

@@ -0,0 +1,4 @@
export * from './promise';
export * from './request';
export * from './types';
export * from './unit';

View 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;