cordova-plugin-unvired-universal-sdk 1.0.6 → 1.0.9

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.
Files changed (76) hide show
  1. package/package.json +1 -1
  2. package/plugin.xml +2 -14
  3. package/www/kernel.js +38344 -1243
  4. package/aar/README.md +0 -3
  5. package/aar/Unvired_Kernel_Android.aar +0 -0
  6. package/aar/Unvired_Kernel_HTML5_Android.aar +0 -0
  7. package/src/android/build.gradle +0 -35
  8. package/src/android/xml/provider_paths.xml +0 -21
  9. package/src/browser/UnviredPluginProxy.js +0 -2430
  10. package/src/browser/bootstrap.min.js +0 -17
  11. package/src/browser/codemirror.js +0 -9755
  12. package/src/browser/jquery-3.2.1.js +0 -10253
  13. package/src/browser/sql-wasm.wasm +0 -0
  14. package/src/browser/sql.js +0 -203
  15. package/src/browser/src_index_worker_js.unvired-db-worker.js +0 -231
  16. package/src/browser/unvired-db-worker.js +0 -166
  17. package/src/browser/vendors-node_modules_comlink_dist_esm_comlink_mjs.unvired-db-worker.js +0 -22
  18. package/src/ios/AttachmentPlugin.h +0 -21
  19. package/src/ios/AttachmentPlugin.m +0 -180
  20. package/src/ios/DataStructureHelper.h +0 -28
  21. package/src/ios/DataStructureHelper.m +0 -188
  22. package/src/ios/IOSAuthPlugin.h +0 -14
  23. package/src/ios/IOSAuthPlugin.m +0 -13
  24. package/src/ios/IOSDatabasePlugin.h +0 -28
  25. package/src/ios/IOSDatabasePlugin.m +0 -253
  26. package/src/ios/IOSFWSettingsPlugin.h +0 -65
  27. package/src/ios/IOSFWSettingsPlugin.m +0 -363
  28. package/src/ios/IOSLoggerPlugin.h +0 -34
  29. package/src/ios/IOSLoggerPlugin.m +0 -198
  30. package/src/ios/IOSLoginPlugin.h +0 -29
  31. package/src/ios/IOSLoginPlugin.m +0 -480
  32. package/src/ios/IOSProxyPlugin.h +0 -21
  33. package/src/ios/IOSProxyPlugin.m +0 -172
  34. package/src/ios/IOSSyncEnginePlugin.h +0 -54
  35. package/src/ios/IOSSyncEnginePlugin.m +0 -847
  36. package/src/ios/PluginConstants.h +0 -195
  37. package/src/ios/PluginHelper.h +0 -29
  38. package/src/ios/PluginHelper.m +0 -74
  39. package/src/ios/SyncHTML5Response.h +0 -50
  40. package/src/ios/SyncHTML5Response.m +0 -68
  41. package/www/applicationMeta/applicationMetadataParser.ts +0 -285
  42. package/www/applicationMeta/fieldConstants.ts +0 -92
  43. package/www/attachment/attachmentHelper.ts +0 -326
  44. package/www/attachment/attachmentQHelper.ts +0 -158
  45. package/www/attachment/attachmentService.ts +0 -259
  46. package/www/authenticationService.ts +0 -751
  47. package/www/database/appDatabaseManager.ts +0 -54
  48. package/www/database/databaseManager.ts +0 -616
  49. package/www/helper/dbCreateTablesManager.ts +0 -354
  50. package/www/helper/frameworkHelper.ts +0 -127
  51. package/www/helper/frameworkSettingsManager.ts +0 -287
  52. package/www/helper/getMessageTimerManager.ts +0 -81
  53. package/www/helper/httpConnection.ts +0 -1051
  54. package/www/helper/logger.ts +0 -312
  55. package/www/helper/notificationListnerHelper.ts +0 -56
  56. package/www/helper/passcodeGenerator.ts +0 -61
  57. package/www/helper/reconciler.ts +0 -1062
  58. package/www/helper/serverResponseHandler.ts +0 -677
  59. package/www/helper/serviceConstants.ts +0 -254
  60. package/www/helper/settingsHelper.ts +0 -386
  61. package/www/helper/status.ts +0 -83
  62. package/www/helper/syncInputDataManager.ts +0 -205
  63. package/www/helper/unviredAccount.ts +0 -104
  64. package/www/helper/unviredAccountManager.ts +0 -120
  65. package/www/helper/urlService.ts +0 -43
  66. package/www/helper/userSettingsManager.ts +0 -172
  67. package/www/helper/utils.ts +0 -110
  68. package/www/inbox/downloadMessageService.ts +0 -270
  69. package/www/inbox/inboxHelper.ts +0 -132
  70. package/www/inbox/inboxService.ts +0 -223
  71. package/www/outbox/outboxAttachmentManager.ts +0 -152
  72. package/www/outbox/outboxHelper.ts +0 -67
  73. package/www/outbox/outboxService.ts +0 -519
  74. package/www/subtract.ts +0 -5
  75. package/www/sum.ts +0 -4
  76. package/www/syncEngine.ts +0 -687
