@hla4ts/hla-api 0.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/src/types.ts ADDED
@@ -0,0 +1,440 @@
1
+ /**
2
+ * HLA 4 Type Definitions
3
+ *
4
+ * This module provides type-safe wrappers and type definitions for HLA 4 concepts.
5
+ */
6
+
7
+ import {
8
+ CallbackModel,
9
+ ResignAction,
10
+ OrderType,
11
+ SynchronizationPointFailureReason,
12
+ SaveFailureReason,
13
+ RestoreFailureReason,
14
+ SaveStatus,
15
+ RestoreStatus,
16
+ } from "@hla4ts/proto";
17
+
18
+ // Re-export enums for convenience
19
+ export {
20
+ CallbackModel,
21
+ ResignAction,
22
+ OrderType,
23
+ SynchronizationPointFailureReason,
24
+ SaveFailureReason,
25
+ RestoreFailureReason,
26
+ SaveStatus,
27
+ RestoreStatus,
28
+ };
29
+
30
+ // =============================================================================
31
+ // Handle Types
32
+ // =============================================================================
33
+
34
+ /**
35
+ * Opaque handle representing a federate in the federation.
36
+ * Handles are represented as Uint8Array (byte arrays) in the Federate Protocol.
37
+ */
38
+ export type FederateHandle = Uint8Array;
39
+
40
+ /**
41
+ * Opaque handle representing an object class in the FOM.
42
+ */
43
+ export type ObjectClassHandle = Uint8Array;
44
+
45
+ /**
46
+ * Opaque handle representing an attribute within an object class.
47
+ */
48
+ export type AttributeHandle = Uint8Array;
49
+
50
+ /**
51
+ * Opaque handle representing an interaction class in the FOM.
52
+ */
53
+ export type InteractionClassHandle = Uint8Array;
54
+
55
+ /**
56
+ * Opaque handle representing a parameter within an interaction class.
57
+ */
58
+ export type ParameterHandle = Uint8Array;
59
+
60
+ /**
61
+ * Opaque handle representing a registered object instance.
62
+ */
63
+ export type ObjectInstanceHandle = Uint8Array;
64
+
65
+ /**
66
+ * Opaque handle representing a message retraction.
67
+ */
68
+ export type MessageRetractionHandle = Uint8Array;
69
+
70
+ /**
71
+ * Opaque handle representing a transportation type.
72
+ */
73
+ export type TransportationTypeHandle = Uint8Array;
74
+
75
+ /**
76
+ * Opaque handle representing a dimension for DDM.
77
+ */
78
+ export type DimensionHandle = Uint8Array;
79
+
80
+ /**
81
+ * Opaque handle representing a region for DDM.
82
+ */
83
+ export type RegionHandle = Uint8Array;
84
+
85
+ // =============================================================================
86
+ // Logical Time
87
+ // =============================================================================
88
+
89
+ /**
90
+ * Encoded logical time (RTI-specific encoding).
91
+ * The actual time representation depends on the LogicalTimeFactory used.
92
+ */
93
+ export type LogicalTime = Uint8Array;
94
+
95
+ /**
96
+ * Encoded logical time interval (RTI-specific encoding).
97
+ */
98
+ export type LogicalTimeInterval = Uint8Array;
99
+
100
+ // =============================================================================
101
+ // Handle Sets
102
+ // =============================================================================
103
+
104
+ /**
105
+ * Set of federate handles.
106
+ */
107
+ export type FederateHandleSet = FederateHandle[];
108
+
109
+ /**
110
+ * Set of attribute handles.
111
+ */
112
+ export type AttributeHandleSet = AttributeHandle[];
113
+
114
+ /**
115
+ * Set of dimension handles.
116
+ */
117
+ export type DimensionHandleSet = DimensionHandle[];
118
+
119
+ /**
120
+ * Set of region handles.
121
+ */
122
+ export type RegionHandleSet = RegionHandle[];
123
+
124
+ /**
125
+ * Set of interaction class handles.
126
+ */
127
+ export type InteractionClassHandleSet = InteractionClassHandle[];
128
+
129
+ // =============================================================================
130
+ // Handle-Value Maps
131
+ // =============================================================================
132
+
133
+ /**
134
+ * A single attribute handle-value pair.
135
+ */
136
+ export interface AttributeHandleValue {
137
+ attributeHandle: AttributeHandle;
138
+ value: Uint8Array;
139
+ }
140
+
141
+ /**
142
+ * Map of attribute handles to their values.
143
+ */
144
+ export type AttributeHandleValueMap = AttributeHandleValue[];
145
+
146
+ /**
147
+ * A single parameter handle-value pair.
148
+ */
149
+ export interface ParameterHandleValue {
150
+ parameterHandle: ParameterHandle;
151
+ value: Uint8Array;
152
+ }
153
+
154
+ /**
155
+ * Map of parameter handles to their values.
156
+ */
157
+ export type ParameterHandleValueMap = ParameterHandleValue[];
158
+
159
+ // =============================================================================
160
+ // Federation Information
161
+ // =============================================================================
162
+
163
+ /**
164
+ * Information about a federation execution.
165
+ */
166
+ export interface FederationExecutionInformation {
167
+ federationName: string;
168
+ logicalTimeImplementationName: string;
169
+ }
170
+
171
+ /**
172
+ * Set of federation execution information.
173
+ */
174
+ export type FederationExecutionInformationSet = FederationExecutionInformation[];
175
+
176
+ /**
177
+ * Information about a member of a federation execution.
178
+ */
179
+ export interface FederationExecutionMemberInformation {
180
+ federateName: string;
181
+ federateType: string;
182
+ }
183
+
184
+ /**
185
+ * Set of federation execution member information.
186
+ */
187
+ export type FederationExecutionMemberInformationSet = FederationExecutionMemberInformation[];
188
+
189
+ /**
190
+ * Result of joining a federation execution.
191
+ */
192
+ export interface JoinResult {
193
+ federateHandle: FederateHandle;
194
+ logicalTimeImplementationName: string;
195
+ }
196
+
197
+ // =============================================================================
198
+ // Save/Restore Information
199
+ // =============================================================================
200
+
201
+ /**
202
+ * Federate restore status.
203
+ */
204
+ export interface FederateRestoreStatus {
205
+ preHandle: FederateHandle;
206
+ postHandle: FederateHandle;
207
+ status: RestoreStatus;
208
+ }
209
+
210
+ /**
211
+ * Array of federate restore statuses.
212
+ */
213
+ export type FederateRestoreStatusArray = FederateRestoreStatus[];
214
+
215
+ /**
216
+ * Federate handle and save status pair.
217
+ */
218
+ export interface FederateHandleSaveStatusPair {
219
+ federateHandle: FederateHandle;
220
+ saveStatus: SaveStatus;
221
+ }
222
+
223
+ /**
224
+ * Array of federate save status pairs.
225
+ */
226
+ export type FederateHandleSaveStatusPairArray = FederateHandleSaveStatusPair[];
227
+
228
+ // =============================================================================
229
+ // Time Query Returns
230
+ // =============================================================================
231
+
232
+ /**
233
+ * Result of a time query operation.
234
+ */
235
+ export interface TimeQueryReturn {
236
+ logicalTimeIsValid: boolean;
237
+ logicalTime?: LogicalTime;
238
+ }
239
+
240
+ /**
241
+ * Result of an operation that may return a message retraction handle.
242
+ */
243
+ export interface MessageRetractionReturn {
244
+ retractionHandleIsValid: boolean;
245
+ retractionHandle?: MessageRetractionHandle;
246
+ }
247
+
248
+ // =============================================================================
249
+ // DDM (Data Distribution Management) Types
250
+ // =============================================================================
251
+
252
+ /**
253
+ * Range bounds for a dimension.
254
+ */
255
+ export interface RangeBounds {
256
+ lower: bigint;
257
+ upper: bigint;
258
+ }
259
+
260
+ /**
261
+ * Dimension and its range specification.
262
+ */
263
+ export interface DimensionAndRange {
264
+ dimensionHandle: DimensionHandle;
265
+ range: RangeBounds;
266
+ }
267
+
268
+ /**
269
+ * A conveyed region (list of dimension-range pairs).
270
+ */
271
+ export type ConveyedRegion = DimensionAndRange[];
272
+
273
+ /**
274
+ * Set of conveyed regions.
275
+ */
276
+ export type ConveyedRegionSet = ConveyedRegion[];
277
+
278
+ /**
279
+ * Pair of attribute set and region set.
280
+ */
281
+ export interface AttributeSetRegionSetPair {
282
+ attributeSet: AttributeHandleSet;
283
+ regionSet: RegionHandleSet;
284
+ }
285
+
286
+ /**
287
+ * List of attribute-set/region-set pairs.
288
+ */
289
+ export type AttributeSetRegionSetPairList = AttributeSetRegionSetPair[];
290
+
291
+ // =============================================================================
292
+ // Supplemental Information
293
+ // =============================================================================
294
+
295
+ /**
296
+ * Supplemental information for attribute reflections.
297
+ */
298
+ export interface SupplementalReflectInfo {
299
+ hasProducingFederate: boolean;
300
+ producingFederate?: FederateHandle;
301
+ hasSentRegions: boolean;
302
+ sentRegions?: ConveyedRegionSet;
303
+ }
304
+
305
+ /**
306
+ * Supplemental information for interaction receipts.
307
+ */
308
+ export interface SupplementalReceiveInfo {
309
+ hasProducingFederate: boolean;
310
+ producingFederate?: FederateHandle;
311
+ hasSentRegions: boolean;
312
+ sentRegions?: ConveyedRegionSet;
313
+ }
314
+
315
+ // =============================================================================
316
+ // FOM Module Types
317
+ // =============================================================================
318
+
319
+ /**
320
+ * A FOM module as inline content.
321
+ */
322
+ export interface FomModuleInline {
323
+ type: "inline";
324
+ content: string;
325
+ }
326
+
327
+ /**
328
+ * A FOM module as a file reference.
329
+ */
330
+ export interface FomModuleFile {
331
+ type: "file";
332
+ name: string;
333
+ content: Uint8Array;
334
+ }
335
+
336
+ /**
337
+ * A FOM module as a URL/designator reference.
338
+ */
339
+ export interface FomModuleUrl {
340
+ type: "url";
341
+ url: string;
342
+ }
343
+
344
+ /**
345
+ * A FOM module (one of inline, file, or URL).
346
+ */
347
+ export type FomModule = FomModuleInline | FomModuleFile | FomModuleUrl;
348
+
349
+ /**
350
+ * Set of FOM modules.
351
+ */
352
+ export type FomModuleSet = FomModule[];
353
+
354
+ // =============================================================================
355
+ // Configuration Types
356
+ // =============================================================================
357
+
358
+ /**
359
+ * RTI configuration for connecting.
360
+ */
361
+ export interface RtiConfiguration {
362
+ configurationName?: string;
363
+ rtiAddress?: string;
364
+ additionalSettings?: string;
365
+ }
366
+
367
+ /**
368
+ * Result of RTI configuration.
369
+ */
370
+ export interface ConfigurationResult {
371
+ configurationUsed: boolean;
372
+ reportedConfiguration?: RtiConfiguration;
373
+ message?: string;
374
+ }
375
+
376
+ /**
377
+ * Credentials for authenticated connections.
378
+ */
379
+ export interface Credentials {
380
+ type: string;
381
+ data: Uint8Array;
382
+ }
383
+
384
+ // =============================================================================
385
+ // Connection Options
386
+ // =============================================================================
387
+
388
+ /**
389
+ * Options for connecting to the RTI.
390
+ */
391
+ export interface ConnectionOptions {
392
+ /** The callback model to use (EVOKED or IMMEDIATE) */
393
+ callbackModel: CallbackModel;
394
+
395
+ /** RTI configuration (optional) */
396
+ rtiConfiguration?: RtiConfiguration;
397
+
398
+ /** Credentials for authentication (optional) */
399
+ credentials?: Credentials;
400
+ }
401
+
402
+ // =============================================================================
403
+ // Utility Types
404
+ // =============================================================================
405
+
406
+ /**
407
+ * User-supplied tag (arbitrary byte array).
408
+ */
409
+ export type UserSuppliedTag = Uint8Array;
410
+
411
+ /**
412
+ * Compare two handles for equality.
413
+ */
414
+ export function handlesEqual(a: Uint8Array, b: Uint8Array): boolean {
415
+ if (a.length !== b.length) return false;
416
+ for (let i = 0; i < a.length; i++) {
417
+ if (a[i] !== b[i]) return false;
418
+ }
419
+ return true;
420
+ }
421
+
422
+ /**
423
+ * Convert a handle to a hex string for debugging/logging.
424
+ */
425
+ export function handleToHex(handle: Uint8Array): string {
426
+ return Array.from(handle)
427
+ .map((b) => b.toString(16).padStart(2, "0"))
428
+ .join("");
429
+ }
430
+
431
+ /**
432
+ * Create a handle from a hex string.
433
+ */
434
+ export function handleFromHex(hex: string): Uint8Array {
435
+ const bytes = new Uint8Array(hex.length / 2);
436
+ for (let i = 0; i < bytes.length; i++) {
437
+ bytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
438
+ }
439
+ return bytes;
440
+ }