@karpeleslab/klbfw 0.1.2 → 0.1.6
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/fw-wrapper.js +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/rest.js +24 -6
- package/util.js +4 -0
package/fw-wrapper.js
CHANGED
|
@@ -8,6 +8,7 @@ module.exports.getCurrency = () => (typeof FW !== "undefined") ? FW.Context.c :
|
|
|
8
8
|
module.exports.getContext = () => (typeof FW !== "undefined") ? FW.Context : {};
|
|
9
9
|
module.exports.setContext = (k, v) => { if (typeof FW !== "undefined") FW.Context[k] = v; };
|
|
10
10
|
module.exports.getToken = () => (typeof FW !== "undefined") ? FW.token : undefined;
|
|
11
|
+
module.exports.getRegistry = () => (typeof FW !== "undefined") ? FW.Registry : undefined;
|
|
11
12
|
module.exports.getUrl = () => (typeof FW !== "undefined") ? FW.URL : {path: window.location.pathname, full: window.location.href};
|
|
12
13
|
module.exports.getSiteStatic = () => (typeof FW !== "undefined") ? FW.site_static : true;
|
|
13
14
|
module.exports.getCallUrlPrefix = () => (typeof FW !== "undefined") ? FW.call_url_prefix : "https://hub.atonline.com";
|
package/index.js
CHANGED
|
@@ -15,6 +15,7 @@ module.exports.getContext = internalFW.getContext;
|
|
|
15
15
|
module.exports.setContext = internalFW.setContext;
|
|
16
16
|
module.exports.getMode = internalFW.getMode;
|
|
17
17
|
module.exports.getHostname = internalFW.getHostname;
|
|
18
|
+
module.exports.getRegistry = internalFW.getRegistry;
|
|
18
19
|
module.exports.getLocale = internalFW.getLocale;
|
|
19
20
|
module.exports.getUserGroup = internalFW.getUserGroup;
|
|
20
21
|
module.exports.getCurrency = internalFW.getCurrency;
|
package/package.json
CHANGED
package/rest.js
CHANGED
|
@@ -2,15 +2,26 @@
|
|
|
2
2
|
// vim: et:ts=4:sw=4
|
|
3
3
|
|
|
4
4
|
const internal = require('./internal');
|
|
5
|
+
const fwWrapper = require('./fw-wrapper');
|
|
5
6
|
|
|
6
7
|
module.exports.rest = (name, verb, params, context) => {
|
|
8
|
+
if (typeof __platformAsyncRest !== "undefined") {
|
|
9
|
+
context = context || {};
|
|
10
|
+
var ctx_final = fwWrapper.getContext();
|
|
11
|
+
for (var i in context) ctx_final[i] = context[i];
|
|
12
|
+
return __platformAsyncRest(name, verb, params, ctx_final);
|
|
13
|
+
}
|
|
7
14
|
if (typeof __platformRest !== "undefined") {
|
|
8
15
|
// direct SSR-mode call to rest api
|
|
9
16
|
return new Promise(function(resolve, reject) {
|
|
10
17
|
__platformRest(name, verb, params, function(res, err) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
if (err) {
|
|
19
|
+
reject(err);
|
|
20
|
+
} else if (res.result != "success") {
|
|
21
|
+
reject(res);
|
|
22
|
+
} else {
|
|
23
|
+
resolve(res);
|
|
24
|
+
}
|
|
14
25
|
});
|
|
15
26
|
});
|
|
16
27
|
}
|
|
@@ -39,13 +50,20 @@ module.exports.rest = (name, verb, params, context) => {
|
|
|
39
50
|
};
|
|
40
51
|
|
|
41
52
|
module.exports.rest_get = (name, params) => {
|
|
53
|
+
if (typeof __platformAsyncRest !== "undefined") {
|
|
54
|
+
return __platformAsyncRest(name, "GET", params);
|
|
55
|
+
}
|
|
42
56
|
if (typeof __platformRest !== "undefined") {
|
|
43
57
|
// direct SSR-mode call to rest api
|
|
44
58
|
return new Promise(function(resolve, reject) {
|
|
45
59
|
__platformRest(name, "GET", params, function(res, err) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
60
|
+
if (err) {
|
|
61
|
+
reject(err);
|
|
62
|
+
} else if (res.result != "success") {
|
|
63
|
+
reject(res);
|
|
64
|
+
} else {
|
|
65
|
+
resolve(res);
|
|
66
|
+
}
|
|
49
67
|
});
|
|
50
68
|
});
|
|
51
69
|
}
|
package/util.js
CHANGED
|
@@ -4,6 +4,10 @@ const internalFW = require('./fw-wrapper');
|
|
|
4
4
|
function getI18N(language) {
|
|
5
5
|
language = language || internalFW.getLocale();
|
|
6
6
|
|
|
7
|
+
if (typeof __platformAsyncI18N !== "undefined") {
|
|
8
|
+
// new SSR mode
|
|
9
|
+
return __platformAsyncI18N(language);
|
|
10
|
+
}
|
|
7
11
|
if (typeof __platformGetI18N !== "undefined") {
|
|
8
12
|
// we are in SSR mode
|
|
9
13
|
return new Promise(function (resolve, reject) {
|