@signalk/server-api 2.6.1 → 2.7.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/dist/autopilotapi.d.ts +241 -0
- package/dist/autopilotapi.d.ts.map +1 -0
- package/dist/autopilotapi.guard.d.ts +1 -0
- package/dist/autopilotapi.guard.d.ts.map +1 -0
- package/dist/autopilotapi.guard.js +3 -3
- package/dist/autopilotapi.guard.js.map +1 -0
- package/dist/autopilotapi.js +5 -8
- package/dist/autopilotapi.js.map +1 -0
- package/dist/brand.d.ts +24 -0
- package/dist/brand.d.ts.map +1 -0
- package/dist/{types.js → brand.js} +1 -1
- package/dist/brand.js.map +1 -0
- package/dist/course.d.ts +40 -0
- package/dist/course.d.ts.map +1 -0
- package/dist/course.js +3 -0
- package/dist/course.js.map +1 -0
- package/dist/coursetypes.d.ts +10 -11
- package/dist/coursetypes.d.ts.map +1 -0
- package/dist/coursetypes.js +1 -0
- package/dist/coursetypes.js.map +1 -0
- package/dist/deltas.d.ts +26 -19
- package/dist/deltas.d.ts.map +1 -0
- package/dist/deltas.js +6 -5
- package/dist/deltas.js.map +1 -0
- package/dist/deltas.test.d.ts +2 -0
- package/dist/deltas.test.d.ts.map +1 -0
- package/dist/features.d.ts +65 -0
- package/dist/features.d.ts.map +1 -0
- package/dist/features.js +3 -0
- package/dist/features.js.map +1 -0
- package/dist/index.d.ts +19 -134
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -8
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +171 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +3 -0
- package/dist/plugin.js.map +1 -0
- package/dist/propertyvalues.d.ts +50 -0
- package/dist/propertyvalues.d.ts.map +1 -0
- package/dist/propertyvalues.js +22 -27
- package/dist/propertyvalues.js.map +1 -0
- package/dist/propertyvalues.test.d.ts +2 -0
- package/dist/propertyvalues.test.d.ts.map +1 -0
- package/dist/resourcesapi.d.ts +336 -15
- package/dist/resourcesapi.d.ts.map +1 -0
- package/dist/resourcesapi.js +2 -3
- package/dist/resourcesapi.js.map +1 -0
- package/dist/resourcetypes.d.ts +9 -3
- package/dist/resourcetypes.d.ts.map +1 -0
- package/dist/resourcetypes.js +1 -0
- package/dist/resourcetypes.js.map +1 -0
- package/dist/serverapi.d.ts +369 -0
- package/dist/serverapi.d.ts.map +1 -0
- package/dist/serverapi.js +3 -0
- package/dist/serverapi.js.map +1 -0
- package/dist/streambundle.d.ts +148 -0
- package/dist/streambundle.d.ts.map +1 -0
- package/dist/streambundle.js +3 -0
- package/dist/streambundle.js.map +1 -0
- package/dist/subscriptionmanager.d.ts +84 -0
- package/dist/subscriptionmanager.d.ts.map +1 -0
- package/dist/subscriptionmanager.js +3 -0
- package/dist/subscriptionmanager.js.map +1 -0
- package/package.json +7 -22
- package/tsconfig.json +2 -72
- package/tsconfig.tsbuildinfo +1 -1
- package/typedoc.json +4 -0
- package/dist/types.d.ts +0 -7
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { SKVersion, AutopilotProviderRegistry, Features, PropertyValuesEmitter, ResourceProviderRegistry, Delta } from '.';
|
|
2
|
+
import { CourseApi } from './course';
|
|
3
|
+
import { StreamBundle } from './streambundle';
|
|
4
|
+
import { SubscriptionManager } from './subscriptionmanager';
|
|
5
|
+
/**
|
|
6
|
+
* SignalK server provides an interface to allow {@link Plugin | Plugins } to:
|
|
7
|
+
*
|
|
8
|
+
* - Discover Features.
|
|
9
|
+
* - Access / update the full data model
|
|
10
|
+
* - send / receive deltas (updates)
|
|
11
|
+
* - Interact with APIs
|
|
12
|
+
* - Expose HTTP endpoints
|
|
13
|
+
*
|
|
14
|
+
* These functions are available via the app object passed to the plugin when it is invoked.
|
|
15
|
+
*
|
|
16
|
+
* > [!WARNING]
|
|
17
|
+
* > Typing is incomplete. If you find a missing or inaccurate type, please [report it](https://github.com/SignalK/signalk-server/issues/1917).
|
|
18
|
+
*/
|
|
19
|
+
export interface ServerAPI extends PropertyValuesEmitter, ResourceProviderRegistry, AutopilotProviderRegistry, Features, CourseApi, SelfIdentity {
|
|
20
|
+
/**
|
|
21
|
+
* Returns the entry for the provided path starting from `vessels.self` in the full data model.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* let uuid = app.getSelfPath('uuid');
|
|
26
|
+
* // Note: This is synonymous with app.getPath('vessels.self.uuid')
|
|
27
|
+
*
|
|
28
|
+
* app.debug(uuid);
|
|
29
|
+
* // urn:mrn:signalk:uuid:a9d2c3b1-611b-4b00-8628-0b89d014ed60
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @category Data Model
|
|
33
|
+
*/
|
|
34
|
+
getSelfPath(path: string): any;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the entry for the provided path starting from the `root` of the full data model.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```javascript
|
|
40
|
+
* let baseStations = app.getPath('shore.basestations');
|
|
41
|
+
*
|
|
42
|
+
* // baseStations:
|
|
43
|
+
* {
|
|
44
|
+
* 'urn:mrn:imo:mmsi:2766140': {
|
|
45
|
+
* url: 'basestations',
|
|
46
|
+
* navigation: { position: {latitude: 45.2, longitude: 76.4} },
|
|
47
|
+
* mmsi: '2766140'
|
|
48
|
+
* },
|
|
49
|
+
* 'urn:mrn:imo:mmsi:2766160': {
|
|
50
|
+
* url: 'basestations',
|
|
51
|
+
* navigation: { position: {latitude: 46.9, longitude: 72.22} },
|
|
52
|
+
* mmsi: '2766160'
|
|
53
|
+
* }
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @category Data Model
|
|
58
|
+
*/
|
|
59
|
+
getPath(path: string): any;
|
|
60
|
+
/**
|
|
61
|
+
* @category Data Model
|
|
62
|
+
*/
|
|
63
|
+
getMetadata(path: string): Metadata | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* @category Data Model
|
|
66
|
+
*/
|
|
67
|
+
putSelfPath(aPath: string, value: any, updateCb: () => void): Promise<any>;
|
|
68
|
+
/**
|
|
69
|
+
* @category Data Model
|
|
70
|
+
*/
|
|
71
|
+
putPath(aPath: string, value: number | string | object | boolean, updateCb: (err?: Error) => void, source: string): Promise<any>;
|
|
72
|
+
/**
|
|
73
|
+
* @category Data Model
|
|
74
|
+
*/
|
|
75
|
+
streambundle: StreamBundle;
|
|
76
|
+
/**
|
|
77
|
+
* @see [Processing data from the server](../../../docs/develop/plugins/deltas.md#subscribing-to-deltas)
|
|
78
|
+
* @category Data Model
|
|
79
|
+
*/
|
|
80
|
+
subscriptionmanager: SubscriptionManager;
|
|
81
|
+
queryRequest(requestId: string): Promise<any>;
|
|
82
|
+
/**
|
|
83
|
+
* @category Status and Debugging
|
|
84
|
+
*/
|
|
85
|
+
error(msg: string): void;
|
|
86
|
+
/**
|
|
87
|
+
* Log debug messages.
|
|
88
|
+
*
|
|
89
|
+
* This function exposes the `debug` method from the [debug module](https://www.npmjs.com/package/debug).
|
|
90
|
+
* The npm module name is used as the debug name.
|
|
91
|
+
*
|
|
92
|
+
* `app.debug()` can take any type and will serialize it before outputting.
|
|
93
|
+
*
|
|
94
|
+
* > [!note]
|
|
95
|
+
* > Do not use `debug` from the debug module directly! Using `app.debug()` provided by the server ensures that the plugin taps into the server's debug logging system, including the helper switches in Admin UI's Server Log page.
|
|
96
|
+
*
|
|
97
|
+
* @category Status and Debugging
|
|
98
|
+
*/
|
|
99
|
+
debug(msg: string): void;
|
|
100
|
+
/**
|
|
101
|
+
* Register a function to intercept all delta messages _before_ they are processed by the server.
|
|
102
|
+
*
|
|
103
|
+
* The callback function should call `next(delta)` with either:
|
|
104
|
+
* - A modified delta (if it wants to alter the incoming delta)
|
|
105
|
+
* - With the original delta to process it normally.
|
|
106
|
+
*
|
|
107
|
+
* > [!important]
|
|
108
|
+
* > Not calling `next(delta)` will cause the incoming delta to be dropped and will only show in delta statistics.
|
|
109
|
+
*
|
|
110
|
+
* Other, non-delta messages produced by provider pipe elements are emitted normally.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```javascript
|
|
114
|
+
* app.registerDeltaInputHandler((delta, next) => {
|
|
115
|
+
* delta.updates.forEach(update => {
|
|
116
|
+
* update.values.forEach(pathValue => {
|
|
117
|
+
* if(pathValue.startsWith("foo")) {
|
|
118
|
+
* pathValue.path = "bar"
|
|
119
|
+
* }
|
|
120
|
+
* })
|
|
121
|
+
* })
|
|
122
|
+
* next(delta)
|
|
123
|
+
* });
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* @category Data Model
|
|
127
|
+
*/
|
|
128
|
+
registerDeltaInputHandler(handler: DeltaInputHandler): void;
|
|
129
|
+
/**
|
|
130
|
+
* Set the current status of the plugin that is displayed in the plugin configuration UI and the Dashboard.
|
|
131
|
+
*
|
|
132
|
+
* The `msg` parameter should be a short text message describing the current status of the plugin.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```javascript
|
|
136
|
+
* app.setPluginStatus('Initializing');
|
|
137
|
+
* // Do something
|
|
138
|
+
* app.setPluginStatus('Done initializing');
|
|
139
|
+
* ```
|
|
140
|
+
*
|
|
141
|
+
* _Note: Replaces deprecated `setProviderStatus()`_
|
|
142
|
+
*
|
|
143
|
+
* @category Status and Debugging
|
|
144
|
+
*/
|
|
145
|
+
setPluginStatus(msg: string): void;
|
|
146
|
+
/**
|
|
147
|
+
* Set the current error status of the plugin that is displayed in the plugin configuration UI and the Dashboard.
|
|
148
|
+
*
|
|
149
|
+
* The `msg` parameter should be a short text message describing the current status of the plugin.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```javascript
|
|
153
|
+
* app.setPluginError('Error connecting to database');
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* _Note: Replaces deprecated `setProviderError()`_
|
|
157
|
+
*
|
|
158
|
+
* @category Status and Debugging
|
|
159
|
+
*/
|
|
160
|
+
setPluginError(msg: string): void;
|
|
161
|
+
/**
|
|
162
|
+
* Emit a delta message.
|
|
163
|
+
*
|
|
164
|
+
* _Note: These deltas are handled by the server in the same way as any other incoming deltas._
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```javascript
|
|
168
|
+
* app.handleMessage('my-signalk-plugin', {
|
|
169
|
+
* updates: [
|
|
170
|
+
* {
|
|
171
|
+
* values: [
|
|
172
|
+
* {
|
|
173
|
+
* path: 'navigation.courseOverGroundTrue',
|
|
174
|
+
* value: 1.0476934
|
|
175
|
+
* }
|
|
176
|
+
* ]
|
|
177
|
+
* }
|
|
178
|
+
* ]
|
|
179
|
+
* });
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
* Plugins emitting deltas that use Signal K v2 paths (like the [Course API](http://localhost:3000/admin/openapi/?urls.primaryName=course) paths) should call `handleMessage` with the optional `skVersion` parameter set to `v2`. This prevents v2 API data getting mixed in v1 paths' data in full data model & the v1 http API.
|
|
183
|
+
*
|
|
184
|
+
* Omitting the `skVersion` parameter will cause the delta to be sent as `v1`.
|
|
185
|
+
*
|
|
186
|
+
* @param skVersion Optional parameter to specify the Signal K version of the delta.
|
|
187
|
+
* @category Data Model
|
|
188
|
+
*/
|
|
189
|
+
handleMessage(id: string, msg: Partial<Delta>, skVersion?: SKVersion): void;
|
|
190
|
+
/**
|
|
191
|
+
* Save changes to the plugin's configuration options.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```javascript
|
|
195
|
+
* let options = {
|
|
196
|
+
* myConfigValue = 'Something the plugin calculated'
|
|
197
|
+
* };
|
|
198
|
+
*
|
|
199
|
+
* app.savePluginOptions(options, () => {app.debug('Plugin options saved')});
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
* @category Configuration
|
|
203
|
+
*/
|
|
204
|
+
savePluginOptions(configuration: object, cb: (err: NodeJS.ErrnoException | null) => void): void;
|
|
205
|
+
/**
|
|
206
|
+
* Read the stored plugin configuration options.
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```javascript
|
|
210
|
+
* let options = app.readPluginOptions();
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
213
|
+
* @category Configuration
|
|
214
|
+
*/
|
|
215
|
+
readPluginOptions(): object;
|
|
216
|
+
/**
|
|
217
|
+
* Returns the full path of the directory where the plugin can persist its internal data, e.g. data files, etc.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```javascript
|
|
221
|
+
* let myDataFile = require('path').join( app.getDataDirPath(), 'somedatafile.ext')
|
|
222
|
+
* ```
|
|
223
|
+
* @category Configuration
|
|
224
|
+
*/
|
|
225
|
+
getDataDirPath(): string;
|
|
226
|
+
/**
|
|
227
|
+
* Register a handler to action [`PUT`](http://signalk.org/specification/1.3.0/doc/put.html) requests for a specific path.
|
|
228
|
+
*
|
|
229
|
+
* The action handler can handle the request synchronously or asynchronously.
|
|
230
|
+
*
|
|
231
|
+
* The `callback` parameter should be a function which accepts the following arguments:
|
|
232
|
+
* - `context`
|
|
233
|
+
* - `path`
|
|
234
|
+
* - `value`
|
|
235
|
+
* - `callback`
|
|
236
|
+
*
|
|
237
|
+
* For synchronous actions, the handler must return a value describing the response of the request:
|
|
238
|
+
*
|
|
239
|
+
* ```javascript
|
|
240
|
+
* {
|
|
241
|
+
* state: 'COMPLETED',
|
|
242
|
+
* statusCode: 200
|
|
243
|
+
* }
|
|
244
|
+
* ```
|
|
245
|
+
*
|
|
246
|
+
* or
|
|
247
|
+
*
|
|
248
|
+
* ```javascript
|
|
249
|
+
* {
|
|
250
|
+
* state:'COMPLETED',
|
|
251
|
+
* statusCode: 400,
|
|
252
|
+
* message:'Some Error Message'
|
|
253
|
+
* }
|
|
254
|
+
* ```
|
|
255
|
+
*
|
|
256
|
+
* The `statusCode` value can be any valid HTTP response code.
|
|
257
|
+
*
|
|
258
|
+
* For asynchronous actions, that may take considerable time to complete and the requester should not be kept waiting for the result, the handler must return:
|
|
259
|
+
*
|
|
260
|
+
* ```javascript
|
|
261
|
+
* { state: 'PENDING' }
|
|
262
|
+
* ```
|
|
263
|
+
*
|
|
264
|
+
* When the action has completed the handler should call the `callback` function with the result:
|
|
265
|
+
*
|
|
266
|
+
* ```javascript
|
|
267
|
+
* callback({ state: 'COMPLETED', statusCode: 200 })
|
|
268
|
+
* ```
|
|
269
|
+
* or
|
|
270
|
+
*
|
|
271
|
+
* ```javascript
|
|
272
|
+
* callback({
|
|
273
|
+
* state:'COMPLETED',
|
|
274
|
+
* statusCode: 400,
|
|
275
|
+
* message:'Some Error Message'
|
|
276
|
+
* })
|
|
277
|
+
* ```
|
|
278
|
+
*
|
|
279
|
+
* _Example: Synchronous response:_
|
|
280
|
+
* ```javascript
|
|
281
|
+
* function myActionHandler(context, path, value, callback) {
|
|
282
|
+
* if(doSomething(context, path, value)){
|
|
283
|
+
* return { state: 'COMPLETED', statusCode: 200 };
|
|
284
|
+
* } else {
|
|
285
|
+
* return { state: 'COMPLETED', statusCode: 400 };
|
|
286
|
+
* }
|
|
287
|
+
* }
|
|
288
|
+
*
|
|
289
|
+
* plugin.start = (options) => {
|
|
290
|
+
* app.registerPutHandler('vessels.self', 'some.path', myActionHandler, 'somesource.1');
|
|
291
|
+
* }
|
|
292
|
+
* ```
|
|
293
|
+
*
|
|
294
|
+
* _Example: Asynchronous response:_
|
|
295
|
+
* ```javascript
|
|
296
|
+
* function myActionHandler(context, path, value, callback) {
|
|
297
|
+
*
|
|
298
|
+
* doSomethingAsync(context, path, value, (result) =>{
|
|
299
|
+
* if(result) {
|
|
300
|
+
* callback({ state: 'COMPLETED', result: 200 })
|
|
301
|
+
* } else {
|
|
302
|
+
* callback({ state: 'COMPLETED', result: 400 })
|
|
303
|
+
* }
|
|
304
|
+
* });
|
|
305
|
+
*
|
|
306
|
+
* return { state: 'PENDING' };
|
|
307
|
+
* }
|
|
308
|
+
*
|
|
309
|
+
* plugin.start = (options) => {
|
|
310
|
+
* app.registerPutHandler('vessels.self', 'some.path', myActionHandler);
|
|
311
|
+
* }
|
|
312
|
+
* ```
|
|
313
|
+
*/
|
|
314
|
+
registerPutHandler(context: string, path: string, callback: () => void, source: string): void;
|
|
315
|
+
registerActionHandler(context: string, path: string, callback: () => void, source: string): void;
|
|
316
|
+
registerHistoryProvider(provider: {
|
|
317
|
+
hasAnydata: (options: object, cb: (hasResults: boolean) => void) => void;
|
|
318
|
+
getHistory: (date: Date, path: string, cb: (deltas: object[]) => void) => void;
|
|
319
|
+
streamHistory: (spark: any, options: object, onDelta: (delta: object) => void) => void;
|
|
320
|
+
}): void;
|
|
321
|
+
/**
|
|
322
|
+
* Returns Ports object which contains information about the serial ports available on the machine.
|
|
323
|
+
*
|
|
324
|
+
* @category Serial Ports
|
|
325
|
+
*/
|
|
326
|
+
getSerialPorts(): Promise<Ports>;
|
|
327
|
+
/**
|
|
328
|
+
* Report to the server that the plugin has sent data to other hosts, which will update the output message rate and
|
|
329
|
+
* icon in the Dashboard.
|
|
330
|
+
*
|
|
331
|
+
* _Note: This function is for use when the plugin is sending data to hosts other than the Signal K server (e.g.
|
|
332
|
+
* network packets, http requests or messages sent to a broker)._
|
|
333
|
+
*
|
|
334
|
+
* _**This function should NOT be used for deltas that the plugin sends with `handleMessage()`!**_
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```javascript
|
|
338
|
+
* app.reportOutputMessages(54);
|
|
339
|
+
* ```
|
|
340
|
+
*
|
|
341
|
+
* @param count - number of handled messages between the last
|
|
342
|
+
* call and this one. If omitted the call will count as one output
|
|
343
|
+
* message.
|
|
344
|
+
*
|
|
345
|
+
* @category Status and Debugging
|
|
346
|
+
*/
|
|
347
|
+
reportOutputMessages(count?: number): void;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* @deprecated Use {@link ServerAPI} instead.
|
|
351
|
+
*/
|
|
352
|
+
export type PluginServerApp = ServerAPI;
|
|
353
|
+
export type DeltaInputHandler = (delta: Delta, next: (delta: Delta) => void) => void;
|
|
354
|
+
export interface Ports {
|
|
355
|
+
byId: string[];
|
|
356
|
+
byPath: string[];
|
|
357
|
+
byOpenPlotter: string[];
|
|
358
|
+
serialports: any;
|
|
359
|
+
}
|
|
360
|
+
export interface SelfIdentity {
|
|
361
|
+
selfType: string;
|
|
362
|
+
selfId: string;
|
|
363
|
+
selfContext: string;
|
|
364
|
+
}
|
|
365
|
+
export interface Metadata {
|
|
366
|
+
units?: string;
|
|
367
|
+
description?: string;
|
|
368
|
+
}
|
|
369
|
+
//# sourceMappingURL=serverapi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverapi.d.ts","sourceRoot":"","sources":["../src/serverapi.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,yBAAyB,EACzB,QAAQ,EACR,qBAAqB,EACrB,wBAAwB,EACxB,KAAK,EACN,MAAM,GAAG,CAAA;AACV,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAE3D;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,SACf,SAAQ,qBAAqB,EAC3B,wBAAwB,EACxB,yBAAyB,EACzB,QAAQ,EACR,SAAS,EACT,YAAY;IACd;;;;;;;;;;;;;OAaG;IAEH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAA;IAE9B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IAEH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAA;IAE1B;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAA;IAE/C;;OAEG;IAEH,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CA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E,MAAM,EAAE,CAAA;IACd,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,aAAa,EAAE,MAAM,EAAE,CAAA;IAEvB,WAAW,EAAE,GAAG,CAAA;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverapi.js","sourceRoot":"","sources":["../src/serverapi.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { NormalizedDelta, Path, Value } from './deltas';
|
|
2
|
+
export interface StreamBundle {
|
|
3
|
+
/**
|
|
4
|
+
* Get a [Bacon JS 1.0](https://baconjs.github.io/api.html) stream for a Signal K path that will stream values from any context.
|
|
5
|
+
*
|
|
6
|
+
* Stream values are objects with the following structure:
|
|
7
|
+
* ```javascript
|
|
8
|
+
* {
|
|
9
|
+
* path: ...,
|
|
10
|
+
* value: ...,
|
|
11
|
+
* context: ...,
|
|
12
|
+
* source: ...,
|
|
13
|
+
* $source: ...,
|
|
14
|
+
* timestamp: ...
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```javascript
|
|
20
|
+
* app.streambundle
|
|
21
|
+
* .getBus('navigation.position')
|
|
22
|
+
* .onValue(pos => app.debug(pos));
|
|
23
|
+
*
|
|
24
|
+
* /* output
|
|
25
|
+
* {
|
|
26
|
+
* path: 'navigation.position',
|
|
27
|
+
* value: { longitude: 24.7366117, latitude: 59.72493 },
|
|
28
|
+
* context: 'vessels.urn:mrn:imo:mmsi:2766160',
|
|
29
|
+
* source: {
|
|
30
|
+
* label: 'n2k-sample-data',
|
|
31
|
+
* type: 'NMEA2000',
|
|
32
|
+
* pgn: 129039,
|
|
33
|
+
* src: '43'
|
|
34
|
+
* },
|
|
35
|
+
* '$source': 'n2k-sample-data.43',
|
|
36
|
+
* timestamp: '2014-08-15T19:00:02.392Z'
|
|
37
|
+
* }
|
|
38
|
+
* {
|
|
39
|
+
* path: 'navigation.position',
|
|
40
|
+
* value: { longitude: 24.82365, latitude: 58.159598 },
|
|
41
|
+
* context: 'vessels.urn:mrn:imo:mmsi:2766140',
|
|
42
|
+
* source: {
|
|
43
|
+
* label: 'n2k-sample-data',
|
|
44
|
+
* type: 'NMEA2000',
|
|
45
|
+
* pgn: 129025,
|
|
46
|
+
* src: '160'
|
|
47
|
+
* },
|
|
48
|
+
* '$source': 'n2k-sample-data.160',
|
|
49
|
+
* timestamp: '2014-08-15T19:00:02.544Z'
|
|
50
|
+
* }
|
|
51
|
+
* *\/
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @param path - If it is not provided the returned stream produces values for all paths.
|
|
55
|
+
*/
|
|
56
|
+
getBus(path?: Path): Bacon.Bus<unknown, NormalizedDelta>;
|
|
57
|
+
/**
|
|
58
|
+
* Get a [Bacon JS](https://baconjs.github.io/) stream for path from the `vessels.self` context.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```javascript
|
|
62
|
+
* app.streambundle
|
|
63
|
+
* .getSelfBus('navigation.position')
|
|
64
|
+
* .onValue(pos => app.debug(pos));
|
|
65
|
+
* ```
|
|
66
|
+
* Output:
|
|
67
|
+
* ```
|
|
68
|
+
* {
|
|
69
|
+
* path: 'navigation.position',
|
|
70
|
+
* value: { longitude: 24.7366117, latitude: 59.72493 },
|
|
71
|
+
* context: 'vessels.urn:mrn:signalk:uuid:a9d2c3b1-611b-4b00-8628-0b89d014ed60',
|
|
72
|
+
* source: {
|
|
73
|
+
* label: 'n2k-sample-data',
|
|
74
|
+
* type: 'NMEA2000',
|
|
75
|
+
* pgn: 129039,
|
|
76
|
+
* src: '43'
|
|
77
|
+
* },
|
|
78
|
+
* '$source': 'n2k-sample-data.43',
|
|
79
|
+
* timestamp: '2014-08-15T19:00:02.392Z'
|
|
80
|
+
* }
|
|
81
|
+
* {
|
|
82
|
+
* path: 'navigation.position',
|
|
83
|
+
* value: { longitude: 24.7366208, latitude: 59.7249198 },
|
|
84
|
+
* context: 'vessels.urn:mrn:signalk:uuid:a9d2c3b1-611b-4b00-8628-0b89d014ed60',
|
|
85
|
+
* source: {
|
|
86
|
+
* label: 'n2k-sample-data',
|
|
87
|
+
* type: 'NMEA2000',
|
|
88
|
+
* pgn: 129025,
|
|
89
|
+
* src: '160'
|
|
90
|
+
* },
|
|
91
|
+
* '$source': 'n2k-sample-data.160',
|
|
92
|
+
* timestamp: '2014-08-15T19:00:02.544Z'
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @param path - If it is not provided the returned stream produces values for all paths.
|
|
97
|
+
*/
|
|
98
|
+
getSelfBus(path: Path): Bacon.Bus<unknown, NormalizedDelta>;
|
|
99
|
+
/**
|
|
100
|
+
* Get a [Bacon JS](https://baconjs.github.io/) stream for a path in the `vessels.self` context.
|
|
101
|
+
*
|
|
102
|
+
* > [!NOTE]
|
|
103
|
+
* > This is similar to {@link getSelfBus}, except that the stream values contain only the `value` property from the incoming deltas.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```javascript
|
|
107
|
+
* app.streambundle
|
|
108
|
+
* .getSelfStream('navigation.position')
|
|
109
|
+
* .onValue(pos => app.debug(pos));
|
|
110
|
+
* ```
|
|
111
|
+
* Output:
|
|
112
|
+
* ```
|
|
113
|
+
* my-signalk-plugin { longitude: 24.736677, latitude: 59.7250108 } +600ms
|
|
114
|
+
* my-signalk-plugin { longitude: 24.736645, latitude: 59.7249883 } +321ms
|
|
115
|
+
* my-signalk-plugin { longitude: 24.7366563, latitude: 59.7249807 } +174ms
|
|
116
|
+
* my-signalk-plugin { longitude: 24.7366563, latitude: 59.724980699999996 } +503ms
|
|
117
|
+
*
|
|
118
|
+
* @param path - If it is not provided the returned stream produces values for all paths.
|
|
119
|
+
*/
|
|
120
|
+
getSelfStream(path?: Path): Bacon.Bus<unknown, Value>;
|
|
121
|
+
/**
|
|
122
|
+
* Get a list of available full data model paths maintained by the server.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```javascript
|
|
126
|
+
* app.streambundle.getAvailablePaths();
|
|
127
|
+
* ```
|
|
128
|
+
* Returns
|
|
129
|
+
* ```json
|
|
130
|
+
* [
|
|
131
|
+
* "navigation.speedOverGround",
|
|
132
|
+
* "navigation.courseOverGroundTrue",
|
|
133
|
+
* "navigation.courseGreatCircle.nextPoint.position",
|
|
134
|
+
* "navigation.position",
|
|
135
|
+
* "navigation.gnss.antennaAltitude",
|
|
136
|
+
* "navigation.gnss.satellites",
|
|
137
|
+
* "navigation.gnss.horizontalDilution",
|
|
138
|
+
* "navigation.gnss.positionDilution",
|
|
139
|
+
* "navigation.gnss.geoidalSeparation",
|
|
140
|
+
* "navigation.gnss.type","navigation.gnss.methodQuality",
|
|
141
|
+
* "navigation.gnss.integrity",
|
|
142
|
+
* "navigation.magneticVariation",
|
|
143
|
+
* ]
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
getAvailablePaths(): Path[];
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=streambundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streambundle.d.ts","sourceRoot":"","sources":["../src/streambundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAEvD,MAAM,WAAW,YAAY;IAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoDG;IACH,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;IAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;IAE3D;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAErD;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,iBAAiB,IAAI,IAAI,EAAE,CAAA;CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streambundle.js","sourceRoot":"","sources":["../src/streambundle.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { RelativePositionOrigin } from '.';
|
|
2
|
+
import { Context, Delta, Path } from './deltas';
|
|
3
|
+
export interface SubscriptionManager {
|
|
4
|
+
subscribe(command: SubscribeMessage, unsubscribes: Unsubscribes, errorCallback: (err: unknown) => void, callback: SubscribeCallback, user?: string): void;
|
|
5
|
+
unsubscribe(msg: UnsubscribeMessage, unsubscribes: Unsubscribes): void;
|
|
6
|
+
}
|
|
7
|
+
export type SubscribeCallback = (delta: Delta) => void;
|
|
8
|
+
export type Unsubscribes = Array<() => void>;
|
|
9
|
+
/**
|
|
10
|
+
* A message to allow a client to subscribe for data updates from a signalk server
|
|
11
|
+
*
|
|
12
|
+
* @see [SignalK Specification: Subscription Protocol](https://signalk.org/specification/1.7.0/doc/subscription_protocol.html?highlight=subscribe#introduction)
|
|
13
|
+
*/
|
|
14
|
+
export interface SubscribeMessage {
|
|
15
|
+
/**
|
|
16
|
+
* The context path for all subsequent paths, usually a vessel's path.
|
|
17
|
+
*/
|
|
18
|
+
context: Context | RelativePositionOrigin;
|
|
19
|
+
/**
|
|
20
|
+
* An array of paths to subscribe to, with optional criteria
|
|
21
|
+
*/
|
|
22
|
+
subscribe: SubscriptionOptions[];
|
|
23
|
+
}
|
|
24
|
+
/** @inline */
|
|
25
|
+
type FixedPolicyOptions = {
|
|
26
|
+
/**
|
|
27
|
+
* - `fixed` - Send the last known values every `period`.
|
|
28
|
+
* - `inline` - Send all changes as fast as they are received, but no faster than `minPeriod`. With this policy the client has an immediate copy of the current state of the server.
|
|
29
|
+
*/
|
|
30
|
+
policy?: 'fixed';
|
|
31
|
+
/**
|
|
32
|
+
* The subscription will be sent every period millisecs.
|
|
33
|
+
*/
|
|
34
|
+
period?: number;
|
|
35
|
+
/**
|
|
36
|
+
* If policy=immediate or ideal, consecutive messages will be buffered until minPeriod has expired so the receiver is not swamped.
|
|
37
|
+
*/
|
|
38
|
+
minPeriod?: never;
|
|
39
|
+
};
|
|
40
|
+
/** @inline docs inherited from above */
|
|
41
|
+
type InstantPolicyOptions = {
|
|
42
|
+
policy?: 'instant';
|
|
43
|
+
minPeriod?: number;
|
|
44
|
+
period?: never;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* A path object with optional criteria to control output
|
|
48
|
+
* @inline
|
|
49
|
+
*/
|
|
50
|
+
export type SubscriptionOptions = (FixedPolicyOptions | InstantPolicyOptions) & {
|
|
51
|
+
/**
|
|
52
|
+
* The path to subscribe to.
|
|
53
|
+
*/
|
|
54
|
+
path?: Path;
|
|
55
|
+
/**
|
|
56
|
+
* The signal K format to use for the message. Only `delta` is currently supported. See [Signal K Data Model](https://signalk.org/specification/1.7.0/doc/data_model.html)
|
|
57
|
+
*/
|
|
58
|
+
format?: 'delta';
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* A message to allow a client to unsubscribe from data updates from a signalk server
|
|
62
|
+
*/
|
|
63
|
+
export interface UnsubscribeMessage {
|
|
64
|
+
/**
|
|
65
|
+
* The root path for all subsequent paths, usually a vessel's path.
|
|
66
|
+
*
|
|
67
|
+
* > [!NOTE]
|
|
68
|
+
* > Currently only `*` is supported for the context.
|
|
69
|
+
*/
|
|
70
|
+
context: '*';
|
|
71
|
+
/**
|
|
72
|
+
* An array of paths to unsubscribe from.
|
|
73
|
+
|
|
74
|
+
* > [!NOTE]
|
|
75
|
+
* > Currently only one entry is supported, and it must have `"path": "*"`.
|
|
76
|
+
*/
|
|
77
|
+
unsubscribe: [
|
|
78
|
+
{
|
|
79
|
+
path: '*';
|
|
80
|
+
}
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=subscriptionmanager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriptionmanager.d.ts","sourceRoot":"","sources":["../src/subscriptionmanager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,GAAG,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAE/C,MAAM,WAAW,mBAAmB;IAClC,SAAS,CACP,OAAO,EAAE,gBAAgB,EACzB,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,EACrC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,CAAC,EAAE,MAAM,GACZ,IAAI,CAAA;IAEP,WAAW,CAAC,GAAG,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,GAAG,IAAI,CAAA;CACvE;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;AAEtD,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,IAAI,CAAC,CAAA;AAE5C;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,OAAO,EAAE,OAAO,GAAG,sBAAsB,CAAA;IAEzC;;OAEG;IACH,SAAS,EAAE,mBAAmB,EAAE,CAAA;CACjC;AAED,cAAc;AACd,KAAK,kBAAkB,GAAG;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAEhB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,SAAS,CAAC,EAAE,KAAK,CAAA;CAClB,CAAA;AAED,wCAAwC;AACxC,KAAK,oBAAoB,GAAG;IAC1B,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,KAAK,CAAA;CACf,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAC9B,kBAAkB,GAClB,oBAAoB,CACvB,GAAG;IACF;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,CAAA;IAEX;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,OAAO,EAAE,GAAG,CAAA;IAEZ;;;;;OAKG;IACH,WAAW,EAAE;QACX;YACE,IAAI,EAAE,GAAG,CAAA;SACV;KACF,CAAA;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriptionmanager.js","sourceRoot":"","sources":["../src/subscriptionmanager.ts"],"names":[],"mappings":""}
|