rclnodejs 1.6.0 → 1.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/index.js +59 -0
- package/lib/action/client.js +55 -9
- package/lib/action/deferred.js +8 -2
- package/lib/action/server.js +10 -1
- package/lib/action/uuid.js +4 -1
- package/lib/client.js +152 -3
- package/lib/clock.js +4 -1
- package/lib/context.js +12 -2
- package/lib/duration.js +37 -12
- package/lib/errors.js +571 -0
- package/lib/event_handler.js +21 -4
- package/lib/interface_loader.js +52 -12
- package/lib/lifecycle.js +8 -2
- package/lib/logging.js +12 -3
- package/lib/message_serialization.js +10 -2
- package/lib/native_loader.js +9 -4
- package/lib/node.js +270 -49
- package/lib/parameter.js +172 -35
- package/lib/parameter_client.js +506 -0
- package/lib/parameter_watcher.js +309 -0
- package/lib/qos.js +22 -5
- package/lib/rate.js +6 -1
- package/lib/serialization.js +7 -2
- package/lib/time.js +136 -21
- package/lib/time_source.js +13 -4
- package/lib/utils.js +27 -1
- package/lib/validator.js +11 -12
- package/package.json +1 -1
- package/prebuilds/linux-x64/jazzy-noble-x64-rclnodejs.node +0 -0
- package/types/base.d.ts +3 -0
- package/types/client.d.ts +36 -0
- package/types/errors.d.ts +447 -0
- package/types/interfaces.d.ts +1910 -1
- package/types/node.d.ts +40 -0
- package/types/parameter_client.d.ts +252 -0
- package/types/parameter_watcher.d.ts +104 -0
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
// Copyright (c) 2025 Mahmoud Alghalayini. All rights reserved.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
declare module 'rclnodejs' {
|
|
16
|
+
/**
|
|
17
|
+
* Options for RclNodeError constructor
|
|
18
|
+
*/
|
|
19
|
+
export interface RclNodeErrorOptions {
|
|
20
|
+
/** Machine-readable error code (e.g., 'TIMEOUT', 'INVALID_ARGUMENT') */
|
|
21
|
+
code?: string;
|
|
22
|
+
/** Name of the node where error occurred */
|
|
23
|
+
nodeName?: string;
|
|
24
|
+
/** Type of entity (publisher, subscription, client, etc.) */
|
|
25
|
+
entityType?: string;
|
|
26
|
+
/** Name of the entity (topic name, service name, etc.) */
|
|
27
|
+
entityName?: string;
|
|
28
|
+
/** Original error that caused this error */
|
|
29
|
+
cause?: Error;
|
|
30
|
+
/** Additional error-specific details */
|
|
31
|
+
details?: any;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Base error class for all rclnodejs errors.
|
|
36
|
+
* Provides structured error information with context.
|
|
37
|
+
*/
|
|
38
|
+
export class RclNodeError extends Error {
|
|
39
|
+
/** Error code for machine-readable error identification */
|
|
40
|
+
code: string;
|
|
41
|
+
/** Name of the node where error occurred */
|
|
42
|
+
nodeName?: string;
|
|
43
|
+
/** Type of entity (publisher, subscription, client, etc.) */
|
|
44
|
+
entityType?: string;
|
|
45
|
+
/** Name of the entity (topic name, service name, etc.) */
|
|
46
|
+
entityName?: string;
|
|
47
|
+
/** Additional error-specific details */
|
|
48
|
+
details?: any;
|
|
49
|
+
/** Original error that caused this error */
|
|
50
|
+
cause?: Error;
|
|
51
|
+
/** Timestamp when error was created */
|
|
52
|
+
timestamp: Date;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @param message - Human-readable error message
|
|
56
|
+
* @param options - Additional error context
|
|
57
|
+
*/
|
|
58
|
+
constructor(message: string, options?: RclNodeErrorOptions);
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Returns a detailed error object for logging/serialization
|
|
62
|
+
*/
|
|
63
|
+
toJSON(): {
|
|
64
|
+
name: string;
|
|
65
|
+
message: string;
|
|
66
|
+
code: string;
|
|
67
|
+
nodeName?: string;
|
|
68
|
+
entityType?: string;
|
|
69
|
+
entityName?: string;
|
|
70
|
+
details?: any;
|
|
71
|
+
timestamp: string;
|
|
72
|
+
stack?: string;
|
|
73
|
+
cause?: any;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Returns a user-friendly error description
|
|
78
|
+
*/
|
|
79
|
+
toString(): string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Options for ValidationError constructor
|
|
84
|
+
*/
|
|
85
|
+
export interface ValidationErrorOptions extends RclNodeErrorOptions {
|
|
86
|
+
/** Name of the argument that failed validation */
|
|
87
|
+
argumentName?: string;
|
|
88
|
+
/** The value that was provided */
|
|
89
|
+
providedValue?: any;
|
|
90
|
+
/** The expected type or format */
|
|
91
|
+
expectedType?: string;
|
|
92
|
+
/** The validation rule that failed */
|
|
93
|
+
validationRule?: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Error thrown when validation fails
|
|
98
|
+
*/
|
|
99
|
+
export class ValidationError extends RclNodeError {
|
|
100
|
+
/** Name of the argument that failed validation */
|
|
101
|
+
argumentName?: string;
|
|
102
|
+
/** The value that was provided */
|
|
103
|
+
providedValue?: any;
|
|
104
|
+
/** The expected type or format */
|
|
105
|
+
expectedType?: string;
|
|
106
|
+
/** The validation rule that failed */
|
|
107
|
+
validationRule?: string;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @param message - Error message
|
|
111
|
+
* @param options - Additional options
|
|
112
|
+
*/
|
|
113
|
+
constructor(message: string, options?: ValidationErrorOptions);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Type validation error
|
|
118
|
+
*/
|
|
119
|
+
export class TypeValidationError extends ValidationError {
|
|
120
|
+
/**
|
|
121
|
+
* @param argumentName - Name of the argument
|
|
122
|
+
* @param providedValue - The value that was provided
|
|
123
|
+
* @param expectedType - The expected type
|
|
124
|
+
* @param options - Additional options
|
|
125
|
+
*/
|
|
126
|
+
constructor(
|
|
127
|
+
argumentName: string,
|
|
128
|
+
providedValue: any,
|
|
129
|
+
expectedType: string,
|
|
130
|
+
options?: RclNodeErrorOptions
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Range/value validation error
|
|
136
|
+
*/
|
|
137
|
+
export class RangeValidationError extends ValidationError {
|
|
138
|
+
/**
|
|
139
|
+
* @param argumentName - Name of the argument
|
|
140
|
+
* @param providedValue - The value that was provided
|
|
141
|
+
* @param constraint - The constraint that was violated
|
|
142
|
+
* @param options - Additional options
|
|
143
|
+
*/
|
|
144
|
+
constructor(
|
|
145
|
+
argumentName: string,
|
|
146
|
+
providedValue: any,
|
|
147
|
+
constraint: string,
|
|
148
|
+
options?: RclNodeErrorOptions
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* ROS name validation error (topics, nodes, services)
|
|
154
|
+
*/
|
|
155
|
+
export class NameValidationError extends ValidationError {
|
|
156
|
+
/** Index where validation failed */
|
|
157
|
+
invalidIndex: number;
|
|
158
|
+
/** The validation error message */
|
|
159
|
+
validationResult: string;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @param name - The invalid name
|
|
163
|
+
* @param nameType - Type of name (node, topic, service, etc.)
|
|
164
|
+
* @param validationResult - The validation error message
|
|
165
|
+
* @param invalidIndex - Index where validation failed
|
|
166
|
+
* @param options - Additional options
|
|
167
|
+
*/
|
|
168
|
+
constructor(
|
|
169
|
+
name: string,
|
|
170
|
+
nameType: string,
|
|
171
|
+
validationResult: string,
|
|
172
|
+
invalidIndex: number,
|
|
173
|
+
options?: RclNodeErrorOptions
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Base class for operation/runtime errors
|
|
179
|
+
*/
|
|
180
|
+
export class OperationError extends RclNodeError {
|
|
181
|
+
/**
|
|
182
|
+
* @param message - Error message
|
|
183
|
+
* @param options - Additional options
|
|
184
|
+
*/
|
|
185
|
+
constructor(message: string, options?: RclNodeErrorOptions);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Request timeout error
|
|
190
|
+
*/
|
|
191
|
+
export class TimeoutError extends OperationError {
|
|
192
|
+
/** Timeout duration in milliseconds */
|
|
193
|
+
timeout: number;
|
|
194
|
+
/** Type of operation that timed out */
|
|
195
|
+
operationType: string;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @param operationType - Type of operation that timed out
|
|
199
|
+
* @param timeoutMs - Timeout duration in milliseconds
|
|
200
|
+
* @param options - Additional options
|
|
201
|
+
*/
|
|
202
|
+
constructor(
|
|
203
|
+
operationType: string,
|
|
204
|
+
timeoutMs: number,
|
|
205
|
+
options?: RclNodeErrorOptions
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Request abortion error
|
|
211
|
+
*/
|
|
212
|
+
export class AbortError extends OperationError {
|
|
213
|
+
/** Type of operation that was aborted */
|
|
214
|
+
operationType: string;
|
|
215
|
+
/** Reason for abortion */
|
|
216
|
+
abortReason?: string;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* @param operationType - Type of operation that was aborted
|
|
220
|
+
* @param reason - Reason for abortion
|
|
221
|
+
* @param options - Additional options
|
|
222
|
+
*/
|
|
223
|
+
constructor(
|
|
224
|
+
operationType: string,
|
|
225
|
+
reason?: string,
|
|
226
|
+
options?: RclNodeErrorOptions
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Service not available error
|
|
232
|
+
*/
|
|
233
|
+
export class ServiceNotFoundError extends OperationError {
|
|
234
|
+
/** Name of the service */
|
|
235
|
+
serviceName: string;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* @param serviceName - Name of the service
|
|
239
|
+
* @param options - Additional options
|
|
240
|
+
*/
|
|
241
|
+
constructor(serviceName: string, options?: RclNodeErrorOptions);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Remote node not found error
|
|
246
|
+
*/
|
|
247
|
+
export class NodeNotFoundError extends OperationError {
|
|
248
|
+
/** Name of the target node */
|
|
249
|
+
targetNodeName: string;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* @param nodeName - Name of the node
|
|
253
|
+
* @param options - Additional options
|
|
254
|
+
*/
|
|
255
|
+
constructor(nodeName: string, options?: RclNodeErrorOptions);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Base error for parameter operations
|
|
260
|
+
*/
|
|
261
|
+
export class ParameterError extends RclNodeError {
|
|
262
|
+
/** Name of the parameter */
|
|
263
|
+
parameterName: string;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* @param message - Error message
|
|
267
|
+
* @param parameterName - Name of the parameter
|
|
268
|
+
* @param options - Additional options
|
|
269
|
+
*/
|
|
270
|
+
constructor(
|
|
271
|
+
message: string,
|
|
272
|
+
parameterName: string,
|
|
273
|
+
options?: RclNodeErrorOptions
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Parameter not found error
|
|
279
|
+
*/
|
|
280
|
+
export class ParameterNotFoundError extends ParameterError {
|
|
281
|
+
/**
|
|
282
|
+
* @param parameterName - Name of the parameter
|
|
283
|
+
* @param nodeName - Name of the node
|
|
284
|
+
* @param options - Additional options
|
|
285
|
+
*/
|
|
286
|
+
constructor(
|
|
287
|
+
parameterName: string,
|
|
288
|
+
nodeName: string,
|
|
289
|
+
options?: RclNodeErrorOptions
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Parameter type mismatch error
|
|
295
|
+
*/
|
|
296
|
+
export class ParameterTypeError extends ParameterError {
|
|
297
|
+
/** Expected parameter type */
|
|
298
|
+
expectedType: string;
|
|
299
|
+
/** Actual parameter type */
|
|
300
|
+
actualType: string;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* @param parameterName - Name of the parameter
|
|
304
|
+
* @param expectedType - Expected parameter type
|
|
305
|
+
* @param actualType - Actual parameter type
|
|
306
|
+
* @param options - Additional options
|
|
307
|
+
*/
|
|
308
|
+
constructor(
|
|
309
|
+
parameterName: string,
|
|
310
|
+
expectedType: string,
|
|
311
|
+
actualType: string,
|
|
312
|
+
options?: RclNodeErrorOptions
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Read-only parameter modification error
|
|
318
|
+
*/
|
|
319
|
+
export class ReadOnlyParameterError extends ParameterError {
|
|
320
|
+
/**
|
|
321
|
+
* @param parameterName - Name of the parameter
|
|
322
|
+
* @param options - Additional options
|
|
323
|
+
*/
|
|
324
|
+
constructor(parameterName: string, options?: RclNodeErrorOptions);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Base error for topic operations
|
|
329
|
+
*/
|
|
330
|
+
export class TopicError extends RclNodeError {
|
|
331
|
+
/** Name of the topic */
|
|
332
|
+
topicName: string;
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* @param message - Error message
|
|
336
|
+
* @param topicName - Name of the topic
|
|
337
|
+
* @param options - Additional options
|
|
338
|
+
*/
|
|
339
|
+
constructor(
|
|
340
|
+
message: string,
|
|
341
|
+
topicName: string,
|
|
342
|
+
options?: RclNodeErrorOptions
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Publisher-specific error
|
|
348
|
+
*/
|
|
349
|
+
export class PublisherError extends TopicError {
|
|
350
|
+
/**
|
|
351
|
+
* @param message - Error message
|
|
352
|
+
* @param topicName - Name of the topic
|
|
353
|
+
* @param options - Additional options
|
|
354
|
+
*/
|
|
355
|
+
constructor(
|
|
356
|
+
message: string,
|
|
357
|
+
topicName: string,
|
|
358
|
+
options?: RclNodeErrorOptions
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Subscription-specific error
|
|
364
|
+
*/
|
|
365
|
+
export class SubscriptionError extends TopicError {
|
|
366
|
+
/**
|
|
367
|
+
* @param message - Error message
|
|
368
|
+
* @param topicName - Name of the topic
|
|
369
|
+
* @param options - Additional options
|
|
370
|
+
*/
|
|
371
|
+
constructor(
|
|
372
|
+
message: string,
|
|
373
|
+
topicName: string,
|
|
374
|
+
options?: RclNodeErrorOptions
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Base error for action operations
|
|
380
|
+
*/
|
|
381
|
+
export class ActionError extends RclNodeError {
|
|
382
|
+
/** Name of the action */
|
|
383
|
+
actionName: string;
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* @param message - Error message
|
|
387
|
+
* @param actionName - Name of the action
|
|
388
|
+
* @param options - Additional options
|
|
389
|
+
*/
|
|
390
|
+
constructor(
|
|
391
|
+
message: string,
|
|
392
|
+
actionName: string,
|
|
393
|
+
options?: RclNodeErrorOptions
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Goal rejected by action server
|
|
399
|
+
*/
|
|
400
|
+
export class GoalRejectedError extends ActionError {
|
|
401
|
+
/** ID of the rejected goal */
|
|
402
|
+
goalId: string;
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* @param actionName - Name of the action
|
|
406
|
+
* @param goalId - ID of the rejected goal
|
|
407
|
+
* @param options - Additional options
|
|
408
|
+
*/
|
|
409
|
+
constructor(
|
|
410
|
+
actionName: string,
|
|
411
|
+
goalId: string,
|
|
412
|
+
options?: RclNodeErrorOptions
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Action server not found
|
|
418
|
+
*/
|
|
419
|
+
export class ActionServerNotFoundError extends ActionError {
|
|
420
|
+
/**
|
|
421
|
+
* @param actionName - Name of the action
|
|
422
|
+
* @param options - Additional options
|
|
423
|
+
*/
|
|
424
|
+
constructor(actionName: string, options?: RclNodeErrorOptions);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Wraps errors from native C++ layer with additional context
|
|
429
|
+
*/
|
|
430
|
+
export class NativeError extends RclNodeError {
|
|
431
|
+
/** Error message from C++ layer */
|
|
432
|
+
nativeMessage: string;
|
|
433
|
+
/** Operation that failed */
|
|
434
|
+
operation: string;
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* @param nativeMessage - Error message from C++ layer
|
|
438
|
+
* @param operation - Operation that failed
|
|
439
|
+
* @param options - Additional options
|
|
440
|
+
*/
|
|
441
|
+
constructor(
|
|
442
|
+
nativeMessage: string,
|
|
443
|
+
operation: string,
|
|
444
|
+
options?: RclNodeErrorOptions
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
}
|