pigallery2-extension-kit 2.0.3-edge7 → 2.5.0-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.
- package/README.md +18 -19
- package/index.ts +1 -1
- package/lib/backend/model/extension/IExtension.d.ts +289 -181
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ See sample extension at https://github.com/bpatrik/pigallery2-sample-extension.
|
|
|
7
7
|
# Extension Usage
|
|
8
8
|
|
|
9
9
|
Extension folder can be set through config. For the docker-ised version,
|
|
10
|
-
they live under the `config/extension` folder in their own subdirectory.
|
|
10
|
+
they live under the `config/extension` folder in their own subdirectory.
|
|
11
11
|
|
|
12
12
|
# Extension development
|
|
13
13
|
|
|
@@ -21,16 +21,20 @@ You need at least a `server.js` in your extension folder that exports a `init(ex
|
|
|
21
21
|
<path to the extension fodler>/myextension/package.js <- this is optional. You can add extra npm packages here
|
|
22
22
|
<path to the extension fodler>/myextension/server.js <- this is needed
|
|
23
23
|
```
|
|
24
|
+
|
|
24
25
|
Where `<path to the extension fodler>` is what you set in the config and `myextension` is the name of your extension.
|
|
25
|
-
Note: you do not need to add your `node_modules` folder. The app will call `npm
|
|
26
|
+
Note: you do not need to add your `node_modules` folder. The app will call `npm install` when initializing your extension.
|
|
27
|
+
|
|
26
28
|
## Extension environment
|
|
27
29
|
|
|
28
30
|
The app runs the extension the following way:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
- It reads all extensions in `<path to the extension fodler>/**` folder
|
|
33
|
+
- Checks if `package.js` is present. If yes installs the packages
|
|
34
|
+
- Checks if `server.js` is present. If yes, calls the `init` function.
|
|
32
35
|
|
|
33
36
|
### Init and cleanup lifecycle
|
|
37
|
+
|
|
34
38
|
There is also a `cleanUp` function that you can implement in your extension.
|
|
35
39
|
The app can call your `init` and `cleanUp` functions any time.
|
|
36
40
|
Always calls the `init` first then `cleanUp` later.
|
|
@@ -39,8 +43,7 @@ Main use-case: `init` is called on app startup. `cleanUp` and `init` called late
|
|
|
39
43
|
## Extension interface
|
|
40
44
|
|
|
41
45
|
The app calls the `init` and `cleanUp` function with a `IExtensionObject` object.
|
|
42
|
-
See https://github.com/bpatrik/pigallery2/blob/master/src/backend/model/extension/IExtension.ts
|
|
43
|
-
|
|
46
|
+
See https://github.com/bpatrik/pigallery2/blob/master/src/backend/model/extension/IExtension.ts for details.
|
|
44
47
|
|
|
45
48
|
`IExtensionObject` exposes lifecycle events, configs, RestAPis with some limitation.
|
|
46
49
|
Changes made during the these public apis you do not need to clean up in the `cleanUp` function.
|
|
@@ -50,7 +53,7 @@ App also exposes private `_app` object to provide access to low level API. Any c
|
|
|
50
53
|
|
|
51
54
|
See sample server.js at https://github.com/bpatrik/pigallery2-sample-extension.
|
|
52
55
|
|
|
53
|
-
It is recommended to do the development in `ts`, so creating a `server.ts`.
|
|
56
|
+
It is recommended to do the development in `ts`, so creating a `server.ts`.
|
|
54
57
|
Note: You need to manually transpile your `server.ts` file to `server.js` as the app does not do that for you.
|
|
55
58
|
This doc assumes you do the development in `ts`.
|
|
56
59
|
|
|
@@ -59,23 +62,23 @@ This doc assumes you do the development in `ts`.
|
|
|
59
62
|
You can import package from both the main app package.json and from your extension package.json.
|
|
60
63
|
To import packages from the main app, you import as usual.
|
|
61
64
|
For packages from the extension, you always need to write relative path. i.e.: prefix with `./node_modules`
|
|
65
|
+
|
|
62
66
|
```ts
|
|
63
67
|
// Including dev-kit interfaces. It is not necessary, only helps development with types.
|
|
64
68
|
// You need to prefix them with ./node_modules
|
|
65
|
-
import {IExtensionObject} from
|
|
69
|
+
import { IExtensionObject } from "./node_modules/pigallery2-extension-kit";
|
|
66
70
|
|
|
67
71
|
// Including prod extension packages. You need to prefix them with ./node_modules
|
|
68
72
|
// lodash does not have types
|
|
69
73
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
70
74
|
// @ts-ignore
|
|
71
|
-
import * as _ from
|
|
75
|
+
import * as _ from "./node_modules/lodash";
|
|
72
76
|
|
|
73
77
|
// Importing packages that are available in the main app (listed in the packages.json in pigallery2)
|
|
74
|
-
import {Column, Entity, Index, PrimaryGeneratedColumn} from
|
|
78
|
+
import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm";
|
|
75
79
|
```
|
|
76
80
|
|
|
77
|
-
|
|
78
|
-
#### pigallery2 extension dev-kit
|
|
81
|
+
#### pigallery2 extension dev-kit
|
|
79
82
|
|
|
80
83
|
It is recommended to use the `pigallery2-extension-kit` node package.
|
|
81
84
|
`npm install pigallery2-extension-kit --save` to your extension.
|
|
@@ -87,17 +90,14 @@ You can then `import {IExtensionObject} from './node_modules/pigallery2-extensio
|
|
|
87
90
|
|
|
88
91
|
See https://github.com/bpatrik/pigallery2/blob/master/src/backend/model/extension/IExtension.ts to understand what contains `IExtensionObject`.
|
|
89
92
|
|
|
90
|
-
NOTE: this is not needed to create an extension it only helps your IDE and your
|
|
93
|
+
NOTE: this is not needed to create an extension it only helps your IDE and your development. These type definitions are removed when you compile `ts` to `js`.
|
|
91
94
|
|
|
92
95
|
#### `init` function
|
|
93
96
|
|
|
94
97
|
You need to implement the `init` function for a working extension:
|
|
95
98
|
|
|
96
99
|
```ts
|
|
97
|
-
|
|
98
|
-
export const init = async (extension: IExtensionObject<void>): Promise<void> => {
|
|
99
|
-
|
|
100
|
-
}
|
|
100
|
+
export const init = async (extension: IExtensionObject<void>): Promise<void> => {};
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
#### pigallery2 lifecycle `events`
|
|
@@ -105,5 +105,4 @@ export const init = async (extension: IExtensionObject<void>): Promise<void> =>
|
|
|
105
105
|
Tha app exposes multiple interfaces for the extensions to interact with the main app. `events` are one of the main interfaces.
|
|
106
106
|
Here are their flow:
|
|
107
107
|
|
|
108
|
-
|
|
109
108
|

|
package/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {IServerExtension,IExtensionObject} from './lib/backend/model/extension/IExtension';
|
|
1
|
+
export {IServerExtension,IExtensionObject, IClientExtension} from './lib/backend/model/extension/IExtension';
|
|
2
2
|
|
|
@@ -1,226 +1,334 @@
|
|
|
1
1
|
import * as express from 'express';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
2
|
+
import {NextFunction, Request, Response} from 'express';
|
|
3
|
+
import {PrivateConfigClass} from '../../../common/config/private/PrivateConfigClass';
|
|
4
|
+
import {ObjectManagers} from '../ObjectManagers';
|
|
5
|
+
import {ProjectPathClass} from '../../ProjectPath';
|
|
6
|
+
import {ILogger} from '../../Logger';
|
|
7
|
+
import {UserDTO, UserRoles} from '../../../common/entities/UserDTO';
|
|
8
|
+
import {ParamsDictionary} from 'express-serve-static-core';
|
|
9
|
+
import {Connection} from 'typeorm';
|
|
10
|
+
import {DynamicConfig} from '../../../common/entities/DynamicConfig';
|
|
11
|
+
import {MediaDTOWithThPath} from '../messenger/Messenger';
|
|
12
|
+
import {PhotoMetadata} from '../../../common/entities/PhotoDTO';
|
|
13
|
+
import {VideoMetadata} from '../../../common/entities/VideoDTO';
|
|
14
|
+
import {MediaRendererInput, SvgRendererInput} from '../fileaccess/PhotoWorker';
|
|
15
|
+
import {SearchQueryDTO} from '../../../common/entities/SearchQueryDTO';
|
|
16
|
+
import {CoverPhotoDTOWithID} from '../database/CoverManager';
|
|
17
|
+
import {ParentDirectoryDTO} from '../../../common/entities/DirectoryDTO';
|
|
18
|
+
import {DirectoryScanSettings} from '../fileaccess/DiskManager';
|
|
19
|
+
|
|
19
20
|
export declare type IExtensionBeforeEventHandler<I extends unknown[], O> = (input: I, event: {
|
|
20
|
-
|
|
21
|
+
stopPropagation: boolean;
|
|
21
22
|
}) => Promise<I | O>;
|
|
22
23
|
/**
|
|
23
24
|
* input: is the original input: this is output of all before handler. This value was also piped to app's function
|
|
24
25
|
* output: is the output of the app's function or the previous after handler
|
|
25
26
|
*/
|
|
26
27
|
export declare type IExtensionAfterEventHandler<I extends unknown[], O> = (data: {
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
input: I;
|
|
29
|
+
output: O;
|
|
29
30
|
}) => Promise<O>;
|
|
31
|
+
|
|
30
32
|
export interface IExtensionEvent<I extends unknown[], O> {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
before: (handler: IExtensionBeforeEventHandler<I, O>) => void;
|
|
34
|
+
after: (handler: IExtensionAfterEventHandler<I, O>) => void;
|
|
33
35
|
}
|
|
36
|
+
|
|
34
37
|
/**
|
|
35
38
|
* All main event callbacks in the app
|
|
36
39
|
*/
|
|
37
40
|
export interface IExtensionEvents {
|
|
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
|
-
* Reads exif, iptc, etc.. metadata for photos/videos
|
|
68
|
-
*/
|
|
69
|
-
MetadataLoader: {
|
|
70
|
-
loadVideoMetadata: IExtensionEvent<[string], VideoMetadata>;
|
|
71
|
-
loadPhotoMetadata: IExtensionEvent<[string], PhotoMetadata>;
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* Scans the storage for a given directory and returns the list of child directories,
|
|
75
|
-
* photos, videos and metafiles
|
|
76
|
-
*/
|
|
77
|
-
DiskManager: {
|
|
78
|
-
excludeDir: IExtensionEvent<[
|
|
79
|
-
{
|
|
80
|
-
name: string;
|
|
81
|
-
parentDirRelativeName: string;
|
|
82
|
-
parentDirAbsoluteName: string;
|
|
83
|
-
}
|
|
84
|
-
], boolean>;
|
|
85
|
-
scanDirectory: IExtensionEvent<[
|
|
86
|
-
string,
|
|
87
|
-
DirectoryScanSettings
|
|
88
|
-
], ParentDirectoryDTO>;
|
|
89
|
-
};
|
|
41
|
+
gallery: {
|
|
42
|
+
/**
|
|
43
|
+
* Events for Directory and Album covers
|
|
44
|
+
*/
|
|
45
|
+
CoverManager: {
|
|
46
|
+
getCoverForAlbum: IExtensionEvent<[
|
|
47
|
+
{
|
|
48
|
+
searchQuery: SearchQueryDTO;
|
|
49
|
+
}
|
|
50
|
+
], CoverPhotoDTOWithID>;
|
|
51
|
+
getCoverForDirectory: IExtensionEvent<[
|
|
52
|
+
{
|
|
53
|
+
id: number;
|
|
54
|
+
name: string;
|
|
55
|
+
path: string;
|
|
56
|
+
}
|
|
57
|
+
], CoverPhotoDTOWithID>;
|
|
58
|
+
/**
|
|
59
|
+
* Invalidates directory covers for a given directory and every parent
|
|
60
|
+
*/
|
|
61
|
+
invalidateDirectoryCovers: IExtensionEvent<[ParentDirectoryDTO], void>;
|
|
62
|
+
};
|
|
63
|
+
ImageRenderer: {
|
|
64
|
+
/**
|
|
65
|
+
* Renders a thumbnail or photo
|
|
66
|
+
*/
|
|
67
|
+
render: IExtensionEvent<[MediaRendererInput | SvgRendererInput], void>;
|
|
90
68
|
};
|
|
91
|
-
}
|
|
92
|
-
export interface IExtensionApp {
|
|
93
|
-
expressApp: express.Express;
|
|
94
|
-
objectManagers: ObjectManagers;
|
|
95
|
-
config: PrivateConfigClass;
|
|
96
|
-
}
|
|
97
|
-
export interface IExtensionRESTRoute {
|
|
98
69
|
/**
|
|
99
|
-
*
|
|
100
|
-
* @param paths RESTapi path, relative to the extension base endpoint
|
|
101
|
-
* @param minRole set to null to omit auer check (ie make the endpoint public)
|
|
102
|
-
* @param cb function callback
|
|
103
|
-
* @return newly added REST api path
|
|
70
|
+
* Reads exif, iptc, etc.. metadata for photos/videos
|
|
104
71
|
*/
|
|
105
|
-
|
|
72
|
+
MetadataLoader: {
|
|
73
|
+
loadVideoMetadata: IExtensionEvent<[string], VideoMetadata>;
|
|
74
|
+
loadPhotoMetadata: IExtensionEvent<[string], PhotoMetadata>;
|
|
75
|
+
};
|
|
106
76
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* @param minRole set to null to omit auer check (ie make the endpoint public)
|
|
110
|
-
* @param mw expressjs middleware
|
|
111
|
-
* @return newly added REST api path
|
|
77
|
+
* Scans the storage for a given directory and returns the list of child directories,
|
|
78
|
+
* photos, videos and metafiles
|
|
112
79
|
*/
|
|
113
|
-
|
|
80
|
+
DiskManager: {
|
|
81
|
+
excludeDir: IExtensionEvent<[
|
|
82
|
+
{
|
|
83
|
+
name: string;
|
|
84
|
+
parentDirRelativeName: string;
|
|
85
|
+
parentDirAbsoluteName: string;
|
|
86
|
+
}
|
|
87
|
+
], boolean>;
|
|
88
|
+
scanDirectory: IExtensionEvent<[
|
|
89
|
+
string,
|
|
90
|
+
DirectoryScanSettings
|
|
91
|
+
], ParentDirectoryDTO>;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface IExtensionApp {
|
|
97
|
+
expressApp: express.Express;
|
|
98
|
+
objectManagers: ObjectManagers;
|
|
99
|
+
config: PrivateConfigClass;
|
|
114
100
|
}
|
|
101
|
+
|
|
102
|
+
export interface IExtensionRESTRoute {
|
|
103
|
+
/**
|
|
104
|
+
* Sends a pigallery2 standard JSON object with payload or error message back to the client.
|
|
105
|
+
* @param paths RESTapi path, relative to the extension base endpoint
|
|
106
|
+
* @param minRole set to null to omit auer check (ie make the endpoint public)
|
|
107
|
+
* @param cb function callback
|
|
108
|
+
* @return newly added REST api path
|
|
109
|
+
*/
|
|
110
|
+
jsonResponse(paths: string[], minRole: UserRoles, cb: (params?: ParamsDictionary, body?: any, user?: UserDTO) => Promise<unknown> | unknown): string;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Exposes a standard expressjs middleware
|
|
114
|
+
* @param paths RESTapi path, relative to the extension base endpoint
|
|
115
|
+
* @param minRole set to null to omit auer check (ie make the endpoint public)
|
|
116
|
+
* @param mw expressjs middleware
|
|
117
|
+
* @return newly added REST api path
|
|
118
|
+
*/
|
|
119
|
+
rawMiddleware(paths: string[], minRole: UserRoles, mw: (req: Request, res: Response, next: NextFunction) => void | Promise<void>): string;
|
|
120
|
+
}
|
|
121
|
+
|
|
115
122
|
export interface IExtensionRESTApi {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
123
|
+
use: IExtensionRESTRoute;
|
|
124
|
+
get: IExtensionRESTRoute;
|
|
125
|
+
post: IExtensionRESTRoute;
|
|
126
|
+
put: IExtensionRESTRoute;
|
|
127
|
+
delete: IExtensionRESTRoute;
|
|
121
128
|
}
|
|
129
|
+
|
|
122
130
|
export interface IExtensionDB {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
131
|
+
/**
|
|
132
|
+
* Returns with a typeorm SQL connection
|
|
133
|
+
*/
|
|
134
|
+
getSQLConnection(): Promise<Connection>;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Adds SQL tables to typeorm
|
|
138
|
+
* @param tables
|
|
139
|
+
*/
|
|
140
|
+
setExtensionTables(tables: Function[]): Promise<void>;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Exposes all tables. You can use this if you van to have a foreign key to a built-in table.
|
|
144
|
+
* Use with caution. This exposes the app's internal working.
|
|
145
|
+
*/
|
|
146
|
+
_getAllTables(): Function[];
|
|
137
147
|
}
|
|
148
|
+
|
|
138
149
|
export interface IExtensionConfig<C> {
|
|
139
|
-
|
|
150
|
+
getConfig(): C;
|
|
140
151
|
}
|
|
152
|
+
|
|
141
153
|
export interface IExtensionMessengers {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Adds a new messenger that the user can select e.g.: for sending top pick photos
|
|
156
|
+
* @param name Name of the messenger (also used as id)
|
|
157
|
+
* @param config config metadata for this messenger
|
|
158
|
+
* @param callbacks messenger logic
|
|
159
|
+
*/
|
|
160
|
+
addMessenger<C extends Record<string, unknown> = Record<string, unknown>>(name: string, config: DynamicConfig[], callbacks: {
|
|
161
|
+
sendMedia: (config: C, media: MediaDTOWithThPath[]) => Promise<void>;
|
|
162
|
+
}): void;
|
|
151
163
|
}
|
|
164
|
+
|
|
152
165
|
export interface IExtensionObject<C = void> {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
166
|
+
/**
|
|
167
|
+
* ID of the extension that is internally used. By default, the name and ID matches if there is no collision.
|
|
168
|
+
*/
|
|
169
|
+
extensionId: string;
|
|
170
|
+
/**
|
|
171
|
+
* Name of the extension
|
|
172
|
+
*/
|
|
173
|
+
extensionName: string;
|
|
174
|
+
/**
|
|
175
|
+
* Inner functionality of the app. Use this with caution.
|
|
176
|
+
* If you want to go deeper than the standard exposed APIs, you can try doing so here.
|
|
177
|
+
*/
|
|
178
|
+
_app: IExtensionApp;
|
|
179
|
+
/**
|
|
180
|
+
* Create extension related configuration
|
|
181
|
+
*/
|
|
182
|
+
config: IExtensionConfig<C>;
|
|
183
|
+
/**
|
|
184
|
+
* Create new SQL tables and access SQL connection
|
|
185
|
+
*/
|
|
186
|
+
db: IExtensionDB;
|
|
187
|
+
/**
|
|
188
|
+
* Paths to the main components of the app.
|
|
189
|
+
*/
|
|
190
|
+
paths: ProjectPathClass;
|
|
191
|
+
/**
|
|
192
|
+
* Logger of the app
|
|
193
|
+
*/
|
|
194
|
+
Logger: ILogger;
|
|
195
|
+
/**
|
|
196
|
+
* Main app events. Use this change indexing, cover or serving gallery
|
|
197
|
+
*/
|
|
198
|
+
events: IExtensionEvents;
|
|
199
|
+
/**
|
|
200
|
+
* Use this to define REST calls related to the extension
|
|
201
|
+
*/
|
|
202
|
+
RESTApi: IExtensionRESTApi;
|
|
203
|
+
/**
|
|
204
|
+
* Object to manipulate messengers.
|
|
205
|
+
* Messengers are used to send messages (like emails) from the app.
|
|
206
|
+
* One type of message is a list of selected photos.
|
|
207
|
+
*/
|
|
208
|
+
messengers: IExtensionMessengers;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export interface IClientSVGIconConfig {
|
|
212
|
+
/**
|
|
213
|
+
* SVG path viewBox. See: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox
|
|
214
|
+
*/
|
|
215
|
+
viewBox: string;
|
|
216
|
+
/**
|
|
217
|
+
* Content elements (paths, circles, rects) of the SVG icon. Icons used on the map: fontawesome.com/icons.
|
|
218
|
+
*/
|
|
219
|
+
items: string;
|
|
196
220
|
}
|
|
221
|
+
|
|
222
|
+
export enum IClientMediaFields {
|
|
223
|
+
title,
|
|
224
|
+
caption,
|
|
225
|
+
cameraData,
|
|
226
|
+
positionData,
|
|
227
|
+
faces,
|
|
228
|
+
size,
|
|
229
|
+
creationDate,
|
|
230
|
+
creationDateOffset,
|
|
231
|
+
bitRate,
|
|
232
|
+
duration,
|
|
233
|
+
fileSize,
|
|
234
|
+
fps
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export interface IClientMediaButtonPopupConfig {
|
|
238
|
+
/**
|
|
239
|
+
* Header of the popup.
|
|
240
|
+
*/
|
|
241
|
+
header: string;
|
|
242
|
+
/**
|
|
243
|
+
* Body of the popup.
|
|
244
|
+
*/
|
|
245
|
+
body: string;
|
|
246
|
+
/**
|
|
247
|
+
* Fields to show in the popup as editable text fields.
|
|
248
|
+
*/
|
|
249
|
+
fields: IClientMediaFields[];
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export interface IClientMediaButtonConfig {
|
|
253
|
+
/**
|
|
254
|
+
* Name of the button. This is also used as id.
|
|
255
|
+
*/
|
|
256
|
+
name: string;
|
|
257
|
+
/**
|
|
258
|
+
* Icon of the button. This will be shown in the gallery and also in the lightbox.
|
|
259
|
+
*/
|
|
260
|
+
svgIcon: IClientSVGIconConfig;
|
|
261
|
+
/**
|
|
262
|
+
* If true, the button will be hidden if on photos
|
|
263
|
+
*/
|
|
264
|
+
skipPhotos?: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* If true, the button will be hidden if on videos
|
|
267
|
+
*/
|
|
268
|
+
skipVideos?: boolean;
|
|
269
|
+
/**
|
|
270
|
+
* Path to the server side function that will be called when the button is clicked.
|
|
271
|
+
*/
|
|
272
|
+
apiPath: string;
|
|
273
|
+
/**
|
|
274
|
+
* Popup config. IF you want conformation before calling the apiPath or want to change media metedata, set this.
|
|
275
|
+
*/
|
|
276
|
+
popup?: IClientMediaButtonPopupConfig;
|
|
277
|
+
/**
|
|
278
|
+
* If true, after calling the apiPath, the gallery content will be reloaded. (faster than reloadContent)
|
|
279
|
+
*/
|
|
280
|
+
reloadContent?: boolean;
|
|
281
|
+
/**
|
|
282
|
+
* If true, after calling the apiPath, the whole webpage will be reloaded. (slower than reloadSite)
|
|
283
|
+
*/
|
|
284
|
+
reloadSite?: boolean;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export interface IClientUIConfig {
|
|
288
|
+
mediaButtons: IClientMediaButtonConfig[];
|
|
289
|
+
}
|
|
290
|
+
|
|
197
291
|
export interface IExtensionConfigInit<C> {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
292
|
+
/**
|
|
293
|
+
* Sets the config tempalte class
|
|
294
|
+
* @param template
|
|
295
|
+
*/
|
|
296
|
+
setConfigTemplate(template: new () => C): void;
|
|
203
297
|
}
|
|
298
|
+
|
|
204
299
|
/**
|
|
205
300
|
* Extension interface. All extension is expected to implement and export these methods.
|
|
206
301
|
* This is the content of the server.js file
|
|
207
302
|
*/
|
|
208
303
|
export interface IServerExtension<C> {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
304
|
+
cleanUp?: (extension: IExtensionObject<C>) => Promise<void>;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Extension init function. Extension should at minimum expose this function.
|
|
308
|
+
* @param extension
|
|
309
|
+
*/
|
|
310
|
+
init(extension: IExtensionObject<C>): Promise<void>;
|
|
215
311
|
}
|
|
312
|
+
|
|
216
313
|
/**
|
|
217
314
|
* Extension config interface. All extension can implement and export these methods.
|
|
218
315
|
* This is the content of the config.js file.
|
|
219
316
|
*/
|
|
220
317
|
export interface IServerExtensionConfig<C> {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
318
|
+
/**
|
|
319
|
+
* This function can be called any time. It should only set the config template class
|
|
320
|
+
* @param extension
|
|
321
|
+
*/
|
|
322
|
+
initConfig(extension: IExtensionConfigInit<C>): void;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Extension interface. Extension with UI changes expectged to implement it.
|
|
327
|
+
* This is the content of the client.js file
|
|
328
|
+
*/
|
|
329
|
+
export interface IClientExtension {
|
|
330
|
+
/**
|
|
331
|
+
* Client UI options. This is how to template the UI.
|
|
332
|
+
*/
|
|
333
|
+
clinet: IClientUIConfig;
|
|
226
334
|
}
|
package/package.json
CHANGED