opcjs-client 0.1.5 → 0.1.8

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ChannelFactory, SecureChannel, Configuration, Encoder, registerEncoders, Decoder, BinaryReader, registerTypeDecoders, registerBinaryDecoders, NodeId, UserTokenTypeEnum, AnonymousIdentityToken, UserNameIdentityToken, IssuedIdentityToken, SubscriptionAcknowledgement, CreateSubscriptionRequest, PublishRequest, ReadValueId, QualifiedName, MonitoringParameters, ExtensionObject, MonitoredItemCreateRequest, CreateMonitoredItemsRequest, TimestampsToReturnEnum, ReadRequest, ApplicationDescription, LocalizedText, ApplicationTypeEnum, CreateSessionRequest, CreateSessionResponse, SignatureData, ActivateSessionRequest, RequestHeader } from '@opcua/base';
1
+ import { ChannelFactory, SecureChannel, Configuration, Encoder, BinaryWriter, registerEncoders, Decoder, BinaryReader, registerTypeDecoders, registerBinaryDecoders, NodeId, UserTokenTypeEnum, AnonymousIdentityToken, UserNameIdentityToken, IssuedIdentityToken, SubscriptionAcknowledgement, CreateSubscriptionRequest, PublishRequest, ReadValueId, QualifiedName, MonitoringParameters, ExtensionObject, MonitoredItemCreateRequest, CreateMonitoredItemsRequest, TimestampsToReturnEnum, ReadRequest, ApplicationDescription, LocalizedText, ApplicationTypeEnum, CreateSessionRequest, CreateSessionResponse, SignatureData, ActivateSessionRequest, RequestHeader } from 'opcjs-base';
2
2
 
3
3
  // src/client.ts
4
4
  var ServiceBase = class {
@@ -395,700 +395,6 @@ var Client = class {
395
395
  this.subscriptionHandler?.subscribe(ids, callback);
396
396
  }
397
397
  };
