/** * Copyright Linkurious SAS 2012 - 2019 * * - Created on 2019-08-19. */ import { TlsOptions } from 'node:tls'; import { GenericObject } from '../commonTypes'; import { GraphVendor } from '../dataSource'; import { LicenseState, LimitState } from '../license'; import { IPluginConfig } from '../plugin'; import { OgmaNodeShape, OgmaEdgeShape } from '../displayTypes'; import { ToolNameRequiringApproval } from '../llm/types'; import { ValidLlmVendorConfig } from './llmVendor'; export interface IGetConfigParams { sourceIndex?: number; } /** * License information for end users, with default values. */ export type ConfigLicenseInfo = { state: LicenseState.MISSING; } | { state: LicenseState; endDate: number; strictLicenseEnforcement: boolean; seatsLimitState: LimitState; alertsLimitState: LimitState; isSaaS: boolean; trial: boolean; customGroups: boolean; dataAccessRights: 'entityLevel' | 'propertyLevel'; }; export interface Configuration { ogma: IOgmaConfig; domain: string; ssoProvider?: 'oauth2' | 'saml2'; url: string; setupAuthentication: boolean; instanceKey: string; config: { hide: boolean; }; license: { readOnly: boolean; } & ConfigLicenseInfo; access: IAccessConfig; advanced?: IAdvancedConfig; embeddedElasticSearch?: { enabled: boolean; }; leaflet?: ILeafletConfig[]; alerts?: IAlertsConfig; db?: IDatabaseConfig; server?: IHttpServerConfig; metrics?: MetricsConfig; auditTrail?: IAuditTrailConfig; defaultPreferences?: IUserPreferencesConfig; guestPreferences?: IGuestPreferencesConfig; webhooks?: WebhooksConfig; plugins?: PluginsConfig; isPluginUploadEnabled?: boolean; dataSource?: SelectedDataSourceConfig; needRestart?: boolean; emailNotifications: IEmailNotificationsConfig; entityResolution?: EntityResolutionConfig; entityResolutionSourceKey?: string; cluster?: ClusterConfig; troubleshooting?: TroubleshootingConfig; llm?: LlmConfig; /** * The frontend interaction tools allowed by the admin. * Set by the server only when Copilot is enabled. */ copilotAllowedTools?: ToolNameRequiringApproval[]; datasets?: DatasetConfig[]; } export type DatabaseDialect = 'sqlite' | 'mysql' | 'mariadb' | 'mssql'; export interface IDatabaseOptions { dialect: Exclude; host?: string; port?: number; pool?: DatabaseConnectionPoolConfig; dialectOptions?: Record; } export interface ISqliteOptions { dialect: 'sqlite'; storage: string; } export interface DatabaseConnectionPoolConfig { max?: number; min?: number; } export interface IDatabaseConfig { name: string; username?: string; password?: string; connectionRetries?: number; transactionTimeout?: number; options: IDatabaseOptions | ISqliteOptions; allowFutureStoreVersion?: boolean; slowQueryThreshold?: number; } export interface IHttpServerConfig { listenPort: number; clientFolder: string; cookieHttpOnly?: boolean; cookieSecret?: string; allowOrigin?: string | string[]; allowFraming?: boolean; domain?: string; basePath?: string; publicPortHttp?: number; publicPortHttps?: number; cookieDomain?: string; listenPortHttps?: number; useHttps?: boolean; forceHttps?: boolean; forcePublicHttps?: boolean; certificateFile?: string; certificateKeyFile?: string; certificatePassphrase?: string; tlsCipherList?: string; customHTTPHeaders?: GenericObject; } export interface MetricsConfig { enabled?: boolean; listenPort?: number; } export declare enum AuditTrailMode { READ = "r", WRITE = "w", READ_WRITE = "rw" } export interface IAuditTrailConfig { enabled?: boolean; logFolder?: string; fileSizeLimit?: number; strictMode?: boolean; logResult?: boolean; mode?: AuditTrailMode; logFulltextSearch?: boolean; logPlugins?: boolean; } export interface CopilotUserPreferences { autoApprovedTools: ToolNameRequiringApproval[]; } export interface IUserPreferencesConfig { locale: string; pinOnDrag: boolean; incrementalLayout: boolean; nodeSnapping: boolean; copilot?: CopilotUserPreferences; } export interface IGuestPreferencesConfig { locale: string; uiWorkspaceSearch: boolean; uiExport: boolean; uiLayout: UILayout; uiDesign: boolean; uiEdgeGrouping: boolean; uiFilter: boolean; } export interface WebhooksConfig { enabled: boolean; deliveryFrequency?: string; cleanupFrequency?: string; deliveryRetentionDelayMs?: number; } export type PluginsConfig = Record; export declare enum UILayout { REGULAR = "regular", SIMPLE = "simple", NONE = "none" } export type SelectedDataSourceConfig = IDataSourceConfig | IDataSourceConfig | IDataSourceConfig | IDataSourceConfig; export interface IDataSourceConfig { name?: string; sourceKey?: string; readOnly?: boolean; graphdb: G; index: I; } export interface IGraphVendorConfig extends IVendorConfig { latitudeProperty?: string; longitudeProperty?: string; allowSelfSigned?: boolean; } export interface IVendorConfig { vendor: string; } export interface INeo4jConfig extends IGraphVendorConfig { url: string; proxy?: string; user?: string; password?: string; databaseName?: string; alternativeNodeId?: string; alternativeEdgeId?: string; allowVirtualEntities?: boolean; timestampPropertyName?: string; } export interface ICosmosDbConfig extends IGraphVendorConfig { url: string; database: string; collection: string; primaryKey: string; partitionKey: string; '.NET SDK URI': string; } export interface INeo4jSearchConfig extends IVendorConfig { initialization?: boolean; indexEdges?: boolean; analyzer?: string; } export type InternalIndexConfig = IElasticSearchConfig; export interface IElasticSearchConfig extends IVendorConfig { host: string; port: number; https?: boolean; user?: string; password?: string; mapping?: string; analyzer?: string; incrementalIndexing?: boolean; incrementalIndexingCron?: string; forceReindex?: boolean; skipEdgeIndexing?: boolean; } export interface IAzureSearchConfig extends IVendorConfig { url: string; apiKey: string; nodeIndexName: string; edgeIndexName?: string; } export interface IAlertsConfig { enabled?: boolean; maxMatchesLimit?: number; maxRuntimeLimit?: number; enableDataPreprocessing?: boolean; } export interface IAdvancedConfig { supernodeThreshold: number; expandThreshold: number; rawQueryLimit: number; searchAddAllThreshold: number; minSearchQueryLength: number; rawQueryTimeout: number; searchPrefixExpansion: boolean; showBuiltinQueries?: boolean; slowQueryThreshold?: number; searchRetryMultiplier?: number; sampledItemsPerType: number; sampledVisualizationItems: number; pollInterval?: number; indexingChunkSize?: number; layoutWorkers?: number; defaultFuzziness?: number; extraCertificateAuthorities?: string; obfuscation?: boolean; edgesBetweenSupernodes?: boolean; itemTypeCountLimit?: number; dataSourceConnectionTimeout?: number; dataSourceAutoReconnectInterval?: number; productFruits?: ProductFruitsConfig; flags?: GenericObject; } export interface ILeafletConfig { name: string; urlTemplate: string; attribution: string; minZoom: number; maxZoom: number; thumbnail: string; subdomains?: string; id?: string; accessToken?: string; overlay?: boolean; } /** * A dataset that can be loaded into a data-source. Only exposed to admin users. */ export interface DatasetConfig { /** * A human readable name identifying the dataset. */ name: string; /** * The path to the JSON file describing the dataset (see {@link Dataset}). */ path: string; } /** * The content of a dataset file referenced by an {@link DatasetConfig}. */ export interface Dataset { /** * The vendor names compatible with this dataset (e.g. `["memgraph", "neo4j"]`). */ vendors: GraphVendor[]; /** * The database queries that will create nodes and edges in the database. */ databaseInitQueries: string[]; /** * An optional configuration export (from the config-migration plugin) that is applied to the * data-source after indexation, when the plugin is installed and running. */ configuration?: object; } export interface IAccessConfig { authRequired?: boolean; disableLocalAuth?: boolean; guestMode?: boolean; dataEdition?: boolean; widget?: boolean; visualizationExport: boolean; loginTimeout?: number; externalUsersAllowedGroups?: Array; externalUserDefaultGroupId?: number | number[]; externalUsersGroupMapping?: GenericObject>; autoRefreshGroupMapping?: boolean; msActiveDirectory?: Array | IMSActiveDirectoryConfig; ldap?: Array | ILDAPConfig; saml2?: ISaml2Config; oauth2?: IOAuth2Config; minimumPasswordLength?: number; requiredPasswordCharacterClasses?: Record; } export interface IMSActiveDirectoryConfig { enabled?: boolean; url?: string; baseDN?: string; domain?: string; netbiosDomain?: string; tls?: TlsOptions; } export interface ILDAPConfig { enabled: boolean; url: string; bindDN?: string; bindPassword?: string; baseDN: string | string[]; usernameField: string; emailField?: string; groupField?: string; tls?: TlsOptions; } export interface ISaml2Config { enabled: boolean; url: string; identityProviderCertificate?: string; identityProviderCertificateValue?: string; groupAttribute?: string; emailAttribute?: string; } export interface IOpenIDConnectConfig { userinfoURL?: string; scope?: string; groupClaim?: string; } export interface IAzureOAuthConfig { tenantID?: string; } export interface IOAuth2Config { enabled: boolean; provider: string; authorizationURL: string; tokenURL: string; clientID: string; clientSecret: string; resource?: string; openidconnect?: IOpenIDConnectConfig; azure?: IAzureOAuthConfig; } export declare enum AntiAliasing { SUPER_SAMPLING = "super-sampling", NATIVE = "native", NONE = "none" } export declare enum OgmaRenderer { WEBGL = "webgl", CANVAS = "canvas" } export declare enum ImgCrossOrigin { ANONYMOUS = "anonymous", USE_CREDENTIALS = "use-credentials" } export interface IWebGLConfig { antiAliasing?: AntiAliasing; fontSamplingSize?: number; } export interface TextOptions { maxTextLength?: number; minVisibleSize?: number; maxLineLength?: number; backgroundColor?: string; font?: string; color?: string; size?: number; } export interface IOgmaConfig { renderer?: OgmaRenderer; webglOptions?: IWebGLConfig; imgCrossOrigin?: ImgCrossOrigin; options?: { styles?: { node?: { nodeRadius?: number; shape?: OgmaNodeShape; text?: TextOptions & { nodePosition?: 'right' | 'left' | 'top' | 'bottom' | 'center'; }; }; edge?: { edgeWidth?: number; shape?: OgmaEdgeShape; text?: TextOptions; }; }; interactions?: { zoom?: { modifier?: number; }; rotation?: { enabled?: boolean; }; }; backgroundColor?: string; }; nodeGrouping?: NodeGroupingConfig; } export interface IConfigurationParams { path?: string; configuration: T; sourceIndex?: number; reset?: boolean; } export interface IResetConfigParams extends IConfigurationParams { reset: true; } export interface IDataSourceConfigParams extends IConfigurationParams { sourceIndex: number; path: 'dataSource'; } export type IUpdateConfigParams = IResetConfigParams | IDataSourceConfigParams | IConfigurationParams; export interface IAbstractMailerConfig { type: string; } export type MailerType = 'smtp'; export interface IMailerConfig extends IAbstractMailerConfig { type: MailerType; auth?: ISMTPAuthConfig; host: string; port: number; ssl: boolean; allowSelfSigned?: boolean; } export interface ISMTPAuthConfig { user: string; password: string; } export interface IEmailNotificationsConfig { alertNotifications: boolean; newCasesDigestNotificationFrequency: string; caseAssignmentNotificationFrequency: string; caseMentionNotificationFrequency: string; visualizationNotifications: boolean; visualizationMentionNotificationFrequency: string; entityResolutionLicenseNotifications: boolean; entityResolutionLicenseCheckFrequency: string; entityResolutionIngestionSuccessNotifications: boolean; entityResolutionIngestionFailureNotifications: boolean; mailer: IMailerConfig; fromEmail: string; } export interface EntityResolutionConfig { enabled: boolean; url: string; chunkSize?: number; expandLimitPerNode?: number; serviceApiKey?: string; } export type ClusterMode = 'primary' | 'secondary'; export interface ClusterConfig { enabled: boolean; mode?: ClusterMode; maxDriftMs?: number; } export interface TroubleshootingConfig { enableReport: boolean; enableFullErrors: boolean; } export interface NodeGroupingConfig { displayCollapsedByDefault?: boolean; } export interface ProductFruitsConfig { enabled: boolean; secretKey?: string; projectCode?: string; } export interface BaseLlmConfig { copilotEnabled: boolean; vendor?: ValidLlmVendorConfig; maxContextTokens?: number; maxGraphViewNodes?: number; maxGraphViewEdges?: number; maxGraphViewPropertyValueLength?: number; /** * Whether the frontend interaction tools are made available to the LLM by default. * - `allow` only exposes the tool: the user's approval preferences still apply. * - `deny` hides the tool from the LLM. */ defaultToolPermission?: ToolPermission; /** * Set the permission for each frontend interaction tool individually, overriding the `defaultToolPermission` if specified. */ permissionPerTool?: Partial>; } export declare const TOOL_PERMISSION_VALUES: readonly ['allow', 'deny']; export type ToolPermission = (typeof TOOL_PERMISSION_VALUES)[number]; /** * Permission applied to a frontend interaction tool when neither `defaultToolPermission` * nor `permissionPerTool` is configured for it. */ export declare const DEFAULT_TOOL_PERMISSION: ToolPermission; export interface EnabledLlmConfig extends BaseLlmConfig { copilotEnabled: true; vendor: ValidLlmVendorConfig; } export interface DisabledLlmConfig extends BaseLlmConfig { copilotEnabled: false; } export type LlmConfig = EnabledLlmConfig | DisabledLlmConfig;