Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@signalk/resources-provider

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@signalk/resources-provider - npm Package Compare versions

Comparing version 1.1.2 to 1.2.0

6

CHANGELOG.md
# CHANGELOG: RESOURCES-PROVIDER
___Note: Signal K server on which this plugin is installed must implement the `ResourceProvider API`.___
___Note: Can only be used with Signal K server version 2.0.0 or later.___
---
## v1.2.0
- **Update**: Update plugin configuration to include `charts`.
## v1.1.2

@@ -8,0 +12,0 @@

2

package.json
{
"name": "@signalk/resources-provider",
"version": "1.1.2",
"version": "1.2.0",
"description": "Resources provider plugin for Signal K server.",

@@ -5,0 +5,0 @@ "main": "plugin/index.js",

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

Object.defineProperty(exports, "__esModule", { value: true });
const server_api_1 = require("@signalk/server-api");
const filestorage_1 = require("./lib/filestorage");

@@ -36,2 +37,6 @@ const CONFIG_SCHEMA = {

title: 'REGIONS'
},
charts: {
type: 'boolean',
title: 'CHART SOURCES'
}

@@ -79,2 +84,7 @@ }

'ui:help': '/signalk/v2/api/resources/regions'
},
charts: {
'ui:widget': 'checkbox',
'ui:title': ' ',
'ui:help': '/signalk/v2/api/resources/charts'
}

@@ -89,4 +99,4 @@ }

uiSchema: () => CONFIG_UISCHEMA,
start: (options) => {
doStartup(options);
start: (settings) => {
doStartup(settings);
},

@@ -98,25 +108,7 @@ stop: () => {

const db = new filestorage_1.FileStore(plugin.id, server.debug);
let config = {
standard: {
routes: true,
waypoints: true,
notes: true,
regions: true
},
custom: [],
path: './resources'
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const doStartup = (options) => {
let config;
const doStartup = (settings) => {
try {
server.debug(`${plugin.name} starting.......`);
if (options && options.standard) {
config = options;
}
else {
// save defaults if no options loaded
server.savePluginOptions(config, () => {
server.debug(`Default configuration applied...`);
});
}
config = cleanConfig(settings);
server.debug(`Applied config: ${JSON.stringify(config)}`);

@@ -131,3 +123,2 @@ // compile list of enabled resource types

if (config.custom && Array.isArray(config.custom)) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const customTypes = config.custom.map((i) => {

@@ -150,6 +141,8 @@ return i.name;

const result = registerProviders(apiProviderFor);
const msg = result.length !== 0
? `${result.toString()} not registered!`
: `Providing: ${apiProviderFor.toString()}`;
server.setPluginStatus(msg);
if (result.length !== 0) {
server.setPluginError(`Error registering providers: ${result.toString()}`);
}
else {
server.setPluginStatus(`Providing: ${apiProviderFor.toString()}`);
}
})

@@ -174,2 +167,37 @@ .catch((e) => {

};
/** process changes in config schema */
const cleanConfig = (options) => {
server.debug(`Check / Clean loaded settings...`);
const defaultConfig = {
standard: {
routes: true,
waypoints: true,
notes: true,
regions: true,
charts: true
},
custom: []
};
// set / save defaults if no saved settings
if (!(options === null || options === void 0 ? void 0 : options.standard)) {
server.savePluginOptions(defaultConfig, () => {
server.debug(`Default configuration applied...`);
});
return defaultConfig;
}
// check / clean settings
if (!Array.isArray(options === null || options === void 0 ? void 0 : options.custom)) {
options.custom = [];
}
server_api_1.SIGNALKRESOURCETYPES.forEach((r) => {
if (!(r in options.standard)) {
options.standard[r] = true;
}
});
options.custom = options.custom.filter((i) => !(i.name in defaultConfig.standard));
server.savePluginOptions(options, () => {
server.debug(`Configuration cleaned and saved...`);
});
return options;
};
const getVesselPosition = () => {

@@ -211,3 +239,3 @@ const p = server.getSelfPath('navigation.position');

// eslint-disable-next-line @typescript-eslint/no-explicit-any
params
params = {}
// eslint-disable-next-line @typescript-eslint/no-explicit-any

@@ -214,0 +242,0 @@ ) => __awaiter(void 0, void 0, void 0, function* () {

@@ -60,2 +60,4 @@ # Signal K Resources Provider Plugin:

...
/charts
...
/my_custom_type

@@ -62,0 +64,0 @@ ...

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