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

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 +22 -25
  2. package/dist/UnviredWrapper.d.ts.map +1 -1
  3. package/dist/UnviredWrapper.js +48 -32
  4. package/dist/lib/AuthBuilder.d.ts.map +1 -0
  5. package/package.json +3 -3
  6. package/src/UnviredWrapper.ts +52 -34
  7. package/dist/lib/auth/AuthBuilder.d.ts.map +0 -1
  8. package/dist/lib/auth/AuthService.d.ts +0 -27
  9. package/dist/lib/auth/AuthService.d.ts.map +0 -1
  10. package/dist/lib/auth/AuthService.js +0 -46
  11. package/dist/lib/database/DatabaseService.d.ts +0 -86
  12. package/dist/lib/database/DatabaseService.d.ts.map +0 -1
  13. package/dist/lib/database/DatabaseService.js +0 -134
  14. package/dist/lib/file/FileService.d.ts +0 -72
  15. package/dist/lib/file/FileService.d.ts.map +0 -1
  16. package/dist/lib/file/FileService.js +0 -136
  17. package/dist/lib/logger/LoggerService.d.ts +0 -45
  18. package/dist/lib/logger/LoggerService.d.ts.map +0 -1
  19. package/dist/lib/logger/LoggerService.js +0 -65
  20. package/dist/lib/notification/NotificationService.d.ts +0 -28
  21. package/dist/lib/notification/NotificationService.d.ts.map +0 -1
  22. package/dist/lib/notification/NotificationService.js +0 -47
  23. package/dist/lib/settings/SettingsService.d.ts +0 -41
  24. package/dist/lib/settings/SettingsService.d.ts.map +0 -1
  25. package/dist/lib/settings/SettingsService.js +0 -108
  26. package/dist/lib/sync/SyncService.d.ts +0 -96
  27. package/dist/lib/sync/SyncService.d.ts.map +0 -1
  28. package/dist/lib/sync/SyncService.js +0 -139
  29. package/src/lib/auth/AuthService.ts +0 -45
  30. package/src/lib/database/DatabaseService.ts +0 -148
  31. package/src/lib/file/FileService.ts +0 -149
  32. package/src/lib/logger/LoggerService.ts +0 -70
  33. package/src/lib/notification/NotificationService.ts +0 -45
  34. package/src/lib/settings/SettingsService.ts +0 -126
  35. package/src/lib/sync/SyncService.ts +0 -160
  36. /package/dist/lib/{auth/AuthBuilder.d.ts → AuthBuilder.d.ts} +0 -0
  37. /package/dist/lib/{auth/AuthBuilder.js → AuthBuilder.js} +0 -0
  38. /package/src/lib/{auth/AuthBuilder.ts → AuthBuilder.ts} +0 -0
