Socket
Socket
Sign inDemoInstall

@shapediver/sdk.sdtf-primitives

Package Overview
Dependencies
2
Maintainers
5
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.2 to 1.3.0

2

dist/ISdtfPrimitiveTypes.d.ts
/** Represents an RGBA color (red, green, blue, alpha) with values between `0` and `1`. */
export type SdtfPrimitiveColorType = [number, number, number, number];
/** Represents a JSON object with arbitrary data. */
export type SdtfPrimitiveJsonType = Record<string, unknown> | Array<unknown>;
//# sourceMappingURL=ISdtfPrimitiveTypes.d.ts.map
import { SdtfPrimitiveTypeHintName } from "@shapediver/sdk.sdtf-core";
import { SdtfPrimitiveColorType } from "./ISdtfPrimitiveTypes";
import { SdtfPrimitiveColorType, SdtfPrimitiveJsonType } from "./ISdtfPrimitiveTypes";
export declare class SdtfPrimitiveTypeGuard {

@@ -109,3 +109,12 @@ /**

static isDataViewType(typeHint: string | undefined): typeHint is SdtfPrimitiveTypeHintName.DATA | SdtfPrimitiveTypeHintName.IMAGE;
/**
* Runtime check that raises an error when the given value is not of type `SdtfPrimitiveTypeHintName.JSON`.
* @throws {@link SdtfError} when the invariant is not met.
*/
static assertJson(value: unknown): asserts value is SdtfPrimitiveJsonType;
/** Returns `true` when the given value is of type `SdtfPrimitiveTypeHintName.JSON`. */
static isJson(value: unknown): value is SdtfPrimitiveJsonType;
/** Returns `true` when the given type hint name is of type `SdtfPrimitiveTypeHintName.JSON`. */
static isJsonType(typeHint: string | undefined): typeHint is SdtfPrimitiveTypeHintName.JSON;
}
//# sourceMappingURL=SdtfPrimitiveTypeGuard.d.ts.map

@@ -165,4 +165,20 @@ "use strict";

}
/**
* Runtime check that raises an error when the given value is not of type `SdtfPrimitiveTypeHintName.JSON`.
* @throws {@link SdtfError} when the invariant is not met.
*/
static assertJson(value) {
if (!this.isJson(value))
throw new sdk_sdtf_core_1.SdtfError("Assertion error: Value is not a primitive json type.");
}
/** Returns `true` when the given value is of type `SdtfPrimitiveTypeHintName.JSON`. */
static isJson(value) {
return (0, sdk_sdtf_core_1.isDataObject)(value) || Array.isArray(value);
}
/** Returns `true` when the given type hint name is of type `SdtfPrimitiveTypeHintName.JSON`. */
static isJsonType(typeHint) {
return typeHint === sdk_sdtf_core_1.SdtfPrimitiveTypeHintName.JSON;
}
}
exports.SdtfPrimitiveTypeGuard = SdtfPrimitiveTypeGuard;
//# sourceMappingURL=SdtfPrimitiveTypeGuard.js.map

@@ -38,2 +38,3 @@ "use strict";

case sdk_sdtf_core_1.SdtfPrimitiveTypeHintName.INT64:
case sdk_sdtf_core_1.SdtfPrimitiveTypeHintName.JSON:
case sdk_sdtf_core_1.SdtfPrimitiveTypeHintName.SINGLE:

@@ -40,0 +41,0 @@ case sdk_sdtf_core_1.SdtfPrimitiveTypeHintName.STRING:

18

dist/SdtfPrimitiveTypeValidator.d.ts

@@ -10,18 +10,12 @@ import { ISdtfReadableAccessor, ISdtfWriteableAccessor, SdtfPrimitiveTypeHintName } from "@shapediver/sdk.sdtf-core";

