@contember/schema-utils
Advanced tools
Comparing version 0.9.1 to 0.9.2-alpha.0
@@ -5,4 +5,4 @@ import { Acl, Model } from '@contember/schema'; | ||
constructor(operations?: Acl.Operation[]); | ||
create(schema: Pick<Model.Schema, 'entities'>): Acl.Permissions; | ||
create(schema: Pick<Model.Schema, 'entities'>, allowCustomPrimary?: boolean): Acl.Permissions; | ||
} | ||
//# sourceMappingURL=AllowAllPermissionFactory.d.ts.map |
@@ -14,3 +14,3 @@ "use strict"; | ||
} | ||
create(schema) { | ||
create(schema, allowCustomPrimary = false) { | ||
const permissions = {}; | ||
@@ -35,2 +35,3 @@ for (let entityName in schema.entities) { | ||
: {}), | ||
...(allowCustomPrimary ? { customPrimary: true } : {}), | ||
}, | ||
@@ -37,0 +38,0 @@ }; |
@@ -14,2 +14,3 @@ 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; | ||
@@ -16,0 +17,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.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.tryGetColumnName = exports.getColumnName = exports.getEntity = exports.ModelError = exports.ModelErrorCode = void 0; | ||
const utils_1 = require("../utils"); | ||
@@ -40,2 +40,13 @@ 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) => { | ||
@@ -42,0 +53,0 @@ return exports.acceptFieldVisitor(schema, entity, fieldName, { |
{ | ||
"name": "@contember/schema-utils", | ||
"version": "0.9.1", | ||
"version": "0.9.2-alpha.0", | ||
"license": "Apache-2.0", | ||
@@ -9,3 +9,3 @@ "main": "dist/src/index.js", | ||
"dependencies": { | ||
"@contember/schema": "^0.9.1" | ||
"@contember/schema": "^0.9.2-alpha.0" | ||
}, | ||
@@ -12,0 +12,0 @@ "devDependencies": { |
@@ -13,3 +13,3 @@ import { Acl, Model } from '@contember/schema' | ||
create(schema: Pick<Model.Schema, 'entities'>): Acl.Permissions { | ||
create(schema: Pick<Model.Schema, 'entities'>, allowCustomPrimary = false): Acl.Permissions { | ||
const permissions: Acl.Permissions = {} | ||
@@ -39,2 +39,3 @@ for (let entityName in schema.entities) { | ||
: {}), | ||
...(allowCustomPrimary ? { customPrimary: true } : {}), | ||
}, | ||
@@ -41,0 +42,0 @@ } |
@@ -46,2 +46,13 @@ 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 => { | ||
@@ -48,0 +59,0 @@ return acceptFieldVisitor(schema, entity, fieldName, { |
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
684021
3483