badmfck-api-server 3.3.3 → 3.3.4
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.
@@ -95,7 +95,7 @@ async function Initializer(services) {
|
|
95
95
|
exports.Initializer = Initializer;
|
96
96
|
class APIService extends BaseService_1.BaseService {
|
97
97
|
static nextLogID = 0;
|
98
|
-
version = "3.3.
|
98
|
+
version = "3.3.3";
|
99
99
|
options;
|
100
100
|
monitor = null;
|
101
101
|
started = new Date();
|
@@ -196,26 +196,38 @@ class Validator {
|
|
196
196
|
static syncStructure(structure, object) {
|
197
197
|
if (typeof structure !== "object")
|
198
198
|
return;
|
199
|
-
if (typeof object !== "object")
|
200
|
-
return;
|
201
199
|
for (const key in object) {
|
202
200
|
if (!(key in structure)) {
|
203
201
|
delete object[key];
|
204
202
|
}
|
205
203
|
}
|
206
204
|
for (const key in structure) {
|
207
|
-
const
|
208
|
-
const
|
205
|
+
const structureValue = structure[key];
|
206
|
+
const objectValue = object[key];
|
209
207
|
if (!(key in object)) {
|
210
|
-
object[key] =
|
208
|
+
object[key] = structureValue;
|
209
|
+
continue;
|
210
|
+
}
|
211
|
+
if (objectValue === null && structureValue !== null) {
|
212
|
+
if (!structure["$__" + key + "_optional"])
|
213
|
+
object[key] = structureValue;
|
214
|
+
continue;
|
215
|
+
}
|
216
|
+
if (key.startsWith("$__")) {
|
217
|
+
object[key] = structure[key];
|
218
|
+
continue;
|
211
219
|
}
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
220
|
+
if (objectValue && typeof objectValue === "object") {
|
221
|
+
if (Array.isArray(objectValue) && Array.isArray(structureValue) && structureValue.length > 0) {
|
222
|
+
for (let i of objectValue) {
|
223
|
+
if (typeof i === "object")
|
224
|
+
this.syncStructure(structureValue[0], i);
|
225
|
+
}
|
226
|
+
}
|
227
|
+
else {
|
228
|
+
this.syncStructure(structureValue, objectValue);
|
229
|
+
}
|
230
|
+
continue;
|
219
231
|
}
|
220
232
|
}
|
221
233
|
return object;
|