@signalk/server-api 2.6.1 → 2.7.1

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.
Files changed (69) hide show
  1. package/dist/autopilotapi.d.ts +241 -0
  2. package/dist/autopilotapi.d.ts.map +1 -0
  3. package/dist/autopilotapi.guard.d.ts +1 -0
  4. package/dist/autopilotapi.guard.d.ts.map +1 -0
  5. package/dist/autopilotapi.guard.js +3 -3
  6. package/dist/autopilotapi.guard.js.map +1 -0
  7. package/dist/autopilotapi.js +5 -8
  8. package/dist/autopilotapi.js.map +1 -0
  9. package/dist/brand.d.ts +24 -0
  10. package/dist/brand.d.ts.map +1 -0
  11. package/dist/{types.js → brand.js} +1 -1
  12. package/dist/brand.js.map +1 -0
  13. package/dist/course.d.ts +40 -0
  14. package/dist/course.d.ts.map +1 -0
  15. package/dist/course.js +3 -0
  16. package/dist/course.js.map +1 -0
  17. package/dist/coursetypes.d.ts +10 -11
  18. package/dist/coursetypes.d.ts.map +1 -0
  19. package/dist/coursetypes.js +1 -0
  20. package/dist/coursetypes.js.map +1 -0
  21. package/dist/deltas.d.ts +26 -19
  22. package/dist/deltas.d.ts.map +1 -0
  23. package/dist/deltas.js +6 -5
  24. package/dist/deltas.js.map +1 -0
  25. package/dist/deltas.test.d.ts +2 -0
  26. package/dist/deltas.test.d.ts.map +1 -0
  27. package/dist/features.d.ts +65 -0
  28. package/dist/features.d.ts.map +1 -0
  29. package/dist/features.js +3 -0
  30. package/dist/features.js.map +1 -0
  31. package/dist/index.d.ts +19 -134
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +15 -8
  34. package/dist/index.js.map +1 -0
  35. package/dist/plugin.d.ts +171 -0
  36. package/dist/plugin.d.ts.map +1 -0
  37. package/dist/plugin.js +3 -0
  38. package/dist/plugin.js.map +1 -0
  39. package/dist/propertyvalues.d.ts +50 -0
  40. package/dist/propertyvalues.d.ts.map +1 -0
  41. package/dist/propertyvalues.js +22 -27
  42. package/dist/propertyvalues.js.map +1 -0
  43. package/dist/propertyvalues.test.d.ts +2 -0
  44. package/dist/propertyvalues.test.d.ts.map +1 -0
  45. package/dist/resourcesapi.d.ts +336 -15
  46. package/dist/resourcesapi.d.ts.map +1 -0
  47. package/dist/resourcesapi.js +2 -3
  48. package/dist/resourcesapi.js.map +1 -0
  49. package/dist/resourcetypes.d.ts +9 -3
  50. package/dist/resourcetypes.d.ts.map +1 -0
  51. package/dist/resourcetypes.js +1 -0
  52. package/dist/resourcetypes.js.map +1 -0
  53. package/dist/serverapi.d.ts +369 -0
  54. package/dist/serverapi.d.ts.map +1 -0
  55. package/dist/serverapi.js +3 -0
  56. package/dist/serverapi.js.map +1 -0
  57. package/dist/streambundle.d.ts +149 -0
  58. package/dist/streambundle.d.ts.map +1 -0
  59. package/dist/streambundle.js +3 -0
  60. package/dist/streambundle.js.map +1 -0
  61. package/dist/subscriptionmanager.d.ts +84 -0
  62. package/dist/subscriptionmanager.d.ts.map +1 -0
  63. package/dist/subscriptionmanager.js +3 -0
  64. package/dist/subscriptionmanager.js.map +1 -0
  65. package/package.json +7 -22
  66. package/tsconfig.json +2 -72
  67. package/tsconfig.tsbuildinfo +1 -1
  68. package/typedoc.json +4 -0
  69. package/dist/types.d.ts +0 -7
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @ignore this is extended by {@link ServerAPI}, no need to document separately
3
+ */
4
+ export interface Features {
5
+ /**
6
+ * Returns the available APIs and Plugins.
7
+ *
8
+ * _Example:_
9
+ * ```javascript
10
+ * let features = app.getFeatures();
11
+ *
12
+ * {
13
+ * "apis": [
14
+ * "resources","course"
15
+ * ],
16
+ * "plugins": [
17
+ * {
18
+ * "id": "anchoralarm",
19
+ * "name": "Anchor Alarm",
20
+ * "version": "1.13.0",
21
+ * "enabled": true
22
+ * },
23
+ * {
24
+ * "id": "autopilot",
25
+ * "name": "Autopilot Control",
26
+ * "version": "1.4.0",
27
+ * "enabled": false
28
+ * },
29
+ * {
30
+ * "id": "sk-to-nmea2000",
31
+ * "name": "Signal K to NMEA 2000",
32
+ * "version": "2.17.0",
33
+ * "enabled": false
34
+ * },
35
+ * {
36
+ * "id": "udp-nmea-sender",
37
+ * "name": "UDP NMEA0183 Sender",
38
+ * "version": "2.0.0",
39
+ * "enabled": false
40
+ * }
41
+ * ]
42
+ * }
43
+ * ```
44
+ *
45
+ * @param onlyEnabled
46
+ * - `undefined` (not provided): list all features
47
+ * - `true`: list only enabled features
48
+ * - `false`: list only disabled features
49
+ */
50
+ getFeatures(onlyEnabled?: boolean): FeatureInfo;
51
+ }
52
+ /**
53
+ * Information about the available APIs and Plugins.
54
+ */
55
+ export interface FeatureInfo {
56
+ apis: SignalKApiId[];
57
+ plugins: Array<{
58
+ id: string;
59
+ name: string;
60
+ version: string;
61
+ enabled: boolean;
62
+ }>;
63
+ }
64
+ export type SignalKApiId = 'resources' | 'course' | 'history' | 'autopilot' | 'anchor' | 'logbook' | 'historyplayback' | 'historysnapshot';
65
+ //# sourceMappingURL=features.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../src/features.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;IACH,WAAW,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,WAAW,CAAA;CAChD;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,YAAY,EAAE,CAAA;IACpB,OAAO,EAAE,KAAK,CAAC;QACb,EAAE,EAAE,MAAM,CAAA;QACV,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,OAAO,CAAA;KACjB,CAAC,CAAA;CACH;AAED,MAAM,MAAM,YAAY,GACpB,WAAW,GACX,QAAQ,GACR,SAAS,GACT,WAAW,GACX,QAAQ,GACR,SAAS,GACT,iBAAiB,GACjB,iBAAiB,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=features.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features.js","sourceRoot":"","sources":["../src/features.ts"],"names":[],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -1,11 +1,26 @@
1
- /// <reference types="node" />
2
- import { IRouter } from 'express';
3
- import { PropertyValuesCallback } from './propertyvalues';
1
+ export * from './plugin';
2
+ export * from './serverapi';
3
+ export * from './deltas';
4
+ export * from './coursetypes';
5
+ export * from './resourcetypes';
6
+ export * from './resourcesapi';
7
+ export * from './features';
8
+ export * from './course';
9
+ export * from './autopilotapi';
10
+ export * from './autopilotapi.guard';
11
+ export * from './propertyvalues';
12
+ export * from './brand';
13
+ export * from './streambundle';
14
+ export * from './subscriptionmanager';
4
15
  export interface Position {
5
16
  latitude: number;
6
17
  longitude: number;
7
18
  altitude?: number;
8
19
  }
