import { GraphQLSchema } from 'graphql'; import { ProjectOptions } from '../config/interfaces'; import { LoggerProvider } from '../config/logging'; import { DatabaseAdapter } from '../database/database-adapter'; import { ExecutionOptions } from '../execution/execution-options'; import { SchemaExecutor } from '../execution/schema-executor'; import { Model, TimeToLiveType, ValidationResult } from '../model'; import { ModuleSelectionOptions } from './select-modules-in-sources'; import { ProjectSource, SourceLike, SourceType } from './source'; import { TTLInfo } from './time-to-live'; export { ProjectOptions }; export interface ProjectConfig extends ProjectOptions { /** * Array of source files * * The name of each source identifies its type, so files ending with .yaml are interpreted as YAML files */ readonly sources: ReadonlyArray; } export interface TTLCleanupResult { /** * Specifies if all objects to be deleted have been deleted despite possibly configured limits * * (could be false if exactly as many objects have been deleted as the configured limit) */ readonly isComplete: boolean; /** * Specifies if there has been an error in one of the type executions */ readonly hasErrors: boolean; readonly types: ReadonlyArray; } export interface TTLCleanupTypeResult { /** * The TTL type this is the result for */ readonly type: TimeToLiveType; /** * The actual number of objects that have been deleted for this type */ readonly deletedObjectsCount: number; /** * The limit used for object deletion. * * If hasReducedLimit is true, this is the reduced limit. If has been no limit, this is undefined. */ readonly limit: number | undefined; /** * Specifies if the limit has been reduced to avoid resource errors * * Will always be false if reduceLimitOnResourceLimits is not set to true. */ readonly hasReducedLimit: boolean; /** * Specifies if all objects to be deleted have been deleted despite possibly configured limits * * (could be false if exactly as many objects have been deleted as the configured limit) */ readonly isComplete: boolean; /** * Specifies if an error occurred for this type */ readonly hasError: boolean; /** * An error, if an error occurred for this type */ readonly error: Error | undefined; /** * The last resource-exhaustion error that caused the limit to be reduce. The presence of this does not mean that the * operation failed, see error/hasError for this */ readonly lastLimitReductionCause: Error | undefined; } export declare class Project { /** * Array of source files * * The name of each source identifies its type, so files ending with .yaml are interpreted as YAML files */ readonly sources: ReadonlyArray; readonly loggerProvider: LoggerProvider; readonly options: ProjectOptions; constructor(configOrSources: ProjectConfig | ReadonlyArray); getSourcesOfType(type: SourceType): ReadonlyArray; /** * Validates this project ot identify if createSchema() would succeed * * @return the result with all validation messages encountered */ validate(): ValidationResult; /** * Gets a structured representation of the elements of this project * * @throws InvalidProjectError if this project is invalid */ getModel(): Model; /** * Generates a new project from this one where only types and fields of the given modules are included * * Only works if modelOptions.withModuleDefinitions is set in the options of this project * * The resulting project's sources will be modified as well, so they can be used to serialize the resulting model. * * Throws an error if this project is not valid. */ withModuleSelection(selectedModules: ReadonlyArray, options?: ModuleSelectionOptions): Project; /** * Checks if this project is compatible with another project * * A project is compatible with another project if it declares all types and fields of it in a compatible manner. * It can have additional types and fields, and it can differ in some ways that are considered compatible (e.g. * the flexSearchLanguage arguments can differ). * * If the baselineProject includes module declarations, the module names will be used in the messages. * * @return a ValidationResult, with messages of severity COMPATIBILITY_ISSUE if there are compatibility issues, or none if the project is compatible */ checkCompatibility(baselineProject: Project): ValidationResult; /** * Creates an executable GraphQLSchema that uses the given DatabaseAdapter to execute queries * * @throws InvalidProjectError if this project is invalid */ createSchema(databaseAdapter: DatabaseAdapter): GraphQLSchema; /** * Experimental API, lacks of significant features like validation or introspection * * @throws InvalidProjectError if this project is invalid */ createSchemaExecutor(databaseAdapter: DatabaseAdapter): SchemaExecutor; /** * Creates an executable GraphQLSchema that allows to inspect the active model with its types and fields * * @throws InvalidProjectError if this project is invalid */ createMetaSchema(): GraphQLSchema; executeTTLCleanup(databaseAdapter: DatabaseAdapter, executionOptions: ExecutionOptions): Promise<{ [name: string]: number; }>; executeTTLCleanupExt(databaseAdapter: DatabaseAdapter, executionOptions: ExecutionOptions): Promise; private executeTTLCleanupForType; getTTLInfo(databaseAdapter: DatabaseAdapter, executionOptions: ExecutionOptions): Promise>; private execute; }