@signalk/server-api 2.0.0-beta.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +25 -0
- package/dist/{autopilot.d.ts → autopilotapi.d.ts} +6 -9
- package/dist/deltas.d.ts +73 -0
- package/dist/deltas.js +18 -0
- package/dist/index.d.ts +58 -64
- package/dist/index.js +15 -12
- package/dist/propertyvalues.d.ts +1 -1
- package/dist/propertyvalues.js +7 -6
- package/dist/propertyvalues.test.js +12 -7
- package/dist/resourcesapi.d.ts +37 -0
- package/dist/resourcesapi.js +14 -0
- package/dist/resourcetypes.d.ts +4 -4
- package/dist/types.js +1 -0
- package/package.json +16 -7
- package/tsconfig.tsbuildinfo +1 -3475
- /package/dist/{autopilot.js → autopilotapi.js} +0 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// eslint-disable-next-line no-undef
|
|
2
|
+
module.exports = {
|
|
3
|
+
root: true,
|
|
4
|
+
extends: ['eslint:recommended', 'prettier'],
|
|
5
|
+
parserOptions: {
|
|
6
|
+
ecmaVersion: 2019,
|
|
7
|
+
sourceType: 'module'
|
|
8
|
+
},
|
|
9
|
+
env: {
|
|
10
|
+
node: true,
|
|
11
|
+
es2019: true
|
|
12
|
+
},
|
|
13
|
+
overrides: [
|
|
14
|
+
{
|
|
15
|
+
files: ['**/*.ts'],
|
|
16
|
+
extends: [
|
|
17
|
+
'eslint:recommended',
|
|
18
|
+
'plugin:@typescript-eslint/recommended',
|
|
19
|
+
'prettier'
|
|
20
|
+
],
|
|
21
|
+
parser: '@typescript-eslint/parser',
|
|
22
|
+
plugins: ['@typescript-eslint']
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
export interface AutopilotApi {
|
|
2
2
|
register: (pluginId: string, provider: AutopilotProvider) => void;
|
|
3
3
|
unRegister: (pluginId: string) => void;
|
|
4
|
-
getStates: () => Promise<[string]>;
|
|
5
|
-
setState: (state: string) => Promise<void>;
|
|
6
|
-
getModes: () => Promise<[string]>;
|
|
7
|
-
setMode: (mode: string) => Promise<void>;
|
|
8
|
-
setTarget: (value: number) => Promise<void>;
|
|
9
|
-
adjustTarget: (value: number) => Promise<void>;
|
|
10
|
-
tack: (port: boolean) => Promise<void>;
|
|
11
4
|
}
|
|
12
5
|
export interface AutopilotProvider {
|
|
13
6
|
pilotType: string;
|
|
@@ -15,9 +8,13 @@ export interface AutopilotProvider {
|
|
|
15
8
|
}
|
|
16
9
|
export interface AutopilotProviderMethods {
|
|
17
10
|
pluginId?: string;
|
|
18
|
-
|
|
11
|
+
engage: (enable: boolean) => Promise<void>;
|
|
12
|
+
getConfig: () => Promise<{
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}>;
|
|
15
|
+
getState: () => Promise<string>;
|
|
19
16
|
setState: (state: string) => Promise<void>;
|
|
20
|
-
|
|
17
|
+
getMode: () => Promise<string>;
|
|
21
18
|
setMode: (mode: string) => Promise<void>;
|
|
22
19
|
setTarget: (value: number) => Promise<void>;
|
|
23
20
|
adjustTarget: (value: number) => Promise<void>;
|
package/dist/deltas.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Brand } from '.';
|
|
2
|
+
export interface WithContext {
|
|
3
|
+
context: Context;
|
|
4
|
+
}
|
|
5
|
+
export interface NormalizedDelta extends WithContext {
|
|
6
|
+
$source: SourceRef;
|
|
7
|
+
source: Source;
|
|
8
|
+
path: Path;
|
|
9
|
+
value: Value;
|
|
10
|
+
isMeta: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type SourceRef = Brand<string, 'sourceRef'>;
|
|
13
|
+
export type Source = any;
|
|
14
|
+
export type Path = Brand<string, 'path'>;
|
|
15
|
+
export type Timestamp = Brand<string, 'timestamp'>;
|
|
16
|
+
export type Context = Brand<string, 'context'>;
|
|
17
|
+
export type Value = object | number | string | null | Notification;
|
|
18
|
+
export interface DeltaSubscription {
|
|
19
|
+
context: Context;
|
|
20
|
+
subscribe: Array<{
|
|
21
|
+
path: Path;
|
|
22
|
+
period: number;
|
|
23
|
+
format: 'delta' | 'full';
|
|
24
|
+
policy: 'instant' | 'ideal' | 'fixed';
|
|
25
|
+
minPeriod: number;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
export interface ValuesDelta {
|
|
29
|
+
context?: Context;
|
|
30
|
+
updates: Update[];
|
|
31
|
+
}
|
|
32
|
+
export interface MetaDelta {
|
|
33
|
+
metas: Array<{
|
|
34
|
+
values: Meta[];
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
export type Delta = ValuesDelta | MetaDelta;
|
|
38
|
+
export interface Update {
|
|
39
|
+
timestamp?: Timestamp;
|
|
40
|
+
source?: Source;
|
|
41
|
+
$source?: SourceRef;
|
|
42
|
+
values: PathValue[];
|
|
43
|
+
}
|
|
44
|
+
export interface PathValue {
|
|
45
|
+
path: Path;
|
|
46
|
+
value: Value;
|
|
47
|
+
}
|
|
48
|
+
export interface Notification {
|
|
49
|
+
state: ALARM_STATE;
|
|
50
|
+
method: ALARM_METHOD[];
|
|
51
|
+
message: string;
|
|
52
|
+
}
|
|
53
|
+
export interface Meta {
|
|
54
|
+
path: string;
|
|
55
|
+
value: MetaValue;
|
|
56
|
+
}
|
|
57
|
+
export interface MetaValue {
|
|
58
|
+
description: string;
|
|
59
|
+
units?: string;
|
|
60
|
+
example?: string;
|
|
61
|
+
}
|
|
62
|
+
export declare enum ALARM_STATE {
|
|
63
|
+
nominal = "nominal",
|
|
64
|
+
normal = "normal",
|
|
65
|
+
alert = "alert",
|
|
66
|
+
warn = "warn",
|
|
67
|
+
alarm = "alarm",
|
|
68
|
+
emergency = "emergency"
|
|
69
|
+
}
|
|
70
|
+
export declare enum ALARM_METHOD {
|
|
71
|
+
visual = "visual",
|
|
72
|
+
sound = "sound"
|
|
73
|
+
}
|
package/dist/deltas.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ALARM_METHOD = exports.ALARM_STATE = void 0;
|
|
4
|
+
// Notification attribute types
|
|
5
|
+
var ALARM_STATE;
|
|
6
|
+
(function (ALARM_STATE) {
|
|
7
|
+
ALARM_STATE["nominal"] = "nominal";
|
|
8
|
+
ALARM_STATE["normal"] = "normal";
|
|
9
|
+
ALARM_STATE["alert"] = "alert";
|
|
10
|
+
ALARM_STATE["warn"] = "warn";
|
|
11
|
+
ALARM_STATE["alarm"] = "alarm";
|
|
12
|
+
ALARM_STATE["emergency"] = "emergency";
|
|
13
|
+
})(ALARM_STATE = exports.ALARM_STATE || (exports.ALARM_STATE = {}));
|
|
14
|
+
var ALARM_METHOD;
|
|
15
|
+
(function (ALARM_METHOD) {
|
|
16
|
+
ALARM_METHOD["visual"] = "visual";
|
|
17
|
+
ALARM_METHOD["sound"] = "sound";
|
|
18
|
+
})(ALARM_METHOD = exports.ALARM_METHOD || (exports.ALARM_METHOD = {}));
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { IRouter } from 'express';
|
|
2
3
|
import { PropertyValuesCallback } from './propertyvalues';
|
|
3
4
|
export interface Position {
|
|
@@ -5,71 +6,27 @@ export interface Position {
|
|
|
5
6
|
longitude: number;
|
|
6
7
|
altitude?: number;
|
|
7
8
|
}
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export declare type ResourceType = SignalKResourceType | string;
|
|
14
|
-
export interface ResourcesApi {
|
|
15
|
-
register: (pluginId: string, provider: ResourceProvider) => void;
|
|
16
|
-
unRegister: (pluginId: string) => void;
|
|
17
|
-
listResources: (resType: SignalKResourceType, params: {
|
|
18
|
-
[key: string]: any;
|
|
19
|
-
}, providerId?: string) => Promise<{
|
|
20
|
-
[id: string]: any;
|
|
21
|
-
}>;
|
|
22
|
-
getResource: (resType: SignalKResourceType, resId: string, providerId?: string) => Promise<object>;
|
|
23
|
-
setResource: (resType: SignalKResourceType, resId: string, data: {
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
}, providerId?: string) => Promise<void>;
|
|
26
|
-
deleteResource: (resType: SignalKResourceType, resId: string, providerId?: string) => Promise<void>;
|
|
27
|
-
}
|
|
28
|
-
export interface ResourceProvider {
|
|
29
|
-
type: ResourceType;
|
|
30
|
-
methods: ResourceProviderMethods;
|
|
31
|
-
}
|
|
32
|
-
export interface ResourceProviderMethods {
|
|
33
|
-
listResources: (query: {
|
|
34
|
-
[key: string]: any;
|
|
35
|
-
}) => Promise<{
|
|
36
|
-
[id: string]: any;
|
|
37
|
-
}>;
|
|
38
|
-
getResource: (id: string, property?: string) => Promise<object>;
|
|
39
|
-
setResource: (id: string, value: {
|
|
40
|
-
[key: string]: any;
|
|
41
|
-
}) => Promise<void>;
|
|
42
|
-
deleteResource: (id: string) => Promise<void>;
|
|
43
|
-
}
|
|
44
|
-
export interface ResourceProviderRegistry {
|
|
45
|
-
registerResourceProvider: (provider: ResourceProvider) => void;
|
|
46
|
-
}
|
|
47
|
-
export interface AutopilotApi {
|
|
48
|
-
register: (pluginId: string, provider: AutopilotProvider) => void;
|
|
49
|
-
unRegister: (pluginId: string) => void;
|
|
50
|
-
}
|
|
51
|
-
export interface AutopilotProvider {
|
|
52
|
-
pilotType: string;
|
|
53
|
-
methods: AutopilotProviderMethods;
|
|
9
|
+
export interface ActionResult {
|
|
10
|
+
state: 'COMPLETED' | 'PENDING' | 'FAILED';
|
|
11
|
+
statusCode: number;
|
|
12
|
+
message?: string;
|
|
13
|
+
resultStatus?: number;
|
|
54
14
|
}
|
|
55
|
-
export
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
getConfig: () => Promise<{
|
|
59
|
-
[key: string]: any;
|
|
60
|
-
}>;
|
|
61
|
-
getState: () => Promise<string>;
|
|
62
|
-
setState: (state: string) => Promise<void>;
|
|
63
|
-
getMode: () => Promise<string>;
|
|
64
|
-
setMode: (mode: string) => Promise<void>;
|
|
65
|
-
setTarget: (value: number) => Promise<void>;
|
|
66
|
-
adjustTarget: (value: number) => Promise<void>;
|
|
67
|
-
tack: (port: boolean) => Promise<void>;
|
|
15
|
+
export declare enum SKVersion {
|
|
16
|
+
v1 = "v1",
|
|
17
|
+
v2 = "v2"
|
|
68
18
|
}
|
|
69
|
-
export
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
19
|
+
export type Brand<K, T> = K & {
|
|
20
|
+
__brand: T;
|
|
21
|
+
};
|
|
22
|
+
export * from './deltas';
|
|
23
|
+
export * from './resourcetypes';
|
|
24
|
+
export * from './resourcesapi';
|
|
25
|
+
export { ResourceProviderRegistry } from './resourcesapi';
|
|
26
|
+
import { ResourceProviderRegistry } from './resourcesapi';
|
|
27
|
+
export * from './autopilotapi';
|
|
28
|
+
export { PropertyValue, PropertyValues, PropertyValuesCallback } from './propertyvalues';
|
|
29
|
+
type Unsubscribe = () => void;
|
|
73
30
|
export interface PropertyValuesEmitter {
|
|
74
31
|
emitPropertyValue: (name: string, value: any) => void;
|
|
75
32
|
onPropertyValues: (name: string, cb: PropertyValuesCallback) => Unsubscribe;
|
|
@@ -105,7 +62,7 @@ export interface Plugin {
|
|
|
105
62
|
* in the admin UI
|
|
106
63
|
* - when a plugin is Enabled in the admin UI
|
|
107
64
|
*/
|
|
108
|
-
start: (config: object, restart: (newConfiguration: object) => void) =>
|
|
65
|
+
start: (config: object, restart: (newConfiguration: object) => void) => void;
|
|
109
66
|
/**
|
|
110
67
|
* Called to stop the plugin. Called when the user disables the plugin in the admin UI.
|
|
111
68
|
*/
|
|
@@ -115,4 +72,41 @@ export interface Plugin {
|
|
|
115
72
|
registerWithRouter?: (router: IRouter) => void;
|
|
116
73
|
signalKApiRoutes?: (router: IRouter) => IRouter;
|
|
117
74
|
enabledByDefault?: boolean;
|
|
75
|
+
getOpenApi?: () => any;
|
|
76
|
+
}
|
|
77
|
+
export type DeltaInputHandler = (delta: object, next: (delta: object) => void) => void;
|
|
78
|
+
export interface Ports {
|
|
79
|
+
byId: string[];
|
|
80
|
+
byPath: string[];
|
|
81
|
+
byOpenPlotter: string[];
|
|
82
|
+
serialports: any;
|
|
83
|
+
}
|
|
84
|
+
export interface Metadata {
|
|
85
|
+
units?: string;
|
|
86
|
+
description?: string;
|
|
87
|
+
}
|
|
88
|
+
export interface ServerAPI extends PluginServerApp {
|
|
89
|
+
getSelfPath: (path: string) => any;
|
|
90
|
+
getPath: (path: string) => any;
|
|
91
|
+
getMetadata: (path: string) => Metadata | undefined;
|
|
92
|
+
putSelfPath: (aPath: string, value: any, updateCb: () => void) => Promise<any>;
|
|
93
|
+
putPath: (aPath: string, value: number | string | object | boolean, updateCb: (err?: Error) => void, source: string) => Promise<any>;
|
|
94
|
+
queryRequest: (requestId: string) => Promise<any>;
|
|
95
|
+
error: (msg: string) => void;
|
|
96
|
+
debug: (msg: string) => void;
|
|
97
|
+
registerDeltaInputHandler: (handler: DeltaInputHandler) => void;
|
|
98
|
+
setPluginStatus: (msg: string) => void;
|
|
99
|
+
setPluginError: (msg: string) => void;
|
|
100
|
+
handleMessage: (id: string, msg: any, skVersion?: SKVersion) => void;
|
|
101
|
+
savePluginOptions: (configuration: object, cb: (err: NodeJS.ErrnoException | null) => void) => void;
|
|
102
|
+
readPluginOptions: () => object;
|
|
103
|
+
getDataDirPath: () => string;
|
|
104
|
+
registerPutHandler: (context: string, path: string, callback: () => void, source: string) => void;
|
|
105
|
+
registerActionHandler: (context: string, path: string, callback: () => void, source: string) => void;
|
|
106
|
+
registerHistoryProvider: (provider: {
|
|
107
|
+
hasAnydata: (options: object, cb: (hasResults: boolean) => void) => void;
|
|
108
|
+
getHistory: (date: Date, path: string, cb: (deltas: object[]) => void) => void;
|
|
109
|
+
streamHistory: (spark: any, options: object, onDelta: (delta: object) => void) => void;
|
|
110
|
+
}) => void;
|
|
111
|
+
getSerialPorts: () => Promise<Ports>;
|
|
118
112
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -10,16 +14,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
15
|
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.
|
|
17
|
+
exports.PropertyValues = exports.SKVersion = void 0;
|
|
18
|
+
var SKVersion;
|
|
19
|
+
(function (SKVersion) {
|
|
20
|
+
SKVersion["v1"] = "v1";
|
|
21
|
+
SKVersion["v2"] = "v2";
|
|
22
|
+
})(SKVersion = exports.SKVersion || (exports.SKVersion = {}));
|
|
23
|
+
__exportStar(require("./deltas"), exports);
|
|
24
|
+
__exportStar(require("./resourcetypes"), exports);
|
|
25
|
+
__exportStar(require("./resourcesapi"), exports);
|
|
26
|
+
__exportStar(require("./autopilotapi"), exports);
|
|
14
27
|
var propertyvalues_1 = require("./propertyvalues");
|
|
15
28
|
Object.defineProperty(exports, "PropertyValues", { enumerable: true, get: function () { return propertyvalues_1.PropertyValues; } });
|
|
16
|
-
__exportStar(require("./resourcetypes"), exports);
|
|
17
|
-
exports.SIGNALKRESOURCETYPES = [
|
|
18
|
-
'routes',
|
|
19
|
-
'waypoints',
|
|
20
|
-
'notes',
|
|
21
|
-
'regions',
|
|
22
|
-
'charts'
|
|
23
|
-
];
|
|
24
|
-
var isSignalKResourceType = function (s) { return exports.SIGNALKRESOURCETYPES.includes(s); };
|
|
25
|
-
exports.isSignalKResourceType = isSignalKResourceType;
|
package/dist/propertyvalues.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface PropertyValue {
|
|
|
4
4
|
name: string;
|
|
5
5
|
value: any;
|
|
6
6
|
}
|
|
7
|
-
export
|
|
7
|
+
export type PropertyValuesCallback = (propValuesHistory: PropertyValue[]) => void;
|
|
8
8
|
export declare class PropertyValues {
|
|
9
9
|
private streams;
|
|
10
10
|
private count;
|
package/dist/propertyvalues.js
CHANGED
|
@@ -15,7 +15,7 @@ var PropertyValues = /** @class */ (function () {
|
|
|
15
15
|
};
|
|
16
16
|
PropertyValues.prototype.emitPropertyValue = function (pv) {
|
|
17
17
|
if (this.count >= PropertyValues.MAX_VALUES_COUNT) {
|
|
18
|
-
throw new Error("Max PropertyValues count "
|
|
18
|
+
throw new Error("Max PropertyValues count ".concat(PropertyValues.MAX_VALUES_COUNT, " exceeded trying to emit ").concat(JSON.stringify(pv)));
|
|
19
19
|
}
|
|
20
20
|
this.getStreamTuple(pv.name).bus.push(pv);
|
|
21
21
|
};
|
|
@@ -23,17 +23,18 @@ var PropertyValues = /** @class */ (function () {
|
|
|
23
23
|
var _this = this;
|
|
24
24
|
var streamTuple = this.streams[propName];
|
|
25
25
|
if (!streamTuple) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
stream: null
|
|
29
|
-
};
|
|
30
|
-
streamTuple.stream = streamTuple.bus
|
|
26
|
+
var bus = new baconjs_1.default.Bus();
|
|
27
|
+
var stream = bus
|
|
31
28
|
.scan([], function (acc, v) {
|
|
32
29
|
acc.push(v);
|
|
33
30
|
_this.count++;
|
|
34
31
|
return acc;
|
|
35
32
|
})
|
|
36
33
|
.toProperty();
|
|
34
|
+
streamTuple = {
|
|
35
|
+
bus: bus,
|
|
36
|
+
stream: stream
|
|
37
|
+
};
|
|
37
38
|
streamTuple.stream.subscribe(function () { return ({}); }); // start the stream eagerly
|
|
38
39
|
streamTuple.bus.push(undefined);
|
|
39
40
|
this.streams[propName] = streamTuple;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
3
|
-
for (var i = 0,
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
6
10
|
};
|
|
7
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
12
|
var chai_1 = require("chai");
|
|
@@ -19,9 +23,9 @@ var setupTest = function (done, startAt) {
|
|
|
19
23
|
var pv = new propertyvalues_1.PropertyValues();
|
|
20
24
|
var cbCount = 0;
|
|
21
25
|
var cb = function (values) {
|
|
22
|
-
chai_1.expect(values).to.deep.equal(__spreadArray([
|
|
26
|
+
(0, chai_1.expect)(values).to.deep.equal(__spreadArray([
|
|
23
27
|
undefined
|
|
24
|
-
], testValues.slice(0, startAt + cbCount++)));
|
|
28
|
+
], testValues.slice(0, startAt + cbCount++), true));
|
|
25
29
|
if (cbCount === testValues.length) {
|
|
26
30
|
done();
|
|
27
31
|
}
|
|
@@ -46,11 +50,12 @@ describe('PropertyValues', function () {
|
|
|
46
50
|
for (var i = 1; i < propertyvalues_1.PropertyValues.MAX_VALUES_COUNT; i++) {
|
|
47
51
|
pv.emitPropertyValue(newPropertyValue(i));
|
|
48
52
|
}
|
|
49
|
-
chai_1.expect(function () {
|
|
53
|
+
(0, chai_1.expect)(function () {
|
|
50
54
|
return pv.emitPropertyValue(newPropertyValue(propertyvalues_1.PropertyValues.MAX_VALUES_COUNT));
|
|
51
55
|
}).to.throw();
|
|
52
56
|
});
|
|
53
57
|
});
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
59
|
var newPropertyValue = function (value) { return ({
|
|
55
60
|
timestamp: Date.now(),
|
|
56
61
|
setter: 'foobar',
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type SignalKResourceType = 'routes' | 'waypoints' | 'notes' | 'regions' | 'charts';
|
|
2
|
+
export declare const SIGNALKRESOURCETYPES: SignalKResourceType[];
|
|
3
|
+
export declare const isSignalKResourceType: (s: string) => boolean;
|
|
4
|
+
export type ResourceType = SignalKResourceType | string;
|
|
5
|
+
export interface ResourcesApi {
|
|
6
|
+
register: (pluginId: string, provider: ResourceProvider) => void;
|
|
7
|
+
unRegister: (pluginId: string) => void;
|
|
8
|
+
listResources: (resType: SignalKResourceType, params: {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}, providerId?: string) => Promise<{
|
|
11
|
+
[id: string]: any;
|
|
12
|
+
}>;
|
|
13
|
+
getResource: (resType: SignalKResourceType, resId: string, providerId?: string) => Promise<object>;
|
|
14
|
+
setResource: (resType: SignalKResourceType, resId: string, data: {
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}, providerId?: string) => Promise<void>;
|
|
17
|
+
deleteResource: (resType: SignalKResourceType, resId: string, providerId?: string) => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export interface ResourceProvider {
|
|
20
|
+
type: ResourceType;
|
|
21
|
+
methods: ResourceProviderMethods;
|
|
22
|
+
}
|
|
23
|
+
export interface ResourceProviderMethods {
|
|
24
|
+
listResources: (query: {
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
}) => Promise<{
|
|
27
|
+
[id: string]: any;
|
|
28
|
+
}>;
|
|
29
|
+
getResource: (id: string, property?: string) => Promise<object>;
|
|
30
|
+
setResource: (id: string, value: {
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}) => Promise<void>;
|
|
33
|
+
deleteResource: (id: string) => Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export interface ResourceProviderRegistry {
|
|
36
|
+
registerResourceProvider: (provider: ResourceProvider) => void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSignalKResourceType = exports.SIGNALKRESOURCETYPES = void 0;
|
|
4
|
+
exports.SIGNALKRESOURCETYPES = [
|
|
5
|
+
'routes',
|
|
6
|
+
'waypoints',
|
|
7
|
+
'notes',
|
|
8
|
+
'regions',
|
|
9
|
+
'charts'
|
|
10
|
+
];
|
|
11
|
+
var isSignalKResourceType = function (s) {
|
|
12
|
+
return exports.SIGNALKRESOURCETYPES.includes(s);
|
|
13
|
+
};
|
|
14
|
+
exports.isSignalKResourceType = isSignalKResourceType;
|
package/dist/resourcetypes.d.ts
CHANGED
|
@@ -55,10 +55,10 @@ export interface Chart {
|
|
|
55
55
|
bounds?: [[number, number], [number, number]];
|
|
56
56
|
chartFormat: string;
|
|
57
57
|
}
|
|
58
|
-
export
|
|
59
|
-
export
|
|
60
|
-
export
|
|
61
|
-
export
|
|
58
|
+
export type GeoJsonPoint = [number, number, number?];
|
|
59
|
+
export type GeoJsonLinestring = GeoJsonPoint[];
|
|
60
|
+
export type GeoJsonPolygon = GeoJsonLinestring[];
|
|
61
|
+
export type GeoJsonMultiPolygon = GeoJsonPolygon[];
|
|
62
62
|
interface Polygon {
|
|
63
63
|
type: 'Feature';
|
|
64
64
|
geometry: {
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signalk/server-api",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "signalk-server Typescript API for plugins etc with relevant implementation classes",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
"watch": "tsc --declaration --watch",
|
|
10
10
|
"prepublishOnly": "npm run build",
|
|
11
11
|
"typedoc": "typedoc --out docs src",
|
|
12
|
-
"
|
|
12
|
+
"prettier": "prettier -w src/",
|
|
13
|
+
"lint": "eslint -c .eslintrc.js --ext .ts --ext .js --fix src/",
|
|
14
|
+
"format": "npm run prettier && npm run lint",
|
|
15
|
+
"ci-lint": "eslint -c .eslintrc.js --ext .ts --ext .js src/ && prettier --check src/",
|
|
16
|
+
"test": "mocha --require ts-node/register src/**/*.test.ts && npm run ci-lint"
|
|
13
17
|
},
|
|
14
18
|
"repository": {
|
|
15
19
|
"type": "git",
|
|
@@ -18,14 +22,19 @@
|
|
|
18
22
|
"author": "teppo.kurki@iki.fi",
|
|
19
23
|
"license": "Apache-2.0",
|
|
20
24
|
"devDependencies": {
|
|
21
|
-
"express": "^4.10.4",
|
|
22
25
|
"@types/chai": "^4.2.15",
|
|
23
26
|
"@types/express": "^4.17.1",
|
|
24
|
-
"@types/mocha": "^
|
|
27
|
+
"@types/mocha": "^10.0.1",
|
|
28
|
+
"@typescript-eslint/eslint-plugin": "^5.52.0",
|
|
29
|
+
"@typescript-eslint/parser": "^5.52.0",
|
|
25
30
|
"chai": "^4.3.0",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
31
|
+
"eslint": "^8.34.0",
|
|
32
|
+
"eslint-config-prettier": "^8.6.0",
|
|
33
|
+
"express": "^4.10.4",
|
|
34
|
+
"mocha": "^10.2.0",
|
|
35
|
+
"prettier": "^2.8.4",
|
|
36
|
+
"ts-node": "^10.9.1",
|
|
37
|
+
"typedoc": "^0.23.23",
|
|
29
38
|
"typescript": "^4.1.5"
|
|
30
39
|
},
|
|
31
40
|
"peerDependencies": {
|