@sap_oss/wdio-qmate-service 2.7.1 → 2.7.3
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.
- package/docs/sections/bestPractices/selectors.md +1 -1
- package/docs/sections/features/selectors.md +2 -2
- package/lib/index.js.map +1 -1
- package/lib/reuse/authenticator/authHandler.js.map +1 -1
- package/lib/reuse/authenticator/basicUrlAuthenticator.js.map +1 -1
- package/lib/reuse/authenticator/customAuthenticator.js.map +1 -1
- package/lib/reuse/authenticator/formAuthenticator.js.map +1 -1
- package/lib/reuse/authenticator/plainAuthenticator.js.map +1 -1
- package/lib/reuse/helper/clientsideUI5scripts.js.map +1 -1
- package/lib/reuse/helper/elementHighlight.js.map +1 -1
- package/lib/reuse/helper/elementResolving.js.map +1 -1
- package/lib/reuse/helper/errorHandler.js.map +1 -1
- package/lib/reuse/helper/inputValidation.js.map +1 -1
- package/lib/reuse/helper/jsDocGen.js.map +1 -1
- package/lib/reuse/helper/jsonDocGen.js.map +1 -1
- package/lib/reuse/modules/common/constants/date.constants.js +1 -1
- package/lib/reuse/modules/common/constants/date.constants.js.map +1 -1
- package/lib/reuse/modules/common/constants/userInteraction.constants.js +1 -1
- package/lib/reuse/modules/common/constants/userInteraction.constants.js.map +1 -1
- package/lib/reuse/modules/common/date.js.map +1 -1
- package/lib/reuse/modules/common/navigation.js.map +1 -1
- package/lib/reuse/modules/common/userInteraction.js.map +1 -1
- package/lib/reuse/modules/nonUi5/assertion.js.map +1 -1
- package/lib/reuse/modules/nonUi5/element.js.map +1 -1
- package/lib/reuse/modules/nonUi5/navigation.js.map +1 -1
- package/lib/reuse/modules/nonUi5/session.js.map +1 -1
- package/lib/reuse/modules/nonUi5/userInteraction.js.map +1 -1
- package/lib/reuse/modules/service/odata.d.ts +74 -48
- package/lib/reuse/modules/service/odata.js +167 -134
- package/lib/reuse/modules/service/odata.js.map +1 -1
- package/lib/reuse/modules/service/rest.js.map +1 -1
- package/lib/reuse/modules/ui5/assertion.js +9 -0
- package/lib/reuse/modules/ui5/assertion.js.map +1 -1
- package/lib/reuse/modules/ui5/constants/mockserver.constants.js +1 -1
- package/lib/reuse/modules/ui5/constants/mockserver.constants.js.map +1 -1
- package/lib/reuse/modules/ui5/control.js.map +1 -1
- package/lib/reuse/modules/ui5/date.d.ts +1 -1
- package/lib/reuse/modules/ui5/date.js +1 -1
- package/lib/reuse/modules/ui5/date.js.map +1 -1
- package/lib/reuse/modules/ui5/element.js.map +1 -1
- package/lib/reuse/modules/ui5/mockserver.js.map +1 -1
- package/lib/reuse/modules/ui5/navigation.js.map +1 -1
- package/lib/reuse/modules/ui5/navigationBar.js.map +1 -1
- package/lib/reuse/modules/ui5/qunit.js.map +1 -1
- package/lib/reuse/modules/ui5/session.js +1 -1
- package/lib/reuse/modules/ui5/session.js.map +1 -1
- package/lib/reuse/modules/ui5/table.js.map +1 -1
- package/lib/reuse/modules/ui5/userInteraction.js.map +1 -1
- package/lib/reuse/modules/util/browser.js.map +1 -1
- package/lib/reuse/modules/util/component.js.map +1 -1
- package/lib/reuse/modules/util/console.js.map +1 -1
- package/lib/reuse/modules/util/constants/formatter.constants.js +1 -1
- package/lib/reuse/modules/util/constants/formatter.constants.js.map +1 -1
- package/lib/reuse/modules/util/data.js.map +1 -1
- package/lib/reuse/modules/util/file.js.map +1 -1
- package/lib/reuse/modules/util/formatter.js.map +1 -1
- package/lib/reuse/modules/util/function.js.map +1 -1
- package/lib/reuse/modules/util/system.js.map +1 -1
- package/lib/reuse/runner/runner.js.map +1 -1
- package/lib/scripts/clientsideUI5scripts.js.map +1 -1
- package/lib/scripts/dataExchange/dataExchange.js.map +1 -1
- package/lib/scripts/dataExchange/dataExchangeUtil.js.map +1 -1
- package/lib/scripts/hooks/beforeSession.js.map +1 -1
- package/lib/scripts/hooks/onPrepare.js.map +1 -1
- package/lib/scripts/hooks/utils/addLocatorCommands.js.map +1 -1
- package/lib/scripts/hooks/utils/browserLog.js.map +1 -1
- package/lib/scripts/hooks/utils/cycle.js.map +1 -1
- package/lib/scripts/hooks/utils/dataExchangeCommands.js.map +1 -1
- package/lib/scripts/hooks/utils/decryption.js.map +1 -1
- package/lib/scripts/hooks/utils/lib.js.map +1 -1
- package/lib/scripts/hooks/utils/locatorCommands.js.map +1 -1
- package/lib/scripts/locators/qmateLocator.js.map +1 -1
- package/lib/scripts/locators/uiveri5Locator.js.map +1 -1
- package/package.json +13 -13
- package/test/core/functional/chaining/test.conf.js +1 -1
- package/test/core/functional/locators/ancestorProperties.test.js +3 -3
- package/test/core/functional/locators/childProperties.test.js +1 -1
- package/test/core/functional/locators/descendantProperties.test.js +2 -2
- package/test/core/functional/locators/parentProperties.test.js +1 -1
- package/test/core/functional/locators/test.locator.conf.js +1 -1
- package/test/core/functional/nativeBrowser/runInBrowser.test.js +1 -1
- package/test/core/functional/nativeBrowser/test.conf.js +1 -1
- package/test/core/functional/nonUi5/test.conf.js +1 -1
- package/test/core/functional/ui5Properties/getAggregations.test.js +3 -3
- package/test/core/functional/ui5Properties/getProperties.test.js +4 -4
- package/test/core/functional/ui5Properties/test.conf.js +1 -1
- package/test/core/functional/uiveri5/test.conf.js +1 -1
- package/test/core/testIntegration/config.js +1 -1
- package/test/core/testIntegration/configMultiCombo.js +1 -1
- package/test/core/testIntegration/configTable.js +1 -1
- package/test/reuse/common/assertion/test.assertion.conf.js +1 -1
- package/test/reuse/common/navigation/navigateToUrl.spec.js +1 -1
- package/test/reuse/common/navigation/navigateToUrlAndRetry.spec.js +1 -1
- package/test/reuse/common/userInteraction/clearAndFillActive.spec.js +3 -3
- package/test/reuse/common/userInteraction/clearAndFillActiveAndRetry.spec.js +3 -3
- package/test/reuse/common/userInteraction/fillActive.spec.js +6 -6
- package/test/reuse/common/userInteraction/fillActiveAndRetry.spec.js +4 -4
- package/test/reuse/common/userInteraction/pressKey.spec.js +1 -1
- package/test/reuse/nonUi5/assertion/expectToBeVisible.spec.js +1 -1
- package/test/reuse/nonUi5/assertion/expectValueToBe.spec.js +2 -2
- package/test/reuse/nonUi5/assertion/test.assertion.conf.js +1 -1
- package/test/reuse/nonUi5/assertion/test.assertion.sauceLabs.conf.js +1 -1
- package/test/reuse/nonUi5/element/getAttributeValue.spec.js +3 -3
- package/test/reuse/nonUi5/element/getByChild.spec.js +4 -4
- package/test/reuse/nonUi5/element/getByClass.spec.js +4 -4
- package/test/reuse/nonUi5/element/getByCss.spec.js +3 -3
- package/test/reuse/nonUi5/element/getByCssContainingText.spec.js +4 -4
- package/test/reuse/nonUi5/element/getById.spec.js +3 -3
- package/test/reuse/nonUi5/element/getByParent.spec.js +4 -4
- package/test/reuse/nonUi5/element/getByXPath.spec.js +2 -2
- package/test/reuse/nonUi5/element/getValue.spec.js +3 -3
- package/test/reuse/nonUi5/element/highlight.spec.js +1 -1
- package/test/reuse/nonUi5/element/isPresent.spec.js +3 -3
- package/test/reuse/nonUi5/element/isPresentByCss.spec.js +2 -2
- package/test/reuse/nonUi5/element/isPresentByXPath.spec.js +2 -2
- package/test/reuse/nonUi5/element/setInnerHTML.spec.js +1 -1
- package/test/reuse/nonUi5/element/test.element.conf.js +1 -1
- package/test/reuse/nonUi5/element/test.element.sauceLabs.conf.js +1 -1
- package/test/reuse/nonUi5/userInteraction/doubleClick.spec.js +1 -1
- package/test/reuse/nonUi5/userInteraction/moveCursorAndClick.spec.js +1 -1
- package/test/reuse/nonUi5/userInteraction/rightClick.spec.js +1 -1
- package/test/reuse/nonUi5/userInteraction/scrollToElement.spec.js +3 -3
- package/test/reuse/service/odata/get.spec.js +4 -10
- package/test/reuse/service/odata/getEntitySet.spec.js +2 -8
- package/test/reuse/ui5/assertion/expectMessageToastTextToBe.spec.js +2 -2
- package/test/reuse/ui5/assertion/expectToBeVisible.spec.js +1 -1
- package/test/reuse/ui5/assertion/expectToBeVisibleInViewport.spec.js +1 -1
- package/test/reuse/ui5/assertion/expectValidationError.spec.js +2 -2
- package/test/reuse/ui5/assertion/expectValidationSuccess.spec.js +2 -2
- package/test/reuse/ui5/assertion/expectValueToBeDefined.spec.js +1 -1
- package/test/reuse/ui5/assertion/test.assertion.conf.js +1 -1
- package/test/reuse/ui5/assertion/test.assertion.sauceLab.conf.js +1 -1
- package/test/reuse/ui5/confirmationDialog/clickButton.spec.js +2 -2
- package/test/reuse/ui5/confirmationDialog/clickNo.spec.js +2 -2
- package/test/reuse/ui5/confirmationDialog/clickOk.spec.js +1 -1
- package/test/reuse/ui5/confirmationDialog/clickYes.spec.js +1 -1
- package/test/reuse/ui5/confirmationDialog/test.confirmationDialog.conf.js +1 -1
- package/test/reuse/ui5/confirmationDialog/test.confirmationDialog.sauceLab.conf.js +1 -1
- package/test/reuse/ui5/control/focus.spec.js +4 -4
- package/test/reuse/ui5/control/getAggregationProperty.spec.js +2 -2
- package/test/reuse/ui5/control/getAssociationProperty.spec.js +2 -2
- package/test/reuse/ui5/control/test.control.conf.js +1 -1
- package/test/reuse/ui5/control/test.control.sauceLab.conf.js +1 -1
- package/test/reuse/ui5/date/fillRange.spec.js +2 -2
- package/test/reuse/ui5/date/pick.spec.js +4 -4
- package/test/reuse/ui5/date/pickRange.spec.js +4 -4
- package/test/reuse/ui5/element/getByChild.spec.js +3 -3
- package/test/reuse/ui5/element/getByParent.spec.js +3 -3
- package/test/reuse/ui5/element/getByText.spec.js +1 -1
- package/test/reuse/ui5/element/getPropertyValue.spec.js +1 -1
- package/test/reuse/ui5/element/test.element.conf.js +1 -1
- package/test/reuse/ui5/element/test.element.sauceLab.conf.js +1 -1
- package/test/reuse/ui5/element/waitForAll.spec.js +2 -2
- package/test/reuse/ui5/errorDialog/clickClose.spec.js +1 -1
- package/test/reuse/ui5/errorDialog/expectToBeVisible.spec.js +1 -1
- package/test/reuse/ui5/mockserver_qunit/test/flpSandboxMockServer.html +2 -2
- package/test/reuse/ui5/mockserver_qunit/test/flpSandboxMockServerAllData.html +2 -2
- package/test/reuse/ui5/mockserver_qunit/test/unit/unitTests.qunit.html +1 -1
- package/test/reuse/ui5/navigationBar/test.navigationBar.sauceLab.conf.js +1 -1
- package/test/reuse/ui5/session/logout.spec.js +1 -1
- package/test/reuse/ui5/table/clickSettingsButton.spec.js +2 -2
- package/test/reuse/ui5/table/sortColumnAscending.spec.js +3 -3
- package/test/reuse/ui5/table/sortColumnDescending.spec.js +3 -3
- package/test/reuse/ui5/userInteraction/check.spec.js +3 -3
- package/test/reuse/ui5/userInteraction/clear.spec.js +3 -3
- package/test/reuse/ui5/userInteraction/clearAndFill.spec.js +6 -6
- package/test/reuse/ui5/userInteraction/clearAndFillAndRetry.spec.js +5 -5
- package/test/reuse/ui5/userInteraction/clearAndFillSmartFieldInput.spec.js +2 -2
- package/test/reuse/ui5/userInteraction/clearAndFillSmartFieldInputAndRetry.spec.js +1 -1
- package/test/reuse/ui5/userInteraction/clearAndRetry.spec.js +2 -2
- package/test/reuse/ui5/userInteraction/click.spec.js +4 -4
- package/test/reuse/ui5/userInteraction/clickAndRetry.spec.js +3 -3
- package/test/reuse/ui5/userInteraction/clickSelectArrow.spec.js +2 -2
- package/test/reuse/ui5/userInteraction/clickSelectArrowAndRetry.spec.js +3 -3
- package/test/reuse/ui5/userInteraction/clickTab.spec.js +3 -3
- package/test/reuse/ui5/userInteraction/doubleClick.spec.js +4 -4
- package/test/reuse/ui5/userInteraction/dragAndDrop.spec.js +1 -1
- package/test/reuse/ui5/userInteraction/fill.spec.js +4 -4
- package/test/reuse/ui5/userInteraction/fillAndRetry.spec.js +4 -4
- package/test/reuse/ui5/userInteraction/mouseOverElement.spec.js +2 -2
- package/test/reuse/ui5/userInteraction/openF4Help.spec.js +2 -2
- package/test/reuse/ui5/userInteraction/rightClick.spec.js +4 -4
- package/test/reuse/ui5/userInteraction/scrollToElement.spec.js +4 -4
- package/test/reuse/ui5/userInteraction/searchFor.spec.js +4 -4
- package/test/reuse/ui5/userInteraction/selectBox.spec.js +4 -4
- package/test/reuse/ui5/userInteraction/selectCombobox.spec.js +4 -4
- package/test/reuse/ui5/userInteraction/selectFromTab.spec.js +1 -1
- package/test/reuse/ui5/userInteraction/selectMultiComboBox.spec.js +5 -5
- package/test/reuse/ui5/userInteraction/test.userInteraction.conf.js +1 -1
- package/test/reuse/ui5/userInteraction/test.userInteraction.sauceLab.conf.js +1 -1
- package/test/reuse/ui5/userInteraction/uncheck.spec.js +3 -3
- package/test/reuse/util/browser/back.spec.js +1 -1
- package/test/reuse/util/browser/forward.spec.js +1 -1
- package/test/reuse/util/browser/getBaseUrl.spec.js +1 -1
- package/test/reuse/util/browser/getBrowserName.spec.js +1 -1
- package/test/reuse/util/browser/getCurrentWindow.spec.js +2 -2
- package/test/reuse/util/browser/setBaseUrl.spec.js +2 -2
- package/test/reuse/util/browser/switchToWindow.spec.js +2 -2
- package/test/reuse/util/browser/test.browser.conf.js +1 -1
- package/test/reuse/util/file/test.file.conf.js +1 -1
- package/test/reuse/util/file/upload.spec.js +2 -2
- package/test/reuse/util/formatter/test.formatter.conf.js +1 -1
- package/test/reuse/util/system/test.system.conf.js +1 -1
- package/tsconfig.json +0 -1
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
interface IHeaders {
|
|
2
|
+
[key: string]: string;
|
|
3
|
+
}
|
|
4
|
+
interface IParams {
|
|
5
|
+
[key: string]: string;
|
|
6
|
+
}
|
|
1
7
|
/**
|
|
2
8
|
* @class odata
|
|
3
9
|
* @memberof service
|
|
@@ -11,48 +17,58 @@ export declare class OData {
|
|
|
11
17
|
/**
|
|
12
18
|
* @function init
|
|
13
19
|
* @memberOf service.odata
|
|
14
|
-
* @description Initializes
|
|
20
|
+
* @description Initializes the OData Service.
|
|
15
21
|
* XCSRF-Token will be automatically fetched and stored in the service instance.
|
|
16
22
|
* Cookies will also automatically assembled and stored in the service instance.
|
|
17
|
-
* @param {String} url - The base url of the service
|
|
18
|
-
* @param {String} username - The username.
|
|
23
|
+
* @param {String} url - The base url of the service.
|
|
24
|
+
* @param {String} username - The username to authenticate the service.
|
|
19
25
|
* @param {String} password - The password of the username.
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {Object} [params={}] - JSON object with key-value pairs of parameter names and corresponding values
|
|
22
|
-
*
|
|
26
|
+
* @param {Boolean} [loggingEnabled=false] - The boolean param to control whether user wants to see logs during build run.
|
|
27
|
+
* @param {Object} [params={}] - JSON object with key-value pairs of parameter names and corresponding values.
|
|
28
|
+
* By default we send {
|
|
23
29
|
* "client": "715",
|
|
24
30
|
* "documentation": ["heading", "quickinfo"],
|
|
25
31
|
* "language": "EN"
|
|
26
32
|
* }
|
|
27
|
-
* These can be overridden by sending params as JSON object with additional params as shown in example
|
|
33
|
+
* These can be overridden by sending params as JSON object with additional params as shown in example.
|
|
28
34
|
* @param {String} [authType] - authentication type, in case you want to override the default
|
|
29
35
|
* SAML authentication. Set this to "basic", to use basic authentication for communication users for whom SAML login doesn't work.
|
|
30
36
|
* Or "none" for no authentication.
|
|
37
|
+
* @param {Object} [headers=undefined] - JSON object with key-value pairs of optional headers.
|
|
31
38
|
* @returns {Object} The initialized service object.
|
|
32
39
|
* @example const url = "<urlToSystem>/sap/opu/odata/sap/API_PURCHASEORDER_PROCESS_SRV/";
|
|
33
40
|
* const params = {
|
|
34
41
|
* "saml2": "disabled",
|
|
35
42
|
* "language": "de"
|
|
36
43
|
* }
|
|
37
|
-
* srv = await service.odata.init(url, user, password, false, params);
|
|
44
|
+
* const srv = await service.odata.init(url, user, password, false, params);
|
|
45
|
+
* @example const base64Credentials = Buffer.from(`${user}:${password}`).toString("base64");
|
|
46
|
+
* const authHeaders = {
|
|
47
|
+
* "Authorization": `Basic ${base64Credentials}`,
|
|
48
|
+
* "DwC-Tenant": tenant
|
|
49
|
+
* };
|
|
50
|
+
*
|
|
51
|
+
* const srv = await service.odata.init(url, user, password, true, params, "headers", authHeaders);
|
|
38
52
|
*/
|
|
39
|
-
init(url: string, username: string, password: string, loggingEnabled?: boolean, params?: {}, authType?: string): Promise<any>;
|
|
53
|
+
init(url: string, username: string, password: string, loggingEnabled?: boolean, params?: {}, authType?: string, headers?: any): Promise<any>;
|
|
40
54
|
/**
|
|
41
55
|
* @function get
|
|
42
56
|
* @memberOf service.odata
|
|
43
|
-
* @description
|
|
44
|
-
* @param {Object} srv -
|
|
45
|
-
* @param {String} entitySet - The
|
|
46
|
-
* @param {Object} keys - The required keys for the GET
|
|
47
|
-
* @param {Boolean} raw -
|
|
57
|
+
* @description Sends a GET request to retrieve data from the specified OData entity set.
|
|
58
|
+
* @param {Object} srv - An instance of the service.
|
|
59
|
+
* @param {String} entitySet - The entity set from which data is to be retrieved.
|
|
60
|
+
* @param {Object} keys - The required keys for the GET request.
|
|
61
|
+
* @param {Boolean} [raw=false] - Specifies whether the response should include all header contents.
|
|
62
|
+
* @param {Object} [headers] - Optional headers to be included in the request.
|
|
63
|
+
* @returns {Promise} A Promise that resolves to the response data.
|
|
48
64
|
* @example const url = "<baseUrl>/sap/opu/odata/sap/API_PURCHASEORDER_PROCESS_SRV/";
|
|
49
|
-
* srv = await service.odata.init(url, user, password);
|
|
65
|
+
* const srv = await service.odata.init(url, user, password);
|
|
50
66
|
* const keys = {
|
|
51
67
|
* PurchaseOrder: "4100000000"
|
|
52
68
|
* };
|
|
53
69
|
* const res = await service.odata.get(srv, "A_PurchaseOrder", keys);
|
|
54
70
|
*/
|
|
55
|
-
get(srv: any, entitySet: string, keys: any, raw?: boolean): Promise<any>;
|
|
71
|
+
get(srv: any, entitySet: string, keys: any, raw?: boolean, headers?: IHeaders): Promise<any>;
|
|
56
72
|
/**
|
|
57
73
|
* @function getEntitySet
|
|
58
74
|
* @memberOf service.odata
|
|
@@ -62,7 +78,7 @@ export declare class OData {
|
|
|
62
78
|
* @param {String} [filterString] - The filters to be applied on get query
|
|
63
79
|
* @param {String} [selectionFields] - comma separated list of fields to be selected
|
|
64
80
|
* @param {Object} [queryParams] - JSON object of key value pairs of custom query parameters.
|
|
65
|
-
* @returns {
|
|
81
|
+
* @returns {Promise} A Promise that resolves to the response data.
|
|
66
82
|
* @example
|
|
67
83
|
* const url = "<baseUrl>/sap/opu/odata/sap/API_PURCHASEORDER_PROCESS_SRV/";
|
|
68
84
|
* srv = await service.odata.init(url, user, password);
|
|
@@ -80,73 +96,69 @@ export declare class OData {
|
|
|
80
96
|
* let res = await service.odata.getEntitySet(srv, "A_PurchaseOrder", filterString, select, queryParams);
|
|
81
97
|
*/
|
|
82
98
|
getEntitySet(srv: any, entitySet: string, filterString?: string, selectionFields?: string, queryParams?: any): Promise<any>;
|
|
83
|
-
/**
|
|
84
|
-
* @function isFeatureToggleActivated
|
|
85
|
-
* @memberOf service.odata
|
|
86
|
-
* @description checks if a feature toggle is switched on or off
|
|
87
|
-
* @param {Object} srv - Instance of the service
|
|
88
|
-
* @param {String} featureName - The name of the feature you want know the status of.
|
|
89
|
-
* @example const url = browser.params.systemUrl + "/sap/opu/odata/SAP/CA_FM_FEATURE_TOGGLE_STATUS_SRV/";
|
|
90
|
-
* const srv = await service.odata.init(url, user, password);
|
|
91
|
-
* let isFeatureActive = await service.odata.isFeatureToggleActivated(srv, "MM_PUR_PO_BATCHES_IN_MANAGE_PO");
|
|
92
|
-
*/
|
|
93
|
-
isFeatureToggleActivated(srv: any, featureName: string): Promise<boolean>;
|
|
94
99
|
/**
|
|
95
100
|
* @function post
|
|
96
101
|
* @memberOf service.odata
|
|
97
|
-
* @description
|
|
102
|
+
* @description Sends a POST request to retrieve data from the specified OData entity set for the given payload.
|
|
98
103
|
* @param {Object} srv - Instance of the service
|
|
99
104
|
* @param {String} entitySet - The entitySet you want to POST against.
|
|
100
|
-
* @param {Object} payload - The payload
|
|
101
|
-
* @param {Boolean} raw -
|
|
105
|
+
* @param {Object} payload - The payload of the POST request.
|
|
106
|
+
* @param {Boolean} [raw=false] - Specifies whether the response should include all header contents.
|
|
107
|
+
* @param {Object} [headers] - Optional headers to be included in the request.
|
|
108
|
+
* @returns {Promise} A Promise that resolves to the response data.
|
|
102
109
|
* @example
|
|
103
|
-
*
|
|
110
|
+
* const payload = {
|
|
104
111
|
* "PurchaseOrder": "4500007108",
|
|
105
112
|
* "DraftUUID": "00000000-0000-0000-0000-000000000000",
|
|
106
113
|
* "IsActiveEntity": "true"
|
|
107
114
|
* };
|
|
108
|
-
*
|
|
115
|
+
* const res = await service.odata.post(srv, "A_PurchaseOrder", payload);
|
|
109
116
|
*/
|
|
110
|
-
post(srv: any, entitySet: string, payload: any, raw?: boolean): Promise<any>;
|
|
117
|
+
post(srv: any, entitySet: string, payload: any, raw?: boolean, headers?: IHeaders): Promise<any>;
|
|
111
118
|
/**
|
|
112
119
|
* @function merge
|
|
113
120
|
* @memberOf service.odata
|
|
114
|
-
* @description
|
|
121
|
+
* @description @description Sends a MERGE request to merge data from the specified OData entity set for the given payload.
|
|
115
122
|
* @param {Object} srv - Instance of the service
|
|
116
123
|
* @param {String} entitySet - The entitySet you want to MERGE in.
|
|
117
|
-
* @param {Object} payload - The payload
|
|
124
|
+
* @param {Object} payload - The payload of the MERGE request.
|
|
125
|
+
* @param {Object} [headers] - Optional headers to be included in the request.
|
|
126
|
+
* @returns {Promise} A Promise that resolves to the response data.
|
|
118
127
|
* @example
|
|
119
|
-
*
|
|
128
|
+
* const res = await service.odata.merge(srv, "A_PurchaseOrderScheduleLine", {
|
|
120
129
|
* "PurchasingDocument": "4500007108",
|
|
121
130
|
* "PurchasingDocumentItem": "10",
|
|
122
131
|
* "ScheduleLine": "1",
|
|
123
132
|
* "ScheduleLineDeliveryDate": new Date()
|
|
124
133
|
* };
|
|
125
134
|
*/
|
|
126
|
-
merge(srv: any, entitySet: string, payload: any): Promise<any>;
|
|
135
|
+
merge(srv: any, entitySet: string, payload: any, headers?: IHeaders): Promise<any>;
|
|
127
136
|
/**
|
|
128
137
|
* @function delete
|
|
129
138
|
* @memberOf service.odata
|
|
130
|
-
* @description
|
|
131
|
-
* @param {Object} srv - Instance of the service
|
|
139
|
+
* @description Sends a DELETE request to the specified OData entity set.
|
|
140
|
+
* @param {Object} srv - Instance of the service.
|
|
132
141
|
* @param {String} entitySet - The entitySet you want to DELETE.
|
|
133
|
-
* @param {Object} options - The options for the DELETE
|
|
142
|
+
* @param {Object} options - The options for the DELETE request.
|
|
143
|
+
* @param {Object} [headers] - Optional headers to be included in the request.
|
|
144
|
+
* @returns {Promise} A Promise that resolves to the response data.
|
|
134
145
|
* @example
|
|
135
|
-
*
|
|
146
|
+
* const options = {
|
|
136
147
|
* "PurchaseOrder": "",
|
|
137
148
|
* "DraftUUID": draftUUID,
|
|
138
149
|
* "IsActiveEntity": false
|
|
139
150
|
* };
|
|
140
|
-
* await service.odata.delete(srv, "C_PurchaseOrderTP", options);
|
|
151
|
+
* const res = await service.odata.delete(srv, "C_PurchaseOrderTP", options);
|
|
141
152
|
*/
|
|
142
|
-
delete(srv: any, entitySet: string, options: any): Promise<any>;
|
|
153
|
+
delete(srv: any, entitySet: string, options: any, headers?: IHeaders): Promise<any>;
|
|
143
154
|
/**
|
|
144
155
|
* @function callFunctionImport
|
|
145
156
|
* @memberOf service.odata
|
|
146
|
-
* @description
|
|
147
|
-
* @param {Object} srv - Instance of the service
|
|
148
|
-
* @param {String} functionImportName - Name of Function Import
|
|
149
|
-
* @param {Object} options -
|
|
157
|
+
* @description Sends a function import request to the OData service instance.
|
|
158
|
+
* @param {Object} srv - Instance of the service.
|
|
159
|
+
* @param {String} functionImportName - Name of Function Import.
|
|
160
|
+
* @param {Object} options - Parameters for function import.
|
|
161
|
+
* @returns {Promise} A Promise that resolves to the response data.
|
|
150
162
|
* @example
|
|
151
163
|
* const options = {
|
|
152
164
|
* CentralRequestForQuotation : "7500000026",
|
|
@@ -155,6 +167,18 @@ export declare class OData {
|
|
|
155
167
|
* const res = await service.odata.callFunctionImport(srv, "Cancel", options);
|
|
156
168
|
*/
|
|
157
169
|
callFunctionImport(srv: any, functionImportName: string, options: any): Promise<any>;
|
|
170
|
+
/**
|
|
171
|
+
* @function isFeatureToggleActivated
|
|
172
|
+
* @memberOf service.odata
|
|
173
|
+
* @description Checks if a feature toggle is switched on or off.
|
|
174
|
+
* @param {Object} srv - Instance of the service
|
|
175
|
+
* @param {String} featureName - The name of the feature you want know the status of.
|
|
176
|
+
* @returns {Promise} A Promise that resolves to a bool value.
|
|
177
|
+
* @example const url = browser.params.systemUrl + "/sap/opu/odata/SAP/CA_FM_FEATURE_TOGGLE_STATUS_SRV/";
|
|
178
|
+
* const srv = await service.odata.init(url, user, password);
|
|
179
|
+
* let isFeatureActive = await service.odata.isFeatureToggleActivated(srv, "MM_PUR_PO_BATCHES_IN_MANAGE_PO");
|
|
180
|
+
*/
|
|
181
|
+
isFeatureToggleActivated(srv: any, featureName: string): Promise<boolean>;
|
|
158
182
|
/**
|
|
159
183
|
* @function getOutputManagementPdfStream
|
|
160
184
|
* @memberOf service.odata
|
|
@@ -186,6 +210,8 @@ export declare class OData {
|
|
|
186
210
|
*/
|
|
187
211
|
readPdfFromDirectUrl(url: string, username: string, password: string, isSaml?: boolean): Promise<any>;
|
|
188
212
|
_doRequest(url: string, username: string, password: string, isSaml: boolean): Promise<any>;
|
|
213
|
+
_applyHeaders(entity: any, headers: IHeaders): any;
|
|
214
|
+
_applyQueryParameters(entity: any, params: IParams): any;
|
|
189
215
|
}
|
|
190
216
|
declare const _default: OData;
|
|
191
217
|
export default _default;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OData = void 0;
|
|
4
|
+
// =================================== CONSTANTS ================================
|
|
5
|
+
const SERVICE_INIT_ERROR = "Service instance not found. Make sure the service is initialized and passed to the request.";
|
|
6
|
+
const entitySetError = (entitySet) => `Entity Set "${entitySet}" not found in service.`;
|
|
7
|
+
// =================================== MAIN =====================================
|
|
4
8
|
/**
|
|
5
9
|
* @class odata
|
|
6
10
|
* @memberof service
|
|
@@ -20,32 +24,40 @@ class OData {
|
|
|
20
24
|
/**
|
|
21
25
|
* @function init
|
|
22
26
|
* @memberOf service.odata
|
|
23
|
-
* @description Initializes
|
|
27
|
+
* @description Initializes the OData Service.
|
|
24
28
|
* XCSRF-Token will be automatically fetched and stored in the service instance.
|
|
25
29
|
* Cookies will also automatically assembled and stored in the service instance.
|
|
26
|
-
* @param {String} url - The base url of the service
|
|
27
|
-
* @param {String} username - The username.
|
|
30
|
+
* @param {String} url - The base url of the service.
|
|
31
|
+
* @param {String} username - The username to authenticate the service.
|
|
28
32
|
* @param {String} password - The password of the username.
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {Object} [params={}] - JSON object with key-value pairs of parameter names and corresponding values
|
|
31
|
-
*
|
|
33
|
+
* @param {Boolean} [loggingEnabled=false] - The boolean param to control whether user wants to see logs during build run.
|
|
34
|
+
* @param {Object} [params={}] - JSON object with key-value pairs of parameter names and corresponding values.
|
|
35
|
+
* By default we send {
|
|
32
36
|
* "client": "715",
|
|
33
37
|
* "documentation": ["heading", "quickinfo"],
|
|
34
38
|
* "language": "EN"
|
|
35
39
|
* }
|
|
36
|
-
* These can be overridden by sending params as JSON object with additional params as shown in example
|
|
40
|
+
* These can be overridden by sending params as JSON object with additional params as shown in example.
|
|
37
41
|
* @param {String} [authType] - authentication type, in case you want to override the default
|
|
38
42
|
* SAML authentication. Set this to "basic", to use basic authentication for communication users for whom SAML login doesn't work.
|
|
39
43
|
* Or "none" for no authentication.
|
|
44
|
+
* @param {Object} [headers=undefined] - JSON object with key-value pairs of optional headers.
|
|
40
45
|
* @returns {Object} The initialized service object.
|
|
41
46
|
* @example const url = "<urlToSystem>/sap/opu/odata/sap/API_PURCHASEORDER_PROCESS_SRV/";
|
|
42
47
|
* const params = {
|
|
43
48
|
* "saml2": "disabled",
|
|
44
49
|
* "language": "de"
|
|
45
50
|
* }
|
|
46
|
-
* srv = await service.odata.init(url, user, password, false, params);
|
|
51
|
+
* const srv = await service.odata.init(url, user, password, false, params);
|
|
52
|
+
* @example const base64Credentials = Buffer.from(`${user}:${password}`).toString("base64");
|
|
53
|
+
* const authHeaders = {
|
|
54
|
+
* "Authorization": `Basic ${base64Credentials}`,
|
|
55
|
+
* "DwC-Tenant": tenant
|
|
56
|
+
* };
|
|
57
|
+
*
|
|
58
|
+
* const srv = await service.odata.init(url, user, password, true, params, "headers", authHeaders);
|
|
47
59
|
*/
|
|
48
|
-
async init(url, username, password, loggingEnabled = false, params = {}, authType = "") {
|
|
60
|
+
async init(url, username, password, loggingEnabled = false, params = {}, authType = "", headers) {
|
|
49
61
|
const logger = {
|
|
50
62
|
trace: () => { },
|
|
51
63
|
debug: console.debug,
|
|
@@ -54,26 +66,25 @@ class OData {
|
|
|
54
66
|
error: console.error
|
|
55
67
|
};
|
|
56
68
|
const parameters = {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
69
|
+
...params,
|
|
70
|
+
...{
|
|
71
|
+
"sap-client": "715",
|
|
72
|
+
"sap-documentation": ["heading", "quickinfo"],
|
|
73
|
+
"sap-language": "EN"
|
|
74
|
+
}
|
|
60
75
|
};
|
|
61
|
-
if (params) {
|
|
62
|
-
// @ts-ignore
|
|
63
|
-
Object.keys(params).forEach((key) => (parameters[key] = params[key]));
|
|
64
|
-
}
|
|
65
76
|
const auth = {
|
|
66
|
-
|
|
67
|
-
|
|
77
|
+
type: authType ?? "",
|
|
78
|
+
username,
|
|
79
|
+
password
|
|
68
80
|
};
|
|
69
|
-
if (
|
|
70
|
-
auth
|
|
71
|
-
}
|
|
81
|
+
if (headers && Object.entries(headers).length > 0)
|
|
82
|
+
auth.headers = headers;
|
|
72
83
|
const srv = new this.Service({
|
|
73
84
|
logger: loggingEnabled ? logger : "",
|
|
74
|
-
url
|
|
75
|
-
auth
|
|
76
|
-
parameters
|
|
85
|
+
url,
|
|
86
|
+
auth,
|
|
87
|
+
parameters, // Define initial request by $metadata?sap-client=<client-number>&sap-documentation=&sap-language=EN
|
|
77
88
|
strict: false // ignore non critical errors, e.g. orphaned annotations
|
|
78
89
|
});
|
|
79
90
|
await srv.init;
|
|
@@ -82,31 +93,37 @@ class OData {
|
|
|
82
93
|
/**
|
|
83
94
|
* @function get
|
|
84
95
|
* @memberOf service.odata
|
|
85
|
-
* @description
|
|
86
|
-
* @param {Object} srv -
|
|
87
|
-
* @param {String} entitySet - The
|
|
88
|
-
* @param {Object} keys - The required keys for the GET
|
|
89
|
-
* @param {Boolean} raw -
|
|
96
|
+
* @description Sends a GET request to retrieve data from the specified OData entity set.
|
|
97
|
+
* @param {Object} srv - An instance of the service.
|
|
98
|
+
* @param {String} entitySet - The entity set from which data is to be retrieved.
|
|
99
|
+
* @param {Object} keys - The required keys for the GET request.
|
|
100
|
+
* @param {Boolean} [raw=false] - Specifies whether the response should include all header contents.
|
|
101
|
+
* @param {Object} [headers] - Optional headers to be included in the request.
|
|
102
|
+
* @returns {Promise} A Promise that resolves to the response data.
|
|
90
103
|
* @example const url = "<baseUrl>/sap/opu/odata/sap/API_PURCHASEORDER_PROCESS_SRV/";
|
|
91
|
-
* srv = await service.odata.init(url, user, password);
|
|
104
|
+
* const srv = await service.odata.init(url, user, password);
|
|
92
105
|
* const keys = {
|
|
93
106
|
* PurchaseOrder: "4100000000"
|
|
94
107
|
* };
|
|
95
108
|
* const res = await service.odata.get(srv, "A_PurchaseOrder", keys);
|
|
96
109
|
*/
|
|
97
|
-
async get(srv, entitySet, keys, raw = false) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
110
|
+
async get(srv, entitySet, keys, raw = false, headers) {
|
|
111
|
+
if (!srv)
|
|
112
|
+
throw new Error(SERVICE_INIT_ERROR);
|
|
113
|
+
let entity = srv[entitySet];
|
|
114
|
+
if (!entity)
|
|
115
|
+
throw new Error(entitySetError(entitySet));
|
|
116
|
+
if (headers)
|
|
117
|
+
entity = this._applyHeaders(entity, headers);
|
|
118
|
+
if (raw)
|
|
119
|
+
entity = entity.raw();
|
|
120
|
+
if (keys && Object.entries(keys).length > 0) {
|
|
121
|
+
return entity.get(keys);
|
|
104
122
|
}
|
|
105
123
|
else {
|
|
106
|
-
return entity.get(
|
|
124
|
+
return entity.get();
|
|
107
125
|
}
|
|
108
126
|
}
|
|
109
|
-
;
|
|
110
127
|
/**
|
|
111
128
|
* @function getEntitySet
|
|
112
129
|
* @memberOf service.odata
|
|
@@ -116,7 +133,7 @@ class OData {
|
|
|
116
133
|
* @param {String} [filterString] - The filters to be applied on get query
|
|
117
134
|
* @param {String} [selectionFields] - comma separated list of fields to be selected
|
|
118
135
|
* @param {Object} [queryParams] - JSON object of key value pairs of custom query parameters.
|
|
119
|
-
* @returns {
|
|
136
|
+
* @returns {Promise} A Promise that resolves to the response data.
|
|
120
137
|
* @example
|
|
121
138
|
* const url = "<baseUrl>/sap/opu/odata/sap/API_PURCHASEORDER_PROCESS_SRV/";
|
|
122
139
|
* srv = await service.odata.init(url, user, password);
|
|
@@ -133,136 +150,112 @@ class OData {
|
|
|
133
150
|
* };
|
|
134
151
|
* let res = await service.odata.getEntitySet(srv, "A_PurchaseOrder", filterString, select, queryParams);
|
|
135
152
|
*/
|
|
136
|
-
async getEntitySet(srv, entitySet, filterString = "", selectionFields = "", queryParams
|
|
137
|
-
if (!srv)
|
|
138
|
-
throw new Error(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
entity = entity.select(selectionFields.split(","));
|
|
150
|
-
}
|
|
151
|
-
if (queryParams) {
|
|
152
|
-
Object.keys(queryParams).forEach((key) => {
|
|
153
|
-
entity = entity.queryParameter(key, queryParams[key]);
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
const res = entity.get();
|
|
157
|
-
return res;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* @function isFeatureToggleActivated
|
|
162
|
-
* @memberOf service.odata
|
|
163
|
-
* @description checks if a feature toggle is switched on or off
|
|
164
|
-
* @param {Object} srv - Instance of the service
|
|
165
|
-
* @param {String} featureName - The name of the feature you want know the status of.
|
|
166
|
-
* @example const url = browser.params.systemUrl + "/sap/opu/odata/SAP/CA_FM_FEATURE_TOGGLE_STATUS_SRV/";
|
|
167
|
-
* const srv = await service.odata.init(url, user, password);
|
|
168
|
-
* let isFeatureActive = await service.odata.isFeatureToggleActivated(srv, "MM_PUR_PO_BATCHES_IN_MANAGE_PO");
|
|
169
|
-
*/
|
|
170
|
-
async isFeatureToggleActivated(srv, featureName) {
|
|
171
|
-
const res = await this.getEntitySet(srv, "ToggleStatusSet");
|
|
172
|
-
for (const featureEntity of Object.values(res)) {
|
|
173
|
-
// @ts-ignore
|
|
174
|
-
if (featureEntity.Featureid === featureName) {
|
|
175
|
-
//feature toggle is disabled if found
|
|
176
|
-
util.console.info(`Feature Toggle "${featureName}" is disabled.`);
|
|
177
|
-
return false;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
//feature toggle is enabled if NOT found
|
|
181
|
-
util.console.info(`Feature Toggle "${featureName}" is enabled.`);
|
|
182
|
-
return true;
|
|
153
|
+
async getEntitySet(srv, entitySet, filterString = "", selectionFields = "", queryParams) {
|
|
154
|
+
if (!srv)
|
|
155
|
+
throw new Error(SERVICE_INIT_ERROR);
|
|
156
|
+
let entity = srv[entitySet];
|
|
157
|
+
if (!entity)
|
|
158
|
+
throw new Error(entitySetError(entitySet));
|
|
159
|
+
if (filterString)
|
|
160
|
+
entity = entity.filter(filterString);
|
|
161
|
+
if (selectionFields)
|
|
162
|
+
entity = entity.select(selectionFields.split(","));
|
|
163
|
+
if (queryParams)
|
|
164
|
+
entity = this._applyQueryParameters(entity, queryParams);
|
|
165
|
+
return entity.get();
|
|
183
166
|
}
|
|
184
167
|
/**
|
|
185
168
|
* @function post
|
|
186
169
|
* @memberOf service.odata
|
|
187
|
-
* @description
|
|
170
|
+
* @description Sends a POST request to retrieve data from the specified OData entity set for the given payload.
|
|
188
171
|
* @param {Object} srv - Instance of the service
|
|
189
172
|
* @param {String} entitySet - The entitySet you want to POST against.
|
|
190
|
-
* @param {Object} payload - The payload
|
|
191
|
-
* @param {Boolean} raw -
|
|
173
|
+
* @param {Object} payload - The payload of the POST request.
|
|
174
|
+
* @param {Boolean} [raw=false] - Specifies whether the response should include all header contents.
|
|
175
|
+
* @param {Object} [headers] - Optional headers to be included in the request.
|
|
176
|
+
* @returns {Promise} A Promise that resolves to the response data.
|
|
192
177
|
* @example
|
|
193
|
-
*
|
|
178
|
+
* const payload = {
|
|
194
179
|
* "PurchaseOrder": "4500007108",
|
|
195
180
|
* "DraftUUID": "00000000-0000-0000-0000-000000000000",
|
|
196
181
|
* "IsActiveEntity": "true"
|
|
197
182
|
* };
|
|
198
|
-
*
|
|
183
|
+
* const res = await service.odata.post(srv, "A_PurchaseOrder", payload);
|
|
199
184
|
*/
|
|
200
|
-
async post(srv, entitySet, payload, raw = false) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
185
|
+
async post(srv, entitySet, payload, raw = false, headers) {
|
|
186
|
+
if (!srv)
|
|
187
|
+
throw new Error(SERVICE_INIT_ERROR);
|
|
188
|
+
let entity = srv[entitySet];
|
|
189
|
+
if (!entity)
|
|
190
|
+
throw new Error(entitySetError(entitySet));
|
|
191
|
+
if (headers)
|
|
192
|
+
entity = this._applyHeaders(entity, headers);
|
|
193
|
+
if (raw)
|
|
194
|
+
entity = entity.raw();
|
|
195
|
+
return entity.post(payload);
|
|
211
196
|
}
|
|
212
|
-
;
|
|
213
197
|
/**
|
|
214
198
|
* @function merge
|
|
215
199
|
* @memberOf service.odata
|
|
216
|
-
* @description
|
|
200
|
+
* @description @description Sends a MERGE request to merge data from the specified OData entity set for the given payload.
|
|
217
201
|
* @param {Object} srv - Instance of the service
|
|
218
202
|
* @param {String} entitySet - The entitySet you want to MERGE in.
|
|
219
|
-
* @param {Object} payload - The payload
|
|
203
|
+
* @param {Object} payload - The payload of the MERGE request.
|
|
204
|
+
* @param {Object} [headers] - Optional headers to be included in the request.
|
|
205
|
+
* @returns {Promise} A Promise that resolves to the response data.
|
|
220
206
|
* @example
|
|
221
|
-
*
|
|
207
|
+
* const res = await service.odata.merge(srv, "A_PurchaseOrderScheduleLine", {
|
|
222
208
|
* "PurchasingDocument": "4500007108",
|
|
223
209
|
* "PurchasingDocumentItem": "10",
|
|
224
210
|
* "ScheduleLine": "1",
|
|
225
211
|
* "ScheduleLineDeliveryDate": new Date()
|
|
226
212
|
* };
|
|
227
213
|
*/
|
|
228
|
-
async merge(srv, entitySet, payload) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
214
|
+
async merge(srv, entitySet, payload, headers) {
|
|
215
|
+
if (!srv)
|
|
216
|
+
throw new Error(SERVICE_INIT_ERROR);
|
|
217
|
+
let entity = srv[entitySet];
|
|
218
|
+
if (!entity)
|
|
219
|
+
throw new Error(entitySetError(entitySet));
|
|
220
|
+
if (headers)
|
|
221
|
+
entity = this._applyHeaders(entity, headers);
|
|
222
|
+
return await entity.merge(payload);
|
|
235
223
|
}
|
|
236
224
|
/**
|
|
237
225
|
* @function delete
|
|
238
226
|
* @memberOf service.odata
|
|
239
|
-
* @description
|
|
240
|
-
* @param {Object} srv - Instance of the service
|
|
227
|
+
* @description Sends a DELETE request to the specified OData entity set.
|
|
228
|
+
* @param {Object} srv - Instance of the service.
|
|
241
229
|
* @param {String} entitySet - The entitySet you want to DELETE.
|
|
242
|
-
* @param {Object} options - The options for the DELETE
|
|
230
|
+
* @param {Object} options - The options for the DELETE request.
|
|
231
|
+
* @param {Object} [headers] - Optional headers to be included in the request.
|
|
232
|
+
* @returns {Promise} A Promise that resolves to the response data.
|
|
243
233
|
* @example
|
|
244
|
-
*
|
|
234
|
+
* const options = {
|
|
245
235
|
* "PurchaseOrder": "",
|
|
246
236
|
* "DraftUUID": draftUUID,
|
|
247
237
|
* "IsActiveEntity": false
|
|
248
238
|
* };
|
|
249
|
-
* await service.odata.delete(srv, "C_PurchaseOrderTP", options);
|
|
239
|
+
* const res = await service.odata.delete(srv, "C_PurchaseOrderTP", options);
|
|
250
240
|
*/
|
|
251
|
-
async delete(srv, entitySet, options) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
241
|
+
async delete(srv, entitySet, options, headers) {
|
|
242
|
+
if (!srv)
|
|
243
|
+
throw new Error(SERVICE_INIT_ERROR);
|
|
244
|
+
let entity = srv[entitySet];
|
|
245
|
+
if (!entity)
|
|
246
|
+
throw new Error(entitySetError(entitySet));
|
|
247
|
+
if (headers)
|
|
248
|
+
entity = this._applyHeaders(entity, headers);
|
|
249
|
+
return await entity.delete(options);
|
|
258
250
|
}
|
|
259
251
|
/**
|
|
260
252
|
* @function callFunctionImport
|
|
261
253
|
* @memberOf service.odata
|
|
262
|
-
* @description
|
|
263
|
-
* @param {Object} srv - Instance of the service
|
|
264
|
-
* @param {String} functionImportName - Name of Function Import
|
|
265
|
-
* @param {Object} options -
|
|
254
|
+
* @description Sends a function import request to the OData service instance.
|
|
255
|
+
* @param {Object} srv - Instance of the service.
|
|
256
|
+
* @param {String} functionImportName - Name of Function Import.
|
|
257
|
+
* @param {Object} options - Parameters for function import.
|
|
258
|
+
* @returns {Promise} A Promise that resolves to the response data.
|
|
266
259
|
* @example
|
|
267
260
|
* const options = {
|
|
268
261
|
* CentralRequestForQuotation : "7500000026",
|
|
@@ -271,10 +264,39 @@ class OData {
|
|
|
271
264
|
* const res = await service.odata.callFunctionImport(srv, "Cancel", options);
|
|
272
265
|
*/
|
|
273
266
|
async callFunctionImport(srv, functionImportName, options) {
|
|
267
|
+
if (!srv)
|
|
268
|
+
throw new Error(SERVICE_INIT_ERROR);
|
|
274
269
|
const functionImport = srv.functionImports[functionImportName];
|
|
275
|
-
|
|
276
|
-
return res;
|
|
270
|
+
return await functionImport.call(options);
|
|
277
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* @function isFeatureToggleActivated
|
|
274
|
+
* @memberOf service.odata
|
|
275
|
+
* @description Checks if a feature toggle is switched on or off.
|
|
276
|
+
* @param {Object} srv - Instance of the service
|
|
277
|
+
* @param {String} featureName - The name of the feature you want know the status of.
|
|
278
|
+
* @returns {Promise} A Promise that resolves to a bool value.
|
|
279
|
+
* @example const url = browser.params.systemUrl + "/sap/opu/odata/SAP/CA_FM_FEATURE_TOGGLE_STATUS_SRV/";
|
|
280
|
+
* const srv = await service.odata.init(url, user, password);
|
|
281
|
+
* let isFeatureActive = await service.odata.isFeatureToggleActivated(srv, "MM_PUR_PO_BATCHES_IN_MANAGE_PO");
|
|
282
|
+
*/
|
|
283
|
+
async isFeatureToggleActivated(srv, featureName) {
|
|
284
|
+
if (!srv)
|
|
285
|
+
throw new Error(SERVICE_INIT_ERROR);
|
|
286
|
+
const res = await this.getEntitySet(srv, "ToggleStatusSet");
|
|
287
|
+
for (const featureEntity of Object.values(res)) {
|
|
288
|
+
// @ts-ignore
|
|
289
|
+
if (featureEntity.Featureid === featureName) {
|
|
290
|
+
//feature toggle is disabled if found
|
|
291
|
+
util.console.info(`Feature Toggle "${featureName}" is disabled.`);
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
//feature toggle is enabled if NOT found
|
|
296
|
+
util.console.info(`Feature Toggle "${featureName}" is enabled.`);
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
// =================================== PDF ======================================
|
|
278
300
|
/**
|
|
279
301
|
* @function getOutputManagementPdfStream
|
|
280
302
|
* @memberOf service.odata
|
|
@@ -317,8 +339,7 @@ class OData {
|
|
|
317
339
|
if (url === undefined || url === null) {
|
|
318
340
|
throw new Error("Function 'readPdfFromDirectUrl' Failed. Please provide valid url as first parameter");
|
|
319
341
|
}
|
|
320
|
-
|
|
321
|
-
return res;
|
|
342
|
+
return await this._doRequest(url, username, password, isSaml);
|
|
322
343
|
}
|
|
323
344
|
// =================================== HELPER ===================================
|
|
324
345
|
async _doRequest(url, username, password, isSaml) {
|
|
@@ -364,6 +385,18 @@ class OData {
|
|
|
364
385
|
});
|
|
365
386
|
});
|
|
366
387
|
}
|
|
388
|
+
_applyHeaders(entity, headers) {
|
|
389
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
390
|
+
entity.header(key, value);
|
|
391
|
+
}
|
|
392
|
+
return entity;
|
|
393
|
+
}
|
|
394
|
+
_applyQueryParameters(entity, params) {
|
|
395
|
+
for (const [key, value] of Object.entries(params)) {
|
|
396
|
+
entity.queryParameter(key, value);
|
|
397
|
+
}
|
|
398
|
+
return entity;
|
|
399
|
+
}
|
|
367
400
|
}
|
|
368
401
|
exports.OData = OData;
|
|
369
402
|
exports.default = new OData();
|