@unvired/react-native-wrapper-sdk 0.0.23 → 0.0.25

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 (42) 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 +43 -0
  9. package/dist/lib/database/DatabaseService.d.ts.map +1 -0
  10. package/dist/lib/database/DatabaseService.js +34 -0
  11. package/dist/lib/file/FileService.d.ts +89 -0
  12. package/dist/lib/file/FileService.d.ts.map +1 -0
  13. package/dist/lib/file/FileService.js +267 -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 +44 -0
  21. package/dist/lib/settings/SettingsService.d.ts.map +1 -0
  22. package/dist/lib/settings/SettingsService.js +120 -0
  23. package/dist/lib/storage/StorageService.d.ts +13 -0
  24. package/dist/lib/storage/StorageService.d.ts.map +1 -0
  25. package/dist/lib/storage/StorageService.js +19 -0
  26. package/dist/lib/sync/SyncService.d.ts +96 -0
  27. package/dist/lib/sync/SyncService.d.ts.map +1 -0
  28. package/dist/lib/sync/SyncService.js +139 -0
  29. package/package.json +11 -6
  30. package/src/UnviredWrapper.ts +34 -52
  31. package/src/lib/auth/AuthService.ts +45 -0
  32. package/src/lib/database/DatabaseService.ts +53 -0
  33. package/src/lib/file/FileService.ts +313 -0
  34. package/src/lib/logger/LoggerService.ts +70 -0
  35. package/src/lib/notification/NotificationService.ts +45 -0
  36. package/src/lib/settings/SettingsService.ts +150 -0
  37. package/src/lib/storage/StorageService.ts +27 -0
  38. package/src/lib/sync/SyncService.ts +160 -0
  39. package/dist/lib/AuthBuilder.d.ts.map +0 -1
  40. /package/dist/lib/{AuthBuilder.d.ts → auth/AuthBuilder.d.ts} +0 -0
  41. /package/dist/lib/{AuthBuilder.js → auth/AuthBuilder.js} +0 -0
  42. /package/src/lib/{AuthBuilder.ts → auth/AuthBuilder.ts} +0 -0
