@magic-xpa/engine 4.1300.0-dev4130.143 → 4.1300.0-dev4130.149

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.
@@ -1,9 +1,11 @@
1
1
  import { StringBuilder, Int32, NString, ApplicationException, NNumber, List, Debug, Char, RefParam, NumberStyles, HashUtils, DateTime, Dictionary, Stack, NChar, isNullOrUndefined, WebException, Thread, Encoding, Exception, isUndefined, Hashtable, NotImplementedException, Array_Enumerator, ISO_8859_1_Encoding, Int64 } from '@magic-xpa/mscorelib';
2
- import { XMLConstants, StorageAttribute, ViewRefreshMode, InternalInterface, Logger, StorageAttributeCheck, StrUtil, SubformType, TableBehaviour, MgControlType, ScrollBarThumbType, ForceExit, XmlParser, Misc, Base64, Priority, SyncExecutionHelper, Queue, Constants, DateTimeUtils, Logger_LogLevels, Logger_MessageDirection, MsgInterface, RequestInfo, OSEnvironment, JSON_Utils, UtilDateJpn, UtilStrByteMode, PICInterface, SubscriberClient, WindowType, BrkScope, RaiseAt, CtrlButtonTypeGui } from '@magic-xpa/utils';
2
+ import { XMLConstants, StorageAttribute, ViewRefreshMode, InternalInterface, Logger, StorageAttributeCheck, StrUtil, SubformType, TableBehaviour, MgControlType, ScrollBarThumbType, ForceExit, XmlParser, Misc, Base64, Priority, SyncExecutionHelper, Queue, Constants, DateTimeUtils, Logger_LogLevels, Logger_MessageDirection, MsgInterface, RequestInfo, OSEnvironment, JSON_Utils, UtilDateJpn, UtilStrByteMode, PICInterface, WindowType, BrkScope, RaiseAt, CtrlButtonTypeGui } from '@magic-xpa/utils';
3
3
  import { RecordUtils, GuiFieldBase, ExpVal, BlobType, FieldDef, GuiTaskBase, MgControlBase, PropInterface, GuiDataCollection, CommandType, Commands, HtmlProperties, ControlTable, Modifiers, KeyboardItem, TaskDefinitionIdTableSaxHandler, DisplayConvertor, VectorType, PIC, MgTimer, GuiConstants, RuntimeContextBase, UsernamePasswordCredentials, Styles, Manager, NUM_TYPE, GuiExpressionEvaluator, ExpressionInterface, DataModificationTypes, GuiDataViewBase, ObjectReferencesCollection, EMPTY_DCREF, ObjectReferenceBase, PropTable, FieldsTable as FieldsTable$1, DcValuesBuilderBase, MgFormBase, GuiEnvironment, TaskDefinitionId, Events, Helps, FocusManager, EventsProcessor, UIBridge } from '@magic-xpa/gui';
4
4
  import { HttpHeaders, HttpErrorResponse } from '@angular/common/http';
5
5
  import { timer, Subject } from 'rxjs';
6
6
  import * as CryptoJS from 'crypto-js';
7
+ import { io } from 'socket.io-client';
8
+ import { filter } from 'rxjs/operators';
7
9
 
8
10
  ///
9
11
  /// This class is used to hold references to global objects, using their interfaces/base classes. This allows other objects to access those global objects
@@ -3455,6 +3457,9 @@ class Event {
3455
3457
  case InternalInterface.MG_ACT_DUMP_ENVIRONMENT:
3456
3458
  description = 'Dump Environment';
3457
3459
  break;
3460
+ case InternalInterface.MG_ACT_PUBSUB_TOPIC_PUBLISHED:
3461
+ description = 'Topic Publish';
3462
+ break;
3458
3463
  default:
3459
3464
  description = '';
3460
3465
  break;
@@ -13837,7 +13842,154 @@ class CookieService {
13837
13842
  }
13838
13843
  }
13839
13844
 
