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.0.2 to 7.0.3-build-fetch-processing-typings-42ccd8c43d1916618531ec75b463a06d3df2536f-1

5

CHANGELOG.md

@@ -7,2 +7,7 @@ # Change Log

# v7.0.3
## (2024-03-12)
* Improve fetchProcessing typings [Pagan Gazzard]
# v7.0.2

@@ -9,0 +14,0 @@ ## (2024-03-12)

5

out/type-utils.d.ts

@@ -6,3 +6,3 @@ export interface DatabaseTypeFn {

export type DatabaseType = string | DatabaseTypeFn;
export interface SbvrType {
export interface SbvrType<Read = unknown> {
types: {

@@ -17,5 +17,6 @@ odata: {

};
fetchProcessing?: (field: any) => any;
fetchProcessing?: FetchProcessing<Read>;
validate: (value: any, required: boolean) => Promise<any>;
}
export type FetchProcessing<Read> = (data: unknown) => Read | null | undefined;
export declare const nativeFactTypeTemplates: {

@@ -22,0 +23,0 @@ equality: {

4

out/types/boolean.d.ts

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

};
export declare const fetchProcessing: (data: any) => boolean;
type ReadType = boolean;
export declare const fetchProcessing: TypeUtils.FetchProcessing<ReadType>;
export declare const validate: {

@@ -17,1 +18,2 @@ (value: any, required: true): Promise<boolean>;

};
export {};

@@ -0,1 +1,2 @@

import * as TypeUtils from '../type-utils';
export declare const types: {

@@ -10,2 +11,8 @@ postgres: string;

};
type ReadType = {
r: number;
g: number;
b: number;
a: number;
};
export declare const nativeProperties: {

@@ -19,8 +26,3 @@ has: {

};
export declare const fetchProcessing: (data: number) => {
r: number;
g: number;
b: number;
a: number;
};
export declare const fetchProcessing: TypeUtils.FetchProcessing<ReadType>;
export declare const validate: {

@@ -31,1 +33,2 @@ (value: any, required: true): Promise<number>;

};
export {};

@@ -41,2 +41,5 @@ "use strict";

const fetchProcessing = (data) => {
if (typeof data !== 'number') {
throw new Error('Fetched color is not an integer: ' + typeof data);
}
return {

@@ -43,0 +46,0 @@ r: (data >> 16) & 0xff,

@@ -0,1 +1,2 @@

import * as TypeUtils from '../type-utils';
export declare const types: {

@@ -9,3 +10,4 @@ postgres: string;

};
export declare const fetchProcessing: (data: any) => any;
type ReadType = string;
export declare const fetchProcessing: TypeUtils.FetchProcessing<ReadType>;
export declare const nativeFactTypes: {

@@ -25,1 +27,2 @@ 'Date Time': {

};
export {};

@@ -17,6 +17,13 @@ "use strict";

}
if (!(data instanceof Date)) {
data = new Date(data);
let date;
if (data instanceof Date) {
date = data;
}
return data.toISOString();
else if (typeof data === 'string' || typeof data === 'number') {
date = new Date(data);
}
else {
throw new Error('Fetched date time is not valid: ' + typeof data);
}
return date.toISOString();
};

@@ -23,0 +30,0 @@ exports.fetchProcessing = fetchProcessing;

@@ -0,1 +1,2 @@

import * as TypeUtils from '../type-utils';
export declare const types: {

@@ -9,3 +10,4 @@ postgres: string;

};
export declare const fetchProcessing: (data: any) => any;
type ReadType = string;
export declare const fetchProcessing: TypeUtils.FetchProcessing<ReadType>;
export declare const nativeFactTypes: {

@@ -22,1 +24,2 @@ Date: {

};
export {};

@@ -17,6 +17,13 @@ "use strict";

}
if (!(data instanceof Date)) {
data = new Date(data);
let date;
if (data instanceof Date) {
date = data;
}
return data.toISOString();
else if (typeof data === 'string' || typeof data === 'number') {
date = new Date(data);
}
else {
throw new Error('Fetched date is not valid: ' + typeof data);
}
return date.toISOString();
};

@@ -23,0 +30,0 @@ exports.fetchProcessing = fetchProcessing;

@@ -0,1 +1,2 @@

import * as TypeUtils from '../type-utils';
export declare const types: {

@@ -9,3 +10,4 @@ postgres: string;

};
export declare const fetchProcessing: (data: any) => any;
type ReadType = Record<string, any> | any[];
export declare const fetchProcessing: TypeUtils.FetchProcessing<ReadType>;
export declare const validate: {

@@ -16,1 +18,2 @@ (value: any, required: true): Promise<string>;

};
export {};

@@ -0,1 +1,2 @@

import * as TypeUtils from '../type-utils';
export declare const types: {

@@ -9,3 +10,5 @@ postgres: string;

};
export declare const fetchProcessing: (data: any) => any;
type ReadType = string;
export declare const fetchProcessing: TypeUtils.FetchProcessing<ReadType>;
export declare const validate: (value: any, required: boolean) => Promise<string | null>;
export {};

@@ -0,1 +1,2 @@

import * as TypeUtils from '../type-utils';
import type { CastNode, ExtractJSONPathAsTextNode, ReferencedFieldNode } from '@balena/abstract-sql-compiler';

@@ -19,2 +20,3 @@ export type WebResource = {

};
type ReadType = WebResource;
export declare const nativeProperties: {

@@ -30,3 +32,3 @@ has: {

};
export declare const fetchProcessing: (data: any) => any;
export declare const fetchProcessing: TypeUtils.FetchProcessing<ReadType>;
export declare const validate: {

@@ -37,1 +39,2 @@ (value: any, required: true): Promise<Promise<string>>;

};
export {};
{
"name": "@balena/sbvr-types",
"version": "7.0.2",
"version": "7.0.3-build-fetch-processing-typings-42ccd8c43d1916618531ec75b463a06d3df2536f-1",
"description": "SBVR type definitions.",

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

"versionist": {
"publishedAt": "2024-03-12T12:48:05.947Z"
"publishedAt": "2024-03-12T15:44:44.857Z"
}
}

@@ -6,3 +6,3 @@ export interface DatabaseTypeFn {

export type DatabaseType = string | DatabaseTypeFn;
export interface SbvrType {
export interface SbvrType<Read = unknown> {
types: {

@@ -17,6 +17,8 @@ odata: {

};
fetchProcessing?: (field: any) => any;
fetchProcessing?: FetchProcessing<Read>;
validate: (value: any, required: boolean) => Promise<any>;
}
export type FetchProcessing<Read> = (data: unknown) => Read | null | undefined;
const checkRequired = <T>(validateFn: (value: any) => T) => {

@@ -23,0 +25,0 @@ function runCheck(value: any, required: true): Promise<T>;

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

type ReadType = boolean;
// `BOOLEAN` on sqlite/websql is just an alias for `INTEGER` hence the `=== 1` check
export const fetchProcessing = (data: any) => data === true || data === 1;
export const fetchProcessing: TypeUtils.FetchProcessing<ReadType> = (data) =>
data === true || data === 1;

@@ -23,0 +26,0 @@ export const validate = TypeUtils.validate.checkRequired((originalValue) => {

@@ -19,2 +19,9 @@ import * as TypeUtils from '../type-utils';

type ReadType = {
r: number;
g: number;
b: number;
a: number;
};
export const nativeProperties = {

@@ -41,3 +48,6 @@ has: {

export const fetchProcessing = (data: number) => {
export const fetchProcessing: TypeUtils.FetchProcessing<ReadType> = (data) => {
if (typeof data !== 'number') {
throw new Error('Fetched color is not an integer: ' + typeof data);
}
/* eslint-disable no-bitwise */

@@ -44,0 +54,0 @@ return {

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

export const fetchProcessing = (data: any) => {
type ReadType = string;
export const fetchProcessing: TypeUtils.FetchProcessing<ReadType> = (data) => {
if (data == null) {
return data;
}
if (!(data instanceof Date)) {
data = new Date(data);
let date: Date;
if (data instanceof Date) {
date = data;
} else if (typeof data === 'string' || typeof data === 'number') {
date = new Date(data);
} else {
throw new Error('Fetched date time is not valid: ' + typeof data);
}
return data.toISOString();
return date.toISOString();
};

@@ -22,0 +29,0 @@

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

export const fetchProcessing = (data: any) => {
type ReadType = string;
export const fetchProcessing: TypeUtils.FetchProcessing<ReadType> = (data) => {
if (data == null) {
return data;
}
if (!(data instanceof Date)) {
data = new Date(data);
let date: Date;
if (data instanceof Date) {
date = data;
} else if (typeof data === 'string' || typeof data === 'number') {
date = new Date(data);
} else {
throw new Error('Fetched date is not valid: ' + typeof data);
}
return data.toISOString();
return date.toISOString();
};

@@ -22,0 +29,0 @@

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

export const fetchProcessing = (data: any) => {
type ReadType = Record<string, any> | any[];
export const fetchProcessing: TypeUtils.FetchProcessing<ReadType> = (data) => {
if (typeof data === 'string') {

@@ -15,0 +17,0 @@ return JSON.parse(data);

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

export const fetchProcessing = (data: any) => {
type ReadType = string;
export const fetchProcessing: TypeUtils.FetchProcessing<ReadType> = (data) => {
if (data != null) {

@@ -15,0 +17,0 @@ // We append the date of the epoch so that we can parse this as a valid date.

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

type ReadType = WebResource;
export const nativeProperties = {

@@ -90,3 +92,3 @@ has: {

*/
export const fetchProcessing = (data: any) => {
export const fetchProcessing: TypeUtils.FetchProcessing<ReadType> = (data) => {
let refData: WebResource;

@@ -103,3 +105,3 @@ if (data === null) {

} else if (typeof data === 'object') {
refData = data;
refData = data as WebResource;
} else {

@@ -106,0 +108,0 @@ throw new Error(`can't be read from stored value ${typeof data}`);

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

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