@itentialopensource/adapter-utils 5.9.5 → 5.10.0
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/CHANGELOG.md +8 -0
- package/lib/restHandler.js +28 -5
- package/package.json +1 -1
- package/refs?service=git-upload-pack +0 -0
- package/schemas/propertiesSchema.json +5 -0
package/CHANGELOG.md
CHANGED
package/lib/restHandler.js
CHANGED
|
@@ -23,6 +23,7 @@ let globalRequestGl = null;
|
|
|
23
23
|
let returnRawGl = false;
|
|
24
24
|
let encodePath = true;
|
|
25
25
|
let encodeUri = true;
|
|
26
|
+
let queryKeyGl = true;
|
|
26
27
|
let stripEscapes = false;
|
|
27
28
|
let returnResponseHeaders = true;
|
|
28
29
|
let healthcheckHeaders = null;
|
|
@@ -797,12 +798,20 @@ function buildRequestPath(entity, action, entitySchema, reqPath, uriPathVars, ur
|
|
|
797
798
|
addquery = entitySchema.querykey;
|
|
798
799
|
}
|
|
799
800
|
if (systemQuery !== null) {
|
|
801
|
+
// do not want to change the global only change this call so use a local var
|
|
802
|
+
let localEncode = encodeUri;
|
|
803
|
+
let localKey = queryKeyGl;
|
|
804
|
+
|
|
800
805
|
// if encoding is changed in call properties that overrides the default
|
|
801
806
|
if (callProperties && Object.hasOwnProperty.call(callProperties, 'encode_queryvars')) {
|
|
802
|
-
|
|
807
|
+
localEncode = callProperties.encode_queryvars;
|
|
808
|
+
}
|
|
809
|
+
if (callProperties && Object.hasOwnProperty.call(callProperties, 'query_keys')) {
|
|
810
|
+
localKey = callProperties.query_keys;
|
|
803
811
|
}
|
|
804
|
-
|
|
805
|
-
if
|
|
812
|
+
|
|
813
|
+
// if we are encoding with keys - use querystring since it does it all!
|
|
814
|
+
if (localEncode === true && localKey === true) {
|
|
806
815
|
addquery += querystring.stringify(systemQuery);
|
|
807
816
|
} else {
|
|
808
817
|
// if not encoding we need to build
|
|
@@ -814,8 +823,17 @@ function buildRequestPath(entity, action, entitySchema, reqPath, uriPathVars, ur
|
|
|
814
823
|
if (k > 0) {
|
|
815
824
|
addquery += '&';
|
|
816
825
|
}
|
|
817
|
-
|
|
818
|
-
|
|
826
|
+
|
|
827
|
+
if (localKey === true) {
|
|
828
|
+
// adds key=value
|
|
829
|
+
addquery += `${qkeys[k]}=${systemQuery[qkeys[k]]}`;
|
|
830
|
+
} else if (localEncode === true) {
|
|
831
|
+
// adds value but encoded
|
|
832
|
+
addquery += encodeURIComponent(systemQuery[qkeys[k]]);
|
|
833
|
+
} else {
|
|
834
|
+
// adds value
|
|
835
|
+
addquery += `${systemQuery[qkeys[k]]}`;
|
|
836
|
+
}
|
|
819
837
|
}
|
|
820
838
|
}
|
|
821
839
|
}
|
|
@@ -1147,6 +1165,11 @@ class RestHandler {
|
|
|
1147
1165
|
encodePath = this.encode;
|
|
1148
1166
|
this.encodeQ = properties.encode_queryvars;
|
|
1149
1167
|
encodeUri = this.encodeQ;
|
|
1168
|
+
this.queryKey = true;
|
|
1169
|
+
if (Object.hasOwnProperty.call(properties, 'query_keys')) {
|
|
1170
|
+
this.queryKey = properties.query_keys;
|
|
1171
|
+
}
|
|
1172
|
+
queryKeyGl = this.queryKey;
|
|
1150
1173
|
|
|
1151
1174
|
// optional to strip extra escapes - default is false
|
|
1152
1175
|
if (properties.stripEscapes) {
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -69,6 +69,11 @@
|
|
|
69
69
|
"description": "When true the query parameters are encoded in the url",
|
|
70
70
|
"default": true
|
|
71
71
|
},
|
|
72
|
+
"query_keys": {
|
|
73
|
+
"type": "boolean",
|
|
74
|
+
"description": "When true the query keys are put into the url (e.g. key=value)",
|
|
75
|
+
"default": true
|
|
76
|
+
},
|
|
72
77
|
"save_metric": {
|
|
73
78
|
"type": [
|
|
74
79
|
"boolean",
|