@solidstarters/solid-core 1.2.70 → 1.2.72
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/dist/services/crud.service.js +1 -1
- package/dist/services/crud.service.js.map +1 -1
- package/dist/services/setting.service.d.ts.map +1 -1
- package/dist/services/setting.service.js +11 -3
- package/dist/services/setting.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/services/crud.service.ts +1 -1
- package/src/services/setting.service.ts +55 -47
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidstarters/solid-core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.72",
|
|
4
4
|
"description": "This module is a NestJS module containing all the required core providers required by a Solid application",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -520,7 +520,7 @@ export class CRUDService<T> { // Add two generic value i.e Person,CreatePersonDt
|
|
|
520
520
|
// Populate the media field entities with the full URL
|
|
521
521
|
for (const mediaFieldEntity of mediaFieldEntities) {
|
|
522
522
|
const mediaWithFullUrl = await this.getMediaWithFullUrl(mediaFieldEntity, mediaFieldMetadata);
|
|
523
|
-
this.appendMediaKey(mediaWithFullUrl, mediaFieldEntity,
|
|
523
|
+
this.appendMediaKey(mediaWithFullUrl, mediaFieldEntity, mediaFieldMetadata.name);
|
|
524
524
|
// mediaFieldEntity['_media'][mediaFieldPath] = mediaWithFullUrl
|
|
525
525
|
}
|
|
526
526
|
}
|
|
@@ -47,9 +47,13 @@ export class SettingService extends CRUDService<Setting> {
|
|
|
47
47
|
iamGoogleOAuthEnabled: false,
|
|
48
48
|
authPagesLayout: "center",
|
|
49
49
|
authPagesTheme: "light",
|
|
50
|
-
appTitle: process.env.SOLID_APP_NAME || "Solid App",
|
|
51
50
|
appLogo: "",
|
|
52
|
-
|
|
51
|
+
appLogoPosition: "in_form_view",
|
|
52
|
+
showAuthContent: false,
|
|
53
|
+
appTitle: process.env.SOLID_APP_NAME || "Solid App",
|
|
54
|
+
appSubtitle: process.env.SOLID_APP_SUBTITLE || "Lorem Ipsum",
|
|
55
|
+
appDescription: process.env.SOLID_APP_DESCRIPTION || "lorem ipsum",
|
|
56
|
+
showLegalLinks: false,
|
|
53
57
|
appTnc: "",
|
|
54
58
|
appPrivacyPolicy: "",
|
|
55
59
|
defaultRole: this.iamConfiguration.defaultRole,
|
|
@@ -65,9 +69,9 @@ export class SettingService extends CRUDService<Setting> {
|
|
|
65
69
|
if (!existingKeys.has(key)) {
|
|
66
70
|
const setting = new Setting();
|
|
67
71
|
setting.key = key;
|
|
68
|
-
setting.value = typeof value === 'boolean' ? value.toString() :
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
setting.value = typeof value === 'boolean' ? value.toString() :
|
|
73
|
+
Array.isArray(value) ? value.join(',') :
|
|
74
|
+
value === null || value === undefined ? '' : String(value);
|
|
71
75
|
settingsToInsert.push(setting);
|
|
72
76
|
}
|
|
73
77
|
}
|
|
@@ -79,16 +83,16 @@ export class SettingService extends CRUDService<Setting> {
|
|
|
79
83
|
|
|
80
84
|
async wrapSettings(): Promise<Record<string, any>> {
|
|
81
85
|
const settingsArray: Setting[] = await this.repo.find();
|
|
82
|
-
|
|
86
|
+
|
|
83
87
|
if (!settingsArray || settingsArray.length === 0) {
|
|
84
88
|
return this.getDefaultSettings();
|
|
85
89
|
}
|
|
86
|
-
|
|
90
|
+
|
|
87
91
|
const settingsMap: Record<string, any> = {};
|
|
88
92
|
for (const setting of settingsArray) {
|
|
89
93
|
if (setting.key && setting.value !== undefined && setting.value !== null) {
|
|
90
94
|
let value = setting.value;
|
|
91
|
-
|
|
95
|
+
|
|
92
96
|
if (value === 'true' || value === 'false') {
|
|
93
97
|
settingsMap[setting.key] = value === 'true';
|
|
94
98
|
}
|
|
@@ -103,17 +107,17 @@ export class SettingService extends CRUDService<Setting> {
|
|
|
103
107
|
}
|
|
104
108
|
}
|
|
105
109
|
}
|
|
106
|
-
|
|
110
|
+
|
|
107
111
|
const defaultSettings = this.getDefaultSettings();
|
|
108
|
-
|
|
112
|
+
|
|
109
113
|
const mergedSettings = Object.keys(defaultSettings).reduce((acc, key) => {
|
|
110
114
|
acc[key] = settingsMap[key] !== undefined ? settingsMap[key] : defaultSettings[key];
|
|
111
115
|
return acc;
|
|
112
116
|
}, {} as Record<string, any>);
|
|
113
|
-
|
|
117
|
+
|
|
114
118
|
return mergedSettings;
|
|
115
119
|
}
|
|
116
|
-
|
|
120
|
+
|
|
117
121
|
private getDefaultSettings(): Record<string, any> {
|
|
118
122
|
return {
|
|
119
123
|
allowPublicRegistration: this.iamConfiguration.allowPublicRegistration,
|
|
@@ -123,9 +127,13 @@ export class SettingService extends CRUDService<Setting> {
|
|
|
123
127
|
iamGoogleOAuthEnabled: false,
|
|
124
128
|
authPagesLayout: "center",
|
|
125
129
|
authPagesTheme: "light",
|
|
126
|
-
appTitle: process.env.SOLID_APP_NAME || "Solid App",
|
|
127
130
|
appLogo: "",
|
|
131
|
+
appLogoPosition: "in_form_view", //in_form_view | in_image_view
|
|
132
|
+
showAuthContent: false,
|
|
133
|
+
appTitle: process.env.SOLID_APP_NAME || "Solid App",
|
|
134
|
+
appSubtitle: "",
|
|
128
135
|
appDescription: "",
|
|
136
|
+
showLegalLinks: false,
|
|
129
137
|
appTnc: "",
|
|
130
138
|
appPrivacyPolicy: "",
|
|
131
139
|
defaultRole: this.iamConfiguration.defaultRole,
|
|
@@ -136,45 +144,45 @@ export class SettingService extends CRUDService<Setting> {
|
|
|
136
144
|
|
|
137
145
|
async getConfigValue(settingKey: string) {
|
|
138
146
|
try {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
else if (!isNaN(Number(value)) && value.trim() !== '') {
|
|
149
|
-
return Number(value);
|
|
150
|
-
}
|
|
151
|
-
else if (value.includes(',')) {
|
|
152
|
-
return value.split(',').map(item => item.trim());
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
return value;
|
|
156
|
-
}
|
|
147
|
+
const settingsArray: Setting[] = await this.repo.find();
|
|
148
|
+
const settingEntry = settingsArray.find(setting => setting.key === settingKey);
|
|
149
|
+
|
|
150
|
+
if (settingEntry && settingEntry.value !== null && settingEntry.value !== undefined) {
|
|
151
|
+
const value = settingEntry.value;
|
|
152
|
+
|
|
153
|
+
if (value === 'true' || value === 'false') {
|
|
154
|
+
return value === 'true';
|
|
157
155
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
156
|
+
else if (!isNaN(Number(value)) && value.trim() !== '') {
|
|
157
|
+
return Number(value);
|
|
158
|
+
}
|
|
159
|
+
else if (value.includes(',')) {
|
|
160
|
+
return value.split(',').map(item => item.trim());
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
return value;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const defaultSettings = this.getDefaultSettings();
|
|
168
|
+
return defaultSettings[settingKey];
|
|
161
169
|
} catch (error) {
|
|
162
|
-
|
|
163
|
-
|
|
170
|
+
const defaultSettings = this.getDefaultSettings();
|
|
171
|
+
return defaultSettings[settingKey];
|
|
164
172
|
}
|
|
165
173
|
}
|
|
166
174
|
|
|
167
175
|
async updateSettings(settings: Record<string, any>): Promise<Setting[]> {
|
|
168
176
|
const existingSettings = await this.repo.find();
|
|
169
177
|
const existingKeys = new Set(existingSettings.map(s => s.key));
|
|
170
|
-
|
|
178
|
+
|
|
171
179
|
const settingsToUpdate: Setting[] = [];
|
|
172
180
|
const settingsToCreate: Setting[] = [];
|
|
173
|
-
|
|
181
|
+
|
|
174
182
|
for (const [key, value] of Object.entries(settings)) {
|
|
175
|
-
const stringValue = typeof value === 'boolean' ? value.toString() :
|
|
176
|
-
|
|
177
|
-
|
|
183
|
+
const stringValue = typeof value === 'boolean' ? value.toString() :
|
|
184
|
+
Array.isArray(value) ? value.join(',') :
|
|
185
|
+
value === null || value === undefined ? '' : String(value);
|
|
178
186
|
|
|
179
187
|
if (existingKeys.has(key)) {
|
|
180
188
|
const existingSetting = existingSettings.find(s => s.key === key);
|
|
@@ -189,26 +197,26 @@ export class SettingService extends CRUDService<Setting> {
|
|
|
189
197
|
settingsToCreate.push(newSetting);
|
|
190
198
|
}
|
|
191
199
|
}
|
|
192
|
-
|
|
200
|
+
|
|
193
201
|
if (settingsToUpdate.length > 0) {
|
|
194
202
|
await this.repo.save(settingsToUpdate);
|
|
195
203
|
}
|
|
196
|
-
|
|
204
|
+
|
|
197
205
|
if (settingsToCreate.length > 0) {
|
|
198
206
|
await this.repo.save(settingsToCreate);
|
|
199
207
|
}
|
|
200
|
-
|
|
208
|
+
|
|
201
209
|
return [...settingsToUpdate, ...settingsToCreate];
|
|
202
210
|
}
|
|
203
211
|
|
|
204
212
|
async getAllSettings(): Promise<Record<string, any>> {
|
|
205
213
|
const settingsArray = await this.repo.find();
|
|
206
214
|
const settingsMap: Record<string, any> = {};
|
|
207
|
-
|
|
215
|
+
|
|
208
216
|
for (const setting of settingsArray) {
|
|
209
217
|
if (setting.key && setting.value !== undefined && setting.value !== null) {
|
|
210
218
|
const value = setting.value;
|
|
211
|
-
|
|
219
|
+
|
|
212
220
|
if (value === 'true' || value === 'false') {
|
|
213
221
|
settingsMap[setting.key] = value === 'true';
|
|
214
222
|
}
|
|
@@ -223,7 +231,7 @@ export class SettingService extends CRUDService<Setting> {
|
|
|
223
231
|
}
|
|
224
232
|
}
|
|
225
233
|
}
|
|
226
|
-
|
|
234
|
+
|
|
227
235
|
return settingsMap;
|
|
228
236
|
}
|
|
229
237
|
}
|