shyft
Version:
Model driven GraphQL API framework
130 lines (129 loc) • 4.34 kB
TypeScript
import { Index } from '../index/Index';
import { Mutation, MutationGenerator } from '../mutation/Mutation';
import { PermissionMap, PermissionMapGenerator } from '../permission/Permission';
import { Subscription } from '../subscription/Subscription';
import { StorageType } from '../storage/StorageType';
import { AttributesMap, AttributesSetupMap, AttributesMapGenerator, PrimaryAttribute } from '../attribute/Attribute';
import { PreFilterMap } from '../filter';
import { Context } from '../context/Context';
import { GraphQLResolveInfo, Source } from 'graphql';
export interface StateMap {
[key: string]: number;
}
interface EntityPreProcessorResponse {
args?: {
[key: string]: unknown;
};
context?: Context;
}
export declare type EntityPreProcessor = (params: {
entity?: Entity;
source?: Source;
args?: {
[key: string]: unknown;
};
context?: Context;
info?: GraphQLResolveInfo;
}) => EntityPreProcessorResponse | Promise<EntityPreProcessorResponse>;
export declare type EntityPostProcessor = (params: {
result?: {
[key: string]: unknown;
};
entity?: Entity;
source?: Source;
args?: {
[key: string]: unknown;
};
context?: Context;
info?: GraphQLResolveInfo;
}) => {
[key: string]: unknown;
};
export interface EntitySetup {
name: string;
description: string;
attributes?: AttributesSetupMap | AttributesMapGenerator;
storageType?: StorageType;
isUserEntity?: boolean;
includeTimeTracking?: boolean;
includeUserTracking?: boolean;
indexes?: Index[];
mutations?: Mutation[] | MutationGenerator;
permissions?: PermissionMap | PermissionMapGenerator;
subscriptions?: any;
states?: StateMap;
preProcessor?: EntityPreProcessor;
postProcessor?: EntityPostProcessor;
preFilters?: PreFilterMap | (() => PreFilterMap);
meta?: {
[key: string]: unknown;
};
}
export declare class Entity {
name: string;
storageTableName: string;
description: string;
storageType?: StorageType;
isUserEntity?: boolean;
includeTimeTracking?: boolean;
includeUserTracking?: boolean;
indexes?: Index[];
mutations?: Mutation[];
permissions?: PermissionMap;
subscriptions?: any;
states?: StateMap;
preProcessor?: EntityPreProcessor;
postProcessor?: EntityPostProcessor;
preFilters?: PreFilterMap;
meta?: {
[key: string]: unknown;
};
private setup;
private _primaryAttribute;
referencedByEntities: {
sourceEntityName: string;
sourceAttributeName: string;
}[];
private defaultPermissions;
private attributes;
descriptionPermissionsFind: string | boolean;
descriptionPermissionsRead: string | boolean;
isFallbackStorageType: boolean;
findOne: () => unknown;
find: () => unknown;
constructor(setup: EntitySetup);
_injectStorageTypeBySchema(storageType: any): void;
_exposeStorageAccess(): void;
_injectDefaultPermissionsBySchema(defaultPermissions: any): void;
getAttributes(): AttributesMap;
private processIndexes;
getIndexes(): Index[];
_processMutations(): Mutation[];
getMutations(): Mutation[];
getMutationByName(name: string): Mutation;
private processStates;
_getDefaultSubscriptions(): {};
_processSubscriptions(): Subscription[];
getSubscriptions(): any;
getSubscriptionByName(name: string): any;
getStates(): StateMap;
hasStates(): boolean;
_collectSystemAttributes(attributeMap: any): any[];
_checkSystemAttributeNameCollision(attributeMap: any, attributeName: any): void;
private processAttribute;
private processAttributeMap;
getPrimaryAttribute(): PrimaryAttribute;
referenceAttribute(attributeName: any): import("../attribute/Attribute").AttributeBase;
getI18nAttributeNames(): string[];
private getDefaultMutations;
private processPermissions;
_generatePermissionDescriptions(): void;
_processPreFilters(preFilters?: PreFilterMap): PreFilterMap;
getPreFilters(): PreFilterMap;
getPermissions(): PermissionMap;
referencedBy(sourceEntityName: any, sourceAttributeName: any): void;
getStorageType(): StorageType;
toString(): string;
}
export declare const isEntity: (obj: unknown) => obj is Entity;
export {};