13840
- //import { SubscriberClient } from "@magic-xpa/utils"
13845
+ class SubscriberClient {
13846
+ static instance;
13847
+ socket;
13848
+ subscribedTopics = new Set();
13849
+ messageSubject = new Subject();
13850
+ subscriptionsDataSubject = new Subject();
13851
+ constructor(task) {
13852
+ // Connect to the Socket.IO server with subscriber role
13853
+ const serverUrl = EnvParamsTable.Instance.get(ConstInterface.MG_TAG_PUBSUB_SERVER_URI);
13854
+ const taskRef = task;
13855
+ this.socket = io(serverUrl, {
13856
+ query: {
13857
+ role: 'subscriber'
13858
+ //token: '' // TODO: TO be used, in case subscriber needs to be authenticated with separate token.
13859
+ }
13860
+ });
13861
+ // Handle connection
13862
+ this.socket.on('connect', () => {
13863
+ console.log('Connected to server as subscriber:', this.socket.id);
13864
+ });
13865
+ // Handle disconnection
13866
+ this.socket.on('disconnect', () => {
13867
+ console.log('Disconnected from server');
13868
+ this.subscribedTopics.clear(); //TODO: Check what happens if we disconnect and reconnect.
13869
+ });
13870
+ // Handle subscription confirmation
13871
+ this.socket.on('subscribed', (data) => {
13872
+ this.subscribedTopics.add(data.topic);
13873
+ console.log('Subscribed to topic:', data.topic, data.message);
13874
+ });
13875
+ // Handle unsubscription confirmation
13876
+ this.socket.on('unsubscribed', (data) => {
13877
+ this.subscribedTopics.delete(data.topic);
13878
+ console.log('Unsubscribed from topic:', data.topic, data.message);
13879
+ });
13880
+ // Handle errors
13881
+ this.socket.on('error', (error) => {
13882
+ console.error('Socket error:', error.message);
13883
+ });
13884
+ // Handle incoming messages
13885
+ this.socket.on('message', (data) => {
13886
+ this.messageSubject.next(data);
13887
+ console.warn("message", data);
13888
+ EventsManager.Instance.AddTopicPublishedEvent(taskRef, data.topic, data.message);
13889
+ });
13890
+ // Handle subscriptions data
13891
+ this.socket.on('subscriptionsData', (data) => {
13892
+ this.subscriptionsDataSubject.next(data);
13893
+ });
13894
+ }
13895
+ /**
13896
+ * Get the singleton instance of SubscriberClient
13897
+ */
13898
+ static getInstance(task) {
13899
+ if (!SubscriberClient.instance) {
13900
+ SubscriberClient.instance = new SubscriberClient(task);
13901
+ }
13902
+ return SubscriberClient.instance;
13903
+ }
13904
+ /**
13905
+ * Subscribe to a specific topic
13906
+ * @param topic The topic to subscribe to
13907
+ */
13908
+ subscribe(topic) {
13909
+ if (!this.subscribedTopics.has(topic)) {
13910
+ this.socket.emit('subscribe', topic);
13911
+ }
13912
+ }
13913
+ /**
13914
+ * Subscribe to multiple topics at once
13915
+ * @param topics Array of topics to subscribe to
13916
+ */
13917
+ subscribeToTopics(topics) {
13918
+ topics.forEach(topic => this.subscribe(topic));
13919
+ }
13920
+ /**
13921
+ * Unsubscribe from a specific topic
13922
+ * @param topic The topic to unsubscribe from
13923
+ */
13924
+ unsubscribe(topic) {
13925
+ if (this.subscribedTopics.has(topic)) {
13926
+ this.socket.emit('unsubscribe', topic);
13927
+ }
13928
+ }
13929
+ /**
13930
+ * Unsubscribe from multiple topics at once
13931
+ * @param topics Array of topics to unsubscribe from
13932
+ */
13933
+ unsubscribeFromTopics(topics) {
13934
+ topics.forEach(topic => this.unsubscribe(topic));
13935
+ }
13936
+ /**
13937
+ * Unsubscribe from all topics
13938
+ */
13939
+ unsubscribeFromAll() {
13940
+ this.subscribedTopics.forEach(topic => this.unsubscribe(topic));
13941
+ }
13942
+ /**
13943
+ * Check if subscribed to a specific topic
13944
+ * @param topic The topic to check
13945
+ * @returns true if subscribed, false otherwise
13946
+ */
13947
+ isSubscribed(topic) {
13948
+ return this.subscribedTopics.has(topic);
13949
+ }
13950
+ /**
13951
+ * Get all currently subscribed topics
13952
+ * @returns Array of subscribed topics
13953
+ */
13954
+ getSubscribedTopics() {
13955
+ return Array.from(this.subscribedTopics);
13956
+ }
13957
+ /**
13958
+ * Get an Observable for incoming messages from all subscribed topics
13959
+ * @returns Observable that emits message data
13960
+ */
13961
+ onMessage() {
13962
+ return this.messageSubject.asObservable();
13963
+ }
13964
+ /**
13965
+ * Get an Observable for incoming messages from a specific topic
13966
+ * @param topic The topic to filter messages for
13967
+ * @returns Observable that emits message data for the specified topic
13968
+ */
13969
+ onMessageForTopic(topic) {
13970
+ return this.messageSubject.asObservable().pipe(filter((data) => data.topic === topic));
13971
+ }
13972
+ /**
13973
+ * Get current subscriptions (for debugging)
13974
+ */
13975
+ getSubscriptions() {
13976
+ this.socket.emit('getSubscriptions');
13977
+ }
13978
+ /**
13979
+ * Listen for subscriptions data
13980
+ * @returns Observable that emits subscriptions list
13981
+ */
13982
+ onSubscriptionsData() {
13983
+ return this.subscriptionsDataSubject.asObservable();
13984
+ }
13985
+ /**
13986
+ * Disconnect from the server
13987
+ */
13988
+ disconnect() {
13989
+ this.socket.disconnect();
13990
+ }
13991
+ }
13992
+
13841
13993
  class ExpressionEvaluator extends GuiExpressionEvaluator {
13842
13994
  static ASTERISK_CHR = String.fromCharCode(1);
13843
13995
  static QUESTION_CHR = String.fromCharCode(2);
@@ -18593,20 +18745,14 @@ class ExpressionEvaluator extends GuiExpressionEvaluator {
18593
18745
  eval_op_Subscribe(val1, resVal) {
18594
18746
  resVal.Attr = StorageAttribute.BOOLEAN;
18595
18747
  resVal.BoolVal = false;
18596
- let sc = SubscriberClient.getInstance(EnvParamsTable.Instance.get(ConstInterface.MG_TAG_PUBSUB_SERVER_URI));
18748
+ let sc = SubscriberClient.getInstance(this.ExpTask);
18597
18749
  let topics = this.params2arguments(val1, 0, val1.length);
18598
18750
  sc.subscribeToTopics(topics);
18599
- topics.forEach(topic => {
18600
- sc.subscribe(topic);
18601
- });
18602
- // topics.forEach(topic => sc.onMessageForTopic(topic).subscribe(data => {
18603
- // console.log("Received message: " + data.message);
18604
- // }));
18605
18751
  }
18606
18752
  eval_op_UnSubscribe(val1, resVal) {
18607
18753
  resVal.Attr = StorageAttribute.BOOLEAN;
18608
18754
  resVal.BoolVal = false;
18609
- let sc = SubscriberClient.getInstance(EnvParamsTable.Instance.get(ConstInterface.MG_TAG_PUBSUB_SERVER_URI));
18755
+ let sc = SubscriberClient.getInstance(this.ExpTask);
18610
18756
  let topics = this.params2arguments(val1, 0, val1.length);
18611
18757
  sc.unsubscribeFromTopics(topics);
18612
18758
  }
@@ -32646,6 +32792,7 @@ class Task extends TaskBase {
32646
32792
  enable = await this.checkProp(PropInterface.PROP_TYPE_TASK_PROPERTIES_ALLOW_INDEX, true);
32647
32793
  this.ActionManager.enable(InternalInterface.MG_ACT_VIEW_BY_KEY, enable);
32648
32794
  this.ActionManager.enable(InternalInterface.MG_ACT_DUMP_ENVIRONMENT, true);
32795
+ this.ActionManager.enable(InternalInterface.MG_ACT_PUBSUB_TOPIC_PUBLISHED, true);
32649
32796
  }
32650
32797
  /// <summary>
32651
32798
  /// set hasZoomHandler to true
@@ -34868,6 +35015,22 @@ class EventsManager {
34868
35015
  }
34869
35016
  }
34870
35017
  /// <summary>
35018
+ /// Add internal to handle published topic from pubsub middleware
35019
+ /// </summary>
35020
+ /// <param name = "task"> control </param>
35021
+ /// <param name = "topic"> value of control </param>
35022
+ /// <param name = "message"> refresh display </param>
35023
+ AddTopicPublishedEvent(task, topic, message) {
35024
+ const rtEvt = new RunTimeEvent(task); //, false);
35025
+ rtEvt.setInternal(InternalInterface.MG_ACT_PUBSUB_TOPIC_PUBLISHED);
35026
+ let argsList = new Array(2);
35027
+ argsList[0] = new ExpVal(StorageAttribute.ALPHA, false, topic);
35028
+ argsList[1] = new ExpVal(StorageAttribute.ALPHA, false, message);
35029
+ let args = new ArgumentsList(argsList);
35030
+ rtEvt.setArgList(args);
35031
+ this.addToTail(rtEvt);
35032
+ }
35033
+ /// <summary>
34871
35034
  /// Add internal event ro set the value of control
34872
35035
  /// </summary>
34873
35036
  /// <param name = "ctrl"> control </param>
@@ -39696,7 +39859,7 @@ class CommandsTable {
39696
39859
  }
39697
39860
  }
