remult 0.19.0-exp.2 → 0.19.0

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.
@@ -115,7 +115,7 @@ export interface FieldMetadata<valueType = any, entityType = any> {
115
115
  * repo.fields.createDate.displayValue(task) //will display the date as defined in the `displayValue` option defined for it.
116
116
  */
117
117
  displayValue(item: Partial<OmitEB<entityType>>): string;
118
- apiUpdateAllowed(item: Partial<OmitEB<entityType>>): boolean;
118
+ apiUpdateAllowed(item?: Partial<OmitEB<entityType>>): boolean;
119
119
  readonly includedInApi: boolean;
120
120
  /** Adapts the value for usage with html input
121
121
  * @example
@@ -186,7 +186,7 @@ export declare class columnDefsImpl implements FieldMetadata {
186
186
  private entityDefs;
187
187
  private remult;
188
188
  constructor(settings: FieldOptions, entityDefs: EntityFullInfo<any>, remult: Remult);
189
- apiUpdateAllowed(item: any): boolean;
189
+ apiUpdateAllowed(item?: any): boolean;
190
190
  displayValue(item: any): string;
191
191
  get includedInApi(): boolean;
192
192
  toInput(value: any, inputType?: string): string;
@@ -1249,6 +1249,8 @@ export class columnDefsImpl {
1249
1249
  this.caption = buildCaption(settings.caption, settings.key, remult);
1250
1250
  }
1251
1251
  apiUpdateAllowed(item) {
1252
+ if (this.options.allowApiUpdate === undefined)
1253
+ return true;
1252
1254
  return this.remult.isAllowedForInstance(item, this.options.allowApiUpdate);
1253
1255
  }
1254
1256
  displayValue(item) {
@@ -1388,10 +1390,26 @@ class EntityFullInfo {
1388
1390
  this.idMetadata.field = [...this.fields][0];
1389
1391
  }
1390
1392
  }
1391
- apiUpdateAllowed(item) { return this.remult.repo(this.entityType).getEntityRef(item).apiUpdateAllowed; }
1392
- get apiReadAllowed() { return this.remult.isAllowed(this.options.allowApiRead); }
1393
- apiDeleteAllowed(item) { return this.remult.repo(this.entityType).getEntityRef(item).apiDeleteAllowed; }
1394
- apiInsertAllowed(item) { return this.remult.repo(this.entityType).getEntityRef(item).apiInsertAllowed; }
1393
+ apiUpdateAllowed(item) {
1394
+ if (this.options.allowApiUpdate === undefined)
1395
+ return false;
1396
+ return !item ? this.remult.isAllowedForInstance(undefined, this.options.allowApiUpdate) : this.remult.repo(this.entityType).getEntityRef(item).apiUpdateAllowed;
1397
+ }
1398
+ get apiReadAllowed() {
1399
+ if (this.options.allowApiUpdate === undefined)
1400
+ return true; //TODO2 - consider that this default may be confusing, since it's different from all others.
1401
+ return this.remult.isAllowed(this.options.allowApiRead);
1402
+ }
1403
+ apiDeleteAllowed(item) {
1404
+ if (this.options.allowApiDelete === undefined)
1405
+ return false;
1406
+ return !item ? this.remult.isAllowedForInstance(undefined, this.options.allowApiDelete) : this.remult.repo(this.entityType).getEntityRef(item).apiDeleteAllowed;
1407
+ }
1408
+ apiInsertAllowed(item) {
1409
+ if (this.options.allowApiUpdate === undefined)
1410
+ return false;
1411
+ return !item ? this.remult.isAllowedForInstance(undefined, this.options.allowApiInsert) : this.remult.repo(this.entityType).getEntityRef(item).apiInsertAllowed;
1412
+ }
1395
1413
  getDbName() {
1396
1414
  if (this.dbNamePromise)
1397
1415
  return this.dbNamePromise;
@@ -123,7 +123,7 @@ export interface EntityMetadata<entityType = any> {
123
123
  * // Allow user to edit the entity
124
124
  * }
125
125
  */
126
- apiUpdateAllowed(item: entityType): boolean;
126
+ apiUpdateAllowed(item?: entityType): boolean;
127
127
  /** true if the current user is allowed to read from entity
128
128
  * @example
129
129
  * const taskRepo = remult.repo(Task);
@@ -139,7 +139,7 @@ export interface EntityMetadata<entityType = any> {
139
139
  * // display delete button
140
140
  * }
141
141
  */
142
- apiDeleteAllowed(item: entityType): boolean;
142
+ apiDeleteAllowed(item?: entityType): boolean;
143
143
  /** true if the current user is allowed to create an entity instance
144
144
  * @example
145
145
  * const taskRepo = remult.repo(Task);
@@ -147,7 +147,7 @@ export interface EntityMetadata<entityType = any> {
147
147
  * // display insert button
148
148
  * }
149
149
  */
150
- apiInsertAllowed(item: entityType): boolean;
150
+ apiInsertAllowed(item?: entityType): boolean;
151
151
  /** Returns the dbName - based on it's `dbName` option and it's `sqlExpression` option */
152
152
  getDbName(): Promise<string>;
153
153
  /** Metadata for the Entity's id */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "0.19.0-exp.2",
3
+ "version": "0.19.0",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -115,7 +115,7 @@ export interface FieldMetadata<valueType = any, entityType = any> {
115
115
  * repo.fields.createDate.displayValue(task) //will display the date as defined in the `displayValue` option defined for it.
116
116
  */
117
117
  displayValue(item: Partial<OmitEB<entityType>>): string;
118
- apiUpdateAllowed(item: Partial<OmitEB<entityType>>): boolean;
118
+ apiUpdateAllowed(item?: Partial<OmitEB<entityType>>): boolean;
119
119
  readonly includedInApi: boolean;
120
120
  /** Adapts the value for usage with html input
121
121
  * @example
@@ -186,7 +186,7 @@ export declare class columnDefsImpl implements FieldMetadata {
186
186
  private entityDefs;
187
187
  private remult;
188
188
  constructor(settings: FieldOptions, entityDefs: EntityFullInfo<any>, remult: Remult);
189
- apiUpdateAllowed(item: any): boolean;
189
+ apiUpdateAllowed(item?: any): boolean;
190
190
  displayValue(item: any): string;
191
191
  get includedInApi(): boolean;
192
192
  toInput(value: any, inputType?: string): string;
@@ -2289,6 +2289,8 @@ var columnDefsImpl = /** @class */ (function () {
2289
2289
  this.caption = buildCaption(settings.caption, settings.key, remult);
2290
2290
  }
2291
2291
  columnDefsImpl.prototype.apiUpdateAllowed = function (item) {
2292
+ if (this.options.allowApiUpdate === undefined)
2293
+ return true;
2292
2294
  return this.remult.isAllowedForInstance(item, this.options.allowApiUpdate);
2293
2295
  };
2294
2296
  columnDefsImpl.prototype.displayValue = function (item) {
@@ -2470,14 +2472,30 @@ var EntityFullInfo = /** @class */ (function () {
2470
2472
  this.idMetadata.field = tslib_1.__spread(this.fields)[0];
2471
2473
  }
2472
2474
  }
2473
- EntityFullInfo.prototype.apiUpdateAllowed = function (item) { return this.remult.repo(this.entityType).getEntityRef(item).apiUpdateAllowed; };
2475
+ EntityFullInfo.prototype.apiUpdateAllowed = function (item) {
2476
+ if (this.options.allowApiUpdate === undefined)
2477
+ return false;
2478
+ return !item ? this.remult.isAllowedForInstance(undefined, this.options.allowApiUpdate) : this.remult.repo(this.entityType).getEntityRef(item).apiUpdateAllowed;
2479
+ };
2474
2480
  Object.defineProperty(EntityFullInfo.prototype, "apiReadAllowed", {
2475
- get: function () { return this.remult.isAllowed(this.options.allowApiRead); },
2481
+ get: function () {
2482
+ if (this.options.allowApiUpdate === undefined)
2483
+ return true; //TODO2 - consider that this default may be confusing, since it's different from all others.
2484
+ return this.remult.isAllowed(this.options.allowApiRead);
2485
+ },
2476
2486
  enumerable: false,
2477
2487
  configurable: true
2478
2488
  });
2479
- EntityFullInfo.prototype.apiDeleteAllowed = function (item) { return this.remult.repo(this.entityType).getEntityRef(item).apiDeleteAllowed; };
2480
- EntityFullInfo.prototype.apiInsertAllowed = function (item) { return this.remult.repo(this.entityType).getEntityRef(item).apiInsertAllowed; };
2489
+ EntityFullInfo.prototype.apiDeleteAllowed = function (item) {
2490
+ if (this.options.allowApiDelete === undefined)
2491
+ return false;
2492
+ return !item ? this.remult.isAllowedForInstance(undefined, this.options.allowApiDelete) : this.remult.repo(this.entityType).getEntityRef(item).apiDeleteAllowed;
2493
+ };
2494
+ EntityFullInfo.prototype.apiInsertAllowed = function (item) {
2495
+ if (this.options.allowApiUpdate === undefined)
2496
+ return false;
2497
+ return !item ? this.remult.isAllowedForInstance(undefined, this.options.allowApiInsert) : this.remult.repo(this.entityType).getEntityRef(item).apiInsertAllowed;
2498
+ };
2481
2499
  EntityFullInfo.prototype.getDbName = function () {
2482
2500
  var _this = this;
2483
2501
  if (this.dbNamePromise)
@@ -123,7 +123,7 @@ export interface EntityMetadata<entityType = any> {
123
123
  * // Allow user to edit the entity
124
124
  * }
125
125
  */
126
- apiUpdateAllowed(item: entityType): boolean;
126
+ apiUpdateAllowed(item?: entityType): boolean;
127
127
  /** true if the current user is allowed to read from entity
128
128
  * @example
129
129
  * const taskRepo = remult.repo(Task);
@@ -139,7 +139,7 @@ export interface EntityMetadata<entityType = any> {
139
139
  * // display delete button
140
140
  * }
141
141
  */
142
- apiDeleteAllowed(item: entityType): boolean;
142
+ apiDeleteAllowed(item?: entityType): boolean;
143
143
  /** true if the current user is allowed to create an entity instance
144
144
  * @example
145
145
  * const taskRepo = remult.repo(Task);
@@ -147,7 +147,7 @@ export interface EntityMetadata<entityType = any> {
147
147
  * // display insert button
148
148
  * }
149
149
  */
150
- apiInsertAllowed(item: entityType): boolean;
150
+ apiInsertAllowed(item?: entityType): boolean;
151
151
  /** Returns the dbName - based on it's `dbName` option and it's `sqlExpression` option */
152
152
  getDbName(): Promise<string>;
153
153
  /** Metadata for the Entity's id */