@8base/utils
Advanced tools
Comparing version 0.28.4 to 0.28.5
@@ -17,3 +17,3 @@ "use strict"; | ||
const { fields = [] } = getTableByName(tablesList, tableName) || {}; | ||
const { deep = DEFAULT_DEPTH, withMeta = true, relationItemsCount, includeColumns } = queryObjectConfig; | ||
const { deep = DEFAULT_DEPTH, withMeta = true, relationItemsCount, includeColumns, permissions = {}, } = queryObjectConfig; | ||
let queryObject = ''; | ||
@@ -23,3 +23,14 @@ fields | ||
const isMeta = tableFieldSelectors.isMetaField(field); | ||
return withMeta ? true : !isMeta; | ||
const isRelation = tableFieldSelectors.isRelationField(field); | ||
let shouldIncludeField = withMeta ? true : !isMeta; | ||
if (isRelation) { | ||
const refTableName = tableFieldSelectors.getRelationTableName(field); | ||
const refTableAllowed = R.pathOr(true, ['data', refTableName, 'permission', 'read', 'allow'], permissions); | ||
shouldIncludeField = refTableAllowed && shouldIncludeField; | ||
} | ||
else { | ||
const fieldAllowed = R.pathOr(true, ['data', tableName, 'permission', 'read', 'fields', field.name], permissions); | ||
shouldIncludeField = fieldAllowed && shouldIncludeField; | ||
} | ||
return shouldIncludeField; | ||
}) | ||
@@ -26,0 +37,0 @@ .forEach(field => { |
@@ -79,2 +79,3 @@ import { FIELD_TYPE, SWITCH_FORMATS, TEXT_FORMATS, NUMBER_FORMATS, FILE_FORMATS, DATE_FORMATS, MUTATION_TYPE, SMART_FORMATS } from './constants'; | ||
includeColumns?: null | string[]; | ||
permissions?: Object; | ||
}; | ||
@@ -81,0 +82,0 @@ export declare type FormatDataAfterQueryOptions = { |
{ | ||
"name": "@8base/utils", | ||
"version": "0.28.4", | ||
"version": "0.28.5", | ||
"repository": "https://github.com/8base/sdk", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/8base/sdk/tree/master/packages/utils#readme", |
@@ -25,3 +25,9 @@ import * as R from 'ramda'; | ||
const { fields = [] } = getTableByName(tablesList, tableName) || {}; | ||
const { deep = DEFAULT_DEPTH, withMeta = true, relationItemsCount, includeColumns } = queryObjectConfig; | ||
const { | ||
deep = DEFAULT_DEPTH, | ||
withMeta = true, | ||
relationItemsCount, | ||
includeColumns, | ||
permissions = {}, | ||
} = queryObjectConfig; | ||
@@ -33,4 +39,22 @@ let queryObject = ''; | ||
const isMeta = tableFieldSelectors.isMetaField(field); | ||
const isRelation = tableFieldSelectors.isRelationField(field); | ||
return withMeta ? true : !isMeta; | ||
let shouldIncludeField = withMeta ? true : !isMeta; | ||
if (isRelation) { | ||
const refTableName = tableFieldSelectors.getRelationTableName(field); | ||
const refTableAllowed = R.pathOr(true, ['data', refTableName, 'permission', 'read', 'allow'], permissions); | ||
shouldIncludeField = refTableAllowed && shouldIncludeField; | ||
} else { | ||
const fieldAllowed = R.pathOr( | ||
true, | ||
['data', tableName, 'permission', 'read', 'fields', field.name], | ||
permissions, | ||
); | ||
shouldIncludeField = fieldAllowed && shouldIncludeField; | ||
} | ||
return shouldIncludeField; | ||
}) | ||
@@ -37,0 +61,0 @@ .forEach(field => { |
@@ -102,2 +102,3 @@ import { | ||
includeColumns?: null | string[]; | ||
permissions?: Object; | ||
}; | ||
@@ -104,0 +105,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
208599
3336