20
+ export interface RelativePositionOrigin {
21
+ radius: number;
22
+ position: Position;
23
+ }
9
24
  export interface ActionResult {
10
25
  state: 'COMPLETED' | 'PENDING' | 'FAILED';
11
26
  statusCode: number;
@@ -16,134 +31,4 @@ export declare enum SKVersion {
16
31
  v1 = "v1",
17
32
  v2 = "v2"
18
33
  }
19
- export type Brand<K, T> = K & {
20
- __brand: T;
21
- };
22
- export * from './deltas';
23
- export * from './coursetypes';
24
- export * from './resourcetypes';
25
- export * from './resourcesapi';
26
- export { ResourceProviderRegistry } from './resourcesapi';
27
- import { ResourceProviderRegistry } from './resourcesapi';
28
- export * from './autopilotapi';
29
- import { AutopilotProviderRegistry } from './autopilotapi';
30
- export { AutopilotProviderRegistry } from './autopilotapi';
31
- export * from './autopilotapi.guard';
32
- import { PointDestination, RouteDestination, CourseInfo } from './coursetypes';
33
- export type SignalKApiId = 'resources' | 'course' | 'history' | 'autopilot' | 'anchor' | 'logbook' | 'historyplayback' | 'historysnapshot';
34
- export { PropertyValue, PropertyValues, PropertyValuesCallback } from './propertyvalues';
35
- type Unsubscribe = () => void;
36
- export interface PropertyValuesEmitter {
37
- emitPropertyValue: (name: string, value: any) => void;
38
- onPropertyValues: (name: string, cb: PropertyValuesCallback) => Unsubscribe;
39
- }
40
- /**
41
- * This is the API that the server exposes in the app object that
42
- * is passed in Plugin "constructor" call.
43
- *
44
- * INCOMPLETE, work in progress.
45
- */
46
- export interface PluginServerApp extends PropertyValuesEmitter, ResourceProviderRegistry, AutopilotProviderRegistry {
47
- }
48
- /**
49
- * This is the API that a [server plugin](https://github.com/SignalK/signalk-server/blob/master/SERVERPLUGINS.md) must implement.
50
- *
51
- * Typing is INCOMPLETE.
52
- */
53
- export interface Plugin {
54
- /**
55
- * Used to identify the plugin in the server, for example
56
- * when storing the plugin's configuration and in http endpoints.
57
- */
58
- id: string;
59
- /**
60
- * Human oriented name for the plugin. This is used in the
61
- * server's plugin configuration user interface.
62
- */
63
- name: string;
64
- /**
65
- * Called to start the plugin with latest saved configuration. Called
66
- * - for enabled (by configuration or by default) plugins during server startup
67
- * - after stop() when the configuration of an enabled plugin has been updated
68
- * in the admin UI
69
- * - when a plugin is Enabled in the admin UI
70
- */
71
- start: (config: object, restart: (newConfiguration: object) => void) => void;
72
- /**
73
- * Called to stop the plugin. Called when the user disables the plugin in the admin UI.
74
- */
75
- stop: () => void;
76
- schema: () => object | object;
77
- uiSchema?: () => object | object;
78
- registerWithRouter?: (router: IRouter) => void;
79
- signalKApiRoutes?: (router: IRouter) => IRouter;
80
- enabledByDefault?: boolean;
81
- getOpenApi?: () => any;
82
- }
83
- export type DeltaInputHandler = (delta: object, next: (delta: object) => void) => void;
84
- export interface Ports {
85
- byId: string[];
86
- byPath: string[];
87
- byOpenPlotter: string[];
88
- serialports: any;
89
- }
90
- export interface Metadata {
91
- units?: string;
92
- description?: string;
93
- }
94
- export interface FeatureInfo {
95
- apis: SignalKApiId[];
96
- plugins: Array<{
97
- id: string;
98
- name: string;
99
- version: string;
100
- enabled: boolean;
101
- }>;
102
- }
103
- export interface ServerAPI extends PluginServerApp {
104
- getSelfPath: (path: string) => any;
105
- getPath: (path: string) => any;
106
- getMetadata: (path: string) => Metadata | undefined;
107
- putSelfPath: (aPath: string, value: any, updateCb: () => void) => Promise<any>;
108
- putPath: (aPath: string, value: number | string | object | boolean, updateCb: (err?: Error) => void, source: string) => Promise<any>;
109
- queryRequest: (requestId: string) => Promise<any>;
110
- error: (msg: string) => void;
111
- debug: (msg: string) => void;
112
- registerDeltaInputHandler: (handler: DeltaInputHandler) => void;
113
- setPluginStatus: (msg: string) => void;
114
- setPluginError: (msg: string) => void;
115
- handleMessage: (id: string, msg: any, skVersion?: SKVersion) => void;
116
- savePluginOptions: (configuration: object, cb: (err: NodeJS.ErrnoException | null) => void) => void;
117
- readPluginOptions: () => object;
118
- getDataDirPath: () => string;
119
- registerPutHandler: (context: string, path: string, callback: () => void, source: string) => void;
120
- registerActionHandler: (context: string, path: string, callback: () => void, source: string) => void;
121
- registerHistoryProvider: (provider: {
122
- hasAnydata: (options: object, cb: (hasResults: boolean) => void) => void;
123
- getHistory: (date: Date, path: string, cb: (deltas: object[]) => void) => void;
124
- streamHistory: (spark: any, options: object, onDelta: (delta: object) => void) => void;
125
- }) => void;
126
- getSerialPorts: () => Promise<Ports>;
127
- getFeatures: () => FeatureInfo;
128
- getCourse: () => Promise<CourseInfo>;
129
- clearDestination: () => Promise<void>;
130
- setDestination: (dest: (PointDestination & {
131
- arrivalCircle?: number;
132
- }) | null) => Promise<void>;
133
- activateRoute: (dest: RouteDestination | null) => Promise<void>;
134
- /**
135
- * A plugin can report that it has handled output messages. This will
136
- * update the output message rate and icon in the Dashboard.
137
- *
138
- * This is for traffic that the plugin is sending outside the server,
139
- * for example network packets, http calls or messages sent to
140
- * a broker. This should NOT be used for deltas that the plugin
141
- * sends with handleMessage, they are reported as input from the
142
- * server's perspective.
143
- *
144
- * @param count optional count of handled messages between the last
145
- * call and this one. If omitted the call will count as one output
146
- * message.
147
- */
148
- reportOutputMessages: (count?: number) => void;
149
- }
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA;AAErC,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,QAAQ,CAAA;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAA;IACzC,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,oBAAY,SAAS;IACnB,EAAE,OAAO;IACT,EAAE,OAAO;CACV"}
package/dist/index.js CHANGED
@@ -14,17 +14,24 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
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 = {}));
17
+ exports.SKVersion = void 0;
18
+ __exportStar(require("./plugin"), exports);
19
+ __exportStar(require("./serverapi"), exports);
23
20
  __exportStar(require("./deltas"), exports);
