feat: optional payment for server (#5055)

This commit is contained in:
DarkSky 2023-11-25 22:59:47 +08:00 committed by GitHub
parent 9dc2d55a5a
commit 13e712158c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 92 additions and 5 deletions

View File

@ -0,0 +1,30 @@
import { Module } from '@nestjs/common';
import { Field, ObjectType, Query } from '@nestjs/graphql';
import { SERVER_FLAVOR } from '../modules';
@ObjectType()
export class ServerConfigType {
@Field({ description: 'server version' })
version!: string;
@Field({ description: 'server flavor' })
flavor!: string;
}
export class ServerConfigResolver {
@Query(() => ServerConfigType, {
description: 'server config',
})
serverConfig(): ServerConfigType {
return {
version: AFFiNE.version,
flavor: SERVER_FLAVOR || 'allinone',
};
}
}
@Module({
providers: [ServerConfigResolver],
})
export class ServerConfigModule {}

View File

@ -3,7 +3,7 @@ import { EventEmitterModule } from '@nestjs/event-emitter';
import { ScheduleModule } from '@nestjs/schedule';
import { GqlModule } from '../graphql.module';
import { AuthModule } from './auth';
import { ServerConfigModule } from './config';
import { DocModule } from './doc';
import { PaymentModule } from './payment';
import { SyncModule } from './sync';
@ -22,13 +22,23 @@ switch (SERVER_FLAVOR) {
case 'sync':
BusinessModules.push(SyncModule, DocModule.forSync());
break;
case 'graphql':
case 'selfhosted':
BusinessModules.push(
ServerConfigModule,
ScheduleModule.forRoot(),
GqlModule,
WorkspaceModule,
UsersModule,
DocModule.forRoot()
);
break;
case 'graphql':
BusinessModules.push(
ServerConfigModule,
ScheduleModule.forRoot(),
GqlModule,
WorkspaceModule,
UsersModule,
AuthModule,
DocModule.forRoot(),
PaymentModule
);
@ -36,11 +46,11 @@ switch (SERVER_FLAVOR) {
case 'allinone':
default:
BusinessModules.push(
ServerConfigModule,
ScheduleModule.forRoot(),
GqlModule,
WorkspaceModule,
UsersModule,
AuthModule,
SyncModule,
DocModule.forRoot(),
PaymentModule
@ -48,4 +58,4 @@ switch (SERVER_FLAVOR) {
break;
}
export { BusinessModules };
export { BusinessModules, SERVER_FLAVOR };

View File

@ -2,6 +2,14 @@
# THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY)
# ------------------------------------------------------
type ServerConfigType {
"""server version"""
version: String!
"""server flavor"""
flavor: String!
}
type UserType {
id: ID!
@ -240,6 +248,9 @@ type DocHistoryType {
}
type Query {
"""server config"""
serverConfig: ServerConfigType!
"""Get is owner of workspace"""
isOwner(workspaceId: String!): Boolean!

View File

@ -545,6 +545,20 @@ mutation sendVerifyChangeEmail($token: String!, $email: String!, $callbackUrl: S
}`,
};
export const serverConfigQuery = {
id: 'serverConfigQuery' as const,
operationName: 'serverConfig',
definitionName: 'serverConfig',
containsFile: false,
query: `
query serverConfig {
serverConfig {
version
flavor
}
}`,
};
export const setWorkspacePublicByIdMutation = {
id: 'setWorkspacePublicByIdMutation' as const,
operationName: 'setWorkspacePublicById',

View File

@ -0,0 +1,6 @@
query serverConfig {
serverConfig {
version
flavor
}
}

View File

@ -533,6 +533,17 @@ export type SendVerifyChangeEmailMutation = {
sendVerifyChangeEmail: boolean;
};
export type ServerConfigQueryVariables = Exact<{ [key: string]: never }>;
export type ServerConfigQuery = {
__typename?: 'Query';
serverConfig: {
__typename?: 'ServerConfigType';
version: string;
flavor: string;
};
};
export type SetWorkspacePublicByIdMutationVariables = Exact<{
id: Scalars['ID']['input'];
public: Scalars['Boolean']['input'];
@ -732,6 +743,11 @@ export type Queries =
variables: PricesQueryVariables;
response: PricesQuery;
}
| {
name: 'serverConfigQuery';
variables: ServerConfigQueryVariables;
response: ServerConfigQuery;
}
| {
name: 'subscriptionQuery';
variables: SubscriptionQueryVariables;