generated from teqfw/repo-tmpl-mod
/
Local.mjs
57 lines (54 loc) · 1.64 KB
/
Local.mjs
1
2
3
4
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
/**
* Local configuration DTO for the plugin.
* @see TeqFw_Core_Back_Config
*/
// MODULE'S VARS
const NS = 'TeqFw_Web_Back_Plugin_Dto_Config_Local';
// MODULE'S CLASSES
/**
* @memberOf TeqFw_Web_Back_Plugin_Dto_Config_Local
*/
class Dto {
static namespace = NS;
/**
* Any custom object to use as application configuration on the front.
* @type {Object}
*/
custom;
/** @type {boolean} */
frontLogsMonitoring;
/** @type {TeqFw_Web_Back_Plugin_Dto_Config_Local_Server} */
server;
/** @type {string} base for URL constructing */
urlBase;
}
/**
* @implements TeqFw_Core_Shared_Api_Factory_Dto
*/
export default class TeqFw_Web_Back_Plugin_Dto_Config_Local {
/**
* @param {TeqFw_Core_Shared_Util_Cast} cast
* @param {TeqFw_Web_Back_Plugin_Dto_Config_Local_Server.Factory} fServer
*/
constructor(
{
TeqFw_Core_Shared_Util_Cast$: cast,
'TeqFw_Web_Back_Plugin_Dto_Config_Local_Server.Factory$': fServer,
}
) {
/**
* @param {TeqFw_Web_Back_Plugin_Dto_Config_Local.Dto} data
* @return {TeqFw_Web_Back_Plugin_Dto_Config_Local.Dto}
*/
this.createDto = function (data) {
// create new DTO and populate it with initialization data
const res = Object.assign(new Dto(), data);
// cast known attributes
res.custom = structuredClone(data?.custom);
res.frontLogsMonitoring = cast.boolean(data?.frontLogsMonitoring);
res.server = fServer.create(data?.server);
res.urlBase = cast.string(data?.urlBase);
return res;
};
}
}