@sap_oss/wdio-qmate-service 1.0.0 → 1.0.2
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/README.md +2 -1
- package/{test/core/package-lock.json → docs/bestPractices/spec.md} +0 -0
- package/docs/doc.md +176 -353
- package/docs/gettingStarted/setup.md +2 -2
- package/docs/index.md +1 -1
- package/docs/sections/bestPractices/authentication.md +151 -0
- package/docs/sections/bestPractices/dataHandling.md +61 -0
- package/docs/sections/bestPractices/selectors.md +44 -0
- package/docs/{contact.md → sections/contact.md} +0 -0
- package/docs/sections/features/advancedDataHandling.md +252 -0
- package/docs/sections/features/config.md +171 -0
- package/docs/sections/features/dataHandling.md +83 -0
- package/docs/{gettingStarted → sections/features}/selectors.md +0 -0
- package/docs/sections/features/spec.md +0 -0
- package/docs/sections/gettingStarted/config.md +18 -0
- package/docs/sections/gettingStarted/execution.md +7 -0
- package/docs/sections/gettingStarted/setup.md +9 -0
- package/docs/sections/gettingStarted/spec.md +31 -0
- package/docs/sections/gettingStarted/specs.md +19 -0
- package/docs/sections/support/bugReporting.md +19 -0
- package/docs/sections/support/knownIssuesAndLimitations.md +0 -0
- package/docs/sections/support/troubleshooting.md +16 -0
- package/docs/sources/images/fiori_form.PNG +0 -0
- package/docs/sources/images/sapCloud_form.PNG +0 -0
- package/lib/index.js +59 -82
- package/lib/index.js.map +1 -1
- package/lib/reuse/authenticator/authHandler.js +12 -23
- package/lib/reuse/authenticator/authHandler.js.map +1 -1
- package/lib/reuse/authenticator/basicUrlAuthenticator.js +21 -32
- package/lib/reuse/authenticator/basicUrlAuthenticator.js.map +1 -1
- package/lib/reuse/authenticator/customAuthenticator.js +42 -55
- package/lib/reuse/authenticator/customAuthenticator.js.map +1 -1
- package/lib/reuse/authenticator/formAuthenticator.js +37 -50
- package/lib/reuse/authenticator/formAuthenticator.js.map +1 -1
- package/lib/reuse/authenticator/plainAuthenticator.js +5 -16
- package/lib/reuse/authenticator/plainAuthenticator.js.map +1 -1
- package/lib/reuse/helper/jsDocGen.js +4 -12
- package/lib/reuse/helper/jsDocGen.js.map +1 -1
- package/lib/reuse/index.js +20 -5
- package/lib/reuse/index.js.map +1 -1
- package/lib/reuse/modules/common/navigation.js +10 -23
- package/lib/reuse/modules/common/navigation.js.map +1 -1
- package/lib/reuse/modules/common/userInteraction.js +40 -73
- package/lib/reuse/modules/common/userInteraction.js.map +1 -1
- package/lib/reuse/modules/nonUi5/assertion.js +31 -52
- package/lib/reuse/modules/nonUi5/assertion.js.map +1 -1
- package/lib/reuse/modules/nonUi5/element.js +266 -331
- package/lib/reuse/modules/nonUi5/element.js.map +1 -1
- package/lib/reuse/modules/nonUi5/navigation.js +10 -21
- package/lib/reuse/modules/nonUi5/navigation.js.map +1 -1
- package/lib/reuse/modules/nonUi5/userInteraction.js +176 -215
- package/lib/reuse/modules/nonUi5/userInteraction.js.map +1 -1
- package/lib/reuse/modules/service/odata.d.ts +106 -94
- package/lib/reuse/modules/service/odata.js +209 -204
- package/lib/reuse/modules/service/odata.js.map +1 -1
- package/lib/reuse/modules/service/rest.js +64 -81
- package/lib/reuse/modules/service/rest.js.map +1 -1
- package/lib/reuse/modules/ui5/assertion.js +217 -268
- package/lib/reuse/modules/ui5/assertion.js.map +1 -1
- package/lib/reuse/modules/ui5/confirmationDialog.js +17 -42
- package/lib/reuse/modules/ui5/confirmationDialog.js.map +1 -1
- package/lib/reuse/modules/ui5/control.js +12 -33
- package/lib/reuse/modules/ui5/control.js.map +1 -1
- package/lib/reuse/modules/ui5/date.js +70 -89
- package/lib/reuse/modules/ui5/date.js.map +1 -1
- package/lib/reuse/modules/ui5/element.js +121 -156
- package/lib/reuse/modules/ui5/element.js.map +1 -1
- package/lib/reuse/modules/ui5/errorDialog.js +4 -17
- package/lib/reuse/modules/ui5/errorDialog.js.map +1 -1
- package/lib/reuse/modules/ui5/footerBar.js +28 -63
- package/lib/reuse/modules/ui5/footerBar.js.map +1 -1
- package/lib/reuse/modules/ui5/mockserver.js +390 -427
- package/lib/reuse/modules/ui5/mockserver.js.map +1 -1
- package/lib/reuse/modules/ui5/navigation.js +105 -132
- package/lib/reuse/modules/ui5/navigation.js.map +1 -1
- package/lib/reuse/modules/ui5/navigationBar.js +58 -77
- package/lib/reuse/modules/ui5/navigationBar.js.map +1 -1
- package/lib/reuse/modules/ui5/qunit.js +16 -27
- package/lib/reuse/modules/ui5/qunit.js.map +1 -1
- package/lib/reuse/modules/ui5/session.js +200 -236
- package/lib/reuse/modules/ui5/session.js.map +1 -1
- package/lib/reuse/modules/ui5/table.js +79 -98
- package/lib/reuse/modules/ui5/table.js.map +1 -1
- package/lib/reuse/modules/ui5/userInteraction.js +264 -335
- package/lib/reuse/modules/ui5/userInteraction.js.map +1 -1
- package/lib/reuse/modules/util/browser.js +131 -178
- package/lib/reuse/modules/util/browser.js.map +1 -1
- package/lib/reuse/modules/util/data.js +3 -2
- package/lib/reuse/modules/util/data.js.map +1 -1
- package/lib/reuse/modules/util/file.js +71 -90
- package/lib/reuse/modules/util/file.js.map +1 -1
- package/lib/reuse/modules/util/function.js +68 -87
- package/lib/reuse/modules/util/function.js.map +1 -1
- package/lib/reuse/modules/util/system.js +22 -33
- package/lib/reuse/modules/util/system.js.map +1 -1
- package/lib/scripts/dataExchange/dataExchange.js +145 -160
- package/lib/scripts/dataExchange/dataExchange.js.map +1 -1
- package/lib/scripts/dataExchange/dataExchangeUtil.js +93 -114
- package/lib/scripts/dataExchange/dataExchangeUtil.js.map +1 -1
- package/lib/scripts/hooks/after.js +3 -14
- package/lib/scripts/hooks/after.js.map +1 -1
- package/lib/scripts/hooks/before.js +9 -20
- package/lib/scripts/hooks/before.js.map +1 -1
- package/lib/scripts/hooks/beforeSession.js +7 -18
- package/lib/scripts/hooks/beforeSession.js.map +1 -1
- package/lib/scripts/hooks/onComplete.js +2 -13
- package/lib/scripts/hooks/onComplete.js.map +1 -1
- package/lib/scripts/hooks/onPrepare.js +9 -20
- package/lib/scripts/hooks/onPrepare.js.map +1 -1
- package/lib/scripts/hooks/utils/addLocatorCommands.js +109 -172
- package/lib/scripts/hooks/utils/addLocatorCommands.js.map +1 -1
- package/lib/scripts/hooks/utils/browserLog.js +18 -31
- package/lib/scripts/hooks/utils/browserLog.js.map +1 -1
- package/lib/scripts/hooks/utils/dataExchangeCommands.js +13 -24
- package/lib/scripts/hooks/utils/dataExchangeCommands.js.map +1 -1
- package/lib/scripts/hooks/utils/decryption.d.ts +1 -1
- package/lib/scripts/hooks/utils/decryption.js +33 -14
- package/lib/scripts/hooks/utils/decryption.js.map +1 -1
- package/lib/scripts/hooks/utils/lib.js +249 -272
- package/lib/scripts/hooks/utils/lib.js.map +1 -1
- package/lib/scripts/hooks/utils/locatorCommands.js +154 -183
- package/lib/scripts/hooks/utils/locatorCommands.js.map +1 -1
- package/mkdocs.yml +16 -3
- package/package.json +14 -11
- package/test/authenticator/staticLogin/specs/custom.spec.js +30 -1
- package/test/reuse/nonUi5/element/getById.spec.js +17 -0
- package/test/reuse/service/odata/get.spec.js +61 -0
- package/test/reuse/service/odata/getEntitySet.spec.js +87 -0
- package/test/reuse/service/odata/test.odata.conf.js +15 -0
- package/test/reuse/ui5/confirmationDialog/clickButton.spec.js +87 -0
- package/test/reuse/ui5/confirmationDialog/test.confirmationDialog.conf.js +2 -1
- package/test/reuse/ui5/element/test.element.conf.js +2 -1
- package/test/reuse/ui5/element/waitForAll.spec.js +46 -0
- package/test/reuse/ui5/userInteraction/clearAndFillSmartFieldInputAndRetry.spec.js +28 -0
- package/test/reuse/ui5/userInteraction/test.userInteraction.conf.js +1 -0
- package/test/reuse/util/browser/switchToNewWindow.spec.js +2 -2
- package/test/reuse/util/console/console.spec.js +27 -0
- package/test/reuse/util/console/test.console.conf.js +12 -0
- package/test/reuse/util/data/data/test.secure.json +7 -3
- package/test/reuse/util/data/getSecureData.spec.js +9 -3
- package/test/reuse/util/file/pdfParser.spec.js +33 -8
- package/test/reuse/util/system/system.spec.js +16 -0
- package/test/reuse/util/system/test.system.conf.js +12 -0
- package/tsconfig.json +1 -1
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.OData = void 0;
|
|
13
4
|
/**
|
|
@@ -32,9 +23,9 @@ class OData {
|
|
|
32
23
|
* @description Initializes The service to work with.
|
|
33
24
|
* XCSRF-Token will be automatically fetched and stored in the service instance.
|
|
34
25
|
* Cookies will also automatically assembled and stored in the service instance.
|
|
35
|
-
* @param {
|
|
36
|
-
* @param {
|
|
37
|
-
* @param {
|
|
26
|
+
* @param {String} url - The base url of the service
|
|
27
|
+
* @param {String} username - The username.
|
|
28
|
+
* @param {String} password - The password of the username.
|
|
38
29
|
* @param {boolean} [loggingEnabled=false] - The boolean param to control whether user wants to see logs during build run
|
|
39
30
|
* @param {Object} [params={}] - JSON object with key-value pairs of parameter names and corresponding values
|
|
40
31
|
* by default we send {
|
|
@@ -43,6 +34,9 @@ class OData {
|
|
|
43
34
|
* "language": "EN"
|
|
44
35
|
* }
|
|
45
36
|
* These can be overridden by sending params as JSON object with additional params as shown in example
|
|
37
|
+
* @param {String} [authType] - authentication type, in case you want to override the default
|
|
38
|
+
* SAML authentication. Set this to "basic", to use basic authentication for communication users for whom SAML login doesn't work.
|
|
39
|
+
* Or "none" for no authentication.
|
|
46
40
|
* @returns {Object} The initialized service object.
|
|
47
41
|
* @example const url = "https://hbr-715.wdf.sap.corp/sap/opu/odata/sap/API_PURCHASEORDER_PROCESS_SRV/";
|
|
48
42
|
* const params = {
|
|
@@ -51,264 +45,275 @@ class OData {
|
|
|
51
45
|
* }
|
|
52
46
|
* srv = await service.odata.init(url, user, password, false, params);
|
|
53
47
|
*/
|
|
54
|
-
init(url, username, password, loggingEnabled = false, params = {}) {
|
|
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
|
-
|
|
48
|
+
async init(url, username, password, loggingEnabled = false, params = {}, authType = "") {
|
|
49
|
+
const logger = {
|
|
50
|
+
"trace": () => { },
|
|
51
|
+
"debug": console.debug,
|
|
52
|
+
"info": console.info,
|
|
53
|
+
"warn": console.warn,
|
|
54
|
+
"error": console.error
|
|
55
|
+
};
|
|
56
|
+
const parameters = {
|
|
57
|
+
"client": "715",
|
|
58
|
+
"documentation": ["heading", "quickinfo"],
|
|
59
|
+
"language": "EN"
|
|
60
|
+
};
|
|
61
|
+
if (params) {
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
Object.keys(params).forEach((key) => parameters[key] = params[key]);
|
|
64
|
+
}
|
|
65
|
+
const auth = {
|
|
66
|
+
"username": username,
|
|
67
|
+
"password": password
|
|
68
|
+
};
|
|
69
|
+
if (authType) {
|
|
70
|
+
auth["type"] = authType;
|
|
71
|
+
}
|
|
72
|
+
const srv = new this.Service({
|
|
73
|
+
"logger": loggingEnabled ? logger : "",
|
|
74
|
+
"url": url,
|
|
75
|
+
"auth": auth,
|
|
76
|
+
"parameters": parameters,
|
|
77
|
+
"strict": false // ignore non critical errors, e.g. orphaned annotations
|
|
84
78
|
});
|
|
79
|
+
await srv.init;
|
|
80
|
+
return srv;
|
|
85
81
|
}
|
|
86
82
|
;
|
|
87
83
|
/**
|
|
88
84
|
* @function get
|
|
89
85
|
* @memberOf service.odata
|
|
90
86
|
* @description makes a GET request.
|
|
91
|
-
* @param {
|
|
92
|
-
* @param {
|
|
93
|
-
* @param {
|
|
87
|
+
* @param {Object} srv - Instance of the service
|
|
88
|
+
* @param {String} entitySet - The entitySet you want to GET from.
|
|
89
|
+
* @param {Object} keys - The required keys for the GET-request.
|
|
94
90
|
* @example const url = "https://qs9-715.wdf.sap.corp/sap/opu/odata/sap/API_PURCHASEORDER_PROCESS_SRV/";
|
|
95
91
|
* srv = await service.odata.init(url, user, password);
|
|
92
|
+
* const keys = {
|
|
93
|
+
* PurchaseOrder: "4100000000"
|
|
94
|
+
* };
|
|
95
|
+
* const res = await service.odata.get(srv, "A_PurchaseOrder", keys);
|
|
96
96
|
*/
|
|
97
|
-
get(srv, entitySet,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
async get(srv, entitySet, keys) {
|
|
98
|
+
const entity = srv[entitySet];
|
|
99
|
+
if (!entity) {
|
|
100
|
+
throw new Error(`No entity set '${entitySet}' available in service`);
|
|
101
|
+
}
|
|
102
|
+
return entity.get(keys);
|
|
101
103
|
}
|
|
102
104
|
;
|
|
103
105
|
/**
|
|
104
106
|
* @function getEntitySet
|
|
105
107
|
* @memberOf service.odata
|
|
106
108
|
* @description GET's the EntitySet collection.
|
|
107
|
-
* @param {
|
|
108
|
-
* @param {
|
|
109
|
+
* @param {Object} srv - Instance of the service
|
|
110
|
+
* @param {String} entitySet - The entitySet you want to GET from.
|
|
109
111
|
* @param {String} [filterString] - The filters to be applied on get query
|
|
110
112
|
* @param {String} [selectionFields] - comma separated list of fields to be selected
|
|
111
113
|
* @param {Object} [queryParams] - JSON object of key value pairs of custom query parameters.
|
|
112
114
|
* @returns {Array} - Result set array
|
|
113
|
-
* @example
|
|
115
|
+
* @example
|
|
116
|
+
* const url = "https://qs9-715.wdf.sap.corp/sap/opu/odata/sap/API_PURCHASEORDER_PROCESS_SRV/";
|
|
114
117
|
* srv = await service.odata.init(url, user, password);
|
|
115
118
|
*
|
|
116
119
|
* let filterString = "Status eq '01'";
|
|
117
|
-
* let res = await service.odata.getEntitySet(
|
|
120
|
+
* let res = await service.odata.getEntitySet(srv, "A_PurchaseOrder", filterString);
|
|
118
121
|
*
|
|
119
122
|
* let select = "CentralPurchaseContract,PurchasingProcessingStatus" ;
|
|
120
|
-
* let res = await service.odata.getEntitySet(
|
|
123
|
+
* let res = await service.odata.getEntitySet(srv, "A_PurchaseOrder", filterString, select);
|
|
121
124
|
*
|
|
122
125
|
* let queryParams = {
|
|
123
|
-
*
|
|
124
|
-
*
|
|
126
|
+
* "$top" : 5,
|
|
127
|
+
* "$skip" : 10,
|
|
125
128
|
* };
|
|
126
|
-
* let res = await service.odata.getEntitySet(
|
|
129
|
+
* let res = await service.odata.getEntitySet(srv, "A_PurchaseOrder", filterString, select, queryParams);
|
|
127
130
|
*/
|
|
128
|
-
getEntitySet(srv, entitySet, filterString = "", selectionFields = "", queryParams = {}) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
async getEntitySet(srv, entitySet, filterString = "", selectionFields = "", queryParams = {}) {
|
|
132
|
+
if (!srv) {
|
|
133
|
+
throw new Error("Service is not defined. Please make sure to initialize and pass the service.");
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
let entity = srv[entitySet];
|
|
137
|
+
if (!entity) {
|
|
138
|
+
throw new Error(`No entity set '${entitySet}' available in service`);
|
|
132
139
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (filterString) {
|
|
136
|
-
entity = entity.filter(filterString);
|
|
137
|
-
}
|
|
138
|
-
if (selectionFields) {
|
|
139
|
-
entity = entity.select(selectionFields.split(","));
|
|
140
|
-
}
|
|
141
|
-
if (queryParams) {
|
|
142
|
-
Object.keys(queryParams).forEach((key) => {
|
|
143
|
-
entity = entity.queryParameter(key, queryParams[key]);
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
const res = entity.get();
|
|
147
|
-
return res;
|
|
140
|
+
if (filterString) {
|
|
141
|
+
entity = entity.filter(filterString);
|
|
148
142
|
}
|
|
149
|
-
|
|
143
|
+
if (selectionFields) {
|
|
144
|
+
entity = entity.select(selectionFields.split(","));
|
|
145
|
+
}
|
|
146
|
+
if (queryParams) {
|
|
147
|
+
Object.keys(queryParams).forEach((key) => {
|
|
148
|
+
entity = entity.queryParameter(key, queryParams[key]);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
const res = entity.get();
|
|
152
|
+
return res;
|
|
153
|
+
}
|
|
150
154
|
}
|
|
151
155
|
;
|
|
152
156
|
/**
|
|
153
157
|
* @function isFeatureToggleActivated
|
|
154
158
|
* @memberOf service.odata
|
|
155
159
|
* @description checks if a feature toggle is switched on or off
|
|
156
|
-
* @param {
|
|
157
|
-
* @param {
|
|
160
|
+
* @param {Object} srv - Instance of the service
|
|
161
|
+
* @param {String} featureName - The name of the feature you want know the status of.
|
|
158
162
|
* @example const url = browser.params.systemUrl + "/sap/opu/odata/SAP/CA_FM_FEATURE_TOGGLE_STATUS_SRV/";
|
|
159
|
-
*
|
|
160
|
-
* let isFeatureActive = await service.odata.isFeatureToggleActivated(
|
|
163
|
+
* const srv = await service.odata.init(url, user, password);
|
|
164
|
+
* let isFeatureActive = await service.odata.isFeatureToggleActivated(srv, "MM_PUR_PO_BATCHES_IN_MANAGE_PO");
|
|
161
165
|
*/
|
|
162
|
-
isFeatureToggleActivated(srv, featureName) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
return false;
|
|
171
|
-
}
|
|
166
|
+
async isFeatureToggleActivated(srv, featureName) {
|
|
167
|
+
const res = await this.getEntitySet(srv, "ToggleStatusSet");
|
|
168
|
+
for (const featureEntity of Object.values(res)) {
|
|
169
|
+
// @ts-ignore
|
|
170
|
+
if (featureEntity.Featureid === featureName) {
|
|
171
|
+
//feature toggle is disabled if found
|
|
172
|
+
util.console.info(`Feature Toggle "${featureName}" is disabled.`);
|
|
173
|
+
return false;
|
|
172
174
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
}
|
|
176
|
+
//feature toggle is enabled if NOT found
|
|
177
|
+
util.console.info(`Feature Toggle "${featureName}" is enabled.`);
|
|
178
|
+
return true;
|
|
177
179
|
}
|
|
178
180
|
;
|
|
179
181
|
/**
|
|
180
182
|
* @function post
|
|
181
|
-
|
|
182
183
|
* @memberOf service.odata
|
|
183
184
|
* @description makes a POST request.
|
|
184
|
-
* @param {
|
|
185
|
-
* @param {
|
|
186
|
-
* @param {
|
|
187
|
-
* @example
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
185
|
+
* @param {Object} srv - Instance of the service
|
|
186
|
+
* @param {String} entitySet - The entitySet you want to POST against.
|
|
187
|
+
* @param {Object} payload - The payload for the POST-request.
|
|
188
|
+
* @example
|
|
189
|
+
* let payload = {
|
|
190
|
+
* "PurchaseOrder": "4500007108",
|
|
191
|
+
* "DraftUUID": "00000000-0000-0000-0000-000000000000",
|
|
192
|
+
* "IsActiveEntity": "true"
|
|
193
|
+
* };
|
|
194
|
+
* let res = await service.odata.post(srv, "A_PurchaseOrder", payload);
|
|
193
195
|
*/
|
|
194
|
-
post(srv, entitySet, payload) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
async post(srv, entitySet, payload) {
|
|
197
|
+
const entity = srv[entitySet];
|
|
198
|
+
if (!entity) {
|
|
199
|
+
throw new Error(`No entity set '${entitySet}' available in service`);
|
|
200
|
+
}
|
|
201
|
+
return entity.post(payload);
|
|
198
202
|
}
|
|
199
203
|
;
|
|
200
204
|
/**
|
|
201
205
|
* @function merge
|
|
202
206
|
* @memberOf service.odata
|
|
203
207
|
* @description makes a MERGE request.
|
|
204
|
-
* @param {
|
|
205
|
-
* @param {
|
|
206
|
-
* @param {
|
|
207
|
-
* @example
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
208
|
+
* @param {Object} srv - Instance of the service
|
|
209
|
+
* @param {String} entitySet - The entitySet you want to MERGE in.
|
|
210
|
+
* @param {Object} payload - The payload for the MERGE-request.
|
|
211
|
+
* @example
|
|
212
|
+
* let res = await service.odata.merge(srv, "A_PurchaseOrderScheduleLine", {
|
|
213
|
+
* "PurchasingDocument": "4500007108",
|
|
214
|
+
* "PurchasingDocumentItem": "10",
|
|
215
|
+
* "ScheduleLine": "1",
|
|
216
|
+
* "ScheduleLineDeliveryDate": new Date()
|
|
217
|
+
* };
|
|
214
218
|
*/
|
|
215
|
-
merge(srv, entitySet, payload) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
219
|
+
async merge(srv, entitySet, payload) {
|
|
220
|
+
const entity = srv[entitySet];
|
|
221
|
+
if (!entity) {
|
|
222
|
+
throw new Error(`No entity set '${entitySet}' available in service`);
|
|
223
|
+
}
|
|
224
|
+
const res = await entity.merge(payload);
|
|
225
|
+
return res;
|
|
220
226
|
}
|
|
221
227
|
;
|
|
222
228
|
/**
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
229
|
+
* @function delete
|
|
230
|
+
* @memberOf service.odata
|
|
231
|
+
* @description makes a DELETE request.
|
|
232
|
+
* @param {Object} srv - Instance of the service
|
|
233
|
+
* @param {String} entitySet - The entitySet you want to DELETE.
|
|
234
|
+
* @param {Object} options - The options for the DELETE-request.
|
|
235
|
+
* @example
|
|
236
|
+
* let options = {
|
|
237
|
+
* "PurchaseOrder": "",
|
|
238
|
+
* "DraftUUID": draftUUID,
|
|
239
|
+
* "IsActiveEntity": false
|
|
240
|
+
* };
|
|
241
|
+
* await service.odata.delete(srv, "C_PurchaseOrderTP", options);
|
|
242
|
+
*/
|
|
243
|
+
async delete(srv, entitySet, options) {
|
|
244
|
+
const entity = srv[entitySet];
|
|
245
|
+
if (!entity) {
|
|
246
|
+
throw new Error(`No entity set '${entitySet}' available in service`);
|
|
247
|
+
}
|
|
248
|
+
const res = await entity.delete(options);
|
|
249
|
+
return res;
|
|
241
250
|
}
|
|
242
251
|
;
|
|
243
252
|
/**
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
});
|
|
253
|
+
* @function callFunctionImport
|
|
254
|
+
* @memberOf service.odata
|
|
255
|
+
* @description makes a function import request on an OData service.
|
|
256
|
+
* @param {Object} srv - Instance of the service
|
|
257
|
+
* @param {String} functionImportName - Name of Function Import
|
|
258
|
+
* @param {Object} options - parameters for function import
|
|
259
|
+
* @example
|
|
260
|
+
* const options = {
|
|
261
|
+
* CentralRequestForQuotation : "7500000026",
|
|
262
|
+
* Supplier : "100006"
|
|
263
|
+
* };
|
|
264
|
+
* const res = await service.odata.callFunctionImport(srv, "Cancel", options);
|
|
265
|
+
*/
|
|
266
|
+
async callFunctionImport(srv, functionImportName, options) {
|
|
267
|
+
const functionImport = srv.functionImports[functionImportName];
|
|
268
|
+
const res = await functionImport.call(options);
|
|
269
|
+
return res;
|
|
262
270
|
}
|
|
263
271
|
;
|
|
264
272
|
/**
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
getOutputManagementPdfStream(outputConf, url, username, password) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
const dataBuffer = yield srv.Items.key(outputConf).GetDocument.get();
|
|
290
|
-
return dataBuffer;
|
|
291
|
-
});
|
|
273
|
+
* @function getOutputManagementPdfStream
|
|
274
|
+
* @memberOf service.odata
|
|
275
|
+
* @description returns a stream of output management pdf file.
|
|
276
|
+
* @param {Object} outputConf - Configuration for the output management pdf.
|
|
277
|
+
* @param {String} url - system url
|
|
278
|
+
* @param {String} username - username for login
|
|
279
|
+
* @param {String} password - password for login
|
|
280
|
+
* @example
|
|
281
|
+
* const outputConf =
|
|
282
|
+
* ApplObjectType: "REQUEST_FOR_QUOTATION",
|
|
283
|
+
* ApplObjectId: "7000002653",
|
|
284
|
+
* ItemId: "1"
|
|
285
|
+
* };
|
|
286
|
+
* const pdfStream = await service.odata.getOutputManagementPdfStream(outputConf, url, user, password);
|
|
287
|
+
*/
|
|
288
|
+
async getOutputManagementPdfStream(outputConf, url, username, password) {
|
|
289
|
+
if (arguments.length < 4) {
|
|
290
|
+
throw new Error("getOutputManagementPdfStream Failed. Please send correct parameters");
|
|
291
|
+
}
|
|
292
|
+
const uri = new this.urlLib(url);
|
|
293
|
+
url = uri.origin + "/sap/opu/odata/sap/CA_OC_OUTPUT_REQUEST_SRV/";
|
|
294
|
+
const srv = await service.odata.init(url, username, password);
|
|
295
|
+
const dataBuffer = await srv.Items.key(outputConf).GetDocument.get();
|
|
296
|
+
return dataBuffer;
|
|
292
297
|
}
|
|
293
298
|
;
|
|
294
299
|
/**
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
300
|
+
* @function readPdfFromDirectUrl
|
|
301
|
+
* @memberOf service.odata
|
|
302
|
+
* @description returns a stream of pdf file which is part of attachment.
|
|
303
|
+
* @param {String} url - system url
|
|
304
|
+
* @param {String} [username] - username for login
|
|
305
|
+
* @param {String} [password] - password for login
|
|
306
|
+
* @param {Boolean} [isSaml=false] - use SAML login if true
|
|
307
|
+
* @example
|
|
308
|
+
* const url = "https://domain.com/getPdfFile";
|
|
309
|
+
* const pdfStream = await service.odata.readPdfFromDirectUrl(url, "username", "Password");
|
|
310
|
+
*/
|
|
311
|
+
async readPdfFromDirectUrl(url, username, password, isSaml = false) {
|
|
312
|
+
if (url === undefined || url === null) {
|
|
313
|
+
throw new Error("Function 'readPdfFromDirectUrl' Failed. Please provide valid url as first parameter");
|
|
314
|
+
}
|
|
315
|
+
const res = await this._doRequest(url, username, password, isSaml);
|
|
316
|
+
return res;
|
|
312
317
|
}
|
|
313
318
|
;
|
|
314
319
|
// =================================== HELPER ===================================
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odata.js","sourceRoot":"","sources":["../../../../src/reuse/modules/service/odata.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"odata.js","sourceRoot":"","sources":["../../../../src/reuse/modules/service/odata.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb;;;GAGG;AACH,MAAa,KAAK;IAMhB;QALS,eAAU,GAAG,OAAO,CAAC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