remult 0.14.4 → 0.14.5
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/assign.js +1 -5
- package/classType.js +1 -2
- package/graphql.js +84 -146
- package/index.js +25 -73
- package/inputTypes.js +9 -16
- package/package.json +2 -1
- package/postgres/index.js +1 -4
- package/postgres/postgres-data-provider.js +165 -364
- package/postgres/postgresColumnSyntax.js +4 -8
- package/remult-express.js +6 -10
- package/remult-knex/index.js +300 -720
- package/remult-middleware.js +24 -30
- package/remult-mongo.js +172 -406
- package/server/JsonEntityFileStorage.js +10 -15
- package/server/expressBridge.js +383 -569
- package/server/index.js +4 -11
- package/server/register-actions-on-server.js +12 -38
- package/server/register-entities-on-server.js +9 -13
- package/src/__EntityValueProvider.js +1 -2
- package/src/__RowsOfDataForTesting.js +1 -2
- package/src/backend-tests/backend-database-test-setup.backend-spec.js +72 -190
- package/src/backend-tests/my-test.backend-spec.js +45 -114
- package/src/column-interfaces.js +2 -6
- package/src/column.js +71 -113
- package/src/context.js +174 -330
- package/src/data-api.js +162 -326
- package/src/data-interfaces.js +7 -11
- package/src/data-providers/array-entity-data-provider.js +171 -286
- package/src/data-providers/in-memory-database.js +12 -27
- package/src/data-providers/json-data-provider.js +41 -77
- package/src/data-providers/rest-data-provider.js +102 -189
- package/src/data-providers/sql-database.js +223 -403
- package/src/data-providers/web-sql-data-provider.js +78 -139
- package/src/entity.js +1 -2
- package/src/filter/filter-consumer-bridge-to-sql-request.js +106 -248
- package/src/filter/filter-consumer-bridge-to-url-builder.js +1 -2
- package/src/filter/filter-interfaces.js +277 -440
- package/src/id-entity.js +8 -17
- package/src/remult3/RepositoryImplementation.js +1191 -2367
- package/src/remult3/index.js +2 -5
- package/src/remult3/remult3.js +1 -2
- package/src/server-action.js +294 -528
- package/src/shared-tests/db-tests-setup.js +49 -153
- package/src/shared-tests/db-tests.db-tests.js +660 -1566
- package/src/shared-tests/deleteAll.js +3 -20
- package/src/shared-tests/entityWithValidations.js +52 -79
- package/src/shared-tests/index.js +4 -6
- package/src/shared-tests/test-custom-id-column.spec.js +37 -85
- package/src/shared-tests/test-special-value.spec.js +64 -104
- package/src/shared-tests/test-update-with-null.spec.js +28 -49
- package/src/sort.js +38 -95
- package/src/sql-command.js +1 -2
- package/src/tests/Done.js +7 -13
- package/src/tests/TestDataApiResponse.js +15 -22
- package/src/tests/c.js +21 -27
- package/src/tests/createData.js +20 -48
- package/src/tests/d.js +19 -27
- package/src/tests/dWithPrefilter.js +31 -44
- package/src/tests/entityForCustomFilter.js +42 -66
- package/src/tests/entityWithValidationsOnColumn.js +21 -29
- package/src/tests/frontend-database-tests-setup.spec.js +35 -98
- package/src/tests/h.js +35 -44
- package/src/tests/remult-3-entities.js +71 -80
- package/src/tests/tasks.js +23 -29
- package/src/tests/testHelper.spec.js +170 -322
- package/src/tests/testModel/models.js +25 -33
- package/src/validators.js +32 -59
- package/urlBuilder.js +8 -14
- package/valueConverters.js +161 -160
package/src/context.js
CHANGED
|
@@ -1,170 +1,119 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var rest_data_provider_1 = require("./data-providers/rest-data-provider");
|
|
7
|
-
var RepositoryImplementation_1 = require("./remult3/RepositoryImplementation");
|
|
8
|
-
var HttpProviderBridgeToRestDataProviderHttpProvider = /** @class */ (function () {
|
|
9
|
-
function HttpProviderBridgeToRestDataProviderHttpProvider(http) {
|
|
1
|
+
import { Action, actionInfo } from './server-action';
|
|
2
|
+
import { RestDataProvider, RestDataProviderHttpProviderUsingFetch } from './data-providers/rest-data-provider';
|
|
3
|
+
import { RepositoryImplementation } from "./remult3/RepositoryImplementation";
|
|
4
|
+
export class HttpProviderBridgeToRestDataProviderHttpProvider {
|
|
5
|
+
constructor(http) {
|
|
10
6
|
this.http = http;
|
|
11
7
|
}
|
|
12
|
-
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
switch (_a.label) {
|
|
17
|
-
case 0: return [4 /*yield*/, retry(function () { return toPromise(_this.http.post(url, data)); })];
|
|
18
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
HttpProviderBridgeToRestDataProviderHttpProvider.prototype.delete = function (url) {
|
|
8
|
+
async post(url, data) {
|
|
9
|
+
return await retry(() => toPromise(this.http.post(url, data)));
|
|
10
|
+
}
|
|
11
|
+
delete(url) {
|
|
24
12
|
return toPromise(this.http.delete(url));
|
|
25
|
-
}
|
|
26
|
-
|
|
13
|
+
}
|
|
14
|
+
put(url, data) {
|
|
27
15
|
return toPromise(this.http.put(url, data));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
case 0:
|
|
50
|
-
if (!true) return [3 /*break*/, 7];
|
|
51
|
-
_e.label = 1;
|
|
52
|
-
case 1:
|
|
53
|
-
_e.trys.push([1, 3, , 6]);
|
|
54
|
-
return [4 /*yield*/, what()];
|
|
55
|
-
case 2: return [2 /*return*/, _e.sent()];
|
|
56
|
-
case 3:
|
|
57
|
-
err_1 = _e.sent();
|
|
58
|
-
if (!(((_a = err_1.message) === null || _a === void 0 ? void 0 : _a.startsWith("Error occurred while trying to proxy")) || ((_b = err_1.message) === null || _b === void 0 ? void 0 : _b.startsWith("Error occured while trying to proxy")) || ((_c = err_1.message) === null || _c === void 0 ? void 0 : _c.includes("http proxy error")) || ((_d = err_1.message) === null || _d === void 0 ? void 0 : _d.startsWith("Gateway Timeout")))) return [3 /*break*/, 5];
|
|
59
|
-
return [4 /*yield*/, new Promise(function (res, req) {
|
|
60
|
-
setTimeout(function () {
|
|
61
|
-
res({});
|
|
62
|
-
}, 250);
|
|
63
|
-
})];
|
|
64
|
-
case 4:
|
|
65
|
-
_e.sent();
|
|
66
|
-
return [3 /*break*/, 0];
|
|
67
|
-
case 5: throw err_1;
|
|
68
|
-
case 6: return [3 /*break*/, 0];
|
|
69
|
-
case 7: return [2 /*return*/];
|
|
16
|
+
}
|
|
17
|
+
async get(url) {
|
|
18
|
+
return await retry(() => toPromise(this.http.get(url)));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export async function retry(what) {
|
|
22
|
+
while (true) {
|
|
23
|
+
try {
|
|
24
|
+
return await what();
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
if (err.message?.startsWith("Error occurred while trying to proxy") ||
|
|
28
|
+
err.message?.startsWith("Error occured while trying to proxy") ||
|
|
29
|
+
err.message?.includes("http proxy error") ||
|
|
30
|
+
err.message?.startsWith("Gateway Timeout")) {
|
|
31
|
+
await new Promise((res, req) => {
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
res({});
|
|
34
|
+
}, 250);
|
|
35
|
+
});
|
|
36
|
+
continue;
|
|
70
37
|
}
|
|
71
|
-
|
|
72
|
-
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
73
41
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
var _this = this;
|
|
77
|
-
var r;
|
|
42
|
+
export function toPromise(p) {
|
|
43
|
+
let r;
|
|
78
44
|
if (p["toPromise"] !== undefined) {
|
|
79
45
|
r = p["toPromise"]();
|
|
80
46
|
}
|
|
81
47
|
//@ts-ignore
|
|
82
48
|
else
|
|
83
49
|
r = p;
|
|
84
|
-
return r.then(
|
|
50
|
+
return r.then((x) => {
|
|
85
51
|
if (x && (x.status == 200 || x.status == 201) && x.headers && x.request && x.data) //for axios
|
|
86
52
|
return x.data;
|
|
87
53
|
return x;
|
|
88
|
-
}).catch(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
case 0: return [4 /*yield*/, processHttpException(ex)];
|
|
92
|
-
case 1: throw _a.sent();
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}); });
|
|
54
|
+
}).catch(async (ex) => {
|
|
55
|
+
throw await processHttpException(ex);
|
|
56
|
+
});
|
|
96
57
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (httpStatusCode === undefined)
|
|
126
|
-
httpStatusCode = (_c = z.response) === null || _c === void 0 ? void 0 : _c.status;
|
|
127
|
-
if (httpStatusCode !== undefined && httpStatusCode !== null) {
|
|
128
|
-
error.httpStatusCode = httpStatusCode;
|
|
129
|
-
}
|
|
130
|
-
result = Object.assign(error, {
|
|
131
|
-
// exception: ex disabled for now because JSON.stringify crashed with this
|
|
132
|
-
});
|
|
133
|
-
return [2 /*return*/, result];
|
|
134
|
-
}
|
|
135
|
-
});
|
|
58
|
+
export async function processHttpException(ex) {
|
|
59
|
+
let z = await ex;
|
|
60
|
+
var error;
|
|
61
|
+
if (z.error)
|
|
62
|
+
error = z.error;
|
|
63
|
+
else if (z.isAxiosError) {
|
|
64
|
+
if (typeof z.response?.data === "string")
|
|
65
|
+
error = z.response.data;
|
|
66
|
+
else
|
|
67
|
+
error = z?.response?.data;
|
|
68
|
+
}
|
|
69
|
+
if (!error)
|
|
70
|
+
error = z.message;
|
|
71
|
+
if (z.status == 0 && z.error.isTrusted)
|
|
72
|
+
error = "Network Error";
|
|
73
|
+
if (typeof error === 'string') {
|
|
74
|
+
error = {
|
|
75
|
+
message: error,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
let httpStatusCode = z.status;
|
|
79
|
+
if (httpStatusCode === undefined)
|
|
80
|
+
httpStatusCode = z.response?.status;
|
|
81
|
+
if (httpStatusCode !== undefined && httpStatusCode !== null) {
|
|
82
|
+
error.httpStatusCode = httpStatusCode;
|
|
83
|
+
}
|
|
84
|
+
var result = Object.assign(error, {
|
|
85
|
+
// exception: ex disabled for now because JSON.stringify crashed with this
|
|
136
86
|
});
|
|
87
|
+
return result;
|
|
137
88
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return server_action_1.actionInfo.runningOnServer;
|
|
89
|
+
export function isBackend() {
|
|
90
|
+
return actionInfo.runningOnServer;
|
|
141
91
|
}
|
|
142
|
-
|
|
143
|
-
var Remult = /** @class */ (function () {
|
|
92
|
+
export class Remult {
|
|
144
93
|
/** Creates a new instance of the `remult` object.
|
|
145
94
|
*
|
|
146
95
|
* Can receive either an HttpProvider or a DataProvider as a parameter - which will be used to fetch data from.
|
|
147
96
|
*
|
|
148
97
|
* If no provider is specified, `fetch` will be used as an http provider
|
|
149
98
|
*/
|
|
150
|
-
|
|
99
|
+
constructor(provider) {
|
|
151
100
|
this._userChangeEvent = new EventSource();
|
|
152
101
|
this.repCache = new Map();
|
|
153
102
|
if (provider && provider.getEntityDataProvider) {
|
|
154
103
|
this._dataSource = provider;
|
|
155
104
|
return;
|
|
156
105
|
}
|
|
157
|
-
|
|
158
|
-
|
|
106
|
+
let http = provider;
|
|
107
|
+
let dataProvider;
|
|
159
108
|
if (http) {
|
|
160
109
|
dataProvider = new HttpProviderBridgeToRestDataProviderHttpProvider(http);
|
|
161
110
|
}
|
|
162
111
|
if (!dataProvider) {
|
|
163
|
-
dataProvider = new
|
|
112
|
+
dataProvider = new RestDataProviderHttpProviderUsingFetch();
|
|
164
113
|
}
|
|
165
|
-
this._dataSource = new
|
|
166
|
-
if (!
|
|
167
|
-
|
|
114
|
+
this._dataSource = new RestDataProvider(Remult.apiBaseUrl, dataProvider);
|
|
115
|
+
if (!Action.provider)
|
|
116
|
+
Action.provider = dataProvider;
|
|
168
117
|
}
|
|
169
118
|
/**Return's a `Repository` of the specific entity type
|
|
170
119
|
* @example
|
|
@@ -172,90 +121,64 @@ var Remult = /** @class */ (function () {
|
|
|
172
121
|
* @see [Repository](https://remult.dev/docs/ref_repository.html)
|
|
173
122
|
*
|
|
174
123
|
*/
|
|
175
|
-
|
|
124
|
+
repo(entity, dataProvider) {
|
|
176
125
|
if (dataProvider === undefined)
|
|
177
126
|
dataProvider = this._dataSource;
|
|
178
|
-
|
|
127
|
+
let dpCache = this.repCache.get(dataProvider);
|
|
179
128
|
if (!dpCache)
|
|
180
129
|
this.repCache.set(dataProvider, dpCache = new Map());
|
|
181
|
-
|
|
130
|
+
let r = dpCache.get(entity);
|
|
182
131
|
if (!r) {
|
|
183
|
-
dpCache.set(entity, r = new
|
|
132
|
+
dpCache.set(entity, r = new RepositoryImplementation(entity, this, dataProvider));
|
|
184
133
|
}
|
|
185
134
|
return r;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
},
|
|
199
|
-
enumerable: false,
|
|
200
|
-
configurable: true
|
|
201
|
-
});
|
|
135
|
+
}
|
|
136
|
+
/** Returns the current user's info */
|
|
137
|
+
get user() {
|
|
138
|
+
if (this._user === undefined) {
|
|
139
|
+
return {
|
|
140
|
+
id: undefined,
|
|
141
|
+
name: '',
|
|
142
|
+
roles: []
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
return this._user;
|
|
146
|
+
}
|
|
202
147
|
/** Set's the current user info */
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
if (this._user && !this._user.roles)
|
|
221
|
-
this._user.roles = [];
|
|
222
|
-
return [4 /*yield*/, this._userChangeEvent.fire()];
|
|
223
|
-
case 1:
|
|
224
|
-
_a.sent();
|
|
225
|
-
return [2 /*return*/];
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
};
|
|
148
|
+
async setUser(info) {
|
|
149
|
+
this._user = info;
|
|
150
|
+
let auth = info;
|
|
151
|
+
if (auth) {
|
|
152
|
+
if (!this._user.id && auth.sub)
|
|
153
|
+
this._user.id = auth.sub;
|
|
154
|
+
if (!this._user.roles && auth.permissions) {
|
|
155
|
+
this._user.roles = auth.permissions;
|
|
156
|
+
}
|
|
157
|
+
if (!this._user.name)
|
|
158
|
+
this._user.name = auth.username;
|
|
159
|
+
}
|
|
160
|
+
if (this._user && !this._user.roles)
|
|
161
|
+
this._user.roles = [];
|
|
162
|
+
await this._userChangeEvent.fire();
|
|
163
|
+
}
|
|
230
164
|
/** Checks if a user was authenticated */
|
|
231
|
-
|
|
165
|
+
authenticated() {
|
|
232
166
|
return this.user.id !== undefined;
|
|
233
|
-
}
|
|
167
|
+
}
|
|
234
168
|
/** checks if the user has any of the roles specified in the parameters
|
|
235
169
|
* @example
|
|
236
170
|
* remult.isAllowed("admin")
|
|
237
171
|
* @see
|
|
238
172
|
* [Allowed](https://remult.dev/docs/allowed.html)
|
|
239
173
|
*/
|
|
240
|
-
|
|
241
|
-
var e_1, _a;
|
|
174
|
+
isAllowed(roles) {
|
|
242
175
|
if (roles == undefined)
|
|
243
176
|
return undefined;
|
|
244
177
|
if (roles instanceof Array) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (this.isAllowed(role) === true) {
|
|
249
|
-
return true;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
254
|
-
finally {
|
|
255
|
-
try {
|
|
256
|
-
if (roles_1_1 && !roles_1_1.done && (_a = roles_1.return)) _a.call(roles_1);
|
|
178
|
+
for (const role of roles) {
|
|
179
|
+
if (this.isAllowed(role) === true) {
|
|
180
|
+
return true;
|
|
257
181
|
}
|
|
258
|
-
finally { if (e_1) throw e_1.error; }
|
|
259
182
|
}
|
|
260
183
|
return false;
|
|
261
184
|
}
|
|
@@ -268,28 +191,17 @@ var Remult = /** @class */ (function () {
|
|
|
268
191
|
if (this.user.roles.indexOf(roles.toString()) >= 0)
|
|
269
192
|
return true;
|
|
270
193
|
return false;
|
|
271
|
-
}
|
|
194
|
+
}
|
|
272
195
|
/** checks if the user matches the allowedForInstance callback
|
|
273
196
|
* @see
|
|
274
197
|
* [Allowed](https://remult.dev/docs/allowed.html)
|
|
275
198
|
*/
|
|
276
|
-
|
|
277
|
-
var e_2, _a;
|
|
199
|
+
isAllowedForInstance(instance, allowed) {
|
|
278
200
|
if (Array.isArray(allowed)) {
|
|
279
201
|
{
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
if (this.isAllowedForInstance(instance, item))
|
|
284
|
-
return true;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
288
|
-
finally {
|
|
289
|
-
try {
|
|
290
|
-
if (allowed_1_1 && !allowed_1_1.done && (_a = allowed_1.return)) _a.call(allowed_1);
|
|
291
|
-
}
|
|
292
|
-
finally { if (e_2) throw e_2.error; }
|
|
202
|
+
for (const item of allowed) {
|
|
203
|
+
if (this.isAllowedForInstance(instance, item))
|
|
204
|
+
return true;
|
|
293
205
|
}
|
|
294
206
|
}
|
|
295
207
|
}
|
|
@@ -298,144 +210,76 @@ var Remult = /** @class */ (function () {
|
|
|
298
210
|
}
|
|
299
211
|
else
|
|
300
212
|
return this.isAllowed(allowed);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
},
|
|
307
|
-
enumerable: false,
|
|
308
|
-
configurable: true
|
|
309
|
-
});
|
|
213
|
+
}
|
|
214
|
+
/** returns a dispatcher object that fires once a user has changed*/
|
|
215
|
+
get userChange() {
|
|
216
|
+
return this._userChangeEvent.dispatcher;
|
|
217
|
+
}
|
|
310
218
|
/** sets the current data provider */
|
|
311
|
-
|
|
219
|
+
setDataProvider(dataProvider) {
|
|
312
220
|
this._dataSource = dataProvider;
|
|
313
|
-
}
|
|
314
|
-
|
|
221
|
+
}
|
|
222
|
+
clearAllCache() {
|
|
315
223
|
this.repCache.clear();
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
var ClassHelper = /** @class */ (function () {
|
|
330
|
-
function ClassHelper() {
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/** The api Base Url to be used in all remult calls. by default it's set to `/api`.
|
|
227
|
+
*
|
|
228
|
+
* Set this property in case you want to determine a non relative api url
|
|
229
|
+
*/
|
|
230
|
+
Remult.apiBaseUrl = '/api';
|
|
231
|
+
/** A helper callback that can be used to debug and trace all find operations. Useful in debugging scenarios */
|
|
232
|
+
Remult.onFind = (metadata, options) => { };
|
|
233
|
+
export const allEntities = [];
|
|
234
|
+
export const classHelpers = new Map();
|
|
235
|
+
export class ClassHelper {
|
|
236
|
+
constructor() {
|
|
331
237
|
this.methods = [];
|
|
332
238
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
var MethodHelper = /** @class */ (function () {
|
|
337
|
-
function MethodHelper() {
|
|
239
|
+
}
|
|
240
|
+
export class MethodHelper {
|
|
241
|
+
constructor() {
|
|
338
242
|
this.classes = new Map();
|
|
339
243
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
function setControllerSettings(target, options) {
|
|
344
|
-
var e_3, _a;
|
|
345
|
-
var r = target;
|
|
244
|
+
}
|
|
245
|
+
export function setControllerSettings(target, options) {
|
|
246
|
+
let r = target;
|
|
346
247
|
while (true) {
|
|
347
|
-
|
|
248
|
+
let helper = classHelpers.get(r);
|
|
348
249
|
if (helper) {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
var m = _c.value;
|
|
352
|
-
m.classes.set(target, options);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
356
|
-
finally {
|
|
357
|
-
try {
|
|
358
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
359
|
-
}
|
|
360
|
-
finally { if (e_3) throw e_3.error; }
|
|
250
|
+
for (const m of helper.methods) {
|
|
251
|
+
m.classes.set(target, options);
|
|
361
252
|
}
|
|
362
253
|
}
|
|
363
|
-
|
|
254
|
+
let p = Object.getPrototypeOf(r.prototype);
|
|
364
255
|
if (p == null)
|
|
365
256
|
break;
|
|
366
257
|
r = p.constructor;
|
|
367
258
|
}
|
|
368
259
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
Allow.authenticated = function (remult) { return remult.authenticated(); };
|
|
375
|
-
return Allow;
|
|
376
|
-
}());
|
|
377
|
-
exports.Allow = Allow;
|
|
378
|
-
exports.queryConfig = {
|
|
260
|
+
export class Allow {
|
|
261
|
+
}
|
|
262
|
+
Allow.everyone = () => true;
|
|
263
|
+
Allow.authenticated = (remult) => remult.authenticated();
|
|
264
|
+
export const queryConfig = {
|
|
379
265
|
defaultPageSize: 200
|
|
380
266
|
};
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
var _this = this;
|
|
267
|
+
export class EventSource {
|
|
268
|
+
constructor() {
|
|
384
269
|
this.listeners = [];
|
|
385
270
|
this.dispatcher = {
|
|
386
|
-
observe:
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
case 1:
|
|
394
|
-
_a.sent();
|
|
395
|
-
return [2 /*return*/, function () {
|
|
396
|
-
_this.listeners = _this.listeners.filter(function (x) { return x != what; });
|
|
397
|
-
}];
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
}); }
|
|
271
|
+
observe: async (what) => {
|
|
272
|
+
this.listeners.push(what);
|
|
273
|
+
await what();
|
|
274
|
+
return () => {
|
|
275
|
+
this.listeners = this.listeners.filter(x => x != what);
|
|
276
|
+
};
|
|
277
|
+
}
|
|
401
278
|
};
|
|
402
279
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
case 0:
|
|
410
|
-
_d.trys.push([0, 5, 6, 7]);
|
|
411
|
-
_a = tslib_1.__values(this.listeners), _b = _a.next();
|
|
412
|
-
_d.label = 1;
|
|
413
|
-
case 1:
|
|
414
|
-
if (!!_b.done) return [3 /*break*/, 4];
|
|
415
|
-
l = _b.value;
|
|
416
|
-
return [4 /*yield*/, l()];
|
|
417
|
-
case 2:
|
|
418
|
-
_d.sent();
|
|
419
|
-
_d.label = 3;
|
|
420
|
-
case 3:
|
|
421
|
-
_b = _a.next();
|
|
422
|
-
return [3 /*break*/, 1];
|
|
423
|
-
case 4: return [3 /*break*/, 7];
|
|
424
|
-
case 5:
|
|
425
|
-
e_4_1 = _d.sent();
|
|
426
|
-
e_4 = { error: e_4_1 };
|
|
427
|
-
return [3 /*break*/, 7];
|
|
428
|
-
case 6:
|
|
429
|
-
try {
|
|
430
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
431
|
-
}
|
|
432
|
-
finally { if (e_4) throw e_4.error; }
|
|
433
|
-
return [7 /*endfinally*/];
|
|
434
|
-
case 7: return [2 /*return*/];
|
|
435
|
-
}
|
|
436
|
-
});
|
|
437
|
-
});
|
|
438
|
-
};
|
|
439
|
-
return EventSource;
|
|
440
|
-
}());
|
|
441
|
-
exports.EventSource = EventSource;
|
|
280
|
+
async fire() {
|
|
281
|
+
for (const l of this.listeners) {
|
|
282
|
+
await l();
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|