@contember/schema-definition
Advanced tools
Comparing version 1.2.0-alpha.6 to 1.2.0-alpha.7
import { EntityConstructor } from './types'; | ||
export declare const View: (sql: string, { dependencies }?: { | ||
dependencies?: EntityConstructor<any>[] | undefined; | ||
dependencies?: EntityConstructor<any>[] | (() => EntityConstructor[]) | undefined; | ||
}) => import("./types").DecoratorFunction<unknown>; | ||
//# sourceMappingURL=ViewDefinition.d.ts.map |
@@ -5,10 +5,23 @@ "use strict"; | ||
const extensions_1 = require("./extensions"); | ||
const View = (sql, { dependencies } = {}) => (0, extensions_1.extendEntity)(({ entity, registry }) => ({ | ||
...entity, | ||
view: { | ||
sql, | ||
...(dependencies ? { dependencies: dependencies === null || dependencies === void 0 ? void 0 : dependencies.map(it => registry.getName(it)) } : {}), | ||
}, | ||
})); | ||
const View = (sql, { dependencies } = {}) => (0, extensions_1.extendEntity)(({ entity, registry }) => { | ||
const dependenciesResolved = typeof dependencies === 'function' ? dependencies() : dependencies; | ||
if (dependenciesResolved === null || dependenciesResolved === void 0 ? void 0 : dependenciesResolved.some(it => it === undefined)) { | ||
throw `"undefined" value detected in dependencies of view entity ${entity.name}. This is possibly caused by circular imports. | ||
Please wrap the array of dependencies into a function returning this array. | ||
Instead of: | ||
dependencies: [MyEntity] | ||
Use: | ||
dependencies: () => [MyEntity] | ||
`; | ||
} | ||
return ({ | ||
...entity, | ||
view: { | ||
sql, | ||
...(dependenciesResolved ? { dependencies: dependenciesResolved.map(it => registry.getName(it)) } : {}), | ||
}, | ||
}); | ||
}); | ||
exports.View = View; | ||
//# sourceMappingURL=ViewDefinition.js.map |
{ | ||
"name": "@contember/schema-definition", | ||
"version": "1.2.0-alpha.6", | ||
"version": "1.2.0-alpha.7", | ||
"license": "Apache-2.0", | ||
@@ -11,4 +11,4 @@ "main": "dist/src/index.js", | ||
"dependencies": { | ||
"@contember/schema": "^1.2.0-alpha.6", | ||
"@contember/schema-utils": "^1.2.0-alpha.6", | ||
"@contember/schema": "^1.2.0-alpha.7", | ||
"@contember/schema-utils": "^1.2.0-alpha.7", | ||
"reflect-metadata": "^0.1.13" | ||
@@ -15,0 +15,0 @@ }, |
import { extendEntity } from './extensions' | ||
import { EntityConstructor } from './types' | ||
export const View = (sql: string, { dependencies }: { dependencies?: EntityConstructor[] } = {}) => | ||
extendEntity(({ entity, registry }) => ({ | ||
...entity, | ||
view: { | ||
sql, | ||
...(dependencies ? { dependencies: dependencies?.map(it => registry.getName(it)) } : {}), | ||
}, | ||
})) | ||
export const View = (sql: string, { dependencies }: { dependencies?: (() => EntityConstructor[]) | EntityConstructor[] } = {}) => | ||
extendEntity(({ entity, registry }) => { | ||
const dependenciesResolved = typeof dependencies === 'function' ? dependencies() : dependencies | ||
if (dependenciesResolved?.some(it => it === undefined)) { | ||
throw `"undefined" value detected in dependencies of view entity ${entity.name}. This is possibly caused by circular imports. | ||
Please wrap the array of dependencies into a function returning this array. | ||
Instead of: | ||
dependencies: [MyEntity] | ||
Use: | ||
dependencies: () => [MyEntity] | ||
` | ||
} | ||
return ({ | ||
...entity, | ||
view: { | ||
sql, | ||
...(dependenciesResolved ? { dependencies: dependenciesResolved.map(it => registry.getName(it)) } : {}), | ||
}, | ||
}) | ||
}) |
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
524463
6949