remult 0.13.26 → 0.13.27

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "0.13.26",
3
+ "version": "0.13.27",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "homepage": "https://remult.dev/",
6
6
  "repository": {
@@ -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>;
@@ -61,7 +61,7 @@ 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
- var apiArea = bridge.addArea(__1.Remult.apiBaseUrl);
64
+ var apiArea = bridge.addArea((options === null || options === void 0 ? void 0 : options.rootPath) || __1.Remult.apiBaseUrl);
65
65
  if (!options.disableAutoApi) {
66
66
  var actions = [];
67
67
  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: Allowed): boolean;
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, x: AllowedForInstance<any>): boolean;
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, x) {
276
+ Remult.prototype.isAllowedForInstance = function (instance, allowed) {
275
277
  var e_2, _a;
276
- if (Array.isArray(x)) {
278
+ if (Array.isArray(allowed)) {
277
279
  {
278
280
  try {
279
- for (var x_1 = tslib_1.__values(x), x_1_1 = x_1.next(); !x_1_1.done; x_1_1 = x_1.next()) {
280
- var item = x_1_1.value;
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 (x_1_1 && !x_1_1.done && (_a = x_1.return)) _a.call(x_1);
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 (x) === "function") {
295
- return x(this, instance);
296
+ else if (typeof (allowed) === "function") {
297
+ return allowed(this, instance);
296
298
  }
297
299
  else
298
- return this.isAllowed(x);
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*/