@@ -1,519 +0,0 @@
1
- import DatabaseManager, { DatabaseType } from '../database/databaseManager';
2
- import FrameworkHelper from '../helper/frameworkHelper';
3
- import { FetchAPIResponse, HttpConnection } from '../helper/httpConnection';
4
- import { Logger } from '../helper/logger';
5
- import { RequestType } from '../helper/serviceConstants';
6
- import { Status } from '../helper/status';
7
- import { UnviredAccount } from '../helper/unviredAccount';
8
- import { UnviredAccountManager } from '../helper/unviredAccountManager';
9
- import { ObjectStatus, SyncStatus, isServerReachable } from '../helper/utils';
10
- import * as ServiceConstants from '../helper/serviceConstants';
11
- import * as FieldConstants from '../applicationMeta/fieldConstants';
12
- import OutBoxHelper from './outboxHelper';
13
- import OutboxAttachmentManager from './outboxAttachmentManager';
14
- import { AuthenticationService } from '../authenticationService';
15
- import InboxHelper from '../inbox/inboxHelper';
16
- import DownloadMessageService from '../inbox/downloadMessageService';
17
- import { SyncEngine } from '../syncEngine';
18
- import { DATA, ERROR, ERROR_DETAIL, MESSAGE, NotificationListenerHelper, NotificationListnerType, TYPE } from '../helper/notificationListnerHelper';
19
-
20
-
21
- const fileName = "OutboxService"
22
-
23
- export default class OutboxService {
24
-
25
- private static instance: OutboxService;
26
- private isRunning: boolean = false;
27
- private shouldStop: boolean = false;
28
-
29
- private constructor() {}
30
-
31
- public static getInstance(): OutboxService {
32
- if (!OutboxService.instance) {
33
- OutboxService.instance = new OutboxService();
34
- }
35
- return OutboxService.instance;
36
- }
37
-
38
- public start(): void {
39
- if (this.isRunning) {
40
- Logger.logInfo(fileName, "start", "Download message service is already running.");
41
- return;
42
- }
43
- this.isRunning = true;
44
- this.shouldStop = false;
45
- this.makeNetworkCallWithOutObject();
46
- Logger.logInfo(fileName, "start", "Download message service started.");
47
- }
48
-
49
- public stop(): void {
50
- if (this.isRunning) {
51
- this.shouldStop = true;
52
- Logger.logInfo(fileName, "stop", "Stopping download message service.");
53
- } else {
54
- Logger.logInfo(fileName, "stop", "Download message service is not running.");
55
- }
56
- }
57
-
58
- private async makeNetworkCallWithOutObject() {
59
- let isOutboxEmpty = false;
60
- let data = {};
61
- do {
62
- if (this.shouldStop) {
63
- Logger.logInfo("OutboxService", "makeNetworkCallWithOutObject", "Stopping to process outbox items...");
64
- break;
65
- }
66
- Logger.logInfo("OutboxService", "makeNetworkCallWithOutObject", "Starting to process outbox items...");
67
- const databaseManager = DatabaseManager.getInstance();
68
- const outObjectCount = await databaseManager.count(DatabaseType.FrameworkDb, "OutObject");
69
- if (outObjectCount > 0) {
70
- NotificationListenerHelper.postSynchronizationStateNotification(`sending (${outObjectCount})`);
71
- }
72
- const outObject = await databaseManager.getFirstEntity(DatabaseType.FrameworkDb, "OutObject");
73
- isOutboxEmpty = outObject === null;
74
- if (outObject !== null) {
75
- const outObjectData = outObject;
76
- Logger.logInfo("OutboxService", "makeNetworkCallWithOutObject", `OutObject to send: ${outObjectData.beName} - ${outObjectData.beHeaderLid} - outobject lid ${outObjectData.lid}`);
77
- try {
78
- if (!navigator.onLine) {
79
- break;
80
- }
81
- const lastLoggedInAccount = UnviredAccountManager.getInstance().getLastLoggedInAccount();
82
- if (!(await isServerReachable(lastLoggedInAccount.getServerURL()))) {
83
- break;
84
- }
85
- if (outObjectData.isAdminServices == "true") {
86
- const result = await HttpConnection.makeAdminServicesCall(outObjectData.messageJson, outObjectData.functionName, lastLoggedInAccount, AuthenticationService.instance.loginParameters);
87
- await this.deleteOutObject(outObjectData);
88
- } else {
89
- if (outObjectData.requestType === RequestType.RQST.toString() || outObjectData.requestType === RequestType.REQ.toString()) {
90
- const attachmentUploadSuccess = await new OutboxAttachmentManager().checkAndUploadAttachmentsInOutBox(outObjectData.beName, JSON.parse(outObjectData.messageJson));
91
- if (!attachmentUploadSuccess) {
92
- Logger.logInfo("OutboxService", "makeNetworkCallWithOutObject", "Failed to upload attachments");
93
- await this.createInfoMessage(outObjectData, "Failed to upload attachments", FieldConstants.InfoMessageFailure);
94
- await OutBoxHelper.updateSyncStatusToEntityObjects(outObjectData, SyncStatus.error);
95
- await this.deleteOutObject(outObjectData);
96
- continue;
97
- }
98
- }
99
- let retrySendOnConflict = false;
100
- do {
101
- if (this.shouldStop) {
102
- Logger.logInfo("OutboxService", "makeNetworkCallWithOutObject", "Stop requested. Exiting outbox processing loop.");
103
- break;
104
- }
105
- if (!navigator.onLine) {
106
- Logger.logError("OutboxService", "checkOutBoxAndSendToServer", "No internet connection to process outbox items...");
107
- break;
108
- }
109
- const lastLoggedInAccount = UnviredAccountManager.getInstance().getLastLoggedInAccount();
110
- if (!(await isServerReachable(lastLoggedInAccount.getServerURL()))) {
111
- Logger.logError("OutboxService", "makeNetworkCallWithOutObject", "Server not reachable.");
112
- break;
113
- }
114
- const result = await new HttpConnection().makeSyncCall(outObjectData.messageJson, outObjectData.functionName, lastLoggedInAccount, AuthenticationService.instance.loginParameters);
115
- Logger.logInfo("OutboxService", "makeNetworkCallWithOutObject", `DataSender submitRequest: ${result.httpStatusCode} HeaderLid : ${outObjectData.beHeaderLid}`);
116
- switch (result.httpStatusCode) {
117
- case Status.created:
118
- case Status.noContent:
119
- await this.handleSuccess(result, outObjectData);
120
- break;
121
- case 0:
122
- await this.handleZeroResponse(result, outObjectData);
123
- break;
124
- case Status.conflict:
125
- await new Promise(resolve => setTimeout(resolve, 5000));
126
- Logger.logInfo("OutboxService", "makeNetworkCallWithOutObject", `Retrying after 5 seconds. Retry count: ${data[outObjectData.beHeaderLid]}`);
127
- if (data[outObjectData.beHeaderLid] == null) {
128
- data[outObjectData.beHeaderLid] = 0;
129
- }
130
- retrySendOnConflict = data[outObjectData.beHeaderLid] < 12;
131
- data[outObjectData.beHeaderLid] += 1;
132
- Logger.logInfo("OutboxService", "makeNetworkCallWithOutObject", `Got Status Code: 409 from server. Waiting for 5 seconds and restart the process.`);
133
- if (data[outObjectData.beHeaderLid] >= 12) {
134
- await OutBoxHelper.updateSyncStatusToEntityObjects(outObjectData, SyncStatus.error);
135
- await this.deleteOutObjectAndCreateInfoMessage(outObjectData, "Failed to synchronize with server within 1 minute. Please submit your request again.", true);
136
- }
137
- break;
138
- case Status.badRequest:
139
- case Status.unauthorized:
140
- case Status.forbidden:
141
- case Status.notFound:
142
- case Status.notAcceptable:
143
- case Status.unsupportedMediaType:
144
- case Status.gone:
145
- default:
146
- await this.handleServerError(result, outObjectData);
147
- break;
148
- }
149
- } while (retrySendOnConflict);
150
- if (data[outObjectData.beHeaderLid] != null) {
151
- delete data[outObjectData.beHeaderLid];
152
- }
153
- }
154
- } catch (e) {
155
- Logger.logInfo("OutboxService", "makeNetworkCallWithOutObject", `Exception when processing outObject Message JSON: ${outObjectData.messageJson}`);
156
- Logger.logInfo("OutboxService", "makeNetworkCallWithOutObject", `Exception when processing outObject. MESSAGE : ${e.toString()}... Outobjec Data: ${outObjectData.lid} ${JSON.stringify(outObjectData)}`);
157
- await this.createInfoMessage(outObjectData, e.toString(), FieldConstants.InfoMessageFailure);
158
- await this.updateOutObjectProcessingError(outObjectData);
159
- isOutboxEmpty = true
160
- }
161
- }
162
- } while (!isOutboxEmpty);
163
- Logger.logInfo("OutboxService", "makeNetworkCallWithOutObject", "Outbox is empty. Stopping outbox processing service.")
164
- NotificationListenerHelper.postSynchronizationStateNotification(`idle`);
165
- this.isRunning = false;
166
- this.shouldStop = false;
167
- DownloadMessageService.getInstance().start();
168
- }
169
-
170
- private async handleServerError(result: FetchAPIResponse, outObjectData: any) {
171
- const responseObject = JSON.parse(result.data);
172
- if (responseObject[ServiceConstants.KeyInfoMessage] != null) {
173
- const infoMessages = responseObject[ServiceConstants.KeyInfoMessage];
174
- if (infoMessages.length > 0) {
175
- for (const element of infoMessages) {
176
- const category = element[FieldConstants.FieldInfoMessageCategory];
177
- const message = element[FieldConstants.FieldInfoMessageMessage] ?? "UNI_RESPONSE_ERROR_500_503";
178
- await this.createInfoMessage(outObjectData, message, category);
179
- }
180
- }
181
- // No need to Post Notification to the app
182
- } else if (responseObject[ServiceConstants.KeyError] != null) {
183
- // No need to Post Notification to the app
184
- }
185
- await this.deleteOutObject(outObjectData);
186
- }
187
-
188
- private async handleZeroResponse(result: FetchAPIResponse, outObjectData: any) {
189
- const errorMessage = this.getResponseText(result.httpStatusCode);
190
- Logger.logError("OutboxService", "handleZeroResponse", `HTTP response error. Response code: ${result.httpStatusCode} Response message: ${errorMessage}`);
191
- const msg = `Function: ${outObjectData.functionName}. Message: ${errorMessage}`;
192
- await this.createInfoMessage(outObjectData, msg, FieldConstants.InfoMessageFailure);
193
- await this.deleteOutObject(outObjectData);
194
- }
195
-
196
- private async handleSuccess(result: FetchAPIResponse, outObjectData: any) {
197
-
198
- // if (FrameworkHelper.getPlatform() === "browser") {
199
- // Logger.logInfo("OutboxService", "handleSuccess", "Process browser platform success resposne.");
200
- // // TODO: Need to handle the success response for browser platform.
201
- // return;
202
- // }
203
-
204
- const headers = JSON.parse(result.header);
205
- var conversationId = headers[ServiceConstants.HeaderConstantConversationId.toLowerCase()];
206
- if (FrameworkHelper.getPlatform() == "browser") {
207
- conversationId = FrameworkHelper.getUUID();
208
- }
209
- if (outObjectData.syncType === ServiceConstants.SyncType.ASYNC.toString()) {
210
- if (!conversationId) {
211
- Logger.logError("OutboxService", "handleSuccess", "Conversation Id empty in http header fields.");
212
- await this.deleteOutObjectAndCreateInfoMessage(outObjectData, "Conversation id not available in response. Deleting out object.");
213
- return;
214
- }
215
-
216
- Logger.logInfo("OutboxService", "handleSuccess", `Conversation Id: ${conversationId}`);
217
- Logger.logInfo("OutboxService", "handleSuccess", `Deleting OutObject LID: ${outObjectData.lid}`);
218
-
219
- const deleteResult = await this.deleteOutObject(outObjectData);
220
- const databaseManager = DatabaseManager.getInstance()
221
-
222
- if (outObjectData.requestType === RequestType.RQST.toString()) {
223
- const sentItems = await databaseManager.select(DatabaseType.FrameworkDb, "SentItems", `conversationId='${conversationId}'`)
224
- if (sentItems.length > 0) {
225
- Logger.logInfo("OutboxService", "handleSuccess", `Conversation Id already present in sent items...ignoring Conversation Id: ${outObjectData.conversationId}`);
226
- return;
227
- }
228
- const structureMetas = await databaseManager.select(DatabaseType.FrameworkDb, "StructureMeta", `structureName='${outObjectData.beName}'`);
229
- if (structureMetas.length == 0) {
230
- Logger.logError("OutboxService", "handleSuccess", `Invalid BE. Cannot Upload Attachments. Table Name: ${outObjectData.beName}`);
231
- return;
232
- }
233
- const isAttachmentSupported = await new OutboxAttachmentManager().isAttachmentSupportedForBEName(structureMetas[0].beName);
234
- let attachmentFlag = "";
235
- if (isAttachmentSupported) {
236
- attachmentFlag = "X";
237
- }
238
- try {
239
- if (FrameworkHelper.getPlatform() !== "browser") {
240
- Logger.logInfo("OutboxService", "handleSuccess", `Adding into sent items. Conversation Id: ${conversationId}`);
241
- const sentItem = {
242
- lid: FrameworkHelper.getUUID(),
243
- timestamp: Date.now(),
244
- objectStatus: 0,
245
- syncStatus: 0,
246
- beName: outObjectData.beName,
247
- beHeaderLid: outObjectData.beHeaderLid,
248
- conversationId,
249
- entryDate: Date.now().toString(),
250
- attachmentFlag
251
- };
252
-
253
- const result = await databaseManager.insert(DatabaseType.FrameworkDb, "SentItems", sentItem, true);
254
-
255
- if (result === 0) {
256
- Logger.logInfo("OutboxService", "handleSuccess", `Error while adding into sent items. Conversation Id: ${conversationId}`);
257
- }
258
- }
259
-
260
- await OutBoxHelper.updateSyncStatusToEntityObjects(outObjectData, SyncStatus.sent);
261
-
262
- let headerDataArray = []
263
- try {
264
- headerDataArray = await databaseManager.select(DatabaseType.AppDb, outObjectData.beName, `${FieldConstants.FieldLid}='${outObjectData.beHeaderLid}'`);
265
- } catch (e) {
266
- Logger.logError("OutboxService", "handleSuccess", `DBException caught when querying ${outObjectData.beName}: ${e.toString()}`);
267
- }
268
- NotificationListenerHelper.postDataSenderNotification(headerDataArray, NotificationListnerType.data_send);
269
- } catch (e) {
270
- Logger.logError("OutboxService", "handleSuccess", `Exception caught while adding sent item object to database. Deleting out object. OutObject LID: ${outObjectData.lid}, ${e.toString()}`);
271
- return;
272
- }
273
- } else if (outObjectData.requestType === RequestType.REQ.toString()) {
274
- // No need to Post Notification to the app
275
- await this.updateOutObjectBEWithGlobalStatus(outObjectData);
276
- } else {
277
- // No need to Post Notification to the app
278
- }
279
- if (FrameworkHelper.getPlatform() == "browser") {
280
- const responseData = JSON.parse(result.data);
281
- const headerObj = JSON.parse(result.header);
282
- const conversationId = headerObj[ServiceConstants.HeaderConstantConversationId.toLowerCase()];
283
- let requestType = headerObj[ServiceConstants.HeaderConstantRequestType.toLowerCase()];
284
- let type = -1;
285
- let subType = -1;
286
- let appId = "";
287
- let serverId = "";
288
- let applicationName = "";
289
-
290
- if (ServiceConstants.Type in responseData && ServiceConstants.Subtype in responseData) {
291
- type = responseData[ServiceConstants.Type];
292
- subType = responseData[ServiceConstants.Subtype];
293
- appId = responseData[ServiceConstants.ApplicationId];
294
- serverId = responseData[ServiceConstants.ServerId];
295
- applicationName = responseData[ServiceConstants.AppName];
296
- }
297
-
298
- if (headerObj[ServiceConstants.HeaderConstantPullMode] === ServiceConstants.PullModeDelete) {
299
- requestType = "PULL_D";
300
- }
301
- const inObjectData: any = {
302
- lid: FrameworkHelper.getUUID(),
303
- timestamp: Date.now(),
304
- objectStatus: ObjectStatus.global,
305
- syncStatus: SyncStatus.none,
306
- conversationId: conversationId,
307
- requestType: requestType,
308
- jsonData: outObjectData.beName,
309
- beLid: outObjectData.beHeaderLid,
310
- subtype: subType,
311
- serverId: serverId,
312
- type: type,
313
- appName: applicationName,
314
- appId: appId
315
- };
316
-
317
- const inObjectsArray = await databaseManager.select(DatabaseType.FrameworkDb, "InObject", `conversationId = '${conversationId}'`)
318
- if (inObjectsArray.length == 0) {
319
- try {
320
- await InboxHelper.addInBoxData(conversationId, JSON.stringify(responseData));
321
- }
322
- catch (e) {
323
- Logger.logError(fileName, "downloadMessage", `Failed to add inbox data to file. Error: ${JSON.stringify(e)}`);
324
- return false;
325
- }
326
- await databaseManager.insert(DatabaseType.FrameworkDb, "InObject", inObjectData, true);
327
- }
328
- }
329
- } else {
330
- await this.deleteOutObject(outObjectData);
331
- }
332
- }
333
-
334
- private async updateOutObjectBEWithGlobalStatus(outObjectData: any) {
335
- const databaseManager = DatabaseManager.getInstance()
336
- const structureMetas = await databaseManager.select(DatabaseType.FrameworkDb, "StructureMeta", `structureName = '${outObjectData.beName}' AND isHeader = '1'`);
337
- if (structureMetas.length > 0) {
338
- let result = [];
339
- try {
340
- result = await databaseManager.select(DatabaseType.AppDb, outObjectData.beName, `${FieldConstants.FieldLid} = '${outObjectData.beHeaderLid}'`);
341
- console.log("OutboxService | updateOutObjectBEWithGlobalStatus | result: ", result);
342
- } catch (e) {
343
- Logger.logError("OutboxService", "updateOutObjectBEWithGlobalStatus", `DBException caught when querying ${outObjectData.beName}: ${e.toString()}`);
344
- return
345
- }
346
- if (result.length > 0) {
347
- try {
348
- const beData = result[0];
349
- await databaseManager.update(DatabaseType.AppDb, outObjectData.beName, {
350
- [FieldConstants.FieldSyncStatus]: SyncStatus.none,
351
- [FieldConstants.FieldInfoMsgCat]: ""
352
- }, `${FieldConstants.FieldLid}='${beData[FieldConstants.FieldLid]}'`, true); // isFromApp is true because it just need to update the data and should not set the missing fields to null.
353
- const childStructureMetas = await databaseManager.select(DatabaseType.FrameworkDb, "StructureMeta", `beName = '${structureMetas[0].beName}' AND isHeader != '1'`)
354
-
355
- for (const childStructureMetaData of childStructureMetas) {
356
- await databaseManager.update(DatabaseType.AppDb, childStructureMetaData.structureName, {
357
- [FieldConstants.FieldSyncStatus]: SyncStatus.none
358
- }, `${FieldConstants.FieldFid}='${beData[FieldConstants.FieldLid]}' AND ${FieldConstants.FieldObjectStatus} != ${ObjectStatus.global}`, true); // isFromApp is true because it just need to update the data and should not set the missing fields to null.
359
- }
360
- } catch (e) {
361
- Logger.logError("OutboxService", "updateOutObjectBEWithGlobalStatus", `DBException caught when updating ${outObjectData.beName}: ${e.toString()}`);
362
- }
363
- }
364
- }
365
- }
366
-
367
- private async deleteOutObjectAndCreateInfoMessage(outObjectData: any, message: string, isInfoRequired = false) {
368
- if (outObjectData != null) {
369
- await this.deleteOutObject(outObjectData);
370
- if (!isInfoRequired) {
371
- return;
372
- }
373
- try {
374
- const list = new TextEncoder().encode(outObjectData.messageJson);
375
- const bytes = new Uint8Array(list);
376
- const infoMessageData = {
377
- lid: FrameworkHelper.getUUID(),
378
- timestamp: Date.now(),
379
- objectStatus: 0,
380
- syncStatus: 0,
381
- type: "type",
382
- subtype: "subtype",
383
- category: FieldConstants.InfoMessageError,
384
- message,
385
- bename: outObjectData.beName,
386
- belid: outObjectData.beHeaderLid,
387
- messagedetails: bytes
388
- };
389
- const databaseManager = DatabaseManager.getInstance();
390
- await databaseManager.insert(DatabaseType.FrameworkDb, "InfoMessage", infoMessageData, true);
391
- const infoMessageClientData = {
392
- LID: infoMessageData.lid,
393
- TIMESTAMP: infoMessageData.timestamp,
394
- OBJECT_STATUS: infoMessageData.objectStatus,
395
- SYNC_STATUS: infoMessageData.syncStatus,
396
- TYPE: infoMessageData.type,
397
- SUBTYPE: infoMessageData.subtype,
398
- CATEGORY: infoMessageData.category,
399
- MESSAGE: infoMessageData.message,
400
- BE_NAME: infoMessageData.bename,
401
- BE_LID: infoMessageData.belid,
402
- MESSAGE_BLOB: bytes
403
- };
404
- NotificationListenerHelper.postDataSenderNotification([infoMessageClientData], NotificationListnerType.infoMessage);
405
- } catch (e) {
406
- Logger.logInfo("OutboxService", "deleteOutObjectAndCreateInfoMessage", `DBException caught while inserting Info Message: ${JSON.stringify(e)}`);
407
- }
408
- }
409
- }
410
-
411
- private async updateOutObjectProcessingError(outObjectData: any) {
412
- try {
413
- outObjectData["fieldOutObjectStatus"] = ServiceConstants.OutObjectStatus.errorOnProcessing.toString();
414
- const databaseManager = DatabaseManager.getInstance();
415
- await databaseManager.update(DatabaseType.FrameworkDb, "OutObject", outObjectData, `${FieldConstants.FieldLid}='${outObjectData[FieldConstants.FieldLid]}'`);
416
- await OutBoxHelper.updateSyncStatusToEntityObjects(outObjectData, SyncStatus.error);
417
- } catch (e) {
418
- Logger.logInfo("OutboxService", "updateOutObjectProcessingError", `DBException caught while updating OutObject: ${JSON.stringify(e)}`);
419
- }
420
- }
421
-
422
- private async createInfoMessage(outObjectData: any, errorMessage: string, category: string) {
423
- const list = new TextEncoder().encode(outObjectData.messageJson);
424
- const bytes = new Uint8Array(list);
425
- const infoMessageData = {
426
- lid: FrameworkHelper.getUUID(),
427
- timestamp: Date.now(),
428
- objectStatus: ObjectStatus.global,
429
- syncStatus: SyncStatus.none,
430
- type: "",
431
- subtype: "",
432
- category,
433
- message: errorMessage,
434
- bename: outObjectData.beName,
435
- belid: outObjectData.beHeaderLid,
436
- messagedetails: bytes
437
- };
438
- const databaseManager = DatabaseManager.getInstance();
439
- await databaseManager.insert(DatabaseType.FrameworkDb, "InfoMessage", infoMessageData, true);
440
- }
441
-
442
- private async deleteOutObject(outObjectData: any) {
443
- try {
444
- const databaseManager = DatabaseManager.getInstance();
445
- await databaseManager.delete(DatabaseType.FrameworkDb, "OutObject", `${FieldConstants.FieldLid}='${outObjectData[FieldConstants.FieldLid.toLowerCase()]}'`);
446
- Logger.logInfo("OutboxService", "deleteOutObject", `After delete is called. LID: ${outObjectData[FieldConstants.FieldLid.toLowerCase()]}`);
447
- return true;
448
- } catch (e) {
449
- Logger.logError("OutboxService", "deleteOutObject", `DBException caught while deleting OutObject: ${JSON.stringify(e)}`);
450
- return false;
451
- }
452
- }
453
-
454
- private getResponseText(responseCode: number) {
455
- let text = "";
456
-
457
- switch (responseCode) {
458
- case 0:
459
- case -1:
460
- text = "Cannot connect to server. Please try again later.";
461
- break;
462
- case 200:
463
- text = "Successful.";
464
- break;
465
- case 204:
466
- text = "No content. The server successfully processed the request, but is not returning any content.";
467
- break;
468
- case 400:
469
- text = "Bad request. The request could not be understood by the server due to malformed syntax.";
470
- break;
471
- case 401:
472
- text = "Unauthorized request. The request requires user authentication.";
473
- break;
474
- case 403:
475
- text = "Forbidden. The server understood the request, but is refusing to fulfill it.";
476
- break;
477
- case 404:
478
- text = "Not found. The server has not found anything matching the Request-URI.";
479
- break;
480
- case 405:
481
- text = "Method not allowed. The method specified in the Request-Line is not allowed for the resource identified by the Request-URI.";
482
- break;
483
- case 406:
484
- text = "Not acceptable.";
485
- break;
486
- case 407:
487
- text = "Proxy authentication required.";
488
- break;
489
- case 408:
490
- text = "Request timeout. The client did not produce a request within the time that the server was prepared to wait.";
491
- break;
492
- case 410:
493
- text = "Gone. The requested resource is no longer available at the server and no forwarding address is known.";
494
- break;
495
- case 500:
496
- text = "Internal server error. The server encountered an unexpected condition which prevented it from fulfilling the request.";
497
- break;
498
- case 501:
499
- text = "Not implemented. The server does not support the functionality required to fulfill the request.";
500
- break;
501
- case 502:
502
- text = "Bad gateway. The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.";
503
- break;
504
- case 503:
505
- text = "Service unavailable. The server is currently unable to handle the request due to a temporary overloading or maintenance of the server.";
506
- break;
507
- case 504:
508
- text = "Gateway timeout. The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI.";
509
- break;
510
- case 505:
511
- text = "HTTP version not supported. The server does not support, or refuses to support, the HTTP protocol version that was used in the request message.";
512
- break;
513
- default:
514
- break;
515
- }
516
-
517
- return text;
518
- }
519
- }
package/www/subtract.ts DELETED
@@ -1,5 +0,0 @@
1
- function sub(a: number, b: number): any {
2
- return {"a":a, "b":b, "result":a - b};
3
- }
4
- export default sub;
5
-
package/www/sum.ts DELETED
@@ -1,4 +0,0 @@
1
- function sum(a: number, b: number): number {
2
- return a + b;
3
- }
4
- export default sum;