@@ -1,139 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SyncService = void 0;
4
- const unvired_ts_core_sdk_1 = require("@unvired/unvired-ts-core-sdk");
5
- /**
6
- * Service for handling Synchronization with Unvired Server
7
- */
8
- class SyncService {
9
- /**
10
- * Submit data to UMP server in sync mode (Foreground)
11
- * @param reqType Request Type (RQST/PULL/PUSH/QUERY/REQ)
12
- * @param header Header Data Structure
13
- * @param customData Custom data string (optional)
14
- * @param paFunction Process Agent Function Name
15
- * @param autoSave Whether to auto-save data in DB
16
- */
17
- async syncForeground(reqType, header, customData = "", paFunction, autoSave) {
18
- return unvired_ts_core_sdk_1.SyncEngine.syncForeground(reqType, header, customData, paFunction, autoSave);
19
- }
20
- /**
21
- * Submit data to UMP server in async mode (Background)
22
- * @param reqType Request Type
23
- * @param header Header Data Structure
24
- * @param customData Custom data string (optional)
25
- * @param paFunction Process Agent Function Name
26
- * @param beName Business Entity Name
27
- */
28
- async syncBackground(reqType, header, customData = "", paFunction, beName) {
29
- return unvired_ts_core_sdk_1.SyncEngine.syncBackground(reqType, header, customData, paFunction, beName);
30
- }
31
- /**
32
- * Sends request for initial data download
33
- * @param functions List of functions to execute
34
- */
35
- async sendInitialDataDownloadRequest(functions = []) {
36
- return unvired_ts_core_sdk_1.SettingsHelper.requestInitialDataDownload(functions);
37
- }
38
- /**
39
- * Gets synchronization state
40
- * @param callback Callback to receive state updates
41
- */
42
- getSynchronizationState(callback) {
43
- unvired_ts_core_sdk_1.NotificationListenerHelper.synchronizationStateListener = callback;
44
- // Initial state
45
- callback("idle");
46
- }
47
- /**
48
- * Starts Inbox Handler
49
- */
50
- startInboxHandler() {
51
- // Correct usage of SyncEngine as per SDK definition
52
- unvired_ts_core_sdk_1.SyncEngine.startInboxHandler();
53
- }
54
- /**
55
- * Starts Data Sender (Outbox Handler)
56
- */
57
- startDataSender() {
58
- unvired_ts_core_sdk_1.OutboxService.getInstance().start();
59
- }
60
- /**
61
- * Request for downloading messages from server
62
- */
63
- getMessages() {
64
- unvired_ts_core_sdk_1.SyncEngine.getMessages();
65
- }
66
- /**
67
- * Register for Data Sender notifications
68
- * @param callback Callback function
69
- */
70
- registerDataSenderListener(callback) {
71
- unvired_ts_core_sdk_1.NotificationListenerHelper.dataSenderListener = callback;
72
- }
73
- /**
74
- * Unregister Data Sender notifications
75
- */
76
- unRegisterDataSenderListener() {
77
- unvired_ts_core_sdk_1.NotificationListenerHelper.dataSenderListener = null;
78
- }
79
- /**
80
- * Register for Sync Items count updates
81
- * @param callback Callback function
82
- */
83
- registerSyncItemsCountListener(callback) {
84
- unvired_ts_core_sdk_1.NotificationListenerHelper.syncItemsCountListener = callback;
85
- }
86
- /**
87
- * Check if a BE is in the Outbox queue
88
- * @param beLid BE Header LID
89
- */
90
- async isInOutBox(beLid) {
91
- return unvired_ts_core_sdk_1.SettingsHelper.isInOutBoxQueue(beLid);
92
- }
93
- /**
94
- * Check if a BE is in Sent Items
95
- * @param beLid BE Header LID
96
- */
97
- async isInSentItem(beLid) {
98
- return unvired_ts_core_sdk_1.SettingsHelper.isInSentItems(beLid);
99
- }
100
- /**
101
- * Get count of items in Outbox
102
- */
103
- async outBoxItemCount() {
104
- return unvired_ts_core_sdk_1.SettingsHelper.getOutboxCount();
105
- }
106
- /**
107
- * Get count of items in Sent Items
108
- */
109
- async sentItemCount() {
110
- return unvired_ts_core_sdk_1.SettingsHelper.getSentItemsCount();
111
- }
112
- /**
113
- * Get count of items in Inbox
114
- */
115
- async inBoxItemCount() {
116
- return unvired_ts_core_sdk_1.SettingsHelper.getInboxCount();
117
- }
118
- /**
119
- * Delete an entry from Outbox
120
- * @param beLid BE Header LID
121
- */
122
- async deleteOutBoxEntry(beLid) {
123
- return unvired_ts_core_sdk_1.SyncEngine.removeOutObjectBasedOnLid(beLid);
124
- }
125
- /**
126
- * Lock Data Sender for a specific BE
127
- * @param beLid BE LID
128
- */
129
- async lockDataSender(beLid) {
130
- return unvired_ts_core_sdk_1.SyncEngine.lockDataSender(beLid);
131
- }
132
- /**
133
- * Unlock Data Sender
134
- */
135
- async unlockDataSender() {
136
- return unvired_ts_core_sdk_1.SyncEngine.unlockDataSender();
137
- }
138
- }
139
- exports.SyncService = SyncService;
@@ -1,45 +0,0 @@
1
- import AuthBuilder from './AuthBuilder';
2
- import { AuthenticationService } from '@unvired/unvired-ts-core-sdk';
3
-
4
- /**
5
- * Service for handling Authentication operations
6
- */
7
- export class AuthService {
8
-
9
- /**
10
- * Returns a builder for login method
11
- */
12
- login(): AuthBuilder {
13
- return new AuthBuilder('login');
14
- }
15
-
16
- /**
17
- * Returns a builder for authenticateAndActivate method
18
- */
19
- authenticateAndActivate(): AuthBuilder {
20
- return new AuthBuilder('authenticateAndActivate');
21
- }
22
-
23
- /**
24
- * Returns a builder for authenticateLocal method
25
- */
26
- authenticateLocal(): AuthBuilder {
27
- return new AuthBuilder('authenticateLocal');
28
- }
29
-
30
- /**
31
- * Logout method - Logs out the current user
32
- */
33
- async logout(): Promise<any> {
34
- const authService = (AuthenticationService as any).instance;
35
- return authService.logout();
36
- }
37
-
38
- /**
39
- * Clear all data
40
- */
41
- async clearData(): Promise<any> {
42
- const authService = (AuthenticationService as any).instance;
43
- return authService.clearData();
44
- }
45
- }
@@ -1,148 +0,0 @@
1
- import { AppDatabaseManager, DatabaseManager, SettingsHelper, FrameworkHelper, PlatformManager, DatabaseType } from '@unvired/unvired-ts-core-sdk';
2
-
3
- export class DatabaseService {
4
- private db: AppDatabaseManager;
5
-
6
- constructor() {
7
- this.db = AppDatabaseManager.getInstance();
8
- }
9
-
10
- /**
11
- * Selects data from the database
12
- * @param tableName Name of the table
13
- * @param whereClause Optional SQL where clause
14
- */
15
- async select(tableName: string, whereClause?: string): Promise<any> {
16
- return this.db.select(tableName, whereClause);
17
- }
18
-
19
- /**
20
- * Inserts data into the database
21
- * @param tableName Name of the table
22
- * @param structureObject Data object to insert
23
- * @param isHeader Whether the data is a header or an item
24
- */
25
- async insert(tableName: string, structureObject: any, isHeader: boolean): Promise<any> {
26
- return this.db.insert(tableName, structureObject, isHeader);
27
- }
28
-
29
- /**
30
- * Inserts or updates data in the database
31
- * @param tableName Name of the table
32
- * @param structureObject Data object to insert or update
33
- * @param isHeader Whether the data is a header or an item
34
- */
35
- async insertOrUpdate(tableName: string, structureObject: any, isHeader: boolean): Promise<any> {
36
- return this.db.insertOrUpdate(tableName, structureObject, isHeader);
37
- }
38
-
39
- /**
40
- * Deletes data from the database
41
- * @param tableName Name of the table
42
- * @param whereClause Optional SQL where clause
43
- */
44
- async delete(tableName: string, whereClause?: string): Promise<any> {
45
- return this.db.delete(tableName, whereClause);
46
- }
47
-
48
- /**
49
- * Updates data in the database
50
- * @param tableName Name of the table
51
- * @param updatedObject Object with updated values
52
- * @param whereClause SQL where clause identifying rows to update
53
- */
54
- async update(tableName: string, updatedObject: any, whereClause: any): Promise<any> {
55
- return this.db.update(tableName, updatedObject, whereClause);
56
- }
57
-
58
- /**
59
- * Executes a raw SQL statement
60
- * @param query SQL query
61
- */
62
- async executeStatement(query: string): Promise<any> {
63
- return this.db.executeStatement(query);
64
- }
65
-
66
- /**
67
- * Begins a transaction
68
- */
69
- async beginTransaction(): Promise<void> {
70
- return this.db.beginTransaction();
71
- }
72
-
73
- /**
74
- * Ends (commits) a transaction
75
- */
76
- async endTransaction(): Promise<void> {
77
- return this.db.endTransaction();
78
- }
79
-
80
- /**
81
- * Rolls back a transaction
82
- */
83
- async rollbackTransaction(): Promise<void> {
84
- return this.db.rollbackTransaction();
85
- }
86
-
87
- /**
88
- * Creates a save point
89
- * @param savePoint Name of the save point
90
- */
91
- async createSavePoint(savePoint: string): Promise<void> {
92
- return this.db.createSavePoint(savePoint);
93
- }
94
-
95
- /**
96
- * Releases a save point
97
- * @param savePoint Name of the save point
98
- */
99
- async releaseSavePoint(savePoint: string): Promise<void> {
100
- return this.db.releaseSavePoint(savePoint);
101
- }
102
-
103
- /**
104
- * Rolls back to a save point
105
- * @param savePoint Name of the save point
106
- */
107
- async rollbackToSavePoint(savePoint: string): Promise<void> {
108
- return this.db.rollbackToSavePoint(savePoint);
109
- }
110
-
111
- /**
112
- * Saves Web Data (Browser only)
113
- */
114
- async saveWebData(): Promise<void> {
115
- if (FrameworkHelper.getPlatform() === 'browser') {
116
- return DatabaseManager.getInstance().saveWebData();
117
- }
118
- }
119
-
120
- /**
121
- * Exports Web Data
122
- */
123
- async exportWebData(): Promise<void> {
124
- return DatabaseManager.getInstance().exportWebData();
125
- }
126
-
127
- /**
128
- * Prepares database for export
129
- */
130
- async prepareDatabaseForExport(): Promise<void> {
131
- return SettingsHelper.prepareDatabaseForExport();
132
- }
133
-
134
- /**
135
- * Gets the database directory path
136
- */
137
- async getDatabasePath(): Promise<string> {
138
- return new Promise((resolve, reject) => {
139
- try {
140
- const adapter = PlatformManager.getInstance().getPlatformAdapter().getDatabaseAdapter();
141
- // @ts-ignore - The type might be mismatch in d.ts but logical flow is correct
142
- adapter.getDBFilePath({ dbType: DatabaseType.AppDb }, (path) => resolve(path));
143
- } catch (e) {
144
- reject(e);
145
- }
146
- });
147
- }
148
- }
@@ -1,149 +0,0 @@
1
- import { AttachmentHelper, AttachmentQHelper, ServiceConstants, AppDatabaseManager } from '@unvired/unvired-ts-core-sdk';
2
-
3
- export class FileService {
4
-
5
- // AttachmentService is not exported from the SDK, so we cannot expose start/stop here directly.
6
- // If background sync control is needed, it might be via SyncEngine or other means.
7
-
8
- /**
9
- * Gets the directory used for storing attachments
10
- */
11
- async getAttachmentDirectory(): Promise<string> {
12
- let dir = await AttachmentHelper.getAttachmentDirectory();
13
- if (!dir.endsWith("/")) {
14
- dir += "/";
15
- }
16
- return dir;
17
- }
18
-
19
- /**
20
- * Adds an attachment
21
- * @param attachmentName Name of the attachment
22
- * @param attachmentData Data as ArrayBuffer
23
- */
24
- async addAttachment(attachmentName: string, attachmentData: ArrayBuffer): Promise<string> {
25
- return AttachmentHelper.addAttachment(attachmentName, attachmentData);
26
- }
27
-
28
- /**
29
- * Gets an attachment's data
30
- * @param attachmentName Name of the attachment
31
- */
32
- async getAttachment(attachmentName: string): Promise<ArrayBuffer> {
33
- return AttachmentHelper.getAttachment(attachmentName);
34
- }
35
-
36
- /**
37
- * Deletes an attachment
38
- * @param attachmentName Name of the attachment
39
- */
40
- async deleteAttachment(attachmentName: string): Promise<void> {
41
- return AttachmentHelper.deleteAttachment(attachmentName);
42
- }
43
-
44
- /**
45
- * Gets the file system path of an attachment
46
- * @param attachmentName Name of the attachment
47
- */
48
- async getAttachmentPath(attachmentName: string): Promise<string> {
49
- return AttachmentHelper.getAttachmentPath(attachmentName);
50
- }
51
-
52
- /**
53
- * Reads a file from the filesystem as ArrayBuffer
54
- * @param filePath Absolute path to the file
55
- */
56
- async readFileAsArrayBuffer(filePath: string): Promise<ArrayBuffer> {
57
- return AttachmentHelper.readFileAsArrayBuffer(filePath);
58
- }
59
-
60
- /**
61
- * Checks if a file exists
62
- * @param filePath Absolute path to the file
63
- */
64
- async fileExists(filePath: string): Promise<boolean> {
65
- return AttachmentHelper.fileExists(filePath);
66
- }
67
-
68
- /**
69
- * Reads an external file
70
- * @param filePath Absolute path to the file
71
- */
72
- async readExternalFile(filePath: string): Promise<ArrayBuffer> {
73
- return AttachmentHelper.readExternalFile(filePath);
74
- }
75
-
76
- /**
77
- * Writes data to an external file
78
- * @param filePath Parent directory path
79
- * @param fileName File name
80
- * @param data Data to write
81
- */
82
- async writeExternalFile(filePath: string, fileName: string, data: ArrayBuffer): Promise<void> {
83
- return AttachmentHelper.writeExternalFile(filePath, fileName, data);
84
- }
85
-
86
- /**
87
- * Deletes an external file
88
- * @param filePath Absolute path to the file
89
- */
90
- async deleteExternalFile(filePath: string): Promise<void> {
91
- return AttachmentHelper.deleteExternalFile(filePath);
92
- }
93
-
94
- /**
95
- * Create Attachment Item - Copies file to attachment folder and inserts record in DB
96
- * @param tableName Table name for attachment
97
- * @param structureObject Attachment item object
98
- */
99
- async createAttachmentItem(tableName: string, structureObject: any): Promise<any> {
100
- if (!tableName) throw new Error("Table name is null or empty");
101
- if (!structureObject) throw new Error("Structure object is null or empty");
102
-
103
- const fileName = structureObject[ServiceConstants.AttachmentItemFieldFileName];
104
- const localPath = structureObject[ServiceConstants.AttachmentItemFieldLocalPath];
105
-
106
- if (!fileName) throw new Error("File Name is null or empty");
107
- if (!localPath) throw new Error("Local Path is null or empty");
108
-
109
- const arrayBuffer = await AttachmentHelper.readFileAsArrayBuffer(localPath);
110
- if (!arrayBuffer) {
111
- throw new Error(`Attachment file could not be read at the location: ${localPath}`);
112
- }
113
-
114
- let attachmentName = structureObject[ServiceConstants.AttachmentItemFieldUid];
115
- if (fileName) {
116
- attachmentName = fileName;
117
- }
118
-
119
- const attachmentPath = await AttachmentHelper.addAttachment(attachmentName, arrayBuffer);
120
- structureObject[ServiceConstants.AttachmentItemFieldLocalPath] = attachmentPath;
121
- structureObject[ServiceConstants.AttachmentItemFieldAttachmentStatus] = ServiceConstants.AttachmentStatusSavedForUpload;
122
-
123
- await AppDatabaseManager.getInstance().insert(tableName, structureObject, false);
124
- return structureObject;
125
- }
126
-
127
- /**
128
- * Queues an attachment for download
129
- * @param tableName Table name
130
- * @param structureObject Structure object
131
- */
132
- async downloadAttachment(tableName: string, structureObject: any): Promise<any> {
133
- await AttachmentQHelper.queueForDownload(tableName, structureObject, ServiceConstants.FwAttachmentForceDownloadPriority);
134
- // Note: AttachmentService start is not exposed in SDK exports currently.
135
- // If needed, SyncEngine might handle it or it should be auto-handled.
136
- return structureObject;
137
- }
138
-
139
- /**
140
- * Downloads an attachment synchronously (waits for completion)
141
- * @param structureObject Structure object with UID and FileName
142
- */
143
- async downloadAttachmentSync(structureObject: any): Promise<any> {
144
- const uid = structureObject[ServiceConstants.AttachmentItemFieldUid];
145
- const fileName = structureObject[ServiceConstants.AttachmentItemFieldFileName];
146
- const attachmentPath = await AttachmentQHelper.downloadAttachmentAndGetPath(uid, fileName);
147
- return attachmentPath;
148
- }
149
- }
@@ -1,70 +0,0 @@
1
- import { PlatformManager } from '@unvired/unvired-ts-core-sdk';
2
-
3
- export class LoggerService {
4
-
5
- /**
6
- * Log Information
7
- * @param className Class Name
8
- * @param methodName Method Name
9
- * @param message Message
10
- */
11
- info(className: string, methodName: string, message: string): void {
12
- PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().logInfo(className, methodName, message);
13
- }
14
-
15
- /**
16
- * Log Error
17
- * @param className Class Name
18
- * @param methodName Method Name
19
- * @param message Message
20
- */
21
- error(className: string, methodName: string, message: string): void {
22
- PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().logError(className, methodName, message);
23
- }
24
-
25
- /**
26
- * Log Debug
27
- * @param className Class Name
28
- * @param methodName Method Name
29
- * @param message Message
30
- */
31
- debug(className: string, methodName: string, message: string): void {
32
- PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().logDebug(className, methodName, message);
33
- }
34
-
35
- /**
36
- * Set Log Level
37
- * @param level Log Level
38
- */
39
- setLogLevel(level: string): void {
40
- PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().setLogLevel(level);
41
- }
42
-
43
- /**
44
- * Get Log File URL
45
- */
46
- async getLogFileURL(): Promise<string> {
47
- return PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().getLogFileURL();
48
- }
49
-
50
- /**
51
- * Get Log File Content
52
- */
53
- async getLogFileContent(): Promise<string> {
54
- return PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().getLogFileContent();
55
- }
56
-
57
- /**
58
- * Get Backup Log File Content
59
- */
60
- async getBackupLogFileContent(): Promise<string> {
61
- return PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().getBackupLogFileContent();
62
- }
63
-
64
- /**
65
- * Clear Log File
66
- */
67
- async clearLogFile(): Promise<void> {
68
- return PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().clearLogFile();
69
- }
70
- }
@@ -1,45 +0,0 @@
1
- import { PlatformManager } from '@unvired/unvired-ts-core-sdk';
2
-
3
- export class NotificationService {
4
-
5
- private get adapter() {
6
- return PlatformManager.getInstance().getPlatformAdapter().getPushNotificationAdapter();
7
- }
8
-
9
- /**
10
- * Requests permission and gets token
11
- */
12
- async requestPermission(options?: { forceShow: boolean }): Promise<void> {
13
- return this.adapter?.requestPermission(options);
14
- }
15
-
16
- /**
17
- * Gets the push token
18
- */
19
- async getToken(): Promise<string | undefined> {
20
- return this.adapter?.getToken();
21
- }
22
-
23
- /**
24
- * Sets callback for token refresh
25
- */
26
- onTokenRefresh(callback: (token: string) => void): void {
27
- this.adapter?.onTokenRefresh(callback);
28
- }
29
-
30
- /**
31
- * Sets listener for incoming notifications (foreground)
32
- * @param onMessage Callback when a notification is received
33
- */
34
- onNotificationReceived(onMessage: (data: any) => void): void {
35
- this.adapter?.onMessage(onMessage);
36
- }
37
-
38
- /**
39
- * Sets listener for incoming notifications (background)
40
- * @param onMessage Callback when a notification is received
41
- */
42
- onBackgroundNotificationReceived(onMessage: (data: any) => void): void {
43
- this.adapter?.onBackgroundMessage(onMessage);
44
- }
45
- }