remult 0.13.25 → 0.13.28
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/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -33,13 +33,15 @@
|
|
|
33
33
|
|
|
34
34
|
#### Remult :heart: Code Sharing
|
|
35
35
|
|
|
36
|
-
With model types shared between frontend and backend code, Remult can **enforce data validation and constraints, defined once, both in the front-end and
|
|
36
|
+
With model types shared between frontend and backend code, Remult can **enforce data validation and constraints, defined once, both in the front-end and within back-end API routes**.
|
|
37
37
|
|
|
38
38
|
## Getting started
|
|
39
39
|
The best way to learn Remult is by following a tutorial of a simple Todo web app with a Node.js Express backend.
|
|
40
40
|
|
|
41
41
|
* [Tutorial with React](https://remult.dev/tutorials/react/)
|
|
42
42
|
* [Tutorial with Angular](https://remult.dev/tutorials/angular/)
|
|
43
|
+
* [Tutorial with Vue](https://remult.dev/tutorials/vue/)
|
|
44
|
+
* [Tutorial with Next.js](https://remult.dev/tutorials/react-next/)
|
|
43
45
|
|
|
44
46
|
## Installation
|
|
45
47
|
```sh
|
|
@@ -21,6 +21,7 @@ export declare function remultExpress(options?: {
|
|
|
21
21
|
entities?: ClassType<any>[];
|
|
22
22
|
controllers?: ClassType<any>[];
|
|
23
23
|
bodyParser?: boolean;
|
|
24
|
+
rootPath?: string;
|
|
24
25
|
}): RemultExpressBridge;
|
|
25
26
|
export interface RemultExpressBridge extends express.RequestHandler {
|
|
26
27
|
getRemult(req: express.Request): Promise<Remult>;
|
package/server/expressBridge.js
CHANGED
|
@@ -61,7 +61,9 @@ function remultExpress(options) {
|
|
|
61
61
|
var bridge = new ExpressBridge(app, new inProcessQueueHandler(options.queueStorage), options.initRequest, dataProvider);
|
|
62
62
|
if (options.logApiEndPoints !== undefined)
|
|
63
63
|
bridge.logApiEndPoints = options.logApiEndPoints;
|
|
64
|
-
|
|
64
|
+
if (options.rootPath === undefined)
|
|
65
|
+
options.rootPath = __1.Remult.apiBaseUrl;
|
|
66
|
+
var apiArea = bridge.addArea(options.rootPath);
|
|
65
67
|
if (!options.disableAutoApi) {
|
|
66
68
|
var actions = [];
|
|
67
69
|
if (options.entities)
|
package/src/context.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export declare class Remult {
|
|
|
44
44
|
sub?: string;
|
|
45
45
|
name?: string;
|
|
46
46
|
permissions?: string[];
|
|
47
|
+
username?: string;
|
|
47
48
|
}): Promise<void>;
|
|
48
49
|
private _user;
|
|
49
50
|
private _userChangeEvent;
|
|
@@ -55,12 +56,12 @@ export declare class Remult {
|
|
|
55
56
|
* @see
|
|
56
57
|
* [Allowed](https://remult.dev/docs/allowed.html)
|
|
57
58
|
*/
|
|
58
|
-
isAllowed(roles
|
|
59
|
+
isAllowed(roles?: Allowed): boolean;
|
|
59
60
|
/** checks if the user matches the allowedForInstance callback
|
|
60
61
|
* @see
|
|
61
62
|
* [Allowed](https://remult.dev/docs/allowed.html)
|
|
62
63
|
*/
|
|
63
|
-
isAllowedForInstance(instance: any,
|
|
64
|
+
isAllowedForInstance(instance: any, allowed?: AllowedForInstance<any>): boolean;
|
|
64
65
|
/** returns a dispatcher object that fires once a user has changed*/
|
|
65
66
|
get userChange(): EventDispatcher;
|
|
66
67
|
private repCache;
|
package/src/context.js
CHANGED
|
@@ -214,6 +214,8 @@ var Remult = /** @class */ (function () {
|
|
|
214
214
|
if (!this._user.roles && auth.permissions) {
|
|
215
215
|
this._user.roles = auth.permissions;
|
|
216
216
|
}
|
|
217
|
+
if (!this._user.name)
|
|
218
|
+
this._user.name = auth.username;
|
|
217
219
|
}
|
|
218
220
|
if (this._user && !this._user.roles)
|
|
219
221
|
this._user.roles = [];
|
|
@@ -271,13 +273,13 @@ var Remult = /** @class */ (function () {
|
|
|
271
273
|
* @see
|
|
272
274
|
* [Allowed](https://remult.dev/docs/allowed.html)
|
|
273
275
|
*/
|
|
274
|
-
Remult.prototype.isAllowedForInstance = function (instance,
|
|
276
|
+
Remult.prototype.isAllowedForInstance = function (instance, allowed) {
|
|
275
277
|
var e_2, _a;
|
|
276
|
-
if (Array.isArray(
|
|
278
|
+
if (Array.isArray(allowed)) {
|
|
277
279
|
{
|
|
278
280
|
try {
|
|
279
|
-
for (var
|
|
280
|
-
var item =
|
|
281
|
+
for (var allowed_1 = tslib_1.__values(allowed), allowed_1_1 = allowed_1.next(); !allowed_1_1.done; allowed_1_1 = allowed_1.next()) {
|
|
282
|
+
var item = allowed_1_1.value;
|
|
281
283
|
if (this.isAllowedForInstance(instance, item))
|
|
282
284
|
return true;
|
|
283
285
|
}
|
|
@@ -285,17 +287,17 @@ var Remult = /** @class */ (function () {
|
|
|
285
287
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
286
288
|
finally {
|
|
287
289
|
try {
|
|
288
|
-
if (
|
|
290
|
+
if (allowed_1_1 && !allowed_1_1.done && (_a = allowed_1.return)) _a.call(allowed_1);
|
|
289
291
|
}
|
|
290
292
|
finally { if (e_2) throw e_2.error; }
|
|
291
293
|
}
|
|
292
294
|
}
|
|
293
295
|
}
|
|
294
|
-
else if (typeof (
|
|
295
|
-
return
|
|
296
|
+
else if (typeof (allowed) === "function") {
|
|
297
|
+
return allowed(this, instance);
|
|
296
298
|
}
|
|
297
299
|
else
|
|
298
|
-
return this.isAllowed(
|
|
300
|
+
return this.isAllowed(allowed);
|
|
299
301
|
};
|
|
300
302
|
Object.defineProperty(Remult.prototype, "userChange", {
|
|
301
303
|
/** returns a dispatcher object that fires once a user has changed*/
|
|
@@ -309,6 +309,7 @@ export declare class EntityBase {
|
|
|
309
309
|
export declare class ControllerBase {
|
|
310
310
|
protected remult: Remult;
|
|
311
311
|
constructor(remult: Remult);
|
|
312
|
+
assign(values: Partial<Omit<this, keyof EntityBase>>): this;
|
|
312
313
|
get $(): FieldsRef<this>;
|
|
313
314
|
get _(): ControllerRef<this>;
|
|
314
315
|
}
|
|
@@ -2729,6 +2729,10 @@ var ControllerBase = /** @class */ (function () {
|
|
|
2729
2729
|
function ControllerBase(remult) {
|
|
2730
2730
|
this.remult = remult;
|
|
2731
2731
|
}
|
|
2732
|
+
ControllerBase.prototype.assign = function (values) {
|
|
2733
|
+
assign_1.assign(this, values);
|
|
2734
|
+
return this;
|
|
2735
|
+
};
|
|
2732
2736
|
Object.defineProperty(ControllerBase.prototype, "$", {
|
|
2733
2737
|
get: function () { return getFields(this); },
|
|
2734
2738
|
enumerable: false,
|