pigallery2-extension-kit 2.0.3-edge6 → 2.0.3-edge7
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/Logger.d.ts +3 -2
- package/lib/backend/model/extension/ExtensionConfigTemplateLoader.js +32 -22
- package/lib/backend/model/extension/ExtensionConfigWrapper.d.ts +2 -2
- package/lib/backend/model/extension/ExtensionConfigWrapper.js +21 -8
- package/lib/backend/model/extension/IExtension.d.ts +13 -6
- package/lib/backend/model/fileaccess/MetadataLoader.d.ts +12 -0
- package/lib/backend/routes/LoggerRouter.d.ts +2 -2
- package/lib/backend/server.d.ts +4 -2
- package/lib/common/HTMLCharCodes.d.ts +5 -0
- package/lib/common/HTMLCharCodes.js +117 -0
- package/lib/common/Utils.d.ts +9 -0
- package/lib/common/Utils.js +131 -2
- package/lib/common/config/private/Config.js +4 -2
- package/lib/common/config/private/subconfigs/ServerExtensionsConfig.js +2 -0
- package/lib/common/entities/MediaDTO.d.ts +0 -10
- package/package.json +1 -1
- package/lib/backend/middlewares/thumbnail/PhotoConverterMWs.d.ts +0 -4
- package/lib/backend/model/jobs/jobs/ThumbnailGenerationJob.d.ts +0 -18
- package/lib/common/config/private/MessagingConfig.d.ts +0 -15
- package/lib/common/config/private/MessagingConfig.js +0 -134
package/lib/backend/Logger.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export declare type LoggerArgs = (string | number | (() => string));
|
|
1
|
+
import { ErrorCodes } from '../common/entities/Error';
|
|
2
|
+
export declare type LoggerArgs = (string | number | (() => string) | Record<any, unknown> | Error);
|
|
3
3
|
export declare type LoggerFunction = (...args: LoggerArgs[]) => void;
|
|
4
4
|
export interface ILogger {
|
|
5
5
|
silly: LoggerFunction;
|
|
@@ -18,4 +18,5 @@ export declare class Logger {
|
|
|
18
18
|
static warn(...args: LoggerArgs[]): void;
|
|
19
19
|
static error(...args: LoggerArgs[]): void;
|
|
20
20
|
private static log;
|
|
21
|
+
static logLevelForError(e: ErrorCodes): LoggerFunction;
|
|
21
22
|
}
|
|
@@ -4,6 +4,8 @@ exports.ExtensionConfigTemplateLoader = void 0;
|
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const ServerExtensionsConfig_1 = require("../../../common/config/private/subconfigs/ServerExtensionsConfig");
|
|
7
|
+
const child_process = require("child_process");
|
|
8
|
+
const execSync = child_process.execSync;
|
|
7
9
|
const LOG_TAG = '[ExtensionConfigTemplateLoader]';
|
|
8
10
|
/**
|
|
9
11
|
* This class decouples the extension management and the config.
|
|
@@ -31,30 +33,36 @@ class ExtensionConfigTemplateLoader {
|
|
|
31
33
|
}
|
|
32
34
|
// already loaded
|
|
33
35
|
if (!this.loaded) {
|
|
34
|
-
this.extensionList = (fs
|
|
35
|
-
.readdirSync(this.extensionsFolder))
|
|
36
|
-
.filter((f) => fs.statSync(path.join(this.extensionsFolder, f)).isDirectory());
|
|
37
|
-
this.extensionList.sort();
|
|
38
36
|
this.extensionTemplates = [];
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
37
|
+
if (fs.existsSync(this.extensionsFolder)) {
|
|
38
|
+
this.extensionList = (fs
|
|
39
|
+
.readdirSync(this.extensionsFolder))
|
|
40
|
+
.filter((f) => fs.statSync(path.join(this.extensionsFolder, f)).isDirectory());
|
|
41
|
+
this.extensionList.sort();
|
|
42
|
+
for (let i = 0; i < this.extensionList.length; ++i) {
|
|
43
|
+
const extFolder = this.extensionList[i];
|
|
44
|
+
const extPath = path.join(this.extensionsFolder, extFolder);
|
|
45
|
+
const configExtPath = path.join(extPath, 'config.js');
|
|
46
|
+
const serverExtPath = path.join(extPath, 'server.js');
|
|
47
|
+
// if server.js is missing, it's not a valid extension
|
|
48
|
+
if (!fs.existsSync(serverExtPath)) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (fs.existsSync(configExtPath)) {
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
53
|
+
const extCfg = require(configExtPath);
|
|
54
|
+
if (typeof extCfg?.initConfig === 'function') {
|
|
55
|
+
extCfg?.initConfig({
|
|
56
|
+
setConfigTemplate: (template) => {
|
|
57
|
+
this.extensionTemplates.push({ folder: extFolder, template: template });
|
|
58
|
+
}
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
//also create basic config extensions that do not have any
|
|
64
|
+
this.extensionTemplates.push({ folder: extFolder });
|
|
65
|
+
}
|
|
58
66
|
}
|
|
59
67
|
}
|
|
60
68
|
this.loaded = true;
|
|
@@ -79,6 +87,8 @@ class ExtensionConfigTemplateLoader {
|
|
|
79
87
|
if (ext.template) {
|
|
80
88
|
c.configs = new ext.template();
|
|
81
89
|
}
|
|
90
|
+
// TODO: this does not hold if the order of the extensions mixes up.
|
|
91
|
+
// TODO: experiment with a map instead of an array
|
|
82
92
|
config.Extensions.extensions.push(c);
|
|
83
93
|
}
|
|
84
94
|
}
|
|
@@ -4,6 +4,6 @@ import { PrivateConfigClass } from '../../../common/config/private/PrivateConfig
|
|
|
4
4
|
* Wraps to original config and makes sure all extension related config is loaded
|
|
5
5
|
*/
|
|
6
6
|
export declare class ExtensionConfigWrapper {
|
|
7
|
-
static original(
|
|
8
|
-
static originalSync(
|
|
7
|
+
static original(showDetailedError?: boolean): Promise<PrivateConfigClass & IConfigClass>;
|
|
8
|
+
static originalSync(showDetailedError?: boolean): PrivateConfigClass & IConfigClass;
|
|
9
9
|
}
|
|
@@ -5,38 +5,51 @@ const PrivateConfigClass_1 = require("../../../common/config/private/PrivateConf
|
|
|
5
5
|
const node_1 = require("typeconfig/node");
|
|
6
6
|
const ExtensionConfigTemplateLoader_1 = require("./ExtensionConfigTemplateLoader");
|
|
7
7
|
const NotifocationManager_1 = require("../NotifocationManager");
|
|
8
|
+
const fs = require("fs");
|
|
8
9
|
const LOG_TAG = '[ExtensionConfigWrapper]';
|
|
9
10
|
/**
|
|
10
11
|
* Wraps to original config and makes sure all extension related config is loaded
|
|
11
12
|
*/
|
|
12
13
|
class ExtensionConfigWrapper {
|
|
13
|
-
static async original(
|
|
14
|
+
static async original(showDetailedError = false) {
|
|
14
15
|
const pc = node_1.ConfigClassBuilder.attachPrivateInterface(new PrivateConfigClass_1.PrivateConfigClass());
|
|
15
16
|
ExtensionConfigTemplateLoader_1.ExtensionConfigTemplateLoader.Instance.loadExtensionTemplates(pc);
|
|
16
17
|
try {
|
|
18
|
+
// make sure the config file exists by the time we load it.
|
|
19
|
+
// TODO: remove this once typeconfig is fixed and can properly load defaults in arrays
|
|
20
|
+
if (!fs.existsSync(pc.__options.configPath)) {
|
|
21
|
+
await pc.save();
|
|
22
|
+
}
|
|
17
23
|
await pc.load(); // loading the basic configs, but we do not know the extension config hierarchy yet
|
|
24
|
+
// TODO make sure that all extensions are present even after loading them from file
|
|
18
25
|
}
|
|
19
26
|
catch (e) {
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
console.error(LOG_TAG, 'Error during loading config. Reverting to defaults.');
|
|
28
|
+
console.error(e);
|
|
29
|
+
if (showDetailedError) {
|
|
22
30
|
console.error(LOG_TAG, 'This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.');
|
|
23
|
-
console.error(e);
|
|
24
31
|
NotifocationManager_1.NotificationManager.error('Can\'t load config. Reverting to default. This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.', (e.toString ? e.toString() : JSON.stringify(e)));
|
|
25
32
|
}
|
|
26
33
|
}
|
|
27
34
|
return pc;
|
|
28
35
|
}
|
|
29
|
-
static originalSync(
|
|
36
|
+
static originalSync(showDetailedError = false) {
|
|
30
37
|
const pc = node_1.ConfigClassBuilder.attachPrivateInterface(new PrivateConfigClass_1.PrivateConfigClass());
|
|
31
38
|
ExtensionConfigTemplateLoader_1.ExtensionConfigTemplateLoader.Instance.loadExtensionTemplates(pc);
|
|
32
39
|
try {
|
|
40
|
+
// make sure the config file exists by the time we load it.
|
|
41
|
+
// TODO: remove this once typeconfig is fixed and can properly load defaults in arrays
|
|
42
|
+
if (!fs.existsSync(pc.__options.configPath)) {
|
|
43
|
+
pc.saveSync();
|
|
44
|
+
}
|
|
33
45
|
pc.loadSync(); // loading the basic configs, but we do not know the extension config hierarchy yet
|
|
46
|
+
// TODO make sure that all extensions are present even after loading them from file
|
|
34
47
|
}
|
|
35
48
|
catch (e) {
|
|
36
|
-
|
|
37
|
-
|
|
49
|
+
console.error(LOG_TAG, 'Error during loading config. Reverting to defaults.');
|
|
50
|
+
console.error(e);
|
|
51
|
+
if (showDetailedError) {
|
|
38
52
|
console.error(LOG_TAG, 'This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.');
|
|
39
|
-
console.error(e);
|
|
40
53
|
NotifocationManager_1.NotificationManager.error('Ca\'nt load config. Reverting to default. This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.', (e.toString ? e.toString() : JSON.stringify(e)));
|
|
41
54
|
}
|
|
42
55
|
}
|
|
@@ -202,14 +202,10 @@ export interface IExtensionConfigInit<C> {
|
|
|
202
202
|
setConfigTemplate(template: new () => C): void;
|
|
203
203
|
}
|
|
204
204
|
/**
|
|
205
|
-
* Extension interface. All extension is expected to implement and export these methods
|
|
205
|
+
* Extension interface. All extension is expected to implement and export these methods.
|
|
206
|
+
* This is the content of the server.js file
|
|
206
207
|
*/
|
|
207
208
|
export interface IServerExtension<C> {
|
|
208
|
-
/**
|
|
209
|
-
* This function can be called any time. It should only set the config template class
|
|
210
|
-
* @param extension
|
|
211
|
-
*/
|
|
212
|
-
initConfig(extension: IExtensionConfigInit<C>): void;
|
|
213
209
|
/**
|
|
214
210
|
* Extension init function. Extension should at minimum expose this function.
|
|
215
211
|
* @param extension
|
|
@@ -217,3 +213,14 @@ export interface IServerExtension<C> {
|
|
|
217
213
|
init(extension: IExtensionObject<C>): Promise<void>;
|
|
218
214
|
cleanUp?: (extension: IExtensionObject<C>) => Promise<void>;
|
|
219
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Extension config interface. All extension can implement and export these methods.
|
|
218
|
+
* This is the content of the config.js file.
|
|
219
|
+
*/
|
|
220
|
+
export interface IServerExtensionConfig<C> {
|
|
221
|
+
/**
|
|
222
|
+
* This function can be called any time. It should only set the config template class
|
|
223
|
+
* @param extension
|
|
224
|
+
*/
|
|
225
|
+
initConfig(extension: IExtensionConfigInit<C>): void;
|
|
226
|
+
}
|
|
@@ -4,4 +4,16 @@ export declare class MetadataLoader {
|
|
|
4
4
|
static loadVideoMetadata(fullPath: string): Promise<VideoMetadata>;
|
|
5
5
|
private static readonly EMPTY_METADATA;
|
|
6
6
|
static loadPhotoMetadata(fullPath: string): Promise<PhotoMetadata>;
|
|
7
|
+
private static mapMetadata;
|
|
8
|
+
private static getOrientation;
|
|
9
|
+
private static mapImageDimensions;
|
|
10
|
+
private static mapKeywords;
|
|
11
|
+
private static mapTitle;
|
|
12
|
+
private static mapCaption;
|
|
13
|
+
private static mapTimestampAndOffset;
|
|
14
|
+
private static mapCameraData;
|
|
15
|
+
private static mapGPS;
|
|
16
|
+
private static mapToponyms;
|
|
17
|
+
private static mapRating;
|
|
18
|
+
private static mapFaces;
|
|
7
19
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Express, Request, Response } from 'express';
|
|
2
|
-
import {
|
|
2
|
+
import { LoggerFunction } from '../Logger';
|
|
3
3
|
declare global {
|
|
4
4
|
namespace Express {
|
|
5
5
|
interface Request {
|
|
@@ -12,6 +12,6 @@ declare global {
|
|
|
12
12
|
* Adds logging to express
|
|
13
13
|
*/
|
|
14
14
|
export declare class LoggerRouter {
|
|
15
|
-
static log(loggerFn:
|
|
15
|
+
static log(loggerFn: LoggerFunction, req: Request, res: Response): void;
|
|
16
16
|
static route(app: Express): void;
|
|
17
17
|
}
|
package/lib/backend/server.d.ts
CHANGED
|
@@ -8,9 +8,10 @@ export declare class Server {
|
|
|
8
8
|
private server;
|
|
9
9
|
static instance: Server;
|
|
10
10
|
static getInstance(): Server;
|
|
11
|
-
constructor();
|
|
11
|
+
constructor(listen?: boolean);
|
|
12
12
|
get Server(): HttpServer;
|
|
13
|
-
init(): Promise<void>;
|
|
13
|
+
init(listen?: boolean): Promise<void>;
|
|
14
|
+
private SIGTERM;
|
|
14
15
|
/**
|
|
15
16
|
* Event listener for HTTP server "error" event.
|
|
16
17
|
*/
|
|
@@ -23,4 +24,5 @@ export declare class Server {
|
|
|
23
24
|
* Event listener for HTTP server "close" event.
|
|
24
25
|
*/
|
|
25
26
|
private onClose;
|
|
27
|
+
Stop(): Promise<void>;
|
|
26
28
|
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HTMLChar = void 0;
|
|
4
|
+
exports.HTMLChar = {
|
|
5
|
+
""": "\"",
|
|
6
|
+
"&": "&",
|
|
7
|
+
"<": "<",
|
|
8
|
+
">": ">",
|
|
9
|
+
" ": " ",
|
|
10
|
+
"¡": "¡",
|
|
11
|
+
"¢": "¢",
|
|
12
|
+
"£": "£",
|
|
13
|
+
"¤": "¤",
|
|
14
|
+
"¥": "¥",
|
|
15
|
+
"¦": "¦",
|
|
16
|
+
"§": "§",
|
|
17
|
+
"¨": "¨",
|
|
18
|
+
"©": "©",
|
|
19
|
+
"®": "®",
|
|
20
|
+
"™": "™",
|
|
21
|
+
"ª": "ª",
|
|
22
|
+
"«": "«",
|
|
23
|
+
"¬": "¬",
|
|
24
|
+
"­": "",
|
|
25
|
+
"¯": "¯",
|
|
26
|
+
"°": "°",
|
|
27
|
+
"±": "±",
|
|
28
|
+
"²": "²",
|
|
29
|
+
"³": "³",
|
|
30
|
+
"´": "´",
|
|
31
|
+
"µ": "µ",
|
|
32
|
+
"¶": "¶",
|
|
33
|
+
"·": "·",
|
|
34
|
+
"¸": "¸",
|
|
35
|
+
"¹": "¹",
|
|
36
|
+
"º": "º",
|
|
37
|
+
"»": "»",
|
|
38
|
+
"¼": "¼",
|
|
39
|
+
"½": "½",
|
|
40
|
+
"¾": "¾",
|
|
41
|
+
"¿": "¿",
|
|
42
|
+
"×": "×",
|
|
43
|
+
"÷": "÷",
|
|
44
|
+
"Ð": "Ð",
|
|
45
|
+
"ð": "ð",
|
|
46
|
+
"Þ": "Þ",
|
|
47
|
+
"þ": "þ",
|
|
48
|
+
"Æ": "Æ",
|
|
49
|
+
"æ": "æ",
|
|
50
|
+
"Œ": "Œ",
|
|
51
|
+
"œ": "œ",
|
|
52
|
+
"Å": "Å",
|
|
53
|
+
"Ø": "Ø",
|
|
54
|
+
"Ç": "Ç",
|
|
55
|
+
"ç": "ç",
|
|
56
|
+
"ß": "ß",
|
|
57
|
+
"Ñ": "Ñ",
|
|
58
|
+
"ñ": "ñ",
|
|
59
|
+
"Á": "Á",
|
|
60
|
+
"À": "À",
|
|
61
|
+
"Â": "Â",
|
|
62
|
+
"Ä": "Ä",
|
|
63
|
+
"Ã": "Ã",
|
|
64
|
+
"á": "á",
|
|
65
|
+
"à": "à",
|
|
66
|
+
"â": "â",
|
|
67
|
+
"ä": "ä",
|
|
68
|
+
"ã": "ã",
|
|
69
|
+
"å": "å",
|
|
70
|
+
"É": "É",
|
|
71
|
+
"È": "È",
|
|
72
|
+
"Ê": "Ê",
|
|
73
|
+
"Ë": "Ë",
|
|
74
|
+
"&Etilde;": "Ẽ",
|
|
75
|
+
"é": "é",
|
|
76
|
+
"è": "è",
|
|
77
|
+
"ê": "ê",
|
|
78
|
+
"ë": "ë",
|
|
79
|
+
"Í": "Í",
|
|
80
|
+
"Ì": "Ì",
|
|
81
|
+
"Î": "Î",
|
|
82
|
+
"Ï": "Ï",
|
|
83
|
+
"Ĩ": "Ĩ",
|
|
84
|
+
"í": "í",
|
|
85
|
+
"ì": "ì",
|
|
86
|
+
"î": "î",
|
|
87
|
+
"ï": "ï",
|
|
88
|
+
"ĩ": "ĩ",
|
|
89
|
+
"Ó": "Ó",
|
|
90
|
+
"Ò": "Ò",
|
|
91
|
+
"Ô": "Ô",
|
|
92
|
+
"Ö": "Ö",
|
|
93
|
+
"Õ": "Õ",
|
|
94
|
+
"ó": "ó",
|
|
95
|
+
"ò": "ò",
|
|
96
|
+
"ô": "ô",
|
|
97
|
+
"ö": "ö",
|
|
98
|
+
"õ": "õ",
|
|
99
|
+
"Ú": "Ú",
|
|
100
|
+
"Ù": "Ù",
|
|
101
|
+
"Û": "Û",
|
|
102
|
+
"Ü": "Ü",
|
|
103
|
+
"Ũ": "Ũ",
|
|
104
|
+
"Ů": "Ů",
|
|
105
|
+
"ú": "ú",
|
|
106
|
+
"ù": "ù",
|
|
107
|
+
"û": "û",
|
|
108
|
+
"ü": "ü",
|
|
109
|
+
"ũ": "ũ",
|
|
110
|
+
"ů": "ů",
|
|
111
|
+
"Ý": "Ý",
|
|
112
|
+
"Ŷ": "Ŷ",
|
|
113
|
+
"Ÿ": "Ÿ",
|
|
114
|
+
"ý": "ý",
|
|
115
|
+
"ŷ": "ŷ",
|
|
116
|
+
"ÿ": "ÿ"
|
|
117
|
+
};
|
package/lib/common/Utils.d.ts
CHANGED
|
@@ -13,14 +13,19 @@ export declare class Utils {
|
|
|
13
13
|
*/
|
|
14
14
|
static equalsFilter(object: any, filter: any, skipProp?: string[]): boolean;
|
|
15
15
|
static toIsoString(d: number | Date): string;
|
|
16
|
+
static toIsoTimestampString(YYYYMMDD: string, hhmmss: string): string;
|
|
16
17
|
static makeUTCMidnight(d: number | Date): Date;
|
|
17
18
|
static getUTCFullYear(d: number | Date, offset: string): number;
|
|
18
19
|
static getFullYear(d: number | Date, offset: string): number;
|
|
20
|
+
static timestampToMS(timestamp: string, offset: string): number;
|
|
21
|
+
static timestampToOffsetString(timestamp: string): string;
|
|
22
|
+
static getTimeOffsetByGPSStamp(timestamp: string, gpsTimeStamp: string, gps: any): string;
|
|
19
23
|
static getOffsetString(offsetMinutes: number): string;
|
|
20
24
|
static getOffsetMinutes(offsetString: string): number;
|
|
21
25
|
static isLeapYear(year: number): boolean;
|
|
22
26
|
static isDateFromLeapYear(date: Date): boolean;
|
|
23
27
|
static getDayOfYear(date: Date): number;
|
|
28
|
+
static addMonthToDate(date: Date, numMonths: number): Date;
|
|
24
29
|
static renderDataSize(size: number): string;
|
|
25
30
|
static getUnique(arr: any[]): any[];
|
|
26
31
|
static createRange(from: number, to: number): Array<number>;
|
|
@@ -36,10 +41,14 @@ export declare class Utils {
|
|
|
36
41
|
}[];
|
|
37
42
|
static findClosest(num: number, arr: number[]): number;
|
|
38
43
|
static findClosestinSorted(num: number, arr: number[]): number;
|
|
44
|
+
static asciiToUTF8(text: string): string;
|
|
45
|
+
static decodeHTMLChars(text: string): string;
|
|
39
46
|
static isUInt32(value: number, max?: number): boolean;
|
|
40
47
|
static isInt32(value: number): boolean;
|
|
41
48
|
static isFloat32(value: number): boolean;
|
|
42
49
|
static getAnyX(num: number, arr: any[], start?: number): any[][];
|
|
50
|
+
static xmpExifGpsCoordinateToDecimalDegrees(text: string): number;
|
|
51
|
+
static sortableFilename(filename: string): string;
|
|
43
52
|
}
|
|
44
53
|
export declare class LRU<V> {
|
|
45
54
|
readonly size: number;
|
package/lib/common/Utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LRU = exports.Utils = void 0;
|
|
4
|
+
const HTMLCharCodes_1 = require("./HTMLCharCodes");
|
|
4
5
|
class Utils {
|
|
5
6
|
static GUID() {
|
|
6
7
|
const s4 = () => Math.floor((1 + Math.random()) * 0x10000)
|
|
@@ -33,7 +34,7 @@ class Utils {
|
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
|
-
else if (obj[key] === null) {
|
|
37
|
+
else if (obj[key] === null || obj[key] === undefined) {
|
|
37
38
|
delete obj[key];
|
|
38
39
|
}
|
|
39
40
|
}
|
|
@@ -88,6 +89,26 @@ class Utils {
|
|
|
88
89
|
}
|
|
89
90
|
return d.getUTCFullYear() + '-' + d.getUTCMonth() + '-' + d.getUTCDate();
|
|
90
91
|
}
|
|
92
|
+
static toIsoTimestampString(YYYYMMDD, hhmmss) {
|
|
93
|
+
if (YYYYMMDD && hhmmss) {
|
|
94
|
+
// Regular expression to match YYYYMMDD format
|
|
95
|
+
const dateRegex = /^(\d{4})(\d{2})(\d{2})$/;
|
|
96
|
+
// Regular expression to match hhmmss+/-ohom format
|
|
97
|
+
const timeRegex = /^(\d{2})(\d{2})(\d{2})([+-]\d{2})?(\d{2})?$/;
|
|
98
|
+
const [, year, month, day] = YYYYMMDD.match(dateRegex);
|
|
99
|
+
const [, hour, minute, second, offsetHour, offsetMinute] = hhmmss.match(timeRegex);
|
|
100
|
+
const isoTimestamp = `${year}-${month}-${day}T${hour}:${minute}:${second}`;
|
|
101
|
+
if (offsetHour && offsetMinute) {
|
|
102
|
+
return isoTimestamp + `${offsetHour}:${offsetMinute}`;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
return isoTimestamp;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
91
112
|
static makeUTCMidnight(d) {
|
|
92
113
|
if (!(d instanceof Date)) {
|
|
93
114
|
d = new Date(d);
|
|
@@ -110,6 +131,61 @@ class Utils {
|
|
|
110
131
|
}
|
|
111
132
|
return new Date(new Date(d).toISOString().substring(0, 19) + (offset ? offset : '')).getFullYear();
|
|
112
133
|
}
|
|
134
|
+
//function to convert timestamp into milliseconds taking offset into account
|
|
135
|
+
static timestampToMS(timestamp, offset) {
|
|
136
|
+
if (!timestamp) {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
//replace : with - in the yyyy-mm-dd part of the timestamp.
|
|
140
|
+
let formattedTimestamp = timestamp.substring(0, 9).replaceAll(':', '-') + timestamp.substring(9, timestamp.length);
|
|
141
|
+
if (formattedTimestamp.indexOf("Z") > 0) { //replace Z (and what comes after the Z) with offset
|
|
142
|
+
formattedTimestamp = formattedTimestamp.substring(0, formattedTimestamp.indexOf("Z")) + (offset ? offset : '+00:00');
|
|
143
|
+
}
|
|
144
|
+
else if (formattedTimestamp.indexOf("+") > 0 || timestamp.substring(9, timestamp.length).indexOf("-") > 0) { //don't do anything
|
|
145
|
+
}
|
|
146
|
+
else { //add offset
|
|
147
|
+
formattedTimestamp = formattedTimestamp + (offset ? offset : '+00:00');
|
|
148
|
+
}
|
|
149
|
+
//parse into MS and return
|
|
150
|
+
return Date.parse(formattedTimestamp);
|
|
151
|
+
}
|
|
152
|
+
//function to extract offset string from timestamp string, returns undefined if timestamp does not contain offset
|
|
153
|
+
static timestampToOffsetString(timestamp) {
|
|
154
|
+
try {
|
|
155
|
+
const offsetRegex = /[+-]\d{2}:\d{2}$/;
|
|
156
|
+
const match = timestamp.match(offsetRegex);
|
|
157
|
+
if (match) {
|
|
158
|
+
return match[0];
|
|
159
|
+
}
|
|
160
|
+
else if (timestamp.indexOf("Z") > 0) {
|
|
161
|
+
return '+00:00';
|
|
162
|
+
}
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
//function to calculate offset from exif.exif.gpsTimeStamp or exif.gps.GPSDateStamp + exif.gps.GPSTimestamp
|
|
170
|
+
static getTimeOffsetByGPSStamp(timestamp, gpsTimeStamp, gps) {
|
|
171
|
+
let UTCTimestamp = gpsTimeStamp;
|
|
172
|
+
if (!UTCTimestamp &&
|
|
173
|
+
gps &&
|
|
174
|
+
gps.GPSDateStamp &&
|
|
175
|
+
gps.GPSTimeStamp) { //else use exif.gps.GPS*Stamp if available
|
|
176
|
+
//GPS timestamp is always UTC (+00:00)
|
|
177
|
+
UTCTimestamp = gps.GPSDateStamp.replaceAll(':', '-') + gps.GPSTimeStamp.join(':');
|
|
178
|
+
}
|
|
179
|
+
if (UTCTimestamp && timestamp) {
|
|
180
|
+
//offset in minutes is the difference between gps timestamp and given timestamp
|
|
181
|
+
//to calculate this correctly, we have to work with the same offset
|
|
182
|
+
const offsetMinutes = (Utils.timestampToMS(timestamp, '+00:00') - Utils.timestampToMS(UTCTimestamp, '+00:00')) / 1000 / 60;
|
|
183
|
+
return Utils.getOffsetString(offsetMinutes);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
return undefined;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
113
189
|
static getOffsetString(offsetMinutes) {
|
|
114
190
|
if (-720 <= offsetMinutes && offsetMinutes <= 840) {
|
|
115
191
|
//valid offset is within -12 and +14 hrs (https://en.wikipedia.org/wiki/List_of_UTC_offsets)
|
|
@@ -122,7 +198,7 @@ class Utils {
|
|
|
122
198
|
}
|
|
123
199
|
}
|
|
124
200
|
static getOffsetMinutes(offsetString) {
|
|
125
|
-
const regex = /^([+-](0[0-9]|1[0-4]):[0-5][0-9])$/; //checks if offset is between -14:00 and +14:00.
|
|
201
|
+
const regex = /^([+-](0[0-9]|1[0-4]):[0-5][0-9])$/; //checks if offset is between -14:00 and +14:00.
|
|
126
202
|
//-12:00 is the lowest valid UTC-offset, but we allow down to -14 for efficiency
|
|
127
203
|
if (regex.test(offsetString)) {
|
|
128
204
|
const hhmm = offsetString.split(":");
|
|
@@ -150,6 +226,18 @@ class Utils {
|
|
|
150
226
|
}
|
|
151
227
|
return dayOfYear;
|
|
152
228
|
}
|
|
229
|
+
//Adding months to a date differently from standard JS
|
|
230
|
+
//this function makes sure that if date is the 31st and you add a month, you will get the last day of the next month
|
|
231
|
+
//so adding or subtracting a month from 31st of march will give 30th of april or 28th of february respectively (29th on leap years).
|
|
232
|
+
static addMonthToDate(date, numMonths) {
|
|
233
|
+
const result = new Date(date);
|
|
234
|
+
const expectedMonth = ((date.getMonth() + numMonths) % 12 + 12) % 12; //inner %12 + 12 makes correct handling of negative months
|
|
235
|
+
result.setMonth(result.getMonth() + numMonths);
|
|
236
|
+
if (result.getMonth() !== expectedMonth) {
|
|
237
|
+
result.setDate(0);
|
|
238
|
+
}
|
|
239
|
+
return result;
|
|
240
|
+
}
|
|
153
241
|
static renderDataSize(size) {
|
|
154
242
|
const postFixes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
155
243
|
let index = 0;
|
|
@@ -271,6 +359,28 @@ class Utils {
|
|
|
271
359
|
}
|
|
272
360
|
return curr;
|
|
273
361
|
}
|
|
362
|
+
static asciiToUTF8(text) {
|
|
363
|
+
if (text) {
|
|
364
|
+
return Buffer.from(text, 'ascii').toString('utf-8');
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
return text;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
static decodeHTMLChars(text) {
|
|
371
|
+
if (text) {
|
|
372
|
+
const newtext = text.replace(/&#([0-9]{1,3});/gi, function (match, numStr) {
|
|
373
|
+
return String.fromCharCode(parseInt(numStr, 10));
|
|
374
|
+
});
|
|
375
|
+
return newtext.replace(/&[^;]+;/g, function (match) {
|
|
376
|
+
const char = HTMLCharCodes_1.HTMLChar[match];
|
|
377
|
+
return char ? char : match;
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
return text;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
274
384
|
static isUInt32(value, max = 4294967295) {
|
|
275
385
|
value = parseInt('' + value, 10);
|
|
276
386
|
return !isNaN(value) && value >= 0 && value <= max;
|
|
@@ -305,6 +415,25 @@ class Utils {
|
|
|
305
415
|
}
|
|
306
416
|
return ret;
|
|
307
417
|
}
|
|
418
|
+
static xmpExifGpsCoordinateToDecimalDegrees(text) {
|
|
419
|
+
if (!text) {
|
|
420
|
+
return undefined;
|
|
421
|
+
}
|
|
422
|
+
const parts = text.match(/^([0-9]+),([0-9.]+)([EWNS])$/);
|
|
423
|
+
const degrees = parseInt(parts[1], 10);
|
|
424
|
+
const minutes = parseFloat(parts[2]);
|
|
425
|
+
const sign = (parts[3] === "N" || parts[3] === "E") ? 1 : -1;
|
|
426
|
+
return (sign * (degrees + (minutes / 60.0)));
|
|
427
|
+
}
|
|
428
|
+
static sortableFilename(filename) {
|
|
429
|
+
const lastDot = filename.lastIndexOf(".");
|
|
430
|
+
// Avoid 0 as well as -1 to prevent empty names for extensionless dot-files
|
|
431
|
+
if (lastDot > 0) {
|
|
432
|
+
return filename.substring(0, lastDot);
|
|
433
|
+
}
|
|
434
|
+
// Fallback to the full name
|
|
435
|
+
return filename;
|
|
436
|
+
}
|
|
308
437
|
}
|
|
309
438
|
exports.Utils = Utils;
|
|
310
439
|
class LRU {
|
|
@@ -6,10 +6,12 @@ const PrivateConfigClass_1 = require("./PrivateConfigClass");
|
|
|
6
6
|
const node_1 = require("typeconfig/node");
|
|
7
7
|
const ExtensionConfigTemplateLoader_1 = require("../../../backend/model/extension/ExtensionConfigTemplateLoader");
|
|
8
8
|
const path = require("path");
|
|
9
|
+
// we need to know the location of the extensions to load the full config (including the extensions)
|
|
9
10
|
const pre = node_1.ConfigClassBuilder.attachPrivateInterface(new PrivateConfigClass_1.PrivateConfigClass());
|
|
10
11
|
try {
|
|
11
|
-
pre.loadSync();
|
|
12
|
+
pre.loadSync({ preventSaving: true });
|
|
13
|
+
}
|
|
14
|
+
catch (e) { /* empty */
|
|
12
15
|
}
|
|
13
|
-
catch (e) { /* empty */ }
|
|
14
16
|
ExtensionConfigTemplateLoader_1.ExtensionConfigTemplateLoader.Instance.init(path.join(__dirname, '/../../../../', pre.Extensions.folder));
|
|
15
17
|
exports.Config = ExtensionConfigWrapper_1.ExtensionConfigWrapper.originalSync(true);
|
|
@@ -57,6 +57,8 @@ let ServerExtensionsConfig = class ServerExtensionsConfig extends ClientConfig_1
|
|
|
57
57
|
constructor() {
|
|
58
58
|
super(...arguments);
|
|
59
59
|
this.folder = 'extensions';
|
|
60
|
+
// TODO: this does not hold if the order of the extensions mixes up.
|
|
61
|
+
// TODO: experiment with a map instead of an array
|
|
60
62
|
this.extensions = [];
|
|
61
63
|
this.cleanUpUnusedTables = true;
|
|
62
64
|
}
|
|
@@ -22,16 +22,6 @@ export interface MediaDimension {
|
|
|
22
22
|
width: number;
|
|
23
23
|
height: number;
|
|
24
24
|
}
|
|
25
|
-
export interface SideCar {
|
|
26
|
-
dc?: SideCarDc;
|
|
27
|
-
xmp?: SideCarXmp;
|
|
28
|
-
}
|
|
29
|
-
export interface SideCarDc {
|
|
30
|
-
subject?: string[];
|
|
31
|
-
}
|
|
32
|
-
export interface SideCarXmp {
|
|
33
|
-
Rating?: RatingTypes;
|
|
34
|
-
}
|
|
35
25
|
export declare const MediaDTOUtils: {
|
|
36
26
|
hasPositionData: (media: MediaDTO) => boolean;
|
|
37
27
|
isPhoto: (media: FileDTO) => boolean;
|
package/package.json
CHANGED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { FileJob } from './FileJob';
|
|
2
|
-
import { FileDTO } from '../../../../common/entities/FileDTO';
|
|
3
|
-
export declare class ThumbnailGenerationJob extends FileJob<{
|
|
4
|
-
sizes?: number[];
|
|
5
|
-
indexedOnly?: boolean;
|
|
6
|
-
}> {
|
|
7
|
-
readonly Name: string;
|
|
8
|
-
constructor();
|
|
9
|
-
get Supported(): boolean;
|
|
10
|
-
start(config: {
|
|
11
|
-
sizes?: number[];
|
|
12
|
-
indexedOnly?: boolean;
|
|
13
|
-
}, soloRun?: boolean, allowParallelRun?: boolean): Promise<void>;
|
|
14
|
-
protected filterMediaFiles(files: FileDTO[]): Promise<FileDTO[]>;
|
|
15
|
-
protected filterMetaFiles(files: FileDTO[]): Promise<FileDTO[]>;
|
|
16
|
-
protected shouldProcess(mPath: string): Promise<boolean>;
|
|
17
|
-
protected processFile(mPath: string): Promise<void>;
|
|
18
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare class EmailSMTPMessagingConfig {
|
|
2
|
-
host: string;
|
|
3
|
-
port: number;
|
|
4
|
-
secure: boolean;
|
|
5
|
-
requireTLS: boolean;
|
|
6
|
-
user: string;
|
|
7
|
-
password: string;
|
|
8
|
-
}
|
|
9
|
-
export declare class EmailMessagingConfig {
|
|
10
|
-
emailFrom: string;
|
|
11
|
-
smtp?: EmailSMTPMessagingConfig;
|
|
12
|
-
}
|
|
13
|
-
export declare class MessagingConfig {
|
|
14
|
-
Email: EmailMessagingConfig;
|
|
15
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessagingConfig = exports.EmailMessagingConfig = exports.EmailSMTPMessagingConfig = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-inferrable-types */
|
|
6
|
-
const common_1 = require("typeconfig/common");
|
|
7
|
-
const ClientConfig_1 = require("../public/ClientConfig");
|
|
8
|
-
if (typeof $localize === 'undefined') {
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
global.$localize = (s) => s;
|
|
12
|
-
}
|
|
13
|
-
let EmailSMTPMessagingConfig = class EmailSMTPMessagingConfig {
|
|
14
|
-
constructor() {
|
|
15
|
-
this.host = '';
|
|
16
|
-
this.port = 587;
|
|
17
|
-
this.secure = false;
|
|
18
|
-
this.requireTLS = true;
|
|
19
|
-
this.user = '';
|
|
20
|
-
this.password = '';
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
tslib_1.__decorate([
|
|
24
|
-
(0, common_1.ConfigProperty)({
|
|
25
|
-
tags: {
|
|
26
|
-
name: $localize `Host`,
|
|
27
|
-
priority: ClientConfig_1.ConfigPriority.advanced,
|
|
28
|
-
hint: 'smtp.example.com'
|
|
29
|
-
},
|
|
30
|
-
description: $localize `SMTP host server`
|
|
31
|
-
}),
|
|
32
|
-
tslib_1.__metadata("design:type", String)
|
|
33
|
-
], EmailSMTPMessagingConfig.prototype, "host", void 0);
|
|
34
|
-
tslib_1.__decorate([
|
|
35
|
-
(0, common_1.ConfigProperty)({
|
|
36
|
-
tags: {
|
|
37
|
-
name: $localize `Port`,
|
|
38
|
-
priority: ClientConfig_1.ConfigPriority.advanced,
|
|
39
|
-
},
|
|
40
|
-
description: $localize `SMTP server's port`
|
|
41
|
-
}),
|
|
42
|
-
tslib_1.__metadata("design:type", Number)
|
|
43
|
-
], EmailSMTPMessagingConfig.prototype, "port", void 0);
|
|
44
|
-
tslib_1.__decorate([
|
|
45
|
-
(0, common_1.ConfigProperty)({
|
|
46
|
-
tags: {
|
|
47
|
-
name: $localize `isSecure`,
|
|
48
|
-
priority: ClientConfig_1.ConfigPriority.advanced,
|
|
49
|
-
},
|
|
50
|
-
description: $localize `Is the connection secure. See https://nodemailer.com/smtp/#tls-options for more details`
|
|
51
|
-
}),
|
|
52
|
-
tslib_1.__metadata("design:type", Boolean)
|
|
53
|
-
], EmailSMTPMessagingConfig.prototype, "secure", void 0);
|
|
54
|
-
tslib_1.__decorate([
|
|
55
|
-
(0, common_1.ConfigProperty)({
|
|
56
|
-
tags: {
|
|
57
|
-
name: $localize `TLS required`,
|
|
58
|
-
priority: ClientConfig_1.ConfigPriority.advanced,
|
|
59
|
-
},
|
|
60
|
-
description: $localize `if this is true and secure is false then Nodemailer (used library in the background) tries to use STARTTLS. See https://nodemailer.com/smtp/#tls-options for more details`
|
|
61
|
-
}),
|
|
62
|
-
tslib_1.__metadata("design:type", Boolean)
|
|
63
|
-
], EmailSMTPMessagingConfig.prototype, "requireTLS", void 0);
|
|
64
|
-
tslib_1.__decorate([
|
|
65
|
-
(0, common_1.ConfigProperty)({
|
|
66
|
-
tags: {
|
|
67
|
-
name: $localize `User`,
|
|
68
|
-
priority: ClientConfig_1.ConfigPriority.advanced,
|
|
69
|
-
},
|
|
70
|
-
description: $localize `User to connect to the SMTP server.`
|
|
71
|
-
}),
|
|
72
|
-
tslib_1.__metadata("design:type", String)
|
|
73
|
-
], EmailSMTPMessagingConfig.prototype, "user", void 0);
|
|
74
|
-
tslib_1.__decorate([
|
|
75
|
-
(0, common_1.ConfigProperty)({
|
|
76
|
-
tags: {
|
|
77
|
-
name: $localize `Password`,
|
|
78
|
-
priority: ClientConfig_1.ConfigPriority.advanced,
|
|
79
|
-
},
|
|
80
|
-
type: 'password',
|
|
81
|
-
description: $localize `Password to connect to the SMTP server.`
|
|
82
|
-
}),
|
|
83
|
-
tslib_1.__metadata("design:type", String)
|
|
84
|
-
], EmailSMTPMessagingConfig.prototype, "password", void 0);
|
|
85
|
-
EmailSMTPMessagingConfig = tslib_1.__decorate([
|
|
86
|
-
(0, common_1.SubConfigClass)({ softReadonly: true })
|
|
87
|
-
], EmailSMTPMessagingConfig);
|
|
88
|
-
exports.EmailSMTPMessagingConfig = EmailSMTPMessagingConfig;
|
|
89
|
-
let EmailMessagingConfig = class EmailMessagingConfig {
|
|
90
|
-
constructor() {
|
|
91
|
-
this.emailFrom = 'noreply@pigallery2.com';
|
|
92
|
-
this.smtp = new EmailSMTPMessagingConfig();
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
tslib_1.__decorate([
|
|
96
|
-
(0, common_1.ConfigProperty)({
|
|
97
|
-
tags: {
|
|
98
|
-
name: $localize `Sender email`,
|
|
99
|
-
priority: ClientConfig_1.ConfigPriority.advanced,
|
|
100
|
-
},
|
|
101
|
-
description: $localize `Some services do not allow sending from random e-mail addresses. Set this accordingly.`
|
|
102
|
-
}),
|
|
103
|
-
tslib_1.__metadata("design:type", String)
|
|
104
|
-
], EmailMessagingConfig.prototype, "emailFrom", void 0);
|
|
105
|
-
tslib_1.__decorate([
|
|
106
|
-
(0, common_1.ConfigProperty)({
|
|
107
|
-
tags: {
|
|
108
|
-
name: $localize `SMTP`,
|
|
109
|
-
}
|
|
110
|
-
}),
|
|
111
|
-
tslib_1.__metadata("design:type", EmailSMTPMessagingConfig)
|
|
112
|
-
], EmailMessagingConfig.prototype, "smtp", void 0);
|
|
113
|
-
EmailMessagingConfig = tslib_1.__decorate([
|
|
114
|
-
(0, common_1.SubConfigClass)({ softReadonly: true })
|
|
115
|
-
], EmailMessagingConfig);
|
|
116
|
-
exports.EmailMessagingConfig = EmailMessagingConfig;
|
|
117
|
-
let MessagingConfig = class MessagingConfig {
|
|
118
|
-
constructor() {
|
|
119
|
-
this.Email = new EmailMessagingConfig();
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
tslib_1.__decorate([
|
|
123
|
-
(0, common_1.ConfigProperty)({
|
|
124
|
-
tags: {
|
|
125
|
-
name: $localize `Email`,
|
|
126
|
-
},
|
|
127
|
-
description: $localize `The app uses Nodemailer in the background for sending e-mails. Refer to https://nodemailer.com/usage/ if some options are not clear.`
|
|
128
|
-
}),
|
|
129
|
-
tslib_1.__metadata("design:type", EmailMessagingConfig)
|
|
130
|
-
], MessagingConfig.prototype, "Email", void 0);
|
|
131
|
-
MessagingConfig = tslib_1.__decorate([
|
|
132
|
-
(0, common_1.SubConfigClass)({ softReadonly: true })
|
|
133
|
-
], MessagingConfig);
|
|
134
|
-
exports.MessagingConfig = MessagingConfig;
|