validateComponent(typeHint: SdtfPrimitiveTypeHintName, value?: unknown, accessor?: ISdtfReadableAccessor | ISdtfWriteableAccessor): boolean;
/** Returns `true` when the given value is a valid `SdtfPrimitiveTypeHintName.BOOLEAN` type, otherwise `false`. */
static validateBooleanType(value: unknown): value is boolean;
/** Returns `true` when the given value is a valid `SdtfPrimitiveTypeHintName.CHAR` type, otherwise `false`. */
static validateCharType(value: unknown): value is string;
/** Returns `true` when the given value is a valid `SdtfPrimitiveTypeHintName.COLOR` type. */
static validateColorType(value: unknown): value is SdtfPrimitiveColorType | string;
/**
* Returns `true` when the given value is a valid `SdtfPrimitiveTypeHintName.DECIMAL` type, otherwise `false`.
* Returns `true` when the given value is a valid `SdtfPrimitiveTypeHintName.COLOR` type.
*
* WARNING:
* JavaScript floating-point numbers have a maximum precision of 17, while .Net decimals have a precision of 29.
* Thus, JavaScript automatically rounds them to a precision of 17.
* NOTE:
* The validator excepts both color types, regular (4 parts) and legacy (3 parts). However, a
* legacy color is later on mapped to a regular color structure.
*/
static validateDecimalType(value: unknown): value is number;
/** Returns `true` when the given value is a valid `SdtfPrimitiveTypeHintName.DOUBLE` type, otherwise `false`. */
static validateDoubleType(value: unknown): value is number;
static validateColorType(value: unknown): value is SdtfPrimitiveColorType | string;
/** Returns `true` when the given value is a valid `SdtfPrimitiveTypeHintName.GUID` type, otherwise `false`. */

@@ -45,4 +39,2 @@ static validateGuidType(value: unknown): value is string;

static validateSingleType(value: unknown): value is number;
/** Returns `true` when the given value is a valid `SdtfPrimitiveTypeHintName.STRING` type, otherwise `false`. */
static validateStringType(value: unknown): value is string;
/** Returns `true` when the given value is a valid `SdtfPrimitiveTypeHintName.UINT8` type, otherwise `false`. */

@@ -49,0 +41,0 @@ static validateUint8Type(value: unknown): value is number;

@@ -6,2 +6,3 @@ "use strict";

const decimal_js_1 = require("decimal.js");
const SdtfPrimitiveTypeGuard_1 = require("./SdtfPrimitiveTypeGuard");
const UUIDv4_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;

@@ -19,3 +20,3 @@ const SINGLE_MAX = new decimal_js_1.Decimal(3.40282347E+38);

case sdk_sdtf_core_1.SdtfPrimitiveTypeHintName.BOOLEAN:
return SdtfPrimitiveTypeValidator.validateBooleanType(value);
return SdtfPrimitiveTypeGuard_1.SdtfPrimitiveTypeGuard.isBoolean(value);
case sdk_sdtf_core_1.SdtfPrimitiveTypeHintName.CHAR:

@@ -28,5 +29,5 @@ return SdtfPrimitiveTypeValidator.validateCharType(value);

case sdk_sdtf_core_1.SdtfPrimitiveTypeHintName.DECIMAL:
return SdtfPrimitiveTypeValidator.validateDecimalType(value);
return SdtfPrimitiveTypeGuard_1.SdtfPrimitiveTypeGuard.isNumber(value);
case sdk_sdtf_core_1.SdtfPrimitiveTypeHintName.DOUBLE:
return SdtfPrimitiveTypeValidator.validateDoubleType(value);
return SdtfPrimitiveTypeGuard_1.SdtfPrimitiveTypeGuard.isNumber(value);
case sdk_sdtf_core_1.SdtfPrimitiveTypeHintName.GUID:

@@ -44,6 +45,8 @@ return SdtfPrimitiveTypeValidator.validateGuidType(value);

return SdtfPrimitiveTypeValidator.validateInt64Type(value);
case sdk_sdtf_core_1.SdtfPrimitiveTypeHintName.JSON:
return SdtfPrimitiveTypeGuard_1.SdtfPrimitiveTypeGuard.isJson(value);
case sdk_sdtf_core_1.SdtfPrimitiveTypeHintName.SINGLE:
return SdtfPrimitiveTypeValidator.validateSingleType(value);
case sdk_sdtf_core_1.SdtfPrimitiveTypeHintName.STRING:
return SdtfPrimitiveTypeValidator.validateStringType(value);
return SdtfPrimitiveTypeGuard_1.SdtfPrimitiveTypeGuard.isString(value);
case sdk_sdtf_core_1.SdtfPrimitiveTypeHintName.UINT8:

