forked from danielsogl/awesome-cordova-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
1516 lines (1402 loc) · 45.2 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { Injectable } from '@angular/core';
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
import { Observable } from 'rxjs';
/**
* Outbox Lock Result States
*/
export enum OutboxLockStatus {
LockApplied = 0,
DataBeingSent = 1,
DataNotInQueue = 2,
}
/**
* Log levels supported in the sdk.
*/
export enum LogLevel {
important = 7,
error = 8,
debug = 9,
}
/**
* AuthenticateAndActivateResultType Some Documentation
*/
export enum AuthenticateAndActivateResultType {
/**
* This value indicates that UMP was able to validate users credentials & activation of the user is complete.
* In mobile apps, this also means database is created & apps can proceed with their custom logic.
*/
auth_activation_success = 2,
/**
* This value indicates that UMP was unable to validate users credentials.
*/
auth_activation_error = 3,
}
export enum AuthenticateLocalResultType {
/**
* This value indicates that UnviredCordovaSDK was able to validate users credentials and apps can proceed with their custom logic.
*/
login_success = 4,
/**
* This value indicates that UnviredCordovaSDK was unable to validate users credentials. You can retrieve the error information from AuthenticateLocalResult.
*/
login_error = 5,
}
export enum LoginListenerType {
/**
* This value indicates that there is no user account exists and user needs to authenticate & activate. Call authenticateAndActivate() api to activate the user.
*/
auth_activation_required = 0,
/**
* Applicable for mobile.
* This value indicates user needs to login before using the app. This depends on the setting LOCAL_PASSWORD which is set in UMP Admin Cockpit.
* If LOCAL_PASSWORD is set to true, this type is set everytime user opens the app.
*/
app_requires_login = 1,
/**
* This value indicates app can proceed with its custom logic.
*/
login_success = 4,
/**
* If there are multiple accounts active & no account is specified in the login(), then this value is returned indicating that a current account needs to be specified for the login().
*/
app_requires_current_account = 6,
/**
* This value indicates app can proceed with demo mode.
*/
login_demo = 7,
}
export enum LoginType {
/**
* This value represents authentication using Unvired ID.
* Example:
* ```
* loginParameters.username = 'USER_NAME'
* loginParameters.password = 'password'
* loginParameters.company = 'unvired'
* loginParameters.loginType = LoginType.unvired
* ```
*/
unvired = 'UNVIRED_ID',
/**
* This value represents authentication using Active Directory Service (ADS).
* Example:
* ```
* loginParameters.username = 'USER_NAME'
* loginParameters.password = 'password'
* loginParameters.company = 'unvired'
* loginParameters.domain = 'ADS_DOMAIN'
* loginParameters.loginType = LoginType.ads
* ```
*/
ads = 'ADS',
/**
* This value represents authentication using SAP ID.
* Example:
* ```
* loginParameters.username = 'USER_NAME'
* loginParameters.password = 'password'
* loginParameters.company = 'unvired'
* loginParameters.port = 'SAP_PORT_NAME'
* loginParameters.domain = 'SAP_DOMAIN'
* loginParameters.loginType = LoginType.sap
* ```
*/
sap = 'SAP',
/**
* EMAIL
* Set the type to email to login based on email id.
*/
email = 'EMAIL',
/**
* TODO:
*/
custom = 'CUSTOM',
}
export enum ResultType {
/**
* This value indicates a succesful operation.
*/
success = 0,
/**
* This value indicates an error.
*/
error,
}
export enum RequestType {
/**
* Set this type if the data exchange with UMP is 1:1. The header datastructure needs to be sent which also should be present in database prior to the call.
* You can use UnviredCordovaSDK's db methods to insert data into database.
*/
RQST = 'RQST',
/**
* Set this type if the data exchange with UMP is 1:N pr 0:N. Sending a datastructure is optional and is dependent on the Process Agent function.
* If the Process Agent function is marked with metadata delete flag, then server data replaces the data in database.
* If the Process Agent function is NOT marked with metadata delete flag, then this request type behaves the same as QUERY
*/
PULL = 'PULL',
/**
* This request type is for those message which are initiated by the server. You typically do not set this request type in sync.. methods.
*/
PUSH = 'PUSH',
/**
* Set this type if the data exchange with UMP is 1:N pr 0:N. Sending a datastructure is optional and is dependent on the Process Agent function.
* Unlike PULL, this request type updates the data in database without deleting existing entries.
*/
QUERY = 'QUERY',
/**
* Set this type if the data exchange with UMP is 1:0. This handles the case where no server response is expected.
*/
REQ = 'REQ',
}
export enum NotificationListenerType {
/**
* Notify successful asynchronous send of data to the server. This type indicates that data has moved from outbox to sent items.
*/
dataSend = 0,
/**
* Notify data changes for each BusinessEntity when received data from server. This type indicates when data is removed from sent items table.
*/
dataChanged = 1,
/**
* Notify data receive completion on receiving of all BusinessEntities from server. Data would get processed after this step.
*/
dataReceived = 2,
/**
* Notify application data reset.
*/
appReset = 3,
/**
* Notify application with error message and attchment item on attachment download success
*/
attachmentDownloadSuccess = 4,
/**
* Notify application with error message and attchment item on attachment download error
*/
attachmentDownloadError = 5,
/**
* Notify application when incoming data handling finished
*/
incomingDataProcessingFinished = 6,
/**
* Notify application when incoming data handling finished
*/
attachmentDownloadWaiting = 7,
/**
* Notify application with any InfoMessages
*/
infoMessage = 8,
/**
* Notify application with Server errors
*/
serverError = 9,
/**
* Notify attachment downloads completed
*/
attachmentDownloadCompleted = 10,
/**
* Notify when the sent item count changes.
*/
SentItemChanged = 11,
}
export enum AttachmentItemStatus {
DEFAULT = 0,
QUEUED_FOR_DOWNLOAD,
DOWNLOADED,
ERROR_IN_DOWNLOAD,
SAVED_FOR_UPLOAD,
UPLOADED,
ERROR_IN_UPLOAD,
MARKED_FOR_DELETE,
EXTERNAL,
}
export class Settings {
loginType: LoginType;
ADS_DOMAIN: string;
SAP_PORT_NAME: string;
EMAIL: string;
ADS_USER_ID: string;
SAP_USER_ID: string;
FULL_NAME: string;
SERVER_URL: string;
USER_ID: string;
}
export class UnviredResult {
/**
* The data returned in response to the api call.
*/
data: any;
/**
* The informational message returned in lieu of data.
*/
message: string;
/**
* Refer to the overrided property in subclasses.
*/
type: number;
/**
* Contains the error information which the apps can convey to the users.
*/
error: string;
/**
* Contains the detailed error information which the apps can convey to the users.
*/
errorDetail: string;
}
export class OutboxLockResult extends UnviredResult {
type: ResultType;
data: OutboxLockStatus;
}
export class LogResult extends UnviredResult {
type: ResultType;
data: LogLevel;
}
export class LogDataResult extends UnviredResult {
type: ResultType;
data: string;
}
export class NotifResult extends UnviredResult {
type: NotificationListenerType;
}
export class SettingsResult extends UnviredResult {
data: Settings;
type: ResultType;
}
export class SyncResult extends UnviredResult {
type: ResultType;
/**
* This code refers to the HTTP status code obtained during the network call.
*/
code: number;
}
export class DbResult extends UnviredResult {
type: ResultType;
}
export class LoginParameters {
/**
* Set the application name as configured in UMP.
*/
appName: string;
/**
* Company name as configured in UMP.
*/
company: string;
/**
* Username of the user trying to login.
*/
username: string;
/**
* Password of the user trying to login.
*/
password: string;
/**
* UMP URL. For example: https://umpdev.unvired.io/UMP
*/
url: string;
/**
* Domain name. Required only if the login type is ADS or SAP.
*/
domain: string;
/**
* Set this value to one of the allowed login types for your app as configured in UMP.
*/
loginType: LoginType;
/**
* FrontEndUserId: This id uniquely identifies the user across devices of same type. If the Unvired user has multiple front end ids for a device type, you need to set this value.
* If the Unvired user has only one front end id, leave this field blank.
*/
feUserId: string;
/**
* Required only if the loginType is 'sap'. This sets the SAP Port Name.
*/
port: string;
/**
* Required for Browser Platform.
* For iOS Platform include the metadata.xml file as part of App Bundle
* For Android Platform include the metadata.xml file in src > res > raw
*/
metadataPath: string;
/**
* This is required for Android only. Setting this value would save the attachments as Base64 string for easy access.
*/
isRequiredAttachmentBase64: boolean;
/**
* Set an interval in seconds at which the framework has to make an attempt to send data from outbox.
* If the data-sender fails for reason, then the framework does not restart even if there are outbox items.
* In those cases, you will have to set this value, so that the framework always makes an attempt to send from outbox.
* Example:
* loginParameters.autoSendTime = '5' // Make an attempt to send data every 5 seconds.
*/
autoSendTime: string;
/**
* Set the number of seconds at which GetMessage should automatically run. When this value is set, GetMessage would run in a interval as long as there are entries in Sent Items.
* You may need to set this value if your app doesn't support Push Notifications.
* By default, the framework does not do GetMessage automatically.
* Example:
* loginParameters.autoSyncTime = '5' // Make an attempt to receive data (GetMessage) every 5 seconds.
*/
autoSyncTime: string;
/**
* Specify the metadata as a JSON string. This will override metadata.xml set at platform level.
*/
metadataJSON: string;
/**
* Specify the demo data xml string for demo mode.
*/
demoData: string;
/**
* Set 'true' if the application supports demo mode otherwise set 'false'.
*/
demoModeRequired: boolean;
/*
* Set this value to true to persist web application database. By default, this value is false.
*/
persistWebDb: boolean;
/*
* Optional jwt token parameter. Please check with your Unvired Admin for this value.
* For Example:
* loginParameters.jwtOptions = {"app": "myapp"};
*/
jwtOptions: object;
/**
* Language code to be sent to UMP. Specify a two-letter language code.
* The default value of this is 'en'.
*/
loginLanguage: string;
}
export class LoginResult extends UnviredResult {
type: LoginListenerType;
}
export class AuthenticateActivateResult extends UnviredResult {
type: AuthenticateAndActivateResultType;
}
export class AuthenticateLocalResult extends UnviredResult {
type: AuthenticateLocalResultType;
}
/**
* @name Unvired Cordova SDK
* @description
* This plugin lets you build apps which connect to Unvired Mobile Platform (UMP).
* -
* iOS Requirements
* -
* Update your Cocoapods repo before you install the plugin.
* ```
* $ pod repo update
* ```
* -
* Browser Requirements
* -
* After you install the plugin, for Ionic/Angular projects, please add a reference to the following JS files within <head></head> section of index.html.
* ```
* <script src="assets/js/sql.js"></script>
* <script src="assets/js/kernel.js"></script>
* <script src="assets/js/winstore-jscompat.js"></script>
* <script src="assets/js/jquery-3.2.1.js"></script>
* ```
* @usage
* ```typescript
* import { UnviredCordovaSDK } from '@ionic-native/unvired-cordova-sdk/ngx';
*
*
* constructor(private unviredSDK: UnviredCordovaSDK) { }
*
* ...
* // This is usually done in app.component.ts of your app.
* // Before you can interact with UMP, you need to initialize the SDK and authenticate with UMP.
* // SDK Initialization
* let loginParameters = new LoginParameters()
* loginParameters.appName = 'UNVIRED_DIGITAL_FORMS'
* loginParameters.metadataPath = '../assets/metadata.json'
* let loginResult: LoginResult
* try {
* loginResult = await this.unviredSDK.login(loginParameters)
* }
* catch (error) {
* this.unviredSDK.logError("AppComponent", "Initialize", "Error during login: " + error)
* }
*
*
* switch (loginResult.type) {
* case LoginListenerType.auth_activation_required:
* // App is not activated. i.e, User is using the app for the very first time.
* // App needs to be activated before it can interact with UMP.
* // At this point of time, you basically navigate to a login screen & accept username / password from the user.
* // Set the username & password to loginParameters object and call authenticateAndActivate
* try {
* // Execute this block of code in a login screen.
* let loginParameters = new LoginParameters();
* loginParameters.url = '<UMP_URL>';
* loginParameters.company = '<Company>';
* loginParameters.username = '<Username>';
* loginParameters.password = '<Password>';
* loginParameters.loginType = LoginType.unvired;
* let authenticateActivateResult: AuthenticateActivateResult = await this.unviredSDK.authenticateAndActivate(loginParameters);
* if (authenticateActivateResult.type === AuthenticateAndActivateResultType.auth_activation_success) {
* // App is fully setup. Navigate to your app's home screen.
* } else if (authenticateActivateResult.type === AuthenticateAndActivateResultType.auth_activation_error) {
* console.log("Error during login: " + authenticateActivateResult.error)
* } catch (error) {
* this.unviredSDK.logError('LoginPage', 'auth_activation_required', 'ERROR: ' + error);
* }
* break;
*
*
*
* case LoginListenerType.app_requires_login:
* // App is already activated. But, the user needs to enter credentials because the setting LOCAL_PASSWORD is set to YES in Unvired Admin Cockpit.
* // To set LOCAL_PASSWORD property for your app, contact your administrator.
* try {
* // Execute this block of code in a login screen.
* let loginParameters = new LoginParameters()
* loginParameters.username = '<Username>';
* loginParameters.password = '<Password>';
* let authenticateLocalResult: AuthenticateLocalResult = await this.unviredSDK.authenticateLocal(loginParameters);
* if (authenticateLocalResult.type === AuthenticateLocalResultType.login_success) {
* // App is fully setup. Navigate to your app's home screen.
* } else if (authenticateLocalResult.type === AuthenticateLocalResultType.login_error) {
* console.log("Error during local login: " + authenticateActivateResult.error)
* } catch (error) {
* this.unviredSDK.logError('LoginPage', 'app_requires_login', 'ERROR: ' + error);
* }
* break;
*
*
*
* case login_success:
* // The setting LOCAL_PASSWORD is set to false.
* // App is fully initialized. Users can interact with the UMP
* // Navigate to Home screen
* break;
* }
*
*
*
*
*
* // Synchronization APIs
* // Example 1: Make a Sync RQST call
* ```
* await this.unviredSDK.syncForeground(RequestType.RQST, {"CUSTOMER_HEADER": {"CUST_NO" : "007", "CUST_NAME" : "James Bond"}}, '', 'PA_GET_CUSTOMER_DETAILS', true)
* ```
*
* // Example 2: Make a Sync QUERY / PULL call
* ```
* await this.unviredSDK.syncForeground(RequestType.QUERY, '', {"CUSTOMER_SEARCH_CONTEXT":[{"CUSTOMER_SEARCH_HEADER":{"CUST_NO":"007"}}]}, 'PA_SEARCH_CUSTOMER', true)
* ```
*
* Example 3: Make a Async RQST call
* ```
* await this.unviredSDK.syncBackground(RequestType.RQST, {"CUSTOMER_HEADER": {"CUST_NO" : "007", "CUST_NAME" : "James Bond"}}, '', 'PA_GET_CUSTOMER_DETAILS', 'CUSTOMER', beLID, false)
* ```
*
* Example 4: Make a Async QUERY / PULL call
* ```
* await this.unviredSDK.syncBackground(RequestType.QUERY, '', {"CUSTOMER_SEARCH_CONTEXT":[{"CUSTOMER_SEARCH_HEADER":{"CUST_NO":"007"}}]}, 'PA_SEARCH_CUSTOMER', '', '', true)
* ```
*
* // Note: Subscribe to NotificationListener to get updates on data processing in background
* // However, only one screen can listen to background data updates at any point of time.
* this.unviredSDK.registerNotifListener().subscribe( data => {
* switch (data.type) {
* case NotificationListenerType.dataSend:
* break;
* case NotificationListenerType.dataChanged:
* break;
* case NotificationListenerType.dataReceived:
* break;
* .
* .
* .
* }})
*
*
*
*
*
* // Database APIs
* // Insert a record onto database
* this.unviredsdk.dbInsert("CUSTOMER_HEADER", {"NAME":"James Bond","CUST_NO":"007"}, true);
*
* // Update a record in database
* this.unviredSDK.dbUpdate('CUSTOMER_HEADER', {"NAME":"John Doe","CUST_NO":"008"}, "CUST_NO = '007'")
*
* // Delete a record in database
* this.unviredSDK.dbDelete('CUSTOMER_HEADER', "CUST_NO = '007'")
*
* // Execute a SQL Query
* this.unviredSDK.dbExecuteStatement('SELECT * FROM CUSTOMER_HEADER WHERE CUSTOMER_ID = "007"')
*/
@Plugin({
pluginName: 'UnviredCordovaSDK',
plugin: 'cordova-plugin-unvired-sdk', // npm package name, example: cordova-plugin-camera
pluginRef: 'ump', // the variable reference to call the plugin, example: navigator.geolocation
repo: 'https://github.com/unvired/cordova-plugin-unvired-sdk/', // the github repository URL for the plugin
install: 'ionic cordova plugin add @ionic-native/unvired-cordova-sdk', // OPTIONAL install command, in case the plugin requires variables
installVariables: [], // OPTIONAL the plugin requires variables
platforms: ['iOS', 'Android', 'Windows', 'Browser'], // Array of platforms supported, example: ['Android', 'iOS']
})
@Injectable()
export class UnviredCordovaSDK extends IonicNativePlugin {
loginParameters: LoginParameters;
/**
* Write debug logs.
* @param sourceClass Name of the class
* @param method Name of the method
* @param message The actual message
* Example:
* ```
* this.unviredSDK.logDebug("Class Name", "Method Name", "Log Message")
* ```
* would produce the log message like this
* 01-07-2019 15:52 | DEBUG | Class Name | Method Name | Log Message
*/
@Cordova()
logDebug(sourceClass: string, method: string, message: string): Promise<any> {
return;
}
/**
* Write error logs.
* @param sourceClass Name of the class
* @param method Name of the method
* @param message The actual message
* Example:
* ```
* this.unviredSDK.logError("Class Name", "Method Name", "Log Message")
* ```
* would produce the log message like this
* 01-07-2019 15:52 | ERROR | Class Name | Method Name | Log Message
*/
@Cordova()
logError(sourceClass: string, method: string, message: string): Promise<any> {
return;
}
/**
* Write Info logs.
* @param sourceClass Name of the class
* @param method Name of the method
* @param message The actual message
* Example:
* ```
* this.unviredSDK.logInfo("Class Name", "Method Name", "Log Message")
* ```
* would produce the log message like this
* 01-07-2019 15:52 | IMPORTANT | Class Name | Method Name | Log Message
*/
@Cordova()
logInfo(sourceClass: string, method: string, message: string): Promise<any> {
return;
}
/**
* Returns the contents of the log file as a string.
*/
@Cordova()
logRead(): Promise<LogDataResult> {
return;
}
/**
* Resets the log file.
*/
@Cordova()
logDelete(): Promise<any> {
return;
}
/**
* Sends log file to server. The log file can be viewed under Settings > Device & Data in UMP Admin Cockpit.
*/
@Cordova()
sendLogToServer(): Promise<any> {
return;
}
/**
* Send logs via email interface. Calling this function opens up the default email interface with the log file as an attachment.
*/
@Cordova()
sendLogViaEmail(): Promise<any> {
return;
}
/**
* Returns the current log level.
*/
@Cordova()
getLogLevel(): Promise<LogResult> {
return;
}
/**
* Returns the path of the log file.
*/
@Cordova()
getLogFilePath(): Promise<string> {
return;
}
/**
* Set the log level of the app.
* @param logLevel The log level to set
*/
@Cordova()
setLogLevel(logLevel: LogLevel): Promise<any> {
return;
}
/**
* This api initializes the Unvired Application.
* @param loginParameters Set of parameters to be passed the login()
* For Example:
* ```
* let loginParameters = new LoginParameters()
* loginParameters.appName = 'UNVIRED_DIGITAL_FORMS'
* loginParameters.metadataPath = '../assets/metadata.json'
* loginParameters.loginType = LoginType.unvired
* ```
*/
@Cordova()
login(loginParameters: LoginParameters): Promise<LoginResult> {
return;
}
/**
* This api initializes the Unvired Application.
* @param loginParameters Set of parameters to be passed the loginWithDemoData()
* For Example:
* ```
* let loginParameters = new LoginParameters()
* loginParameters.appName = 'UNVIRED_DIGITAL_FORMS'
* loginParameters.metadataPath = '../assets/metadata.json'
* loginParameters.loginType = LoginType.unvired
* loginParameters.demoData = "<tag></tag>"
* ```
*/
@Cordova()
loginWithDemoData(loginParameters: LoginParameters): Promise<LoginResult> {
return;
}
/**
* Logs out the last active user.
*/
@Cordova()
logout(): Promise<any> {
return;
}
/**
* Authenticates ( With the Unvired Server ) & activates ( Receives Framework Settings ) the app against UMP
* Example:
* ```
* let loginParameters = new LoginParameters()
* loginParameters.username = 'MY_USERNAME'
* loginParameters.password = 'MY_PASSWORD'
* await this.unviredSDK.authenticateAndActivate(loginParameters)
* ```
* @param loginParameters LoginParamerter instance used to send username / password.
*/
@Cordova()
authenticateAndActivate(loginParameters: LoginParameters): Promise<AuthenticateActivateResult> {
return;
}
/**
* Authenticates the user against the previously saved username & password.
* For ADS Login, authentication is performed with the ADS Server.
* @param loginParameters Send username & Password through LoginParameters
* Example:
* ```
* let loginParameters = new LoginParameters()
* loginParameters.username = 'MY_USERNAME'
* loginParameters.password = 'MY_PASSWORD'
* await this.unviredSDK.authenticateLocal(loginParameters)
*/
@Cordova()
authenticateLocal(loginParameters: LoginParameters): Promise<AuthenticateLocalResult> {
return;
}
/**
* Get all the accounts configured on the device.
*/
@Cordova()
getAllAccounts(): Promise<any> {
return;
}
/**
* Switch account
* @param account The account to switch to
*/
@Cordova()
switchAccount(account: any): Promise<any> {
return;
}
/**
* Delete account
* @param account The account to delete
*/
@Cordova()
deleteAccount(account: any): Promise<any> {
return;
}
/**
* Get all InfoMessages linked to the header.
* @param headerName Name of the header. Example: CUSTOMER_HEADER
* @param lid LID of the header.
*/
@Cordova()
getInfoMessages(headerName: string, lid: string): Promise<any> {
return;
}
/**
* Supported for mobile Platforms.
* Display framework settings.
*/
@Cordova()
showSettings(): Promise<any> {
return;
}
/**
* Get User settings.
* Returns User setting in the following format:
* ```
* {
* "UNVIRED_ID": "", // The Unvired ID configured in UMP
* "USER_ID": "", // Deprecated. Select among UNVIRED_ID / EMAIL / ADS_USER_ID / SAP_USER_ID depending on the LoginType
* "FULL_NAME": "FirstName LastName",
* "EMAIL": "abc@example.com", // Email id of the user as configurd in UMP
* "SERVER_URL": "https://umpdev.unvired.io/UMP", // UMP Server's URL
* "SAP_USER_ID": "SAP_ID", // If LoginType is SAP
* "SAP_PORT_NAME": "", // If LoginType is SAP
* "LOGIN_TYPE": "", // @see LoginType
* "ADS_USER_ID": "ADS_USER_ID", // If LoginType is ADS
* "ADS_DOMAIN": "ADS_DOMAIN" // If LoginType is ADS
* }
* ```
*/
@Cordova()
userSettings(): Promise<SettingsResult> {
return;
}
/**
* Update System Credential
* @param credentials The credential to update to
*/
@Cordova()
updateSystemCredentials(credentials: any): Promise<any> {
return;
}
/**
* Get all system credentials.
*/
@Cordova()
getSystemCredentials(): Promise<any> {
return;
}
/**
* Get version number of unvired-cordova-sdk.
*/
@Cordova()
getVersionNumbers(): Promise<any> {
return;
}
/**
* Delete all data from the device.
*/
@Cordova()
clearData(): Promise<any> {
return;
}
/**
* Check whether the device has internet.
*/
@Cordova()
hasInternet(): Promise<any> {
return;
}
/**
* Get a random id to use as guid.
*/
@Cordova({ sync: true })
guid(): string {
return;
}
/**
* For Debugging Only. pull database file to "temp" folder for development purpose only.
*/
@Cordova()
pullDb(): Promise<any> {
return;
}
/**
* For Debugging Only. ush updated database file from "temp" folder to application directory for development purpose only
*/
@Cordova()
pushDb(): Promise<any> {
return;
}
/**
* Select records from Database
* @param tableName table name. Example: CUSTOMER_HEADER
* @param whereClause {Object} Browser: JSON object containing name-value pairs.
* Mobile: Or a Sqlite whereClause ( without the 'where' keyword )
* Example:
* ```
* # Select values from FORM_HEADER table where FORM_ID is 5caed815892215034dacad56
* this.unviredSDK.dbSelect('FORM_HEADER', "FORM_ID = '5caed815892215034dacad56'")
* ```
*/
@Cordova()
dbSelect(tableName: string, whereClause: any): Promise<DbResult> {
return;
}
/**
* Insert record into database.
* In browser platform this function always inserts or updates based on GID.
* @param tableName Name of the table.
* @param structureObject - JSON object containing name-value pairs.
* @param isHeader {boolean} - is DataStructure a header or item?
* Example:
* ```
* # Insert CUSTOMER_HEADER Datastructure into DB.
* this.unviredsdk.dbInsert("CUSTOMER_HEADER", {"NAME":"USER","NO":"0039"}, true);
* ```
*/
@Cordova()
dbInsert(tableName: string, structureObject: any, isHeader: boolean): Promise<DbResult> {
return;
}
/**
* insert or update the record ( if record exists ) into database.
* In browser insert always inserts or updates based on gid
* @param tableName Name of the table
* @param structureObject - JSON object containing name-value pairs.
* @param isHeader {boolean} - is DataStructure a header or item?
* Example:
* ```
* # Insert or update a CUSTOMER_HEADER with NAME as USER and NO as '0039'
* this.unviredsdk.dbInsertOrUpdate("CUSTOMER_HEADER",{"NAME":"UPDATED_USER","UPDATED_NO":"0039"},true);
* ```
*/
@Cordova()
dbInsertOrUpdate(tableName: string, structureObject: any, isHeader: boolean): Promise<DbResult> {
return;
}
/**
* Delete records from the database.
* @param tableName Name of the table
* @param whereClause {Object} Browser: JSON object containing name-value pairs.
* Mobile: Or a Sqlite whereClause ( without the 'where' keyword )
* Example:
* ```
* # Select values from FORM_HEADER table where FORM_ID is 5caed815892215034dacad56
* this.unviredSDK.dbDelete('FORM_HEADER', "FORM_ID = '5caed815892215034dacad56'")
* ```
*/
@Cordova()
dbDelete(tableName: string, whereClause: any): Promise<DbResult> {
return;
}
/**
* Update records in database.
* @param tableName Name of the table
* @param updatedObject JSON object containing updated name-value pairs.
* @param whereClause {Object} Browser: JSON object containing name-value pairs.
* Mobile: Or a Sqlite where Clause ( without the 'where' keyword )
* Example:
* ```
* # Update NAME & NO from FORM_HEADER table where FORM_ID is 5caed815892215034dacad56
* this.unviredSDK.dbUpdate('FORM_HEADER', {"NAME":"UPDATED_USER","UPDATED_NO":"0039"}, "FORM_ID = '5caed815892215034dacad56'")
* ```
*/
@Cordova()
dbUpdate(tableName: string, updatedObject: any, whereClause: any): Promise<DbResult> {
return;
}
/**
* Execute a SQL statement
* @param query {string} SQL Statement.
* Example:
* ```
* this.unviredSDK.dbExecuteStatement("SELECT * FROM CUSTOMER_HEADER WHERE CUSTOMER_ID = '39'")
* ```
*/
@Cordova()
dbExecuteStatement(query: string): Promise<DbResult> {
return;
}
/**
* Create Savepoint. For more info consult SQLite Documentation ( https://www.sqlite.org/lang_savepoint.html )
* @param savePoint {string} Name of savepoint
* Example:
* ```
* this.unviredSDK.dbCreateSavePoint('MySavePointName')
* ```