pigallery2-extension-kit 3.8.1-edge → 3.9.1-edge

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/index.d.ts +3 -0
  2. package/index.js +3 -0
  3. package/lib/backend/Logger.d.ts +9 -0
  4. package/lib/backend/ProjectPath.d.ts +4 -0
  5. package/lib/backend/exceptions/SearchQueryTooLargeException.d.ts +13 -0
  6. package/lib/backend/middlewares/admin/ExtensionMWs.d.ts +4 -0
  7. package/lib/backend/middlewares/user/AuthenticationMWs.d.ts +13 -0
  8. package/lib/backend/middlewares/user/OIDCMWs.d.ts +5 -0
  9. package/lib/backend/model/ObjectManagers.d.ts +7 -0
  10. package/lib/backend/model/database/AlbumManager.d.ts +4 -0
  11. package/lib/backend/model/database/GalleryManager.d.ts +10 -0
  12. package/lib/backend/model/database/IObjectManager.d.ts +4 -0
  13. package/lib/backend/model/database/IndexingManager.d.ts +1 -5
  14. package/lib/backend/model/database/PersonManager.d.ts +18 -5
  15. package/lib/backend/model/database/ProjectedCacheManager.d.ts +5 -1
  16. package/lib/backend/model/database/ProjectionAwareManager.d.ts +4 -0
  17. package/lib/backend/model/database/SessionManager.d.ts +10 -1
  18. package/lib/backend/model/extension/ExpressRouterWrapper.d.ts +29 -8
  19. package/lib/backend/model/extension/ExtensionGallery.d.ts +54 -0
  20. package/lib/backend/model/extension/ExtensionManager.d.ts +5 -1
  21. package/lib/backend/model/extension/ExtensionObject.d.ts +4 -0
  22. package/lib/backend/model/extension/ExtensionSessions.d.ts +12 -0
  23. package/lib/backend/model/extension/IExtension.d.ts +211 -25
  24. package/lib/backend/model/extension/UIExtension.d.ts +33 -9
  25. package/lib/backend/model/fileaccess/MetadataLoader.d.ts +4 -0
  26. package/lib/backend/routes/admin/ExtensionRouter.d.ts +1 -0
  27. package/lib/common/ExtensionActionUtils.d.ts +21 -0
  28. package/lib/common/SearchQueryUtils.d.ts +5 -0
  29. package/lib/common/config/private/PrivateConfig.d.ts +1 -0
  30. package/lib/common/config/public/ClientConfig.d.ts +13 -0
  31. package/lib/common/config/public/ClientConfig.js +84 -8
  32. package/lib/common/entities/Error.d.ts +1 -0
  33. package/lib/common/entities/Error.js +2 -0
  34. package/lib/common/entities/extension/ExtensionError.d.ts +12 -0
  35. package/lib/common/entities/extension/ExtensionError.js +22 -0
  36. package/lib/common/entities/extension/IClientUIConfig.d.ts +109 -114
  37. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1 +1,4 @@
1
1
  export { IServerExtension, IExtensionObject } from './lib/backend/model/extension/IExtension';
2
+ export type { UIAction, MediaActionArgs } from './lib/backend/model/extension/IExtension';
3
+ export type { UIFormData, UIFormDTO, UIFormField, UIWhen, IMetadataFilter } from './lib/common/entities/extension/IClientUIConfig';
4
+ export { ExtensionError } from './lib/common/entities/extension/ExtensionError';
package/index.js CHANGED
@@ -1,2 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExtensionError = void 0;
4
+ var ExtensionError_1 = require("./lib/common/entities/extension/ExtensionError");
5
+ Object.defineProperty(exports, "ExtensionError", { enumerable: true, get: function () { return ExtensionError_1.ExtensionError; } });
@@ -11,6 +11,8 @@ export interface ILogger {
11
11
  }
12
12
  export declare const createLoggerWrapper: (TAG: string) => ILogger;
