@vsaas/loopback-datasource-juggler 11.1.0 → 11.2.0
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/lib/model.js +11 -2
- package/dist/lib/utils.js +31 -2
- package/dist/package.js +4 -4
- package/package.json +6 -6
package/dist/lib/model.js
CHANGED
|
@@ -36,6 +36,15 @@ var require_model = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, mod
|
|
|
36
36
|
Text: true,
|
|
37
37
|
ObjectID: true
|
|
38
38
|
};
|
|
39
|
+
function isSelectedField(fields, key) {
|
|
40
|
+
if (fields.indexOf(key) !== -1) return true;
|
|
41
|
+
const prefix = key + ".";
|
|
42
|
+
for (let i = 0; i < fields.length; i++) {
|
|
43
|
+
const field = fields[i];
|
|
44
|
+
if (typeof field === "string" && field.indexOf(prefix) === 0) return true;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
39
48
|
/**
|
|
40
49
|
* Model class: base class for all persistent objects.
|
|
41
50
|
*
|
|
@@ -128,7 +137,7 @@ var require_model = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, mod
|
|
|
128
137
|
if (data.__cachedRelations) this.__cachedRelations = data.__cachedRelations;
|
|
129
138
|
let keys = Object.keys(data);
|
|
130
139
|
if (Array.isArray(options.fields)) keys = keys.filter(function(k) {
|
|
131
|
-
return options.fields
|
|
140
|
+
return isSelectedField(options.fields, k);
|
|
132
141
|
});
|
|
133
142
|
let size = keys.length;
|
|
134
143
|
let p, propVal;
|
|
@@ -170,7 +179,7 @@ var require_model = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, mod
|
|
|
170
179
|
}
|
|
171
180
|
keys = Object.keys(properties);
|
|
172
181
|
if (Array.isArray(options.fields)) keys = keys.filter(function(k) {
|
|
173
|
-
return options.fields
|
|
182
|
+
return isSelectedField(options.fields, k);
|
|
174
183
|
});
|
|
175
184
|
size = keys.length;
|
|
176
185
|
for (let k = 0; k < size; k++) {
|
package/dist/lib/utils.js
CHANGED
|
@@ -196,21 +196,50 @@ var require_utils = /* @__PURE__ */ require_runtime.__commonJSMin(((exports) =>
|
|
|
196
196
|
}
|
|
197
197
|
let fieldArray = [];
|
|
198
198
|
if (excludeUnknown) {
|
|
199
|
-
for (i = 0, n = result.length; i < n; i++) if (
|
|
199
|
+
for (i = 0, n = result.length; i < n; i++) if (isKnownField(result[i], properties)) fieldArray.push(result[i]);
|
|
200
200
|
} else fieldArray = result;
|
|
201
201
|
return fieldArray;
|
|
202
202
|
}
|
|
203
|
+
function isKnownField(field, properties) {
|
|
204
|
+
if (properties.indexOf(field) !== -1) return true;
|
|
205
|
+
if (typeof field !== "string") return false;
|
|
206
|
+
const dotIndex = field.indexOf(".");
|
|
207
|
+
if (dotIndex <= 0) return false;
|
|
208
|
+
return properties.indexOf(field.slice(0, dotIndex)) !== -1;
|
|
209
|
+
}
|
|
203
210
|
function selectFields(fields) {
|
|
204
211
|
return function(obj) {
|
|
205
212
|
const result = {};
|
|
206
213
|
let key;
|
|
207
214
|
for (let i = 0; i < fields.length; i++) {
|
|
208
215
|
key = fields[i];
|
|
209
|
-
result
|
|
216
|
+
copySelectedField(obj, result, key);
|
|
210
217
|
}
|
|
211
218
|
return result;
|
|
212
219
|
};
|
|
213
220
|
}
|
|
221
|
+
function copySelectedField(source, target, field) {
|
|
222
|
+
if (typeof field !== "string" || field.indexOf(".") === -1 || Object.prototype.hasOwnProperty.call(source, field)) {
|
|
223
|
+
target[field] = source[field];
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const segments = field.split(".");
|
|
227
|
+
let value = source;
|
|
228
|
+
for (let i = 0; i < segments.length; i++) {
|
|
229
|
+
if (value == null || typeof value !== "object") {
|
|
230
|
+
value = void 0;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
value = value[segments[i]];
|
|
234
|
+
}
|
|
235
|
+
let cursor = target;
|
|
236
|
+
for (let i = 0; i < segments.length - 1; i++) {
|
|
237
|
+
const segment = segments[i];
|
|
238
|
+
if (!cursor[segment] || typeof cursor[segment] !== "object") cursor[segment] = {};
|
|
239
|
+
cursor = cursor[segment];
|
|
240
|
+
}
|
|
241
|
+
cursor[segments[segments.length - 1]] = value;
|
|
242
|
+
}
|
|
214
243
|
function isProhibited(key, prohibitedKeys) {
|
|
215
244
|
if (!prohibitedKeys || !prohibitedKeys.length) return false;
|
|
216
245
|
if (typeof key !== "string") return false;
|
package/dist/package.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var require_package = /* @__PURE__ */ require("./_virtual/_rolldown/runtime.js").__commonJSMin(((exports, module) => {
|
|
3
3
|
module.exports = {
|
|
4
4
|
"name": "@vsaas/loopback-datasource-juggler",
|
|
5
|
-
"version": "11.
|
|
5
|
+
"version": "11.2.0",
|
|
6
6
|
"description": "Fork of loopback-datasource-juggler for LoopBack 3 style applications",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"Connector",
|
|
@@ -63,12 +63,12 @@ var require_package = /* @__PURE__ */ require("./_virtual/_rolldown/runtime.js")
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@vsaas/loopback-connector": "workspace:^",
|
|
66
|
-
"debug": "
|
|
66
|
+
"debug": "catalog:",
|
|
67
67
|
"depd": "^2.0.0",
|
|
68
68
|
"inflection": "^3.0.2",
|
|
69
69
|
"minimatch": "10.2.4",
|
|
70
70
|
"neotraverse": "^0.6.18",
|
|
71
|
-
"qs": "
|
|
71
|
+
"qs": "catalog:"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@types/node": "catalog:",
|
|
@@ -76,7 +76,7 @@ var require_package = /* @__PURE__ */ require("./_virtual/_rolldown/runtime.js")
|
|
|
76
76
|
"loopback-connector-throwing": "workspace:*",
|
|
77
77
|
"oxfmt": "catalog:",
|
|
78
78
|
"oxlint": "catalog:",
|
|
79
|
-
"should": "
|
|
79
|
+
"should": "catalog:",
|
|
80
80
|
"tsdown": "catalog:",
|
|
81
81
|
"typescript": "catalog:",
|
|
82
82
|
"vitest": "catalog:"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vsaas/loopback-datasource-juggler",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.2.0",
|
|
4
4
|
"description": "Fork of loopback-datasource-juggler for LoopBack 3 style applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Connector",
|
|
@@ -51,23 +51,23 @@
|
|
|
51
51
|
"registry": "https://registry.npmjs.org/"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"debug": "
|
|
54
|
+
"debug": "4.4.3",
|
|
55
55
|
"depd": "^2.0.0",
|
|
56
56
|
"inflection": "^3.0.2",
|
|
57
57
|
"minimatch": "10.2.4",
|
|
58
58
|
"neotraverse": "^0.6.18",
|
|
59
|
-
"qs": "
|
|
60
|
-
"@vsaas/loopback-connector": "^11.0.
|
|
59
|
+
"qs": "6.15.0",
|
|
60
|
+
"@vsaas/loopback-connector": "^11.0.3"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/node": "25.5.0",
|
|
64
64
|
"bson": "^4.7.2",
|
|
65
65
|
"oxfmt": "0.42.0",
|
|
66
66
|
"oxlint": "1.57.0",
|
|
67
|
-
"should": "
|
|
67
|
+
"should": "13.2.3",
|
|
68
68
|
"tsdown": "0.21.7",
|
|
69
69
|
"typescript": "6.0.2",
|
|
70
|
-
"vitest": "4.1.
|
|
70
|
+
"vitest": "4.1.4",
|
|
71
71
|
"loopback-connector-throwing": "1.0.0"
|
|
72
72
|
},
|
|
73
73
|
"engines": {
|