@ama-sdk/core 12.3.0-prerelease.13 → 12.3.0-prerelease.14
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/cjs/clients/api-angular-client.js +2 -1
- package/cjs/clients/api-beacon-client.js +2 -1
- package/cjs/clients/api-fetch-client.js +2 -1
- package/cjs/fwk/api.helpers.js +2 -1
- package/cjs/fwk/param-serialization.js +37 -10
- package/cjs/plugins/additional-params/additional-params-sync.request.js +71 -2
- package/cjs/plugins/additional-params/additional-params.request.js +72 -3
- package/cjs/plugins/additional-params/additional-params.spec.js +179 -1
- package/esm2015/clients/api-angular-client.js +2 -1
- package/esm2015/clients/api-beacon-client.js +2 -1
- package/esm2015/clients/api-fetch-client.js +2 -1
- package/esm2015/fwk/api.helpers.js +2 -2
- package/esm2015/fwk/param-serialization.js +37 -10
- package/esm2015/plugins/additional-params/additional-params-sync.request.js +71 -2
- package/esm2015/plugins/additional-params/additional-params.request.js +72 -3
- package/esm2015/plugins/additional-params/additional-params.spec.js +179 -1
- package/package.json +6 -6
- package/src/clients/api-angular-client.d.ts +1 -1
- package/src/clients/api-angular-client.d.ts.map +1 -1
- package/src/clients/api-angular-client.js +2 -1
- package/src/clients/api-angular-client.js.map +1 -1
- package/src/clients/api-beacon-client.d.ts +1 -1
- package/src/clients/api-beacon-client.d.ts.map +1 -1
- package/src/clients/api-beacon-client.js +2 -1
- package/src/clients/api-beacon-client.js.map +1 -1
- package/src/clients/api-fetch-client.d.ts +1 -1
- package/src/clients/api-fetch-client.d.ts.map +1 -1
- package/src/clients/api-fetch-client.js +2 -1
- package/src/clients/api-fetch-client.js.map +1 -1
- package/src/fwk/api.helpers.d.ts +1 -2
- package/src/fwk/api.helpers.d.ts.map +1 -1
- package/src/fwk/api.helpers.js +1 -2
- package/src/fwk/api.helpers.js.map +1 -1
- package/src/fwk/core/api-client.d.ts +4 -2
- package/src/fwk/core/api-client.d.ts.map +1 -1
- package/src/fwk/core/api-client.js.map +1 -1
- package/src/fwk/core/base-api-constructor.d.ts +2 -0
- package/src/fwk/core/base-api-constructor.d.ts.map +1 -1
- package/src/fwk/core/base-api-constructor.js.map +1 -1
- package/src/fwk/param-serialization.d.ts +20 -0
- package/src/fwk/param-serialization.d.ts.map +1 -1
- package/src/fwk/param-serialization.js +36 -8
- package/src/fwk/param-serialization.js.map +1 -1
- package/src/plugins/additional-params/additional-params-sync.request.d.ts +9 -2
- package/src/plugins/additional-params/additional-params-sync.request.d.ts.map +1 -1
- package/src/plugins/additional-params/additional-params-sync.request.js +21 -2
- package/src/plugins/additional-params/additional-params-sync.request.js.map +1 -1
- package/src/plugins/additional-params/additional-params.request.d.ts +11 -2
- package/src/plugins/additional-params/additional-params.request.d.ts.map +1 -1
- package/src/plugins/additional-params/additional-params.request.js +21 -2
- package/src/plugins/additional-params/additional-params.request.js.map +1 -1
- package/src/plugins/core/request-plugin.d.ts +14 -1
- package/src/plugins/core/request-plugin.d.ts.map +1 -1
- package/src/plugins/si-token/si-token.request.d.ts.map +1 -1
- package/src/plugins/si-token/si-token.request.js.map +1 -1
|
@@ -248,7 +248,8 @@ var DEFAULT_OPTIONS = {
|
|
|
248
248
|
angularPlugins: [],
|
|
249
249
|
requestPlugins: [],
|
|
250
250
|
enableTokenization: false,
|
|
251
|
-
disableFallback: false
|
|
251
|
+
disableFallback: false,
|
|
252
|
+
enableParameterSerialization: false
|
|
252
253
|
};
|
|
253
254
|
var ApiAngularClient = /*#__PURE__*/ function() {
|
|
254
255
|
"use strict";
|
|
@@ -91,7 +91,8 @@ function _object_spread_props(target, source) {
|
|
|
91
91
|
var DEFAULT_OPTIONS = {
|
|
92
92
|
replyPlugins: [],
|
|
93
93
|
requestPlugins: [],
|
|
94
|
-
enableTokenization: false
|
|
94
|
+
enableTokenization: false,
|
|
95
|
+
enableParameterSerialization: false
|
|
95
96
|
};
|
|
96
97
|
/**
|
|
97
98
|
* Determine if the given value is a promise
|
|
@@ -248,7 +248,8 @@ var DEFAULT_OPTIONS = {
|
|
|
248
248
|
fetchPlugins: [],
|
|
249
249
|
requestPlugins: [],
|
|
250
250
|
enableTokenization: false,
|
|
251
|
-
disableFallback: false
|
|
251
|
+
disableFallback: false,
|
|
252
|
+
enableParameterSerialization: false
|
|
252
253
|
};
|
|
253
254
|
var ApiFetchClient = /*#__PURE__*/ function() {
|
|
254
255
|
"use strict";
|
package/cjs/fwk/api.helpers.js
CHANGED
|
@@ -129,7 +129,8 @@ function prepareUrl(url) {
|
|
|
129
129
|
var paramsPrefix = url.includes('?') ? '&' : '?';
|
|
130
130
|
return url + (queryPart ? paramsPrefix + queryPart : '');
|
|
131
131
|
}
|
|
132
|
-
function prepareUrlWithQueryParams(url
|
|
132
|
+
function prepareUrlWithQueryParams(url) {
|
|
133
|
+
var serializedQueryParams = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
133
134
|
var paramsPrefix = url.includes('?') ? '&' : '?';
|
|
134
135
|
var queryPart = Object.values(serializedQueryParams).join('&');
|
|
135
136
|
return url + (queryPart ? paramsPrefix + queryPart : '');
|
|
@@ -12,11 +12,17 @@ _export(exports, {
|
|
|
12
12
|
isDateType: function() {
|
|
13
13
|
return isDateType;
|
|
14
14
|
},
|
|
15
|
+
isParamValueRecord: function() {
|
|
16
|
+
return isParamValueRecord;
|
|
17
|
+
},
|
|
15
18
|
serializePathParams: function() {
|
|
16
19
|
return serializePathParams;
|
|
17
20
|
},
|
|
18
21
|
serializeQueryParams: function() {
|
|
19
22
|
return serializeQueryParams;
|
|
23
|
+
},
|
|
24
|
+
serializeRequestPluginQueryParams: function() {
|
|
25
|
+
return serializeRequestPluginQueryParams;
|
|
20
26
|
}
|
|
21
27
|
});
|
|
22
28
|
var _date = require("./date");
|
|
@@ -77,9 +83,31 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
77
83
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
78
84
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
79
85
|
}
|
|
86
|
+
/** URL encoding of space character, delimiter for spaceDelimited style */ var SPACE_URL_CODE = encodeURIComponent(' ');
|
|
87
|
+
/** URL encoding of pipe character, delimiter for pipeDelimited style */ var PIPE_URL_CODE = encodeURIComponent('|');
|
|
88
|
+
/** URL encoding of opening square bracket, used in deepObject style */ var OPENING_SQUARE_BRACKET_URL_CODE = encodeURIComponent('[');
|
|
89
|
+
/** URL encoding of closing square bracket, used in deepObject style */ var CLOSING_SQUARE_BRACKET_URL_CODE = encodeURIComponent(']');
|
|
80
90
|
function isDateType(prop) {
|
|
81
91
|
return _instanceof(prop, Date) || _instanceof(prop, _date.utils.Date) || _instanceof(prop, _date.utils.DateTime);
|
|
82
92
|
}
|
|
93
|
+
function isParamValueRecord(param) {
|
|
94
|
+
return (typeof param === "undefined" ? "undefined" : _type_of(param)) === 'object' && Object.values(param).every(function(item) {
|
|
95
|
+
return typeof item === 'string';
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function serializeRequestPluginQueryParams(queryParams) {
|
|
99
|
+
var queryParamsValues = {};
|
|
100
|
+
var queryParamSerialization = {};
|
|
101
|
+
Object.entries(queryParams).forEach(function(param) {
|
|
102
|
+
var _param = _sliced_to_array(param, 2), paramKey = _param[0], paramValue = _param[1];
|
|
103
|
+
queryParamsValues[paramKey] = paramValue.value;
|
|
104
|
+
queryParamSerialization[paramKey] = {
|
|
105
|
+
explode: paramValue.explode,
|
|
106
|
+
style: paramValue.style
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
return serializeQueryParams(queryParamsValues, queryParamSerialization);
|
|
110
|
+
}
|
|
83
111
|
/**
|
|
84
112
|
* Serialize query parameters of type array
|
|
85
113
|
* OpenAPI Parameter Serialization {@link https://swagger.io/specification | documentation}
|
|
@@ -110,7 +138,7 @@ function isDateType(prop) {
|
|
|
110
138
|
}
|
|
111
139
|
return encodeURIComponent(queryParamName) + '=' + filteredArray.map(function(v) {
|
|
112
140
|
return isDateType(v) ? v.toJSON() : encodeURIComponent(v.toString());
|
|
113
|
-
}).join(
|
|
141
|
+
}).join(SPACE_URL_CODE);
|
|
114
142
|
}
|
|
115
143
|
case 'pipeDelimited':
|
|
116
144
|
{
|
|
@@ -119,7 +147,7 @@ function isDateType(prop) {
|
|
|
119
147
|
}
|
|
120
148
|
return encodeURIComponent(queryParamName) + '=' + filteredArray.map(function(v) {
|
|
121
149
|
return isDateType(v) ? v.toJSON() : encodeURIComponent(v.toString());
|
|
122
|
-
}).join(
|
|
150
|
+
}).join(PIPE_URL_CODE);
|
|
123
151
|
}
|
|
124
152
|
}
|
|
125
153
|
}
|
|
@@ -150,17 +178,17 @@ function isDateType(prop) {
|
|
|
150
178
|
} else if (paramSerialization.style === 'spaceDelimited' && !paramSerialization.explode && !emptyObject) {
|
|
151
179
|
return encodeURIComponent(queryParamName) + '=' + Object.entries(filteredObject).map(function(param) {
|
|
152
180
|
var _param = _sliced_to_array(param, 2), propName = _param[0], propValue = _param[1];
|
|
153
|
-
return encodeURIComponent(propName) +
|
|
154
|
-
}).join(
|
|
181
|
+
return encodeURIComponent(propName) + SPACE_URL_CODE + (isDateType(propValue) ? propValue.toJSON() : encodeURIComponent(propValue.toString()));
|
|
182
|
+
}).join(SPACE_URL_CODE);
|
|
155
183
|
} else if (paramSerialization.style === 'pipeDelimited' && !paramSerialization.explode && !emptyObject) {
|
|
156
184
|
return encodeURIComponent(queryParamName) + '=' + Object.entries(filteredObject).map(function(param) {
|
|
157
185
|
var _param = _sliced_to_array(param, 2), propName = _param[0], propValue = _param[1];
|
|
158
|
-
return encodeURIComponent(propName) +
|
|
159
|
-
}).join(
|
|
186
|
+
return encodeURIComponent(propName) + PIPE_URL_CODE + (isDateType(propValue) ? propValue.toJSON() : encodeURIComponent(propValue.toString()));
|
|
187
|
+
}).join(PIPE_URL_CODE);
|
|
160
188
|
} else if (paramSerialization.style === 'deepObject' && paramSerialization.explode && !emptyObject) {
|
|
161
189
|
return Object.entries(filteredObject).map(function(param) {
|
|
162
190
|
var _param = _sliced_to_array(param, 2), propName = _param[0], propValue = _param[1];
|
|
163
|
-
return encodeURIComponent(queryParamName) +
|
|
191
|
+
return encodeURIComponent(queryParamName) + OPENING_SQUARE_BRACKET_URL_CODE + encodeURIComponent(propName) + CLOSING_SQUARE_BRACKET_URL_CODE + '=' + (isDateType(propValue) ? propValue.toJSON() : encodeURIComponent(propValue.toString()));
|
|
164
192
|
}).join('&');
|
|
165
193
|
}
|
|
166
194
|
}
|
|
@@ -175,9 +203,8 @@ function serializeQueryParams(queryParams, queryParamSerialization) {
|
|
|
175
203
|
} else if ((typeof queryParamValue === "undefined" ? "undefined" : _type_of(queryParamValue)) === 'object' && !isDateType(queryParamValue)) {
|
|
176
204
|
serializedValue = serializeObjectQueryParams(queryParamName, queryParamValue, paramSerialization);
|
|
177
205
|
} else {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
206
|
+
// NOTE: 'form' style is the default value for primitive types
|
|
207
|
+
serializedValue = encodeURIComponent(queryParamName) + '=' + (isDateType(queryParamValue) ? queryParamValue.toJSON() : encodeURIComponent(queryParamValue.toString()));
|
|
181
208
|
}
|
|
182
209
|
if (serializedValue) {
|
|
183
210
|
acc[queryParamName] = serializedValue;
|
|
@@ -8,7 +8,17 @@ Object.defineProperty(exports, "AdditionalParamsSyncRequest", {
|
|
|
8
8
|
return AdditionalParamsSyncRequest;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
var _apihelpers = require("../../fwk/api.helpers");
|
|
12
|
+
var _paramserialization = require("../../fwk/param-serialization");
|
|
11
13
|
var _additionalparamsrequest = require("./additional-params.request");
|
|
14
|
+
function _array_like_to_array(arr, len) {
|
|
15
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
16
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
17
|
+
return arr2;
|
|
18
|
+
}
|
|
19
|
+
function _array_with_holes(arr) {
|
|
20
|
+
if (Array.isArray(arr)) return arr;
|
|
21
|
+
}
|
|
12
22
|
function _class_call_check(instance, Constructor) {
|
|
13
23
|
if (!(instance instanceof Constructor)) {
|
|
14
24
|
throw new TypeError("Cannot call a class as a function");
|
|
@@ -41,6 +51,33 @@ function _define_property(obj, key, value) {
|
|
|
41
51
|
}
|
|
42
52
|
return obj;
|
|
43
53
|
}
|
|
54
|
+
function _iterable_to_array_limit(arr, i) {
|
|
55
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
56
|
+
if (_i == null) return;
|
|
57
|
+
var _arr = [];
|
|
58
|
+
var _n = true;
|
|
59
|
+
var _d = false;
|
|
60
|
+
var _s, _e;
|
|
61
|
+
try {
|
|
62
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
63
|
+
_arr.push(_s.value);
|
|
64
|
+
if (i && _arr.length === i) break;
|
|
65
|
+
}
|
|
66
|
+
} catch (err) {
|
|
67
|
+
_d = true;
|
|
68
|
+
_e = err;
|
|
69
|
+
} finally{
|
|
70
|
+
try {
|
|
71
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
72
|
+
} finally{
|
|
73
|
+
if (_d) throw _e;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return _arr;
|
|
77
|
+
}
|
|
78
|
+
function _non_iterable_rest() {
|
|
79
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
80
|
+
}
|
|
44
81
|
function _object_spread(target) {
|
|
45
82
|
for(var i = 1; i < arguments.length; i++){
|
|
46
83
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -56,6 +93,17 @@ function _object_spread(target) {
|
|
|
56
93
|
}
|
|
57
94
|
return target;
|
|
58
95
|
}
|
|
96
|
+
function _sliced_to_array(arr, i) {
|
|
97
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
98
|
+
}
|
|
99
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
100
|
+
if (!o) return;
|
|
101
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
102
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
103
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
104
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
105
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
106
|
+
}
|
|
59
107
|
var AdditionalParamsSyncRequest = /*#__PURE__*/ function() {
|
|
60
108
|
"use strict";
|
|
61
109
|
function AdditionalParamsSyncRequest(additionalParams) {
|
|
@@ -66,7 +114,7 @@ var AdditionalParamsSyncRequest = /*#__PURE__*/ function() {
|
|
|
66
114
|
_create_class(AdditionalParamsSyncRequest, [
|
|
67
115
|
{
|
|
68
116
|
key: "load",
|
|
69
|
-
value: function load() {
|
|
117
|
+
value: function load(context) {
|
|
70
118
|
var _this = this;
|
|
71
119
|
return {
|
|
72
120
|
transform: function(data) {
|
|
@@ -74,7 +122,28 @@ var AdditionalParamsSyncRequest = /*#__PURE__*/ function() {
|
|
|
74
122
|
var headers = typeof _this.additionalParams.headers === 'function' ? _this.additionalParams.headers(data.headers) : _this.additionalParams.headers;
|
|
75
123
|
var body = _this.additionalParams.body && (0, _additionalparamsrequest.isStringOrUndefined)(data.body) ? _this.additionalParams.body(data.body) : undefined;
|
|
76
124
|
if (queryParams) {
|
|
77
|
-
|
|
125
|
+
var _data_paramSerializationOptions;
|
|
126
|
+
if ((_data_paramSerializationOptions = data.paramSerializationOptions) === null || _data_paramSerializationOptions === void 0 ? void 0 : _data_paramSerializationOptions.enableParameterSerialization) {
|
|
127
|
+
if ((0, _paramserialization.isParamValueRecord)(queryParams)) {
|
|
128
|
+
throw new Error('It is not possible to serialize additional query parameters without their serialization properties `value`, `explode`, and `style`.');
|
|
129
|
+
} else {
|
|
130
|
+
data.queryParams = _object_spread({}, data.queryParams, (0, _paramserialization.serializeRequestPluginQueryParams)(queryParams));
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
if ((0, _paramserialization.isParamValueRecord)(queryParams)) {
|
|
134
|
+
data.queryParams = _object_spread({}, data.queryParams, queryParams);
|
|
135
|
+
} else {
|
|
136
|
+
var queryParamsValues = Object.fromEntries(Object.entries(queryParams).map(function(param) {
|
|
137
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
138
|
+
return [
|
|
139
|
+
key,
|
|
140
|
+
value.value
|
|
141
|
+
];
|
|
142
|
+
}));
|
|
143
|
+
data.queryParams = _object_spread({}, data.queryParams, (0, _apihelpers.stringifyQueryParams)(queryParamsValues));
|
|
144
|
+
((context === null || context === void 0 ? void 0 : context.logger) || console).log('The serialization of additional query parameters has been ignored since parameter serialization is not enabled.');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
78
147
|
}
|
|
79
148
|
if (body !== undefined) {
|
|
80
149
|
data.body = body === null ? undefined : body;
|
|
@@ -16,6 +16,16 @@ _export(exports, {
|
|
|
16
16
|
return isStringOrUndefined;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
+
var _apihelpers = require("../../fwk/api.helpers");
|
|
20
|
+
var _paramserialization = require("../../fwk/param-serialization");
|
|
21
|
+
function _array_like_to_array(arr, len) {
|
|
22
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
23
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
24
|
+
return arr2;
|
|
25
|
+
}
|
|
26
|
+
function _array_with_holes(arr) {
|
|
27
|
+
if (Array.isArray(arr)) return arr;
|
|
28
|
+
}
|
|
19
29
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
20
30
|
try {
|
|
21
31
|
var info = gen[key](arg);
|
|
@@ -77,6 +87,33 @@ function _define_property(obj, key, value) {
|
|
|
77
87
|
}
|
|
78
88
|
return obj;
|
|
79
89
|
}
|
|
90
|
+
function _iterable_to_array_limit(arr, i) {
|
|
91
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
92
|
+
if (_i == null) return;
|
|
93
|
+
var _arr = [];
|
|
94
|
+
var _n = true;
|
|
95
|
+
var _d = false;
|
|
96
|
+
var _s, _e;
|
|
97
|
+
try {
|
|
98
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
99
|
+
_arr.push(_s.value);
|
|
100
|
+
if (i && _arr.length === i) break;
|
|
101
|
+
}
|
|
102
|
+
} catch (err) {
|
|
103
|
+
_d = true;
|
|
104
|
+
_e = err;
|
|
105
|
+
} finally{
|
|
106
|
+
try {
|
|
107
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
108
|
+
} finally{
|
|
109
|
+
if (_d) throw _e;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return _arr;
|
|
113
|
+
}
|
|
114
|
+
function _non_iterable_rest() {
|
|
115
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
116
|
+
}
|
|
80
117
|
function _object_spread(target) {
|
|
81
118
|
for(var i = 1; i < arguments.length; i++){
|
|
82
119
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -92,10 +129,21 @@ function _object_spread(target) {
|
|
|
92
129
|
}
|
|
93
130
|
return target;
|
|
94
131
|
}
|
|
132
|
+
function _sliced_to_array(arr, i) {
|
|
133
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
134
|
+
}
|
|
95
135
|
function _type_of(obj) {
|
|
96
136
|
"@swc/helpers - typeof";
|
|
97
137
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
98
138
|
}
|
|
139
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
140
|
+
if (!o) return;
|
|
141
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
142
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
143
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
144
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
145
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
146
|
+
}
|
|
99
147
|
function _ts_generator(thisArg, body) {
|
|
100
148
|
var f, y, t, g, _ = {
|
|
101
149
|
label: 0,
|
|
@@ -205,12 +253,12 @@ var AdditionalParamsRequest = /*#__PURE__*/ function() {
|
|
|
205
253
|
_create_class(AdditionalParamsRequest, [
|
|
206
254
|
{
|
|
207
255
|
key: "load",
|
|
208
|
-
value: function load() {
|
|
256
|
+
value: function load(context) {
|
|
209
257
|
var _this = this;
|
|
210
258
|
return {
|
|
211
259
|
transform: /*#__PURE__*/ function() {
|
|
212
260
|
var _ref = _async_to_generator(function(data) {
|
|
213
|
-
var queryParams, _tmp, headers, _tmp1, body, _tmp2;
|
|
261
|
+
var queryParams, _tmp, headers, _tmp1, body, _data_paramSerializationOptions, queryParamsValues, _tmp2;
|
|
214
262
|
return _ts_generator(this, function(_state) {
|
|
215
263
|
switch(_state.label){
|
|
216
264
|
case 0:
|
|
@@ -254,7 +302,28 @@ var AdditionalParamsRequest = /*#__PURE__*/ function() {
|
|
|
254
302
|
headers = _tmp1;
|
|
255
303
|
body = _this.additionalParams.body && isStringOrUndefined(data.body) ? _this.additionalParams.body(data.body) : undefined;
|
|
256
304
|
if (queryParams) {
|
|
257
|
-
|
|
305
|
+
;
|
|
306
|
+
if ((_data_paramSerializationOptions = data.paramSerializationOptions) === null || _data_paramSerializationOptions === void 0 ? void 0 : _data_paramSerializationOptions.enableParameterSerialization) {
|
|
307
|
+
if ((0, _paramserialization.isParamValueRecord)(queryParams)) {
|
|
308
|
+
throw new Error('It is not possible to serialize additional query parameters without their serialization properties `value`, `explode`, and `style`.');
|
|
309
|
+
} else {
|
|
310
|
+
data.queryParams = _object_spread({}, data.queryParams, (0, _paramserialization.serializeRequestPluginQueryParams)(queryParams));
|
|
311
|
+
}
|
|
312
|
+
} else {
|
|
313
|
+
if ((0, _paramserialization.isParamValueRecord)(queryParams)) {
|
|
314
|
+
data.queryParams = _object_spread({}, data.queryParams, queryParams);
|
|
315
|
+
} else {
|
|
316
|
+
queryParamsValues = Object.fromEntries(Object.entries(queryParams).map(function(param) {
|
|
317
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
318
|
+
return [
|
|
319
|
+
key,
|
|
320
|
+
value.value
|
|
321
|
+
];
|
|
322
|
+
}));
|
|
323
|
+
data.queryParams = _object_spread({}, data.queryParams, (0, _apihelpers.stringifyQueryParams)(queryParamsValues));
|
|
324
|
+
((context === null || context === void 0 ? void 0 : context.logger) || console).log('The serialization of additional query parameters has been ignored since parameter serialization is not enabled.');
|
|
325
|
+
}
|
|
326
|
+
}
|
|
258
327
|
}
|
|
259
328
|
if (!(body !== undefined)) return [
|
|
260
329
|
3,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
/* eslint-disable no-console -- only using the reference */ "use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
@@ -171,6 +171,115 @@ describe('Additional Params Request Plugin', function() {
|
|
|
171
171
|
}
|
|
172
172
|
});
|
|
173
173
|
}));
|
|
174
|
+
it('should add serialized query params', /*#__PURE__*/ _async_to_generator(function() {
|
|
175
|
+
var plugin, runner, result;
|
|
176
|
+
return _ts_generator(this, function(_state) {
|
|
177
|
+
switch(_state.label){
|
|
178
|
+
case 0:
|
|
179
|
+
options.paramSerializationOptions = {
|
|
180
|
+
enableParameterSerialization: true
|
|
181
|
+
};
|
|
182
|
+
plugin = new _additionalparamsrequest.AdditionalParamsRequest({
|
|
183
|
+
queryParams: {
|
|
184
|
+
primParam: {
|
|
185
|
+
value: 'ok',
|
|
186
|
+
explode: false,
|
|
187
|
+
style: 'form'
|
|
188
|
+
},
|
|
189
|
+
arrParam: {
|
|
190
|
+
value: [
|
|
191
|
+
'a',
|
|
192
|
+
'b',
|
|
193
|
+
'c'
|
|
194
|
+
],
|
|
195
|
+
explode: false,
|
|
196
|
+
style: 'spaceDelimited'
|
|
197
|
+
},
|
|
198
|
+
objParam: {
|
|
199
|
+
value: {
|
|
200
|
+
prop1: 'value1',
|
|
201
|
+
prop2: 'value2'
|
|
202
|
+
},
|
|
203
|
+
explode: true,
|
|
204
|
+
style: 'deepObject'
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
runner = plugin.load();
|
|
209
|
+
return [
|
|
210
|
+
4,
|
|
211
|
+
runner.transform(options)
|
|
212
|
+
];
|
|
213
|
+
case 1:
|
|
214
|
+
result = _state.sent();
|
|
215
|
+
expect(result.queryParams).toStrictEqual({
|
|
216
|
+
defaultTest: 'ok',
|
|
217
|
+
primParam: 'primParam=ok',
|
|
218
|
+
arrParam: 'arrParam=a%20b%20c',
|
|
219
|
+
objParam: 'objParam%5Bprop1%5D=value1&objParam%5Bprop2%5D=value2'
|
|
220
|
+
});
|
|
221
|
+
return [
|
|
222
|
+
2
|
|
223
|
+
];
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}));
|
|
227
|
+
it('should not serialize additional query params if param serialization is not enabled', /*#__PURE__*/ _async_to_generator(function() {
|
|
228
|
+
var plugin, runner, result;
|
|
229
|
+
return _ts_generator(this, function(_state) {
|
|
230
|
+
switch(_state.label){
|
|
231
|
+
case 0:
|
|
232
|
+
jest.spyOn(console, 'log');
|
|
233
|
+
plugin = new _additionalparamsrequest.AdditionalParamsRequest({
|
|
234
|
+
queryParams: {
|
|
235
|
+
test: {
|
|
236
|
+
value: 'ok',
|
|
237
|
+
explode: false,
|
|
238
|
+
style: 'form'
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
runner = plugin.load();
|
|
243
|
+
return [
|
|
244
|
+
4,
|
|
245
|
+
runner.transform(options)
|
|
246
|
+
];
|
|
247
|
+
case 1:
|
|
248
|
+
result = _state.sent();
|
|
249
|
+
expect(result.queryParams.test).toBe('ok');
|
|
250
|
+
expect(console.log).toHaveBeenCalled();
|
|
251
|
+
return [
|
|
252
|
+
2
|
|
253
|
+
];
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}));
|
|
257
|
+
it('should not add a specified query param of type string if param serialization is enabled', /*#__PURE__*/ _async_to_generator(function() {
|
|
258
|
+
var plugin, runner;
|
|
259
|
+
return _ts_generator(this, function(_state) {
|
|
260
|
+
switch(_state.label){
|
|
261
|
+
case 0:
|
|
262
|
+
options.paramSerializationOptions = {
|
|
263
|
+
enableParameterSerialization: true
|
|
264
|
+
};
|
|
265
|
+
plugin = new _additionalparamsrequest.AdditionalParamsRequest({
|
|
266
|
+
queryParams: {
|
|
267
|
+
test: 'ok'
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
runner = plugin.load();
|
|
271
|
+
return [
|
|
272
|
+
4,
|
|
273
|
+
expect(runner.transform(options)).rejects.toThrow('It is not possible to serialize additional query parameters without their serialization properties `value`, `explode`, and `style`.')
|
|
274
|
+
];
|
|
275
|
+
case 1:
|
|
276
|
+
_state.sent();
|
|
277
|
+
return [
|
|
278
|
+
2
|
|
279
|
+
];
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}));
|
|
174
283
|
it('should add the query params returned by a function', /*#__PURE__*/ _async_to_generator(function() {
|
|
175
284
|
var plugin, runner, result;
|
|
176
285
|
return _ts_generator(this, function(_state) {
|
|
@@ -249,6 +358,75 @@ describe('Additional Params Request Sync Plugin', function() {
|
|
|
249
358
|
var result = runner.transform(options);
|
|
250
359
|
expect(result.queryParams.test).toBe('ok');
|
|
251
360
|
});
|
|
361
|
+
it('should add serialized query params', function() {
|
|
362
|
+
options.paramSerializationOptions = {
|
|
363
|
+
enableParameterSerialization: true
|
|
364
|
+
};
|
|
365
|
+
var plugin = new _additionalparamssyncrequest.AdditionalParamsSyncRequest({
|
|
366
|
+
queryParams: {
|
|
367
|
+
primParam: {
|
|
368
|
+
value: 'ok',
|
|
369
|
+
explode: false,
|
|
370
|
+
style: 'form'
|
|
371
|
+
},
|
|
372
|
+
arrParam: {
|
|
373
|
+
value: [
|
|
374
|
+
'a',
|
|
375
|
+
'b',
|
|
376
|
+
'c'
|
|
377
|
+
],
|
|
378
|
+
explode: false,
|
|
379
|
+
style: 'spaceDelimited'
|
|
380
|
+
},
|
|
381
|
+
objParam: {
|
|
382
|
+
value: {
|
|
383
|
+
prop1: 'value1',
|
|
384
|
+
prop2: 'value2'
|
|
385
|
+
},
|
|
386
|
+
explode: true,
|
|
387
|
+
style: 'deepObject'
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
var runner = plugin.load();
|
|
392
|
+
var result = runner.transform(options);
|
|
393
|
+
expect(result.queryParams).toStrictEqual({
|
|
394
|
+
defaultTest: 'ok',
|
|
395
|
+
primParam: 'primParam=ok',
|
|
396
|
+
arrParam: 'arrParam=a%20b%20c',
|
|
397
|
+
objParam: 'objParam%5Bprop1%5D=value1&objParam%5Bprop2%5D=value2'
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
it('should not serialize additional query params if param serialization is not enabled', function() {
|
|
401
|
+
jest.spyOn(console, 'log');
|
|
402
|
+
var plugin = new _additionalparamssyncrequest.AdditionalParamsSyncRequest({
|
|
403
|
+
queryParams: {
|
|
404
|
+
test: {
|
|
405
|
+
value: 'ok',
|
|
406
|
+
explode: false,
|
|
407
|
+
style: 'form'
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
var runner = plugin.load();
|
|
412
|
+
var result = runner.transform(options);
|
|
413
|
+
expect(result.queryParams.test).toBe('ok');
|
|
414
|
+
expect(console.log).toHaveBeenCalled();
|
|
415
|
+
});
|
|
416
|
+
it('should not add a specified query param of type string if param serialization is enabled', function() {
|
|
417
|
+
options.paramSerializationOptions = {
|
|
418
|
+
enableParameterSerialization: true
|
|
419
|
+
};
|
|
420
|
+
var plugin = new _additionalparamssyncrequest.AdditionalParamsSyncRequest({
|
|
421
|
+
queryParams: {
|
|
422
|
+
test: 'ok'
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
var runner = plugin.load();
|
|
426
|
+
expect(function() {
|
|
427
|
+
return runner.transform(options);
|
|
428
|
+
}).toThrow('It is not possible to serialize additional query parameters without their serialization properties `value`, `explode`, and `style`.');
|
|
429
|
+
});
|
|
252
430
|
it('should add the query params returned by a function', function() {
|
|
253
431
|
var plugin = new _additionalparamssyncrequest.AdditionalParamsSyncRequest({
|
|
254
432
|
queryParams: additionalGetParams
|
|
@@ -238,7 +238,8 @@ var DEFAULT_OPTIONS = {
|
|
|
238
238
|
angularPlugins: [],
|
|
239
239
|
requestPlugins: [],
|
|
240
240
|
enableTokenization: false,
|
|
241
|
-
disableFallback: false
|
|
241
|
+
disableFallback: false,
|
|
242
|
+
enableParameterSerialization: false
|
|
242
243
|
};
|
|
243
244
|
/**
|
|
244
245
|
* Client to process the call to the API using Angular API
|
|
@@ -81,7 +81,8 @@ import { serializePathParams, serializeQueryParams } from '../fwk/param-serializ
|
|
|
81
81
|
var DEFAULT_OPTIONS = {
|
|
82
82
|
replyPlugins: [],
|
|
83
83
|
requestPlugins: [],
|
|
84
|
-
enableTokenization: false
|
|
84
|
+
enableTokenization: false,
|
|
85
|
+
enableParameterSerialization: false
|
|
85
86
|
};
|
|
86
87
|
/**
|
|
87
88
|
* Determine if the given value is a promise
|
|
@@ -238,7 +238,8 @@ var DEFAULT_OPTIONS = {
|
|
|
238
238
|
fetchPlugins: [],
|
|
239
239
|
requestPlugins: [],
|
|
240
240
|
enableTokenization: false,
|
|
241
|
-
disableFallback: false
|
|
241
|
+
disableFallback: false,
|
|
242
|
+
enableParameterSerialization: false
|
|
242
243
|
};
|
|
243
244
|
/**
|
|
244
245
|
* Client to process the call to the API using Fetch API
|
|
@@ -81,7 +81,6 @@ import { isDateType } from './param-serialization';
|
|
|
81
81
|
* Prepares the url to be called
|
|
82
82
|
* @param url Base url to be used
|
|
83
83
|
* @param queryParameters Key value pair with the parameters. If the value is undefined, the key is dropped
|
|
84
|
-
* @deprecated use {@link prepareUrlWithQueryParams} with query parameter serialization, will be removed in v14.
|
|
85
84
|
*/ export function prepareUrl(url) {
|
|
86
85
|
var queryParameters = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
87
86
|
var queryPart = Object.keys(queryParameters).filter(function(name) {
|
|
@@ -96,7 +95,8 @@ import { isDateType } from './param-serialization';
|
|
|
96
95
|
* Prepares the url to be called with the query parameters
|
|
97
96
|
* @param url Base url to be used
|
|
98
97
|
* @param serializedQueryParams Key value pairs of query parameter names and their serialized values
|
|
99
|
-
*/ export function prepareUrlWithQueryParams(url
|
|
98
|
+
*/ export function prepareUrlWithQueryParams(url) {
|
|
99
|
+
var serializedQueryParams = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
100
100
|
var paramsPrefix = url.includes('?') ? '&' : '?';
|
|
101
101
|
var queryPart = Object.values(serializedQueryParams).join('&');
|
|
102
102
|
return url + (queryPart ? paramsPrefix + queryPart : '');
|