ng2-rest 13.1.13 → 13.2.1
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/app.js +3 -3
- package/browser/esm2020/lib/models.mjs +43 -20
- package/browser/esm2020/lib/request-cache.mjs +5 -1
- package/browser/esm2020/lib/resource.service.mjs +1 -1
- package/browser/esm2020/lib/rest-headers.mjs +1 -1
- package/browser/esm2020/lib/rest-request.mjs +6 -5
- package/browser/esm2020/lib/rest.class.mjs +6 -3
- package/browser/fesm2015/ng2-rest.mjs +55 -25
- package/browser/fesm2015/ng2-rest.mjs.map +1 -1
- package/browser/fesm2020/ng2-rest.mjs +55 -25
- package/browser/fesm2020/ng2-rest.mjs.map +1 -1
- package/browser/lib/models.d.ts +8 -6
- package/browser/lib/request-cache.d.ts +4 -0
- package/client/esm2020/lib/models.mjs +43 -20
- package/client/esm2020/lib/request-cache.mjs +5 -1
- package/client/esm2020/lib/resource.service.mjs +1 -1
- package/client/esm2020/lib/rest-headers.mjs +1 -1
- package/client/esm2020/lib/rest-request.mjs +6 -5
- package/client/esm2020/lib/rest.class.mjs +6 -3
- package/client/fesm2015/ng2-rest.mjs +55 -25
- package/client/fesm2015/ng2-rest.mjs.map +1 -1
- package/client/fesm2020/ng2-rest.mjs +55 -25
- package/client/fesm2020/ng2-rest.mjs.map +1 -1
- package/client/lib/models.d.ts +8 -6
- package/client/lib/request-cache.d.ts +4 -0
- package/lib/models.d.ts +8 -6
- package/lib/models.js +49 -23
- package/lib/models.js.map +1 -1
- package/lib/request-cache.d.ts +4 -0
- package/lib/request-cache.js +4 -0
- package/lib/request-cache.js.map +1 -1
- package/lib/resource.service.js.map +1 -1
- package/lib/rest-headers.js +8 -0
- package/lib/rest-headers.js.map +1 -1
- package/lib/rest-request.js +10 -6
- package/lib/rest-request.js.map +1 -1
- package/lib/rest.class.js +6 -2
- package/lib/rest.class.js.map +1 -1
- package/package.json +5 -5
- package/tmp-environment.json +40 -35
- package/websql/esm2020/lib/models.mjs +43 -20
- package/websql/esm2020/lib/request-cache.mjs +5 -1
- package/websql/esm2020/lib/resource.service.mjs +1 -1
- package/websql/esm2020/lib/rest-headers.mjs +1 -1
- package/websql/esm2020/lib/rest-request.mjs +6 -5
- package/websql/esm2020/lib/rest.class.mjs +6 -3
- package/websql/fesm2015/ng2-rest.mjs +55 -25
- package/websql/fesm2015/ng2-rest.mjs.map +1 -1
- package/websql/fesm2020/ng2-rest.mjs +55 -25
- package/websql/fesm2020/ng2-rest.mjs.map +1 -1
- package/websql/lib/models.d.ts +8 -6
- package/websql/lib/request-cache.d.ts +4 -0
|
@@ -756,9 +756,11 @@ class Rest {
|
|
|
756
756
|
get headers() {
|
|
757
757
|
return this._headers;
|
|
758
758
|
}
|
|
759
|
-
req(method,
|
|
759
|
+
req(method, requestBody, params, doNotSerializeParams = false, isArray = false) {
|
|
760
760
|
const modelUrl = this.creatUrl(params, doNotSerializeParams);
|
|
761
|
-
const body =
|
|
761
|
+
const body = (CLASS.getNameFromObject(requestBody) === 'FormData')
|
|
762
|
+
? requestBody
|
|
763
|
+
: (requestBody ? JSON.stringify(requestBody) : void 0);
|
|
762
764
|
if (this.customContentType) {
|
|
763
765
|
const customHeaderKeys = this.customContentType.keys();
|
|
764
766
|
const currentHeaderKeys = this._headers.keys();
|
|
@@ -834,6 +836,10 @@ class Cookie {
|
|
|
834
836
|
({}); // @--end-of-file-for-module=ng2-rest lib/cookie.ts
|
|
835
837
|
|
|
836
838
|
const log$2 = Log.create('request-cache', Level.__NOTHING);
|
|
839
|
+
/**
|
|
840
|
+
* @deprecated
|
|
841
|
+
* there is Cache API for that
|
|
842
|
+
*/
|
|
837
843
|
class RequestCache {
|
|
838
844
|
constructor(response) {
|
|
839
845
|
this.response = response;
|
|
@@ -951,39 +957,50 @@ var Models;
|
|
|
951
957
|
}
|
|
952
958
|
Models.BaseBody = BaseBody;
|
|
953
959
|
class HttpBody extends BaseBody {
|
|
954
|
-
constructor(
|
|
960
|
+
constructor(responseText, isArray = false, entity, circular) {
|
|
955
961
|
super();
|
|
956
|
-
this.
|
|
962
|
+
this.responseText = responseText;
|
|
957
963
|
this.isArray = isArray;
|
|
958
964
|
this.entity = entity;
|
|
959
965
|
this.circular = circular;
|
|
960
966
|
}
|
|
967
|
+
get blob() {
|
|
968
|
+
return this.responseText;
|
|
969
|
+
}
|
|
961
970
|
get booleanValue() {
|
|
962
|
-
|
|
971
|
+
if (!isBlob(this.responseText)) {
|
|
972
|
+
return ['ok', 'true'].includes(this.responseText.trim());
|
|
973
|
+
}
|
|
963
974
|
}
|
|
964
975
|
get rawJson() {
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
976
|
+
if (!isBlob(this.responseText)) {
|
|
977
|
+
let res = this.toJSON(this.responseText, this.isArray);
|
|
978
|
+
if (this.circular && Array.isArray(this.circular)) {
|
|
979
|
+
res = JSON10.parse(JSON.stringify(res), this.circular);
|
|
980
|
+
}
|
|
981
|
+
return res;
|
|
968
982
|
}
|
|
969
|
-
return res;
|
|
970
983
|
}
|
|
971
984
|
get json() {
|
|
972
|
-
if (this.
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
985
|
+
if (!isBlob(this.responseText)) {
|
|
986
|
+
if (this.entity && typeof this.entity === 'function') {
|
|
987
|
+
return this.entity(); // @LAST
|
|
988
|
+
}
|
|
989
|
+
if (this.entity && typeof this.entity === 'object') {
|
|
990
|
+
const json = this.toJSON(this.responseText, this.isArray);
|
|
991
|
+
return Mapping.encode(json, this.entity, this.circular);
|
|
992
|
+
}
|
|
993
|
+
let res = this.toJSON(this.responseText, this.isArray);
|
|
994
|
+
if (this.circular && Array.isArray(this.circular)) {
|
|
995
|
+
res = JSON10.parse(JSON.stringify(res), this.circular);
|
|
996
|
+
}
|
|
997
|
+
return res;
|
|
982
998
|
}
|
|
983
|
-
return res;
|
|
984
999
|
}
|
|
985
1000
|
get text() {
|
|
986
|
-
|
|
1001
|
+
if (!isBlob(this.responseText)) {
|
|
1002
|
+
return this.responseText.replace(/^\"/, '').replace(/\"$/, '');
|
|
1003
|
+
}
|
|
987
1004
|
}
|
|
988
1005
|
}
|
|
989
1006
|
Models.HttpBody = HttpBody;
|
|
@@ -1058,7 +1075,19 @@ var Models;
|
|
|
1058
1075
|
}
|
|
1059
1076
|
}
|
|
1060
1077
|
Models.HttpResponseError = HttpResponseError;
|
|
1078
|
+
/* */
|
|
1079
|
+
/* */
|
|
1080
|
+
/* */
|
|
1081
|
+
/* */
|
|
1082
|
+
/* */
|
|
1083
|
+
/* */
|
|
1061
1084
|
})(Models || (Models = {}));
|
|
1085
|
+
function isBlob(maybeBlob) {
|
|
1086
|
+
if (typeof Blob === 'undefined') { // OK because there is no Blob in node
|
|
1087
|
+
return false;
|
|
1088
|
+
}
|
|
1089
|
+
return maybeBlob instanceof Blob; // || toString.call(maybeBlob) === '[object Blob]';
|
|
1090
|
+
}
|
|
1062
1091
|
;
|
|
1063
1092
|
({}); // @--end-of-file-for-module=ng2-rest lib/models.ts
|
|
1064
1093
|
|
|
@@ -1100,7 +1129,6 @@ class RestRequest {
|
|
|
1100
1129
|
checkCache(sourceRequest, jobid) {
|
|
1101
1130
|
const existedInCache = RequestCache.findBy(sourceRequest);
|
|
1102
1131
|
if (existedInCache) {
|
|
1103
|
-
log$1.i('cache exists', existedInCache);
|
|
1104
1132
|
const success = Resource['_listenSuccess'];
|
|
1105
1133
|
success.next(existedInCache.response);
|
|
1106
1134
|
this.subjectInuUse[jobid].next(existedInCache);
|
|
@@ -1143,14 +1171,16 @@ class RestRequest {
|
|
|
1143
1171
|
};
|
|
1144
1172
|
}
|
|
1145
1173
|
}
|
|
1174
|
+
const headersJson = headers.toJSON();
|
|
1175
|
+
const responseType = headersJson.responsetypeaxios ? headersJson.responsetypeaxios : 'text';
|
|
1146
1176
|
try {
|
|
1147
1177
|
if (!response) {
|
|
1148
1178
|
response = await axios({
|
|
1149
1179
|
url,
|
|
1150
1180
|
method,
|
|
1151
1181
|
data: body,
|
|
1152
|
-
responseType
|
|
1153
|
-
headers:
|
|
1182
|
+
responseType,
|
|
1183
|
+
headers: headersJson,
|
|
1154
1184
|
cancelToken: source.token,
|
|
1155
1185
|
});
|
|
1156
1186
|
}
|
|
@@ -1160,7 +1190,7 @@ class RestRequest {
|
|
|
1160
1190
|
this.handlerResult({
|
|
1161
1191
|
res: {
|
|
1162
1192
|
code: response.status,
|
|
1163
|
-
data:
|
|
1193
|
+
data: response.data,
|
|
1164
1194
|
isArray,
|
|
1165
1195
|
jobid,
|
|
1166
1196
|
headers: RestHeaders.from(response.headers)
|