remult 0.15.5-exp.1 → 0.15.5-exp.2
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.
|
@@ -132,6 +132,12 @@ export class RestDataProviderHttpProviderUsingFetch {
|
|
|
132
132
|
var h = init.headers;
|
|
133
133
|
h.append('Content-type', "application/json");
|
|
134
134
|
init.credentials = 'include';
|
|
135
|
+
if (typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof (window.document.cookie !== 'undefined'))
|
|
136
|
+
for (const cookie of window.document.cookie.split(';')) {
|
|
137
|
+
if (cookie.trim().startsWith('XSRF-TOKEN=')) {
|
|
138
|
+
h.append('X-XSRF-TOKEN', cookie.split('=')[1]);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
135
141
|
return (this.fetch || fetch)(url, init).then(response => {
|
|
136
142
|
return onSuccess(response);
|
|
137
143
|
}).catch(async (error) => {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Remult } from "./context";
|
|
2
|
+
import { RepositoryImplementation } from "./remult3";
|
|
3
|
+
let defaultRemult = new Remult();
|
|
4
|
+
/*@internal*/
|
|
5
|
+
export class RemultProxy {
|
|
6
|
+
constructor() {
|
|
7
|
+
/*@internal*/
|
|
8
|
+
this.remultFactory = () => defaultRemult;
|
|
9
|
+
this.repo = (...args) => this.remultFactory().repo(...args);
|
|
10
|
+
}
|
|
11
|
+
call(backendMethod, self) {
|
|
12
|
+
return this.remultFactory().call(backendMethod, self);
|
|
13
|
+
}
|
|
14
|
+
get context() {
|
|
15
|
+
return this.remultFactory().context;
|
|
16
|
+
}
|
|
17
|
+
get dataProvider() { return this.remultFactory().dataProvider; }
|
|
18
|
+
;
|
|
19
|
+
set dataProvider(provider) { this.remultFactory().dataProvider = provider; }
|
|
20
|
+
get repCache() { return this.remultFactory().repCache; }
|
|
21
|
+
;
|
|
22
|
+
authenticated() {
|
|
23
|
+
return this.remultFactory().authenticated();
|
|
24
|
+
}
|
|
25
|
+
isAllowed(roles) {
|
|
26
|
+
return this.remultFactory().isAllowed(roles);
|
|
27
|
+
}
|
|
28
|
+
isAllowedForInstance(instance, allowed) {
|
|
29
|
+
return this.remultFactory().isAllowedForInstance(instance, allowed);
|
|
30
|
+
}
|
|
31
|
+
clearAllCache() {
|
|
32
|
+
return this.remultFactory().clearAllCache();
|
|
33
|
+
}
|
|
34
|
+
get user() {
|
|
35
|
+
return this.remultFactory().user;
|
|
36
|
+
}
|
|
37
|
+
set user(info) {
|
|
38
|
+
this.remultFactory().user = info;
|
|
39
|
+
}
|
|
40
|
+
get apiClient() {
|
|
41
|
+
return this.remultFactory().apiClient;
|
|
42
|
+
}
|
|
43
|
+
set apiClient(client) {
|
|
44
|
+
this.remultFactory().apiClient = client;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export const remult = new RemultProxy();
|
|
48
|
+
RepositoryImplementation.defaultRemult = remult;
|
package/package.json
CHANGED
|
@@ -198,6 +198,7 @@ var RestDataProviderHttpProviderUsingFetch = /** @class */ (function () {
|
|
|
198
198
|
});
|
|
199
199
|
};
|
|
200
200
|
RestDataProviderHttpProviderUsingFetch.prototype.myFetch = function (url, init) {
|
|
201
|
+
var e_4, _a;
|
|
201
202
|
var _this = this;
|
|
202
203
|
if (!init)
|
|
203
204
|
init = {};
|
|
@@ -206,6 +207,22 @@ var RestDataProviderHttpProviderUsingFetch = /** @class */ (function () {
|
|
|
206
207
|
var h = init.headers;
|
|
207
208
|
h.append('Content-type', "application/json");
|
|
208
209
|
init.credentials = 'include';
|
|
210
|
+
if (typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof (window.document.cookie !== 'undefined'))
|
|
211
|
+
try {
|
|
212
|
+
for (var _b = tslib_1.__values(window.document.cookie.split(';')), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
213
|
+
var cookie = _c.value;
|
|
214
|
+
if (cookie.trim().startsWith('XSRF-TOKEN=')) {
|
|
215
|
+
h.append('X-XSRF-TOKEN', cookie.split('=')[1]);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
220
|
+
finally {
|
|
221
|
+
try {
|
|
222
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
223
|
+
}
|
|
224
|
+
finally { if (e_4) throw e_4.error; }
|
|
225
|
+
}
|
|
209
226
|
return (this.fetch || fetch)(url, init).then(function (response) {
|
|
210
227
|
return onSuccess(response);
|
|
211
228
|
}).catch(function (error) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.remult = exports.RemultProxy = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var context_1 = require("./context");
|
|
6
|
+
var remult3_1 = require("./remult3");
|
|
7
|
+
var defaultRemult = new context_1.Remult();
|
|
8
|
+
/*@internal*/
|
|
9
|
+
var RemultProxy = /** @class */ (function () {
|
|
10
|
+
function RemultProxy() {
|
|
11
|
+
var _this = this;
|
|
12
|
+
/*@internal*/
|
|
13
|
+
this.remultFactory = function () { return defaultRemult; };
|
|
14
|
+
this.repo = function () {
|
|
15
|
+
var _a;
|
|
16
|
+
var args = [];
|
|
17
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
18
|
+
args[_i] = arguments[_i];
|
|
19
|
+
}
|
|
20
|
+
return (_a = _this.remultFactory()).repo.apply(_a, tslib_1.__spread(args));
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
RemultProxy.prototype.call = function (backendMethod, self) {
|
|
24
|
+
return this.remultFactory().call(backendMethod, self);
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(RemultProxy.prototype, "context", {
|
|
27
|
+
get: function () {
|
|
28
|
+
return this.remultFactory().context;
|
|
29
|
+
},
|
|
30
|
+
enumerable: false,
|
|
31
|
+
configurable: true
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(RemultProxy.prototype, "dataProvider", {
|
|
34
|
+
get: function () { return this.remultFactory().dataProvider; },
|
|
35
|
+
set: function (provider) { this.remultFactory().dataProvider = provider; },
|
|
36
|
+
enumerable: false,
|
|
37
|
+
configurable: true
|
|
38
|
+
});
|
|
39
|
+
;
|
|
40
|
+
Object.defineProperty(RemultProxy.prototype, "repCache", {
|
|
41
|
+
get: function () { return this.remultFactory().repCache; },
|
|
42
|
+
enumerable: false,
|
|
43
|
+
configurable: true
|
|
44
|
+
});
|
|
45
|
+
;
|
|
46
|
+
RemultProxy.prototype.authenticated = function () {
|
|
47
|
+
return this.remultFactory().authenticated();
|
|
48
|
+
};
|
|
49
|
+
RemultProxy.prototype.isAllowed = function (roles) {
|
|
50
|
+
return this.remultFactory().isAllowed(roles);
|
|
51
|
+
};
|
|
52
|
+
RemultProxy.prototype.isAllowedForInstance = function (instance, allowed) {
|
|
53
|
+
return this.remultFactory().isAllowedForInstance(instance, allowed);
|
|
54
|
+
};
|
|
55
|
+
RemultProxy.prototype.clearAllCache = function () {
|
|
56
|
+
return this.remultFactory().clearAllCache();
|
|
57
|
+
};
|
|
58
|
+
Object.defineProperty(RemultProxy.prototype, "user", {
|
|
59
|
+
get: function () {
|
|
60
|
+
return this.remultFactory().user;
|
|
61
|
+
},
|
|
62
|
+
set: function (info) {
|
|
63
|
+
this.remultFactory().user = info;
|
|
64
|
+
},
|
|
65
|
+
enumerable: false,
|
|
66
|
+
configurable: true
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(RemultProxy.prototype, "apiClient", {
|
|
69
|
+
get: function () {
|
|
70
|
+
return this.remultFactory().apiClient;
|
|
71
|
+
},
|
|
72
|
+
set: function (client) {
|
|
73
|
+
this.remultFactory().apiClient = client;
|
|
74
|
+
},
|
|
75
|
+
enumerable: false,
|
|
76
|
+
configurable: true
|
|
77
|
+
});
|
|
78
|
+
return RemultProxy;
|
|
79
|
+
}());
|
|
80
|
+
exports.RemultProxy = RemultProxy;
|
|
81
|
+
exports.remult = new RemultProxy();
|
|
82
|
+
remult3_1.RepositoryImplementation.defaultRemult = exports.remult;
|