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

@contember/schema-utils

Package Overview
Dependencies
Maintainers
0
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 2.0.0-alpha.14 to 2.0.0-alpha.15

dist/tests/cases/unit/schemas/complex.d.ts

3

dist/development/src/definition-generator/AclDefinitionCodeGenerator.js

@@ -94,4 +94,3 @@ import { Acl } from "@contember/schema";

}
return `
${aclOutput.join("")}`;
return `${aclOutput.join("")}`;
}

@@ -98,0 +97,0 @@ getMatchingOperations({ operations, predicate, numberOfEntityFieldsWithoutId }) {

@@ -17,6 +17,3 @@ import { Model } from "@contember/schema";

const aclVariables = this.aclGenerator.generateAclVariables({ acl: schema.acl });
const enums = Object.entries(schema.model.enums).map(([name, values]) => this.generateEnum({
name,
values
})).join("");
const enums = Object.entries(schema.model.enums).map(([name, values]) => this.generateEnum({ name, values })).join("");
const entities = Object.values(schema.model.entities).map((entity) => this.generateEntity({ entity, schema })).join("");

@@ -32,7 +29,6 @@ return `import { c } from '@contember/schema-definition'

generateEntity({ entity, schema }) {
const decorators = [
...Object.values(entity.unique).map((constraint) => this.generateUniqueConstraint({ entity, constraint })),
...Object.values(entity.indexes).map((index) => this.generateIndex({ entity, index })),
this.generateView({ entity })
].filter((it) => !!it).map((it) => `${it}
const uniqueConstraints = Object.values(entity.unique).map((constraint) => this.generateUniqueConstraint({ entity, constraint }));
const indexes = Object.values(entity.indexes).map((index) => this.generateIndex({ entity, index }));
const views = this.generateView({ entity });
const decorators = [...uniqueConstraints, ...indexes, views].filter((it) => !!it).map((it) => `${it}
`).join("");

@@ -39,0 +35,0 @@ const acl = this.aclGenerator.generateEntityAcl({ entity, schema });

@@ -94,4 +94,3 @@ import { Acl } from "@contember/schema";

}
return `
${aclOutput.join("")}`;
return `${aclOutput.join("")}`;
}

@@ -98,0 +97,0 @@ getMatchingOperations({ operations, predicate, numberOfEntityFieldsWithoutId }) {

@@ -17,6 +17,3 @@ import { Model } from "@contember/schema";

const aclVariables = this.aclGenerator.generateAclVariables({ acl: schema.acl });
const enums = Object.entries(schema.model.enums).map(([name, values]) => this.generateEnum({
name,
values
})).join("");
const enums = Object.entries(schema.model.enums).map(([name, values]) => this.generateEnum({ name, values })).join("");
const entities = Object.values(schema.model.entities).map((entity) => this.generateEntity({ entity, schema })).join("");

@@ -32,7 +29,6 @@ return `import { c } from '@contember/schema-definition'

generateEntity({ entity, schema }) {
const decorators = [
...Object.values(entity.unique).map((constraint) => this.generateUniqueConstraint({ entity, constraint })),
...Object.values(entity.indexes).map((index) => this.generateIndex({ entity, index })),
this.generateView({ entity })
].filter((it) => !!it).map((it) => `${it}
const uniqueConstraints = Object.values(entity.unique).map((constraint) => this.generateUniqueConstraint({ entity, constraint }));
const indexes = Object.values(entity.indexes).map((index) => this.generateIndex({ entity, index }));
const views = this.generateView({ entity });
const decorators = [...uniqueConstraints, ...indexes, views].filter((it) => !!it).map((it) => `${it}
`).join("");

@@ -39,0 +35,0 @@ const acl = this.aclGenerator.generateEntityAcl({ entity, schema });

{
"name": "@contember/schema-utils",
"version": "2.0.0-alpha.14",
"version": "2.0.0-alpha.15",
"license": "Apache-2.0",

@@ -26,7 +26,7 @@ "main": "./dist/production/index.js",

"dependencies": {
"@contember/schema": "2.0.0-alpha.14",
"@contember/typesafe": "2.0.0-alpha.14"
"@contember/schema": "2.0.0-alpha.15",
"@contember/typesafe": "2.0.0-alpha.15"
},
"devDependencies": {
"@contember/schema-definition": "2.0.0-alpha.14",
"@contember/schema-definition": "2.0.0-alpha.15",
"@types/node": "^20.9.0"

@@ -33,0 +33,0 @@ },

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

}
return `\n${aclOutput.join('')}`
return `${aclOutput.join('')}`
}