398
-
399
- // ../base/src/codecs/codecError.ts
400
- var CodecError = class _CodecError extends Error {
401
- /**
402
- * The encoding ID involved in the error (if applicable).
403
- */
404
- encodingId;
405
- /**
406
- * The encoding format where the error occurred (Binary, Xml, Json).
407
- */
408
- format;
409
- /**
410
- * Suggested action to resolve the error.
411
- */
412
- suggestedAction;
413
- /**
414
- * The type name involved in the error (if applicable).
415
- */
416
- typeName;
417
- /**
418
- * Original error that caused this codec error (if any).
419
- */
420
- cause;
421
- constructor(message, options) {
422
- super(message);
423
- this.name = "CodecError";
424
- this.encodingId = options?.encodingId;
425
- this.format = options?.format;
426
- this.suggestedAction = options?.suggestedAction;
427
- this.typeName = options?.typeName;
428
- this.cause = options?.cause;
429
- if (Error.captureStackTrace) {
430
- Error.captureStackTrace(this, _CodecError);
431
- }
432
- }
433
- /**
434
- * Returns a detailed error message including all context.
435
- */
436
- toString() {
437
- let result = `${this.name}: ${this.message}`;
438
- if (this.encodingId) {
439
- result += `
440
- Encoding ID: ${this.encodingId}`;
441
- }
442
- if (this.format) {
443
- result += `
444
- Format: ${this.format}`;
445
- }
446
- if (this.typeName) {
447
- result += `
448
- Type: ${this.typeName}`;
449
- }
450
- if (this.suggestedAction) {
451
- result += `
452
- Suggested Action: ${this.suggestedAction}`;
453
- }
454
- return result;
455
- }
456
- };
457
-
458
- // ../base/src/codecs/binary/binaryWriter.ts
459
- var EPOCH_DIFF_MS = 11644473600000n;
460
- var TICKS_PER_MS = 10000n;
461
- function selectNodeIdEncodingFormat(nodeId) {
462
- if (nodeId.identifierType === 0 /* Numeric */) {
463
- const id = nodeId.identifier;
464
- const ns = nodeId.namespace;
465
- if (ns === 0 && id >= 0 && id <= 255) {
466
- return 0 /* TwoByte */;
467
- }
468
- if (ns >= 0 && ns <= 255 && id >= 0 && id <= 65535) {
469
- return 1 /* FourByte */;
470
- }
471
- return 2 /* Numeric */;
472
- }
473
- if (nodeId.identifierType === 1 /* String */) {
474
- return 3 /* String */;
475
- }
476
- if (nodeId.identifierType === 2 /* Guid */) {
477
- return 4 /* Guid */;
478
- }
479
- if (nodeId.identifierType === 3 /* ByteString */) {
480
- return 5 /* ByteString */;
481
- }
482
- throw new CodecError(`Invalid NodeId identifier type: ${nodeId.identifierType}`);
483
- }
484
- var ExpandedNodeIdMask = {
485
- ServerIndexFlag: 64,
486
- NamespaceUriFlag: 128
487
- };
488
- var LocalizedTextMask = {
489
- LocaleFlag: 1,
490
- TextFlag: 2
491
- };
492
- var DataValueMaskBits = {
493
- Value: 1,
494
- StatusCode: 2,
495
- SourceTimestamp: 4,
496
- ServerTimestamp: 8,
497
- SourcePicoseconds: 16,
498
- ServerPicoseconds: 32
499
- };
500
- var DiagnosticInfoMaskBits = {
501
- SymbolicId: 1,
502
- NamespaceUri: 2,
503
- LocalizedText: 4,
504
- Locale: 8,
505
- AdditionalInfo: 16,
506
- InnerStatusCode: 32,
507
- InnerDiagnosticInfo: 64
508
- };
509
- var VariantMask = {
510
- TypeMask: 63,
511
- ArrayDimensions: 64,
512
- Array: 128
513
- };
514
- var BinaryWriter = class {
515
- buffer;
516
- position;
517
- getData() {
518
- return this.buffer.subarray(0, this.position);
519
- }
520
- /** Returns the number of bytes written so far. */
521
- getLength() {
522
- return this.position;
523
- }
524
- /** Appends raw bytes to the buffer. */
525
- writeBytes(data) {
526
- this.ensureCapacity(data.length);
527
- this.buffer.set(data, this.position);
528
- this.position += data.length;
529
- }
530
- /**
531
- * Overwrites bytes in the buffer starting at the given position.
532
- * Also truncates the written length to `offset + data.length` if that
533
- * is less than the current position (i.e. replaces and trims the tail).
534
- */
535
- writeBytesAt(data, offset) {
536
- const end = offset + data.length;
537
- this.ensureCapacity(Math.max(0, end - this.position));
538
- this.buffer.set(data, offset);
539
- if (end > this.position) {
540
- this.position = end;
541
- }
542
- }
543
- /**
544
- * Inserts bytes at the given offset, shifting all subsequent content right.
545
- */
546
- insertBytesAt(data, offset) {
547
- this.ensureCapacity(data.length);
548
- this.buffer.copyWithin(offset + data.length, offset, this.position);
549
- this.buffer.set(data, offset);
550
- this.position += data.length;
551
- }
552
- /**
553
- * Overwrites a UInt32 (little-endian) at the given byte offset without
554
- * advancing the write position.
555
- */
556
- writeUInt32At(value, offset) {
557
- if (!Number.isInteger(value) || value < 0 || value > 4294967295) {
558
- throw new CodecError(`UInt32 value ${value} out of range [0, 4294967295]`);
559
- }
560
- this.buffer.writeUInt32LE(value, offset);
561
- }
562
- /**
563
- * Ensure buffer has enough capacity, growing if necessary.
564
- */
565
- ensureCapacity(additionalBytes) {
566
- const required = this.position + additionalBytes;
567
- if (required > this.buffer.length) {
568
- const newSize = Math.max(required, this.buffer.length * 2);
569
- const newBuffer = Buffer.allocUnsafe(newSize);
570
- this.buffer.copy(newBuffer, 0, 0, this.position);
571
- this.buffer = newBuffer;
572
- }
573
- }
574
- writeBoolean(value) {
575
- this.ensureCapacity(1);
576
- this.buffer.writeUInt8(value ? 1 : 0, this.position);
577
- this.position += 1;
578
- }
579
- writeByte(value) {
580
- if (value < 0 || value > 255) {
581
- throw new CodecError(`Byte value ${value} out of range [0, 255]`);
582
- }
583
- this.ensureCapacity(1);
584
- this.buffer.writeUInt8(value, this.position);
585
- this.position += 1;
586
- }
587
- writeSByte(value) {
588
- if (value < -128 || value > 127) {
589
- throw new CodecError(`SByte value ${value} out of range [-128, 127]`);
590
- }
591
- this.ensureCapacity(1);
592
- this.buffer.writeInt8(value, this.position);
593
- this.position += 1;
594
- }
595
- writeInt16(value) {
596
- if (value < -32768 || value > 32767) {
597
- throw new CodecError(`Int16 value ${value} out of range [-32768, 32767]`);
598
- }
599
- this.ensureCapacity(2);
600
- this.buffer.writeInt16LE(value, this.position);
601
- this.position += 2;
602
- }
603
- writeUInt16(value) {
604
- if (value < 0 || value > 65535) {
605
- throw new CodecError(`UInt16 value ${value} out of range [0, 65535]`);
606
- }
607
- this.ensureCapacity(2);
608
- this.buffer.writeUInt16LE(value, this.position);
609
- this.position += 2;
610
- }
611
- writeInt32(value) {
612
- if (!Number.isInteger(value) || value < -2147483648 || value > 2147483647) {
613
- throw new CodecError(`Int32 value ${value} out of range [-2147483648, 2147483647]`);
614
- }
615
- this.ensureCapacity(4);
616
- this.buffer.writeInt32LE(value, this.position);
617
- this.position += 4;
618
- }
619
- writeUInt32(value) {
620
- if (!Number.isInteger(value) || value < 0 || value > 4294967295) {
621
- throw new CodecError(`UInt32 value ${value} out of range [0, 4294967295]`);
622
- }
623
- this.ensureCapacity(4);
624
- this.buffer.writeUInt32LE(value, this.position);
625
- this.position += 4;
626
- }
627
- writeInt64(value) {
628
- this.ensureCapacity(8);
629
- this.buffer.writeBigInt64LE(value, this.position);
630
- this.position += 8;
631
- }
632
- writeUInt64(value) {
633
- this.ensureCapacity(8);
634
- this.buffer.writeBigUInt64LE(value, this.position);
635
- this.position += 8;
636
- }
637
- writeFloat(value) {
638
- this.ensureCapacity(4);
639
- this.buffer.writeFloatLE(value, this.position);
640
- this.position += 4;
641
- }
642
- writeDouble(value) {
643
- this.ensureCapacity(8);
644
- this.buffer.writeDoubleLE(value, this.position);
645
- this.position += 8;
646
- }
647
- writeString(value) {
648
- if (value == null) {
649
- this.writeInt32(-1);
650
- return;
651
- }
652
- const utf8Bytes = Buffer.from(value, "utf8");
653
- const length = utf8Bytes.length;
654
- if (length > 16777216) {
655
- throw new CodecError(
656
- `String length ${length} exceeds maximum allowed length of 16,777,216 bytes`,
657
- { format: "Binary", suggestedAction: "Reduce string length" }
658
- );
659
- }
660
- this.writeInt32(length);
661
- this.ensureCapacity(length);
662
- utf8Bytes.copy(this.buffer, this.position);
663
- this.position += length;
664
- }
665
- writeDateTime(value) {
666
- const jsTimestamp = BigInt(value.getTime());
667
- const opcTimestamp = (jsTimestamp + EPOCH_DIFF_MS) * TICKS_PER_MS;
668
- this.writeInt64(opcTimestamp);
669
- }
670
- writeGuid(value) {
671
- const hex = value.replace(/-/g, "");
672
- if (hex.length !== 32) {
673
- throw new CodecError(`Invalid GUID format: ${value}`);
674
- }
675
- this.ensureCapacity(16);
676
- const data1 = parseInt(hex.substr(0, 8), 16);
677
- this.buffer.writeUInt32LE(data1, this.position);
678
- const data2 = parseInt(hex.substr(8, 4), 16);
679
- this.buffer.writeUInt16LE(data2, this.position + 4);
680
- const data3 = parseInt(hex.substr(12, 4), 16);
681
- this.buffer.writeUInt16LE(data3, this.position + 6);
682
- for (let i = 0; i < 8; i++) {
683
- const byte = parseInt(hex.substr(16 + i * 2, 2), 16);
684
- this.buffer.writeUInt8(byte, this.position + 8 + i);
685
- }
686
- this.position += 16;
687
- }
688
- writeByteString(value) {
689
- if (value == null) {
690
- this.writeInt32(-1);
691
- return;
692
- }
693
- const length = value.length;
694
- if (length > 16777216) {
695
- throw new CodecError(
696
- `ByteString length ${length} exceeds maximum allowed length of 16,777,216 bytes`,
697
- { format: "Binary", suggestedAction: "Reduce ByteString length" }
698
- );
699
- }
700
- this.writeInt32(length);
701
- this.ensureCapacity(length);
702
- if (Buffer.isBuffer(value)) {
703
- value.copy(this.buffer, this.position);
704
- } else {
705
- this.buffer.set(value, this.position);
706
- }
707
- this.position += length;
708
- }
709
- writeXmlElement(value) {
710
- this.writeString(value);
711
- }
712
- /**
713
- * Write an array with Int32 length prefix.
714
- * Per FR-011: -1 = null, 0 = empty, positive = element count
715
- * Per FR-019: Maximum array length is 2,147,483,647 elements
716
- *
717
- * @param array The array to encode (undefined for null array)
718
- * @param encodeElement Function to encode each element
719
- * @throws {CodecError} if array length exceeds Int32 maximum
720
- * @see OPC 10000-6 Section 5.2.5 - Arrays
721
- */
722
- writeArray(array, encodeElement) {
723
- if (array === void 0) {
724
- this.writeInt32(-1);
725
- return;
726
- }
727
- const length = array.length;
728
- if (length > 2147483647) {
729
- throw new CodecError(
730
- `Array length ${length} exceeds maximum allowed length of 2,147,483,647 elements`,
731
- { format: "Binary", suggestedAction: "Reduce array size" }
732
- );
733
- }
734
- this.writeInt32(length);
735
- for (const element of array) {
736
- encodeElement(this, element);
737
- }
738
- }
739
- // === Complex type write methods ===
740
- /**
741
- * Encode a NodeId in binary format using the most compact representation.
742
- * @see OPC 10000-6 Tables 16-19
743
- */
744
- writeNodeId(value) {
745
- const format = selectNodeIdEncodingFormat(value);
746
- switch (format) {
747
- case 0 /* TwoByte */:
748
- this.writeByte(0 /* TwoByte */);
749
- this.writeByte(value.identifier);
750
- break;
751
- case 1 /* FourByte */:
752
- this.writeByte(1 /* FourByte */);
753
- this.writeByte(value.namespace);
754
- this.writeUInt16(value.identifier);
755
- break;
756
- case 2 /* Numeric */:
757
- this.writeByte(2 /* Numeric */);
758
- this.writeUInt16(value.namespace);
759
- this.writeUInt32(value.identifier);
760
- break;
761
- case 3 /* String */:
762
- this.writeByte(3 /* String */);
763
- this.writeUInt16(value.namespace);
764
- this.writeString(value.identifier);
765
- break;
766
- case 4 /* Guid */:
767
- this.writeByte(4 /* Guid */);
768
- this.writeUInt16(value.namespace);
769
- this.writeGuid(value.identifier);
770
- break;
771
- case 5 /* ByteString */: {
772
- this.writeByte(5 /* ByteString */);
773
- this.writeUInt16(value.namespace);
774
- const ident = value.identifier;
775
- const buf = ident instanceof Uint8Array && !(ident instanceof Buffer) ? Buffer.from(ident) : ident;
776
- this.writeByteString(buf);
777
- break;
778
- }
779
- default:
780
- throw new CodecError(`Unsupported NodeId encoding format: ${format}`);
781
- }
782
- }
783
- /**
784
- * Encode an ExpandedNodeId in binary format.
785
- * @see OPC 10000-6 Table 20
786
- */
787
- writeExpandedNodeId(value) {
788
- const startPos = this.position;
789
- this.writeNodeId(value);
790
- let encodingByte = this.buffer[startPos];
791
- if (value.namespaceUri !== void 0) {
792
- encodingByte |= ExpandedNodeIdMask.NamespaceUriFlag;
793
- }
794
- if (value.serverIndex !== void 0) {
795
- encodingByte |= ExpandedNodeIdMask.ServerIndexFlag;
796
- }
797
- this.buffer[startPos] = encodingByte;
798
- if (value.namespaceUri !== void 0) {
799
- this.writeString(value.namespaceUri);
800
- }
801
- if (value.serverIndex !== void 0) {
802
- this.writeUInt32(value.serverIndex);
803
- }
804
- }
805
- /**
806
- * Encode a StatusCode as a UInt32.
807
- * @see OPC 10000-6 Section 5.2.2.16
808
- */
809
- writeStatusCode(value) {
810
- this.writeUInt32(value);
811
- }
812
- /**
813
- * Encode a QualifiedName as NamespaceIndex (UInt16) + Name (String).
814
- * @see OPC 10000-6 Table 8
815
- */
816
- writeQualifiedName(value) {
817
- this.writeUInt16(value.namespaceIndex);
818
- this.writeString(value.name);
819
- }
820
- /**
821
- * Encode a LocalizedText with optional locale and text.
822
- * @see OPC 10000-6 Table 9
823
- */
824
- writeLocalizedText(value) {
825
- let encodingMask = 0;
826
- if (value.locale !== void 0 && value.locale !== "") {
827
- encodingMask |= LocalizedTextMask.LocaleFlag;
828
- }
829
- if (value.text !== "") {
830
- encodingMask |= LocalizedTextMask.TextFlag;
831
- }
832
- this.writeByte(encodingMask);
833
- if (encodingMask & LocalizedTextMask.LocaleFlag) {
834
- this.writeString(value.locale);
835
- }
836
- if (encodingMask & LocalizedTextMask.TextFlag) {
837
- this.writeString(value.text);
838
- }
839
- }
840
- /**
841
- * Encode an ExtensionObject with its TypeId and body.
842
- * @see OPC 10000-6 Section 5.2.2.15
843
- */
844
- writeExtensionObject(value, encoder) {
845
- const typeId = value.typeId;
846
- if ("namespaceUri" in typeId || "serverIndex" in typeId) {
847
- this.writeExpandedNodeId(typeId);
848
- } else {
849
- this.writeNodeId(typeId);
850
- }
851
- this.writeByte(value.encoding);
852
- switch (value.encoding) {
853
- case 0 /* None */:
854
- break;
855
- case 1 /* Binary */:
856
- if (!value.data) {
857
- throw new CodecError("ExtensionObject with Binary encoding must have data");
858
- }
859
- const binaryData = encoder.encodeWithoutId(value.data, "binary");
860
- this.writeByteString(binaryData);
861
- break;
862
- case 2 /* Xml */:
863
- if (!value.data) {
864
- throw new CodecError("ExtensionObject with Xml encoding must have data");
865
- }
866
- const xmlString = encoder.encodeWithoutId(value.data, "xml");
867
- this.writeXmlElement(xmlString);
868
- break;
869
- default:
870
- throw new CodecError(`Invalid ExtensionObject encoding: ${value.encoding}`);
871
- }
872
- }
873
- /**
874
- * Encode a DataValue with optional fields controlled by an encoding mask.
875
- * @see OPC 10000-6 Table 26
876
- */
877
- writeDataValue(value, encoder) {
878
- let encodingMask = 0;
879
- if (value.value !== null && value.value !== void 0) {
880
- encodingMask |= DataValueMaskBits.Value;
881
- }
882
- if (value.statusCode !== null) {
883
- encodingMask |= DataValueMaskBits.StatusCode;
884
- }
885
- if (value.sourceTimestamp !== null) {
886
- encodingMask |= DataValueMaskBits.SourceTimestamp;
887
- }
888
- if (value.serverTimestamp !== null) {
889
- encodingMask |= DataValueMaskBits.ServerTimestamp;
890
- }
891
- if (value.sourcePicoseconds !== null) {
892
- encodingMask |= DataValueMaskBits.SourcePicoseconds;
893
- }
894
- if (value.serverPicoseconds !== null) {
895
- encodingMask |= DataValueMaskBits.ServerPicoseconds;
896
- }
897
- this.writeByte(encodingMask);
898
- if (encodingMask & DataValueMaskBits.Value) {
899
- this.writeVariant(value.value, encoder);
900
- }
901
- if (encodingMask & DataValueMaskBits.StatusCode) {
902
- this.writeUInt32(value.statusCode ?? 0 /* Good */);
903
- }
904
- if (encodingMask & DataValueMaskBits.SourceTimestamp) {
905
- this.writeDateTime(value.sourceTimestamp);
906
- }
907
- if (encodingMask & DataValueMaskBits.ServerTimestamp) {
908
- this.writeDateTime(value.serverTimestamp);
909
- }
910
- if (encodingMask & DataValueMaskBits.SourcePicoseconds) {
911
- this.writeUInt16(value.sourcePicoseconds);
912
- }
913
- if (encodingMask & DataValueMaskBits.ServerPicoseconds) {
914
- this.writeUInt16(value.serverPicoseconds);
915
- }
916
- }
917
- /**
918
- * Encode a Variant with type ID, value(s), and optional array dimensions.
919
- * @see OPC 10000-6 Section 5.2.2.16
920
- */
921
- writeVariant(value, encoder) {
922
- if (value.variantType < 0 || value.variantType > 25) {
923
- throw new CodecError(`Invalid Variant type ID: ${value.variantType}. Must be 0-25.`);
924
- }
925
- let mask = value.variantType & VariantMask.TypeMask;
926
- const isArrayValue = Array.isArray(value.value);
927
- if (isArrayValue) {
928
- mask |= VariantMask.Array;
929
- }
930
- if (value.arrayDimensions !== void 0 && value.arrayDimensions.length > 0) {
931
- mask |= VariantMask.ArrayDimensions;
932
- }
933
- this.writeByte(mask);
934
- if (isArrayValue) {
935
- const array = value.value;
936
- this.writeInt32(array.length);
937
- for (const elem of array) {
938
- this.writeVariantValue(value.variantType, elem, encoder);
939
- }
940
- } else if (value.variantType !== 0 /* Null */) {
941
- this.writeVariantValue(value.variantType, value.value, encoder);
942
- }
943
- if (value.arrayDimensions !== void 0 && value.arrayDimensions.length > 0) {
944
- this.writeInt32(value.arrayDimensions.length);
945
- for (const dim of value.arrayDimensions) {
946
- this.writeInt32(dim);
947
- }
948
- }
949
- }
950
- /**
951
- * Encode a DiagnosticInfo with optional fields controlled by an encoding mask.
952
- * Supports recursive InnerDiagnosticInfo.
953
- * @see OPC 10000-6 Table 24
954
- */
955
- writeDiagnosticInfo(value) {
956
- let encodingMask = 0;
957
- if (value.symbolicId !== null) {
958
- encodingMask |= DiagnosticInfoMaskBits.SymbolicId;
959
- }
960
- if (value.namespaceUri !== null) {
961
- encodingMask |= DiagnosticInfoMaskBits.NamespaceUri;
962
- }
963
- if (value.localizedText !== null) {
964
- encodingMask |= DiagnosticInfoMaskBits.LocalizedText;
965
- }
966
- if (value.locale !== null) {
967
- encodingMask |= DiagnosticInfoMaskBits.Locale;
968
- }
969
- if (value.additionalInfo !== null) {
970
- encodingMask |= DiagnosticInfoMaskBits.AdditionalInfo;
971
- }
972
- if (value.innerStatusCode !== null) {
973
- encodingMask |= DiagnosticInfoMaskBits.InnerStatusCode;
974
- }
975
- if (value.innerDiagnosticInfo !== null) {
976
- encodingMask |= DiagnosticInfoMaskBits.InnerDiagnosticInfo;
977
- }
978
- this.writeByte(encodingMask);
979
- if (encodingMask & DiagnosticInfoMaskBits.SymbolicId) {
980
- this.writeInt32(value.symbolicId);
981
- }
982
- if (encodingMask & DiagnosticInfoMaskBits.NamespaceUri) {
983
- this.writeInt32(value.namespaceUri);
984
- }
985
- if (encodingMask & DiagnosticInfoMaskBits.LocalizedText) {
986
- this.writeInt32(value.localizedText);
987
- }
988
- if (encodingMask & DiagnosticInfoMaskBits.Locale) {
989
- this.writeInt32(value.locale);
990
- }
991
- if (encodingMask & DiagnosticInfoMaskBits.AdditionalInfo) {
992
- this.writeString(value.additionalInfo);
993
- }
994
- if (encodingMask & DiagnosticInfoMaskBits.InnerStatusCode) {
995
- this.writeUInt32(value.innerStatusCode ?? 0 /* Good */);
996
- }
997
- if (encodingMask & DiagnosticInfoMaskBits.InnerDiagnosticInfo) {
998
- this.writeDiagnosticInfo(value.innerDiagnosticInfo);
999
- }
1000
- }
1001
- // === Private helpers ===
1002
- writeVariantValue(type, value, encoder) {
1003
- switch (type) {
1004
- case 0 /* Null */:
1005
- break;
1006
- case 1 /* Boolean */:
1007
- this.writeBoolean(value);
1008
- break;
1009
- case 2 /* SByte */:
1010
- this.writeSByte(value);
1011
- break;
1012
- case 3 /* Byte */:
1013
- this.writeByte(value);
1014
- break;
1015
- case 4 /* Int16 */:
1016
- this.writeInt16(value);
1017
- break;
1018
- case 5 /* UInt16 */:
1019
- this.writeUInt16(value);
1020
- break;
1021
- case 6 /* Int32 */:
1022
- this.writeInt32(value);
1023
- break;
1024
- case 7 /* UInt32 */:
1025
- this.writeUInt32(value);
1026
- break;
1027
- case 8 /* Int64 */:
1028
- this.writeInt64(value);
1029
- break;
1030
- case 9 /* UInt64 */:
1031
- this.writeUInt64(value);
1032
- break;
1033
- case 10 /* Float */:
1034
- this.writeFloat(value);
1035
- break;
1036
- case 11 /* Double */:
1037
- this.writeDouble(value);
1038
- break;
1039
- case 12 /* String */:
1040
- this.writeString(value);
1041
- break;
1042
- case 13 /* DateTime */:
1043
- this.writeDateTime(value);
1044
- break;
1045
- case 14 /* Guid */:
1046
- this.writeGuid(value);
1047
- break;
1048
- case 15 /* ByteString */:
1049
- this.writeByteString(value);
1050
- break;
1051
- case 16 /* XmlElement */:
1052
- this.writeXmlElement(value);
1053
- break;
1054
- case 17 /* NodeId */:
1055
- this.writeNodeId(value);
1056
- break;
1057
- case 18 /* ExpandedNodeId */:
1058
- this.writeExpandedNodeId(value);
1059
- break;
1060
- case 19 /* StatusCode */:
1061
- this.writeStatusCode(value);
1062
- break;
1063
- case 20 /* QualifiedName */:
1064
- this.writeQualifiedName(value);
1065
- break;
1066
- case 21 /* LocalizedText */:
1067
- this.writeLocalizedText(value);
1068
- break;
1069
- case 22 /* ExtensionObject */:
1070
- this.writeExtensionObject(value, encoder);
1071
- break;
1072
- case 23 /* DataValue */:
1073
- this.writeDataValue(value, encoder);
1074
- break;
1075
- case 24 /* Variant */:
1076
- this.writeVariant(value, encoder);
1077
- break;
1078
- case 25 /* DiagnosticInfo */:
1079
- this.writeDiagnosticInfo(value);
1080
- break;
1081
- default:
1082
- throw new CodecError(`Unsupported Variant type: ${type}`);
1083
- }
1084
- }
1085
- constructor(initialSize = 1024) {
1086
- this.buffer = Buffer.allocUnsafe(initialSize);
1087
- this.position = 0;
1088
- }
1089
- };
1090
-
1091
- // src/configurationClient.ts
1092
398
  var ConfigurationClient = class _ConfigurationClient extends Configuration {
1093
399
  static getSimple(name, company) {
1094
400
  const applicationUri = `urn:${company}:${name}`;