Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(unvired-cordova-sdk): changes to the property names and updated documentation #3633

Merged
merged 41 commits into from
Apr 5, 2021
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
54ca5c1
feat(unvired-cordova-sdk): support login via email
Aug 2, 2019
54266e9
fix(unvired-cordova-sdk): return typed promise object for user settings
Aug 2, 2019
adda8b9
fix(unvired-cordova-sdk): change return type to string for guid()
Aug 2, 2019
d2c3b6f
Merge commit 'f6e77db7b06f391fe31e4367101cbc9d2fccb369'
Aug 2, 2019
a3c6154
doc(unvired-cordova-sdk): doc update
Aug 6, 2019
5d5e799
Merge commit '64ca73e5ccf4163fcd4044257d875727f34c0b39'
Aug 19, 2019
08418d9
doc(unvired-cordova-sdk): update doc
Aug 20, 2019
05e984b
feat(unvired-cordova-sdk): add support for metadata JSON
Aug 22, 2019
dece93b
doc(unvired-cordova-sdk): update doc
Aug 30, 2019
c5b2a4e
doc(unvired-cordova-sdk): update doc
Sep 17, 2019
22d9583
Merge commit '3f172cc2b89f139a7bace275b93af37661b75f4a'
Sep 17, 2019
6293fc0
Merge commit '409a985142df4fe6956ec465921a0b062aaa61e6'
Oct 22, 2019
5a66578
feat(unvired-cordova-sdk): add methods to get and set log level
Oct 22, 2019
c8521c6
fix(unvired-cordova-sdk): update the return type for getLog()
Oct 23, 2019
112a9e5
feat(unvired-cordova-sdk): return platform name
Oct 25, 2019
e425b98
Merge commit '996bf00e850d43374b88fd2f0f417cff587d0650'
Nov 7, 2019
cbd1201
feat(unvired-cordova-sdk): add method to get log file path
Nov 7, 2019
b8e8f6f
feat(unvired-cordova-sdk): test push notifications
Nov 7, 2019
d382ceb
fix(unvired-cordova-sdk): define return for logRead
Nov 11, 2019
47ad3de
Merge commit 'b8695220eae02bdefcb72a3729df5d01be80a36f'
Dec 5, 2019
d700653
doc(unvired-cordova-sdk): remove mobile only restriction for some apis
Dec 5, 2019
e0afe81
feat(unvired-cordova-sdk): add new property containing HTTP status code.
Jan 29, 2020
8987ab9
Merge commit '1bcaa39ffdea7f273c2a30ae0ffc5a322c08edf0'
Jan 29, 2020
bd42d90
Merge commit '7277c0fbe5531f9faaab562fb7d715344b7ceaf8'
Feb 27, 2020
af3c82d
feat(unvired-cordova-sdk): add new functions to lock & unlock sending…
Feb 27, 2020
4af32cd
fix(unvired-cordova-sdk): update the return type for lock and unlock …
Feb 27, 2020
8d06492
fix(unvired-cordova-sdk): change the return type for lockDataSender api
Feb 27, 2020
5f19cb1
fix(unvired-cordova-sdk): fix the data type for ResultType and Outbox…
Feb 29, 2020
5e7a023
Merge branch 'master' into master
srinidhirao Feb 29, 2020
52df88d
doc(unvired-cordova-sdk): Update doc
Jun 25, 2020
59f4044
Merge branch 'master' of https://github.com/srinidhirao/ionic-native
Jun 25, 2020
fc8854f
doc(unvired-cordova-sdk): Update doc
Jun 25, 2020
9ca13e3
feat(unvired-cordova-sdk): Added new notification type
Aug 7, 2020
1c08dc2
Merge branch 'master' into master
srinidhirao Oct 1, 2020
aa34d6a
feat(unvired-cordova-sdk): delete outbox item based on lid
Oct 16, 2020
c540907
fix(unvired-cordova-sdk): Update doc
Dec 8, 2020
75f0fe7
doc(unvired-cordova-sdk): Update doc for userSettings()
Jan 11, 2021
d05a8d1
Merge commit '239ae32ad3cd281a63df4b1cb275785400ebd430'
Mar 2, 2021
2cde98c
feat(unvired-cordova-sdk): add new discovery api
Mar 2, 2021
af13cc1
fix(unvired-cordova-sdk): rename the property
Mar 5, 2021
7d0c896
doc(unvired-cordova-sdk): Doc update
Mar 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
244 changes: 193 additions & 51 deletions src/@ionic-native/plugins/unvired-cordova-sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,17 @@ export enum RequestType {
*/
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
* 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.
* 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',
Expand Down Expand Up @@ -203,6 +203,10 @@ export enum NotificationListenerType {
* Notify attachment downloads completed
*/
attachmentDownloadCompleted = 10,
/**
* Notify when the sent item count changes.
*/
SentItemChanged = 11,
}

export enum AttachmentItemStatus {
Expand All @@ -225,7 +229,7 @@ export class Settings {
ADS_USER_ID: string;
SAP_USER_ID: string;
FULL_NAME: string;
URL: string;
SERVER_URL: string;
USER_ID: string;
}

Expand Down Expand Up @@ -310,7 +314,7 @@ export class LoginParameters {
password: string;

/**
* UMP URL. For example: http://192.168.98.160:8080/UMP
* UMP URL. For example: https://umpdev.unvired.io/UMP
*/
url: string;

Expand Down Expand Up @@ -384,12 +388,19 @@ export class LoginParameters {
* 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'.
*/
languageCode: string;
}
export class LoginResult extends UnviredResult {
type: LoginListenerType;
Expand All @@ -410,10 +421,19 @@ export class AuthenticateLocalResult extends UnviredResult {
* -
* iOS Requirements
* -
* This plugin uses Cocoapods to install dependent libraries. Please make sure you have a valid Cocoapods installation.
* Once you have it ready, do update the cocoapods repo by running the following command before you install this plugin.
* Update your Cocoapods repo before you install the plugin.
* ```
* pod repo update
* $ 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
Expand Down Expand Up @@ -496,11 +516,26 @@ export class AuthenticateLocalResult extends UnviredResult {
*
*
* // Synchronization APIs
* // Make sync call.
* let result = await this.unviredSDK.syncForeground(RequestType.QUERY, null, {"CUSTOMER_HEADER": {"field1" : "value1", "field2" : "value2"}}, 'UNVIRED_DIGITAL_FORMS_PA_MOBILE_GET_USERS', true)
* // 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)
* ```
*
* // Make async call.
* let result = await this.unviredSDK.syncBackground(RequestType.QUERY, null, inputObj, 'UNVIRED_DIGITAL_FORMS_PA_MOBILE_GET_USERS', 'INPUT_GET_USERS', 'GUID', false)
* // 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 => {
Expand All @@ -522,20 +557,20 @@ export class AuthenticateLocalResult extends UnviredResult {
*
* // Database APIs
* // Insert a record onto database
* this.unviredsdk.dbInsert("CUSTOMER_HEADER", {"NAME":"USER","NO":"0039"}, true);
* this.unviredsdk.dbInsert("CUSTOMER_HEADER", {"NAME":"James Bond","CUST_NO":"007"}, true);
*
* // Update a record in database
* this.unviredSDK.dbUpdate('CUSTOMER_HEADER', {"NAME":"UPDATED_USER","NO":"UPDATED_NO"}, "FORM_ID = '5caed815892215034dacad56'")
* this.unviredSDK.dbUpdate('CUSTOMER_HEADER', {"NAME":"John Doe","CUST_NO":"008"}, "CUST_NO = '007'")
*
* // Delete a record in database
* this.unviredSDK.dbDelete('CUSTOMER_HEADER', "FORM_ID = '5caed815892215034dacad56'")
* this.unviredSDK.dbDelete('CUSTOMER_HEADER', "CUST_NO = '007'")
*
* // Execute a SQL Query
* this.unviredSDK.dbExecuteStatement('SELECT * FROM CUSTOMER_HEADER WHERE CUSTOMER_ID = "0039"')
* this.unviredSDK.dbExecuteStatement('SELECT * FROM CUSTOMER_HEADER WHERE CUSTOMER_ID = "007"')
*/
@Plugin({
pluginName: 'UnviredCordovaSDK',
plugin: 'https://github.com/unvired/cordova-plugin-unvired-sdk', // npm package name, example: cordova-plugin-camera
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
Expand Down Expand Up @@ -774,6 +809,21 @@ export class UnviredCordovaSDK extends IonicNativePlugin {

/**
* 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> {
Expand Down Expand Up @@ -1057,14 +1107,14 @@ export class UnviredCordovaSDK extends IonicNativePlugin {
* attachmentObject.LID = guid(); // Random id
* attachmentObject.FID = lid // LID of the header.
* attachmentObject.UID = guid(); // Random id
* attachmentObject.EXTERNAL_URL = ""; // Optional: Check with your Unvired Process agent developer.
* attachmentObject.EXTERNAL_URL = ""; // Optional: Check with your Unvired Process Agent developer.
* attachmentObject.FILE_NAME = 'myfile.jpg'; // Name of the file as stored in the device.
* attachmentObject.LOCAL_PATH = /<folder_location>/myfile.jpg // File path. Please make sure that the path starts with a '/'
* attachmentObject.TAG1 = '' // Optional: Check with your Unvired Process agent developer.
* attachmentObject.TAG2 = '' // Optional: Check with your Unvired Process agent developer.
* attachmentObject.TAG2 = '' // Optional: Check with your Unvired Process agent developer.
* attachmentObject.TAG4 = '' // Optional: Check with your Unvired Process agent developer.
* attachmentObject.TAG5 = '' // Optional: Check with your Unvired Process agent developer.
* attachmentObject.TAG1 = '' // Optional: Check with your Unvired Process Agent developer.
* attachmentObject.TAG2 = '' // Optional: Check with your Unvired Process Agent developer.
* attachmentObject.TAG2 = '' // Optional: Check with your Unvired Process Agent developer.
* attachmentObject.TAG4 = '' // Optional: Check with your Unvired Process Agent developer.
* attachmentObject.TAG5 = '' // Optional: Check with your Unvired Process Agent developer.
* await this.unviredCordovaSDK.createAttachmentItem('INSPECTION_ATTACHMENT', attachmentObject)
* ```
*/
Expand Down Expand Up @@ -1095,24 +1145,50 @@ export class UnviredCordovaSDK extends IonicNativePlugin {
}

/**
* Sends data to UMP in SYNC mode. This means user has to wait until the duration of SYNC call. Only one SYNC call can be active at any point of time. Once the call completes, the result data would be available in the Promise.
* Apps typically block UI during a SYNC call so that there are user-actions when the SYNC call is active.
* @param reqype RequestType for the message. Please check RequestType to select the right request type.
* @param header {Object} Header datastructure to be sent to UMP. Header datastructure is mandatory of the request type is RQST.
* For PA functions which do not accept any input, set an empty string for this parameter.
* Example: If Header datastructure needs to be sent, make sure the header datastructure is in the following format:
* Sends data to UMP in Sync mode. This means user has to wait until the duration of SYNC call. Only one SYNC call can be active at any point of time. Once the call completes, the result would be available in the Promise.
* Apps typically block UI during a SYNC call so that there are no user-actions possible until the call completes.
*
* Example 1: Make a RQST call
* ```
* {"CUSTOMER_HEADER": {"field1" : "value1", "field2" : "value2"}}
* await this.unviredSDK.syncForeground(RequestType.RQST, {"CUSTOMER_HEADER": {"CUST_NO" : "007", "CUST_NAME" : "James Bond"}}, '', 'PA_GET_CUSTOMER_DETAILS', true)
* ```
* @param customData {Object} This depends on the PA function. This is useful if you want to send custom data to a PA function.
* Example: You can also use this parameter to send header datastrucrture provided the data structure is formatted like this.
*
* Example 2: Make a QUERY / PULL call
* ```
* await this.unviredSDK.syncForeground(RequestType.QUERY, '', {"CUSTOMER_SEARCH_CONTEXT":[{"CUSTOMER_SEARCH_HEADER":{"CUST_NO":"007"}}]}, 'PA_SEARCH_CUSTOMER', true)
* ```
*
* @param reqype RequestType for the message. Please check RequestType to select the right request type.
* @param header {Object} Send a value for this parameter only if RequestType is RQST. For others, send an empty string. This parameter represents the header datastructure of the Business Entity which needs to be sent as input to a Process Agent function.
* Before you make this call, ensure that the object statuses are updated for header and child tables.
* Framework builds the input by considering only those child entities whose object status is one among ADD, MODIFY or DELETE.
* Example:
* ```json
* {
* "NAME_OF_HEADER": {
* "FIELD1": "FIELD_1_VALUE",
* "FIELD2": "FIELD_2_VALUE"
* }
* }
* ```
*
* @param customData {Object} Send a value for this parameter only if |reqType| is QUERY or PULL. For others, send an empty string.
* This parameter represents the actual input which need to be sent to the server. Usually this is an input entity, but check with your Process Agent developer on the type of input.
*
* Example:
* ```json
* {
* "CATEGORY_BE": [{
* "CATEGORY_HEADER": {"field1" : "value1", "field2" : "value2"}
* }]
* "BE_NAME": [
* {
* "NAME_OF_HEADER": {
* "FIELD1": "FIELD_1_VALUE",
* "FIELD2": "FIELD_2_VALUE"
* }
* }
* ]
* }
* ```
*
* @param paFunction Name of the Process Agent function to be executed. Example: PA_MOBILE_EXECUTE_SALES_ORDER.
* @param autoSave This defines whether to save the response to database.
*/
Expand All @@ -1128,28 +1204,63 @@ export class UnviredCordovaSDK extends IonicNativePlugin {
}

/**
* Sends data to UMP in ASYNC mode. This means user can make this call and continue with other program execution.
* Make an async call to UMP.
* The result of the call would be notified through the observable returned for the function registerNotifListener().
* @param reqype RequestType for the message. Please check RequestType to select the right request type.
* @param header {Object} Header datastructure to be sent to UMP. Header datastructure is mandatory of the request type is RQST.
* For PA functions which do not accept any input, set an empty string for this parameter.
* Example: If Header datastructure needs to be sent, make sure the header datastructure is in the following format:
*
* Pre-requisites:
* 1. Object status is updated for header and items which need to be synced with the server.
* 2. Updated header and items are saved in database.
* 3. The LID of the header. This value needs to be passed for the parameter `belid`.
*
* Example 1: Make a RQST call
* ```
* let customerHeader = new CUSTOMER_HEADER()
* customerHeader.LID = // TODO
* customerHeader.CUST_NO = '007'
* customerHeader.CUST_NAME = 'James Bond'
*
* await this.unviredSDK.syncBackground(RequestType.RQST, {"CUSTOMER_HEADER": customerHeader}, '', 'PA_GET_CUSTOMER_DETAILS', 'CUSTOMER', customerHeader.LID, false)
* ```
* {"CUSTOMER_HEADER": {"field1" : "value1", "field2" : "value2"}}
* Example 2: Make a QUERY / PULL call
* ```
* @param customData {Object} This depends on the PA function. This is useful if you want to send custom data to a PA function.
* Example: You can also use this parameter to send header datastrucrture provided the data structure is formatted like this.
* await this.unviredSDK.syncBackground(RequestType.QUERY, '', {"CUSTOMER_SEARCH_CONTEXT":[{"CUSTOMER_SEARCH_HEADER":{"CUST_NO":"007"}}]}, 'PA_SEARCH_CUSTOMER', '', '', true)
* ```
*
* @param reqype RequestType for the message. Please check RequestType to select the right request type.
* @param header {Object} Send a value for this parameter only if RequestType is RQST. For others, send an empty string. This parameter represents the header datastructure of the Business Entity which needs to be sent as input to a Process Agent function.
* Before you make this call, ensure that the object statuses are updated for header and child tables.
* Framework builds the input by considering only those child entities whose object status is one among ADD, MODIFY or DELETE.
* Example:
* ```json
* {
* "CATEGORY_BE": [{
* "CATEGORY_HEADER": {"field1" : "value1", "field2" : "value2"}
* }]
* "NAME_OF_HEADER": {
* "FIELD1": "FIELD_1_VALUE",
* "FIELD2": "FIELD_2_VALUE"
* }
* }
* ```
*
* @param customData {Object} Send a value for this parameter only if |reqType| is QUERY or PULL. For others, send an empty string.
* This parameter represents the actual input which need to be sent to the server. Usually this is an input entity, but check with your Process Agent developer on the type of input.
*
* Example:
* ```json
* {
* "BE_NAME": [
* {
* "NAME_OF_HEADER": {
* "FIELD1": "FIELD_1_VALUE",
* "FIELD2": "FIELD_2_VALUE"
* }
* }
* ]
* }
* ```
*
* @param paFunction Name of the Process Agent function to be executed. Example: PA_MOBILE_EXECUTE_SALES_ORDER.
* @param beName Name of the Business Entity
* @param belid LID of the Header datastructure
* @param bypassAttachment Set this flag to false if you want to upload attachments first and then make the server call.
* @param beName Name of the Business Entity. Required for the RequestType RQST only. For others, send empty string.
* @param belid LID of the Header datastructure. Required for the RequestType RQST only. For others, send empty string.
* @param bypassAttachment a true value would upload the data to the server followed by attachments. A false value would do the reverse.
*/
@Cordova()
syncBackground(
Expand Down Expand Up @@ -1233,7 +1344,7 @@ export class UnviredCordovaSDK extends IonicNativePlugin {

/**
* Subscribe to this observable to listen for life-cyle events in the case of an async message.
* Only one class can subscribe to notifications are any point of time.
* Only one class can subscribe to notifications at any point of time.
*/
@Cordova({
observable: true,
Expand Down Expand Up @@ -1372,4 +1483,35 @@ export class UnviredCordovaSDK extends IonicNativePlugin {
unlockDataSender(): Promise<UnviredResult> {
return;
}

/**
* Mobile Platform only.
* Delete an outbox item based on header's lid.
*/
@Cordova()
removeOutObjectBasedOnLid(lid: string): Promise<UnviredResult> {
return;
}

/**
* Returns an observable to return the UMP URLs which are discoverable within the network.
* Clients can use this information to allow users to select UMP servers in login page.
* ```
* this.unviredSDK.startDiscoveryService().subscribe( (result) => {
* if (result.type == ResultType.success) {
* console.log('Discovered URLs: ' + JSON.stringify(result.data))
* // {"name":"Chyme 98","url":"http://192.168.98.98:8080/UMP/","root":"UNVIRED","type":"DEVELOPMENT"}
* }
* else {
* console.log('Error in discovering URLs: ' + result.error)
* }
* })
* ```
*/
@Cordova({
observable: true,
})
startDiscoveryService(): Observable<UnviredResult> {
return;
}
}