@unvired/react-native-wrapper-sdk 0.0.13 → 0.0.15

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 (38) hide show
  1. package/dist/UnviredWrapper.d.ts +25 -22
  2. package/dist/UnviredWrapper.d.ts.map +1 -1
  3. package/dist/UnviredWrapper.js +32 -48
  4. package/dist/lib/auth/AuthBuilder.d.ts.map +1 -0
  5. package/dist/lib/auth/AuthService.d.ts +27 -0
  6. package/dist/lib/auth/AuthService.d.ts.map +1 -0
  7. package/dist/lib/auth/AuthService.js +46 -0
  8. package/dist/lib/database/DatabaseService.d.ts +86 -0
  9. package/dist/lib/database/DatabaseService.d.ts.map +1 -0
  10. package/dist/lib/database/DatabaseService.js +134 -0
  11. package/dist/lib/file/FileService.d.ts +72 -0
  12. package/dist/lib/file/FileService.d.ts.map +1 -0
  13. package/dist/lib/file/FileService.js +136 -0
  14. package/dist/lib/logger/LoggerService.d.ts +45 -0
  15. package/dist/lib/logger/LoggerService.d.ts.map +1 -0
  16. package/dist/lib/logger/LoggerService.js +65 -0
  17. package/dist/lib/notification/NotificationService.d.ts +28 -0
  18. package/dist/lib/notification/NotificationService.d.ts.map +1 -0
  19. package/dist/lib/notification/NotificationService.js +47 -0
  20. package/dist/lib/settings/SettingsService.d.ts +41 -0
  21. package/dist/lib/settings/SettingsService.d.ts.map +1 -0
  22. package/dist/lib/settings/SettingsService.js +108 -0
  23. package/dist/lib/sync/SyncService.d.ts +96 -0
  24. package/dist/lib/sync/SyncService.d.ts.map +1 -0
  25. package/dist/lib/sync/SyncService.js +139 -0
  26. package/package.json +3 -3
  27. package/src/UnviredWrapper.ts +34 -52
  28. package/src/lib/auth/AuthService.ts +45 -0
  29. package/src/lib/database/DatabaseService.ts +148 -0
  30. package/src/lib/file/FileService.ts +149 -0
  31. package/src/lib/logger/LoggerService.ts +70 -0
  32. package/src/lib/notification/NotificationService.ts +45 -0
  33. package/src/lib/settings/SettingsService.ts +126 -0
  34. package/src/lib/sync/SyncService.ts +160 -0
  35. package/dist/lib/AuthBuilder.d.ts.map +0 -1
  36. /package/dist/lib/{AuthBuilder.d.ts → auth/AuthBuilder.d.ts} +0 -0
  37. /package/dist/lib/{AuthBuilder.js → auth/AuthBuilder.js} +0 -0
  38. /package/src/lib/{AuthBuilder.ts → auth/AuthBuilder.ts} +0 -0
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileService = void 0;
4
+ const unvired_ts_core_sdk_1 = require("@unvired/unvired-ts-core-sdk");
5
+ class FileService {
6
+ // AttachmentService is not exported from the SDK, so we cannot expose start/stop here directly.
7
+ // If background sync control is needed, it might be via SyncEngine or other means.
8
+ /**
9
+ * Gets the directory used for storing attachments
10
+ */
11
+ async getAttachmentDirectory() {
12
+ let dir = await unvired_ts_core_sdk_1.AttachmentHelper.getAttachmentDirectory();
13
+ if (!dir.endsWith("/")) {
14
+ dir += "/";
15
+ }
16
+ return dir;
17
+ }
18
+ /**
19
+ * Adds an attachment
20
+ * @param attachmentName Name of the attachment
21
+ * @param attachmentData Data as ArrayBuffer
22
+ */
23
+ async addAttachment(attachmentName, attachmentData) {
24
+ return unvired_ts_core_sdk_1.AttachmentHelper.addAttachment(attachmentName, attachmentData);
25
+ }
26
+ /**
27
+ * Gets an attachment's data
28
+ * @param attachmentName Name of the attachment
29
+ */
30
+ async getAttachment(attachmentName) {
31
+ return unvired_ts_core_sdk_1.AttachmentHelper.getAttachment(attachmentName);
32
+ }
33
+ /**
34
+ * Deletes an attachment
35
+ * @param attachmentName Name of the attachment
36
+ */
37
+ async deleteAttachment(attachmentName) {
38
+ return unvired_ts_core_sdk_1.AttachmentHelper.deleteAttachment(attachmentName);
39
+ }
40
+ /**
41
+ * Gets the file system path of an attachment
42
+ * @param attachmentName Name of the attachment
43
+ */
44
+ async getAttachmentPath(attachmentName) {
45
+ return unvired_ts_core_sdk_1.AttachmentHelper.getAttachmentPath(attachmentName);
46
+ }
47
+ /**
48
+ * Reads a file from the filesystem as ArrayBuffer
49
+ * @param filePath Absolute path to the file
50
+ */
51
+ async readFileAsArrayBuffer(filePath) {
52
+ return unvired_ts_core_sdk_1.AttachmentHelper.readFileAsArrayBuffer(filePath);
53
+ }
54
+ /**
55
+ * Checks if a file exists
56
+ * @param filePath Absolute path to the file
57
+ */
58
+ async fileExists(filePath) {
59
+ return unvired_ts_core_sdk_1.AttachmentHelper.fileExists(filePath);
60
+ }
61
+ /**
62
+ * Reads an external file
63
+ * @param filePath Absolute path to the file
64
+ */
65
+ async readExternalFile(filePath) {
66
+ return unvired_ts_core_sdk_1.AttachmentHelper.readExternalFile(filePath);
67
+ }
68
+ /**
69
+ * Writes data to an external file
70
+ * @param filePath Parent directory path
71
+ * @param fileName File name
72
+ * @param data Data to write
73
+ */
74
+ async writeExternalFile(filePath, fileName, data) {
75
+ return unvired_ts_core_sdk_1.AttachmentHelper.writeExternalFile(filePath, fileName, data);
76
+ }
77
+ /**
78
+ * Deletes an external file
79
+ * @param filePath Absolute path to the file
80
+ */
81
+ async deleteExternalFile(filePath) {
82
+ return unvired_ts_core_sdk_1.AttachmentHelper.deleteExternalFile(filePath);
83
+ }
84
+ /**
85
+ * Create Attachment Item - Copies file to attachment folder and inserts record in DB
86
+ * @param tableName Table name for attachment
87
+ * @param structureObject Attachment item object
88
+ */
89
+ async createAttachmentItem(tableName, structureObject) {
90
+ if (!tableName)
91
+ throw new Error("Table name is null or empty");
92
+ if (!structureObject)
93
+ throw new Error("Structure object is null or empty");
94
+ const fileName = structureObject[unvired_ts_core_sdk_1.ServiceConstants.AttachmentItemFieldFileName];
95
+ const localPath = structureObject[unvired_ts_core_sdk_1.ServiceConstants.AttachmentItemFieldLocalPath];
96
+ if (!fileName)
97
+ throw new Error("File Name is null or empty");
98
+ if (!localPath)
99
+ throw new Error("Local Path is null or empty");
100
+ const arrayBuffer = await unvired_ts_core_sdk_1.AttachmentHelper.readFileAsArrayBuffer(localPath);
101
+ if (!arrayBuffer) {
102
+ throw new Error(`Attachment file could not be read at the location: ${localPath}`);
103
+ }
104
+ let attachmentName = structureObject[unvired_ts_core_sdk_1.ServiceConstants.AttachmentItemFieldUid];
105
+ if (fileName) {
106
+ attachmentName = fileName;
107
+ }
108
+ const attachmentPath = await unvired_ts_core_sdk_1.AttachmentHelper.addAttachment(attachmentName, arrayBuffer);
109
+ structureObject[unvired_ts_core_sdk_1.ServiceConstants.AttachmentItemFieldLocalPath] = attachmentPath;
110
+ structureObject[unvired_ts_core_sdk_1.ServiceConstants.AttachmentItemFieldAttachmentStatus] = unvired_ts_core_sdk_1.ServiceConstants.AttachmentStatusSavedForUpload;
111
+ await unvired_ts_core_sdk_1.AppDatabaseManager.getInstance().insert(tableName, structureObject, false);
112
+ return structureObject;
113
+ }
114
+ /**
115
+ * Queues an attachment for download
116
+ * @param tableName Table name
117
+ * @param structureObject Structure object
118
+ */
119
+ async downloadAttachment(tableName, structureObject) {
120
+ await unvired_ts_core_sdk_1.AttachmentQHelper.queueForDownload(tableName, structureObject, unvired_ts_core_sdk_1.ServiceConstants.FwAttachmentForceDownloadPriority);
121
+ // Note: AttachmentService start is not exposed in SDK exports currently.
122
+ // If needed, SyncEngine might handle it or it should be auto-handled.
123
+ return structureObject;
124
+ }
125
+ /**
126
+ * Downloads an attachment synchronously (waits for completion)
127
+ * @param structureObject Structure object with UID and FileName
128
+ */
129
+ async downloadAttachmentSync(structureObject) {
130
+ const uid = structureObject[unvired_ts_core_sdk_1.ServiceConstants.AttachmentItemFieldUid];
131
+ const fileName = structureObject[unvired_ts_core_sdk_1.ServiceConstants.AttachmentItemFieldFileName];
132
+ const attachmentPath = await unvired_ts_core_sdk_1.AttachmentQHelper.downloadAttachmentAndGetPath(uid, fileName);
133
+ return attachmentPath;
134
+ }
135
+ }
136
+ exports.FileService = FileService;
@@ -0,0 +1,45 @@
1
+ export declare class LoggerService {
2
+ /**
3
+ * Log Information
4
+ * @param className Class Name
5
+ * @param methodName Method Name
6
+ * @param message Message
7
+ */
8
+ info(className: string, methodName: string, message: string): void;
9
+ /**
10
+ * Log Error
11
+ * @param className Class Name
12
+ * @param methodName Method Name
13
+ * @param message Message
14
+ */
15
+ error(className: string, methodName: string, message: string): void;
16
+ /**
17
+ * Log Debug
18
+ * @param className Class Name
19
+ * @param methodName Method Name
20
+ * @param message Message
21
+ */
22
+ debug(className: string, methodName: string, message: string): void;
23
+ /**
24
+ * Set Log Level
25
+ * @param level Log Level
26
+ */
27
+ setLogLevel(level: string): void;
28
+ /**
29
+ * Get Log File URL
30
+ */
31
+ getLogFileURL(): Promise<string>;
32
+ /**
33
+ * Get Log File Content
34
+ */
35
+ getLogFileContent(): Promise<string>;
36
+ /**
37
+ * Get Backup Log File Content
38
+ */
39
+ getBackupLogFileContent(): Promise<string>;
40
+ /**
41
+ * Clear Log File
42
+ */
43
+ clearLogFile(): Promise<void>;
44
+ }
45
+ //# sourceMappingURL=LoggerService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoggerService.d.ts","sourceRoot":"","sources":["../../../src/lib/logger/LoggerService.ts"],"names":[],"mappings":"AAEA,qBAAa,aAAa;IAEtB;;;;;OAKG;IACH,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAIlE;;;;;OAKG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAInE;;;;;OAKG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAInE;;;OAGG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIhC;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI1C;;OAEG;IACG,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIhD;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAGtC"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoggerService = void 0;
4
+ const unvired_ts_core_sdk_1 = require("@unvired/unvired-ts-core-sdk");
5
+ class LoggerService {
6
+ /**
7
+ * Log Information
8
+ * @param className Class Name
9
+ * @param methodName Method Name
10
+ * @param message Message
11
+ */
12
+ info(className, methodName, message) {
13
+ unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().logInfo(className, methodName, message);
14
+ }
15
+ /**
16
+ * Log Error
17
+ * @param className Class Name
18
+ * @param methodName Method Name
19
+ * @param message Message
20
+ */
21
+ error(className, methodName, message) {
22
+ unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().logError(className, methodName, message);
23
+ }
24
+ /**
25
+ * Log Debug
26
+ * @param className Class Name
27
+ * @param methodName Method Name
28
+ * @param message Message
29
+ */
30
+ debug(className, methodName, message) {
31
+ unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().logDebug(className, methodName, message);
32
+ }
33
+ /**
34
+ * Set Log Level
35
+ * @param level Log Level
36
+ */
37
+ setLogLevel(level) {
38
+ unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().setLogLevel(level);
39
+ }
40
+ /**
41
+ * Get Log File URL
42
+ */
43
+ async getLogFileURL() {
44
+ return unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().getLogFileURL();
45
+ }
46
+ /**
47
+ * Get Log File Content
48
+ */
49
+ async getLogFileContent() {
50
+ return unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().getLogFileContent();
51
+ }
52
+ /**
53
+ * Get Backup Log File Content
54
+ */
55
+ async getBackupLogFileContent() {
56
+ return unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().getBackupLogFileContent();
57
+ }
58
+ /**
59
+ * Clear Log File
60
+ */
61
+ async clearLogFile() {
62
+ return unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().clearLogFile();
63
+ }
64
+ }
65
+ exports.LoggerService = LoggerService;
@@ -0,0 +1,28 @@
1
+ export declare class NotificationService {
2
+ private get adapter();
3
+ /**
4
+ * Requests permission and gets token
5
+ */
6
+ requestPermission(options?: {
7
+ forceShow: boolean;
8
+ }): Promise<void>;
9
+ /**
10
+ * Gets the push token
11
+ */
12
+ getToken(): Promise<string | undefined>;
13
+ /**
14
+ * Sets callback for token refresh
15
+ */
16
+ onTokenRefresh(callback: (token: string) => void): void;
17
+ /**
18
+ * Sets listener for incoming notifications (foreground)
19
+ * @param onMessage Callback when a notification is received
20
+ */
21
+ onNotificationReceived(onMessage: (data: any) => void): void;
22
+ /**
23
+ * Sets listener for incoming notifications (background)
24
+ * @param onMessage Callback when a notification is received
25
+ */
26
+ onBackgroundNotificationReceived(onMessage: (data: any) => void): void;
27
+ }
28
+ //# sourceMappingURL=NotificationService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationService.d.ts","sourceRoot":"","sources":["../../../src/lib/notification/NotificationService.ts"],"names":[],"mappings":"AAEA,qBAAa,mBAAmB;IAE5B,OAAO,KAAK,OAAO,GAElB;IAED;;OAEG;IACG,iBAAiB,CAAC,OAAO,CAAC,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxE;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAI7C;;OAEG;IACH,cAAc,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;IAIvD;;;OAGG;IACH,sBAAsB,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;IAI5D;;;OAGG;IACH,gCAAgC,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;CAGzE"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotificationService = void 0;
4
+ const unvired_ts_core_sdk_1 = require("@unvired/unvired-ts-core-sdk");
5
+ class NotificationService {
6
+ get adapter() {
7
+ return unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().getPushNotificationAdapter();
8
+ }
9
+ /**
10
+ * Requests permission and gets token
11
+ */
12
+ async requestPermission(options) {
13
+ var _a;
14
+ return (_a = this.adapter) === null || _a === void 0 ? void 0 : _a.requestPermission(options);
15
+ }
16
+ /**
17
+ * Gets the push token
18
+ */
19
+ async getToken() {
20
+ var _a;
21
+ return (_a = this.adapter) === null || _a === void 0 ? void 0 : _a.getToken();
22
+ }
23
+ /**
24
+ * Sets callback for token refresh
25
+ */
26
+ onTokenRefresh(callback) {
27
+ var _a;
28
+ (_a = this.adapter) === null || _a === void 0 ? void 0 : _a.onTokenRefresh(callback);
29
+ }
30
+ /**
31
+ * Sets listener for incoming notifications (foreground)
32
+ * @param onMessage Callback when a notification is received
33
+ */
34
+ onNotificationReceived(onMessage) {
35
+ var _a;
36
+ (_a = this.adapter) === null || _a === void 0 ? void 0 : _a.onMessage(onMessage);
37
+ }
38
+ /**
39
+ * Sets listener for incoming notifications (background)
40
+ * @param onMessage Callback when a notification is received
41
+ */
42
+ onBackgroundNotificationReceived(onMessage) {
43
+ var _a;
44
+ (_a = this.adapter) === null || _a === void 0 ? void 0 : _a.onBackgroundMessage(onMessage);
45
+ }
46
+ }
47
+ exports.NotificationService = NotificationService;
@@ -0,0 +1,41 @@
1
+ export declare class SettingsService {
2
+ /**
3
+ * Get current log level
4
+ */
5
+ getLogLevel(): Promise<string>;
6
+ /**
7
+ * Set log level
8
+ * @param logLevel Log Level
9
+ */
10
+ setLogLevel(logLevel: string): Promise<void>;
11
+ /**
12
+ * Send logs to server
13
+ */
14
+ sendLogToServer(): Promise<void>;
15
+ /**
16
+ * Create and get Log Zip path (for email etc)
17
+ */
18
+ getLogZipPath(): Promise<string>;
19
+ /**
20
+ * Test Push Notification
21
+ */
22
+ testPushNotification(): Promise<void>;
23
+ /**
24
+ * Get list of Info Messages
25
+ */
26
+ getInfoMessages(): Promise<any[]>;
27
+ /**
28
+ * Get User Settings / Current Account Information
29
+ */
30
+ getUserSettings(): Promise<any>;
31
+ /**
32
+ * Set Auth Token
33
+ * @param token JWT Token
34
+ */
35
+ setAuthToken(token: string): Promise<void>;
36
+ /**
37
+ * Get Auth Token Validity (remaining seconds)
38
+ */
39
+ getAuthTokenValidity(): Promise<number>;
40
+ }
41
+ //# sourceMappingURL=SettingsService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SettingsService.d.ts","sourceRoot":"","sources":["../../../src/lib/settings/SettingsService.ts"],"names":[],"mappings":"AAWA,qBAAa,eAAe;IAExB;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAIpC;;;OAGG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAItC;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC;;OAEG;IACG,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3C;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAIvC;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC;IAoCrC;;;OAGG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhD;;OAEG;IACG,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;CAkBhD"}
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SettingsService = void 0;
4
+ const unvired_ts_core_sdk_1 = require("@unvired/unvired-ts-core-sdk");
5
+ class SettingsService {
6
+ /**
7
+ * Get current log level
8
+ */
9
+ async getLogLevel() {
10
+ return unvired_ts_core_sdk_1.FrameworkSettingsManager.getInstance().getFieldValue(unvired_ts_core_sdk_1.FrameworkSettingsFields.logLevel);
11
+ }
12
+ /**
13
+ * Set log level
14
+ * @param logLevel Log Level
15
+ */
16
+ async setLogLevel(logLevel) {
17
+ return unvired_ts_core_sdk_1.SettingsHelper.setLogLevel(logLevel);
18
+ }
19
+ /**
20
+ * Send logs to server
21
+ */
22
+ async sendLogToServer() {
23
+ return unvired_ts_core_sdk_1.SettingsHelper.sendLogsToServer();
24
+ }
25
+ /**
26
+ * Create and get Log Zip path (for email etc)
27
+ */
28
+ async getLogZipPath() {
29
+ return unvired_ts_core_sdk_1.SettingsHelper.createAndGetLogZipPath();
30
+ }
31
+ /**
32
+ * Test Push Notification
33
+ */
34
+ async testPushNotification() {
35
+ return unvired_ts_core_sdk_1.SettingsHelper.testPushNotification();
36
+ }
37
+ /**
38
+ * Get list of Info Messages
39
+ */
40
+ async getInfoMessages() {
41
+ return unvired_ts_core_sdk_1.SettingsHelper.getInfoMessages();
42
+ }
43
+ /**
44
+ * Get User Settings / Current Account Information
45
+ */
46
+ async getUserSettings() {
47
+ const unviredAccount = unvired_ts_core_sdk_1.UnviredAccountManager.getInstance().getLastLoggedInAccount();
48
+ if (!unviredAccount) {
49
+ throw new Error("No account found");
50
+ }
51
+ let jwtToken = unvired_ts_core_sdk_1.AuthenticationService.instance.jwtToken;
52
+ // Fallback or re-fetch token logic
53
+ if (!jwtToken) {
54
+ jwtToken = unviredAccount.getJwtToken();
55
+ }
56
+ const serverType = await unvired_ts_core_sdk_1.FrameworkSettingsManager.getInstance().getFieldValue(unvired_ts_core_sdk_1.FrameworkSettingsFields.serverType);
57
+ const emailId = await unvired_ts_core_sdk_1.FrameworkSettingsManager.getInstance().getFieldValue(unvired_ts_core_sdk_1.FrameworkSettingsFields.email);
58
+ const unviredUserId = await unvired_ts_core_sdk_1.UserSettingsManager.getInstance().getFieldValue(unvired_ts_core_sdk_1.UserSettingsFields.unviredUserId);
59
+ const unviredPassword = await unvired_ts_core_sdk_1.UserSettingsManager.getInstance().getFieldValue(unvired_ts_core_sdk_1.UserSettingsFields.unviredPassword);
60
+ // Accessing loginParameters from AuthenticationService might need cast if it's protected/private or simply public
61
+ // index.d.ts says: loginParameters: any;
62
+ const loginParams = unvired_ts_core_sdk_1.AuthenticationService.instance.loginParameters || {};
63
+ return {
64
+ "UNVIRED_ID": unviredUserId,
65
+ "USER_ID": loginParams.username || unviredUserId,
66
+ "FIRST_NAME": unviredAccount.getFirstName(),
67
+ "LAST_NAME": unviredAccount.getLastName(),
68
+ "FULL_NAME": `${unviredAccount.getFirstName()} ${unviredAccount.getLastName()}`,
69
+ "EMAIL": emailId || "",
70
+ "SERVER_URL": unviredAccount.getServerURL(),
71
+ "SERVER_TYPE": serverType || "",
72
+ "LOGIN_TYPE": loginParams.loginType,
73
+ "UNVIRED_PASSWORD": unviredPassword || "",
74
+ "JWT_TOKEN": jwtToken
75
+ };
76
+ }
77
+ /**
78
+ * Set Auth Token
79
+ * @param token JWT Token
80
+ */
81
+ async setAuthToken(token) {
82
+ unvired_ts_core_sdk_1.AuthenticationService.instance.jwtToken = token;
83
+ await unvired_ts_core_sdk_1.UserSettingsManager.getInstance().setFieldValue(unvired_ts_core_sdk_1.UserSettingsFields.jwtToken, token);
84
+ }
85
+ /**
86
+ * Get Auth Token Validity (remaining seconds)
87
+ */
88
+ async getAuthTokenValidity() {
89
+ const token = await unvired_ts_core_sdk_1.UserSettingsManager.getInstance().getFieldValue(unvired_ts_core_sdk_1.UserSettingsFields.jwtToken);
90
+ if (!token)
91
+ return 0;
92
+ try {
93
+ const parts = token.split('.');
94
+ if (parts.length !== 3)
95
+ return 0;
96
+ const payload = JSON.parse(atob(parts[1]));
97
+ if (!payload.exp)
98
+ return 0;
99
+ const now = Math.floor(Date.now() / 1000);
100
+ const remaining = payload.exp - now;
101
+ return remaining > 0 ? remaining : 0;
102
+ }
103
+ catch (e) {
104
+ return 0;
105
+ }
106
+ }
107
+ }
108
+ exports.SettingsService = SettingsService;
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Service for handling Synchronization with Unvired Server
3
+ */
4
+ export declare class SyncService {
5
+ /**
6
+ * Submit data to UMP server in sync mode (Foreground)
7
+ * @param reqType Request Type (RQST/PULL/PUSH/QUERY/REQ)
8
+ * @param header Header Data Structure
9
+ * @param customData Custom data string (optional)
10
+ * @param paFunction Process Agent Function Name
11
+ * @param autoSave Whether to auto-save data in DB
12
+ */
13
+ syncForeground(reqType: any, header: any, customData: string | undefined, paFunction: string, autoSave: boolean): Promise<any>;
14
+ /**
15
+ * Submit data to UMP server in async mode (Background)
16
+ * @param reqType Request Type
17
+ * @param header Header Data Structure
18
+ * @param customData Custom data string (optional)
19
+ * @param paFunction Process Agent Function Name
20
+ * @param beName Business Entity Name
21
+ */
22
+ syncBackground(reqType: any, header: any, customData: string | undefined, paFunction: string, beName: string): Promise<any>;
23
+ /**
24
+ * Sends request for initial data download
25
+ * @param functions List of functions to execute
26
+ */
27
+ sendInitialDataDownloadRequest(functions?: any[]): Promise<void>;
28
+ /**
29
+ * Gets synchronization state
30
+ * @param callback Callback to receive state updates
31
+ */
32
+ getSynchronizationState(callback: (state: string) => void): void;
33
+ /**
34
+ * Starts Inbox Handler
35
+ */
36
+ startInboxHandler(): void;
37
+ /**
38
+ * Starts Data Sender (Outbox Handler)
39
+ */
40
+ startDataSender(): void;
41
+ /**
42
+ * Request for downloading messages from server
43
+ */
44
+ getMessages(): void;
45
+ /**
46
+ * Register for Data Sender notifications
47
+ * @param callback Callback function
48
+ */
49
+ registerDataSenderListener(callback: (data: any) => void): void;
50
+ /**
51
+ * Unregister Data Sender notifications
52
+ */
53
+ unRegisterDataSenderListener(): void;
54
+ /**
55
+ * Register for Sync Items count updates
56
+ * @param callback Callback function
57
+ */
58
+ registerSyncItemsCountListener(callback: (count: any) => void): void;
59
+ /**
60
+ * Check if a BE is in the Outbox queue
61
+ * @param beLid BE Header LID
62
+ */
63
+ isInOutBox(beLid: string): Promise<boolean>;
64
+ /**
65
+ * Check if a BE is in Sent Items
66
+ * @param beLid BE Header LID
67
+ */
68
+ isInSentItem(beLid: string): Promise<boolean>;
69
+ /**
70
+ * Get count of items in Outbox
71
+ */
72
+ outBoxItemCount(): Promise<number>;
73
+ /**
74
+ * Get count of items in Sent Items
75
+ */
76
+ sentItemCount(): Promise<number>;
77
+ /**
78
+ * Get count of items in Inbox
79
+ */
80
+ inBoxItemCount(): Promise<number>;
81
+ /**
82
+ * Delete an entry from Outbox
83
+ * @param beLid BE Header LID
84
+ */
85
+ deleteOutBoxEntry(beLid: string): Promise<any>;
86
+ /**
87
+ * Lock Data Sender for a specific BE
88
+ * @param beLid BE LID
89
+ */
90
+ lockDataSender(beLid: string): Promise<any>;
91
+ /**
92
+ * Unlock Data Sender
93
+ */
94
+ unlockDataSender(): Promise<any>;
95
+ }
96
+ //# sourceMappingURL=SyncService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SyncService.d.ts","sourceRoot":"","sources":["../../../src/lib/sync/SyncService.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,qBAAa,WAAW;IAEpB;;;;;;;OAOG;IACG,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,YAAK,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;IAI7H;;;;;;;OAOG;IACG,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,YAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAI1H;;;OAGG;IACG,8BAA8B,CAAC,SAAS,GAAE,GAAG,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1E;;;OAGG;IACH,uBAAuB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;IAMhE;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAKzB;;OAEG;IACH,eAAe,IAAI,IAAI;IAIvB;;OAEG;IACH,WAAW,IAAI,IAAI;IAInB;;;OAGG;IACH,0BAA0B,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;IAI/D;;OAEG;IACH,4BAA4B,IAAI,IAAI;IAIpC;;;OAGG;IACH,8BAA8B,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;IAIpE;;;OAGG;IACG,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIjD;;;OAGG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAInD;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;IAIxC;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAIvC;;;OAGG;IACG,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAIpD;;;OAGG;IACG,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAIjD;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC;CAGzC"}