mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 01:56:27 +08:00
refactor(server): role actions definition (#9962)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { Type } from '@nestjs/common';
|
||||
import { Field, ObjectType } from '@nestjs/graphql';
|
||||
|
||||
import { ApplyType } from '../utils/types';
|
||||
|
||||
export function registerObjectType<T>(
|
||||
fields: Record<string, Type<any>>,
|
||||
options: {
|
||||
name: string;
|
||||
}
|
||||
) {
|
||||
const Inner = ApplyType<T>();
|
||||
for (const [key, value] of Object.entries(fields)) {
|
||||
Field(() => value)(Inner.prototype, key);
|
||||
}
|
||||
|
||||
ObjectType(options.name)(Inner);
|
||||
|
||||
return Inner;
|
||||
}
|
||||
@@ -16,6 +16,7 @@ export {
|
||||
export * from './error';
|
||||
export { EventBus, OnEvent } from './event';
|
||||
export type { GraphqlContext } from './graphql';
|
||||
export { registerObjectType } from './graphql/register';
|
||||
export * from './guard';
|
||||
export { CryptoHelper, URLHelper } from './helpers';
|
||||
export { AFFiNELogger } from './logger';
|
||||
|
||||
@@ -45,6 +45,14 @@ export type LeafPaths<
|
||||
}[keyof T]
|
||||
: never;
|
||||
|
||||
export type LeafVisitor<T, P extends string = ''> = {
|
||||
[K in keyof T]: T[K] extends object
|
||||
? LeafVisitor<T[K], Join<P, K>>
|
||||
: P extends ''
|
||||
? K
|
||||
: Join<P, K>;
|
||||
};
|
||||
|
||||
export interface FileUpload {
|
||||
filename: string;
|
||||
mimetype: string;
|
||||
|
||||
Reference in New Issue
Block a user