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

@balena/sbvr-types

Package Overview
Dependencies
Maintainers
3
Versions
222
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@balena/sbvr-types - npm Package Compare versions

Comparing version 7.1.0 to 8.0.0-build-joshbwlng-big-int-61d5878590d3d28961eff4130e322e5e89293bb5-1

7

CHANGELOG.md

@@ -7,4 +7,9 @@ # Change Log

# v8.0.0
## (2024-05-08)
* Improve BigInteger and BigSerial support [Josh Bowling]
# v7.1.0
## (2024-04-17)
## (2024-04-25)

@@ -11,0 +16,0 @@ * Export typescript read/write types for each sbvr type [Pagan Gazzard]

@@ -50,2 +50,7 @@ export interface DatabaseTypeFn {

};
bigint: {
(value: unknown, required: true): Promise<bigint>;
(value: undefined | null, required: false): Promise<null>;
(value: unknown, required: boolean): Promise<bigint | null>;
};
text: (length?: number) => {

@@ -52,0 +57,0 @@ (value: unknown, required: true): Promise<string>;

@@ -40,2 +40,8 @@ "use strict";

}),
bigint: checkRequired((value) => {
if (value === '') {
throw new Error('Cannot convert empty string to a BigInt');
}
return BigInt(value);
}),
text: (length) => checkRequired((value) => {

@@ -42,0 +48,0 @@ if (typeof value !== 'string') {

5

out/types/big-integer.d.ts

@@ -10,4 +10,5 @@ import * as TypeUtils from '../type-utils';

};
export type Types = TypeUtils.TsTypes<number, number>;
type DbWriteType = number;
export type Types = TypeUtils.TsTypes<bigint, bigint>;
type DbWriteType = bigint;
export declare const fetchProcessing: TypeUtils.FetchProcessing<Types['Read']>;
export declare const nativeFactTypes: {

@@ -14,0 +15,0 @@ Integer: {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validate = exports.nativeFactTypes = exports.types = void 0;
exports.validate = exports.nativeFactTypes = exports.fetchProcessing = exports.types = void 0;
const TypeUtils = require("../type-utils");

@@ -13,2 +13,15 @@ exports.types = {

};
const fetchProcessing = (data) => {
if (data == null) {
return data;
}
if (typeof data === 'bigint') {
return data;
}
else if (typeof data === 'string' || typeof data === 'number') {
return BigInt(data);
}
throw new Error('Fetched bigint is not valid: ' + typeof data);
};
exports.fetchProcessing = fetchProcessing;
exports.nativeFactTypes = {

@@ -18,3 +31,3 @@ Integer: TypeUtils.nativeFactTypeTemplates.comparison,

};
exports.validate = TypeUtils.validate.integer;
exports.validate = TypeUtils.validate.bigint;
//# sourceMappingURL=big-integer.js.map
import * as TypeUtils from '../type-utils';
export { fetchProcessing } from './big-integer';
export declare const types: {

@@ -10,5 +11,4 @@ postgres: string;

};
export type Types = TypeUtils.TsTypes<number, number>;
type DbWriteType = number;
export type Types = TypeUtils.TsTypes<bigint, bigint>;
type DbWriteType = bigint;
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validate = exports.types = void 0;
exports.validate = exports.types = exports.fetchProcessing = void 0;
const TypeUtils = require("../type-utils");
var big_integer_1 = require("./big-integer");
Object.defineProperty(exports, "fetchProcessing", { enumerable: true, get: function () { return big_integer_1.fetchProcessing; } });
const mysqlType = (necessity, index, defaultValue = '') => 'BIGINT' + defaultValue + necessity + index + ' AUTO_INCREMENT';

@@ -17,3 +19,3 @@ mysqlType.castType = 'BIGINT';

};
exports.validate = TypeUtils.validate.integer;
exports.validate = TypeUtils.validate.bigint;
//# sourceMappingURL=big-serial.js.map
{
"name": "@balena/sbvr-types",
"version": "7.1.0",
"version": "8.0.0-build-joshbwlng-big-int-61d5878590d3d28961eff4130e322e5e89293bb5-1",
"description": "SBVR type definitions.",

@@ -54,4 +54,4 @@ "main": "out",

"versionist": {
"publishedAt": "2024-04-17T17:17:22.131Z"
"publishedAt": "2024-05-08T04:55:58.589Z"
}
}

@@ -75,2 +75,8 @@ export interface DatabaseTypeFn {

}),
bigint: checkRequired((value) => {
if (value === '') {
throw new Error('Cannot convert empty string to a BigInt');
}
return BigInt(value);
}),
text: (length?: number) =>

@@ -77,0 +83,0 @@ checkRequired((value) => {

@@ -12,5 +12,21 @@ import * as TypeUtils from '../type-utils';

export type Types = TypeUtils.TsTypes<number, number>;
type DbWriteType = number;
export type Types = TypeUtils.TsTypes<bigint, bigint>;
type DbWriteType = bigint;
export const fetchProcessing: TypeUtils.FetchProcessing<Types['Read']> = (
data,
) => {
if (data == null) {
return data;
}
if (typeof data === 'bigint') {
return data;
} else if (typeof data === 'string' || typeof data === 'number') {
return BigInt(data);
}
throw new Error('Fetched bigint is not valid: ' + typeof data);
};
export const nativeFactTypes = {

@@ -22,2 +38,2 @@ Integer: TypeUtils.nativeFactTypeTemplates.comparison,

export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> =
TypeUtils.validate.integer;
TypeUtils.validate.bigint;
import * as TypeUtils from '../type-utils';
export { fetchProcessing } from './big-integer';

@@ -26,6 +27,6 @@ const mysqlType: TypeUtils.DatabaseTypeFn = (

export type Types = TypeUtils.TsTypes<number, number>;
type DbWriteType = number;
export type Types = TypeUtils.TsTypes<bigint, bigint>;
type DbWriteType = bigint;
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> =
TypeUtils.validate.integer;
TypeUtils.validate.bigint;

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