@@ -0,0 +1,267 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.FileService = void 0;
37
+ const unvired_ts_core_sdk_1 = require("@unvired/unvired-ts-core-sdk");
38
+ class FileService {
39
+ getDocumentDirectory() {
40
+ // @ts-ignore
41
+ return unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().getDocumentDirectory();
42
+ }
43
+ resolveLocalFileSystemURL(url) {
44
+ // @ts-ignore
45
+ return unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().resolveLocalFileSystemURL(url);
46
+ }
47
+ async getFolderBasedOnUserId(userId) {
48
+ // @ts-ignore
49
+ return await unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().getFolderBasedOnUserId(userId);
50
+ }
51
+ async deleteUserFolder(userId) {
52
+ // @ts-ignore
53
+ await unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().deleteUserFolder(userId);
54
+ }
55
+ /**
56
+ * Reads an external file as ArrayBuffer using IFileEntry API
57
+ * @param filePath Absolute path to the file
58
+ */
59
+ async readExternalFile(filePath) {
60
+ // Get the file entry
61
+ const fileEntry = await this.resolveLocalFileSystemURL(filePath);
62
+ return new Promise((resolve, reject) => {
63
+ // Use the file() method to read the file
64
+ if (!fileEntry.file) {
65
+ reject(new Error('file() method not available on entry'));
66
+ return;
67
+ }
68
+ fileEntry.file(async (fileMetadata) => {
69
+ try {
70
+ // Read the file using react-native-fs
71
+ const RNFS = await Promise.resolve().then(() => __importStar(require('react-native-fs')));
72
+ const content = await RNFS.readFile(fileMetadata.path, 'utf8');
73
+ // Convert string to ArrayBuffer
74
+ const encoder = new TextEncoder();
75
+ resolve(encoder.encode(content).buffer);
76
+ }
77
+ catch (error) {
78
+ reject(error);
79
+ }
80
+ }, (error) => {
81
+ reject(error);
82
+ });
83
+ });
84
+ }
85
+ /**
86
+ * Writes data to an external file using IFileEntry API
87
+ * @param filePath Parent directory path
88
+ * @param fileName File name
89
+ * @param data Data to write (ArrayBuffer or string)
90
+ */
91
+ async writeExternalFile(filePath, fileName, data) {
92
+ // Convert data to string if it's ArrayBuffer
93
+ let content;
94
+ if (data instanceof ArrayBuffer) {
95
+ const decoder = new TextDecoder();
96
+ content = decoder.decode(data);
97
+ }
98
+ else {
99
+ content = data;
100
+ }
101
+ // Get the directory entry
102
+ const dirEntry = await this.resolveLocalFileSystemURL(filePath);
103
+ return new Promise((resolve, reject) => {
104
+ // Get or create the file
105
+ if (!dirEntry.getFile) {
106
+ reject(new Error('getFile() method not available on directory entry'));
107
+ return;
108
+ }
109
+ dirEntry.getFile(fileName, { create: true }, (fileEntry) => {
110
+ // Create a writer
111
+ if (!fileEntry.createWriter) {
112
+ reject(new Error('createWriter() method not available on file entry'));
113
+ return;
114
+ }
115
+ fileEntry.createWriter((writer) => {
116
+ writer.onwriteend = () => {
117
+ resolve();
118
+ };
119
+ writer.onerror = (error) => {
120
+ reject(error);
121
+ };
122
+ // Write the content
123
+ writer.write(content);
124
+ }, (error) => {
125
+ reject(error);
126
+ });
127
+ }, (error) => {
128
+ reject(error);
129
+ });
130
+ });
131
+ }
132
+ /**
133
+ * Deletes an external file using IFileEntry API
134
+ * @param filePath Absolute path to the file
135
+ */
136
+ async deleteExternalFile(filePath) {
137
+ const fileEntry = await this.resolveLocalFileSystemURL(filePath);
138
+ return new Promise((resolve, reject) => {
139
+ fileEntry.remove(() => resolve(), (error) => reject(error));
140
+ });
141
+ }
142
+ /**
143
+ * Checks if a file exists using IFileEntry API
144
+ * @param filePath Absolute path to the file
145
+ */
146
+ async fileExists(filePath) {
147
+ try {
148
+ await this.resolveLocalFileSystemURL(filePath);
149
+ return true;
150
+ }
151
+ catch (error) {
152
+ return false;
153
+ }
154
+ }
155
+ /**
156
+ * Creates a directory
157
+ * @param dirPath Parent directory path
158
+ * @param dirName Directory name to create
159
+ */
160
+ async createDirectory(dirPath, dirName) {
161
+ const parentEntry = await this.resolveLocalFileSystemURL(dirPath);
162
+ return new Promise((resolve, reject) => {
163
+ if (!parentEntry.getDirectory) {
164
+ reject(new Error('getDirectory() method not available on entry'));
165
+ return;
166
+ }
167
+ parentEntry.getDirectory(dirName, { create: true }, (dirEntry) => resolve(dirEntry), (error) => reject(error));
168
+ });
169
+ }
170
+ /**
171
+ * Lists files and directories in a directory
172
+ * @param dirPath Directory path to list
173
+ */
174
+ async listDirectory(dirPath) {
175
+ const dirEntry = await this.resolveLocalFileSystemURL(dirPath);
176
+ return new Promise((resolve, reject) => {
177
+ const reader = dirEntry.createReader();
178
+ reader.readEntries((entries) => resolve(entries), (error) => reject(error));
179
+ });
180
+ }
181
+ /**
182
+ * Deletes a directory and all its contents
183
+ * @param dirPath Directory path to delete
184
+ */
185
+ async deleteDirectory(dirPath) {
186
+ const dirEntry = await this.resolveLocalFileSystemURL(dirPath);
187
+ return new Promise((resolve, reject) => {
188
+ dirEntry.removeRecursively(() => resolve(), (error) => reject(error));
189
+ });
190
+ }
191
+ /**
192
+ * Copies a file
193
+ * @param sourcePath Source file path
194
+ * @param destDir Destination directory path
195
+ * @param newName New file name (optional, keeps original name if not provided)
196
+ */
197
+ async copyFile(sourcePath, destDir, newName) {
198
+ // Read source file
199
+ const content = await this.readExternalFile(sourcePath);
200
+ // Get source file name if newName not provided
201
+ const fileName = newName || sourcePath.split('/').pop() || 'file';
202
+ // Write to destination
203
+ await this.writeExternalFile(destDir, fileName, content);
204
+ }
205
+ /**
206
+ * Moves/renames a file
207
+ * @param sourcePath Source file path
208
+ * @param destDir Destination directory path
209
+ * @param newName New file name (optional, keeps original name if not provided)
210
+ */
211
+ async moveFile(sourcePath, destDir, newName) {
212
+ // Copy file to destination
213
+ await this.copyFile(sourcePath, destDir, newName);
214
+ // Delete source file
215
+ await this.deleteExternalFile(sourcePath);
216
+ }
217
+ /**
218
+ * Gets file information (size, modification date, etc.)
219
+ * @param filePath File path
220
+ */
221
+ async getFileInfo(filePath) {
222
+ const fileEntry = await this.resolveLocalFileSystemURL(filePath);
223
+ return new Promise((resolve, reject) => {
224
+ if (!fileEntry.file) {
225
+ reject(new Error('file() method not available on entry'));
226
+ return;
227
+ }
228
+ fileEntry.file((fileMetadata) => resolve(fileMetadata), (error) => reject(error));
229
+ });
230
+ }
231
+ /**
232
+ * Appends data to an existing file
233
+ * @param filePath File path
234
+ * @param data Data to append
235
+ */
236
+ async appendToFile(filePath, data) {
237
+ // Convert data to string if it's ArrayBuffer
238
+ let content;
239
+ if (data instanceof ArrayBuffer) {
240
+ const decoder = new TextDecoder();
241
+ content = decoder.decode(data);
242
+ }
243
+ else {
244
+ content = data;
245
+ }
246
+ const fileEntry = await this.resolveLocalFileSystemURL(filePath);
247
+ return new Promise((resolve, reject) => {
248
+ if (!fileEntry.createWriter) {
249
+ reject(new Error('createWriter() method not available on file entry'));
250
+ return;
251
+ }
252
+ fileEntry.createWriter((writer) => {
253
+ writer.onwriteend = () => {
254
+ resolve();
255
+ };
256
+ writer.onerror = (error) => {
257
+ reject(error);
258
+ };
259
+ // Append the content
260
+ writer.append(content);
261
+ }, (error) => {
262
+ reject(error);
263
+ });
264
+ });
265
+ }
266
+ }
267
+ 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,44 @@
1
+ export declare class SettingsService {
2
+ /**
3
+ * Get current log level
4
+ */
5
+ getLogLevel(): Promise<string>;
6
+ getDeviceInfo(): string;
7
+ getPlatform(): string;
8
+ getFrontendType(): string;
9
+ /**
10
+ * Set log level
11
+ * @param logLevel Log Level
12
+ */
13
+ setLogLevel(logLevel: string): Promise<void>;
14
+ /**
15
+ * Send logs to server
16
+ */
17
+ sendLogToServer(): Promise<void>;
18
+ /**
19
+ * Create and get Log Zip path (for email etc)
20
+ */
21
+ getLogZipPath(): Promise<string>;
22
+ /**
23
+ * Test Push Notification
24
+ */
25
+ testPushNotification(): Promise<void>;
26
+ /**
27
+ * Get list of Info Messages
28
+ */
29
+ getInfoMessages(headerName: string, lid: string): Promise<any[]>;
30
+ /**
31
+ * Get User Settings / Current Account Information
32
+ */
33
+ getUserSettings(): Promise<any>;
34
+ /**
35
+ * Set Auth Token
36
+ * @param token JWT Token
37
+ */
38
+ setAuthToken(token: string): Promise<void>;
39
+ /**
40
+ * Get Auth Token Validity (remaining seconds)
41
+ */
42
+ getAuthTokenValidity(): Promise<number>;
43
+ }
44
+ //# sourceMappingURL=SettingsService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SettingsService.d.ts","sourceRoot":"","sources":["../../../src/lib/settings/SettingsService.ts"],"names":[],"mappings":"AAYA,qBAAa,eAAe;IAC1B;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAIpC,aAAa,IAAI,MAAM;IAKvB,WAAW,IAAI,MAAM;IAKrB,eAAe,IAAI,MAAM;IAIzB;;;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,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAItE;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC;IA4CrC;;;OAGG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhD;;OAEG;IACG,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;CAoB9C"}
@@ -0,0 +1,120 @@
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
+ getDeviceInfo() {
13
+ // @ts-ignore
14
+ return unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().getDeviceInfo();
15
+ }
16
+ getPlatform() {
17
+ // @ts-ignore
18
+ return unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().getPlatform();
19
+ }
20
+ getFrontendType() {
21
+ // @ts-ignore
22
+ return unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().getFrontendType();
23
+ }
24
+ /**
25
+ * Set log level
26
+ * @param logLevel Log Level
27
+ */
28
+ async setLogLevel(logLevel) {
29
+ return unvired_ts_core_sdk_1.SettingsHelper.setLogLevel(logLevel);
30
+ }
31
+ /**
32
+ * Send logs to server
33
+ */
34
+ async sendLogToServer() {
35
+ return unvired_ts_core_sdk_1.SettingsHelper.sendLogsToServer();
36
+ }
37
+ /**
38
+ * Create and get Log Zip path (for email etc)
39
+ */
40
+ async getLogZipPath() {
41
+ return unvired_ts_core_sdk_1.SettingsHelper.createAndGetLogZipPath();
42
+ }
43
+ /**
44
+ * Test Push Notification
45
+ */
46
+ async testPushNotification() {
47
+ return unvired_ts_core_sdk_1.SettingsHelper.testPushNotification();
48
+ }
49
+ /**
50
+ * Get list of Info Messages
51
+ */
52
+ async getInfoMessages(headerName, lid) {
53
+ return unvired_ts_core_sdk_1.SettingsHelper.getInfoMessages(headerName, lid);
54
+ }
55
+ /**
56
+ * Get User Settings / Current Account Information
57
+ */
58
+ async getUserSettings() {
59
+ const unviredAccount = unvired_ts_core_sdk_1.UnviredAccountManager.getInstance().getLastLoggedInAccount();
60
+ if (!unviredAccount) {
61
+ throw new Error('No account found');
62
+ }
63
+ let jwtToken = unvired_ts_core_sdk_1.AuthenticationService.instance.jwtToken;
64
+ // Fallback or re-fetch token logic
65
+ if (!jwtToken) {
66
+ jwtToken = unviredAccount.getJwtToken();
67
+ }
68
+ const serverType = await unvired_ts_core_sdk_1.FrameworkSettingsManager.getInstance().getFieldValue(unvired_ts_core_sdk_1.FrameworkSettingsFields.serverType);
69
+ const emailId = await unvired_ts_core_sdk_1.FrameworkSettingsManager.getInstance().getFieldValue(unvired_ts_core_sdk_1.FrameworkSettingsFields.email);
70
+ const unviredUserId = await unvired_ts_core_sdk_1.UserSettingsManager.getInstance().getFieldValue(unvired_ts_core_sdk_1.UserSettingsFields.unviredUserId);
71
+ const unviredPassword = await unvired_ts_core_sdk_1.UserSettingsManager.getInstance().getFieldValue(unvired_ts_core_sdk_1.UserSettingsFields.unviredPassword);
72
+ // Accessing loginParameters from AuthenticationService might need cast if it's protected/private or simply public
73
+ // index.d.ts says: loginParameters: any;
74
+ const loginParams = unvired_ts_core_sdk_1.AuthenticationService.instance.loginParameters || {};
75
+ return {
76
+ UNVIRED_ID: unviredUserId,
77
+ USER_ID: loginParams.username || unviredUserId,
78
+ FIRST_NAME: unviredAccount.getFirstName(),
79
+ LAST_NAME: unviredAccount.getLastName(),
80
+ FULL_NAME: `${unviredAccount.getFirstName()} ${unviredAccount.getLastName()}`,
81
+ EMAIL: emailId || '',
82
+ SERVER_URL: unviredAccount.getServerURL(),
83
+ SERVER_TYPE: serverType || '',
84
+ LOGIN_TYPE: loginParams.loginType,
85
+ UNVIRED_PASSWORD: unviredPassword || '',
86
+ JWT_TOKEN: jwtToken,
87
+ };
88
+ }
89
+ /**
90
+ * Set Auth Token
91
+ * @param token JWT Token
92
+ */
93
+ async setAuthToken(token) {
94
+ unvired_ts_core_sdk_1.AuthenticationService.instance.jwtToken = token;
95
+ await unvired_ts_core_sdk_1.UserSettingsManager.getInstance().setFieldValue(unvired_ts_core_sdk_1.UserSettingsFields.jwtToken, token);
96
+ }
97
+ /**
98
+ * Get Auth Token Validity (remaining seconds)
99
+ */
100
+ async getAuthTokenValidity() {
101
+ const token = await unvired_ts_core_sdk_1.UserSettingsManager.getInstance().getFieldValue(unvired_ts_core_sdk_1.UserSettingsFields.jwtToken);
102
+ if (!token)
103
+ return 0;
104
+ try {
105
+ const parts = token.split('.');
106
+ if (parts.length !== 3)
107
+ return 0;
108
+ const payload = JSON.parse(atob(parts[1]));
109
+ if (!payload.exp)
110
+ return 0;
111
+ const now = Math.floor(Date.now() / 1000);
112
+ const remaining = payload.exp - now;
113
+ return remaining > 0 ? remaining : 0;
114
+ }
115
+ catch (e) {
116
+ return 0;
117
+ }
118
+ }
119
+ }
120
+ exports.SettingsService = SettingsService;
@@ -0,0 +1,13 @@
1
+ export interface IStorageAdapter {
2
+ getItem(key: string): void;
3
+ setItem(key: string, value: string): void;
4
+ removeItem(key: string): void;
5
+ clear(): void;
6
+ }
7
+ export declare class StorageService {
8
+ getItem(key: string): void;
9
+ setItem(key: string, value: string): void;
10
+ removeItem(key: string): void;
11
+ clear(): void;
12
+ }
13
+ //# sourceMappingURL=StorageService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorageService.d.ts","sourceRoot":"","sources":["../../../src/lib/storage/StorageService.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC5B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,KAAK,IAAI,IAAI,CAAC;CACjB;AAED,qBAAa,cAAc;IAEvB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI1B,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAIzC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI7B,KAAK,IAAI,IAAI;CAGhB"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StorageService = void 0;
4
+ const unvired_ts_core_sdk_1 = require("@unvired/unvired-ts-core-sdk");
5
+ class StorageService {
6
+ getItem(key) {
7
+ unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().getStorageAdapter().getItem(key);
8
+ }
9
+ setItem(key, value) {
10
+ unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().getStorageAdapter().setItem(key, value);
11
+ }
12
+ removeItem(key) {
13
+ unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().getStorageAdapter().removeItem(key);
14
+ }
15
+ clear() {
16
+ unvired_ts_core_sdk_1.PlatformManager.getInstance().getPlatformAdapter().getStorageAdapter().clear();
17
+ }
18
+ }
19
+ exports.StorageService = StorageService;