24
21
  __exportStar(require("./coursetypes"), exports);
25
22
  __exportStar(require("./resourcetypes"), exports);
26
23
  __exportStar(require("./resourcesapi"), exports);
24
+ __exportStar(require("./features"), exports);
25
+ __exportStar(require("./course"), exports);
27
26
  __exportStar(require("./autopilotapi"), exports);
28
27
  __exportStar(require("./autopilotapi.guard"), exports);
29
- var propertyvalues_1 = require("./propertyvalues");
30
- Object.defineProperty(exports, "PropertyValues", { enumerable: true, get: function () { return propertyvalues_1.PropertyValues; } });
28
+ __exportStar(require("./propertyvalues"), exports);
29
+ __exportStar(require("./brand"), exports);
30
+ __exportStar(require("./streambundle"), exports);
31
+ __exportStar(require("./subscriptionmanager"), exports);
32
+ var SKVersion;
33
+ (function (SKVersion) {
34
+ SKVersion["v1"] = "v1";
35
+ SKVersion["v2"] = "v2";
36
+ })(SKVersion || (exports.SKVersion = SKVersion = {}));
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,8CAA2B;AAC3B,2CAAwB;AACxB,gDAA6B;AAC7B,kDAA+B;AAC/B,iDAA8B;AAC9B,6CAA0B;AAC1B,2CAAwB;AACxB,iDAA8B;AAC9B,uDAAoC;AACpC,mDAAgC;AAChC,0CAAuB;AACvB,iDAA8B;AAC9B,wDAAqC;AAoBrC,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,sBAAS,CAAA;IACT,sBAAS,CAAA;AACX,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB"}
@@ -0,0 +1,171 @@
1
+ import { IRouter } from 'express';
2
+ import { ServerAPI } from './serverapi';
3
+ /**
4
+ * A plugin constructor is the interface that all plugins must export.
5
+ * It is called by the server when the server is starting up.
6
+ */
7
+ export type PluginConstructor = (app: ServerAPI) => Plugin;
8
+ /**
9
+ * Plugins are components that extend functionality of the server and can be installed via the Signal K AppStore.
10
+ *
11
+ * A plugin can:
12
+ * - Interact with the {@link ServerAPI}, including the full data model.
13
+ * - Provide a [webapp interface](../../../docs/develop/webapps.md).
14
+ * - Provide access to resources such as `route,` `waypoint`,`POI`, or `charts` via the _[Resources API](../../../docs/develop/rest-api/resources_api.md)_ by operating as a _[Resources Provider Plugin](../../../docs/develop/plugins/resource_provider_plugins.md)_.
15
+ * - Perform common autopilot operations by acting as an [Autopilot Provider Plugin](../../../docs/develop/plugins/autopilot_provider_plugins.md)
16
+ * - Perform course calculations by integrating with the [Course API](../../../docs/develop/rest-api/course_api.md).
17
+ * - process requests
18
+ *
19
+ * > [!WARNING]
20
+ * > Typing is incomplete. If you find a missing or inaccurate type, please [report it](https://github.com/SignalK/signalk-server/issues/1917).
21
+ *
22
+ * @example
23
+ *
24
+ * Signal K server plugins are NodeJs `javascript` or `typescript` projects that return an object that implements this interface.
25
+ *
26
+ * ```typescript
27
+ * import { Plugin, ServerAPI } from '@signalk/server-api';
28
+ *
29
+ * module.exports = (app: ServerAPI): Plugin => {
30
+ * const plugin: Plugin = {
31
+ * id: 'my-signalk-plugin',
32
+ * name: 'My Great Plugin',
33
+ * start: (settings, restartPlugin) => {
34
+ * // start up code goes here.
35
+ * },
36
+ * stop: () => {
37
+ * // shutdown code goes here.
38
+ * },
39
+ * schema: () => {
40
+ * properties: {
41
+ * // plugin configuration goes here
42
+ * }
43
+ * }
44
+ * };
45
+ *
46
+ * return plugin;
47
+ * }
48
+ * ```
49
+ * @see [Developing Server Plugins](../../../docs/develop/plugins/README.md)
50
+ */
51
+ export interface Plugin {
52
+ /**
53
+ * Used to identify the plugin in the server, for example
54
+ * when storing the plugin's configuration and in http endpoints.
55
+ *
56
+ * @category Identification
57
+ */
58
+ id: string;
59
+ /**
60
+ * Human oriented name for the plugin. This is used in the server's plugin configuration UI.
61
+ * @category Identification
62
+ */
63
+ name: string;
64
+ description?: string;
65
+ /**
66
+ * This function is called to start the plugin.
67
+ *
68
+ * It is called:
69
+ * - during server startup for enabled plugins (by configuration or by default)
70
+ * - when a plugin is enabled in the admin UI
71
+ * - after {@link stop} when the configuration of an enabled plugin has been updated in the admin UI
72
+ *
73
+ * @category Lifecycle
74
+ *
75
+ * @param config - the configuration data entered via the Plugin Config screen
76
+ * @param restart - a function that can be called by the plugin to restart itself
77
+ */
78
+ start(config: object, restart: (newConfiguration: object) => void): void;
79
+ /**
80
+ * This function is called when the plugin is disabled or after configuration changes. Use this function to "clean up"
81
+ * the resources consumed by the plugin i.e. unsubscribe from streams, stop timers / loops and close devices. If there
82
+ * are asynchronous operations in your plugin's stop implementation you should return a Promise that resolves when
83
+ * stopping is complete.
84
+ *
85
+ * @category Lifecycle
86
+ */
87
+ stop(): void | Promise<void>;
88
+ /**
89
+ * @category Configuration
90
+ */
91
+ enabledByDefault?: boolean;
92
+ /**
93
+ * A [JSON Schema](http://json-schema.org/) object describing the structure of the configuration data.
94
+ *
95
+ * This is used by the server to render the plugin's configuration screen in the Admin UI.
96
+ * The configuration data is stored by the server in `$SIGNALK_NODE_CONFIG_DIR/plugin-config-data/<plugin-name>.json`. _(Default value of `SIGNALK_NODE_CONFIG_DIR` is `$HOME/.signalk`.)_
97
+ *
98
+ * @example
99
+ * ```javascript
100
+ * plugin.schema = {
101
+ * type: 'object',
102
+ * required: ['some_string', 'some_other_number'],
103
+ * properties: {
104
+ * some_string: {
105
+ * type: 'string',
106
+ * title: 'Some string that the plugin needs'
107
+ * },
108
+ * some_number: {
109
+ * type: 'number',
110
+ * title: 'Some number that the plugin needs',
111
+ * default: 60
112
+ * },
113
+ * some_other_number: {
114
+ * type: 'number',
115
+ * title: 'Some other number that the plugin needs',
116
+ * default: 5
117
+ * }
118
+ * }
119
+ * };
120
+ * ```
121
+ *
122
+ * @category Configuration
123
+ */
124
+ schema: object | (() => object);
125
+ /**
126
+ * A [uiSchema object](https://github.com/mozilla-services/react-jsonschema-form#the-uischema-object) which is used to control how the user interface is rendered in the Admin UI.
127
+ *
128
+ * For more information, see [react-jsonschema-form-extras](https://github.com/RxNT/react-jsonschema-form-extras#collapsible-fields-collapsible)
129
+ *
130
+ * @example
131
+ * Make all data in an object called 'myObject' collapsible:
132
+ * ```javascript
133
+ * uiSchema['myObject'] = {
134
+ * 'ui:field': 'collapsible',
135
+ * collapse: {
136
+ * field: 'ObjectField',
137
+ * wrapClassName: 'panel-group'
138
+ * }
139
+ * }
140
+ * ```
141
+ *
142
+ * @category Configuration
143
+ */
144
+ uiSchema?: object | (() => object);
145
+ /**
146
+ * Plugins can implement this method to provide an API. Like {@link start} and {@link stop}, this function will be
147
+ * called during plugin startup with an [Express](https://expressjs.com/) router as the parameter.
148
+ *
149
+ * The router will be mounted at `/plugins/<pluginId>` and you can use standard _Express_ _(`.get()` `.post()` `.use()`, etc)_ methods to add HTTP path handlers.
150
+ *
151
+ * > [!note]
152
+ * > `GET /plugins/<pluginid>` and `POST /plugins/<pluginid>/configure` are reserved by server (see below).
153
+ *
154
+ * It should be noted that _Express_ does not have a public API for deregistering subrouters, so {@link stop} does not do anything to the router.
155
+ *
156
+ * If a plugin does provide an API, it is strongly recommended that it implement {@link getOpenApi} to document its
157
+ * operation. Doing so promotes interoperability with other plugins / webapps by making it easy to find and use the
158
+ * functionality built into plugins. It is also a means to avoid duplication, promote reuse and the possibility of
159
+ * including them in the Signal K specification.
160
+ *
161
+ * @category Rest API
162
+ *
163
+ * @param router
164
+ * @returns
165
+ */
166
+ registerWithRouter?(router: IRouter): void;
167
+ getOpenApi?: () => object;
168
+ statusMessage?: () => string | void;
169
+ signalKApiRoutes?(router: IRouter): IRouter;
170
+ }
171
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,SAAS,KAAK,MAAM,CAAA;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,WAAW,MAAM;IACrB;;;;;OAKG;IACH,EAAE,EAAE,MAAM,CAAA;IAEV;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,gBAAgB,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAAA;IAExE;;;;;;;OAOG;IACH,IAAI,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5B;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,MAAM,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAA;IAE/B;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAA;IAElC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,kBAAkB,CAAC,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAA;IAE1C,UAAU,CAAC,EAAE,MAAM,MAAM,CAAA;IAEzB,aAAa,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,CAAA;IAEnC,gBAAgB,CAAC,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAA;CAC5C"}
package/dist/plugin.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":""}
@@ -1,3 +1,47 @@
1
+ /**
2
+ * The _PropertyValues_ mechanism provides a means for passing configuration type values between different components running in the server process such as plugins and input connections.
3
+ *
4
+ * A plugin can both *emit* values and *listen* for values emitted by others.
5
+ *
6
+ * The difference between the _PropertyValues_ mechanism and _Event Emitters_ in NodeJs is that when `onPropertyValues` is called, the `callback()` function will be invoked and passed an array containing all of the previous values for that _property name_, starting with the initial value of `undefined`. If no values have been emitted for that _property name_ the callback will be invoked with a value of `undefined`.
7
+ * *
8
+ * **PropertyValue** has the following structure:
9
+ * ```typescript
10
+ * interface PropertyValue {
11
+ * timestamp: number // millis
12
+ * setter: string // plugin id, server, provider id
13
+ * name: string
14
+ * value: any
15
+ * }
16
+ * ```
17
+ *
18
+ * _Note that the value can be also a function._
19
+ *
20
+ * This mechanism allows plugins to _offer_ extensions via _"Well Known Properties"_, for example
21
+ * - additional [NMEA0183 sentence parsers for custom sentences](https://github.com/SignalK/nmea0183-signalk/pull/193) via `nmea0183sentenceParser`
22
+ * - additional PGN definitions for propietary or custom PGNs
23
+ *
24
+ * Code handling incoming _PropertyValues_ should be fully reactive due to:
25
+ * - Plugins being able to emit _PropertyValues_ when they activated and / or started
26
+ * - There being no defined load / startup order for plugins / connections.
27
+ *
28
+ * So even if all plugins / connections emit during their startup, you cannot depend on a specific _PropertyValue_ being available. It may be present when your code starts or it may arrive after your code has started.
29
+ *
30
+ *
31
+ * **Note: The _PropertyValues_ mechanism is not intended to be used for data passing on a regular basis, as the total history makes it a potential memory leak.**
32
+ *
33
+ * To safeguard against a component accidentally emitting regularly, via a fixed upper bound is enforced for the value array per _property name_. New values will be ignored if the upper bound is reached and are logged as errors.
34
+ */
35
+ export interface PropertyValuesEmitter {
36
+ /**
37
+ * @category Property Values
38
+ */
39
+ emitPropertyValue(name: string, value: any): void;
40
+ /**
41
+ * @category Property Values
42
+ */
43
+ onPropertyValues(name: string, cb: PropertyValuesCallback): Unsubscribe;
44
+ }
1
45
  export interface PropertyValue {
2
46
  timestamp: number;
3
47
  setter: string;
@@ -13,3 +57,9 @@ export declare class PropertyValues {
13
57
  emitPropertyValue(pv: PropertyValue): void;
14
58
  private getStreamTuple;
15
59
  }
60
+ /**
61
+ * @inline
62
+ */
63
+ type Unsubscribe = () => void;
64
+ export {};
65
+ //# sourceMappingURL=propertyvalues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"propertyvalues.d.ts","sourceRoot":"","sources":["../src/propertyvalues.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IAEH,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAA;IAEjD;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,sBAAsB,GAAG,WAAW,CAAA;CACxE;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IAEZ,KAAK,EAAE,GAAG,CAAA;CACX;AAED,MAAM,MAAM,sBAAsB,GAAG,CACnC,iBAAiB,EAAE,aAAa,EAAE,KAC/B,IAAI,CAAA;AAQT,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAET;IACN,OAAO,CAAC,KAAK,CAAI;IAEjB,MAAM,CAAC,QAAQ,CAAC,gBAAgB,QAAO;IAEvC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,sBAAsB,GAAG,MAAM,IAAI;IAI1E,iBAAiB,CAAC,EAAE,EAAE,aAAa;IAWnC,OAAO,CAAC,cAAc;CAsBvB;AAED;;GAEG;AACH,KAAK,WAAW,GAAG,MAAM,IAAI,CAAA"}
@@ -4,44 +4,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.PropertyValues = void 0;
7
- var baconjs_1 = __importDefault(require("baconjs"));
8
- var PropertyValues = /** @class */ (function () {
9
- function PropertyValues() {
10
- this.streams = {};
11
- this.count = 0;
12
- }
13
- PropertyValues.prototype.onPropertyValues = function (propName, cb) {
7
+ const baconjs_1 = __importDefault(require("baconjs"));
8
+ class PropertyValues {
9
+ streams = {};
10
+ count = 0;
11
+ static MAX_VALUES_COUNT = 1000;
12
+ onPropertyValues(propName, cb) {
14
13
  return this.getStreamTuple(propName).stream.onValue(cb);
15
- };
16
- PropertyValues.prototype.emitPropertyValue = function (pv) {
14
+ }
15
+ emitPropertyValue(pv) {
17
16
  if (this.count >= PropertyValues.MAX_VALUES_COUNT) {
18
- throw new Error("Max PropertyValues count ".concat(PropertyValues.MAX_VALUES_COUNT, " exceeded trying to emit ").concat(JSON.stringify(pv)));
17
+ throw new Error(`Max PropertyValues count ${PropertyValues.MAX_VALUES_COUNT} exceeded trying to emit ${JSON.stringify(pv)}`);
19
18
  }
20
19
  this.getStreamTuple(pv.name).bus.push(pv);
21
- };
22
- PropertyValues.prototype.getStreamTuple = function (propName) {
23
- var _this = this;
24
- var streamTuple = this.streams[propName];
20
+ }
21
+ getStreamTuple(propName) {
22
+ let streamTuple = this.streams[propName];
25
23
  if (!streamTuple) {
26
- var bus = new baconjs_1.default.Bus();
27
- var stream = bus
28
- .scan([], function (acc, v) {
24
+ const bus = new baconjs_1.default.Bus();
25
+ const stream = bus.scan([], (acc, v) => {
29
26
  acc.push(v);
30
- _this.count++;
27
+ this.count++;
31
28
  return acc;
32
- })
33
- .toProperty();
29
+ });
34
30
  streamTuple = {
35
- bus: bus,
36
- stream: stream
31
+ bus,
32
+ stream
37
33
  };
38
- streamTuple.stream.subscribe(function () { return ({}); }); // start the stream eagerly
34
+ streamTuple.stream.subscribe(() => ({})); // start the stream eagerly
39
35
  streamTuple.bus.push(undefined);
40
36
  this.streams[propName] = streamTuple;
41
37
  }
42
38
  return streamTuple;
43
- };
44
- PropertyValues.MAX_VALUES_COUNT = 1000;
45
- return PropertyValues;
46
- }());
39
+ }
40
+ }
47
41
  exports.PropertyValues = PropertyValues;
42
+ //# sourceMappingURL=propertyvalues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"propertyvalues.js","sourceRoot":"","sources":["../src/propertyvalues.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA2B;AAmE3B,MAAa,cAAc;IACjB,OAAO,GAEX,EAAE,CAAA;IACE,KAAK,GAAG,CAAC,CAAA;IAEjB,MAAM,CAAU,gBAAgB,GAAG,IAAI,CAAA;IAEvC,gBAAgB,CAAC,QAAgB,EAAE,EAA0B;QAC3D,OAAO,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IACzD,CAAC;IAED,iBAAiB,CAAC,EAAiB;QACjC,IAAI,IAAI,CAAC,KAAK,IAAI,cAAc,CAAC,gBAAgB,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CACb,4BACE,cAAc,CAAC,gBACjB,4BAA4B,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CACjD,CAAA;QACH,CAAC;QACD,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC3C,CAAC;IAEO,cAAc,CAAC,QAAgB;QACrC,IAAI,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QACxC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,GAAG,GAAG,IAAI,iBAAK,CAAC,GAAG,EAAsC,CAAA;YAC/D,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CACrB,EAAE,EACF,CAAC,GAAkC,EAAE,CAA4B,EAAE,EAAE;gBACnE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;gBACX,IAAI,CAAC,KAAK,EAAE,CAAA;gBACZ,OAAO,GAAG,CAAA;YACZ,CAAC,CACF,CAAA;YACD,WAAW,GAAG;gBACZ,GAAG;gBACH,MAAM;aACP,CAAA;YACD,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA,CAAC,2BAA2B;YACpE,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YAC/B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,WAAW,CAAA;QACtC,CAAC;QACD,OAAO,WAAW,CAAA;IACpB,CAAC;;AA5CH,wCA6CC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=propertyvalues.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"propertyvalues.test.d.ts","sourceRoot":"","sources":["../src/propertyvalues.test.ts"],"names":[],"mappings":""}