@mos-connection/model
Advanced tools
Comparing version 3.0.0-nightly-feat-mono-repo-20230104-080359-17f8d94.0 to 3.0.0-nightly-feat-mono-repo-20230127-144135-8037b58.0
@@ -6,2 +6,24 @@ # Change Log | ||
# [3.0.0-alpha.2](https://github.com/nrkno/sofie-mos-connection/compare/v3.0.0-alpha.0...v3.0.0-alpha.2) (2023-01-27) | ||
### Bug Fixes | ||
* add stringifyMosObject, an utility-function used to convert objects containing IMOSString128 etc to strings ([f3806ab](https://github.com/nrkno/sofie-mos-connection/commit/f3806ab4e72a02b450e91ab19fbbfca34c605caa)) | ||
# [3.0.0-alpha.1](https://github.com/nrkno/sofie-mos-connection/compare/v3.0.0-alpha.0...3.0.0-alpha.1) (2023-01-27) | ||
### Bug Fixes | ||
* add stringifyMosObject, an utility-function used to convert objects containing IMOSString128 etc to strings ([f3806ab](https://github.com/nrkno/sofie-mos-connection/commit/f3806ab4e72a02b450e91ab19fbbfca34c605caa)) | ||
# [v3.0.0-alpha.0](https://github.com/nrkno/sofie-mos-connection/compare/2.0.1...v3.0.0-alpha.0) (2022-12-09) | ||
@@ -8,0 +30,0 @@ |
@@ -22,2 +22,12 @@ import * as MosString128 from './mosTypes/mosString128'; | ||
} | ||
/** | ||
* If value is a MosType, stringify it. | ||
* Throw error otherwise | ||
*/ | ||
export declare function stringifyMosType(value: MosString128.IMOSString128 | MosDuration.IMOSDuration | MosTime.IMOSTime | any, mosTypes: MosTypes): { | ||
isMosType: true; | ||
stringValue: string; | ||
} | { | ||
isMosType: false; | ||
}; | ||
interface MosType<Serialized, Value, CreateValue> { | ||
@@ -24,0 +34,0 @@ /** Creates a MosType using provided data. The MosType is then used in data sent into MOS-connection */ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.IMOSScope = exports.getMosTypes = void 0; | ||
exports.IMOSScope = exports.stringifyMosType = exports.getMosTypes = void 0; | ||
const MosString128 = require("./mosTypes/mosString128"); | ||
@@ -24,2 +24,16 @@ const MosDuration = require("./mosTypes/mosDuration"); | ||
exports.getMosTypes = getMosTypes; | ||
/** | ||
* If value is a MosType, stringify it. | ||
* Throw error otherwise | ||
*/ | ||
function stringifyMosType(value, mosTypes) { | ||
if (mosTypes.mosTime.is(value)) | ||
return { isMosType: true, stringValue: mosTypes.mosTime.stringify(value) }; | ||
if (mosTypes.mosDuration.is(value)) | ||
return { isMosType: true, stringValue: mosTypes.mosDuration.stringify(value) }; | ||
if (mosTypes.mosString128.is(value)) | ||
return { isMosType: true, stringValue: mosTypes.mosString128.stringify(value) }; | ||
return { isMosType: false }; | ||
} | ||
exports.stringifyMosType = stringifyMosType; | ||
function getMosType(mosType, strict) { | ||
@@ -26,0 +40,0 @@ return { |
@@ -40,2 +40,4 @@ "use strict"; | ||
function stringify(mosDuration) { | ||
if (typeof mosDuration === 'string') | ||
return mosDuration; // helpful hack | ||
let s = mosDuration._mosDuration; | ||
@@ -42,0 +44,0 @@ const hh = Math.floor(s / 3600); |
@@ -47,5 +47,8 @@ "use strict"; | ||
} | ||
else { | ||
else if (timestamp?._mosTime !== undefined) { | ||
time = new Date(timestamp._mosTime); | ||
} | ||
else { | ||
throw new Error(`MosTime: Invalid input: "${timestamp}"`); | ||
} | ||
} | ||
@@ -83,2 +86,4 @@ else { | ||
function stringify(mosTime) { | ||
if (typeof mosTime === 'string') | ||
return mosTime; // helpful hack | ||
const localOffset = new Date(mosTime._mosTime).getTimezoneOffset(); | ||
@@ -159,6 +164,4 @@ // Cheat a little bit to get the time-zone right: | ||
let tzMinutes = m[3]; | ||
if (tzHours.length === 1) | ||
tzHours = '0' + tzHours; | ||
if (tzMinutes.length === 1) | ||
tzMinutes = '0' + tzMinutes; | ||
tzHours = (0, lib_1.pad)(tzHours, 2); | ||
tzMinutes = (0, lib_1.pad)(tzMinutes, 2); | ||
timezoneIndicator = tzSign + tzHours + ':' + tzMinutes; | ||
@@ -165,0 +168,0 @@ timezoneOffset = parseInt(tzSign + tzHours) * 60 + parseInt(tzMinutes); |
{ | ||
"name": "@mos-connection/model", | ||
"version": "3.0.0-nightly-feat-mono-repo-20230104-080359-17f8d94.0", | ||
"version": "3.0.0-nightly-feat-mono-repo-20230127-144135-8037b58.0", | ||
"description": "Types and enums for the mos-connection library", | ||
@@ -15,3 +15,3 @@ "main": "dist/index.js", | ||
"build": "rimraf dist && yarn build:main", | ||
"build:main": "tsc -p tsconfig.json", | ||
"build:main": "tsc -p tsconfig.build.json", | ||
"test": "jest", | ||
@@ -38,3 +38,3 @@ "precommit": "lint-staged" | ||
], | ||
"gitHead": "92b8ca52d6f1ff7e81bca91d28e8feb8e03631cc" | ||
"gitHead": "709499e01e974bd9dde79c0c0785137a06aaf917" | ||
} |
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
55391
781