tscommons-esm-http 0.0.2
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/classes/commons-http-bad-request-error.class.d.mts +4 -0
- package/dist/classes/commons-http-bad-request-error.class.mjs +9 -0
- package/dist/classes/commons-http-bad-request-error.class.mjs.map +1 -0
- package/dist/classes/commons-http-conflict-error.class.d.mts +4 -0
- package/dist/classes/commons-http-conflict-error.class.mjs +9 -0
- package/dist/classes/commons-http-conflict-error.class.mjs.map +1 -0
- package/dist/classes/commons-http-created-success.class.d.mts +4 -0
- package/dist/classes/commons-http-created-success.class.mjs +8 -0
- package/dist/classes/commons-http-created-success.class.mjs.map +1 -0
- package/dist/classes/commons-http-error.class.d.mts +5 -0
- package/dist/classes/commons-http-error.class.mjs +10 -0
- package/dist/classes/commons-http-error.class.mjs.map +1 -0
- package/dist/classes/commons-http-forbidden-error.class.d.mts +4 -0
- package/dist/classes/commons-http-forbidden-error.class.mjs +9 -0
- package/dist/classes/commons-http-forbidden-error.class.mjs.map +1 -0
- package/dist/classes/commons-http-internal-server-error.class.d.mts +4 -0
- package/dist/classes/commons-http-internal-server-error.class.mjs +9 -0
- package/dist/classes/commons-http-internal-server-error.class.mjs.map +1 -0
- package/dist/classes/commons-http-no-content-success.class.d.mts +4 -0
- package/dist/classes/commons-http-no-content-success.class.mjs +8 -0
- package/dist/classes/commons-http-no-content-success.class.mjs.map +1 -0
- package/dist/classes/commons-http-not-found-error.class.d.mts +4 -0
- package/dist/classes/commons-http-not-found-error.class.mjs +9 -0
- package/dist/classes/commons-http-not-found-error.class.mjs.map +1 -0
- package/dist/classes/commons-http-not-implemented-error.class.d.mts +4 -0
- package/dist/classes/commons-http-not-implemented-error.class.mjs +9 -0
- package/dist/classes/commons-http-not-implemented-error.class.mjs.map +1 -0
- package/dist/classes/commons-http-ok-success.class.d.mts +4 -0
- package/dist/classes/commons-http-ok-success.class.mjs +8 -0
- package/dist/classes/commons-http-ok-success.class.mjs.map +1 -0
- package/dist/classes/commons-http-service-unavailable-error.class.d.mts +4 -0
- package/dist/classes/commons-http-service-unavailable-error.class.mjs +9 -0
- package/dist/classes/commons-http-service-unavailable-error.class.mjs.map +1 -0
- package/dist/classes/commons-http-success.class.d.mts +5 -0
- package/dist/classes/commons-http-success.class.mjs +9 -0
- package/dist/classes/commons-http-success.class.mjs.map +1 -0
- package/dist/classes/commons-http-unauthorized-error.class.d.mts +4 -0
- package/dist/classes/commons-http-unauthorized-error.class.mjs +9 -0
- package/dist/classes/commons-http-unauthorized-error.class.mjs.map +1 -0
- package/dist/classes/commons-http-url.class.d.mts +24 -0
- package/dist/classes/commons-http-url.class.mjs +86 -0
- package/dist/classes/commons-http-url.class.mjs.map +1 -0
- package/dist/enums/ecommons-http-content-type.d.mts +9 -0
- package/dist/enums/ecommons-http-content-type.mjs +41 -0
- package/dist/enums/ecommons-http-content-type.mjs.map +1 -0
- package/dist/enums/ecommons-http-method.d.mts +14 -0
- package/dist/enums/ecommons-http-method.mjs +76 -0
- package/dist/enums/ecommons-http-method.mjs.map +1 -0
- package/dist/enums/ecommons-http-response-code.d.mts +15 -0
- package/dist/enums/ecommons-http-response-code.mjs +69 -0
- package/dist/enums/ecommons-http-response-code.mjs.map +1 -0
- package/dist/enums/ecommons-http-response-data-type.d.mts +9 -0
- package/dist/enums/ecommons-http-response-data-type.mjs +41 -0
- package/dist/enums/ecommons-http-response-data-type.mjs.map +1 -0
- package/dist/helpers/commons-http-responses.d.mts +4 -0
- package/dist/helpers/commons-http-responses.mjs +55 -0
- package/dist/helpers/commons-http-responses.mjs.map +1 -0
- package/dist/helpers/commons-http-url.d.mts +2 -0
- package/dist/helpers/commons-http-url.mjs +59 -0
- package/dist/helpers/commons-http-url.mjs.map +1 -0
- package/dist/helpers/http-client-internal-helpers.d.mts +5 -0
- package/dist/helpers/http-client-internal-helpers.mjs +27 -0
- package/dist/helpers/http-client-internal-helpers.mjs.map +1 -0
- package/dist/index.d.mts +28 -0
- package/dist/index.mjs +27 -0
- package/dist/index.mjs.map +1 -0
- package/dist/services/commons-http-client.service.d.mts +41 -0
- package/dist/services/commons-http-client.service.mjs +141 -0
- package/dist/services/commons-http-client.service.mjs.map +1 -0
- package/dist/services/commons-streamable-http-client.service.d.mts +40 -0
- package/dist/services/commons-streamable-http-client.service.mjs +140 -0
- package/dist/services/commons-streamable-http-client.service.mjs.map +1 -0
- package/dist/types/tcommons-http-request-options.d.mts +10 -0
- package/dist/types/tcommons-http-request-options.mjs +15 -0
- package/dist/types/tcommons-http-request-options.mjs.map +1 -0
- package/dist/types/tcommons-http-url-segments.d.mts +12 -0
- package/dist/types/tcommons-http-url-segments.mjs +43 -0
- package/dist/types/tcommons-http-url-segments.mjs.map +1 -0
- package/dist/types/tcommons-streamable-http-observable.d.mts +6 -0
- package/dist/types/tcommons-streamable-http-observable.mjs +2 -0
- package/dist/types/tcommons-streamable-http-observable.mjs.map +1 -0
- package/dist/types/thttp-header-or-param-object.d.mts +3 -0
- package/dist/types/thttp-header-or-param-object.mjs +2 -0
- package/dist/types/thttp-header-or-param-object.mjs.map +1 -0
- package/package.json +31 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TEncodedObject } from 'tscommons-esm-core';
|
|
2
|
+
import { THttpHeaderOrParamObject } from '../types/thttp-header-or-param-object.mjs';
|
|
3
|
+
import { TCommonsHttpRequestOptions, TCommonsHttpInternalRequestOptions } from '../types/tcommons-http-request-options.mjs';
|
|
4
|
+
import { TCommonsStreamableHttpObservable } from '../types/tcommons-streamable-http-observable.mjs';
|
|
5
|
+
import { ECommonsHttpContentType } from '../enums/ecommons-http-content-type.mjs';
|
|
6
|
+
import { ECommonsHttpResponseDataType } from '../enums/ecommons-http-response-data-type.mjs';
|
|
7
|
+
export interface ICommonsStreamableHttpClientImplementation {
|
|
8
|
+
internalHead(url: string, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, options: TCommonsHttpInternalRequestOptions): TCommonsStreamableHttpObservable;
|
|
9
|
+
internalGet(url: string, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): TCommonsStreamableHttpObservable;
|
|
10
|
+
internalPost<B extends TEncodedObject = TEncodedObject>(url: string, body: B, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, bodyDataEncoding: ECommonsHttpContentType, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): TCommonsStreamableHttpObservable;
|
|
11
|
+
internalPut<B extends TEncodedObject = TEncodedObject>(url: string, body: B, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, bodyDataEncoding: ECommonsHttpContentType, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): TCommonsStreamableHttpObservable;
|
|
12
|
+
internalPatch<B extends TEncodedObject = TEncodedObject>(url: string, body: B, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, bodyDataEncoding: ECommonsHttpContentType, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): TCommonsStreamableHttpObservable;
|
|
13
|
+
internalDelete(url: string, params: THttpHeaderOrParamObject, headers: THttpHeaderOrParamObject, responseDataType: ECommonsHttpResponseDataType, options: TCommonsHttpInternalRequestOptions): TCommonsStreamableHttpObservable;
|
|
14
|
+
}
|
|
15
|
+
type TReattemptDebugCallback = (reattempt: number, url: string, params: TEncodedObject | undefined, headers: TEncodedObject | undefined, options: TCommonsHttpRequestOptions | undefined) => void;
|
|
16
|
+
export declare class CommonsStreamableHttpClientService {
|
|
17
|
+
private implementation;
|
|
18
|
+
private reattemptDebugCallback;
|
|
19
|
+
constructor(implementation: ICommonsStreamableHttpClientImplementation);
|
|
20
|
+
setReattemptDebugCallback(callback: TReattemptDebugCallback): void;
|
|
21
|
+
head<P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(url: string, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
22
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional,
|
|
23
|
+
options?: TCommonsHttpRequestOptions): TCommonsStreamableHttpObservable;
|
|
24
|
+
get<P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(url: string, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
25
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
26
|
+
options?: TCommonsHttpRequestOptions): TCommonsStreamableHttpObservable;
|
|
27
|
+
post<B extends TEncodedObject = TEncodedObject, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(url: string, body: B, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
28
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
29
|
+
options?: TCommonsHttpRequestOptions): TCommonsStreamableHttpObservable;
|
|
30
|
+
put<B extends TEncodedObject = TEncodedObject, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(url: string, body: B, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
31
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
32
|
+
options?: TCommonsHttpRequestOptions): TCommonsStreamableHttpObservable;
|
|
33
|
+
patch<B extends TEncodedObject = TEncodedObject, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(url: string, body: B, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
34
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
35
|
+
options?: TCommonsHttpRequestOptions): TCommonsStreamableHttpObservable;
|
|
36
|
+
delete<P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(url: string, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
37
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
38
|
+
options?: TCommonsHttpRequestOptions): TCommonsStreamableHttpObservable;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { commonsHttpClientInternalAppendContentType, commonsHttpClientInternalBuildHeadersOrParams } from '../helpers/http-client-internal-helpers.mjs';
|
|
2
|
+
import { ECommonsHttpContentType } from '../enums/ecommons-http-content-type.mjs';
|
|
3
|
+
import { ECommonsHttpResponseDataType } from '../enums/ecommons-http-response-data-type.mjs';
|
|
4
|
+
import { CommonsHttpTimeoutError } from './commons-http-client.service.mjs';
|
|
5
|
+
export class CommonsStreamableHttpClientService {
|
|
6
|
+
implementation;
|
|
7
|
+
reattemptDebugCallback = (_reattempt, _url, _params, _headers, _options) => {
|
|
8
|
+
// do nothing by default
|
|
9
|
+
};
|
|
10
|
+
constructor(implementation) {
|
|
11
|
+
this.implementation = implementation;
|
|
12
|
+
}
|
|
13
|
+
setReattemptDebugCallback(callback) {
|
|
14
|
+
this.reattemptDebugCallback = callback;
|
|
15
|
+
}
|
|
16
|
+
head(url, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
17
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional,
|
|
18
|
+
options = {}) {
|
|
19
|
+
let maxReattempts = options.maxReattempts || 0;
|
|
20
|
+
let reattempt = 0;
|
|
21
|
+
while (true) {
|
|
22
|
+
try {
|
|
23
|
+
return this.implementation.internalHead(url, commonsHttpClientInternalBuildHeadersOrParams(params), commonsHttpClientInternalBuildHeadersOrParams(headers), options);
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
if (e instanceof CommonsHttpTimeoutError && maxReattempts > 0) {
|
|
27
|
+
maxReattempts--;
|
|
28
|
+
reattempt++;
|
|
29
|
+
this.reattemptDebugCallback(reattempt, url, params, headers, options);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
throw e;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
get(url, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
37
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
38
|
+
options = {}) {
|
|
39
|
+
let maxReattempts = options.maxReattempts || 0;
|
|
40
|
+
let reattempt = 0;
|
|
41
|
+
while (true) {
|
|
42
|
+
try {
|
|
43
|
+
return this.implementation.internalGet(url, commonsHttpClientInternalBuildHeadersOrParams(params), commonsHttpClientInternalBuildHeadersOrParams(headers), options.responseDataType || ECommonsHttpResponseDataType.STRING, options);
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
if (e instanceof CommonsHttpTimeoutError && maxReattempts > 0) {
|
|
47
|
+
maxReattempts--;
|
|
48
|
+
reattempt++;
|
|
49
|
+
this.reattemptDebugCallback(reattempt, url, params, headers, options);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
throw e;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
post(url, body, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
57
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
58
|
+
options = {}) {
|
|
59
|
+
const builtHeaders = commonsHttpClientInternalAppendContentType(options.bodyDataEncoding || ECommonsHttpContentType.FORM_URL, commonsHttpClientInternalBuildHeadersOrParams(headers));
|
|
60
|
+
let maxReattempts = options.maxReattempts || 0;
|
|
61
|
+
let reattempt = 0;
|
|
62
|
+
while (true) {
|
|
63
|
+
try {
|
|
64
|
+
return this.implementation.internalPost(url, body, commonsHttpClientInternalBuildHeadersOrParams(params), builtHeaders, options.bodyDataEncoding || ECommonsHttpContentType.FORM_URL, options.responseDataType || ECommonsHttpResponseDataType.STRING, options);
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
if (e instanceof CommonsHttpTimeoutError && maxReattempts > 0) {
|
|
68
|
+
maxReattempts--;
|
|
69
|
+
reattempt++;
|
|
70
|
+
this.reattemptDebugCallback(reattempt, url, params, headers, options);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
throw e;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
put(url, body, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
78
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
79
|
+
options = {}) {
|
|
80
|
+
const builtHeaders = commonsHttpClientInternalAppendContentType(options.bodyDataEncoding || ECommonsHttpContentType.FORM_URL, commonsHttpClientInternalBuildHeadersOrParams(headers));
|
|
81
|
+
let maxReattempts = options.maxReattempts || 0;
|
|
82
|
+
let reattempt = 0;
|
|
83
|
+
while (true) {
|
|
84
|
+
try {
|
|
85
|
+
return this.implementation.internalPut(url, body, commonsHttpClientInternalBuildHeadersOrParams(params), builtHeaders, options.bodyDataEncoding || ECommonsHttpContentType.FORM_URL, options.responseDataType || ECommonsHttpResponseDataType.STRING, options);
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
if (e instanceof CommonsHttpTimeoutError && maxReattempts > 0) {
|
|
89
|
+
maxReattempts--;
|
|
90
|
+
reattempt++;
|
|
91
|
+
this.reattemptDebugCallback(reattempt, url, params, headers, options);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
throw e;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
patch(url, body, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
99
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
100
|
+
options = {}) {
|
|
101
|
+
const builtHeaders = commonsHttpClientInternalAppendContentType(options.bodyDataEncoding || ECommonsHttpContentType.FORM_URL, commonsHttpClientInternalBuildHeadersOrParams(headers));
|
|
102
|
+
let maxReattempts = options.maxReattempts || 0;
|
|
103
|
+
let reattempt = 0;
|
|
104
|
+
while (true) {
|
|
105
|
+
try {
|
|
106
|
+
return this.implementation.internalPatch(url, body, commonsHttpClientInternalBuildHeadersOrParams(params), builtHeaders, options.bodyDataEncoding || ECommonsHttpContentType.FORM_URL, options.responseDataType || ECommonsHttpResponseDataType.STRING, options);
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
if (e instanceof CommonsHttpTimeoutError && maxReattempts > 0) {
|
|
110
|
+
maxReattempts--;
|
|
111
|
+
reattempt++;
|
|
112
|
+
this.reattemptDebugCallback(reattempt, url, params, headers, options);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
throw e;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
delete(url, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
120
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
121
|
+
options = {}) {
|
|
122
|
+
let maxReattempts = options.maxReattempts || 0;
|
|
123
|
+
let reattempt = 0;
|
|
124
|
+
while (true) {
|
|
125
|
+
try {
|
|
126
|
+
return this.implementation.internalDelete(url, commonsHttpClientInternalBuildHeadersOrParams(params), commonsHttpClientInternalBuildHeadersOrParams(headers), options.responseDataType || ECommonsHttpResponseDataType.STRING, options);
|
|
127
|
+
}
|
|
128
|
+
catch (e) {
|
|
129
|
+
if (e instanceof CommonsHttpTimeoutError && maxReattempts > 0) {
|
|
130
|
+
maxReattempts--;
|
|
131
|
+
reattempt++;
|
|
132
|
+
this.reattemptDebugCallback(reattempt, url, params, headers, options);
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
throw e;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=commons-streamable-http-client.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commons-streamable-http-client.service.mjs","sourceRoot":"","sources":["../../src/services/commons-streamable-http-client.service.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0CAA0C,EAAE,6CAA6C,EAAE,MAAM,6CAA6C,CAAC;AAMxJ,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,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AS,EAAE,oEAAoE;IACrG,UAAuB,SAAS,EAAE,qEAAqE;IACvG,UAAsC,EAAE;QAEzC,IAAI,aAAa,GAAW,OAAO,CAAC,aAAa,IAAI,CAAC,CAAC;QACvD,IAAI,SAAS,GAAW,CAAC,CAAC;QAE1B,OAAO,IAAI,EAAE,CAAC;YACb,IAAI,CAAC;gBACJ,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CACvC,GAAG,EACH,6CAA6C,CAAC,MAAM,CAAC,EACrD,6CAA6C,CAAC,OAAO,CAAC,EACtD,OAAO,CAAC,gBAAgB,IAAI,4BAA4B,CAAC,MAAM,EAC/D,OAAO,CACR,CAAC;YACH,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACZ,IAAI,CAAC,YAAY,uBAAuB,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;oBAC/D,aAAa,EAAE,CAAC;oBAChB,SAAS,EAAE,CAAC;oBAEZ,IAAI,CAAC,sBAAsB,CACzB,SAAS,EACT,GAAG,EACH,MAAM,EACN,OAAO,EACP,OAAO,CACR,CAAC;oBAEF,SAAS;gBACV,CAAC;gBAED,MAAM,CAAC,CAAC;YACT,CAAC;QACF,CAAC;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ECommonsHttpContentType } from '../enums/ecommons-http-content-type.mjs';
|
|
2
|
+
import { ECommonsHttpResponseDataType } from '../enums/ecommons-http-response-data-type.mjs';
|
|
3
|
+
export type TCommonsHttpRequestOptions = {
|
|
4
|
+
timeout?: number;
|
|
5
|
+
bodyDataEncoding?: ECommonsHttpContentType;
|
|
6
|
+
responseDataType?: ECommonsHttpResponseDataType;
|
|
7
|
+
maxReattempts?: number;
|
|
8
|
+
};
|
|
9
|
+
export type TCommonsHttpInternalRequestOptions = Omit<TCommonsHttpRequestOptions, 'maxReattempts' | 'bodyDataEncoding' | 'responseDataType'>;
|
|
10
|
+
export declare function isTCommonsHttpRequestOptions(test: unknown): test is TCommonsHttpRequestOptions;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { commonsTypeHasPropertyNumberOrUndefined, commonsTypeHasPropertyEnumOrUndefined } from 'tscommons-esm-core';
|
|
2
|
+
import { isECommonsHttpContentType } from '../enums/ecommons-http-content-type.mjs';
|
|
3
|
+
import { isECommonsHttpResponseDataType } from '../enums/ecommons-http-response-data-type.mjs';
|
|
4
|
+
export function isTCommonsHttpRequestOptions(test) {
|
|
5
|
+
if (!commonsTypeHasPropertyNumberOrUndefined(test, 'timeout'))
|
|
6
|
+
return false;
|
|
7
|
+
if (!commonsTypeHasPropertyEnumOrUndefined(test, 'bodyDataEncoding', isECommonsHttpContentType))
|
|
8
|
+
return false;
|
|
9
|
+
if (!commonsTypeHasPropertyEnumOrUndefined(test, 'responseDataType', isECommonsHttpResponseDataType))
|
|
10
|
+
return false;
|
|
11
|
+
if (!commonsTypeHasPropertyNumberOrUndefined(test, 'maxReattempts'))
|
|
12
|
+
return false;
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=tcommons-http-request-options.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tcommons-http-request-options.mjs","sourceRoot":"","sources":["../../src/types/tcommons-http-request-options.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,uCAAuC,EACvC,qCAAqC,EACtC,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAA2B,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAC7G,OAAO,EAAgC,8BAA8B,EAAE,MAAM,+CAA+C,CAAC;AAc7H,MAAM,UAAU,4BAA4B,CAAC,IAAa;IACzD,IAAI,CAAC,uCAAuC,CAAC,IAAI,EAAE,SAAS,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5E,IAAI,CAAC,qCAAqC,CAA0B,IAAI,EAAE,kBAAkB,EAAE,yBAAyB,CAAC;QAAE,OAAO,KAAK,CAAC;IACvI,IAAI,CAAC,qCAAqC,CAA+B,IAAI,EAAE,kBAAkB,EAAE,8BAA8B,CAAC;QAAE,OAAO,KAAK,CAAC;IACjJ,IAAI,CAAC,uCAAuC,CAAC,IAAI,EAAE,eAAe,CAAC;QAAE,OAAO,KAAK,CAAC;IAElF,OAAO,IAAI,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type TCommonsHttpUrlSegments = {
|
|
2
|
+
protocol: string;
|
|
3
|
+
hostname: string;
|
|
4
|
+
pathname: string;
|
|
5
|
+
port?: number;
|
|
6
|
+
username?: string;
|
|
7
|
+
password?: string;
|
|
8
|
+
query?: string;
|
|
9
|
+
anchor?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function isTCommonsHttpUrlSegments(test: unknown): test is TCommonsHttpUrlSegments;
|
|
12
|
+
export declare function parseTCommonsHttpUrlSegments(url: string): TCommonsHttpUrlSegments;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { commonsTypeAttemptNumber, commonsTypeHasPropertyNumberOrUndefined, commonsTypeHasPropertyString, commonsTypeHasPropertyStringOrUndefined } from 'tscommons-esm-core';
|
|
2
|
+
export function isTCommonsHttpUrlSegments(test) {
|
|
3
|
+
if (!commonsTypeHasPropertyString(test, 'protocol'))
|
|
4
|
+
return false;
|
|
5
|
+
if (!commonsTypeHasPropertyString(test, 'hostname'))
|
|
6
|
+
return false;
|
|
7
|
+
if (!commonsTypeHasPropertyString(test, 'pathname'))
|
|
8
|
+
return false;
|
|
9
|
+
if (!commonsTypeHasPropertyNumberOrUndefined(test, 'port'))
|
|
10
|
+
return false;
|
|
11
|
+
if (!commonsTypeHasPropertyStringOrUndefined(test, 'username'))
|
|
12
|
+
return false;
|
|
13
|
+
if (!commonsTypeHasPropertyStringOrUndefined(test, 'password'))
|
|
14
|
+
return false;
|
|
15
|
+
if (!commonsTypeHasPropertyStringOrUndefined(test, 'query'))
|
|
16
|
+
return false;
|
|
17
|
+
if (!commonsTypeHasPropertyStringOrUndefined(test, 'anchor'))
|
|
18
|
+
return false;
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
const URL_PATTERN = /^([a-z]+):\/\/(?:([^@:/]*):([^@:/]*)@)?([a-z0-9][-a-z0-9]{0,62}(?:\.[a-z0-9][-a-z0-9]{0,62}){0,32})(?::([0-9]{1,5}))?(\/?[-a-z0-9/._&=!~*'():[\]@$+,;%]{0,940})(?:[?]([^#]*))?(?:#(.*))?$/i;
|
|
22
|
+
export function parseTCommonsHttpUrlSegments(url) {
|
|
23
|
+
const match = URL_PATTERN.exec(url);
|
|
24
|
+
if (!match)
|
|
25
|
+
throw new Error('Unable to parse URL to segments');
|
|
26
|
+
const base = {
|
|
27
|
+
protocol: match[1],
|
|
28
|
+
hostname: match[4],
|
|
29
|
+
pathname: match[6].trim()
|
|
30
|
+
};
|
|
31
|
+
if (match[5] && match[5].trim() !== '')
|
|
32
|
+
base.port = commonsTypeAttemptNumber(match[5]);
|
|
33
|
+
if (match[2] && match[2].trim() !== '')
|
|
34
|
+
base.username = match[2].trim();
|
|
35
|
+
if (match[3] && match[3].trim() !== '')
|
|
36
|
+
base.password = match[3].trim();
|
|
37
|
+
if (match[7] && match[7].trim() !== '')
|
|
38
|
+
base.query = match[7].trim();
|
|
39
|
+
if (match[8] && match[8].trim() !== '')
|
|
40
|
+
base.anchor = match[8].trim();
|
|
41
|
+
return base;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=tcommons-http-url-segments.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tcommons-http-url-segments.mjs","sourceRoot":"","sources":["../../src/types/tcommons-http-url-segments.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,uCAAuC,EAAE,4BAA4B,EAAE,uCAAuC,EAAE,MAAM,oBAAoB,CAAC;AAe9K,MAAM,UAAU,yBAAyB,CAAC,IAAa;IACtD,IAAI,CAAC,4BAA4B,CAAC,IAAI,EAAE,UAAU,CAAC;QAAE,O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AAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACxE,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACxE,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACrE,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAEtE,OAAO,IAAI,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tcommons-streamable-http-observable.mjs","sourceRoot":"","sources":["../../src/types/tcommons-streamable-http-observable.mts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thttp-header-or-param-object.mjs","sourceRoot":"","sources":["../../src/types/thttp-header-or-param-object.mts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tscommons-esm-http",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"tsc": "./node_modules/typescript/bin/tsc",
|
|
7
|
+
"preprepare": "rm -rf ./dist; php ~/Dev/etim.php src/ && npm run tsc",
|
|
8
|
+
"publish-major": "rm -rf dist; npm run tsc && npx eslint . && npm run preprepare && npm version major && npm install && npm publish && git add . && git commit -m 'publish'",
|
|
9
|
+
"publish-minor": "rm -rf dist; npm run tsc && npx eslint . && npm run preprepare && npm version minor && npm install && npm publish && git add . && git commit -m 'publish'",
|
|
10
|
+
"publish-patch": "rm -rf dist; npm run tsc && npx eslint . && npm run preprepare && npm version patch && npm install && npm publish && git add . && git commit -m 'publish'"
|
|
11
|
+
},
|
|
12
|
+
"main": "dist/index.mjs",
|
|
13
|
+
"types": "dist/index.d.mjs",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"author": "Pete Morris",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@stylistic/eslint-plugin-ts": "^2.10.1",
|
|
19
|
+
"eslint-plugin-import": "^2.31.0",
|
|
20
|
+
"eslint-plugin-prefer-arrow-functions": "^3.4.1",
|
|
21
|
+
"typescript": "^5.6.3",
|
|
22
|
+
"typescript-eslint": "^8.14.0"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist/**/*"
|
|
26
|
+
],
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"rxjs": "^7.8.1",
|
|
29
|
+
"tscommons-esm-core": "^0.0.2"
|
|
30
|
+
}
|
|
31
|
+
}
|