@modular-rest/server 1.13.1 → 1.13.3

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/README.md CHANGED
@@ -58,7 +58,7 @@ createRest({
58
58
  - Event system
59
59
  - Extensible architecture
60
60
 
61
- ## TypeScript Support
61
+ ## TypeScript Support
62
62
 
63
63
  This package includes full TypeScript type definitions for all API components. The entire codebase is written in TypeScript, providing:
64
64
 
@@ -178,11 +178,11 @@ function _getPermissionList(db, collection, operationType) {
178
178
  function checkAccess(db, collection, operationType, queryOrDoc, user) {
179
179
  const permissionList = _getPermissionList(db, collection, operationType);
180
180
  return permissionList.some(permission => {
181
- if (permission.type === 'god_access')
181
+ if (permission.accessType === 'god_access')
182
182
  return true;
183
- if (permission.type === 'anonymous_access' && user.type === 'anonymous')
183
+ if (permission.accessType === 'anonymous_access' && user.type === 'anonymous')
184
184
  return true;
185
- if (permission.type === 'user_access' && user.type === 'user')
185
+ if (permission.accessType === 'user_access' && user.type === 'user')
186
186
  return true;
187
187
  return false;
188
188
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modular-rest/server",
3
- "version": "1.13.1",
3
+ "version": "1.13.3",
4
4
  "description": "TypeScript version of a nodejs module based on KOAJS for developing Rest-APIs in a modular solution.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,5 +1,5 @@
1
1
  import mongoose, { Connection, Model, PopulateOptions, Query } from 'mongoose';
2
- import { AccessTypes, AccessDefinition } from '../../class/security';
2
+ import { AccessTypes, AccessDefinition, Permission } from '../../class/security';
3
3
  import triggerOperator from '../../class/trigger_operator';
4
4
  import TypeCasters from './typeCasters';
5
5
  import { config } from '../../config';
@@ -191,7 +191,7 @@ export function getCollection<T>(db: string, collection: string): Model<T> {
191
191
  * @returns {any[]} List of permissions
192
192
  * @private
193
193
  */
194
- function _getPermissionList(db: string, collection: string, operationType: string): any[] {
194
+ function _getPermissionList(db: string, collection: string, operationType: string): Permission[] {
195
195
  if (!permissionDefinitions[db] || !permissionDefinitions[db][collection]) {
196
196
  return [];
197
197
  }
@@ -224,9 +224,9 @@ export function checkAccess(
224
224
  ): boolean {
225
225
  const permissionList = _getPermissionList(db, collection, operationType);
226
226
  return permissionList.some(permission => {
227
- if (permission.type === 'god_access') return true;
228
- if (permission.type === 'anonymous_access' && user.type === 'anonymous') return true;
229
- if (permission.type === 'user_access' && user.type === 'user') return true;
227
+ if (permission.accessType === 'god_access') return true;
228
+ if (permission.accessType === 'anonymous_access' && user.type === 'anonymous') return true;
229
+ if (permission.accessType === 'user_access' && user.type === 'user') return true;
230
230
  return false;
231
231
  });
232
232
  }