@contember/schema-utils
Advanced tools
Comparing version 0.9.2-alpha.7 to 0.9.2
@@ -5,4 +5,4 @@ import { Acl, Model } from '@contember/schema'; | ||
constructor(operations?: Acl.Operation[]); | ||
create(schema: Pick<Model.Schema, 'entities'>, allowCustomPrimary?: boolean): Acl.Permissions; | ||
create(schema: Pick<Model.Schema, 'entities'>): Acl.Permissions; | ||
} | ||
//# sourceMappingURL=AllowAllPermissionFactory.d.ts.map |
@@ -14,3 +14,3 @@ "use strict"; | ||
} | ||
create(schema, allowCustomPrimary = false) { | ||
create(schema) { | ||
const permissions = {}; | ||
@@ -35,3 +35,2 @@ for (let entityName in schema.entities) { | ||
: {}), | ||
...(allowCustomPrimary ? { customPrimary: true } : {}), | ||
}, | ||
@@ -38,0 +37,0 @@ }; |
@@ -14,3 +14,2 @@ import { Model } from '@contember/schema'; | ||
export declare const getColumnName: (schema: Model.Schema, entity: Model.Entity, fieldName: string) => string; | ||
export declare const tryGetColumnName: (schema: Model.Schema, entity: Model.Entity, fieldName: string) => string | undefined; | ||
export declare const getColumnType: (schema: Model.Schema, entity: Model.Entity, fieldName: string) => string; | ||
@@ -17,0 +16,0 @@ export declare const getTargetEntity: (schema: Model.Schema, entity: Model.Entity, relationName: string) => Model.Entity | null; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.emptyModelSchema = exports.isOwnerRelation = exports.isInversedRelation = exports.isRelation = exports.acceptRelationTypeVisitor = exports.acceptFieldVisitor = exports.acceptEveryFieldVisitor = exports.getTargetEntity = exports.getColumnType = exports.tryGetColumnName = exports.getColumnName = exports.getEntity = exports.ModelError = exports.ModelErrorCode = void 0; | ||
exports.emptyModelSchema = exports.isOwnerRelation = exports.isInversedRelation = exports.isRelation = exports.acceptRelationTypeVisitor = exports.acceptFieldVisitor = exports.acceptEveryFieldVisitor = exports.getTargetEntity = exports.getColumnType = exports.getColumnName = exports.getEntity = exports.ModelError = exports.ModelErrorCode = void 0; | ||
const utils_1 = require("../utils"); | ||
@@ -40,13 +40,2 @@ const schema_1 = require("@contember/schema"); | ||
}; | ||
exports.tryGetColumnName = (schema, entity, fieldName) => { | ||
try { | ||
return exports.getColumnName(schema, entity, fieldName); | ||
} | ||
catch (e) { | ||
if (e instanceof ModelError && e.code === ModelErrorCode.NOT_OWNING_SIDE) { | ||
return undefined; | ||
} | ||
throw e; | ||
} | ||
}; | ||
exports.getColumnType = (schema, entity, fieldName) => { | ||
@@ -53,0 +42,0 @@ return exports.acceptFieldVisitor(schema, entity, fieldName, { |
@@ -237,3 +237,3 @@ "use strict"; | ||
} | ||
const extra = utils_1.checkExtraProperties(operations, ['read', 'create', 'update', 'delete', 'customPrimary']); | ||
const extra = utils_1.checkExtraProperties(operations, ['read', 'create', 'update', 'delete']); | ||
if (extra.length) { | ||
@@ -251,8 +251,2 @@ errorBuilder.add('Unsupported properties found: ' + extra.join(', ')); | ||
} | ||
if (operations.customPrimary !== undefined) { | ||
if (typeof operations.customPrimary !== 'boolean') { | ||
errorBuilder.for('customPrimary').add('Must be boolean'); | ||
} | ||
validOperations.customPrimary = operations.customPrimary; | ||
} | ||
return validOperations; | ||
@@ -259,0 +253,0 @@ } |
{ | ||
"name": "@contember/schema-utils", | ||
"version": "0.9.2-alpha.7", | ||
"version": "0.9.2", | ||
"license": "Apache-2.0", | ||
"main": "dist/src/index.js", | ||
"typings": "dist/src/index.d.ts", | ||
"scripts": { | ||
"test": "echo 'No tests'" | ||
}, | ||
"scripts": {}, | ||
"dependencies": { | ||
"@contember/schema": "^0.9.2-alpha.7" | ||
"@contember/schema": "^0.9.2" | ||
}, | ||
@@ -13,0 +11,0 @@ "devDependencies": { |
@@ -13,3 +13,3 @@ import { Acl, Model } from '@contember/schema' | ||
create(schema: Pick<Model.Schema, 'entities'>, allowCustomPrimary = false): Acl.Permissions { | ||
create(schema: Pick<Model.Schema, 'entities'>): Acl.Permissions { | ||
const permissions: Acl.Permissions = {} | ||
@@ -39,3 +39,2 @@ for (let entityName in schema.entities) { | ||
: {}), | ||
...(allowCustomPrimary ? { customPrimary: true } : {}), | ||
}, | ||
@@ -42,0 +41,0 @@ } |
@@ -46,13 +46,2 @@ import { assertNever, isIt } from '../utils' | ||
export const tryGetColumnName = (schema: Model.Schema, entity: Model.Entity, fieldName: string) => { | ||
try { | ||
return getColumnName(schema, entity, fieldName) | ||
} catch (e) { | ||
if (e instanceof ModelError && e.code === ModelErrorCode.NOT_OWNING_SIDE) { | ||
return undefined | ||
} | ||
throw e | ||
} | ||
} | ||
export const getColumnType = (schema: Model.Schema, entity: Model.Entity, fieldName: string): string => { | ||
@@ -59,0 +48,0 @@ return acceptFieldVisitor(schema, entity, fieldName, { |
@@ -310,3 +310,3 @@ import { Acl, Model } from '@contember/schema' | ||
} | ||
const extra = checkExtraProperties(operations, ['read', 'create', 'update', 'delete', 'customPrimary']) | ||
const extra = checkExtraProperties(operations, ['read', 'create', 'update', 'delete']) | ||
if (extra.length) { | ||
@@ -324,8 +324,2 @@ errorBuilder.add('Unsupported properties found: ' + extra.join(', ')) | ||
} | ||
if (operations.customPrimary !== undefined) { | ||
if (typeof operations.customPrimary !== 'boolean') { | ||
errorBuilder.for('customPrimary').add('Must be boolean') | ||
} | ||
validOperations.customPrimary = operations.customPrimary as boolean | ||
} | ||
@@ -332,0 +326,0 @@ return validOperations |
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
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
682534
847
2
3459
3
48
Updated@contember/schema@^0.9.2