@@ -61,11 +64,13 @@ return SdtfPrimitiveTypeValidator.validateUint8Type(value);

}
/** Returns `true` when the given value is a valid `SdtfPrimitiveTypeHintName.BOOLEAN` type, otherwise `false`. */
static validateBooleanType(value) {
return typeof value === "boolean";
}
/** Returns `true` when the given value is a valid `SdtfPrimitiveTypeHintName.CHAR` type, otherwise `false`. */
static validateCharType(value) {
return typeof value === "string" && value.length === 1;
return SdtfPrimitiveTypeGuard_1.SdtfPrimitiveTypeGuard.isString(value) && value.length === 1;
}
/** Returns `true` when the given value is a valid `SdtfPrimitiveTypeHintName.COLOR` type. */
/**
* Returns `true` when the given value is a valid `SdtfPrimitiveTypeHintName.COLOR` type.
*
* NOTE:
* The validator excepts both color types, regular (4 parts) and legacy (3 parts). However, a
* legacy color is later on mapped to a regular color structure.
*/
static validateColorType(value) {

@@ -81,19 +86,5 @@ // Validate color array

}
/**
* Returns `true` when the given value is a valid `SdtfPrimitiveTypeHintName.DECIMAL` type, otherwise `false`.
*
* WARNING:
* JavaScript floating-point numbers have a maximum precision of 17, while .Net decimals have a precision of 29.
* Thus, JavaScript automatically rounds them to a precision of 17.
*/
static validateDecimalType(value) {
return (0, sdk_sdtf_core_1.isNumber)(value);
}
/** Returns `true` when the given value is a valid `SdtfPrimitiveTypeHintName.DOUBLE` type, otherwise `false`. */
static validateDoubleType(value) {
return (0, sdk_sdtf_core_1.isNumber)(value);
}
/** Returns `true` when the given value is a valid `SdtfPrimitiveTypeHintName.GUID` type, otherwise `false`. */
static validateGuidType(value) {
return typeof value === "string" && UUIDv4_REGEX.test(value);
return SdtfPrimitiveTypeGuard_1.SdtfPrimitiveTypeGuard.isString(value) && UUIDv4_REGEX.test(value);
}

@@ -131,6 +122,2 @@ /** Returns `true` when the given value is a valid `SdtfPrimitiveTypeHintName.INT8` type, otherwise `false`. */

}
/** Returns `true` when the given value is a valid `SdtfPrimitiveTypeHintName.STRING` type, otherwise `false`. */
static validateStringType(value) {
return typeof value === "string";
}
/** Returns `true` when the given value is a valid `SdtfPrimitiveTypeHintName.UINT8` type, otherwise `false`. */

@@ -137,0 +124,0 @@ static validateUint8Type(value) {

@@ -25,2 +25,3 @@ "use strict";

case sdk_sdtf_core_1.SdtfPrimitiveTypeHintName.INT64:
case sdk_sdtf_core_1.SdtfPrimitiveTypeHintName.JSON:
case sdk_sdtf_core_1.SdtfPrimitiveTypeHintName.SINGLE:

@@ -27,0 +28,0 @@ case sdk_sdtf_core_1.SdtfPrimitiveTypeHintName.STRING:

{
"name": "@shapediver/sdk.sdtf-primitives",
"version": "1.2.2",
"version": "1.3.0",
"description": "Extension containing sdTF primitive types",

@@ -41,10 +41,10 @@ "keywords": [

"dependencies": {
"@shapediver/sdk.sdtf-core": "~1.2.2",
"@shapediver/sdk.sdtf-core": "~1.3.0",
"decimal.js": "~10.4.3"
},
"devDependencies": {
"jest": "~29.4.1",
"lerna": "~6.4.1",
"jest": "~29.5.0",
"lerna": "~6.6.0",
"typescript": "~4.9.5"
}
}

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc