pigallery2-extension-kit 2.6.0-edge → 3.0.0
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.
- package/lib/backend/middlewares/admin/ExtensionMWs.d.ts +2 -0
- package/lib/backend/model/extension/ExtensionConfig.d.ts +5 -2
- package/lib/backend/model/extension/ExtensionConfigTemplateLoader.d.ts +7 -7
- package/lib/backend/model/extension/ExtensionConfigTemplateLoader.js +50 -44
- package/lib/backend/model/extension/ExtensionManager.d.ts +16 -1
- package/lib/backend/model/extension/ExtensionObject.d.ts +7 -0
- package/lib/backend/routes/admin/ExtensionRouter.d.ts +2 -0
- package/lib/common/config/private/PrivateConfig.d.ts +1 -0
- package/lib/common/config/private/PrivateConfig.js +11 -0
- package/lib/frontend/app/ui/albums/albums.component.d.ts +7 -2
- package/lib/frontend/app/ui/settings/extension-installer/extension-installer.service.d.ts +2 -0
- package/lib/frontend/app/ui/settings/template/template.component.d.ts +12 -7
- package/package.json +1 -1
|
@@ -2,4 +2,6 @@ import { NextFunction, Request, Response } from 'express';
|
|
|
2
2
|
export declare class ExtensionMWs {
|
|
3
3
|
static getExtensionList(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
4
4
|
static installExtension(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
5
|
+
static reloadExtension(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
6
|
+
static deleteExtension(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
5
7
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { IExtensionConfig } from './IExtension';
|
|
2
2
|
export declare class ExtensionConfig<C> implements IExtensionConfig<C> {
|
|
3
|
-
private readonly
|
|
4
|
-
|
|
3
|
+
private readonly configKey;
|
|
4
|
+
/**
|
|
5
|
+
* @param configKey - The key used in Config.Extensions.extensions map (matches the extension's folder name)
|
|
6
|
+
*/
|
|
7
|
+
constructor(configKey: string);
|
|
5
8
|
getConfig(): C;
|
|
6
9
|
}
|
|
@@ -6,16 +6,9 @@ import { PrivateConfigClass } from '../../../common/config/private/PrivateConfig
|
|
|
6
6
|
*/
|
|
7
7
|
export declare class ExtensionConfigTemplateLoader {
|
|
8
8
|
private static instance;
|
|
9
|
-
private loaded;
|
|
10
9
|
private extensionList;
|
|
11
10
|
private extensionTemplates;
|
|
12
11
|
static get Instance(): ExtensionConfigTemplateLoader;
|
|
13
|
-
/**
|
|
14
|
-
* Loads a single extension template
|
|
15
|
-
* @param extFolder The folder name of the extension
|
|
16
|
-
* @returns The extension template object if the extension is valid, null otherwise
|
|
17
|
-
*/
|
|
18
|
-
private loadSingleExtensionTemplate;
|
|
19
12
|
/**
|
|
20
13
|
* Loads a single extension template and adds it to the config
|
|
21
14
|
* @param extFolder The folder name of the extension
|
|
@@ -23,5 +16,12 @@ export declare class ExtensionConfigTemplateLoader {
|
|
|
23
16
|
*/
|
|
24
17
|
loadSingleExtension(extFolder: string, config: PrivateConfigClass): void;
|
|
25
18
|
loadExtensionTemplates(config: PrivateConfigClass): void;
|
|
19
|
+
/**
|
|
20
|
+
* Loads a single extension template
|
|
21
|
+
* @param extFolder The folder name of the extension
|
|
22
|
+
* @returns The extension template object if the extension is valid, null otherwise
|
|
23
|
+
*/
|
|
24
|
+
private loadSingleExtensionTemplate;
|
|
25
|
+
private getExtensionFolders;
|
|
26
26
|
private setTemplatesToConfig;
|
|
27
27
|
}
|
|
@@ -5,6 +5,7 @@ const fs = require("fs");
|
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const ServerExtensionsConfig_1 = require("../../../common/config/private/subconfigs/ServerExtensionsConfig");
|
|
7
7
|
const ProjectPath_1 = require("../../ProjectPath");
|
|
8
|
+
const Utils_1 = require("../../../common/Utils");
|
|
8
9
|
/**
|
|
9
10
|
* This class decouples the extension management and the config.
|
|
10
11
|
* It helps to solve the "chicken and the egg" which should load first:
|
|
@@ -12,7 +13,6 @@ const ProjectPath_1 = require("../../ProjectPath");
|
|
|
12
13
|
*/
|
|
13
14
|
class ExtensionConfigTemplateLoader {
|
|
14
15
|
constructor() {
|
|
15
|
-
this.loaded = false;
|
|
16
16
|
this.extensionList = [];
|
|
17
17
|
this.extensionTemplates = [];
|
|
18
18
|
}
|
|
@@ -22,36 +22,6 @@ class ExtensionConfigTemplateLoader {
|
|
|
22
22
|
}
|
|
23
23
|
return this.instance;
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Loads a single extension template
|
|
27
|
-
* @param extFolder The folder name of the extension
|
|
28
|
-
* @returns The extension template object if the extension is valid, null otherwise
|
|
29
|
-
*/
|
|
30
|
-
loadSingleExtensionTemplate(extFolder) {
|
|
31
|
-
if (!ProjectPath_1.ProjectPath.ExtensionFolder) {
|
|
32
|
-
throw new Error('Unknown extensions folder.');
|
|
33
|
-
}
|
|
34
|
-
const extPath = path.join(ProjectPath_1.ProjectPath.ExtensionFolder, extFolder);
|
|
35
|
-
const configExtPath = path.join(extPath, 'config.js');
|
|
36
|
-
const serverExtPath = path.join(extPath, 'server.js');
|
|
37
|
-
// if server.js is missing, it's not a valid extension
|
|
38
|
-
if (!fs.existsSync(serverExtPath)) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
let template = { folder: extFolder };
|
|
42
|
-
if (fs.existsSync(configExtPath)) {
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
44
|
-
const extCfg = require(configExtPath);
|
|
45
|
-
if (typeof extCfg?.initConfig === 'function') {
|
|
46
|
-
extCfg?.initConfig({
|
|
47
|
-
setConfigTemplate: (templateClass) => {
|
|
48
|
-
template = { folder: extFolder, template: templateClass };
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return template;
|
|
54
|
-
}
|
|
55
25
|
/**
|
|
56
26
|
* Loads a single extension template and adds it to the config
|
|
57
27
|
* @param extFolder The folder name of the extension
|
|
@@ -84,26 +54,62 @@ class ExtensionConfigTemplateLoader {
|
|
|
84
54
|
if (!ProjectPath_1.ProjectPath.ExtensionFolder) {
|
|
85
55
|
throw new Error('Unknown extensions folder.');
|
|
86
56
|
}
|
|
57
|
+
if (!fs.existsSync(ProjectPath_1.ProjectPath.ExtensionFolder)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const newList = this.getExtensionFolders();
|
|
61
|
+
const loaded = Utils_1.Utils.equalsFilter(this.extensionList, newList);
|
|
62
|
+
this.extensionList = newList;
|
|
87
63
|
// already loaded
|
|
88
|
-
if (!
|
|
64
|
+
if (!loaded) {
|
|
89
65
|
this.extensionTemplates = [];
|
|
90
|
-
|
|
91
|
-
this.extensionList
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
for (let i = 0; i < this.extensionList.length; ++i) {
|
|
96
|
-
const extFolder = this.extensionList[i];
|
|
97
|
-
const template = this.loadSingleExtensionTemplate(extFolder);
|
|
98
|
-
if (template) {
|
|
99
|
-
this.extensionTemplates.push(template);
|
|
100
|
-
}
|
|
66
|
+
for (let i = 0; i < this.extensionList.length; ++i) {
|
|
67
|
+
const extFolder = this.extensionList[i];
|
|
68
|
+
const template = this.loadSingleExtensionTemplate(extFolder);
|
|
69
|
+
if (template) {
|
|
70
|
+
this.extensionTemplates.push(template);
|
|
101
71
|
}
|
|
102
72
|
}
|
|
103
|
-
this.loaded = true;
|
|
104
73
|
}
|
|
105
74
|
this.setTemplatesToConfig(config);
|
|
106
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Loads a single extension template
|
|
78
|
+
* @param extFolder The folder name of the extension
|
|
79
|
+
* @returns The extension template object if the extension is valid, null otherwise
|
|
80
|
+
*/
|
|
81
|
+
loadSingleExtensionTemplate(extFolder) {
|
|
82
|
+
if (!ProjectPath_1.ProjectPath.ExtensionFolder) {
|
|
83
|
+
throw new Error('Unknown extensions folder.');
|
|
84
|
+
}
|
|
85
|
+
const extPath = path.join(ProjectPath_1.ProjectPath.ExtensionFolder, extFolder);
|
|
86
|
+
const configExtPath = path.join(extPath, 'config.js');
|
|
87
|
+
const serverExtPath = path.join(extPath, 'server.js');
|
|
88
|
+
// if server.js is missing, it's not a valid extension
|
|
89
|
+
if (!fs.existsSync(serverExtPath)) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
let template = { folder: extFolder };
|
|
93
|
+
if (fs.existsSync(configExtPath)) {
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
95
|
+
const extCfg = require(configExtPath);
|
|
96
|
+
if (typeof extCfg?.initConfig === 'function') {
|
|
97
|
+
extCfg?.initConfig({
|
|
98
|
+
setConfigTemplate: (templateClass) => {
|
|
99
|
+
template = { folder: extFolder, template: templateClass };
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return template;
|
|
105
|
+
}
|
|
106
|
+
getExtensionFolders() {
|
|
107
|
+
const list = (fs
|
|
108
|
+
.readdirSync(ProjectPath_1.ProjectPath.ExtensionFolder))
|
|
109
|
+
.filter((f) => fs.statSync(path.join(ProjectPath_1.ProjectPath.ExtensionFolder, f)).isDirectory());
|
|
110
|
+
list.sort();
|
|
111
|
+
return list;
|
|
112
|
+
}
|
|
107
113
|
setTemplatesToConfig(config) {
|
|
108
114
|
if (!this.extensionTemplates) {
|
|
109
115
|
return;
|
|
@@ -17,13 +17,27 @@ export declare class ExtensionManager implements IObjectManager {
|
|
|
17
17
|
init(): Promise<void>;
|
|
18
18
|
getExtensionListWithInstallStatus(): Promise<ExtensionListItem[]>;
|
|
19
19
|
cleanUp(): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Install an extension from the repository
|
|
22
|
+
* @param extensionId - The repository extension ID (not to be confused with the unique internal extensionId used in extObjects)
|
|
23
|
+
*/
|
|
20
24
|
installExtension(extensionId: string): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Reload an extension by cleaning up and re-initializing it
|
|
27
|
+
* @param configKey - The key used in Config.Extensions.extensions map (typically the folder name)
|
|
28
|
+
*/
|
|
29
|
+
reloadExtension(configKey: string): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Delete an extension by cleaning up, removing its folder, and removing it from configuration
|
|
32
|
+
* @param configKey - The key used in Config.Extensions.extensions map (typically the folder name)
|
|
33
|
+
*/
|
|
34
|
+
deleteExtension(configKey: string): Promise<void>;
|
|
21
35
|
getUIExtensionConfigs(): UIExtensionDTO[];
|
|
22
36
|
private initEvents;
|
|
23
37
|
private createUniqueExtensionObject;
|
|
24
38
|
/**
|
|
25
39
|
* Initialize a single extension
|
|
26
|
-
* @param
|
|
40
|
+
* @param configKey The key used in Config.Extensions.extensions map (typically the folder name)
|
|
27
41
|
* @returns Promise that resolves when the extension is initialized
|
|
28
42
|
*/
|
|
29
43
|
private initSingleExtension;
|
|
@@ -31,6 +45,7 @@ export declare class ExtensionManager implements IObjectManager {
|
|
|
31
45
|
* Initialize all extensions
|
|
32
46
|
*/
|
|
33
47
|
private initExtensions;
|
|
48
|
+
private cleanUpSingleExtension;
|
|
34
49
|
private cleanUpExtensions;
|
|
35
50
|
private downloadFile;
|
|
36
51
|
private unzipFile;
|
|
@@ -19,5 +19,12 @@ export declare class ExtensionObject<C> implements IExtensionObject<C> {
|
|
|
19
19
|
readonly RESTApi: ExpressRouterWrapper;
|
|
20
20
|
readonly messengers: ExtensionMessengerHandler;
|
|
21
21
|
readonly ui: UIExtension<C>;
|
|
22
|
+
/**
|
|
23
|
+
* @param extensionId - Unique ID used internally to track this extension instance (may have _1, _2 suffix if name collision occurs)
|
|
24
|
+
* @param extensionName - Display name of the extension (typically from package.json)
|
|
25
|
+
* @param folder - Folder name where the extension is stored (also used as config key in Config.Extensions.extensions)
|
|
26
|
+
* @param extensionRouter - Express router for extension REST API endpoints
|
|
27
|
+
* @param events - Extension events for hooking into gallery functionality
|
|
28
|
+
*/
|
|
22
29
|
constructor(extensionId: string, extensionName: string, folder: string, extensionRouter: express.Router, events: IExtensionEvents);
|
|
23
30
|
}
|
|
@@ -72,6 +72,7 @@ export declare class ServerUserConfig extends ClientUserConfig {
|
|
|
72
72
|
enforcedUsers: UserConfig[];
|
|
73
73
|
allowQuery: SearchQueryDTO;
|
|
74
74
|
blockQuery: SearchQueryDTO;
|
|
75
|
+
suppressDefUserWarn: boolean;
|
|
75
76
|
}
|
|
76
77
|
export declare class ServerPhotoConfig extends ClientPhotoConfig {
|
|
77
78
|
useLanczos3: boolean;
|
|
@@ -285,6 +285,7 @@ let ServerUserConfig = class ServerUserConfig extends ClientConfig_1.ClientUserC
|
|
|
285
285
|
type: SearchQueryDTO_1.SearchQueryTypes.any_text,
|
|
286
286
|
text: '',
|
|
287
287
|
};
|
|
288
|
+
this.suppressDefUserWarn = false;
|
|
288
289
|
}
|
|
289
290
|
};
|
|
290
291
|
exports.ServerUserConfig = ServerUserConfig;
|
|
@@ -328,6 +329,16 @@ tslib_1.__decorate([
|
|
|
328
329
|
}),
|
|
329
330
|
tslib_1.__metadata("design:type", Object)
|
|
330
331
|
], ServerUserConfig.prototype, "blockQuery", void 0);
|
|
332
|
+
tslib_1.__decorate([
|
|
333
|
+
(0, common_1.ConfigProperty)({
|
|
334
|
+
tags: {
|
|
335
|
+
name: $localize `Suppress default user warning`,
|
|
336
|
+
priority: ClientConfig_1.ConfigPriority.underTheHood
|
|
337
|
+
},
|
|
338
|
+
description: $localize `if true, the app won't show a warning for using the default user.`
|
|
339
|
+
}),
|
|
340
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
341
|
+
], ServerUserConfig.prototype, "suppressDefUserWarn", void 0);
|
|
331
342
|
exports.ServerUserConfig = ServerUserConfig = tslib_1.__decorate([
|
|
332
343
|
(0, common_1.SubConfigClass)({ softReadonly: true })
|
|
333
344
|
], ServerUserConfig);
|
|
@@ -4,11 +4,16 @@ import { BsModalService } from 'ngx-bootstrap/modal';
|
|
|
4
4
|
import { TextSearch } from '../../../../common/entities/SearchQueryDTO';
|
|
5
5
|
import { AuthenticationService } from '../../model/network/authentication.service';
|
|
6
6
|
import { PiTitleService } from '../../model/pi-title.service';
|
|
7
|
+
import { ShareService } from '../gallery/share.service';
|
|
8
|
+
import { NavigationService } from '../../model/navigation.service';
|
|
7
9
|
export declare class AlbumsComponent implements OnInit {
|
|
8
10
|
albumsService: AlbumsService;
|
|
9
11
|
private modalService;
|
|
10
12
|
authenticationService: AuthenticationService;
|
|
11
13
|
private piTitleService;
|
|
14
|
+
private shareService;
|
|
15
|
+
private authService;
|
|
16
|
+
private navigation;
|
|
12
17
|
container: ElementRef;
|
|
13
18
|
size: number;
|
|
14
19
|
savedSearch: {
|
|
@@ -16,9 +21,9 @@ export declare class AlbumsComponent implements OnInit {
|
|
|
16
21
|
searchQuery: TextSearch;
|
|
17
22
|
};
|
|
18
23
|
private modalRef;
|
|
19
|
-
constructor(albumsService: AlbumsService, modalService: BsModalService, authenticationService: AuthenticationService, piTitleService: PiTitleService);
|
|
20
|
-
ngOnInit(): void;
|
|
24
|
+
constructor(albumsService: AlbumsService, modalService: BsModalService, authenticationService: AuthenticationService, piTitleService: PiTitleService, shareService: ShareService, authService: AuthenticationService, navigation: NavigationService);
|
|
21
25
|
get CanCreateAlbum(): boolean;
|
|
26
|
+
ngOnInit(): Promise<boolean>;
|
|
22
27
|
openModal(template: TemplateRef<any>): Promise<void>;
|
|
23
28
|
hideModal(): void;
|
|
24
29
|
saveSearch(): Promise<void>;
|
|
@@ -5,4 +5,6 @@ export declare class ExtensionInstallerService {
|
|
|
5
5
|
constructor(networkService: NetworkService);
|
|
6
6
|
getExtensions(): Promise<Array<ExtensionListItem>>;
|
|
7
7
|
installExtension(extensionId: string): Promise<void>;
|
|
8
|
+
reloadExtension(extensionPath: string): Promise<void>;
|
|
9
|
+
deleteExtension(extensionPath: string): Promise<void>;
|
|
8
10
|
}
|
|
@@ -10,6 +10,7 @@ import { UntypedFormControl } from '@angular/forms';
|
|
|
10
10
|
import { IWebConfigClassPrivate } from 'typeconfig/src/decorators/class/IWebConfigClass';
|
|
11
11
|
import { TAGS } from '../../../../../common/config/public/ClientConfig';
|
|
12
12
|
import { ISettingsComponent } from './ISettingsComponent';
|
|
13
|
+
import { ExtensionInstallerService } from '../extension-installer/extension-installer.service';
|
|
13
14
|
interface ConfigState {
|
|
14
15
|
value: {
|
|
15
16
|
[key: string]: RecursiveState;
|
|
@@ -45,6 +46,7 @@ export declare class TemplateComponent implements OnInit, OnChanges, OnDestroy,
|
|
|
45
46
|
protected notification: NotificationService;
|
|
46
47
|
settingsService: SettingsService;
|
|
47
48
|
jobsService: ScheduledJobsService;
|
|
49
|
+
private extensionService;
|
|
48
50
|
icon: string;
|
|
49
51
|
ConfigPath: string;
|
|
50
52
|
nestedConfigs: {
|
|
@@ -58,19 +60,19 @@ export declare class TemplateComponent implements OnInit, OnChanges, OnDestroy,
|
|
|
58
60
|
error: string;
|
|
59
61
|
changed: boolean;
|
|
60
62
|
states: RecursiveState;
|
|
63
|
+
readonly ConfigStyle: typeof ConfigStyle;
|
|
61
64
|
protected name: string;
|
|
65
|
+
protected sliceFN?: (s: IWebConfigClassPrivate<TAGS> & WebConfig) => ConfigState;
|
|
62
66
|
private subscription;
|
|
63
67
|
private settingsSubscription;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
constructor(authService: AuthenticationService, navigation: NavigationService, notification: NotificationService, settingsService: SettingsService, jobsService: ScheduledJobsService, extensionService: ExtensionInstallerService);
|
|
69
|
+
get Name(): string;
|
|
70
|
+
get Changed(): boolean;
|
|
71
|
+
get HasAvailableSettings(): boolean;
|
|
67
72
|
ngOnChanges(): void;
|
|
68
73
|
ngOnInit(): void;
|
|
69
74
|
ngOnDestroy(): void;
|
|
70
75
|
setSliceFN(sliceFN?: (s: IWebConfigClassPrivate<TAGS> & WebConfig) => ConfigState): void;
|
|
71
|
-
get Name(): string;
|
|
72
|
-
get Changed(): boolean;
|
|
73
|
-
get HasAvailableSettings(): boolean;
|
|
74
76
|
onNewSettings: (s: IWebConfigClassPrivate<TAGS> & WebConfig) => void;
|
|
75
77
|
onOptionChange: () => void;
|
|
76
78
|
reset(): void;
|
|
@@ -81,11 +83,14 @@ export declare class TemplateComponent implements OnInit, OnChanges, OnDestroy,
|
|
|
81
83
|
isExpandableConfig(c: ConfigState): boolean;
|
|
82
84
|
isExpandableArrayConfig(c: ConfigState): boolean;
|
|
83
85
|
save(): Promise<boolean>;
|
|
84
|
-
private getSettings;
|
|
85
86
|
getKeys(states: any): string[];
|
|
86
87
|
getProgress(uiJob: {
|
|
87
88
|
job: string;
|
|
88
89
|
config?: any;
|
|
89
90
|
}): JobProgressDTO;
|
|
91
|
+
protected isExtension(c: ConfigState): boolean;
|
|
92
|
+
protected removeExtension(c: ConfigState): Promise<void>;
|
|
93
|
+
protected reloadExtension(c: ConfigState): Promise<void>;
|
|
94
|
+
private getSettings;
|
|
90
95
|
}
|
|
91
96
|
export {};
|
package/package.json
CHANGED