Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@contember/schema-utils

Package Overview
Dependencies
Maintainers
4
Versions
259
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contember/schema-utils - npm Package Compare versions

Comparing version 1.4.0-rc.1 to 1.4.0-rc.2

8

dist/src/definition-generator/AclDefinitionCodeGenerator.js

@@ -22,3 +22,3 @@ "use strict";

const roleVarName = this.definitionNamingConventions.roleVarName(name);
return `\nexport const ${roleVarName} = acl.createRole(${(0, printJsValue_1.printJsValue)(name)}, ${(0, printJsValue_1.printJsValue)(other)})\n`;
return `\nexport const ${roleVarName} = c.createRole(${(0, printJsValue_1.printJsValue)(name)}, ${(0, printJsValue_1.printJsValue)(other)})\n`;
}

@@ -29,3 +29,3 @@ generateAclVariables({ acl }) {

Object.entries(roleValues.variables).map(([variableName, variableValues]) => {
let variableDefinition = `\nexport const ${this.definitionNamingConventions.variableVarName(roleName, variableName)} = acl.`;
let variableDefinition = `\nexport const ${this.definitionNamingConventions.variableVarName(roleName, variableName)} = c.`;
const varFormatted = (0, printJsValue_1.printJsValue)(variableName);

@@ -78,3 +78,3 @@ const roleVarName = this.definitionNamingConventions.roleVarName(roleName);

const aclDefinition = (0, printJsValue_1.printJsValue)({ when, ...operations }, indentFirstLevel);
aclOutput.push(`@acl.allow(${roleVarName}, ${aclDefinition})\n`);
aclOutput.push(`@c.Allow(${roleVarName}, ${aclDefinition})\n`);
}

@@ -89,3 +89,3 @@ }

const aclDefinition = (0, printJsValue_1.printJsValue)({ ...trueOperations }, indentFirstLevel);
aclOutput.push(`@acl.allow(${roleVarName}, ${aclDefinition})\n`);
aclOutput.push(`@c.Allow(${roleVarName}, ${aclDefinition})\n`);
}

@@ -92,0 +92,0 @@ }

@@ -23,7 +23,7 @@ "use strict";

const entities = Object.values(schema.model.entities).map(entity => this.generateEntity({ entity, schema })).join('');
return `import { SchemaDefinition as def, AclDefinition as acl } from '@contember/schema-definition'
return `import { c } from '@contember/schema-definition'
${roles}${aclVariables}${enums}${entities}`;
}
generateEnum({ name, values }) {
return `\nexport const ${this.formatIdentifier(name)} = def.createEnum(${values.map(it => (0, printJsValue_1.printJsValue)(it)).join(', ')})\n`;
return `\nexport const ${this.formatIdentifier(name)} = c.createEnum(${values.map(it => (0, printJsValue_1.printJsValue)(it)).join(', ')})\n`;
}

@@ -43,7 +43,7 @@ generateEntity({ entity, schema }) {

const fieldsList = `${constraint.fields.map(it => (0, printJsValue_1.printJsValue)(it)).join(', ')}`;
return `@def.Unique(${fieldsList})`;
return `@c.Unique(${fieldsList})`;
}
generateIndex({ entity, index }) {
const fieldsList = `${index.fields.map(it => (0, printJsValue_1.printJsValue)(it)).join(', ')}`;
return `@def.Index(${fieldsList})`;
return `@c.Index(${fieldsList})`;
}

@@ -58,3 +58,3 @@ generateView({ entity }) {

: '';
return `@def.View(\`${entity.view.sql}\`${dependenciesExpr})`;
return `@c.View(\`${entity.view.sql}\`${dependenciesExpr})`;
}

@@ -173,3 +173,3 @@ generateField({ entity, field, schema }) {

}
return `\t${this.formatIdentifier(field.name)} = def.${definitionCode}`;
return `\t${this.formatIdentifier(field.name)} = c.${definitionCode}`;
}

