spice-js 2.6.28 → 2.6.31
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.
|
@@ -6,19 +6,17 @@ var _fs = _interopRequireDefault(require("fs"));
|
|
|
6
6
|
|
|
7
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
8
|
|
|
9
|
-
spice.routers = {};
|
|
10
|
-
|
|
11
9
|
var paths = _path.default.join(spice.root_path, "schema_extenders");
|
|
12
10
|
|
|
13
|
-
spice.
|
|
11
|
+
spice.schema_extenders = {};
|
|
14
12
|
|
|
15
13
|
if (_fs.default.existsSync(paths)) {
|
|
16
14
|
_fs.default.readdirSync(paths).forEach(function (file) {
|
|
17
|
-
if (_path.default.extname(file) ===
|
|
15
|
+
if (_path.default.extname(file) === ".js" && file !== "index.js") {
|
|
18
16
|
try {
|
|
19
17
|
var extender = require(_path.default.join(paths, file));
|
|
20
18
|
|
|
21
|
-
spice.
|
|
19
|
+
spice.schema_extenders[_path.default.basename(file, ".js")] = extender;
|
|
22
20
|
} catch (error) {
|
|
23
21
|
console.error("Failed to load " + file + ":", error);
|
|
24
22
|
}
|
package/package.json
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
|
-
|
|
4
|
-
spice.routers = {};
|
|
5
|
-
|
|
6
3
|
let paths = path.join(spice.root_path, "schema_extenders");
|
|
7
|
-
spice.
|
|
8
|
-
|
|
4
|
+
spice.schema_extenders = {};
|
|
9
5
|
if (fs.existsSync(paths)) {
|
|
10
6
|
fs.readdirSync(paths).forEach(function (file) {
|
|
11
|
-
if (path.extname(file) ===
|
|
7
|
+
if (path.extname(file) === ".js" && file !== "index.js") {
|
|
12
8
|
try {
|
|
13
9
|
let extender = require(path.join(paths, file));
|
|
14
|
-
spice.
|
|
10
|
+
spice.schema_extenders[path.basename(file, ".js")] = extender;
|
|
15
11
|
} catch (error) {
|
|
16
12
|
console.error(`Failed to load ${file}:`, error);
|
|
17
13
|
}
|
|
18
14
|
}
|
|
19
15
|
});
|
|
20
|
-
}
|
|
16
|
+
}
|
package/src/models/SpiceModel.js
CHANGED
|
@@ -130,21 +130,17 @@ export default class SpiceModel {
|
|
|
130
130
|
for (let file_name in spice.schema_extenders) {
|
|
131
131
|
let extender = spice.schema_extenders[file_name];
|
|
132
132
|
if (resourceHasExtender(resource, extender)) {
|
|
133
|
-
|
|
134
133
|
for (let j in props) {
|
|
135
134
|
if (hasExtender(resource, props[j], extender)) {
|
|
136
|
-
|
|
137
135
|
props[j] = applyExtenderModifier(props[j], resource, extender);
|
|
138
|
-
|
|
139
136
|
}
|
|
140
137
|
}
|
|
141
138
|
if (extender?.creator) {
|
|
142
|
-
|
|
143
139
|
props = _.merge(props, extender.creator(resource));
|
|
144
140
|
}
|
|
145
141
|
}
|
|
146
|
-
return props;
|
|
147
142
|
}
|
|
143
|
+
return props;
|
|
148
144
|
}
|
|
149
145
|
//console.log("Applying Overrides to :", this.collection,'||', args.collection)
|
|
150
146
|
args.props = applySchemaOverrides(
|