collimator
Advanced tools
Comparing version 3.1.0 to 4.0.0
@@ -113,5 +113,3 @@ | ||
Dcouments a single column according to JSON Schema semantics. A | ||
non-standard `readonly` property will be added to columns that use a default | ||
value generated by an expression, eg `now()` or `nextval()`. | ||
Dcouments a single column according to JSON Schema semantics. | ||
@@ -118,0 +116,0 @@ ### Params: |
@@ -5,2 +5,7 @@ # Change Log | ||
## 4.0.0 - 2015-11-20 | ||
* Use inline form of `export` syntax | ||
* Swap `belongsTo` and `has` queries as they were incorrect | ||
* Revert 'Implement 'readonly' column schema property' | ||
## 3.1.0 - 2015-11-07 | ||
@@ -7,0 +12,0 @@ * Implement 'readonly' column schema property |
@@ -6,2 +6,3 @@ 'use strict'; | ||
}); | ||
exports['default'] = collimator; | ||
@@ -47,2 +48,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
*/ | ||
function collimator(db) { | ||
@@ -62,3 +64,2 @@ var inspect = function inspect(table) { | ||
exports.relationships = _inspectorsRelationships2['default']; | ||
exports['default'] = collimator; | ||
//# sourceMappingURL=collimator.js.map |
@@ -6,2 +6,3 @@ 'use strict'; | ||
}); | ||
exports['default'] = relationships; | ||
@@ -39,2 +40,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
*/ | ||
function relationships(db, name) { | ||
@@ -49,4 +51,3 @@ var queries = { | ||
exports['default'] = relationships; | ||
module.exports = exports['default']; | ||
//# sourceMappingURL=../inspectors/relationships.js.map |
@@ -6,2 +6,7 @@ 'use strict'; | ||
}); | ||
exports['default'] = schema; | ||
exports.table = table; | ||
exports.properties = properties; | ||
exports.property = property; | ||
exports.required = required; | ||
@@ -29,2 +34,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
*/ | ||
function schema(db, name) { | ||
@@ -44,2 +50,3 @@ return (0, _utilFileQuery2['default'])(db, './schema.sql', { name: name }).then(function (columns) { | ||
*/ | ||
function table(name, columns) { | ||
@@ -63,2 +70,3 @@ return { | ||
*/ | ||
function properties(columns) { | ||
@@ -70,5 +78,3 @@ var columnProperties = (0, _ramda.map)(property, columns); | ||
/** | ||
* Dcouments a single column according to JSON Schema semantics. A | ||
* non-standard `readonly` property will be added to columns that use a default | ||
* value generated by an expression, eg `now()` or `nextval()`. | ||
* Dcouments a single column according to JSON Schema semantics. | ||
* | ||
@@ -79,2 +85,3 @@ * @function collimator.schema.property | ||
*/ | ||
function property(column) { | ||
@@ -102,11 +109,5 @@ var TYPES = { | ||
var schema = { | ||
return _defineProperty({}, column.name, { | ||
type: TYPES[column.type] | ||
}; | ||
if (column['default'] && column['default'].indexOf('(') > -1) { | ||
schema.readonly = true; | ||
} | ||
return _defineProperty({}, column.name, schema); | ||
}); | ||
} | ||
@@ -122,2 +123,3 @@ | ||
*/ | ||
function required(columns) { | ||
@@ -131,8 +133,2 @@ var isRequired = function isRequired(column) { | ||
} | ||
exports['default'] = schema; | ||
exports.table = table; | ||
exports.property = property; | ||
exports.properties = properties; | ||
exports.required = required; | ||
//# sourceMappingURL=../inspectors/schema.js.map |
@@ -6,2 +6,3 @@ 'use strict'; | ||
}); | ||
exports['default'] = tables; | ||
@@ -29,2 +30,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
*/ | ||
function tables(db) { | ||
@@ -34,4 +36,3 @@ return (0, _utilFileQuery2['default'])(db, './tables.sql'); | ||
exports['default'] = tables; | ||
module.exports = exports['default']; | ||
//# sourceMappingURL=../inspectors/tables.js.map |
@@ -6,2 +6,3 @@ 'use strict'; | ||
}); | ||
exports['default'] = fileQuery; | ||
@@ -36,5 +37,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
} | ||
exports['default'] = fileQuery; | ||
module.exports = exports['default']; | ||
//# sourceMappingURL=../util/fileQuery.js.map |
{ | ||
"name": "collimator", | ||
"version": "3.1.0", | ||
"version": "4.0.0", | ||
"description": "Reflection & Introspection for PostgreSQL Databases", | ||
@@ -5,0 +5,0 @@ "main": "lib/collimator.js", |
@@ -11,4 +11,3 @@ import schema from '../../src/inspectors/schema'; | ||
{name: 'age', nullable: false, default: 30, type: 'smallint'}, | ||
{name: 'gender', nullable: true, default: null, type: 'character'}, | ||
{name: 'created', nullable: false, default: 'now()', type: 'timestamp without time zone'} | ||
{name: 'gender', nullable: true, default: null, type: 'character'} | ||
]; | ||
@@ -78,3 +77,3 @@ | ||
var result = property(columns[0]); | ||
expect(result).toEqual({ | ||
@@ -86,13 +85,2 @@ forename: { | ||
}); | ||
it('sets `readonly` to `true` when default value contains an expression', () => { | ||
var result = property(columns[4]); | ||
expect(result).toEqual({ | ||
created: { | ||
type: 'string', | ||
readonly: true | ||
} | ||
}); | ||
}); | ||
}); | ||
@@ -99,0 +87,0 @@ |
@@ -27,3 +27,3 @@ import bluebird from 'bluebird'; | ||
*/ | ||
function collimator(db) { | ||
export default function collimator(db) { | ||
const inspect = table => bluebird.props(merge(table, { | ||
@@ -38,2 +38,1 @@ schema: schema(db, table.name), | ||
export {tables, schema, relationships}; | ||
export default collimator; |
@@ -25,3 +25,3 @@ import bluebird from 'bluebird'; | ||
*/ | ||
function relationships(db, name) { | ||
export default function relationships(db, name) { | ||
var queries = { | ||
@@ -34,3 +34,1 @@ belongsTo: query(db, './relationships/belongsTo.sql', {name}), | ||
} | ||
export default relationships; |
@@ -15,3 +15,3 @@ import query from '../util/fileQuery'; | ||
*/ | ||
function schema(db, name) { | ||
export default function schema(db, name) { | ||
return query(db, './schema.sql', {name: name}) | ||
@@ -29,3 +29,3 @@ .then(columns => table(name, columns)); | ||
*/ | ||
function table(name, columns) { | ||
export function table(name, columns) { | ||
return { | ||
@@ -48,3 +48,3 @@ $schema: 'http://json-schema.org/draft-04/schema#', | ||
*/ | ||
function properties(columns) { | ||
export function properties(columns) { | ||
var columnProperties = map(property, columns); | ||
@@ -55,5 +55,3 @@ return mergeAll(columnProperties); | ||
/** | ||
* Dcouments a single column according to JSON Schema semantics. A | ||
* non-standard `readonly` property will be added to columns that use a default | ||
* value generated by an expression, eg `now()` or `nextval()`. | ||
* Dcouments a single column according to JSON Schema semantics. | ||
* | ||
@@ -64,3 +62,3 @@ * @function collimator.schema.property | ||
*/ | ||
function property(column) { | ||
export function property(column) { | ||
const TYPES = { | ||
@@ -87,12 +85,6 @@ bigserial: 'integer', | ||
var schema = { | ||
type: TYPES[column.type] | ||
}; | ||
if (column.default && column.default.indexOf('(') > -1) { | ||
schema.readonly = true; | ||
} | ||
return { | ||
[column.name]: schema | ||
[column.name]: { | ||
type: TYPES[column.type] | ||
} | ||
}; | ||
@@ -109,3 +101,3 @@ } | ||
*/ | ||
function required(columns) { | ||
export function required(columns) { | ||
const isRequired = column => | ||
@@ -117,4 +109,1 @@ column.nullable === false && column.default === null; | ||
} | ||
export default schema; | ||
export {table, property, properties, required}; |
@@ -18,6 +18,4 @@ import query from '../util/fileQuery'; | ||
*/ | ||
function tables(db) { | ||
export default function tables(db) { | ||
return query(db, './tables.sql'); | ||
} | ||
export default tables; |
@@ -10,3 +10,3 @@ 'use strict'; | ||
function fileQuery(db, file, params, resultMask) { | ||
export default function fileQuery(db, file, params, resultMask) { | ||
var path = resolvePath(file); | ||
@@ -24,3 +24,1 @@ resultMask = resultMask || global.queryResult.manyOrNone; | ||
} | ||
export default fileQuery; |
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
54262
50
756