Fixes #9827 Also uncovered a conflict with `@objectType('Relation')` and `@objectType('relation)` I don't want to address it in this PR so I will create a followup issue when we close this but I think there's a confusion between Relation/RelationMetadata, it's unclear what is what --------- Co-authored-by: Antoine Moreaux <moreaux.antoine@gmail.com>
89 lines
1.9 KiB
TypeScript
89 lines
1.9 KiB
TypeScript
import { Field, HideField, ObjectType } from '@nestjs/graphql';
|
|
|
|
import {
|
|
Authorize,
|
|
BeforeDeleteOne,
|
|
CursorConnection,
|
|
FilterableField,
|
|
IDField,
|
|
QueryOptions,
|
|
} from '@ptc-org/nestjs-query-graphql';
|
|
|
|
import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
|
|
import { FieldMetadataDTO } from 'src/engine/metadata-modules/field-metadata/dtos/field-metadata.dto';
|
|
import { IndexMetadataDTO } from 'src/engine/metadata-modules/index-metadata/dtos/index-metadata.dto';
|
|
import { BeforeDeleteOneObject } from 'src/engine/metadata-modules/object-metadata/hooks/before-delete-one-object.hook';
|
|
|
|
@ObjectType('Object')
|
|
@Authorize({
|
|
authorize: (context: any) => ({
|
|
workspaceId: { eq: context?.req?.workspace?.id },
|
|
}),
|
|
})
|
|
@QueryOptions({
|
|
defaultResultSize: 10,
|
|
disableSort: true,
|
|
maxResultsSize: 1000,
|
|
})
|
|
@BeforeDeleteOne(BeforeDeleteOneObject)
|
|
@CursorConnection('fields', () => FieldMetadataDTO)
|
|
@CursorConnection('indexMetadatas', () => IndexMetadataDTO)
|
|
export class ObjectMetadataDTO {
|
|
@IDField(() => UUIDScalarType)
|
|
id: string;
|
|
|
|
@Field()
|
|
dataSourceId: string;
|
|
|
|
@Field()
|
|
nameSingular: string;
|
|
|
|
@Field()
|
|
namePlural: string;
|
|
|
|
@Field()
|
|
labelSingular: string;
|
|
|
|
@Field()
|
|
labelPlural: string;
|
|
|
|
@Field({ nullable: true })
|
|
description: string;
|
|
|
|
@Field({ nullable: true })
|
|
icon: string;
|
|
|
|
@Field({ nullable: true })
|
|
shortcut: string;
|
|
|
|
@FilterableField()
|
|
isCustom: boolean;
|
|
|
|
@FilterableField()
|
|
isRemote: boolean;
|
|
|
|
@FilterableField()
|
|
isActive: boolean;
|
|
|
|
@FilterableField()
|
|
isSystem: boolean;
|
|
|
|
@HideField()
|
|
workspaceId: string;
|
|
|
|
@Field()
|
|
createdAt: Date;
|
|
|
|
@Field()
|
|
updatedAt: Date;
|
|
|
|
@Field(() => String, { nullable: true })
|
|
labelIdentifierFieldMetadataId?: string | null;
|
|
|
|
@Field(() => String, { nullable: true })
|
|
imageIdentifierFieldMetadataId?: string | null;
|
|
|
|
@Field()
|
|
isLabelSyncedWithName: boolean;
|
|
}
|