@balena/sbvr-types
Advanced tools
Comparing version 3.5.0-web-resource-2-826282f7d61d0004e5edfd34565a90dd9b5096b0-1 to 4.0.0-4-x-99cdcc0b418c931c3a1c71109da12ed4c12e4c90-1
@@ -7,7 +7,13 @@ # Change Log | ||
# v3.5.0 | ||
## (2022-11-17) | ||
# v4.0.0 | ||
## (2022-11-25) | ||
* Create WebResource [Ramiro González Maciel] | ||
* Switch `Boolean` to use `BOOLEAN` db type instead of `INTEGER` [Pagan Gazzard] | ||
* Assert that JSON input typeof is object [Josh Bowling] | ||
# v3.4.15 | ||
## (2022-11-18) | ||
* Dev: Migrate husky setup for v8 [Josh Bowling] | ||
# v3.4.14 | ||
@@ -14,0 +20,0 @@ ## (2022-11-17) |
@@ -21,3 +21,2 @@ "use strict"; | ||
const Time = require("./types/time"); | ||
const WebResource = require("./types/web-resource"); | ||
module.exports = { | ||
@@ -43,4 +42,3 @@ 'Big Integer': BigInteger, | ||
Time, | ||
WebResource, | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -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 |
@@ -27,3 +27,3 @@ "use strict"; | ||
try { | ||
return Buffer.from(value, 'hex'); | ||
return new Buffer(value, 'hex'); | ||
} | ||
@@ -30,0 +30,0 @@ catch (e) { |
@@ -16,2 +16,5 @@ "use strict"; | ||
exports.validate = TypeUtils.validate.checkRequired((value) => { | ||
if (typeof value !== 'object') { | ||
throw new Error(`is not an object/array: ${typeof value}`); | ||
} | ||
try { | ||
@@ -18,0 +21,0 @@ return JSON.stringify(value); |
{ | ||
"name": "@balena/sbvr-types", | ||
"version": "3.5.0-web-resource-2-826282f7d61d0004e5edfd34565a90dd9b5096b0-1", | ||
"version": "4.0.0-4-x-99cdcc0b418c931c3a1c71109da12ed4c12e4c90-1", | ||
"description": "SBVR type definitions.", | ||
@@ -11,6 +11,5 @@ "main": "out", | ||
"test": "mocha", | ||
"test-web-resource": "mocha -g WebResource", | ||
"posttest": "npm run lint", | ||
"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" | ||
@@ -45,10 +44,5 @@ }, | ||
"require-npm4-to-publish": "^1.0.0", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.7.4" | ||
"ts-node": "^10.7.0", | ||
"typescript": "^4.6.3" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"lint-staged": { | ||
@@ -69,4 +63,4 @@ "*.ts": [ | ||
"versionist": { | ||
"publishedAt": "2022-11-17T23:42:15.850Z" | ||
"publishedAt": "2022-11-25T15:16:02.047Z" | ||
} | ||
} |
@@ -22,3 +22,2 @@ import type { SbvrType } from './type-utils'; | ||
import * as Time from './types/time'; | ||
import * as WebResource from './types/web-resource'; | ||
@@ -45,3 +44,2 @@ export = { | ||
Time, | ||
WebResource, | ||
} as { | ||
@@ -48,0 +46,0 @@ Hashed: SbvrType & { |
@@ -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; | ||
}); |
@@ -29,3 +29,3 @@ import * as TypeUtils from '../type-utils'; | ||
try { | ||
return Buffer.from(value, 'hex'); | ||
return new Buffer(value, 'hex'); | ||
} catch (e: any) { | ||
@@ -32,0 +32,0 @@ throw new Error(`could not be converted to binary: ${e.message}`); |
@@ -15,2 +15,7 @@ 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 { | ||
@@ -17,0 +22,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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
108029
93
1644