@balena/sbvr-types
Advanced tools
Comparing version 3.6.0-build-web-resource-2-a73950a1595475215ad58ec00ff79999e8da9cf6-1 to 3.6.0-build-web-resource-2-fba329fc6ffc4287fa49fb4cd90aec08fa9bf86a-1
@@ -8,3 +8,3 @@ # Change Log | ||
# v3.6.0 | ||
## (2023-03-29) | ||
## (2023-04-24) | ||
@@ -11,0 +11,0 @@ * Adds WebResource type [Otávio Jacobi] |
@@ -0,1 +1,2 @@ | ||
import type { CastNode, ExtractJSONPathAsTextNode, JSONTypeNodes } from '@balena/abstract-sql-compiler'; | ||
export type WebResource = { | ||
@@ -19,7 +20,7 @@ filename: string; | ||
has: { | ||
Filename: (stringifiedResource: string) => (string | (string | string[])[])[]; | ||
HRef: (stringifiedResource: string) => (string | (string | string[])[])[]; | ||
'Content Type': (stringifiedResource: string) => (string | (string | string[])[])[]; | ||
'Content Disposition': (stringifiedResource: string) => (string | (string | string[])[])[]; | ||
Size: (stringifiedResource: string) => (string | (string | (string | string[])[])[])[]; | ||
Filename: (stringifiedResource: JSONTypeNodes) => ExtractJSONPathAsTextNode; | ||
HRef: (stringifiedResource: JSONTypeNodes) => ExtractJSONPathAsTextNode; | ||
'Content Type': (stringifiedResource: JSONTypeNodes) => ExtractJSONPathAsTextNode; | ||
'Content Disposition': (stringifiedResource: JSONTypeNodes) => ExtractJSONPathAsTextNode; | ||
Size: (stringifiedResource: JSONTypeNodes) => CastNode; | ||
}; | ||
@@ -26,0 +27,0 @@ }; |
@@ -64,3 +64,3 @@ "use strict"; | ||
catch (e) { | ||
throw new Error(`can't be parsed from stored value ${typeof data} with error ${e.message}`); | ||
throw new Error(`can't parse value of type ${typeof data}`); | ||
} | ||
@@ -87,3 +87,3 @@ } | ||
} | ||
if (!value.filename) { | ||
if (value.filename == null) { | ||
throw new Error('filename is required'); | ||
@@ -94,3 +94,3 @@ } | ||
} | ||
if (!value.href) { | ||
if (value.href == null) { | ||
throw new Error('href is required'); | ||
@@ -101,10 +101,10 @@ } | ||
} | ||
if (value.contentType && typeof value.contentType !== 'string') { | ||
if (value.contentType != null && typeof value.contentType !== 'string') { | ||
throw new Error('contentType must be a string'); | ||
} | ||
if (value.contentDisposition && | ||
if (value.contentDisposition != null && | ||
typeof value.contentDisposition !== 'string') { | ||
throw new Error('contentDisposition must be a string'); | ||
} | ||
if (value.size && !Number.isInteger(value.size)) { | ||
if (value.size != null && !Number.isInteger(value.size)) { | ||
throw new Error('size must be an integer'); | ||
@@ -116,5 +116,5 @@ } | ||
catch (e) { | ||
throw new Error(`can't be stringified; error ${e.message}`); | ||
throw new Error("can't stringify JSON content"); | ||
} | ||
}); | ||
//# sourceMappingURL=web-resource.js.map |
{ | ||
"name": "@balena/sbvr-types", | ||
"version": "3.6.0-build-web-resource-2-a73950a1595475215ad58ec00ff79999e8da9cf6-1", | ||
"version": "3.6.0-build-web-resource-2-fba329fc6ffc4287fa49fb4cd90aec08fa9bf86a-1", | ||
"description": "SBVR type definitions.", | ||
@@ -25,2 +25,3 @@ "main": "out", | ||
"devDependencies": { | ||
"@balena/abstract-sql-compiler": "^8.3.12", | ||
"@balena/lint": "^6.2.1", | ||
@@ -56,4 +57,4 @@ "@types/bcrypt": "^5.0.0", | ||
"versionist": { | ||
"publishedAt": "2023-03-29T11:40:02.920Z" | ||
"publishedAt": "2023-04-24T12:57:48.837Z" | ||
} | ||
} |
import * as TypeUtils from '../type-utils'; | ||
import type { | ||
CastNode, | ||
ExtractJSONPathAsTextNode, | ||
JSONTypeNodes, | ||
} from '@balena/abstract-sql-compiler'; | ||
@@ -30,3 +35,5 @@ export type WebResource = { | ||
has: { | ||
Filename: (stringifiedResource: string) => [ | ||
Filename: ( | ||
stringifiedResource: JSONTypeNodes, | ||
): ExtractJSONPathAsTextNode => [ | ||
'ExtractJSONPathAsText', | ||
@@ -36,3 +43,3 @@ stringifiedResource, | ||
], | ||
HRef: (stringifiedResource: string) => [ | ||
HRef: (stringifiedResource: JSONTypeNodes): ExtractJSONPathAsTextNode => [ | ||
'ExtractJSONPathAsText', | ||
@@ -42,3 +49,5 @@ stringifiedResource, | ||
], | ||
'Content Type': (stringifiedResource: string) => [ | ||
'Content Type': ( | ||
stringifiedResource: JSONTypeNodes, | ||
): ExtractJSONPathAsTextNode => [ | ||
'ExtractJSONPathAsText', | ||
@@ -48,3 +57,5 @@ stringifiedResource, | ||
], | ||
'Content Disposition': (stringifiedResource: string) => [ | ||
'Content Disposition': ( | ||
stringifiedResource: JSONTypeNodes, | ||
): ExtractJSONPathAsTextNode => [ | ||
'ExtractJSONPathAsText', | ||
@@ -54,3 +65,3 @@ stringifiedResource, | ||
], | ||
Size: (stringifiedResource: string) => [ | ||
Size: (stringifiedResource: JSONTypeNodes): CastNode => [ | ||
'Cast', | ||
@@ -83,7 +94,3 @@ [ | ||
} catch (e: any) { | ||
throw new Error( | ||
`can't be parsed from stored value ${typeof data} with error ${ | ||
e.message | ||
}`, | ||
); | ||
throw new Error(`can't parse value of type ${typeof data}`); | ||
} | ||
@@ -116,3 +123,3 @@ } else if (typeof data === 'object') { | ||
} | ||
if (!value.filename) { | ||
if (value.filename == null) { | ||
throw new Error('filename is required'); | ||
@@ -123,3 +130,3 @@ } | ||
} | ||
if (!value.href) { | ||
if (value.href == null) { | ||
throw new Error('href is required'); | ||
@@ -130,7 +137,7 @@ } | ||
} | ||
if (value.contentType && typeof value.contentType !== 'string') { | ||
if (value.contentType != null && typeof value.contentType !== 'string') { | ||
throw new Error('contentType must be a string'); | ||
} | ||
if ( | ||
value.contentDisposition && | ||
value.contentDisposition != null && | ||
typeof value.contentDisposition !== 'string' | ||
@@ -140,3 +147,3 @@ ) { | ||
} | ||
if (value.size && !Number.isInteger(value.size)) { | ||
if (value.size != null && !Number.isInteger(value.size)) { | ||
throw new Error('size must be an integer'); | ||
@@ -147,5 +154,5 @@ } | ||
} catch (e: any) { | ||
throw new Error(`can't be stringified; error ${e.message}`); | ||
throw new Error("can't stringify JSON content"); | ||
} | ||
}, | ||
); |
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
125087
1986
15