UNPKG

@getanthill/datastore

Version:

Event-Sourced Datastore

855 lines (854 loc) 25.4 kB
/// <reference types="node" /> import type { ModelConfig, Services } from './typings'; import type { Express } from 'express'; import type { Server } from 'http'; import { MongoDbConnector } from '@getanthill/mongodb-connector'; import { Models } from './models'; import App from './App'; import Datastore from './sdk/Datastore'; declare function setup(): Promise<void>; declare namespace setup { var setupMongodbInMemory: (attempt?: number) => Promise<void>; var teardownMongoDbInMemory: () => Promise<void>; var uuid: () => string; var build: (config?: Partial<{ exitOnUnavailabilityAfterMilliseconds: number; port: string; mode: string; exitTimeout: number; security: { tokens: any[]; apiSecret: string; encryptionKeys: any; activeNumberEncryptionKeys: number; accessTokenByCookie: boolean; }; features: { properties: { is_readonly: string; is_archived: string; is_deleted: string; }; cookies: { options: { httpOnly: boolean; domain: string; secure: boolean; sameSite: boolean | "strict" | "none" | "lax" | undefined; maxAge: number; }; maxAges: any; }; cors: { isEnabled: boolean; allowCredentials: string; allowHeaders: string; allowMethods: string; allowOrigin: string; exposeHeaders: string; requestHeaders: string; requestMethod: string; }; cache: { isEnabled: boolean; scope: string; }; api: { timeout: { models: number; aggregate: number; }; templates: boolean; admin: boolean; aggregate: boolean; graphql: boolean; openAPI: { isEnabled: boolean; warnOnInvalidSpecificationOnly: boolean; }; json: { limit: string; }; updateSpecOnModelsChange: boolean; sseKeepAliveTimeout: number; checkProcessingAuthorization: boolean; stream: { reconnectDelayOnError: number; maxWaitOnReconnectInMilliseconds: number; }; }; events: { throwOnInvalidEvent: boolean; }; fhe: { isEnabled: boolean; }; mqtt: { isEnabled: boolean; }; amqp: { isEnabled: boolean; }; mongodb: { maxTimeMS: number; explain: boolean; slowQueryThresholdInMilliseconds: number; }; mustWaitStatePersistence: boolean; retryDuration: number; deleteAfterArchiveDurationInSeconds: number; initInternalModels: boolean; loadOnlyModels: any; }; authz: { isEnabled: boolean; noPolicyVerb: string; skipModels: string[]; onlyModels: string[]; }; graphql: { http: any; openApiToGraphQL: any; }; fhe: { scheme: string; polyModulusDegree: number; bitSize: number; bitSizes: any; precision: number; }; mqtt: { namespace: string; url: string; options: any; group: string; }; amqp: { namespace: string; url: any; options: any; failover: { reconnectionTimeoutInMilliseconds: number; }; channel: { prefetch: number; }; exchange: { consumer: { name: string; type: string; options: any; }; producer: { name: string; type: string; options: any; }; }; queue: { consumer: { name: string; options: any; }; errors: { isEnabled: boolean; name: string; options: any; }; }; headers: any; }; mongodb: { databases: { name: string; url: string; options: any; }[]; ensureIndexInBackground: boolean; }; pg: { namespace: string; client: { connectionString: string; }; }; models: import("./models").ModelsConfig; datastores: any; openApi: { spec: any; }; }>) => Promise<App>; var cleanModel: (services: Services, modelName: string) => Promise<void>; var cleanModels: (services: Services) => Promise<void>; var initModels: (services: Services, modelConfigs?: ModelConfig[]) => Promise<Models>; var teardownDb: (mongodb: MongoDbConnector) => Promise<void>; var startApi: (_config?: Partial<{ exitOnUnavailabilityAfterMilliseconds: number; port: string; mode: string; exitTimeout: number; security: { tokens: any[]; apiSecret: string; encryptionKeys: any; activeNumberEncryptionKeys: number; accessTokenByCookie: boolean; }; features: { properties: { is_readonly: string; is_archived: string; is_deleted: string; }; cookies: { options: { httpOnly: boolean; domain: string; secure: boolean; sameSite: boolean | "strict" | "none" | "lax" | undefined; maxAge: number; }; maxAges: any; }; cors: { isEnabled: boolean; allowCredentials: string; allowHeaders: string; allowMethods: string; allowOrigin: string; exposeHeaders: string; requestHeaders: string; requestMethod: string; }; cache: { isEnabled: boolean; scope: string; }; api: { timeout: { models: number; aggregate: number; }; templates: boolean; admin: boolean; aggregate: boolean; graphql: boolean; openAPI: { isEnabled: boolean; warnOnInvalidSpecificationOnly: boolean; }; json: { limit: string; }; updateSpecOnModelsChange: boolean; sseKeepAliveTimeout: number; checkProcessingAuthorization: boolean; stream: { reconnectDelayOnError: number; maxWaitOnReconnectInMilliseconds: number; }; }; events: { throwOnInvalidEvent: boolean; }; fhe: { isEnabled: boolean; }; mqtt: { isEnabled: boolean; }; amqp: { isEnabled: boolean; }; mongodb: { maxTimeMS: number; explain: boolean; slowQueryThresholdInMilliseconds: number; }; mustWaitStatePersistence: boolean; retryDuration: number; deleteAfterArchiveDurationInSeconds: number; initInternalModels: boolean; loadOnlyModels: any; }; authz: { isEnabled: boolean; noPolicyVerb: string; skipModels: string[]; onlyModels: string[]; }; graphql: { http: any; openApiToGraphQL: any; }; fhe: { scheme: string; polyModulusDegree: number; bitSize: number; bitSizes: any; precision: number; }; mqtt: { namespace: string; url: string; options: any; group: string; }; amqp: { namespace: string; url: any; options: any; failover: { reconnectionTimeoutInMilliseconds: number; }; channel: { prefetch: number; }; exchange: { consumer: { name: string; type: string; options: any; }; producer: { name: string; type: string; options: any; }; }; queue: { consumer: { name: string; options: any; }; errors: { isEnabled: boolean; name: string; options: any; }; }; headers: any; }; mongodb: { databases: { name: string; url: string; options: any; }[]; ensureIndexInBackground: boolean; }; pg: { namespace: string; client: { connectionString: string; }; }; models: import("./models").ModelsConfig; datastores: any; openApi: { spec: any; }; }>, modelConfigs?: ModelConfig[]) => Promise<[{ exitOnUnavailabilityAfterMilliseconds: number; port: string; mode: string; exitTimeout: number; security: { tokens: any[]; apiSecret: string; encryptionKeys: any; activeNumberEncryptionKeys: number; accessTokenByCookie: boolean; }; features: { properties: { is_readonly: string; is_archived: string; is_deleted: string; }; cookies: { options: { httpOnly: boolean; domain: string; secure: boolean; sameSite: boolean | "strict" | "none" | "lax" | undefined; maxAge: number; }; maxAges: any; }; cors: { isEnabled: boolean; allowCredentials: string; allowHeaders: string; allowMethods: string; allowOrigin: string; exposeHeaders: string; requestHeaders: string; requestMethod: string; }; cache: { isEnabled: boolean; scope: string; }; api: { timeout: { models: number; aggregate: number; }; templates: boolean; admin: boolean; aggregate: boolean; graphql: boolean; openAPI: { isEnabled: boolean; warnOnInvalidSpecificationOnly: boolean; }; json: { limit: string; }; updateSpecOnModelsChange: boolean; sseKeepAliveTimeout: number; checkProcessingAuthorization: boolean; stream: { reconnectDelayOnError: number; maxWaitOnReconnectInMilliseconds: number; }; }; events: { throwOnInvalidEvent: boolean; }; fhe: { isEnabled: boolean; }; mqtt: { isEnabled: boolean; }; amqp: { isEnabled: boolean; }; mongodb: { maxTimeMS: number; explain: boolean; slowQueryThresholdInMilliseconds: number; }; mustWaitStatePersistence: boolean; retryDuration: number; deleteAfterArchiveDurationInSeconds: number; initInternalModels: boolean; loadOnlyModels: any; }; authz: { isEnabled: boolean; noPolicyVerb: string; skipModels: string[]; onlyModels: string[]; }; graphql: { http: any; openApiToGraphQL: any; }; fhe: { scheme: string; polyModulusDegree: number; bitSize: number; bitSizes: any; precision: number; }; mqtt: { namespace: string; url: string; options: any; group: string; }; amqp: { namespace: string; url: any; options: any; failover: { reconnectionTimeoutInMilliseconds: number; }; channel: { prefetch: number; }; exchange: { consumer: { name: string; type: string; options: any; }; producer: { name: string; type: string; options: any; }; }; queue: { consumer: { name: string; options: any; }; errors: { isEnabled: boolean; name: string; options: any; }; }; headers: any; }; mongodb: { databases: { name: string; url: string; options: any; }[]; ensureIndexInBackground: boolean; }; pg: { namespace: string; client: { connectionString: string; }; }; models: import("./models").ModelsConfig; datastores: any; openApi: { spec: any; }; }, MongoDbConnector, Models, Express | null, Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> | null, Datastore, Services, App]>; var stopApi: (app: App) => Promise<void>; var restartApi: (app: App, _config?: Partial<{ exitOnUnavailabilityAfterMilliseconds: number; port: string; mode: string; exitTimeout: number; security: { tokens: any[]; apiSecret: string; encryptionKeys: any; activeNumberEncryptionKeys: number; accessTokenByCookie: boolean; }; features: { properties: { is_readonly: string; is_archived: string; is_deleted: string; }; cookies: { options: { httpOnly: boolean; domain: string; secure: boolean; sameSite: boolean | "strict" | "none" | "lax" | undefined; maxAge: number; }; maxAges: any; }; cors: { isEnabled: boolean; allowCredentials: string; allowHeaders: string; allowMethods: string; allowOrigin: string; exposeHeaders: string; requestHeaders: string; requestMethod: string; }; cache: { isEnabled: boolean; scope: string; }; api: { timeout: { models: number; aggregate: number; }; templates: boolean; admin: boolean; aggregate: boolean; graphql: boolean; openAPI: { isEnabled: boolean; warnOnInvalidSpecificationOnly: boolean; }; json: { limit: string; }; updateSpecOnModelsChange: boolean; sseKeepAliveTimeout: number; checkProcessingAuthorization: boolean; stream: { reconnectDelayOnError: number; maxWaitOnReconnectInMilliseconds: number; }; }; events: { throwOnInvalidEvent: boolean; }; fhe: { isEnabled: boolean; }; mqtt: { isEnabled: boolean; }; amqp: { isEnabled: boolean; }; mongodb: { maxTimeMS: number; explain: boolean; slowQueryThresholdInMilliseconds: number; }; mustWaitStatePersistence: boolean; retryDuration: number; deleteAfterArchiveDurationInSeconds: number; initInternalModels: boolean; loadOnlyModels: any; }; authz: { isEnabled: boolean; noPolicyVerb: string; skipModels: string[]; onlyModels: string[]; }; graphql: { http: any; openApiToGraphQL: any; }; fhe: { scheme: string; polyModulusDegree: number; bitSize: number; bitSizes: any; precision: number; }; mqtt: { namespace: string; url: string; options: any; group: string; }; amqp: { namespace: string; url: any; options: any; failover: { reconnectionTimeoutInMilliseconds: number; }; channel: { prefetch: number; }; exchange: { consumer: { name: string; type: string; options: any; }; producer: { name: string; type: string; options: any; }; }; queue: { consumer: { name: string; options: any; }; errors: { isEnabled: boolean; name: string; options: any; }; }; headers: any; }; mongodb: { databases: { name: string; url: string; options: any; }[]; ensureIndexInBackground: boolean; }; pg: { namespace: string; client: { connectionString: string; }; }; models: import("./models").ModelsConfig; datastores: any; openApi: { spec: any; }; }>) => Promise<[{ exitOnUnavailabilityAfterMilliseconds: number; port: string; mode: string; exitTimeout: number; security: { tokens: any[]; apiSecret: string; encryptionKeys: any; activeNumberEncryptionKeys: number; accessTokenByCookie: boolean; }; features: { properties: { is_readonly: string; is_archived: string; is_deleted: string; }; cookies: { options: { httpOnly: boolean; domain: string; secure: boolean; sameSite: boolean | "strict" | "none" | "lax" | undefined; maxAge: number; }; maxAges: any; }; cors: { isEnabled: boolean; allowCredentials: string; allowHeaders: string; allowMethods: string; allowOrigin: string; exposeHeaders: string; requestHeaders: string; requestMethod: string; }; cache: { isEnabled: boolean; scope: string; }; api: { timeout: { models: number; aggregate: number; }; templates: boolean; admin: boolean; aggregate: boolean; graphql: boolean; openAPI: { isEnabled: boolean; warnOnInvalidSpecificationOnly: boolean; }; json: { limit: string; }; updateSpecOnModelsChange: boolean; sseKeepAliveTimeout: number; checkProcessingAuthorization: boolean; stream: { reconnectDelayOnError: number; maxWaitOnReconnectInMilliseconds: number; }; }; events: { throwOnInvalidEvent: boolean; }; fhe: { isEnabled: boolean; }; mqtt: { isEnabled: boolean; }; amqp: { isEnabled: boolean; }; mongodb: { maxTimeMS: number; explain: boolean; slowQueryThresholdInMilliseconds: number; }; mustWaitStatePersistence: boolean; retryDuration: number; deleteAfterArchiveDurationInSeconds: number; initInternalModels: boolean; loadOnlyModels: any; }; authz: { isEnabled: boolean; noPolicyVerb: string; skipModels: string[]; onlyModels: string[]; }; graphql: { http: any; openApiToGraphQL: any; }; fhe: { scheme: string; polyModulusDegree: number; bitSize: number; bitSizes: any; precision: number; }; mqtt: { namespace: string; url: string; options: any; group: string; }; amqp: { namespace: string; url: any; options: any; failover: { reconnectionTimeoutInMilliseconds: number; }; channel: { prefetch: number; }; exchange: { consumer: { name: string; type: string; options: any; }; producer: { name: string; type: string; options: any; }; }; queue: { consumer: { name: string; options: any; }; errors: { isEnabled: boolean; name: string; options: any; }; }; headers: any; }; mongodb: { databases: { name: string; url: string; options: any; }[]; ensureIndexInBackground: boolean; }; pg: { namespace: string; client: { connectionString: string; }; }; models: import("./models").ModelsConfig; datastores: any; openApi: { spec: any; }; }, MongoDbConnector, Models, Express | null, Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> | null, Datastore, Services, App]>; var inspect: (obj: any) => void; } export default setup;