cordova-plugin-unvired-universal-sdk 1.0.5 → 1.0.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.
Files changed (76) hide show
  1. package/package.json +1 -1
  2. package/plugin.xml +1 -13
  3. package/www/kernel.js +38345 -1239
  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,83 +0,0 @@
1
- export abstract class Status {
2
- static readonly continue: number = 100;
3
- static readonly switchingProtocols: number = 101;
4
-
5
- static readonly processing: number = 102;
6
- static readonly ok: number = 200;
7
- static readonly created: number = 201;
8
- static readonly accepted: number = 202;
9
- static readonly nonAuthoritativeInformation: number = 203;
10
- static readonly noContent: number = 204;
11
- static readonly resetContent: number = 205;
12
- static readonly partialContent: number = 206;
13
-
14
- static readonly multiStatus: number = 207;
15
-
16
- static readonly alreadyReported: number = 208;
17
-
18
- static readonly imUsed: number = 226;
19
- static readonly multipleChoices: number = 300;
20
- static readonly movedPermanently: number = 301;
21
- static readonly found: number = 302;
22
- static readonly movedTemporarily: number = 302; // Common alias for found.
23
- static readonly seeOther: number = 303;
24
- static readonly notModified: number = 304;
25
- static readonly useProxy: number = 305;
26
- static readonly temporaryRedirect: number = 307;
27
-
28
- static readonly permanentRedirect: number = 308;
29
- static readonly badRequest: number = 400;
30
- static readonly unauthorized: number = 401;
31
- static readonly paymentRequired: number = 402;
32
- static readonly forbidden: number = 403;
33
- static readonly notFound: number = 404;
34
- static readonly methodNotAllowed: number = 405;
35
- static readonly notAcceptable: number = 406;
36
- static readonly proxyAuthenticationRequired: number = 407;
37
- static readonly requestTimeout: number = 408;
38
- static readonly conflict: number = 409;
39
- static readonly gone: number = 410;
40
- static readonly lengthRequired: number = 411;
41
- static readonly preconditionFailed: number = 412;
42
- static readonly requestEntityTooLarge: number = 413;
43
- static readonly requestUriTooLong: number = 414;
44
- static readonly unsupportedMediaType: number = 415;
45
- static readonly requestedRangeNotSatisfiable: number = 416;
46
- static readonly expectationFailed: number = 417;
47
-
48
- static readonly misdirectedRequest: number = 421;
49
-
50
- static readonly unprocessableEntity: number = 422;
51
-
52
- static readonly locked: number = 423;
53
-
54
- static readonly failedDependency: number = 424;
55
- static readonly upgradeRequired: number = 426;
56
-
57
- static readonly preconditionRequired: number = 428;
58
-
59
- static readonly tooManyRequests: number = 429;
60
-
61
- static readonly requestHeaderFieldsTooLarge: number = 431;
62
-
63
- static readonly connectionClosedWithoutResponse: number = 444;
64
-
65
- static readonly unavailableForLegalReasons: number = 451;
66
-
67
- static readonly clientClosedRequest: number = 499;
68
- static readonly internalServerError: number = 500;
69
- static readonly notImplemented: number = 501;
70
- static readonly badGateway: number = 502;
71
- static readonly serviceUnavailable: number = 503;
72
- static readonly gatewayTimeout: number = 504;
73
- static readonly versionNotSupported: number = 505;
74
- static readonly variantAlsoNegotiates: number = 506;
75
- static readonly insufficientStorage: number = 507;
76
- static readonly loopDetected: number = 508;
77
- static readonly notExtended: number = 510;
78
- static readonly networkAuthenticationRequired: number = 511;
79
-
80
- // Client generated status code.
81
- static readonly networkConnectTimeoutError: number = 599;
82
- static readonly submittedToOutbox: number = 600;
83
- }
@@ -1,205 +0,0 @@
1
- import { StructureMeta } from "../applicationMeta/applicationMetadataParser";
2
- import { DatabaseManager, DatabaseType } from "../database/databaseManager";
3
- import FrameworkHelper from "./frameworkHelper";
4
- import { Logger } from "./logger";
5
- import { ObjectStatus, SyncStatus, isServerReachable } from "./utils";
6
- import * as FieldConstants from "../applicationMeta/fieldConstants";
7
- import * as ServiceConstants from "../helper/serviceConstants";
8
- import { HttpConnection } from "./httpConnection";
9
- import { AuthenticationService } from "../authenticationService";
10
-
11
- export enum DataType { all, changed, changedQueued, queued }
12
- class SyncInputDataManager {
13
- static async constructInputBeJson(entityName: string, dataObject: any): Promise<any> {
14
- if (Object.keys(dataObject).length === 0) {
15
- return {};
16
- }
17
- const lid = dataObject[FieldConstants.FieldLid];
18
- if (!lid) {
19
- throw new Error(`${FieldConstants.FieldLid} is mandatory in the input data.`);
20
- }
21
-
22
- try {
23
- const databaseManager = DatabaseManager.getInstance();
24
- const structureMeta = (await databaseManager.select(DatabaseType.FrameworkDb, "StructureMeta"))
25
- .find((element: StructureMeta) => element.structureName === entityName);
26
- if (!structureMeta) {
27
- throw new Error(`StructureMeta not found for entityName: ${entityName}`);
28
- }
29
- const beMeta = (await databaseManager.select(DatabaseType.FrameworkDb, "BusinessEntityMeta"))
30
- .find((element: any) => element.beName === structureMeta.beName);
31
- if (!beMeta) {
32
- throw new Error(`BusinessEntityMeta not found for beName: ${structureMeta.beName}`);
33
- }
34
- const whereClause = `${FieldConstants.FieldLid}='${lid}'`;
35
- const result = await databaseManager.select(DatabaseType.AppDb, entityName, whereClause);
36
-
37
- if (result.length === 0) {
38
- throw new Error(`Data not found for ${FieldConstants.FieldLid}: ${lid}.`);
39
- }
40
- const header = result[0];
41
- if (header[FieldConstants.FieldSyncStatus] === SyncStatus.queued) {
42
- throw new Error("Entity is in outbox. Cannot be submitted again.");
43
- }
44
- if (header[FieldConstants.FieldSyncStatus] === SyncStatus.sent) {
45
- throw new Error("Entity is in sent items waiting for a response from the server. Cannot be submitted again.");
46
- }
47
-
48
- const beObject: any = { [structureMeta.structureName]: header };
49
- const items = await this.getChildData(lid, structureMeta.beName, DataType.changed);
50
- Object.assign(beObject, items);
51
- const inputObject = {
52
- [beMeta.beName]: [beObject]
53
- };
54
- return inputObject;
55
- } catch (e) {
56
- await Logger.logError("SyncInputDataManager", "constructInputBeJson", JSON.stringify(e));
57
- }
58
- return {};
59
- }
60
-
61
- static async getChildData(lid: string, beName: string, dataType: DataType): Promise<any> {
62
- const databaseManager = DatabaseManager.getInstance();
63
- const result: any[] = await databaseManager.select(DatabaseType.FrameworkDb, "StructureMeta")
64
- const childStructureMetas: StructureMeta[] = result.filter((element: StructureMeta) => element.beName === beName && element.isHeader !== "1");
65
- let whereClause = `${FieldConstants.FieldFid}='${lid}'`;
66
- switch (dataType) {
67
- case DataType.all:
68
- whereClause += "";
69
- break;
70
- case DataType.changed:
71
- whereClause += ` AND ${FieldConstants.FieldObjectStatus} IN (${ObjectStatus.add}, ${ObjectStatus.modify}, ${ObjectStatus.delete}) AND ${FieldConstants.FieldSyncStatus} IN (${SyncStatus.none}, ${SyncStatus.error})`;
72
- break;
73
- case DataType.changedQueued:
74
- whereClause += ` AND ${FieldConstants.FieldObjectStatus} IN (${ObjectStatus.add}, ${ObjectStatus.modify}, ${ObjectStatus.delete}) AND ${FieldConstants.FieldSyncStatus} IN (${SyncStatus.none}, ${SyncStatus.error}, ${SyncStatus.queued})`;
75
- break;
76
- case DataType.queued:
77
- whereClause += ` AND ${FieldConstants.FieldObjectStatus} IN (${ObjectStatus.add}, ${ObjectStatus.modify}, ${ObjectStatus.delete}) AND ${FieldConstants.FieldSyncStatus} IN (${SyncStatus.queued})`;
78
- break;
79
- default:
80
- break;
81
- }
82
- const childJsonObject: any = {};
83
- for (const structureMetaData of childStructureMetas) {
84
- try {
85
- const result: any[] = await databaseManager.select(DatabaseType.AppDb, structureMetaData.structureName, whereClause);
86
- childJsonObject[structureMetaData.structureName] = result;
87
- } catch (e) {
88
- Logger.logError("SyncInputDataManager", "_getChildData", JSON.stringify(e));
89
- }
90
- }
91
- return childJsonObject;
92
- }
93
-
94
- static async checkAndUploadAttachments(entityName: string, inputData: any, isAsynchronous: boolean = false): Promise<void> {
95
- const databaseManager = DatabaseManager.getInstance();
96
- const structureMetas = await databaseManager.select(DatabaseType.FrameworkDb, "StructureMeta");
97
- const structureMeta = structureMetas.find((element: any) => element.structureName === entityName);
98
-
99
- // Invalid condition. Should never occur.
100
- if (!structureMeta) {
101
- await Logger.logError("SyncInputDataManager", "checkAndUploadAttachments",
102
- `Invalid BE. Cannot Upload Attachments. Table Name: ${entityName}`);
103
- return;
104
- }
105
-
106
- // If attachments are not supported do not do anything
107
- if (!await this.isAttachmentSupportedForBEName(structureMeta.beName)) {
108
- await Logger.logError("SyncInputDataManager", "checkAndUploadAttachments",
109
- `This BE: ${structureMeta.beName} does not support attachments.`);
110
- return;
111
- }
112
-
113
- try {
114
- const attachmentItemNames = structureMetas
115
- .filter((element: any) =>
116
- element.beName === structureMeta.beName &&
117
- element.structureName.endsWith(ServiceConstants.AttachmentBE))
118
- .map((e: any) => e.structureName);
119
-
120
- for (const attachmentItemName of attachmentItemNames) {
121
- const attachmentItems = await this.getAttachmentsMarkedForUpload(attachmentItemName, inputData);
122
- for (const attachmentItem of attachmentItems) {
123
- try {
124
- if (isAsynchronous) {
125
- // Wait till the internet is connected.
126
- // TODO: Implement this
127
- // await ConnectivityManager.waitForConnection();
128
- } else {
129
- if (!navigator.onLine) {
130
- break;
131
- }
132
- if (!(await isServerReachable(AuthenticationService.instance.loginParameters.url))) {
133
- break;
134
- }
135
- }
136
- const response = await new HttpConnection().uploadAttachment(attachmentItem);
137
- if (response.status === 200 || response.status === 201) {
138
- this.updateAttachmentStatus(
139
- attachmentItemName, attachmentItem, ServiceConstants.AttachmentStatusUploaded);
140
- } else {
141
- await Logger.logError(
142
- "SyncInputDataManager",
143
- "checkAndUploadAttachments",
144
- "Error while uploading attachment.");
145
-
146
- const infoMessage = {
147
- lid: FrameworkHelper.getUUID(),
148
- timestamp: Date.now(),
149
- objectStatus: ObjectStatus.global,
150
- syncStatus: SyncStatus.none,
151
- type: "",
152
- subtype: "",
153
- category: "InfoMessageFailure",
154
- message: "Error while uploading attachment.",
155
- bename: entityName,
156
- belid: attachmentItem[FieldConstants.FieldLid],
157
- messagedetails: new Uint8Array(0)
158
- };
159
- await databaseManager.insert(DatabaseType.FrameworkDb, "InfoMessage", infoMessage, true);
160
- this.updateAttachmentStatus(attachmentItemName, attachmentItem,
161
- ServiceConstants.AttachmentStatusErrorInUpload);
162
- }
163
- } catch (e) {
164
- await Logger.logError("SyncInputDataManager",
165
- "checkAndUploadAttachments", JSON.stringify(e));
166
- this.updateAttachmentStatus(attachmentItemName, attachmentItem,
167
- ServiceConstants.AttachmentStatusErrorInUpload);
168
- }
169
- }
170
- }
171
- } catch (e) {
172
- await Logger.logError(
173
- "SyncInputDataManager", "checkAndUploadAttachments", JSON.stringify(e));
174
- }
175
- }
176
-
177
- private static async updateAttachmentStatus(attachmentItemName: string, attachmentItem: any, attachmentStatus: string): Promise<boolean> {
178
- attachmentItem[ServiceConstants.AttachmentItemFieldAttachmentStatus] = attachmentStatus;
179
- return await DatabaseManager.getInstance().update(DatabaseType.AppDb, attachmentItemName, attachmentItem, attachmentItem[FieldConstants.FieldLid]);
180
- }
181
-
182
- static async isAttachmentSupportedForBEName(beName: string): Promise<boolean> {
183
- if (!beName) {
184
- return false;
185
- }
186
- try {
187
- const databaseManager = DatabaseManager.getInstance();
188
- const beMetas = await databaseManager.select(DatabaseType.FrameworkDb, "BusinessEntityMeta");
189
- const beMeta = beMetas.find((element: any) => element.beName === beName);
190
- return beMeta.attachments === "1";
191
- } catch (e) {
192
- await Logger.logError("SyncInputDataManager", "isAttachmentSupportedForBEName", JSON.stringify(e));
193
- }
194
- return false;
195
- }
196
-
197
- static async getAttachmentsMarkedForUpload(attachmentItemName: string, inputData: any): Promise<any[]> {
198
- const whereClause = `${FieldConstants.FieldFid}='${inputData[FieldConstants.FieldLid]}' AND ${ServiceConstants.AttachmentItemFieldAttachmentStatus}='${ServiceConstants.AttachmentStatusSavedForUpload}'`;
199
- const databaseManager = DatabaseManager.getInstance();
200
- const attachmentItems = await databaseManager.select(DatabaseType.AppDb, attachmentItemName, whereClause);
201
- return attachmentItems;
202
- }
203
- }
204
-
205
- export default SyncInputDataManager;
@@ -1,104 +0,0 @@
1
- import FrameworkHelper from "./frameworkHelper";
2
-
3
- export class UnviredAccount {
4
- private accountId: string;
5
- private username: string;
6
- private company: string;
7
- private serverURL: string;
8
- private feUserId: string;
9
- private loginType: string;
10
- private port: string;
11
- private domain: string;
12
-
13
- constructor(username: string, company: string, serverURL: string, feUserId: string, loginType: string) {
14
- this.accountId = FrameworkHelper.getUUID();
15
- this.username = username;
16
- this.company = company;
17
- this.serverURL = serverURL;
18
- this.feUserId = feUserId;
19
- this.loginType = loginType;
20
- this.port = "";
21
- this.domain = "";
22
- }
23
-
24
- public getAccountId(): string {
25
- return this.accountId;
26
- }
27
-
28
- public getUsername(): string {
29
- return this.username;
30
- }
31
-
32
- public getCompany(): string {
33
- return this.company;
34
- }
35
-
36
- public getServerURL(): string {
37
- return this.serverURL;
38
- }
39
-
40
- public getFeUserId(): string {
41
- return this.feUserId;
42
- }
43
-
44
- public getLoginType(): string {
45
- return this.loginType;
46
- }
47
-
48
- public getPort(): string {
49
- return this.port;
50
- }
51
-
52
- public getDomain(): string {
53
- return this.domain;
54
- }
55
-
56
- public setUsername(username: string): void {
57
- this.username = username;
58
- }
59
-
60
- public setCompany(company: string): void {
61
- this.company = company;
62
- }
63
-
64
- public setServerURL(serverURL: string): void {
65
- this.serverURL = serverURL;
66
- }
67
-
68
- public setFeUserId(feUserId: string): void {
69
- this.feUserId = feUserId;
70
- }
71
-
72
- public setLoginType(loginType: string): void {
73
- this.loginType = loginType;
74
- }
75
-
76
- public setPort(port: string): void {
77
- this.port = port;
78
- }
79
-
80
- public setDomain(domain: string): void {
81
- this.domain = domain;
82
- }
83
-
84
- static fromJSON(json: any): UnviredAccount {
85
- var acc = new UnviredAccount(json.username, json.company, json.serverURL, json.feUserId, json.loginType);
86
- acc.accountId = json.accountId;
87
- acc.port = json.port;
88
- acc.domain = json.domain;
89
- return acc;
90
- }
91
-
92
- toJSON(): any {
93
- return {
94
- accountId: this.accountId,
95
- username: this.username,
96
- company: this.company,
97
- serverURL: this.serverURL,
98
- feUserId: this.feUserId,
99
- loginType: this.loginType,
100
- port: this.port,
101
- domain: this.domain
102
- };
103
- }
104
- }
@@ -1,120 +0,0 @@
1
- import { Logger } from "./logger";
2
- import { UnviredAccount } from "./unviredAccount";
3
-
4
- export class UnviredAccountManager {
5
- private fileName = "UnviredAccountManager"
6
- private storageKey: string;
7
- private lastLoggedInKey: string;
8
- private lastLoggedOutKey: string;
9
-
10
- private static instance: UnviredAccountManager;
11
-
12
- private constructor() {
13
- this.storageKey = 'unviredAccountData';
14
- this.lastLoggedInKey = 'lastLoggedInKey';
15
- this.lastLoggedOutKey = 'lastLoggedOutKey';
16
- }
17
-
18
- public static getInstance(): UnviredAccountManager {
19
- if (!UnviredAccountManager.instance) {
20
- UnviredAccountManager.instance = new UnviredAccountManager();
21
- }
22
- return UnviredAccountManager.instance;
23
- }
24
-
25
- saveAccount(account: UnviredAccount): void {
26
- const serializedData = localStorage.getItem(this.storageKey);
27
- let accounts:any[] = [];
28
- if (serializedData) {
29
- accounts = JSON.parse(serializedData);
30
- if (accounts == null) {
31
- accounts = [];
32
- }
33
- }
34
- accounts.push(account.toJSON());
35
- localStorage.setItem(this.storageKey, JSON.stringify(accounts));
36
- }
37
-
38
- getAccount(userName: string, company: string): UnviredAccount {
39
- const serializedData = localStorage.getItem(this.storageKey);
40
- if (serializedData === null || serializedData.length === 0) {
41
- return null;
42
- }
43
- const accounts:any[] = JSON.parse(serializedData).map((acc: any) => UnviredAccount.fromJSON(acc));
44
- const account = accounts.find((acc: UnviredAccount) => acc.getUsername() === userName && acc.getCompany() === company);
45
- return account ? account : null;
46
- }
47
-
48
- getAllAccounts(): UnviredAccount[] {
49
- const serializedData = localStorage.getItem(this.storageKey);
50
- if (serializedData === null || serializedData.length === 0) {
51
- return [];
52
- }
53
- const accounts:any[] = JSON.parse(serializedData).map((acc: any) => UnviredAccount.fromJSON(acc));
54
- return accounts ? accounts : [];
55
- }
56
-
57
- setLastLoggedInAccount(accountId: string): void {
58
- localStorage.setItem(this.lastLoggedInKey, accountId);
59
- }
60
-
61
- getLastLoggedInAccount(): UnviredAccount {
62
- const accountId = localStorage.getItem(this.lastLoggedInKey);
63
- if (accountId === null || accountId.length === 0) {
64
- Logger.logError(this.fileName, "getlastLoggedInAccount", "No account found to get last logged in account");
65
- return null;
66
- }
67
- const serializedData = localStorage.getItem(this.storageKey);
68
- if (serializedData === null || serializedData.length === 0) {
69
- Logger.logError(this.fileName, "getlastLoggedInAccount", "No accounts found to get last logged in account");
70
- return null;
71
- }
72
- const accounts:any[] = JSON.parse(serializedData).map((acc: any) => UnviredAccount.fromJSON(acc));
73
- const accountIndex = accounts.findIndex((acc: UnviredAccount) => acc.getAccountId() === accountId);
74
- if (accountIndex === -1) {
75
- Logger.logError(this.fileName, "getlastLoggedInAccount", "Account not found in accounts list");
76
- return null;
77
- }
78
- return accounts[accountIndex];
79
- }
80
-
81
- setLastLoggedOutAccount(accountId: string): void {
82
- localStorage.setItem(this.lastLoggedOutKey, accountId);
83
- }
84
-
85
- getlastLoggedOutAccount(): UnviredAccount {
86
- const accountId = localStorage.getItem(this.lastLoggedOutKey);
87
- if (accountId === null || accountId.length === 0) {
88
- Logger.logError(this.fileName, "getlastLoggedOutAccount", "No account found to get last logged out account");
89
- return null;
90
- }
91
- const serializedData = localStorage.getItem(this.storageKey);
92
- if (serializedData === null || serializedData.length === 0) {
93
- Logger.logError(this.fileName, "getlastLoggedOutAccount", "No accounts found to get last logged out account");
94
- return null;
95
- }
96
- const accounts:UnviredAccount[] = JSON.parse(serializedData).map((acc: any) => UnviredAccount.fromJSON(acc));
97
- const accountIndex = accounts.findIndex((acc: UnviredAccount) => acc.getAccountId() === accountId);
98
- if (accountIndex === -1) {
99
- Logger.logError(this.fileName, "getlastLoggedOutAccount", "Account not found in accounts list");
100
- return null;
101
- }
102
- return accounts[accountIndex];
103
- }
104
-
105
- deleteAccount(accountId: string): void {
106
- const serializedData = localStorage.getItem(this.storageKey);
107
- if (serializedData === null || serializedData.length === 0) {
108
- Logger.logError(this.fileName, "deleteAccount", "No accounts found to delete account");
109
- return;
110
- }
111
- let accounts:any[] = JSON.parse(serializedData).map((acc: any) => UnviredAccount.fromJSON(acc));
112
- const accountIndex = accounts.findIndex((acc: UnviredAccount) => acc.getAccountId() === accountId);
113
- if (accountIndex === -1) {
114
- Logger.logError(this.fileName, "deleteAccount", "Account not found in accounts list");
115
- return;
116
- }
117
- accounts.splice(accountIndex, 1);
118
- localStorage.setItem(this.storageKey, JSON.stringify(accounts));
119
- }
120
- }
@@ -1,43 +0,0 @@
1
- import * as ServiceConstants from './serviceConstants'
2
- export class URLService {
3
- static sanitizeLoginURL(loginURL: string): string {
4
- if (loginURL.endsWith("UMP") || loginURL.endsWith("UMP/") || loginURL.endsWith("?local")) {
5
- return loginURL;
6
- }
7
- if (!loginURL.endsWith("/")) {
8
- loginURL += "/";
9
- }
10
- loginURL += "UMP";
11
- return loginURL;
12
- }
13
-
14
- static getBaseUrl(baseUrl: string): string {
15
- if (baseUrl.length === 0) {
16
- return "";
17
- }
18
- baseUrl = this.sanitizeLoginURL(baseUrl)
19
- if (!baseUrl.endsWith("/")) {
20
- baseUrl += "/";
21
- }
22
- baseUrl += ServiceConstants.ServiceApiVersion;
23
- return baseUrl;
24
- }
25
-
26
- static getSessionUrl(baseUrl: string): string {
27
- var sessionUrl = this.getBaseUrl(baseUrl);
28
- sessionUrl += ServiceConstants.ServiceSession;
29
- return sessionUrl;
30
- }
31
-
32
- static getApplicationUrl(baseUrl: string): string {
33
- var appUrl = this.getBaseUrl(baseUrl);
34
- appUrl += ServiceConstants.ServiceApplications;
35
- return appUrl;
36
- }
37
-
38
- static getPingUrl(baseUrl: string): string {
39
- var pingUrl = this.getBaseUrl(baseUrl);
40
- pingUrl += ServiceConstants.AdminServicePing;
41
- return pingUrl;
42
- }
43
- }