tscommons-esm-http 1.0.2 → 2.0.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/dist/enums/ecommons-http-content-type.d.mts +2 -1
- package/dist/enums/ecommons-http-content-type.mjs +7 -0
- package/dist/enums/ecommons-http-content-type.mjs.map +1 -1
- package/dist/helpers/http-client-internal-helpers.mjs +5 -1
- package/dist/helpers/http-client-internal-helpers.mjs.map +1 -1
- package/dist/services/commons-http-client.service.d.mts +6 -6
- package/dist/services/commons-streamable-http-client.service.d.mts +6 -6
- package/package.json +2 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare enum ECommonsHttpContentType {
|
|
2
2
|
FORM_URL = "form_url",
|
|
3
|
-
JSON = "json"
|
|
3
|
+
JSON = "json",
|
|
4
|
+
RAW = "raw"
|
|
4
5
|
}
|
|
5
6
|
export declare function toECommonsHttpContentType(type: string): ECommonsHttpContentType | undefined;
|
|
6
7
|
export declare function fromECommonsHttpContentType(type: ECommonsHttpContentType): string;
|
|
@@ -3,6 +3,7 @@ export var ECommonsHttpContentType;
|
|
|
3
3
|
(function (ECommonsHttpContentType) {
|
|
4
4
|
ECommonsHttpContentType["FORM_URL"] = "form_url";
|
|
5
5
|
ECommonsHttpContentType["JSON"] = "json";
|
|
6
|
+
ECommonsHttpContentType["RAW"] = "raw";
|
|
6
7
|
})(ECommonsHttpContentType || (ECommonsHttpContentType = {}));
|
|
7
8
|
export function toECommonsHttpContentType(type) {
|
|
8
9
|
switch (type) {
|
|
@@ -10,6 +11,8 @@ export function toECommonsHttpContentType(type) {
|
|
|
10
11
|
return ECommonsHttpContentType.FORM_URL;
|
|
11
12
|
case ECommonsHttpContentType.JSON.toString():
|
|
12
13
|
return ECommonsHttpContentType.JSON;
|
|
14
|
+
case ECommonsHttpContentType.RAW.toString():
|
|
15
|
+
return ECommonsHttpContentType.RAW;
|
|
13
16
|
}
|
|
14
17
|
return undefined;
|
|
15
18
|
}
|
|
@@ -19,6 +22,8 @@ export function fromECommonsHttpContentType(type) {
|
|
|
19
22
|
return ECommonsHttpContentType.FORM_URL.toString();
|
|
20
23
|
case ECommonsHttpContentType.JSON:
|
|
21
24
|
return ECommonsHttpContentType.JSON.toString();
|
|
25
|
+
case ECommonsHttpContentType.RAW:
|
|
26
|
+
return ECommonsHttpContentType.RAW.toString();
|
|
22
27
|
}
|
|
23
28
|
throw new Error('Unknown ECommonsHttpContentType');
|
|
24
29
|
}
|
|
@@ -33,6 +38,8 @@ export function keyToECommonsHttpContentType(key) {
|
|
|
33
38
|
return ECommonsHttpContentType.FORM_URL;
|
|
34
39
|
case 'JSON':
|
|
35
40
|
return ECommonsHttpContentType.JSON;
|
|
41
|
+
case 'RAW':
|
|
42
|
+
return ECommonsHttpContentType.RAW;
|
|
36
43
|
}
|
|
37
44
|
throw new Error(`Unable to obtain ECommonsHttpContentType for key: ${key}`);
|
|
38
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecommons-http-content-type.mjs","sourceRoot":"","sources":["../../src/enums/ecommons-http-content-type.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"ecommons-http-content-type.mjs","sourceRoot":"","sources":["../../src/enums/ecommons-http-content-type.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,CAAN,IAAY,uBAIX;AAJD,WAAY,uBAAuB;IACjC,gDAAqB,CAAA;IACrB,wCAAa,CAAA;IACb,sCAAW,CAAA;AACb,CAAC,EAJW,uBAAuB,KAAvB,uBAAuB,QAIlC;AAED,MAAM,UAAU,yBAAyB,CAAC,IAAY;IACrD,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,uBAAuB,CAAC,QAAQ,CAAC,QAAQ,EAAE;YAC/C,OAAO,uBAAuB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B,CAAC;KACvG,GAAG,CAAC,CAAC,CAAS,EAA2B,EAAE,CAAC,4BAA4B,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { commonsObjectMapObject, commonsTypeIsObject } from 'tscommons-esm-core';
|
|
1
|
+
import { commonsObjectMapObject, commonsTypeHasPropertyString, commonsTypeIsObject } from 'tscommons-esm-core';
|
|
2
2
|
import { ECommonsHttpContentType } from '../enums/ecommons-http-content-type.mjs';
|
|
3
3
|
export function commonsHttpClientInternalBuildHeadersOrParams(data) {
|
|
4
4
|
if (!data)
|
|
@@ -21,6 +21,10 @@ export function commonsHttpClientInternalAppendContentType(contentType, headers)
|
|
|
21
21
|
case ECommonsHttpContentType.JSON:
|
|
22
22
|
clone['Content-Type'] = 'application/json; charset=utf-8';
|
|
23
23
|
break;
|
|
24
|
+
case ECommonsHttpContentType.RAW:
|
|
25
|
+
if (!commonsTypeHasPropertyString(clone, 'Content-Type'))
|
|
26
|
+
throw new Error('Content-Type must be explicitly set for RAW');
|
|
27
|
+
break;
|
|
24
28
|
}
|
|
25
29
|
return clone;
|
|
26
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-client-internal-helpers.mjs","sourceRoot":"","sources":["../../src/helpers/http-client-internal-helpers.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAkB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"http-client-internal-helpers.mjs","sourceRoot":"","sources":["../../src/helpers/http-client-internal-helpers.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,mBAAmB,EAAkB,MAAM,oBAAoB,CAAC;AAI/H,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAElF,MAAM,UAAU,6CAA6C,CAAC,IAA8B;IAC3F,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAE9E,OAAO,sBAAsB,CAC3B,IAAI,EACJ,CAAC,KAAU,EAAE,IAAY,EAAU,EAAE;QACpC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,EAAE,CAAC;QACrD,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,yIAAyI;IACnK,CAAC,CACF,CAAC;AACH,CAAC;AAED,MAAM,UAAU,0CAA0C,CACxD,WAAoC,EACpC,OAA2C;IAE5C,2EAA2E;IAC3E,MAAM,KAAK,GAA6B,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC;IAEpF,QAAQ,WAAW,EAAE,CAAC;QACrB,KAAK,uBAAuB,CAAC,QAAQ;YACpC,KAAK,CAAC,cAAc,CAAC,GAAG,mCAAmC,CAAC;YAC5D,MAAM;QACP,KAAK,uBAAuB,CAAC,IAAI;YAChC,KAAK,CAAC,cAAc,CAAC,GAAG,iCAAiC,CAAC;YAC1D,MAAM;QACP,KAAK,uBAAuB,CAAC,GAAG;YAC/B,IAAI,CAAC,4BAA4B,CAAC,KAAK,EAAE,cAAc,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;YACzH,MAAM;IACR,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC"}
|
|
@@ -8,9 +8,9 @@ export declare class CommonsHttpTimeoutError extends Error {
|
|
|
8
8
|
export interface ICommonsHttpClientImplementation {
|
|
9
9
|
internalHead(url: string, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, options: TCommonsHttpInternalRequestOptions): Promise<void>;
|
|
10
10
|
internalGet(url: string, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): Promise<string | Uint8Array>;
|
|
11
|
-
internalPost<BodyT
|
|
12
|
-
internalPut<BodyT
|
|
13
|
-
internalPatch<BodyT
|
|
11
|
+
internalPost<BodyT = unknown>(url: string, body: BodyT, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, bodyDataEncoding: ECommonsHttpContentType, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): Promise<string | Uint8Array>;
|
|
12
|
+
internalPut<BodyT = unknown>(url: string, body: BodyT, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, bodyDataEncoding: ECommonsHttpContentType, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): Promise<string | Uint8Array>;
|
|
13
|
+
internalPatch<BodyT = unknown>(url: string, body: BodyT, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, bodyDataEncoding: ECommonsHttpContentType, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): Promise<string | Uint8Array>;
|
|
14
14
|
internalDelete(url: string, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): Promise<string | Uint8Array>;
|
|
15
15
|
}
|
|
16
16
|
type TReattemptDebugCallback = (reattempt: number, url: string, params: TEncodedObject | undefined, headers: TEncodedObject | undefined, options: TCommonsHttpRequestOptions | undefined) => void;
|
|
@@ -25,13 +25,13 @@ export declare class CommonsHttpClientService {
|
|
|
25
25
|
get<ParamsT extends TEncodedObject = TEncodedObject, HeadersT extends TEncodedObject = TEncodedObject>(url: string, params?: ParamsT | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
26
26
|
headers?: HeadersT | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
27
27
|
options?: TCommonsHttpRequestOptions): Promise<string | Uint8Array>;
|
|
28
|
-
post<BodyT
|
|
28
|
+
post<BodyT = unknown, ParamsT extends TEncodedObject = TEncodedObject, HeadersT extends TEncodedObject = TEncodedObject>(url: string, body: BodyT, params?: ParamsT | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
29
29
|
headers?: HeadersT | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
30
30
|
options?: TCommonsHttpRequestOptions): Promise<string | Uint8Array>;
|
|
31
|
-
put<BodyT
|
|
31
|
+
put<BodyT = unknown, ParamsT extends TEncodedObject = TEncodedObject, HeadersT extends TEncodedObject = TEncodedObject>(url: string, body: BodyT, params?: ParamsT | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
32
32
|
headers?: HeadersT | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
33
33
|
options?: TCommonsHttpRequestOptions): Promise<string | Uint8Array>;
|
|
34
|
-
patch<BodyT
|
|
34
|
+
patch<BodyT = unknown, ParamsT extends TEncodedObject = TEncodedObject, HeadersT extends TEncodedObject = TEncodedObject>(url: string, body: BodyT, params?: ParamsT | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
35
35
|
headers?: HeadersT | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
36
36
|
options?: TCommonsHttpRequestOptions): Promise<string | Uint8Array>;
|
|
37
37
|
delete<ParamsT extends TEncodedObject = TEncodedObject, HeadersT extends TEncodedObject = TEncodedObject>(url: string, params?: ParamsT | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
@@ -7,9 +7,9 @@ import { ECommonsHttpResponseDataType } from '../enums/ecommons-http-response-da
|
|
|
7
7
|
export interface ICommonsStreamableHttpClientImplementation {
|
|
8
8
|
internalHead(url: string, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, options: TCommonsHttpInternalRequestOptions): TCommonsStreamableHttpObservable;
|
|
9
9
|
internalGet(url: string, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): TCommonsStreamableHttpObservable;
|
|
10
|
-
internalPost<BodyT
|
|
11
|
-
internalPut<BodyT
|
|
12
|
-
internalPatch<BodyT
|
|
10
|
+
internalPost<BodyT = unknown>(url: string, body: BodyT, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, bodyDataEncoding: ECommonsHttpContentType, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): TCommonsStreamableHttpObservable;
|
|
11
|
+
internalPut<BodyT = unknown>(url: string, body: BodyT, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, bodyDataEncoding: ECommonsHttpContentType, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): TCommonsStreamableHttpObservable;
|
|
12
|
+
internalPatch<BodyT = unknown>(url: string, body: BodyT, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, bodyDataEncoding: ECommonsHttpContentType, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): TCommonsStreamableHttpObservable;
|
|
13
13
|
internalDelete(url: string, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): TCommonsStreamableHttpObservable;
|
|
14
14
|
}
|
|
15
15
|
type TReattemptDebugCallback = (reattempt: number, url: string, params: TEncodedObject | undefined, headers: TEncodedObject | undefined, options: TCommonsHttpRequestOptions | undefined) => void;
|
|
@@ -24,13 +24,13 @@ export declare class CommonsStreamableHttpClientService {
|
|
|
24
24
|
get<ParamsT extends TEncodedObject = TEncodedObject, HeadersT extends TEncodedObject = TEncodedObject>(url: string, params?: ParamsT | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
25
25
|
headers?: HeadersT | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
26
26
|
options?: TCommonsHttpRequestOptions): TCommonsStreamableHttpObservable;
|
|
27
|
-
post<BodyT
|
|
27
|
+
post<BodyT = unknown, ParamsT extends TEncodedObject = TEncodedObject, HeadersT extends TEncodedObject = TEncodedObject>(url: string, body: BodyT, params?: ParamsT | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
28
28
|
headers?: HeadersT | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
29
29
|
options?: TCommonsHttpRequestOptions): TCommonsStreamableHttpObservable;
|
|
30
|
-
put<BodyT
|
|
30
|
+
put<BodyT = unknown, ParamsT extends TEncodedObject = TEncodedObject, HeadersT extends TEncodedObject = TEncodedObject>(url: string, body: BodyT, params?: ParamsT | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
31
31
|
headers?: HeadersT | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
32
32
|
options?: TCommonsHttpRequestOptions): TCommonsStreamableHttpObservable;
|
|
33
|
-
patch<BodyT
|
|
33
|
+
patch<BodyT = unknown, ParamsT extends TEncodedObject = TEncodedObject, HeadersT extends TEncodedObject = TEncodedObject>(url: string, body: BodyT, params?: ParamsT | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
34
34
|
headers?: HeadersT | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
35
35
|
options?: TCommonsHttpRequestOptions): TCommonsStreamableHttpObservable;
|
|
36
36
|
delete<ParamsT extends TEncodedObject = TEncodedObject, HeadersT extends TEncodedObject = TEncodedObject>(url: string, params?: ParamsT | undefined, // the params can be explicitly undefined (none) as well as optional
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tscommons-esm-http",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"tsc": "./node_modules/typescript/bin/tsc",
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"rxjs": "^7.8.1",
|
|
29
|
-
"tscommons-esm-core": "^0.
|
|
29
|
+
"tscommons-esm-core": "^0.2.0"
|
|
30
30
|
}
|
|
31
31
|
}
|