New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@balena/sbvr-types

Package Overview
Dependencies
Maintainers
2
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 3.5.0-build-web-resource-2-848c8563bf52fe6873d2242da10a489852f83e69-1 to 3.5.0-build-web-resource-2-8eb1fd3d95c2411f2037f94e8a2bb5c46aafc707-1

2

CHANGELOG.md

@@ -8,3 +8,3 @@ # Change Log

# v3.5.0
## (2022-12-13)
## (2023-01-03)

@@ -11,0 +11,0 @@ * Add type WebResource [Ramiro González Maciel]

@@ -6,1 +6,2 @@ import { StorageAdapter } from './types';

export declare function unregisterStorageAdapter(name: string): void;
export declare function getStorageAdapterNames(): string[];

@@ -17,3 +17,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.unregisterStorageAdapter = exports.getStorageAdapter = exports.registerStorageAdapter = void 0;
exports.getStorageAdapterNames = exports.unregisterStorageAdapter = exports.getStorageAdapter = exports.registerStorageAdapter = void 0;
__exportStar(require("./types"), exports);

@@ -33,2 +33,6 @@ const storageRegistry = {};

exports.unregisterStorageAdapter = unregisterStorageAdapter;
function getStorageAdapterNames() {
return Object.keys(storageRegistry);
}
exports.getStorageAdapterNames = getStorageAdapterNames;
//# sourceMappingURL=index.js.map

@@ -26,2 +26,11 @@ /// <reference types="node" />

};
export declare const nativeProperties: {
has: {
Filename: (from: any) => any[];
HRef: (from: any) => any[];
'Content Type': (from: any) => any[];
'Content Disposition': (from: any) => any[];
Size: (from: any) => any[];
};
};
export declare const fetchProcessing: (data: any) => any;

@@ -28,0 +37,0 @@ export declare const validate: {

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

@@ -22,2 +22,31 @@ const index_1 = require("../storage-adapters/index");

};
exports.nativeProperties = {
has: {
Filename: (from) => [
'ExtractJSONPathAsText',
from,
['TextArray', ['EmbeddedText', 'filename']],
],
HRef: (from) => [
'ExtractJSONPathAsText',
from,
['TextArray', ['EmbeddedText', 'href']],
],
'Content Type': (from) => [
'ExtractJSONPathAsText',
from,
['TextArray', ['EmbeddedText', 'contentType']],
],
'Content Disposition': (from) => [
'ExtractJSONPathAsText',
from,
['TextArray', ['EmbeddedText', 'contentDisposition']],
],
Size: (from) => [
'ExtractJSONPathAsText',
from,
['TextArray', ['EmbeddedText', 'size']],
],
},
};
const fetchProcessing = (data) => {

@@ -67,5 +96,11 @@ let refData;

if (!storageAdapter) {
throw new Error(`storage ${storage} not defined`);
throw new Error(`storage named '${storage}' not defined`);
}
const webresource = await storageAdapter.saveFile(value.filename, value.data);
let webresource;
try {
webresource = await storageAdapter.saveFile(value.filename, value.data);
}
catch (e) {
throw new Error(`can't be saved; error ${e.message}`);
}
const refData = {

@@ -83,5 +118,5 @@ filename: value.filename,

catch (e) {
throw new Error(`can't be stringified with error ${e.message}`);
throw new Error(`can't be stringified; error ${e.message}`);
}
});
//# sourceMappingURL=web-resource.js.map
{
"name": "@balena/sbvr-types",
"version": "3.5.0-build-web-resource-2-848c8563bf52fe6873d2242da10a489852f83e69-1",
"version": "3.5.0-build-web-resource-2-8eb1fd3d95c2411f2037f94e8a2bb5c46aafc707-1",
"description": "SBVR type definitions.",

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

"versionist": {
"publishedAt": "2022-12-13T13:37:24.183Z"
"publishedAt": "2023-01-03T12:48:46.853Z"
}
}

@@ -163,3 +163,3 @@ # sbvr-types

Type [`WebResource`](./src//types/web-resource.ts) can be used to persist files or other large content on an external object storage service like Amazon S3. By "object storage" we refer to a service that can store the content and provide a URL to access that content.
Type [`WebResource`](./src//types/web-resource.ts) can be used to persist files or other large content on an external object storage service like MinIO or Amazon S3. By "object storage" we refer to a service that can store the content and provide a URL to access that content.

@@ -185,4 +185,4 @@ In order to save a `WebResource` you send an instance of [`WebResourceInput`](./src/types/web-resource.ts#L18)

The `storage` attribute specifies the name of an [`StorageAdapter`](./src/storage-adapters/storage-adapter.ts#L7). A `StorageAdapter` saves the content to a specific storage, performing a function similar to what a database driver provides. For example, [pinejs-s3-storage](https://github.com/balena-io-modules/pinejs-s3-storage) saves the content to S3 and returns a URL to the persisted object. For testing purposes, this module uses [disk-storage-adapter](./test/storage-adapters/disk-storage-adapter.js).
The `storage` attribute specifies the name of an [`StorageAdapter`](./src/storage-adapters/storage-adapter.ts#L7). A `StorageAdapter` saves the content to a specific storage, performing a function similar to what a database driver provides. For example, [pinejs-s3-storage](https://github.com/balena-io-modules/pinejs-s3-storage) saves the content to S3/MinIO and returns a URL to the persisted object. For testing purposes, this module uses [disk-storage-adapter](./test/storage-adapters/disk-storage-adapter.js).
Applications need to load the `StorageAdapter`s they need in the `storageRegistry`(./src/storage-adapters/index.ts#L4). Please refer to each specific storage adapter for more configuration and setup details.

@@ -20,1 +20,5 @@ import { StorageAdapter, StorageRegistry } from './types';

}
export function getStorageAdapterNames(): string[] {
return Object.keys(storageRegistry);
}

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

export const nativeProperties = {
has: {
Filename: (from: any) => [
'ExtractJSONPathAsText',
from,
['TextArray', ['EmbeddedText', 'filename']],
],
HRef: (from: any) => [
'ExtractJSONPathAsText',
from,
['TextArray', ['EmbeddedText', 'href']],
],
'Content Type': (from: any) => [
'ExtractJSONPathAsText',
from,
['TextArray', ['EmbeddedText', 'contentType']],
],
'Content Disposition': (from: any) => [
'ExtractJSONPathAsText',
from,
['TextArray', ['EmbeddedText', 'contentDisposition']],
],
Size: (from: any) => [
'ExtractJSONPathAsText',
from,
['TextArray', ['EmbeddedText', 'size']],
],
},
};
export const fetchProcessing = (data: any) => {

@@ -93,9 +123,11 @@ let refData: WebResourceRef;

if (!storageAdapter) {
throw new Error(`storage ${storage} not defined`);
throw new Error(`storage named '${storage}' not defined`);
}
const webresource = await storageAdapter.saveFile(
value.filename,
value.data,
);
let webresource;
try {
webresource = await storageAdapter.saveFile(value.filename, value.data);
} catch (e: any) {
throw new Error(`can't be saved; error ${e.message}`);
}

@@ -113,5 +145,5 @@ const refData: WebResourceRef = {

} catch (e: any) {
throw new Error(`can't be stringified with error ${e.message}`);
throw new Error(`can't be stringified; error ${e.message}`);
}
},
);

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