13
13
  export declare class Logger {
14
+ static fileSizeLimit: number;
15
+ private static logFile;
14
16
  static silly(this: void, ...args: LoggerArgs[]): void;
15
17
  static debug(this: void, ...args: LoggerArgs[]): void;
16
18
  static verbose(this: void, ...args: LoggerArgs[]): void;
@@ -18,5 +20,12 @@ export declare class Logger {
18
20
  static warn(this: void, ...args: LoggerArgs[]): void;
19
21
  static error(this: void, ...args: LoggerArgs[]): void;
20
22
  static logLevelForError(e: ErrorCodes): LoggerFunction;
23
+ static closeFile(): void;
24
+ /**
25
+ * Appends a line to Config.Server.Log.file (if set), e.g. for Fail2Ban on hosts without journald (#519).
26
+ * Writes are synchronous, like console output to a file or pipe.
27
+ * If the file can't be written, it logs that once to the console and skips the file until the setting changes.
28
+ */
29
+ private static writeToFile;
21
30
  private static log;
22
31
  }
@@ -11,6 +11,10 @@ export declare class ProjectPathClass {
11
11
  private cfg;
12
12
  init(cfg: PrivateConfigClass): void;
13
13
  normalizeRelative(pathStr: string): string;
14
+ /**
15
+ * Normalises a path from a request, relative to ImageFolder. Null if it would point outside of it.
16
+ */
17
+ normalizeRequestPath(pathStr: string | undefined): string | null;
14
18
  getAbsolutePath(pathStr: string): string;
15
19
  getRelativePathToImages(pathStr: string): string;
16
20
  /**
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The DB refused a search query for its size (too many SQL parameters or a too deep expression).
3
+ * This mostly happens with "some of" queries: they are expanded to every combination of their items.
4
+ */
5
+ export declare class SearchQueryTooLargeException extends Error {
6
+ readonly dbError: unknown;
7
+ private static readonly DB_LIMIT_ERRORS;
8
+ constructor(dbError: unknown);
9
+ /**
10
+ * Returns a SearchQueryTooLargeException if the DB error is about the query size, otherwise the error itself.
11
+ */
12
+ static fromDBError(err: unknown): unknown;
13
+ }
@@ -1,5 +1,9 @@
1
1
  import { NextFunction, Request, Response } from 'express';
2
2
  export declare class ExtensionMWs {
3
+ /**
4
+ * The UI contributions of the extensions that the user of the request may see (none without a session).
5
+ */
6
+ static getUIConfig(req: Request, res: Response, next: NextFunction): void;
3
7
  static getExtensionList(req: Request, res: Response, next: NextFunction): Promise<void>;
4
8
  static installExtension(req: Request, res: Response, next: NextFunction): Promise<void>;
5
9
  static reloadExtension(req: Request, res: Response, next: NextFunction): Promise<void>;
@@ -1,6 +1,7 @@
1
1
  import { NextFunction, Request, Response } from 'express';
2
2
  import { UserRoles } from '../../../common/entities/UserDTO';
3
3
  export declare class AuthenticationMWs {
4
+ private static proxyWarningShown;
4
5
  static tryAuthenticate(req: Request, res: Response, next: NextFunction): Promise<void>;
5
6
  static authenticate(req: Request, res: Response, next: NextFunction): Promise<void>;
6
7
  static normalizePathParam(paramName: string): (req: Request, res: Response, next: NextFunction) => void;
@@ -15,6 +16,18 @@ export declare class AuthenticationMWs {
15
16
  * The response for not existing and not available directories. They need to be the same:
16
17
  * GalleryMWs.listDirectory answers not existing directories with the same status and error.
17
18
  */
19
+ /**
20
+ * Logs a failed login in a stable format for fail2ban (see docs/setup/advanced/fail2ban.md):
21
+ * Failed login from IP `<ip>` <details>
22
+ * User input in details must be JSON.stringify-ed: a raw newline would start a new log line
23
+ * that the client controls, e.g. a fake failed login of someone else's IP.
24
+ */
25
+ private static logFailedLogin;
26
+ /**
27
+ * Behind a reverse proxy, req.ip is the proxy's IP unless Server.trustProxy is set,
28
+ * so fail2ban would only ever see (and ban) the proxy. Tell the admin once.
29
+ */
30
+ private static warnIfBehindUntrustedProxy;
18
31
  private static directoryNotFound;
19
32
  static authoriseMedia(paramName: string): (req: Request, res: Response, next: NextFunction) => Promise<void>;
20
33
  static authorise(role: UserRoles): (req: Request, res: Response, next: NextFunction) => void;
@@ -7,4 +7,9 @@ export declare class OIDCMWs {
7
7
  */
8
8
  static redirectToProvider(req: Request, res: Response, next: NextFunction): Promise<void>;
9
9
  static redirectToApp(req: Request, res: Response): void;
10
+ /**
11
+ * The callback is opened by the browser, not by the app: show the error on the login page, not as JSON (#1422).
12
+ * The reason stays in the server log; the login page only tells whether the access was denied.
13
+ */
14
+ static redirectToLoginOnError(err: unknown, req: Request, res: Response, _next: NextFunction): void;
10
15
  }
@@ -33,11 +33,18 @@ export declare class ObjectManagers {
33
33
  private uploadManager;
34
34
  private sessionManager;
35
35
  private initDone;
36
+ private lastDayKey;
37
+ private dayChangePromise;
36
38
  constructor();
37
39
  static getInstance(): ObjectManagers;
38
40
  static reset(): Promise<void>;
39
41
  static isReady(): boolean;
40
42
  init(): Promise<void>;
43
+ /**
44
+ * Calls onNewDay() of the managers once per day key.
45
+ * Called on every request (SessionManager.buildContext), so it is a string compare unless the day changed.
46
+ */
47
+ onDayChangeIfNeeded(): Promise<void>;
41
48
  private initManagers;
42
49
  onDataChange(changedDir?: DirectoryPathDTO | null): Promise<void>;
43
50
  get VersionManager(): VersionManager;
@@ -12,6 +12,10 @@ export declare class AlbumManager extends ProjectionAwareManager<AlbumBaseEntity
12
12
  deleteAlbum(id: number): Promise<void>;
13
13
  deleteAll(): Promise<void>;
14
14
  protected loadEntities(session: SessionContext): Promise<AlbumBaseEntity[]>;
15
+ /**
16
+ * Albums whose own query has a relative date change daily, also for projection keys that do not.
17
+ */
18
+ onNewDay(): Promise<void>;
15
19
  protected invalidateDBCache(): Promise<void>;
16
20
  private updateAlbums;
17
21
  }
@@ -26,7 +26,17 @@ export declare class GalleryManager {
26
26
  * Sets cover for the directory and caches it in the DB
27
27
  */
28
28
  fillCacheForSubDir(connection: DataSource, session: SessionContext, dir: SubDirectoryDTO): Promise<void>;
29
+ /**
30
+ * Splits a media path (relative to the media folder) into the columns it is stored in.
31
+ */
32
+ private static splitMediaPath;
29
33
  getMedia(session: SessionContext, mediaPath: string): Promise<MediaEntity | null>;
34
+ /**
35
+ * The media of the paths (normalised, relative to the media folder), in the same order, with the projection of the session.
36
+ * Null for a path that does not exist or is hidden by the projection.
37
+ * Batched: one query for the directories and one for the media per chunk, no tuple IN (not portable).
38
+ */
39
+ getMediaList(session: SessionContext, mediaPaths: string[]): Promise<(MediaEntity | null)[]>;
30
40
  authoriseMedia(session: SessionContext, mediaPath: string): Promise<boolean>;
31
41
  /**
32
42
  * Metafiles belong to their directory: they are available if the directory is available (see DirectoryAccess).
@@ -1,6 +1,10 @@
1
1
  import { DirectoryPathDTO } from '../../../common/entities/DirectoryDTO';
2
2
  export interface IObjectManager {
3
3
  onNewDataVersion?: (changedDir?: DirectoryPathDTO) => Promise<void>;
4
+ /**
5
+ * Called once a day (see ObjectManagers.onDayChangeIfNeeded): caches of relative dates (date_pattern) go stale.
6
+ */
7
+ onNewDay?: () => Promise<void>;
4
8
  cleanUp?: () => Promise<void>;
5
9
  init?: () => Promise<void>;
6
10
  }
@@ -13,6 +13,7 @@ export declare class IndexingManager {
13
13
  * does not wait for the DB to be saved
14
14
  */
15
15
  indexDirectory(relativeDirectoryName: string, waitForSave?: boolean): Promise<ParentDirectoryDTO>;
16
+ private hasIndexedFiles;
16
17
  resetDB(): Promise<void>;
17
18
  saveToDB(scannedDirectory: ParentDirectoryDTO): Promise<void>;
18
19
  /**
@@ -25,11 +26,6 @@ export declare class IndexingManager {
25
26
  protected saveChildDirs(connection: DataSource, currentDirId: number, scannedDirectory: ParentDirectoryDTO): Promise<void>;
26
27
  protected saveMetaFiles(connection: DataSource, currentDirID: number, scannedDirectory: ParentDirectoryDTO): Promise<void>;
27
28
  protected saveMedia(connection: DataSource, parentDirId: number, media: MediaDTO[]): Promise<void>;
28
- protected savePersonsToMedia(connection: DataSource, parentDirId: number, scannedFaces: {
29
- name: string;
30
- mediaId: number;
31
- }[]): Promise<void>;
32
29
  private checkSavingReady;
33
30
  private saveChunk;
34
- private insertChunk;
35
31
  }
@@ -1,6 +1,5 @@
1
1
  import { PersonEntry } from './enitites/person/PersonEntry';
2
2
  import { PersonDTO } from '../../../common/entities/PersonDTO';
3
- import { DirectoryPathDTO } from '../../../common/entities/DirectoryDTO';
4
3
  import { SessionContext } from '../SessionContext';
5
4
  import { ProjectionAwareManager } from './ProjectionAwareManager';
6
5
  export declare class PersonManager extends ProjectionAwareManager<PersonEntry> {
@@ -14,10 +13,24 @@ export declare class PersonManager extends ProjectionAwareManager<PersonEntry> {
14
13
  name: string;
15
14
  mediaId: number;
16
15
  }[]): Promise<void>;
17
- protected invalidateDBCache(changedDir?: DirectoryPathDTO & {
18
- id?: number;
19
- }): Promise<void>;
16
+ /**
17
+ * Makes the faces (person - media connections) of some media match the given faces (one per face region):
18
+ * adds the missing persons and connections and removes the connections that are gone.
19
+ * @param scope the media whose faces are given: every media of a directory (indexing) or the listed ones
20
+ */
21
+ saveFaces(scope: {
22
+ directoryId: number;
23
+ } | {
24
+ mediaIds: number[];
25
+ }, faces: {
26
+ name: string;
27
+ mediaId: number;
28
+ }[]): Promise<void>;
29
+ /**
30
+ * Invalidates every person, also on the change of a single directory:
31
+ * the faces are already removed from the DB by then, so the persons who lost their last face there can't be found.
32
+ */
33
+ protected invalidateDBCache(): Promise<void>;
20
34
  protected loadEntities(session: SessionContext): Promise<PersonEntry[]>;
21
- private invalidateAllDBCache;
22
35
  private updateCacheForAll;
23
36
  }
@@ -6,7 +6,11 @@ import { DirectoryPathDTO } from '../../../common/entities/DirectoryDTO';
6
6
  import { SessionContext } from '../SessionContext';
7
7
  import { SearchQueryDTO } from '../../../common/entities/SearchQueryDTO';
8
8
  export declare class ProjectedCacheManager implements IObjectManager {
9
- init(): Promise<void>;
9
+ /**
10
+ * Also runs at startup (ObjectManagers.init), to avoid stale growth.
11
+ * Projection keys with a relative date change daily, so the old ones go away here.
12
+ */
13
+ onNewDay(): Promise<void>;
10
14
  onNewDataVersion(changedDir?: DirectoryPathDTO): Promise<void>;
11
15
  /**
12
16
  * Includes all possible projection keys, including the default one and sharing keys too.
@@ -19,6 +19,10 @@ export declare abstract class ProjectionAwareManager<T> implements IObjectManage
19
19
  * Subclasses can override for more specific behavior.
20
20
  */
21
21
  onNewDataVersion(changedDir?: DirectoryPathDTO): Promise<void>;
22
+ /**
23
+ * Drops the lists of the projection keys that changed with the day (relative dates).
24
+ */
25
+ onNewDay(): Promise<void>;
22
26
  /**
23
27
  * Reset the entire memory cache
24
28
  */
@@ -26,7 +26,16 @@ export declare class SessionManager {
26
26
  * Returns with the final projection query (media and directory allow/block lists) of a sharing.
27
27
  */
28
28
  buildAllowListForSharing(sharing: SharingEntity): SearchQueryDTO | null;
29
- createProjectionKey(q: SearchQueryDTO): string;
29
+ /**
30
+ * Calendar-day stamp combining UTC and local dates (SQLite 'now' is UTC, MySQL CURDATE() is server local,
31
+ * and JS mixes both), so relative-date caches refresh across either midnight without a stale window.
32
+ */
33
+ static getDayKey(): string;
34
+ /**
35
+ * The only place that builds a projection key: buildContext and the cache cleanup (getAllProjections) must agree on it.
36
+ */
37
+ createProjectionKey(q: SearchQueryDTO | null): string;
38
+ getProjectionKeyForUser(user: SessionUser): string;
30
39
  buildContext(user: SessionUser): Promise<SessionContext>;
31
40
  getAvailableUserSessions(): Promise<SessionContext[]>;
32
41
  private buildDirectoryFilter;
@@ -1,11 +1,8 @@
1
1
  import * as express from 'express';
2
2
  import { NextFunction, Request, Response } from 'express';
3
- import { UserDTO, UserRoles } from '../../../common/entities/UserDTO';
4
- import { ParamsDictionary } from 'express-serve-static-core';
5
- import { ExtensionRoutePaths, IExtensionRESTApi, IExtensionRESTRoute, IMediaRequestBody } from './IExtension';
3
+ import { UserRoles } from '../../../common/entities/UserDTO';
4
+ import { ExtensionMediaRequest, ExtensionPublicRequest, ExtensionRequest, ExtensionRoutePaths, IExtensionRESTApi, IExtensionRESTRoute, MediaActionArgs } from './IExtension';
6
5
  import { ILogger } from '../../Logger';
7
- import { MediaEntity } from '../database/enitites/MediaEntity';
8
- import { Repository } from 'typeorm';
9
6
  export declare class ExpressRouterWrapper implements IExtensionRESTApi {
10
7
  private readonly router;
11
8
  private readonly name;
@@ -23,9 +20,33 @@ export declare class ExpressRouteWrapper implements IExtensionRESTRoute {
23
20
  private readonly func;
24
21
  private readonly extLogger;
25
22
  constructor(router: express.Router, name: string, func: 'get' | 'use' | 'put' | 'post' | 'delete', extLogger: ILogger);
26
- mediaJsonResponse<const P extends readonly string[]>(paths: ExtensionRoutePaths<P>, minRole: UserRoles, invalidateDirectory: boolean, cb: (params: ParamsDictionary, body: IMediaRequestBody, user: UserDTO, media: MediaEntity, repository: Repository<MediaEntity>) => unknown): string;
27
- jsonResponse<const P extends readonly string[]>(paths: ExtensionRoutePaths<P>, minRole: UserRoles, cb: (params?: ParamsDictionary, body?: unknown, user?: UserDTO) => unknown): string;
28
- rawMiddleware<const P extends readonly string[]>(paths: ExtensionRoutePaths<P>, minRole: UserRoles, mw: (req: Request, res: Response, next: NextFunction) => void | Promise<void>): string;
23
+ mediaJsonResponse<const P extends readonly string[]>(paths: ExtensionRoutePaths<P>, minRole: UserRoles, invalidateDirectory: boolean, cb: (req: ExtensionMediaRequest) => unknown): string;
24
+ /**
25
+ * The route of a UI action (see UIExtension.addAction): loads the media of `body.items` that the user may see
26
+ * and calls the handler once per media, one after the other.
27
+ * Not part of the extension API.
28
+ */
29
+ actionResponse(actionId: string, minRole: UserRoles, invalidateDirectory: boolean, handler: (args: MediaActionArgs<unknown>) => unknown): string;
30
+ jsonResponse<const P extends readonly string[]>(paths: ExtensionRoutePaths<P>, minRole: UserRoles, cb: (req: ExtensionRequest) => unknown): string;
31
+ jsonResponse<const P extends readonly string[]>(paths: ExtensionRoutePaths<P>, minRole: null, cb: (req: ExtensionPublicRequest) => unknown): string;
32
+ rawMiddleware<const P extends readonly string[]>(paths: ExtensionRoutePaths<P>, minRole: UserRoles | null, mw: (req: Request, res: Response, next: NextFunction) => void | Promise<void>): string;
33
+ /**
34
+ * The object the callbacks get. A public route has no session (and no user).
35
+ */
36
+ private request;
37
+ /**
38
+ * An ExtensionError is sent with its status and message; anything else is logged and answered with a generic 500,
39
+ * so no internals reach the client.
40
+ */
41
+ private handleError;
42
+ /**
43
+ * Callbacks get one object since 4.0. One that declares more parameters expects the old positional arguments:
44
+ * it would get the object as `params` and undefined for the rest, so its route is not registered.
45
+ */
46
+ private isObjectCallback;
47
+ private skip;
48
+ private fullPaths;
49
+ private apiPath;
29
50
  /**
30
51
  * Registers the route on the extension's router.
31
52
  * A route that can't be registered (usually an old extension with an Express 4 path) is logged and skipped:
@@ -0,0 +1,54 @@
1
+ import { FindOptionsWhere } from 'typeorm';
2
+ import { ExtensionSession, IExtensionGallery, IExtensionMediaRepository } from './IExtension';
3
+ import { MediaEntity } from '../database/enitites/MediaEntity';
4
+ import { SessionContext } from '../SessionContext';
5
+ import { DirectoryPathDTO, ParentDirectoryDTO } from '../../../common/entities/DirectoryDTO';
6
+ import { PersonDTO } from '../../../common/entities/PersonDTO';
7
+ import { AlbumBaseDTO } from '../../../common/entities/album/AlbumBaseDTO';
8
+ export declare class ExtensionGallery implements IExtensionGallery {
9
+ getMedia(session: ExtensionSession, path: string): Promise<MediaEntity>;
10
+ getMediaList(session: ExtensionSession, paths: string[]): Promise<MediaEntity[]>;
11
+ getMediaRepository(session: ExtensionSession): IExtensionMediaRepository;
12
+ /**
13
+ * Like the app's directory listing (GalleryMWs.listDirectory), but from the DB only: it never reads the disk or indexes.
14
+ */
15
+ getDirectory(session: ExtensionSession, path: string): Promise<ParentDirectoryDTO>;
16
+ getPersons(session: ExtensionSession): Promise<PersonDTO[]>;
17
+ getAlbums(session: ExtensionSession): Promise<AlbumBaseDTO[]>;
18
+ /**
19
+ * The same role setting that guards the app's own route of the data.
20
+ */
21
+ private static requireRole;
22
+ }
23
+ /**
24
+ * Media table access through the projection of a session, see {@link IExtensionMediaRepository}.
25
+ */
26
+ export declare class ExtensionMediaRepository implements IExtensionMediaRepository {
27
+ private readonly context;
28
+ private readonly deferInvalidation;
29
+ private readonly changedDirs;
30
+ /**
31
+ * @param context the session whose projection applies
32
+ * @param deferInvalidation collect the changed directories until {@link invalidateChanged}
33
+ * (a media route invalidates once, after its callback), instead of invalidating after every call
34
+ */
35
+ constructor(context: SessionContext, deferInvalidation?: boolean);
36
+ find(where?: FindOptionsWhere<MediaEntity> | FindOptionsWhere<MediaEntity>[], options?: {
37
+ skip?: number;
38
+ take?: number;
39
+ }): Promise<MediaEntity[]>;
40
+ save(media: MediaEntity | MediaEntity[]): Promise<void>;
41
+ delete(media: MediaEntity | MediaEntity[]): Promise<void>;
42
+ /**
43
+ * Invalidates the caches of the directories that changed since the last call.
44
+ */
45
+ invalidateChanged(...extraDirs: (DirectoryPathDTO & {
46
+ id: number;
47
+ })[]): Promise<void>;
48
+ private static faceNames;
49
+ /**
50
+ * The current DB rows of the media, by id, if the session may see every one of them.
51
+ */
52
+ private loadVisible;
53
+ private changed;
54
+ }
@@ -5,6 +5,7 @@ import { ExtensionObject } from './ExtensionObject';
5
5
  import { ExtensionRepository } from './ExtensionRepository';
6
6
  import { ExtensionListItem } from '../../../common/entities/extension/ExtensionListItem';
7
7
  import { UIExtensionDTO } from '../../../common/entities/extension/IClientUIConfig';
8
+ import { SessionContext } from '../SessionContext';
8
9
  export declare class ExtensionManager implements IObjectManager {
9
10
  static EXTENSION_API_PATH: string;
10
11
  repository: ExtensionRepository;
@@ -50,7 +51,10 @@ export declare class ExtensionManager implements IObjectManager {
50
51
  * An extension folder is a single, plain folder name inside the extension folder.
51
52
  */
52
53
  private static isFolderName;
53
- getUIExtensionConfigs(): UIExtensionDTO[];
54
+ /**
55
+ * The UI contributions that the user of the session may see (nothing without a session, e.g. on the login page).
56
+ */
57
+ getUIExtensionConfigs(session: SessionContext | undefined): UIExtensionDTO[];
54
58
  private initEvents;
55
59
  private createUniqueExtensionObject;
56
60
  /**
@@ -5,6 +5,7 @@ import { ExpressRouterWrapper } from './ExpressRouterWrapper';
5
5
  import { ExtensionMessengerHandler } from './ExtensionMessengerHandler';
6
6
  import { ExtensionConfig } from './ExtensionConfig';
7
7
  import { UIExtension } from './UIExtension';
8
+ import { ExtensionGallery } from './ExtensionGallery';
8
9
  export declare class ExtensionObject<C> implements IExtensionObject<C> {
9
10
  readonly extensionId: string;
10
11
  readonly extensionName: string;
@@ -18,8 +19,11 @@ export declare class ExtensionObject<C> implements IExtensionObject<C> {
18
19
  readonly RESTApi: ExpressRouterWrapper;
19
20
  readonly messengers: ExtensionMessengerHandler;
20
21
  readonly ui: UIExtension<C>;
22
+ readonly gallery: ExtensionGallery;
21
23
  /** The REST API routes of this extension. They go away with this object on clean up. */
22
24
  readonly router: import("express-serve-static-core").Router;
25
+ /** The routes of the UI actions. They come before {@link router}, so the extension's own routes can't shadow them. */
26
+ readonly uiRouter: import("express-serve-static-core").Router;
23
27
  private readonly eventsTracker;
24
28
  /**
25
29
  * @param extensionId - Unique ID used internally to track this extension instance (may have _1, _2 suffix if name collision occurs)
@@ -0,0 +1,12 @@
1
+ import { SessionContext } from '../SessionContext';
2
+ import { ExtensionSession } from './IExtension';
3
+ /**
4
+ * Turns the request's SessionContext into the opaque session that extensions get, and back.
5
+ * The context stays in a WeakMap, so extensions can't read or change the projection, and a session object
6
+ * the app did not create is refused.
7
+ */
8
+ export declare class ExtensionSessions {
9
+ private static readonly contexts;
10
+ static wrap(context: SessionContext): ExtensionSession;
11
+ static unwrap(session: ExtensionSession): SessionContext;
12
+ }