@@ -104,0 +104,0 @@

@@ -25,15 +25,8 @@ import { Model, Schema, Writable } from '@contember/schema'

const aclVariables = this.aclGenerator.generateAclVariables({ acl: schema.acl })
const enums = Object.entries(schema.model.enums).map(([name, values]) => this.generateEnum({
name,
values,
})).join('')
const enums = Object.entries(schema.model.enums).map(([name, values]) => this.generateEnum({ name, values })).join('')
const entities = Object.values(schema.model.entities).map(entity => this.generateEntity({ entity, schema })).join('')
return `import { c } from '@contember/schema-definition'
${roles}${aclVariables}${enums}${entities}`
return `import { c } from '@contember/schema-definition'\n${roles}${aclVariables}${enums}${entities}`
}
private generateEnum({ name, values }: { name: string; values: readonly string[] }): string {

@@ -44,7 +37,7 @@ return `\nexport const ${this.formatIdentifier(name)} = c.createEnum(${values.map(it => printJsValue(it)).join(', ')})\n`

public generateEntity({ entity, schema }: { entity: Model.Entity; schema: Schema }): string {
const decorators = [
...Object.values(entity.unique).map(constraint => this.generateUniqueConstraint({ entity, constraint })),
...Object.values(entity.indexes).map(index => this.generateIndex({ entity, index })),
this.generateView({ entity }),
].filter(it => !!it).map(it => `${it}\n`).join('')
const uniqueConstraints = Object.values(entity.unique).map(constraint => this.generateUniqueConstraint({ entity, constraint }))
const indexes = Object.values(entity.indexes).map(index => this.generateIndex({ entity, index }))
const views = this.generateView({ entity })
const decorators = [...uniqueConstraints, ...indexes, views].filter(it => !!it).map(it => `${it}\n`).join('')
const acl = this.aclGenerator.generateEntityAcl({ entity, schema })

@@ -57,7 +50,5 @@

private generateUniqueConstraint({ entity, constraint }: {
entity: Model.Entity
constraint: Model.UniqueConstraint
}): string {
private generateUniqueConstraint({ entity, constraint }: { entity: Model.Entity; constraint: Model.UniqueConstraint }): string {
const fieldsList = `${constraint.fields.map(it => printJsValue(it)).join(', ')}`
return `@c.Unique(${fieldsList})`

@@ -68,2 +59,3 @@ }

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

@@ -70,0 +62,0 @@ }

@@ -9,3 +9,2 @@ import { c } from '@contember/schema-definition'

@c.Allow(readerRole, {

@@ -26,3 +25,2 @@ read: true,

@c.Allow(readerRole, {

@@ -29,0 +27,0 @@ read: true,

import { createSchema } from '@contember/schema-definition'
import { expect, test } from 'vitest'
import * as basic from './schemas/basic'
import * as complex from './schemas/complex'
import * as relations from './schemas/relations'

@@ -8,2 +9,3 @@ import * as unique from './schemas/unique'

import * as acl from './schemas/acl'
import * as view from './schemas/view'
import { readFile, writeFile } from 'fs/promises'

@@ -17,2 +19,3 @@ import { join } from 'path'

['basic', basic],
['complex', complex],
['relations', relations],

@@ -22,2 +25,3 @@ ['unique', unique],

['acl', acl],
['view', view],
] as const

@@ -24,0 +28,0 @@ for (const [name, def] of tests) {

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