import { type AppIdentifier, type AppIntent, type AppMetadata, type Context, type Intent } from '@finos/fdc3'; import { AppDirectoryApplication, LocalAppDirectory } from '../app-directory.contracts.js'; import { BackoffRetryParams, FullyQualifiedAppIdentifier, IAppResolver, ResolveForContextResponse } from '../contracts.js'; export declare class AppDirectory { private readonly appResolverPromise; private log; private readonly directory; private readonly instanceLookup; private readonly appDirectoryEntries; readonly loadDirectoryPromise: Promise; constructor(rootAppId: string, appResolverPromise: Promise, appDirectoryEntries?: (string | LocalAppDirectory)[], backoffRetry?: BackoffRetryParams, rootAppDirectoryEntry?: Omit); private _rootAppIdentifier; get applications(): AppDirectoryApplication[]; get rootAppIdentifier(): FullyQualifiedAppIdentifier; private registerRootApp; /** * Populates the instanceLookup for the given instanceId with the intents (and the contexts they listen for) * declared on the supplied application's `interop.intents.listensFor`. */ private populateInstanceLookup; /** * Returns an AppIdentifier for the app to handle the intent. * If the passed in app is fully qualified that is returned. * Otherwise the resolver determines which app to use (usually by launching a UI element). * The returned AppIdentifier may or may not have an instanceId - the caller is responsible * for opening a new instance if needed. */ resolveAppForIntent(intent: Intent, context: Context, app?: AppIdentifier | string): Promise; /** * Returns chosen intent and an AppIdentifier for the app to handle the context. * The resolver determines which intent and app to use (usually by launching a UI element). * The returned AppIdentifier may or may not have an instanceId - the caller is responsible * for opening a new instance if needed. */ resolveAppForContext(context: Context, app?: AppIdentifier | string): Promise; /** * When agent.registerIntentListener is called this function is called to add the app to the app directory */ registerIntentListener(app: FullyQualifiedAppIdentifier, intent: Intent, context: Context[]): Promise; /** * Adds app instance to root desktop agent's app directory * @param app is FullyQualifiedAppIdentifier of app instance being added * @throws error if app is not known to desktop agent but at least one app directory is currently loaded */ registerNewInstance(identityUrl: string): Promise<{ identifier: FullyQualifiedAppIdentifier; application: AppDirectoryApplication; }>; /** * @param appId of app whose instances are being returned * @returns array of AppIdentifiers with appIds that match given appId, or undefined if app is not known to desktop agent */ getAppInstances(appId: string): Promise; /** * Determines an app identity by looking up the identity url in the app directory. If the identity could not be determined an error message is returned * @param appDetails * @returns */ private resolveAppIdentity; /** * Returns a fully qualified app identifier with a fully qualified appId IF the directory knows the appId and instance * If the directory does not know the instance or app an error message is returned */ private getValidatedAppIdentifier; /** * Returns all FullyQualifiedAppIds that match the given appId using FDC3 cross-matching rules. * Used by findInstances where multiple matches should all be returned. */ private getAllMatchingFullyQualifiedAppIds; /** * Resolves an appId (qualified or unqualified) to a known FullyQualifiedAppId that exists in the directory using the * FDC3 Fully-Qualified AppId resolution algorithm: * * 1. Exact match: try the appId as-is against known directory keys. * 2. Cross-match: if a fully-qualified appId was given, split on '@' and match the * unqualified portion against the unqualified part of known fully-qualified appIds. * If an unqualified appId was given, match it against the unqualified part of known * fully-qualified appIds. * * //TODO: update url when current version docs include this resolution algorithm * https://fdc3.finos.org/docs/next/api/spec#fully-qualified-appids * * When the cross-match yields multiple results the first match is returned. */ private getKnownFullyQualifiedAppId; /** * @param appId of app whose metadata is being returned * @returns metadata of given app or undefined if app is not registered in app directory */ getAppMetadata(app: AppIdentifier): Promise; /** * @returns array of contexts which are handled by given intent and given app or undefined */ getContextForAppIntent(app: AppIdentifier, intent: Intent): Promise; /** * @param context for which apps and intents are being found to handle it * @param resultType used to optionally filter apps based on type of context or channel they return * @returns appIntents containing intents which handle the given context and the apps that resolve them */ getAppIntentsForContext(context: Context, resultType?: string): Promise; /** * Returns all intents that can handle given context */ private getIntentsForContext; /** * @param intent for which apps are being found to resolve it * @param context used to optionally filter apps based on whether they handle it * @param resultType used to optionally filter apps based on type of context or channel they return * @returns AppIntent containing info about given intent, as well as appMetadata for apps and app instances which resolve it */ getAppIntent(intent: Intent, context?: Context, resultType?: string): Promise; private getIntentDisplayName; /** * Returns appMetadata for all apps and app instances that resolve given intent, handle given context, and return result of given resultType */ private getAppsForIntent; /** * Returns true if given application returns result of given resultType when resolving given intent, and false otherwise */ private doesAppReturnResultType; /** * Returns appMetadata for all instances of a given app that resolve given intent and handle given context * @param appId of app whose instances are being checked * @param intent to be resolved by instance * @param context to be handled by instance */ private getInstancesForIntent; /** * Returns true if app instance resolves given intent and handles given context. Returns false otherwise */ private checkInstanceResolvesIntent; /** * Returns true if context of same type is contained within given array of Context objects * @param contextArray is array of Context objects * @param context is context object whose type is being checked for in array */ private isContextInArray; /** * Fetches app data from given app directory urls and stores it in directory */ private loadAllAppDirectories; private addLocalApps; private addLocalAppToDirectory; private loadAppDirectory; /** * Add new intentContextLookup without introducing duplicates * @param instanceId which is having new intentContextLookup added * @param newIntentContextLookup being added * @returns true if intentContextLookup was added, and false otherwise */ private addNewIntentContextLookup; getAppDirectoryApplication(appId: string): Promise; removeDisconnectedApp(app: FullyQualifiedAppIdentifier): void; private buildAppHostManifestLookup; }