@@ -176,0 +176,0 @@ generateColumn({ entity, column }) {

@@ -1,13 +0,12 @@

import { SchemaDefinition as def, AclDefinition as acl } from '@contember/schema-definition';
export declare const readerRole: acl.Role<"reader">;
export declare const editorRole: acl.Role<"editor">;
export declare const categoryEditorVariable: acl.VariableDefinition<"category", acl.Role<"editor">, import("@contember/schema").Acl.EntityVariable>;
export declare const readerRole: import("@contember/schema-definition/dist/src/acl/definition").Role<"reader">;
export declare const editorRole: import("@contember/schema-definition/dist/src/acl/definition").Role<"editor">;
export declare const categoryEditorVariable: import("@contember/schema-definition/dist/src/acl/definition").VariableDefinition<"category", import("@contember/schema-definition/dist/src/acl/definition").Role<"editor">, import("@contember/schema").Acl.EntityVariable>;
export declare class Article {
title: def.ColumnDefinition;
deletedAt: def.ColumnDefinition;
category: import("@contember/schema-definition/dist/src/model/definition/types").Interface<def.ManyHasOneDefinitionImpl>;
title: import("@contember/schema-definition/dist/src/model/definition").ColumnDefinition;
deletedAt: import("@contember/schema-definition/dist/src/model/definition").ColumnDefinition;
category: import("@contember/schema-definition/dist/src/model/definition/types").Interface<import("@contember/schema-definition/dist/src/model/definition").ManyHasOneDefinitionImpl>;
}
export declare class Category {
name: def.ColumnDefinition;
name: import("@contember/schema-definition/dist/src/model/definition").ColumnDefinition;
}
//# sourceMappingURL=acl.d.ts.map

@@ -11,10 +11,10 @@ "use strict";

const schema_definition_1 = require("@contember/schema-definition");
exports.readerRole = schema_definition_1.AclDefinition.createRole('reader', { stages: '*' });
exports.editorRole = schema_definition_1.AclDefinition.createRole('editor', { stages: '*' });
exports.categoryEditorVariable = schema_definition_1.AclDefinition.createEntityVariable('category', 'Category', exports.editorRole);
exports.readerRole = schema_definition_1.c.createRole('reader', { stages: '*' });
exports.editorRole = schema_definition_1.c.createRole('editor', { stages: '*' });
exports.categoryEditorVariable = schema_definition_1.c.createEntityVariable('category', 'Category', exports.editorRole);
let Article = class Article {
constructor() {
this.title = schema_definition_1.SchemaDefinition.stringColumn();
this.deletedAt = schema_definition_1.SchemaDefinition.dateTimeColumn();
this.category = schema_definition_1.SchemaDefinition.manyHasOne(Category);
this.title = schema_definition_1.c.stringColumn();
this.deletedAt = schema_definition_1.c.dateTimeColumn();
this.category = schema_definition_1.c.manyHasOne(Category);
}

@@ -24,6 +24,6 @@ };

exports.Article = Article = __decorate([
schema_definition_1.AclDefinition.allow(exports.readerRole, {
schema_definition_1.c.Allow(exports.readerRole, {
read: true,
}),
schema_definition_1.AclDefinition.allow(exports.editorRole, {
schema_definition_1.c.Allow(exports.editorRole, {
when: { category: { id: exports.categoryEditorVariable } },

@@ -37,3 +37,3 @@ read: true,

constructor() {
this.name = schema_definition_1.SchemaDefinition.stringColumn();
this.name = schema_definition_1.c.stringColumn();
}

@@ -43,6 +43,6 @@ };

exports.Category = Category = __decorate([
schema_definition_1.AclDefinition.allow(exports.readerRole, {
schema_definition_1.c.Allow(exports.readerRole, {
read: true,
}),
schema_definition_1.AclDefinition.allow(exports.editorRole, {
schema_definition_1.c.Allow(exports.editorRole, {
read: true,

@@ -49,0 +49,0 @@ })

@@ -1,5 +0,4 @@

import { SchemaDefinition as def } from '@contember/schema-definition';
export declare class Article {
title: def.ColumnDefinition;
title: import("@contember/schema-definition/dist/src/model/definition").ColumnDefinition;
}
//# sourceMappingURL=basic.d.ts.map

@@ -7,3 +7,3 @@ "use strict";

constructor() {
this.title = schema_definition_1.SchemaDefinition.stringColumn();
this.title = schema_definition_1.c.stringColumn();
}

@@ -10,0 +10,0 @@ }

@@ -1,7 +0,6 @@

import { SchemaDefinition as def } from '@contember/schema-definition';
export declare const articleState: def.EnumDefinition<"draft" | "published">;
export declare const articleState: import("@contember/schema-definition/dist/src/model/definition").EnumDefinition<"draft" | "published">;
export declare class Article {
title: def.ColumnDefinition;
state: import("@contember/schema-definition/dist/src/model/definition/types").Interface<def.ColumnDefinition>;
title: import("@contember/schema-definition/dist/src/model/definition").ColumnDefinition;
state: import("@contember/schema-definition/dist/src/model/definition/types").Interface<import("@contember/schema-definition/dist/src/model/definition").ColumnDefinition>;
}
//# sourceMappingURL=enum.d.ts.map

@@ -5,7 +5,7 @@ "use strict";

const schema_definition_1 = require("@contember/schema-definition");
exports.articleState = schema_definition_1.SchemaDefinition.createEnum('draft', 'published');
exports.articleState = schema_definition_1.c.createEnum('draft', 'published');
class Article {
constructor() {
this.title = schema_definition_1.SchemaDefinition.stringColumn();
this.state = schema_definition_1.SchemaDefinition.enumColumn(exports.articleState).notNull().default('draft');
this.title = schema_definition_1.c.stringColumn();
this.state = schema_definition_1.c.enumColumn(exports.articleState).notNull().default('draft');
}

@@ -12,0 +12,0 @@ }

@@ -1,15 +0,14 @@

import { SchemaDefinition as def } from '@contember/schema-definition';
export declare class Article {
title: def.ColumnDefinition;
category: import("@contember/schema-definition/dist/src/model/definition/types").Interface<def.ManyHasOneDefinitionImpl>;
tags: import("@contember/schema-definition/dist/src/model/definition/types").Interface<def.ManyHasManyDefinitionImpl>;
title: import("@contember/schema-definition/dist/src/model/definition").ColumnDefinition;
category: import("@contember/schema-definition/dist/src/model/definition/types").Interface<import("@contember/schema-definition/dist/src/model/definition").ManyHasOneDefinitionImpl>;
tags: import("@contember/schema-definition/dist/src/model/definition/types").Interface<import("@contember/schema-definition/dist/src/model/definition").ManyHasManyDefinitionImpl>;
}
export declare class Category {
name: def.ColumnDefinition;
articles: import("@contember/schema-definition/dist/src/model/definition/types").Interface<def.OneHasManyDefinitionImpl>;
name: import("@contember/schema-definition/dist/src/model/definition").ColumnDefinition;
articles: import("@contember/schema-definition/dist/src/model/definition/types").Interface<import("@contember/schema-definition/dist/src/model/definition").OneHasManyDefinitionImpl>;
}
export declare class Tag {
name: def.ColumnDefinition;
tags: import("@contember/schema-definition/dist/src/model/definition/types").Interface<def.ManyHasManyInverseDefinitionImpl>;
name: import("@contember/schema-definition/dist/src/model/definition").ColumnDefinition;
tags: import("@contember/schema-definition/dist/src/model/definition/types").Interface<import("@contember/schema-definition/dist/src/model/definition").ManyHasManyInverseDefinitionImpl>;
}
//# sourceMappingURL=relations.d.ts.map

@@ -7,5 +7,5 @@ "use strict";

constructor() {
this.title = schema_definition_1.SchemaDefinition.stringColumn();
this.category = schema_definition_1.SchemaDefinition.manyHasOne(Category, 'articles');
this.tags = schema_definition_1.SchemaDefinition.manyHasMany(Tag, 'articles');
this.title = schema_definition_1.c.stringColumn();
this.category = schema_definition_1.c.manyHasOne(Category, 'articles');
this.tags = schema_definition_1.c.manyHasMany(Tag, 'articles');
}

@@ -16,4 +16,4 @@ }

constructor() {
this.name = schema_definition_1.SchemaDefinition.stringColumn();
this.articles = schema_definition_1.SchemaDefinition.oneHasMany(Article, 'category');
this.name = schema_definition_1.c.stringColumn();
this.articles = schema_definition_1.c.oneHasMany(Article, 'category');
}

@@ -24,4 +24,4 @@ }

constructor() {
this.name = schema_definition_1.SchemaDefinition.stringColumn();
this.tags = schema_definition_1.SchemaDefinition.manyHasManyInverse(Article, 'tags');
this.name = schema_definition_1.c.stringColumn();
this.tags = schema_definition_1.c.manyHasManyInverse(Article, 'tags');
}

@@ -28,0 +28,0 @@ }

@@ -1,5 +0,4 @@

import { SchemaDefinition as def } from '@contember/schema-definition';
export declare class Article {
title: def.ColumnDefinition;
title: import("@contember/schema-definition/dist/src/model/definition").ColumnDefinition;
}
//# sourceMappingURL=unique.d.ts.map

@@ -13,3 +13,3 @@ "use strict";

constructor() {
this.title = schema_definition_1.SchemaDefinition.stringColumn();
this.title = schema_definition_1.c.stringColumn();
}

@@ -19,4 +19,4 @@ };

exports.Article = Article = __decorate([
schema_definition_1.SchemaDefinition.Unique('title')
schema_definition_1.c.Unique('title')
], Article);
//# sourceMappingURL=unique.js.map
{
"name": "@contember/schema-utils",
"version": "1.4.0-rc.1",
"version": "1.4.0-rc.2",
"license": "Apache-2.0",

@@ -15,9 +15,9 @@ "main": "dist/src/index.js",

"dependencies": {
"@contember/schema": "1.4.0-rc.1",
"@contember/typesafe": "1.4.0-rc.1"
"@contember/schema": "1.4.0-rc.2",
"@contember/typesafe": "1.4.0-rc.2"
},
"devDependencies": {
"@contember/schema-definition": "1.4.0-rc.1",
"@contember/schema-definition": "1.4.0-rc.2",
"@types/node": "^20.9.0"
}
}

@@ -26,3 +26,3 @@ import { PredicateDefinitionProcessor } from '../acl'

const roleVarName = this.definitionNamingConventions.roleVarName(name)
return `\nexport const ${roleVarName} = acl.createRole(${printJsValue(name)}, ${printJsValue(other)})\n`
return `\nexport const ${roleVarName} = c.createRole(${printJsValue(name)}, ${printJsValue(other)})\n`
}

@@ -35,3 +35,3 @@

Object.entries(roleValues.variables).map(([variableName, variableValues]) => {
let variableDefinition = `\nexport const ${this.definitionNamingConventions.variableVarName(roleName, variableName)} = acl.`
let variableDefinition = `\nexport const ${this.definitionNamingConventions.variableVarName(roleName, variableName)} = c.`
const varFormatted = printJsValue(variableName)

@@ -86,3 +86,3 @@ const roleVarName = this.definitionNamingConventions.roleVarName(roleName)

const aclDefinition = printJsValue({ when, ...operations }, indentFirstLevel)
aclOutput.push(`@acl.allow(${roleVarName}, ${aclDefinition})\n`)
aclOutput.push(`@c.Allow(${roleVarName}, ${aclDefinition})\n`)
}

@@ -97,3 +97,3 @@ }

const aclDefinition = printJsValue({ ...trueOperations }, indentFirstLevel)
aclOutput.push(`@acl.allow(${roleVarName}, ${aclDefinition})\n`)
aclOutput.push(`@c.Allow(${roleVarName}, ${aclDefinition})\n`)
}

@@ -100,0 +100,0 @@ }

@@ -33,3 +33,3 @@ import { Model, Schema, Writable } from '@contember/schema'

return `import { SchemaDefinition as def, AclDefinition as acl } from '@contember/schema-definition'
return `import { c } from '@contember/schema-definition'
${roles}${aclVariables}${enums}${entities}`

@@ -40,3 +40,3 @@ }

private generateEnum({ name, values }: { name: string; values: readonly string[] }): string {
return `\nexport const ${this.formatIdentifier(name)} = def.createEnum(${values.map(it => printJsValue(it)).join(', ')})\n`
return `\nexport const ${this.formatIdentifier(name)} = c.createEnum(${values.map(it => printJsValue(it)).join(', ')})\n`
}

@@ -62,3 +62,3 @@

const fieldsList = `${constraint.fields.map(it => printJsValue(it)).join(', ')}`
return `@def.Unique(${fieldsList})`
return `@c.Unique(${fieldsList})`
}

@@ -68,3 +68,3 @@

const fieldsList = `${index.fields.map(it => printJsValue(it)).join(', ')}`
return `@def.Index(${fieldsList})`
return `@c.Index(${fieldsList})`
}

@@ -82,3 +82,3 @@

return `@def.View(\`${entity.view.sql}\`${dependenciesExpr})`
return `@c.View(\`${entity.view.sql}\`${dependenciesExpr})`
}

@@ -203,3 +203,3 @@

}
return `\t${this.formatIdentifier(field.name)} = def.${definitionCode}`
return `\t${this.formatIdentifier(field.name)} = c.${definitionCode}`
}

@@ -206,0 +206,0 @@

@@ -1,14 +0,14 @@

import { SchemaDefinition as def, AclDefinition as acl } from '@contember/schema-definition'
import { c } from '@contember/schema-definition'
export const readerRole = acl.createRole('reader', { stages: '*' })
export const readerRole = c.createRole('reader', { stages: '*' })
export const editorRole = acl.createRole('editor', { stages: '*' })
export const editorRole = c.createRole('editor', { stages: '*' })
export const categoryEditorVariable = acl.createEntityVariable('category', 'Category', editorRole)
export const categoryEditorVariable = c.createEntityVariable('category', 'Category', editorRole)
@acl.allow(readerRole, {
@c.Allow(readerRole, {
read: true,
})
@acl.allow(editorRole, {
@c.Allow(editorRole, {
when: { category: { id: categoryEditorVariable } },

@@ -20,16 +20,16 @@ read: true,

export class Article {
title = def.stringColumn()
deletedAt = def.dateTimeColumn()
category = def.manyHasOne(Category)
title = c.stringColumn()
deletedAt = c.dateTimeColumn()
category = c.manyHasOne(Category)
}
@acl.allow(readerRole, {
@c.Allow(readerRole, {
read: true,
})
@acl.allow(editorRole, {
@c.Allow(editorRole, {
read: true,
})
export class Category {
name = def.stringColumn()
name = c.stringColumn()
}

@@ -1,5 +0,5 @@

import { SchemaDefinition as def, AclDefinition as acl } from '@contember/schema-definition'
import { c } from '@contember/schema-definition'
export class Article {
title = def.stringColumn()
title = c.stringColumn()
}

@@ -1,8 +0,8 @@

import { SchemaDefinition as def, AclDefinition as acl } from '@contember/schema-definition'
import { c } from '@contember/schema-definition'
export const articleState = def.createEnum('draft', 'published')
export const articleState = c.createEnum('draft', 'published')
export class Article {
title = def.stringColumn()
state = def.enumColumn(articleState).notNull().default('draft')
title = c.stringColumn()
state = c.enumColumn(articleState).notNull().default('draft')
}

@@ -1,17 +0,17 @@

import { SchemaDefinition as def, AclDefinition as acl } from '@contember/schema-definition'
import { c } from '@contember/schema-definition'
export class Article {
title = def.stringColumn()
category = def.manyHasOne(Category, 'articles')
tags = def.manyHasMany(Tag, 'articles')
title = c.stringColumn()
category = c.manyHasOne(Category, 'articles')
tags = c.manyHasMany(Tag, 'articles')
}
export class Category {
name = def.stringColumn()
articles = def.oneHasMany(Article, 'category')
name = c.stringColumn()
articles = c.oneHasMany(Article, 'category')
}
export class Tag {
name = def.stringColumn()
tags = def.manyHasManyInverse(Article, 'tags')
name = c.stringColumn()
tags = c.manyHasManyInverse(Article, 'tags')
}

@@ -1,6 +0,6 @@

import { SchemaDefinition as def, AclDefinition as acl } from '@contember/schema-definition'
import { c } from '@contember/schema-definition'
@def.Unique('title')
@c.Unique('title')
export class Article {
title = def.stringColumn()
title = c.stringColumn()
}

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

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc