@contember/schema-migrations
Advanced tools
Comparing version 0.10.0-alpha.11 to 0.10.0-alpha.12
@@ -15,2 +15,3 @@ export * from './SchemaDiffer'; | ||
export * from './MigrationVersionHelper'; | ||
export { SchemaUpdateError } from './modifications/exceptions'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -16,3 +16,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ModificationHandlerFactory = void 0; | ||
exports.SchemaUpdateError = exports.ModificationHandlerFactory = void 0; | ||
__exportStar(require("./SchemaDiffer"), exports); | ||
@@ -33,2 +33,4 @@ __exportStar(require("./Migration"), exports); | ||
__exportStar(require("./MigrationVersionHelper"), exports); | ||
var exceptions_1 = require("./modifications/exceptions"); | ||
Object.defineProperty(exports, "SchemaUpdateError", { enumerable: true, get: function () { return exceptions_1.SchemaUpdateError; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -26,14 +26,15 @@ "use strict"; | ||
const operations = {}; | ||
if (entityPermissions.operations.create) { | ||
operations.create = updater(entityPermissions.operations.create, entityName, schema_1.Acl.Operation.create); | ||
const handlers = { | ||
create: value => updater(value, entityName, schema_1.Acl.Operation.create), | ||
update: value => updater(value, entityName, schema_1.Acl.Operation.update), | ||
read: value => updater(value, entityName, schema_1.Acl.Operation.read), | ||
delete: value => value, | ||
customPrimary: value => value, | ||
}; | ||
const types = ['create', 'update', 'read', 'delete', 'customPrimary']; | ||
for (const key of types) { | ||
if (key in entityPermissions.operations) { | ||
operations[key] = handlers[key](entityPermissions.operations[key]); | ||
} | ||
} | ||
if (entityPermissions.operations.update) { | ||
operations.update = updater(entityPermissions.operations.update, entityName, schema_1.Acl.Operation.update); | ||
} | ||
if (entityPermissions.operations.read) { | ||
operations.read = updater(entityPermissions.operations.read, entityName, schema_1.Acl.Operation.read); | ||
} | ||
if ('delete' in entityPermissions.operations) { | ||
operations.delete = entityPermissions.operations.delete; | ||
} | ||
return { | ||
@@ -40,0 +41,0 @@ ...entityPermissions, |
{ | ||
"name": "@contember/schema-migrations", | ||
"version": "0.10.0-alpha.11", | ||
"version": "0.10.0-alpha.12", | ||
"license": "Apache-2.0", | ||
@@ -11,6 +11,6 @@ "main": "dist/src/index.js", | ||
"dependencies": { | ||
"@contember/database-migrations": "^0.10.0-alpha.11", | ||
"@contember/engine-common": "^0.10.0-alpha.11", | ||
"@contember/schema": "^0.10.0-alpha.11", | ||
"@contember/schema-utils": "^0.10.0-alpha.11", | ||
"@contember/database-migrations": "^0.10.0-alpha.12", | ||
"@contember/engine-common": "^0.10.0-alpha.12", | ||
"@contember/schema": "^0.10.0-alpha.12", | ||
"@contember/schema-utils": "^0.10.0-alpha.12", | ||
"fast-deep-equal": "^3.1.3", | ||
@@ -20,3 +20,3 @@ "rfc6902": "^4.0.1" | ||
"devDependencies": { | ||
"@contember/schema-definition": "^0.10.0-alpha.11", | ||
"@contember/schema-definition": "^0.10.0-alpha.12", | ||
"uvu": "^0.4.1" | ||
@@ -23,0 +23,0 @@ }, |
@@ -15,1 +15,2 @@ export * from './SchemaDiffer' | ||
export * from './MigrationVersionHelper' | ||
export { SchemaUpdateError } from './modifications/exceptions' |
@@ -50,2 +50,7 @@ import { Acl, Model, Schema } from '@contember/schema' | ||
) => Acl.FieldPermissions | ||
type EntityOperationHandler = { | ||
[K in keyof Required<Acl.EntityOperations>]: ( | ||
value: Exclude<Acl.EntityOperations[K], undefined>, | ||
) => Acl.EntityOperations[K] | ||
} | ||
@@ -57,14 +62,16 @@ export const updateAclFieldPermissions = (updater: EntityAclFieldPermissionsUpdater): EntityPermissionsUpdater => ( | ||
const operations: Acl.EntityOperations = {} | ||
if (entityPermissions.operations.create) { | ||
operations.create = updater(entityPermissions.operations.create, entityName, Acl.Operation.create) | ||
const handlers: EntityOperationHandler = { | ||
create: value => updater(value, entityName, Acl.Operation.create), | ||
update: value => updater(value, entityName, Acl.Operation.update), | ||
read: value => updater(value, entityName, Acl.Operation.read), | ||
delete: value => value, | ||
customPrimary: value => value, | ||
} | ||
if (entityPermissions.operations.update) { | ||
operations.update = updater(entityPermissions.operations.update, entityName, Acl.Operation.update) | ||
const types: (keyof Acl.EntityOperations)[] = ['create', 'update', 'read', 'delete', 'customPrimary'] | ||
for (const key of types) { | ||
if (key in entityPermissions.operations) { | ||
operations[key] = handlers[key](entityPermissions.operations[key] as any) as any | ||
} | ||
} | ||
if (entityPermissions.operations.read) { | ||
operations.read = updater(entityPermissions.operations.read, entityName, Acl.Operation.read) | ||
} | ||
if ('delete' in entityPermissions.operations) { | ||
operations.delete = entityPermissions.operations.delete | ||
} | ||
return { | ||
@@ -71,0 +78,0 @@ ...entityPermissions, |
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
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
1289138
9698