@balena/sbvr-types
Advanced tools
Comparing version
@@ -8,6 +8,41 @@ # Change Log | ||
# v4.0.0 | ||
## (2022-11-12) | ||
## (2022-11-25) | ||
* Assert that JSON input typeof is object [Josh Bowling] | ||
* Switch `Boolean` to use `BOOLEAN` db type instead of `INTEGER` [Pagan Gazzard] | ||
# v3.4.15 | ||
## (2022-11-18) | ||
* Dev: Migrate husky setup for v8 [Josh Bowling] | ||
# v3.4.14 | ||
## (2022-11-17) | ||
* Update dependency mocha to 10.1.0 [Renovate Bot] | ||
# v3.4.13 | ||
## (2022-11-17) | ||
* Update dependency lint-staged to 13.0.3 [Renovate Bot] | ||
# v3.4.12 | ||
## (2022-11-17) | ||
* Update dependency husky to 8.0.2 [Renovate Bot] | ||
# v3.4.11 | ||
## (2022-11-17) | ||
* Dev: Add lint-fix npm script [Josh Bowling] | ||
# v3.4.10 | ||
## (2022-11-17) | ||
* Dev: Move type deps to dev [Josh Bowling] | ||
# v3.4.9 | ||
## (2022-11-17) | ||
* Add .npmrc [Josh Bowling] | ||
# v3.4.8 | ||
@@ -14,0 +49,0 @@ ## (2022-10-14) |
@@ -5,3 +5,3 @@ export interface DatabaseTypeFn { | ||
} | ||
export declare type DatabaseType = string | DatabaseTypeFn; | ||
export type DatabaseType = string | DatabaseTypeFn; | ||
export interface SbvrType { | ||
@@ -8,0 +8,0 @@ types: { |
@@ -12,5 +12,5 @@ import * as TypeUtils from '../type-utils'; | ||
export declare const validate: { | ||
(value: any, required: true): Promise<number>; | ||
(value: any, required: true): Promise<boolean>; | ||
(value: null | undefined, required: false): Promise<null>; | ||
<U>(value: U, required: boolean): Promise<number | null>; | ||
<U>(value: U, required: boolean): Promise<boolean | null>; | ||
}; |
@@ -5,4 +5,4 @@ "use strict"; | ||
const TypeUtils = require("../type-utils"); | ||
const typeFunc = (necessity, index, defaultValue = ' DEFAULT 0') => 'INTEGER' + defaultValue + necessity + index; | ||
typeFunc.castType = 'INTEGER'; | ||
const typeFunc = (necessity, index, defaultValue = ' DEFAULT FALSE') => 'BOOLEAN' + defaultValue + necessity + index; | ||
typeFunc.castType = 'BOOLEAN'; | ||
exports.types = { | ||
@@ -23,4 +23,4 @@ postgres: typeFunc, | ||
} | ||
return value; | ||
return value === 1; | ||
}); | ||
//# sourceMappingURL=boolean.js.map |
@@ -16,5 +16,2 @@ "use strict"; | ||
exports.validate = TypeUtils.validate.checkRequired((value) => { | ||
if (typeof value !== 'object') { | ||
throw new Error(`is not an object/array: ${typeof value}`); | ||
} | ||
try { | ||
@@ -21,0 +18,0 @@ return JSON.stringify(value); |
{ | ||
"name": "@balena/sbvr-types", | ||
"version": "4.0.0-joshbwlng-json-validation-ae0b834536e7d295bbd2dcc75c734a901fd6d352-1", | ||
"version": "4.0.0-true-boolean-3bb0e09429b25b36aa228f48135ce4b90ecf7abb-1", | ||
"description": "SBVR type definitions.", | ||
@@ -8,2 +8,3 @@ "main": "out", | ||
"lint": "balena-lint -e js -e ts src test && npx tsc --noEmit --project tsconfig.js.json", | ||
"lint-fix": "balena-lint --fix -e js -e ts src test", | ||
"pretest": "npm run prepare", | ||
@@ -13,3 +14,3 @@ "test": "mocha", | ||
"prepublish": "require-npm4-to-publish", | ||
"prepare": "tsc", | ||
"prepare": "node -e \"try { require('husky').install() } catch (e) {if (e.code !== 'MODULE_NOT_FOUND') throw e}\" && tsc", | ||
"prettify": "balena-lint -e js -e ts --fix src test" | ||
@@ -20,6 +21,3 @@ }, | ||
"license": "BSD", | ||
"dependencies": { | ||
"@types/bcrypt": "^5.0.0", | ||
"@types/sha.js": "^2.4.0" | ||
}, | ||
"dependencies": {}, | ||
"optionalDependencies": { | ||
@@ -32,2 +30,3 @@ "bcrypt": "^5.0.1", | ||
"@balena/lint": "^6.2.0", | ||
"@types/bcrypt": "^5.0.0", | ||
"@types/chai": "^4.3.0", | ||
@@ -37,3 +36,4 @@ "@types/chai-as-promised": "^7.1.5", | ||
"@types/lodash": "^4.14.181", | ||
"@types/mocha": "^9.1.0", | ||
"@types/mocha": "^10.0.0", | ||
"@types/sha.js": "^2.4.0", | ||
"bluebird": "^3.7.2", | ||
@@ -43,6 +43,6 @@ "chai": "^4.3.6", | ||
"chai-datetime": "^1.8.0", | ||
"husky": "^4.3.8", | ||
"lint-staged": "^12.3.7", | ||
"husky": "^8.0.0", | ||
"lint-staged": "^13.0.0", | ||
"lodash": "^4.17.21", | ||
"mocha": "^9.2.2", | ||
"mocha": "^10.0.0", | ||
"require-npm4-to-publish": "^1.0.0", | ||
@@ -52,7 +52,2 @@ "ts-node": "^10.7.0", | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"lint-staged": { | ||
@@ -73,4 +68,4 @@ "*.ts": [ | ||
"versionist": { | ||
"publishedAt": "2022-11-12T12:31:12.948Z" | ||
"publishedAt": "2022-11-25T13:51:58.208Z" | ||
} | ||
} |
@@ -6,5 +6,5 @@ import * as TypeUtils from '../type-utils'; | ||
index: string, | ||
defaultValue = ' DEFAULT 0', | ||
) => 'INTEGER' + defaultValue + necessity + index; | ||
typeFunc.castType = 'INTEGER'; | ||
defaultValue = ' DEFAULT FALSE', | ||
) => 'BOOLEAN' + defaultValue + necessity + index; | ||
typeFunc.castType = 'BOOLEAN'; | ||
@@ -20,3 +20,3 @@ export const types = { | ||
// Support both `1` from the "boolean" columns that are actually INTEGER types and `true` for truly boolean results | ||
// `BOOLEAN` on sqlite/websql is just an alias for `INTEGER` hence the `=== 1` check | ||
export const fetchProcessing = (data: any) => data === true || data === 1; | ||
@@ -34,3 +34,3 @@ | ||
} | ||
return value; | ||
return value === 1; | ||
}); |
@@ -15,7 +15,2 @@ import * as TypeUtils from '../type-utils'; | ||
export const validate = TypeUtils.validate.checkRequired((value) => { | ||
// Disallow primitives | ||
if (typeof value !== 'object') { | ||
throw new Error(`is not an object/array: ${typeof value}`); | ||
} | ||
try { | ||
@@ -22,0 +17,0 @@ return JSON.stringify(value); |
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
107100
2.66%3
-40%93
1.09%19
11.76%1637
-0.43%- Removed
- Removed
- Removed
- Removed
- Removed
- Removed