39698
39861
 
39699
- let CurrentClientVersion = '4.1300.0-dev4130.143';
39862
+ let CurrentClientVersion = '4.1300.0-dev4130.149';
39700
39863
 
39701
39864
  // @dynamic
39702
39865
  class ClientManager {
@@ -40310,5 +40473,5 @@ class DataSourceIdKey {
40310
40473
  * Generated bundle index. Do not edit.
40311
40474
  */
40312
40475
 
40313
- export { AbortCommand, AccessHelper, ActionManager, AddLocateCommand, AddRangeCommand, AddSortCommand, AddUserLocateDataViewCommand, AddUserLocateRemoteDataViewCommand, AddUserRangeDataviewCommand, AddUserRangeRemoteDataViewCommand, AddUserSortDataViewCommand, AddUserSortRemoteDataViewCommand, Argument, ArgumentsList, Boundary, BrowserEscEventCommand, CachedFileQueryCommand, ClearEventsOnStopExecution, ClientManager, ClientOriginatedCommand, ClientOriginatedCommandSerializer, ClientOriginatedCommandTaskTag, ClientRefreshCommand, ClientTargetedCommandBase, ClientTargetedCommandType, ColumnSortEventCommand, CommandFactory, CommandSerializationHelper, CommandsProcessorBase, CommandsProcessorBase_SendingInstruction, CommandsProcessorBase_SessionStage, CommandsProcessorManager, CommandsTable, CompMainPrgTable, ComputeEventCommand, ConstInterface, ConstUtils, ContextTerminationEventCommand, ContextTimeoutResetCommand, ControlItemsRefreshCommand, CookieService, CreatedFormVector, CurrentClientVersion, DataSourceIdKey, DataView, DataViewBase, DataViewCommandBase, DataViewCommandType, DataViewOutputCommand, DataviewCommand, DataviewHeaderBase, DataviewHeaderFactory, DataviewHeaders, DataviewHeadersSaxHandler, DataviewManager, DataviewManagerBase, DcValuesReference, DummyDataViewCommand, DvCache, EnhancedVerifyCommand, EnvParamsTable, Environment, EnvironmentDetails, EvaluateCommand, Event, EventCommand, EventHandler, EventHandlerPosition, EventSubType, EventsAllowedType, EventsManager, ExecOperCommand, ExecutionStack, ExecutionStackEntry, ExpDesc, ExpStrTracker, ExpTable, Expression, ExpressionDict, ExpressionEvaluator, ExpressionLocalJpn, Expression_ReturnValue, FetchDataControlValuesEventCommand, Field, FieldBase, FieldsTable as FieldsTableExt, FlowMonitorInterface, FlowMonitorQueue, FormsTable, GUIManager, GlobalCommandsManager, GlobalParams, GlobalParamsQueryCommand, GuiEventsProcessor, HandlersTable, HeapSort, HttpClientAsync, HttpClientBase, HttpClientEvents, HttpClientSync, HttpManager, HttpUtility, IClientTargetedCommand, IndexChangeEventCommand, IniputForceWriteCommand, InteractiveCommunicationsFailureHandler, Key, LanguageData, LastFocusedManager, MGData, MGDataCollection, MagicBridge, MgControl, MgForm, MgPriorityBlockingQueue, MgPriorityQueue, MirrorExpVal, MirrorPrmMap, MirrorString, NonReversibleExitEventCommand, NullValueException, OpenURLCommand, OpeningTaskDetails, Operation, OperationTable, ParamParseResult, PrmMap, QueryCommand, RCTimer, Recompute, RecomputeCommand, RecomputeTable, Recompute_RcmpBy, Record, RecordOutOfDataViewException, RecordOutOfDataViewException_ExceptionType, RecordsTable, RefreshEventCommand, RefreshScreenEventCommand, RemoteCommandsProcessor, RemoteControlItemsRefreshCommand, RemoteDataViewCommandBase, RemoteDataViewCommandFactory, RemoteDataViewCommandUpdateNonModifiable, RemoteDataviewHeader, RemoteDataviewManager, RemoteTaskService, RequestMethod, ResetLocateCommand, ResetRangeCommand, ResetSortCommand, ResetUserLocateRemoteDataviewCommand, ResetUserRangeRemoteDataviewCommand, ResetUserSortRemoteDataviewCommand, ResultCommand, ResultValue, RetVals, ReturnResult, ReturnResultBase, RollbackEventCommand, RollbackEventCommand_RollbackType, RunTimeEvent, RunTimeEventBase, SET_DISPLAYLINE_BY_DV, Scrambler, SelectProgramCommand, ServerConfig, ServerError, SetTransactionStateDataviewCommand, SetTransactionStateRemoteDataViewCommand, Sort, SortCollection, SubformOpenEventCommand, SubformRefreshEventCommand, TableCache, TableCacheManager, Task, TaskBase, TaskServiceBase, TaskTransactionManager, Task_Direction, Task_Flow, Task_SubformExecModeEnum, TasksTable, Transaction, TransactionCommand, UniqueIDUtils, UnloadCommand, UserDetails, UserEventsTable, UserRange, VerifyCommand, WriteMessageToServerLogCommand, XMLBasedCommandBuilder, XMLBasedDcValuesBuilder, YesNoExp, getGuiEventObj };
40476
+ export { AbortCommand, AccessHelper, ActionManager, AddLocateCommand, AddRangeCommand, AddSortCommand, AddUserLocateDataViewCommand, AddUserLocateRemoteDataViewCommand, AddUserRangeDataviewCommand, AddUserRangeRemoteDataViewCommand, AddUserSortDataViewCommand, AddUserSortRemoteDataViewCommand, Argument, ArgumentsList, Boundary, BrowserEscEventCommand, CachedFileQueryCommand, ClearEventsOnStopExecution, ClientManager, ClientOriginatedCommand, ClientOriginatedCommandSerializer, ClientOriginatedCommandTaskTag, ClientRefreshCommand, ClientTargetedCommandBase, ClientTargetedCommandType, ColumnSortEventCommand, CommandFactory, CommandSerializationHelper, CommandsProcessorBase, CommandsProcessorBase_SendingInstruction, CommandsProcessorBase_SessionStage, CommandsProcessorManager, CommandsTable, CompMainPrgTable, ComputeEventCommand, ConstInterface, ConstUtils, ContextTerminationEventCommand, ContextTimeoutResetCommand, ControlItemsRefreshCommand, CookieService, CreatedFormVector, CurrentClientVersion, DataSourceIdKey, DataView, DataViewBase, DataViewCommandBase, DataViewCommandType, DataViewOutputCommand, DataviewCommand, DataviewHeaderBase, DataviewHeaderFactory, DataviewHeaders, DataviewHeadersSaxHandler, DataviewManager, DataviewManagerBase, DcValuesReference, DummyDataViewCommand, DvCache, EnhancedVerifyCommand, EnvParamsTable, Environment, EnvironmentDetails, EvaluateCommand, Event, EventCommand, EventHandler, EventHandlerPosition, EventSubType, EventsAllowedType, EventsManager, ExecOperCommand, ExecutionStack, ExecutionStackEntry, ExpDesc, ExpStrTracker, ExpTable, Expression, ExpressionDict, ExpressionEvaluator, ExpressionLocalJpn, Expression_ReturnValue, FetchDataControlValuesEventCommand, Field, FieldBase, FieldsTable as FieldsTableExt, FlowMonitorInterface, FlowMonitorQueue, FormsTable, GUIManager, GlobalCommandsManager, GlobalParams, GlobalParamsQueryCommand, GuiEventsProcessor, HandlersTable, HeapSort, HttpClientAsync, HttpClientBase, HttpClientEvents, HttpClientSync, HttpManager, HttpUtility, IClientTargetedCommand, IndexChangeEventCommand, IniputForceWriteCommand, InteractiveCommunicationsFailureHandler, Key, LanguageData, LastFocusedManager, MGData, MGDataCollection, MagicBridge, MgControl, MgForm, MgPriorityBlockingQueue, MgPriorityQueue, MirrorExpVal, MirrorPrmMap, MirrorString, NonReversibleExitEventCommand, NullValueException, OpenURLCommand, OpeningTaskDetails, Operation, OperationTable, ParamParseResult, PrmMap, QueryCommand, RCTimer, Recompute, RecomputeCommand, RecomputeTable, Recompute_RcmpBy, Record, RecordOutOfDataViewException, RecordOutOfDataViewException_ExceptionType, RecordsTable, RefreshEventCommand, RefreshScreenEventCommand, RemoteCommandsProcessor, RemoteControlItemsRefreshCommand, RemoteDataViewCommandBase, RemoteDataViewCommandFactory, RemoteDataViewCommandUpdateNonModifiable, RemoteDataviewHeader, RemoteDataviewManager, RemoteTaskService, RequestMethod, ResetLocateCommand, ResetRangeCommand, ResetSortCommand, ResetUserLocateRemoteDataviewCommand, ResetUserRangeRemoteDataviewCommand, ResetUserSortRemoteDataviewCommand, ResultCommand, ResultValue, RetVals, ReturnResult, ReturnResultBase, RollbackEventCommand, RollbackEventCommand_RollbackType, RunTimeEvent, RunTimeEventBase, SET_DISPLAYLINE_BY_DV, Scrambler, SelectProgramCommand, ServerConfig, ServerError, SetTransactionStateDataviewCommand, SetTransactionStateRemoteDataViewCommand, Sort, SortCollection, SubformOpenEventCommand, SubformRefreshEventCommand, SubscriberClient, TableCache, TableCacheManager, Task, TaskBase, TaskServiceBase, TaskTransactionManager, Task_Direction, Task_Flow, Task_SubformExecModeEnum, TasksTable, Transaction, TransactionCommand, UniqueIDUtils, UnloadCommand, UserDetails, UserEventsTable, UserRange, VerifyCommand, WriteMessageToServerLogCommand, XMLBasedCommandBuilder, XMLBasedDcValuesBuilder, YesNoExp, getGuiEventObj };
40314
40477
  //# sourceMappingURL=magic-xpa-engine.mjs.map