spice-js 2.6.9 → 2.6.11
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/build/bootstrap/cache.js +13 -7
- package/build/models/SpiceModel.js +9 -2
- package/package.json +1 -1
- package/src/bootstrap/cache.js +14 -12
- package/src/models/SpiceModel.js +11 -6
package/build/bootstrap/cache.js
CHANGED
|
@@ -11,16 +11,22 @@ function connect() {
|
|
|
11
11
|
function _connect() {
|
|
12
12
|
_connect = _asyncToGenerator(function* () {
|
|
13
13
|
try {
|
|
14
|
+
var _spice$config, _spice$config$cache;
|
|
15
|
+
|
|
14
16
|
spice.cache_providers = {};
|
|
15
17
|
spice.monitor = new Map();
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
if ((_spice$config = spice.config) == null ? void 0 : (_spice$config$cache = _spice$config.cache) == null ? void 0 : _spice$config$cache.providers) {
|
|
20
|
+
for (var key of Object.keys(((_spice$config$cache2 = spice.config.cache) == null ? void 0 : _spice$config$cache2.providers) || {})) {
|
|
21
|
+
var _spice$config$cache2;
|
|
22
|
+
|
|
23
|
+
spice.cache_providers[key] = new spice.config.cache.providers[key](spice.config.cache.drivers[key] || {});
|
|
24
|
+
spice.cache_providers[key].initialize().then(() => {
|
|
25
|
+
console.log("Redis initialized successfully");
|
|
26
|
+
}).catch(err => {
|
|
27
|
+
console.error("Error initializing Redis:", err);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
24
30
|
}
|
|
25
31
|
} catch (e) {
|
|
26
32
|
console.log(e.stack);
|
|
@@ -212,8 +212,14 @@ class SpiceModel {
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
if (_this[_ctx]) {
|
|
215
|
-
var
|
|
216
|
-
|
|
215
|
+
var _this$_ctx, _this$_ctx$state;
|
|
216
|
+
|
|
217
|
+
if ((_this$_ctx = _this[_ctx]) == null ? void 0 : (_this$_ctx$state = _this$_ctx.state) == null ? void 0 : _this$_ctx$state.process_fields) {
|
|
218
|
+
var returned = yield new _this[_ctx].state.process_fields().process(_this[_ctx], data, _this.type);
|
|
219
|
+
return returned;
|
|
220
|
+
} else {
|
|
221
|
+
return data;
|
|
222
|
+
}
|
|
217
223
|
}
|
|
218
224
|
|
|
219
225
|
return [];
|
|
@@ -561,6 +567,7 @@ class SpiceModel {
|
|
|
561
567
|
}
|
|
562
568
|
}
|
|
563
569
|
} catch (e) {
|
|
570
|
+
console.log(e.message, e);
|
|
564
571
|
throw e;
|
|
565
572
|
}
|
|
566
573
|
})();
|
package/package.json
CHANGED
package/src/bootstrap/cache.js
CHANGED
|
@@ -4,18 +4,20 @@ async function connect() {
|
|
|
4
4
|
try {
|
|
5
5
|
spice.cache_providers = {};
|
|
6
6
|
spice.monitor = new Map();
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
spice.config.cache.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
if (spice.config?.cache?.providers) {
|
|
8
|
+
for (let key of Object.keys(spice.config.cache?.providers || {})) {
|
|
9
|
+
spice.cache_providers[key] = new spice.config.cache.providers[key](
|
|
10
|
+
spice.config.cache.drivers[key] || {}
|
|
11
|
+
);
|
|
12
|
+
spice.cache_providers[key]
|
|
13
|
+
.initialize()
|
|
14
|
+
.then(() => {
|
|
15
|
+
console.log("Redis initialized successfully");
|
|
16
|
+
})
|
|
17
|
+
.catch((err) => {
|
|
18
|
+
console.error("Error initializing Redis:", err);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
} catch (e) {
|
|
21
23
|
console.log(e.stack);
|
package/src/models/SpiceModel.js
CHANGED
|
@@ -188,12 +188,16 @@ export default class SpiceModel {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
if (this[_ctx]) {
|
|
191
|
-
|
|
192
|
-
this[_ctx]
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
191
|
+
if (this[_ctx]?.state?.process_fields) {
|
|
192
|
+
let returned = await new this[_ctx].state.process_fields().process(
|
|
193
|
+
this[_ctx],
|
|
194
|
+
data,
|
|
195
|
+
this.type
|
|
196
|
+
);
|
|
197
|
+
return returned;
|
|
198
|
+
} else {
|
|
199
|
+
return data;
|
|
200
|
+
}
|
|
197
201
|
}
|
|
198
202
|
return [];
|
|
199
203
|
}
|
|
@@ -484,6 +488,7 @@ export default class SpiceModel {
|
|
|
484
488
|
}
|
|
485
489
|
}
|
|
486
490
|
} catch (e) {
|
|
491
|
+
console.log(e.message, e);
|
|
487
492
|
throw e;
|
|
488
493
|
}
|
|
489
494
|
}
|