ng2-rest 21.0.15 → 21.0.18
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/browser/fesm2022/ng2-rest-browser.mjs +3 -5
- package/browser/fesm2022/ng2-rest-browser.mjs.map +1 -1
- package/browser/package.json +1 -1
- package/browser/types/ng2-rest-browser.d.ts +2 -8
- package/browser-prod/fesm2022/ng2-rest-browser.mjs +376 -393
- package/browser-prod/fesm2022/ng2-rest-browser.mjs.map +1 -1
- package/browser-prod/package.json +23 -0
- package/browser-prod/types/ng2-rest-browser.d.ts +194 -204
- package/browser-prod.split-namespaces.json +72 -0
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/models.d.ts +2 -8
- package/lib/models.js +2 -4
- package/lib/models.js.map +1 -1
- package/lib/package.json +4 -0
- package/lib/rest-request.js.map +1 -1
- package/lib/rest.class.js +0 -1
- package/lib/rest.class.js.map +1 -1
- package/lib-prod/build-info._auto-generated_.d.ts +1 -1
- package/lib-prod/build-info._auto-generated_.js +1 -1
- package/lib-prod/helpers.d.ts +3 -3
- package/lib-prod/helpers.js +2 -2
- package/lib-prod/helpers.js.map +1 -1
- package/lib-prod/mapping.d.ts +10 -12
- package/lib-prod/mapping.js +238 -240
- package/lib-prod/mapping.js.map +1 -1
- package/lib-prod/models.d.ts +141 -149
- package/lib-prod/models.js +153 -160
- package/lib-prod/models.js.map +1 -1
- package/lib-prod/other/simple-resource.d.ts +11 -11
- package/lib-prod/other/simple-resource.js.map +1 -1
- package/lib-prod/package.json +4 -0
- package/lib-prod/params.d.ts +2 -2
- package/lib-prod/params.js.map +1 -1
- package/lib-prod/resource-service.d.ts +7 -7
- package/lib-prod/resource-service.js.map +1 -1
- package/lib-prod/rest-request.d.ts +8 -8
- package/lib-prod/rest-request.js +3 -3
- package/lib-prod/rest-request.js.map +1 -1
- package/lib-prod/rest.class.d.ts +18 -18
- package/lib-prod/rest.class.js +0 -1
- package/lib-prod/rest.class.js.map +1 -1
- package/lib-prod.split-namespaces.json +72 -0
- package/package.json +1 -1
- package/websql/fesm2022/ng2-rest-websql.mjs +3 -5
- package/websql/fesm2022/ng2-rest-websql.mjs.map +1 -1
- package/websql/package.json +1 -1
- package/websql/types/ng2-rest-websql.d.ts +2 -8
- package/websql-prod/fesm2022/ng2-rest-websql.mjs +376 -393
- package/websql-prod/fesm2022/ng2-rest-websql.mjs.map +1 -1
- package/websql-prod/package.json +23 -0
- package/websql-prod/types/ng2-rest-websql.d.ts +194 -204
- package/websql-prod.split-namespaces.json +72 -0
- package/lib/request-cache.d.ts +0 -18
- package/lib/request-cache.js +0 -118
- package/lib/request-cache.js.map +0 -1
- package/migrations/index.d.ts +0 -1
- package/migrations/index.js +0 -19
- package/migrations/index.js.map +0 -1
- package/migrations/migrations_index._auto-generated_.d.ts +0 -0
- package/migrations/migrations_index._auto-generated_.js +0 -4
- package/migrations/migrations_index._auto-generated_.js.map +0 -1
- package/tmp-environment.json +0 -43
package/lib-prod/models.d.ts
CHANGED
|
@@ -3,10 +3,9 @@ import { AxiosRequestConfig } from 'axios';
|
|
|
3
3
|
import { Circ } from 'json10/lib-prod';
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
5
|
import { Subject } from 'rxjs';
|
|
6
|
-
import {
|
|
7
|
-
import { Models as HelpersModels } from 'typescript-class-helpers/lib-prod';
|
|
6
|
+
import { CoreModels__NS__HttpMethod } from 'tnp-core/lib-prod';
|
|
8
7
|
import { Cookie } from './cookie';
|
|
9
|
-
import {
|
|
8
|
+
import { Mapping__NS__Mapping } from './mapping';
|
|
10
9
|
import { RestHeaders } from './rest-headers';
|
|
11
10
|
import { Rest } from './rest.class';
|
|
12
11
|
declare class RestCommonHttpResponseWrapper {
|
|
@@ -30,157 +29,150 @@ export declare class RestErrorResponseWrapper extends RestCommonHttpResponseWrap
|
|
|
30
29
|
*/
|
|
31
30
|
code?: string;
|
|
32
31
|
}
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
doNotSerializeParams?: boolean;
|
|
68
|
-
} & AxiosRequestConfig<any>;
|
|
69
|
-
type MethodWithBody<E, T, R = PromiseObservableMix<E>> = (item?: T, params?: UrlParams[], axiosOptions?: Ng2RestAxiosRequestConfig) => R;
|
|
70
|
-
type ReplayData = {
|
|
71
|
-
subject: Subject<any>;
|
|
72
|
-
data: {
|
|
73
|
-
url: string;
|
|
74
|
-
body: string;
|
|
75
|
-
headers: RestHeaders;
|
|
76
|
-
isArray: boolean;
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* jobid
|
|
80
|
-
*/
|
|
81
|
-
id: number;
|
|
82
|
-
};
|
|
83
|
-
type ReqParams = {
|
|
32
|
+
export interface Models__NS__HandleResultOptions {
|
|
33
|
+
res: Models__NS__MockResponse;
|
|
34
|
+
method: CoreModels__NS__HttpMethod;
|
|
35
|
+
jobid?: number;
|
|
36
|
+
isArray?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface Models__NS__HandleResultSourceRequestOptions {
|
|
39
|
+
url: string;
|
|
40
|
+
method: CoreModels__NS__HttpMethod;
|
|
41
|
+
body: any;
|
|
42
|
+
isArray: boolean;
|
|
43
|
+
}
|
|
44
|
+
export type Models__NS__BackendError = {
|
|
45
|
+
msg?: string;
|
|
46
|
+
stack?: string[];
|
|
47
|
+
data: any;
|
|
48
|
+
};
|
|
49
|
+
export type Models__NS__MetaRequest = {
|
|
50
|
+
path: string;
|
|
51
|
+
endpoint: string;
|
|
52
|
+
entity: Mapping__NS__Mapping;
|
|
53
|
+
circular: Circ[];
|
|
54
|
+
};
|
|
55
|
+
export type Models__NS__HttpCode = 200 | 400 | 401 | 404 | 500;
|
|
56
|
+
export type Models__NS__PromiseObservableMix<T> = Promise<T> & {
|
|
57
|
+
observable: Observable<T>;
|
|
58
|
+
};
|
|
59
|
+
export type Models__NS__Ng2RestAxiosRequestConfig = {
|
|
60
|
+
doNotSerializeParams?: boolean;
|
|
61
|
+
} & AxiosRequestConfig<any>;
|
|
62
|
+
export type Models__NS__MethodWithBody<E, T, R = Models__NS__PromiseObservableMix<E>> = (item?: T, params?: Models__NS__UrlParams[], axiosOptions?: Models__NS__Ng2RestAxiosRequestConfig) => R;
|
|
63
|
+
export type Models__NS__ReplayData = {
|
|
64
|
+
subject: Subject<any>;
|
|
65
|
+
data: {
|
|
84
66
|
url: string;
|
|
85
|
-
|
|
86
|
-
headers?: RestHeaders;
|
|
87
|
-
body?: any;
|
|
88
|
-
jobid: number;
|
|
89
|
-
isArray: boolean;
|
|
90
|
-
};
|
|
91
|
-
interface ResourceModel<A, TA> {
|
|
92
|
-
model: (pathModels?: Object, responseObjectType?: Function) => Rest<A, TA>;
|
|
67
|
+
body: string;
|
|
93
68
|
headers: RestHeaders;
|
|
94
|
-
}
|
|
95
|
-
interface Ng2RestMethods<E, T> {
|
|
96
|
-
get: MethodWithBody<E, T>;
|
|
97
|
-
post: MethodWithBody<E, T>;
|
|
98
|
-
put: MethodWithBody<E, T>;
|
|
99
|
-
patch: MethodWithBody<E, T>;
|
|
100
|
-
head: MethodWithBody<E, T>;
|
|
101
|
-
delete: MethodWithBody<E, T>;
|
|
102
|
-
jsonp: MethodWithBody<E, T>;
|
|
103
|
-
}
|
|
104
|
-
type MockController = (url: string, method: CoreModels.HttpMethod, headers?: RestHeaders, body?: any) => MockResponse;
|
|
105
|
-
type MockHttp = MockResponse | MockController;
|
|
106
|
-
interface FnMethodsHttp<T, TA> extends Ng2RestMethods<HttpResponse<T>, T> {
|
|
107
|
-
array: Ng2RestMethods<HttpResponse<TA>, TA>;
|
|
108
|
-
}
|
|
109
|
-
interface FnMethodsHttpWithMock<T, TA> extends Ng2RestMethods<HttpResponse<T>, T> {
|
|
110
|
-
array: Ng2RestMethods<HttpResponse<TA>, TA>;
|
|
111
|
-
}
|
|
112
|
-
interface NestedParams {
|
|
113
|
-
[params: string]: string;
|
|
114
|
-
}
|
|
115
|
-
interface UrlParams {
|
|
116
|
-
[urlModelName: string]: string | number | boolean | RegExp | Object;
|
|
117
|
-
regex?: RegExp;
|
|
118
|
-
}
|
|
119
|
-
abstract class BaseBody {
|
|
120
|
-
protected toJSON(data: any, opt: {
|
|
121
|
-
isJSONArray?: boolean;
|
|
122
|
-
parsingError?: boolean;
|
|
123
|
-
}): object | undefined;
|
|
124
|
-
}
|
|
125
|
-
class HttpBody<T> extends BaseBody {
|
|
126
|
-
private responseText;
|
|
127
|
-
private isArray;
|
|
128
|
-
private entity;
|
|
129
|
-
private circular;
|
|
130
|
-
constructor(responseText: string | Blob, isArray: boolean, entity: Mapping.Mapping, circular: Circ[]);
|
|
131
|
-
get blob(): Blob;
|
|
132
|
-
get booleanValue(): boolean | undefined;
|
|
133
|
-
get numericValue(): number | undefined;
|
|
134
|
-
get rawJson(): Partial<T>;
|
|
135
|
-
get json(): T;
|
|
136
|
-
/**
|
|
137
|
-
* undefined when blob
|
|
138
|
-
*/
|
|
139
|
-
get text(): string | undefined;
|
|
140
|
-
}
|
|
141
|
-
class ErrorBody<T = RestErrorResponseWrapper> extends BaseBody {
|
|
142
|
-
private data;
|
|
143
|
-
constructor(data: any);
|
|
144
|
-
get json(): T;
|
|
145
|
-
get text(): string;
|
|
146
|
-
}
|
|
147
|
-
abstract class BaseResponse<T> {
|
|
148
|
-
responseText?: string | Blob;
|
|
149
|
-
readonly headers?: RestHeaders;
|
|
150
|
-
readonly statusCode?: HttpCode | number;
|
|
151
|
-
isArray: boolean;
|
|
152
|
-
protected static readonly cookies: Cookie;
|
|
153
|
-
get cookies(): Cookie;
|
|
154
|
-
constructor(responseText?: string | Blob, headers?: RestHeaders, statusCode?: HttpCode | number, isArray?: boolean);
|
|
155
|
-
}
|
|
156
|
-
class HttpResponse<T> extends BaseResponse<T> {
|
|
157
|
-
sourceRequest: Models.HandleResultSourceRequestOptions;
|
|
158
|
-
responseText?: string | Blob;
|
|
159
|
-
headers?: RestHeaders;
|
|
160
|
-
statusCode?: HttpCode | number;
|
|
161
|
-
entity?: Mapping.Mapping | Function;
|
|
162
|
-
circular?: Circ[];
|
|
163
|
-
jobid?: number;
|
|
164
69
|
isArray: boolean;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* jobid
|
|
73
|
+
*/
|
|
74
|
+
id: number;
|
|
75
|
+
};
|
|
76
|
+
export type Models__NS__ReqParams = {
|
|
77
|
+
url: string;
|
|
78
|
+
method: CoreModels__NS__HttpMethod;
|
|
79
|
+
headers?: RestHeaders;
|
|
80
|
+
body?: any;
|
|
81
|
+
jobid: number;
|
|
82
|
+
isArray: boolean;
|
|
83
|
+
};
|
|
84
|
+
export interface Models__NS__ResourceModel<A, TA> {
|
|
85
|
+
model: (pathModels?: Object, responseObjectType?: Function) => Rest<A, TA>;
|
|
86
|
+
headers: RestHeaders;
|
|
87
|
+
}
|
|
88
|
+
export interface Models__NS__Ng2RestMethods<E, T> {
|
|
89
|
+
get: Models__NS__MethodWithBody<E, T>;
|
|
90
|
+
post: Models__NS__MethodWithBody<E, T>;
|
|
91
|
+
put: Models__NS__MethodWithBody<E, T>;
|
|
92
|
+
patch: Models__NS__MethodWithBody<E, T>;
|
|
93
|
+
head: Models__NS__MethodWithBody<E, T>;
|
|
94
|
+
delete: Models__NS__MethodWithBody<E, T>;
|
|
95
|
+
jsonp: Models__NS__MethodWithBody<E, T>;
|
|
96
|
+
}
|
|
97
|
+
export type Models__NS__MockController = (url: string, method: CoreModels__NS__HttpMethod, headers?: RestHeaders, body?: any) => Models__NS__MockResponse;
|
|
98
|
+
export type Models__NS__MockHttp = Models__NS__MockResponse | Models__NS__MockController;
|
|
99
|
+
export interface Models__NS__FnMethodsHttp<T, TA> extends Models__NS__Ng2RestMethods<Models__NS__HttpResponse<T>, T> {
|
|
100
|
+
array: Models__NS__Ng2RestMethods<Models__NS__HttpResponse<TA>, TA>;
|
|
101
|
+
}
|
|
102
|
+
export interface Models__NS__FnMethodsHttpWithMock<T, TA> extends Models__NS__Ng2RestMethods<Models__NS__HttpResponse<T>, T> {
|
|
103
|
+
array: Models__NS__Ng2RestMethods<Models__NS__HttpResponse<TA>, TA>;
|
|
104
|
+
}
|
|
105
|
+
export interface Models__NS__NestedParams {
|
|
106
|
+
[params: string]: string;
|
|
107
|
+
}
|
|
108
|
+
export interface Models__NS__UrlParams {
|
|
109
|
+
[urlModelName: string]: string | number | boolean | RegExp | Object;
|
|
110
|
+
regex?: RegExp;
|
|
111
|
+
}
|
|
112
|
+
export declare abstract class Models__NS__BaseBody {
|
|
113
|
+
protected toJSON(data: any, opt: {
|
|
114
|
+
isJSONArray?: boolean;
|
|
115
|
+
parsingError?: boolean;
|
|
116
|
+
}): object | undefined;
|
|
117
|
+
}
|
|
118
|
+
export declare class Models__NS__HttpBody<T> extends Models__NS__BaseBody {
|
|
119
|
+
private responseText;
|
|
120
|
+
private isArray;
|
|
121
|
+
private entity;
|
|
122
|
+
private circular;
|
|
123
|
+
constructor(responseText: string | Blob, isArray: boolean, entity: Mapping__NS__Mapping, circular: Circ[]);
|
|
124
|
+
get blob(): Blob;
|
|
125
|
+
get booleanValue(): boolean | undefined;
|
|
126
|
+
get numericValue(): number | undefined;
|
|
127
|
+
get rawJson(): Partial<T>;
|
|
128
|
+
get json(): T;
|
|
129
|
+
/**
|
|
130
|
+
* undefined when blob
|
|
131
|
+
*/
|
|
132
|
+
get text(): string | undefined;
|
|
133
|
+
}
|
|
134
|
+
export declare class Models__NS__ErrorBody<T = RestErrorResponseWrapper> extends Models__NS__BaseBody {
|
|
135
|
+
private data;
|
|
136
|
+
constructor(data: any);
|
|
137
|
+
get json(): T;
|
|
138
|
+
get text(): string;
|
|
139
|
+
}
|
|
140
|
+
export declare abstract class Models__NS__BaseResponse<T> {
|
|
141
|
+
responseText?: string | Blob;
|
|
142
|
+
readonly headers?: RestHeaders;
|
|
143
|
+
readonly statusCode?: Models__NS__HttpCode | number;
|
|
144
|
+
isArray: boolean;
|
|
145
|
+
protected static readonly cookies: Cookie;
|
|
146
|
+
get cookies(): Cookie;
|
|
147
|
+
constructor(responseText?: string | Blob, headers?: RestHeaders, statusCode?: Models__NS__HttpCode | number, isArray?: boolean);
|
|
148
|
+
}
|
|
149
|
+
export declare class Models__NS__HttpResponse<T> extends Models__NS__BaseResponse<T> {
|
|
150
|
+
sourceRequest: Models__NS__HandleResultSourceRequestOptions;
|
|
151
|
+
responseText?: string | Blob;
|
|
152
|
+
headers?: RestHeaders;
|
|
153
|
+
statusCode?: Models__NS__HttpCode | number;
|
|
154
|
+
entity?: Mapping__NS__Mapping | Function;
|
|
155
|
+
circular?: Circ[];
|
|
156
|
+
jobid?: number;
|
|
157
|
+
isArray: boolean;
|
|
158
|
+
body: Models__NS__HttpBody<T>;
|
|
159
|
+
constructor(sourceRequest: Models__NS__HandleResultSourceRequestOptions, responseText?: string | Blob, headers?: RestHeaders, statusCode?: Models__NS__HttpCode | number, entity?: Mapping__NS__Mapping | Function, circular?: Circ[], jobid?: number, isArray?: boolean);
|
|
160
|
+
init(): void;
|
|
161
|
+
}
|
|
162
|
+
export interface Models__NS__MockResponse {
|
|
163
|
+
data?: any;
|
|
164
|
+
code?: Models__NS__HttpCode;
|
|
165
|
+
error?: string;
|
|
166
|
+
headers?: RestHeaders;
|
|
167
|
+
jobid?: number;
|
|
168
|
+
isArray: boolean;
|
|
178
169
|
}
|
|
179
|
-
export
|
|
170
|
+
export type Models__NS__ResponseTypeAxios = 'blob' | 'text' | 'arraybuffer' | 'document' | 'stream';
|
|
171
|
+
export declare class HttpResponseError<ERROR_BODY = object> extends Models__NS__BaseResponse<any> {
|
|
180
172
|
message: string;
|
|
181
173
|
jobid?: number;
|
|
182
|
-
sourceRequest?:
|
|
183
|
-
readonly body:
|
|
184
|
-
constructor(message: string, responseText?: string, headers?: RestHeaders, statusCode?:
|
|
174
|
+
sourceRequest?: Models__NS__HandleResultSourceRequestOptions;
|
|
175
|
+
readonly body: Models__NS__ErrorBody<ERROR_BODY>;
|
|
176
|
+
constructor(message: string, responseText?: string, headers?: RestHeaders, statusCode?: Models__NS__HttpCode | number, jobid?: number, sourceRequest?: Models__NS__HandleResultSourceRequestOptions);
|
|
185
177
|
}
|
|
186
178
|
export {};
|
package/lib-prod/models.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpResponseError = exports.
|
|
3
|
+
exports.HttpResponseError = exports.Models__NS__HttpResponse = exports.Models__NS__BaseResponse = exports.Models__NS__ErrorBody = exports.Models__NS__HttpBody = exports.Models__NS__BaseBody = exports.RestErrorResponseWrapper = exports.RestResponseWrapper = void 0;
|
|
4
4
|
const lib_prod_1 = require("json10/lib-prod");
|
|
5
5
|
const lib_prod_2 = require("tnp-core/lib-prod");
|
|
6
6
|
const lib_prod_3 = require("tnp-core/lib-prod");
|
|
7
7
|
const lib_prod_4 = require("tnp-core/lib-prod");
|
|
8
|
-
const lib_prod_5 = require("typescript-class-helpers/lib-prod");
|
|
9
8
|
const cookie_1 = require("./cookie");
|
|
10
9
|
const mapping_1 = require("./mapping");
|
|
11
10
|
class RestCommonHttpResponseWrapper {
|
|
@@ -16,186 +15,180 @@ exports.RestResponseWrapper = RestResponseWrapper;
|
|
|
16
15
|
class RestErrorResponseWrapper extends RestCommonHttpResponseWrapper {
|
|
17
16
|
}
|
|
18
17
|
exports.RestErrorResponseWrapper = RestErrorResponseWrapper;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
let r = opt.isJSONArray ? [] : {};
|
|
30
|
-
if (typeof data === 'string') {
|
|
31
|
-
try {
|
|
32
|
-
let parsed = JSON.parse(data);
|
|
33
|
-
if (typeof parsed === 'string' && parsed.trim().startsWith('{')) {
|
|
34
|
-
parsed = JSON.parse(parsed);
|
|
35
|
-
}
|
|
36
|
-
if (opt.parsingError && parsed[lib_prod_3.CoreModels.TaonHttpErrorCustomProp]) {
|
|
37
|
-
return lib_prod_2._.merge(new RestErrorResponseWrapper(), parsed);
|
|
38
|
-
}
|
|
39
|
-
return parsed;
|
|
18
|
+
[];
|
|
19
|
+
class Models__NS__BaseBody {
|
|
20
|
+
toJSON(data, opt) {
|
|
21
|
+
opt = opt || { isJSONArray: false };
|
|
22
|
+
let r = opt.isJSONArray ? [] : {};
|
|
23
|
+
if (typeof data === 'string') {
|
|
24
|
+
try {
|
|
25
|
+
let parsed = JSON.parse(data);
|
|
26
|
+
if (typeof parsed === 'string' && parsed.trim().startsWith('{')) {
|
|
27
|
+
parsed = JSON.parse(parsed);
|
|
40
28
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return
|
|
29
|
+
if (opt.parsingError && parsed[lib_prod_3.CoreModels__NS__TaonHttpErrorCustomProp]) {
|
|
30
|
+
return lib_prod_2._.merge(new RestErrorResponseWrapper(), parsed);
|
|
31
|
+
}
|
|
32
|
+
return parsed;
|
|
45
33
|
}
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
Models.BaseBody = BaseBody;
|
|
50
|
-
class HttpBody extends BaseBody {
|
|
51
|
-
responseText;
|
|
52
|
-
isArray;
|
|
53
|
-
entity;
|
|
54
|
-
circular;
|
|
55
|
-
constructor(responseText, isArray = false, entity, circular) {
|
|
56
|
-
super();
|
|
57
|
-
this.responseText = responseText;
|
|
58
|
-
this.isArray = isArray;
|
|
59
|
-
this.entity = entity;
|
|
60
|
-
this.circular = circular;
|
|
61
|
-
}
|
|
62
|
-
get blob() {
|
|
63
|
-
return this.responseText;
|
|
34
|
+
catch (e) { }
|
|
64
35
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return ['ok', 'true'].includes(this.responseText?.trim());
|
|
68
|
-
}
|
|
36
|
+
else if (typeof data === 'object') {
|
|
37
|
+
return data;
|
|
69
38
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
39
|
+
return r;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.Models__NS__BaseBody = Models__NS__BaseBody;
|
|
43
|
+
class Models__NS__HttpBody extends Models__NS__BaseBody {
|
|
44
|
+
responseText;
|
|
45
|
+
isArray;
|
|
46
|
+
entity;
|
|
47
|
+
circular;
|
|
48
|
+
constructor(responseText, isArray = false, entity, circular) {
|
|
49
|
+
super();
|
|
50
|
+
this.responseText = responseText;
|
|
51
|
+
this.isArray = isArray;
|
|
52
|
+
this.entity = entity;
|
|
53
|
+
this.circular = circular;
|
|
54
|
+
}
|
|
55
|
+
get blob() {
|
|
56
|
+
return this.responseText;
|
|
57
|
+
}
|
|
58
|
+
get booleanValue() {
|
|
59
|
+
if (!lib_prod_4.Helpers.isBlob(this.responseText)) {
|
|
60
|
+
return ['ok', 'true'].includes(this.responseText?.trim());
|
|
74
61
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
res = lib_prod_1.JSON10.parse(JSON.stringify(res), this.circular);
|
|
80
|
-
}
|
|
81
|
-
return res;
|
|
82
|
-
}
|
|
62
|
+
}
|
|
63
|
+
get numericValue() {
|
|
64
|
+
if (!lib_prod_4.Helpers.isBlob(this.responseText)) {
|
|
65
|
+
return Number(this.responseText?.trim());
|
|
83
66
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return void 0;
|
|
88
|
-
}
|
|
89
|
-
if (this.entity && typeof this.entity === 'function') {
|
|
90
|
-
return this.entity(); // @LAST
|
|
91
|
-
}
|
|
92
|
-
if (this.entity && typeof this.entity === 'object') {
|
|
93
|
-
const json = this.toJSON(this.responseText, {
|
|
94
|
-
isJSONArray: this.isArray,
|
|
95
|
-
});
|
|
96
|
-
return mapping_1.Mapping.encode(json, this.entity, this.circular);
|
|
97
|
-
}
|
|
67
|
+
}
|
|
68
|
+
get rawJson() {
|
|
69
|
+
if (!lib_prod_4.Helpers.isBlob(this.responseText)) {
|
|
98
70
|
let res = this.toJSON(this.responseText, { isJSONArray: this.isArray });
|
|
99
71
|
if (this.circular && Array.isArray(this.circular)) {
|
|
100
72
|
res = lib_prod_1.JSON10.parse(JSON.stringify(res), this.circular);
|
|
101
73
|
}
|
|
102
74
|
return res;
|
|
103
75
|
}
|
|
104
|
-
/**
|
|
105
|
-
* undefined when blob
|
|
106
|
-
*/
|
|
107
|
-
get text() {
|
|
108
|
-
if (!lib_prod_4.Helpers.isBlob(this.responseText)) {
|
|
109
|
-
return this.responseText
|
|
110
|
-
.replace(/^\"/, '')
|
|
111
|
-
.replace(/\"$/, '');
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
76
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
super();
|
|
120
|
-
this.data = data;
|
|
121
|
-
}
|
|
122
|
-
get json() {
|
|
123
|
-
return this.toJSON(this.data, { parsingError: true });
|
|
77
|
+
get json() {
|
|
78
|
+
const isBlob = lib_prod_4.Helpers.isBlob(this.responseText);
|
|
79
|
+
if (isBlob) {
|
|
80
|
+
return void 0;
|
|
124
81
|
}
|
|
125
|
-
|
|
126
|
-
return this.
|
|
82
|
+
if (this.entity && typeof this.entity === 'function') {
|
|
83
|
+
return this.entity(); // @LAST
|
|
127
84
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
statusCode;
|
|
134
|
-
isArray;
|
|
135
|
-
static cookies = cookie_1.Cookie.Instance;
|
|
136
|
-
get cookies() {
|
|
137
|
-
return BaseResponse.cookies;
|
|
85
|
+
if (this.entity && typeof this.entity === 'object') {
|
|
86
|
+
const json = this.toJSON(this.responseText, {
|
|
87
|
+
isJSONArray: this.isArray,
|
|
88
|
+
});
|
|
89
|
+
return (0, mapping_1.Mapping__NS__encode)(json, this.entity, this.circular);
|
|
138
90
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
this.statusCode = statusCode;
|
|
143
|
-
this.isArray = isArray;
|
|
91
|
+
let res = this.toJSON(this.responseText, { isJSONArray: this.isArray });
|
|
92
|
+
if (this.circular && Array.isArray(this.circular)) {
|
|
93
|
+
res = lib_prod_1.JSON10.parse(JSON.stringify(res), this.circular);
|
|
144
94
|
}
|
|
95
|
+
return res;
|
|
145
96
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
jobid;
|
|
155
|
-
isArray;
|
|
156
|
-
body;
|
|
157
|
-
// public readonly TOTAL_COUNT_HEADER = 'X-Total-Count'.toLowerCase();
|
|
158
|
-
// public get totalElements(): number {
|
|
159
|
-
// return Number(this.headers.get(this.TOTAL_COUNT_HEADER));
|
|
160
|
-
// }
|
|
161
|
-
constructor(sourceRequest, responseText, headers, statusCode, entity, circular, jobid, isArray = false) {
|
|
162
|
-
// console.log({
|
|
163
|
-
// sourceRequest, responseText, headers, statusCode, entity, circular, jobid, isArray
|
|
164
|
-
// })
|
|
165
|
-
super(responseText, headers, statusCode, isArray);
|
|
166
|
-
this.sourceRequest = sourceRequest;
|
|
167
|
-
this.responseText = responseText;
|
|
168
|
-
this.headers = headers;
|
|
169
|
-
this.statusCode = statusCode;
|
|
170
|
-
this.entity = entity;
|
|
171
|
-
this.circular = circular;
|
|
172
|
-
this.jobid = jobid;
|
|
173
|
-
this.isArray = isArray;
|
|
174
|
-
this.init();
|
|
97
|
+
/**
|
|
98
|
+
* undefined when blob
|
|
99
|
+
*/
|
|
100
|
+
get text() {
|
|
101
|
+
if (!lib_prod_4.Helpers.isBlob(this.responseText)) {
|
|
102
|
+
return this.responseText
|
|
103
|
+
.replace(/^\"/, '')
|
|
104
|
+
.replace(/\"$/, '');
|
|
175
105
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.Models__NS__HttpBody = Models__NS__HttpBody;
|
|
109
|
+
class Models__NS__ErrorBody extends Models__NS__BaseBody {
|
|
110
|
+
data;
|
|
111
|
+
constructor(data) {
|
|
112
|
+
super();
|
|
113
|
+
this.data = data;
|
|
114
|
+
}
|
|
115
|
+
get json() {
|
|
116
|
+
return this.toJSON(this.data, { parsingError: true });
|
|
117
|
+
}
|
|
118
|
+
get text() {
|
|
119
|
+
return this.data;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.Models__NS__ErrorBody = Models__NS__ErrorBody;
|
|
123
|
+
class Models__NS__BaseResponse {
|
|
124
|
+
responseText;
|
|
125
|
+
headers;
|
|
126
|
+
statusCode;
|
|
127
|
+
isArray;
|
|
128
|
+
static cookies = cookie_1.Cookie.Instance;
|
|
129
|
+
get cookies() {
|
|
130
|
+
return Models__NS__BaseResponse.cookies;
|
|
131
|
+
}
|
|
132
|
+
constructor(responseText, headers, statusCode, isArray = false) {
|
|
133
|
+
this.responseText = responseText;
|
|
134
|
+
this.headers = headers;
|
|
135
|
+
this.statusCode = statusCode;
|
|
136
|
+
this.isArray = isArray;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.Models__NS__BaseResponse = Models__NS__BaseResponse;
|
|
140
|
+
class Models__NS__HttpResponse extends Models__NS__BaseResponse {
|
|
141
|
+
sourceRequest;
|
|
142
|
+
responseText;
|
|
143
|
+
headers;
|
|
144
|
+
statusCode;
|
|
145
|
+
entity;
|
|
146
|
+
circular;
|
|
147
|
+
jobid;
|
|
148
|
+
isArray;
|
|
149
|
+
body;
|
|
150
|
+
// public readonly TOTAL_COUNT_HEADER = 'X-Total-Count'.toLowerCase();
|
|
151
|
+
// public get totalElements(): number {
|
|
152
|
+
// return Number(this.headers.get(this.TOTAL_COUNT_HEADER));
|
|
153
|
+
// }
|
|
154
|
+
constructor(sourceRequest, responseText, headers, statusCode, entity, circular, jobid, isArray = false) {
|
|
155
|
+
// console.log({
|
|
156
|
+
// sourceRequest, responseText, headers, statusCode, entity, circular, jobid, isArray
|
|
157
|
+
// })
|
|
158
|
+
super(responseText, headers, statusCode, isArray);
|
|
159
|
+
this.sourceRequest = sourceRequest;
|
|
160
|
+
this.responseText = responseText;
|
|
161
|
+
this.headers = headers;
|
|
162
|
+
this.statusCode = statusCode;
|
|
163
|
+
this.entity = entity;
|
|
164
|
+
this.circular = circular;
|
|
165
|
+
this.jobid = jobid;
|
|
166
|
+
this.isArray = isArray;
|
|
167
|
+
this.init();
|
|
168
|
+
}
|
|
169
|
+
init() {
|
|
170
|
+
if (typeof this.entity === 'string') {
|
|
171
|
+
// const headerWithMapping = headers.get(entity);
|
|
172
|
+
let entityJSON = this.headers?.getAll(this.entity);
|
|
173
|
+
if (!!entityJSON) {
|
|
174
|
+
this.entity = JSON.parse(entityJSON.join());
|
|
183
175
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
176
|
+
}
|
|
177
|
+
if (typeof this.circular === 'string') {
|
|
178
|
+
// const headerWithMapping = headers.get(circular);
|
|
179
|
+
let circuralJSON = this.headers?.getAll(this.circular);
|
|
180
|
+
if (!!circuralJSON) {
|
|
181
|
+
this.circular = JSON.parse(circuralJSON.join());
|
|
190
182
|
}
|
|
191
|
-
this.body = new HttpBody(this.responseText, this.isArray, this.entity, this.circular);
|
|
192
183
|
}
|
|
184
|
+
this.body = new Models__NS__HttpBody(this.responseText, this.isArray, this.entity, this.circular);
|
|
193
185
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
186
|
+
}
|
|
187
|
+
exports.Models__NS__HttpResponse = Models__NS__HttpResponse;
|
|
188
|
+
// | 'json' - I am parsing json from text...
|
|
189
|
+
//#endregion
|
|
190
|
+
//end of namespace Models
|
|
191
|
+
class HttpResponseError extends Models__NS__BaseResponse {
|
|
199
192
|
message;
|
|
200
193
|
jobid;
|
|
201
194
|
sourceRequest;
|
|
@@ -207,7 +200,7 @@ class HttpResponseError extends Models.BaseResponse {
|
|
|
207
200
|
this.message = message;
|
|
208
201
|
this.jobid = jobid;
|
|
209
202
|
this.sourceRequest = sourceRequest;
|
|
210
|
-
this.body = new
|
|
203
|
+
this.body = new Models__NS__ErrorBody(responseText);
|
|
211
204
|
}
|
|
212
205
|
}
|
|
213
206
|
exports.HttpResponseError = HttpResponseError;
|