tscommons-esm-rest 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/enums/ecommons-authorization-method.d.mts +10 -0
- package/dist/enums/ecommons-authorization-method.mjs +48 -0
- package/dist/enums/ecommons-authorization-method.mjs.map +1 -0
- package/dist/index.d.mts +14 -0
- package/dist/index.mjs +14 -0
- package/dist/index.mjs.map +1 -0
- package/dist/services/commons-authorized-rest-client.service.d.mts +32 -0
- package/dist/services/commons-authorized-rest-client.service.mjs +56 -0
- package/dist/services/commons-authorized-rest-client.service.mjs.map +1 -0
- package/dist/services/commons-bearer-rest-client.service.d.mts +5 -0
- package/dist/services/commons-bearer-rest-client.service.mjs +10 -0
- package/dist/services/commons-bearer-rest-client.service.mjs.map +1 -0
- package/dist/services/commons-key-rest-client.service.d.mts +5 -0
- package/dist/services/commons-key-rest-client.service.mjs +10 -0
- package/dist/services/commons-key-rest-client.service.mjs.map +1 -0
- package/dist/services/commons-rest-client.service.d.mts +25 -0
- package/dist/services/commons-rest-client.service.mjs +93 -0
- package/dist/services/commons-rest-client.service.mjs.map +1 -0
- package/dist/services/commons-session-rest-client.service.d.mts +13 -0
- package/dist/services/commons-session-rest-client.service.mjs +48 -0
- package/dist/services/commons-session-rest-client.service.mjs.map +1 -0
- package/dist/services/commons-simple-single-pw-session-rest-client.service.d.mts +6 -0
- package/dist/services/commons-simple-single-pw-session-rest-client.service.mjs +19 -0
- package/dist/services/commons-simple-single-pw-session-rest-client.service.mjs.map +1 -0
- package/dist/services/commons-streamable-authorized-rest-client.service.d.mts +33 -0
- package/dist/services/commons-streamable-authorized-rest-client.service.mjs +56 -0
- package/dist/services/commons-streamable-authorized-rest-client.service.mjs.map +1 -0
- package/dist/services/commons-streamable-key-rest-client.service.d.mts +5 -0
- package/dist/services/commons-streamable-key-rest-client.service.mjs +10 -0
- package/dist/services/commons-streamable-key-rest-client.service.mjs.map +1 -0
- package/dist/services/commons-streamable-rest-client.service.d.mts +26 -0
- package/dist/services/commons-streamable-rest-client.service.mjs +109 -0
- package/dist/services/commons-streamable-rest-client.service.mjs.map +1 -0
- package/dist/services/commons-user-pw-session-rest-client.service.d.mts +7 -0
- package/dist/services/commons-user-pw-session-rest-client.service.mjs +12 -0
- package/dist/services/commons-user-pw-session-rest-client.service.mjs.map +1 -0
- package/dist/services/commons-user-session-rest-client.service.d.mts +7 -0
- package/dist/services/commons-user-session-rest-client.service.mjs +17 -0
- package/dist/services/commons-user-session-rest-client.service.mjs.map +1 -0
- package/dist/types/tcommons-streamable-rest-observable.d.mts +6 -0
- package/dist/types/tcommons-streamable-rest-observable.mjs +2 -0
- package/dist/types/tcommons-streamable-rest-observable.mjs.map +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare enum ECommonsAuthorizationMethod {
|
|
2
|
+
KEY = "key",
|
|
3
|
+
SESSION = "session",
|
|
4
|
+
BEARER = "bearer"
|
|
5
|
+
}
|
|
6
|
+
export declare function toECommonsAuthorizationMethod(type: string): ECommonsAuthorizationMethod | undefined;
|
|
7
|
+
export declare function fromECommonsAuthorizationMethod(type: ECommonsAuthorizationMethod): string;
|
|
8
|
+
export declare function isECommonsAuthorizationMethod(test: unknown): test is ECommonsAuthorizationMethod;
|
|
9
|
+
export declare function keyToECommonsAuthorizationMethod(key: string): ECommonsAuthorizationMethod;
|
|
10
|
+
export declare const ECOMMONS_AUTHORIZATION_METHODS: ECommonsAuthorizationMethod[];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { commonsTypeIsString } from 'tscommons-esm-core';
|
|
2
|
+
export var ECommonsAuthorizationMethod;
|
|
3
|
+
(function (ECommonsAuthorizationMethod) {
|
|
4
|
+
ECommonsAuthorizationMethod["KEY"] = "key";
|
|
5
|
+
ECommonsAuthorizationMethod["SESSION"] = "session";
|
|
6
|
+
ECommonsAuthorizationMethod["BEARER"] = "bearer";
|
|
7
|
+
})(ECommonsAuthorizationMethod || (ECommonsAuthorizationMethod = {}));
|
|
8
|
+
export function toECommonsAuthorizationMethod(type) {
|
|
9
|
+
switch (type) {
|
|
10
|
+
case ECommonsAuthorizationMethod.KEY.toString():
|
|
11
|
+
return ECommonsAuthorizationMethod.KEY;
|
|
12
|
+
case ECommonsAuthorizationMethod.SESSION.toString():
|
|
13
|
+
return ECommonsAuthorizationMethod.SESSION;
|
|
14
|
+
case ECommonsAuthorizationMethod.BEARER.toString():
|
|
15
|
+
return ECommonsAuthorizationMethod.BEARER;
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
export function fromECommonsAuthorizationMethod(type) {
|
|
20
|
+
switch (type) {
|
|
21
|
+
case ECommonsAuthorizationMethod.KEY:
|
|
22
|
+
return ECommonsAuthorizationMethod.KEY.toString();
|
|
23
|
+
case ECommonsAuthorizationMethod.SESSION:
|
|
24
|
+
return ECommonsAuthorizationMethod.SESSION.toString();
|
|
25
|
+
case ECommonsAuthorizationMethod.BEARER:
|
|
26
|
+
return ECommonsAuthorizationMethod.BEARER.toString();
|
|
27
|
+
}
|
|
28
|
+
throw new Error('Unknown ECommonsAuthorizationMethod');
|
|
29
|
+
}
|
|
30
|
+
export function isECommonsAuthorizationMethod(test) {
|
|
31
|
+
if (!commonsTypeIsString(test))
|
|
32
|
+
return false;
|
|
33
|
+
return toECommonsAuthorizationMethod(test) !== undefined;
|
|
34
|
+
}
|
|
35
|
+
export function keyToECommonsAuthorizationMethod(key) {
|
|
36
|
+
switch (key) {
|
|
37
|
+
case 'KEY':
|
|
38
|
+
return ECommonsAuthorizationMethod.KEY;
|
|
39
|
+
case 'SESSION':
|
|
40
|
+
return ECommonsAuthorizationMethod.SESSION;
|
|
41
|
+
case 'BEARER':
|
|
42
|
+
return ECommonsAuthorizationMethod.BEARER;
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`Unable to obtain ECommonsAuthorizationMethod for key: ${key}`);
|
|
45
|
+
}
|
|
46
|
+
export const ECOMMONS_AUTHORIZATION_METHODS = Object.keys(ECommonsAuthorizationMethod)
|
|
47
|
+
.map((e) => keyToECommonsAuthorizationMethod(e));
|
|
48
|
+
//# sourceMappingURL=ecommons-authorization-method.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecommons-authorization-method.mjs","sourceRoot":"","sources":["../../src/enums/ecommons-authorization-method.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,CAAN,IAAY,2BAIX;AAJD,WAAY,2BAA2B;IACrC,0CAAW,CAAA;IACX,kDAAmB,CAAA;IACnB,gDAAiB,CAAA;AACnB,CAAC,EAJW,2BAA2B,KAA3B,2BAA2B,QAItC;AAED,MAAM,UAAU,6BAA6B,CAAC,IAAY;IACzD,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,2BAA2B,CAAC,GAAG,CAAC,QAAQ,EAAE;YAC9C,OAAO,2BAA2B,CAAC,GAAG,CAAC;QACxC,KAAK,2BAA2B,CAAC,OAAO,CAAC,QAAQ,EAAE;YAClD,OAAO,2BAA2B,CAAC,OAAO,CAAC;QAC5C,KAAK,2BAA2B,CAAC,MAAM,CAAC,QAAQ,EAAE;YACjD,OAAO,2BAA2B,CAAC,MAAM,CAAC;IAC5C,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,IAAiC;IAChF,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,2BAA2B,CAAC,GAAG;YACnC,OAAO,2BAA2B,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QACnD,KAAK,2BAA2B,CAAC,OAAO;YACvC,OAAO,2BAA2B,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACvD,KAAK,2BAA2B,CAAC,MAAM;YACtC,OAAO,2BAA2B,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;IACvD,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,IAAa;IAC1D,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAE7C,OAAO,6BAA6B,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,gCAAgC,CAAC,GAAW;IAC3D,QAAQ,GAAG,EAAE,CAAC;QACb,KAAK,KAAK;YACT,OAAO,2BAA2B,CAAC,GAAG,CAAC;QACxC,KAAK,SAAS;YACb,OAAO,2BAA2B,CAAC,OAAO,CAAC;QAC5C,KAAK,QAAQ;YACZ,OAAO,2BAA2B,CAAC,MAAM,CAAC;IAC5C,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,yDAAyD,GAAG,EAAE,CAAC,CAAC;AACjF,CAAC;AAED,MAAM,CAAC,MAAM,8BAA8B,GAAkC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC;KAClH,GAAG,CAAC,CAAC,CAAS,EAA+B,EAAE,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CommonsStreamableRestClientService } from './services/commons-streamable-rest-client.service.mjs';
|
|
2
|
+
import { CommonsStreamableKeyRestClientService } from './services/commons-streamable-key-rest-client.service.mjs';
|
|
3
|
+
import { CommonsAuthorizedRestClientService } from './services/commons-authorized-rest-client.service.mjs';
|
|
4
|
+
import { CommonsStreamableAuthorizedRestClientService } from './services/commons-streamable-authorized-rest-client.service.mjs';
|
|
5
|
+
import { CommonsSimpleSinglePwSessionRestClientService } from './services/commons-simple-single-pw-session-rest-client.service.mjs';
|
|
6
|
+
import { CommonsRestClientService } from './services/commons-rest-client.service.mjs';
|
|
7
|
+
import { CommonsUserSessionRestClientService } from './services/commons-user-session-rest-client.service.mjs';
|
|
8
|
+
import { CommonsBearerRestClientService } from './services/commons-bearer-rest-client.service.mjs';
|
|
9
|
+
import { CommonsKeyRestClientService } from './services/commons-key-rest-client.service.mjs';
|
|
10
|
+
import { CommonsUserPwSessionRestClientService } from './services/commons-user-pw-session-rest-client.service.mjs';
|
|
11
|
+
import { CommonsSessionRestClientService } from './services/commons-session-rest-client.service.mjs';
|
|
12
|
+
import { ECommonsAuthorizationMethod, toECommonsAuthorizationMethod, fromECommonsAuthorizationMethod, isECommonsAuthorizationMethod, keyToECommonsAuthorizationMethod, ECOMMONS_AUTHORIZATION_METHODS } from './enums/ecommons-authorization-method.mjs';
|
|
13
|
+
import { TCommonsStreamableRestObservable } from './types/tcommons-streamable-rest-observable.mjs';
|
|
14
|
+
export { CommonsStreamableRestClientService, CommonsStreamableKeyRestClientService, CommonsAuthorizedRestClientService, CommonsStreamableAuthorizedRestClientService, CommonsSimpleSinglePwSessionRestClientService, CommonsRestClientService, CommonsUserSessionRestClientService, CommonsBearerRestClientService, CommonsKeyRestClientService, CommonsUserPwSessionRestClientService, CommonsSessionRestClientService, ECommonsAuthorizationMethod, toECommonsAuthorizationMethod, fromECommonsAuthorizationMethod, isECommonsAuthorizationMethod, keyToECommonsAuthorizationMethod, ECOMMONS_AUTHORIZATION_METHODS, TCommonsStreamableRestObservable };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CommonsStreamableRestClientService } from './services/commons-streamable-rest-client.service.mjs';
|
|
2
|
+
import { CommonsStreamableKeyRestClientService } from './services/commons-streamable-key-rest-client.service.mjs';
|
|
3
|
+
import { CommonsAuthorizedRestClientService } from './services/commons-authorized-rest-client.service.mjs';
|
|
4
|
+
import { CommonsStreamableAuthorizedRestClientService } from './services/commons-streamable-authorized-rest-client.service.mjs';
|
|
5
|
+
import { CommonsSimpleSinglePwSessionRestClientService } from './services/commons-simple-single-pw-session-rest-client.service.mjs';
|
|
6
|
+
import { CommonsRestClientService } from './services/commons-rest-client.service.mjs';
|
|
7
|
+
import { CommonsUserSessionRestClientService } from './services/commons-user-session-rest-client.service.mjs';
|
|
8
|
+
import { CommonsBearerRestClientService } from './services/commons-bearer-rest-client.service.mjs';
|
|
9
|
+
import { CommonsKeyRestClientService } from './services/commons-key-rest-client.service.mjs';
|
|
10
|
+
import { CommonsUserPwSessionRestClientService } from './services/commons-user-pw-session-rest-client.service.mjs';
|
|
11
|
+
import { CommonsSessionRestClientService } from './services/commons-session-rest-client.service.mjs';
|
|
12
|
+
import { ECommonsAuthorizationMethod, toECommonsAuthorizationMethod, fromECommonsAuthorizationMethod, isECommonsAuthorizationMethod, keyToECommonsAuthorizationMethod, ECOMMONS_AUTHORIZATION_METHODS } from './enums/ecommons-authorization-method.mjs';
|
|
13
|
+
export { CommonsStreamableRestClientService, CommonsStreamableKeyRestClientService, CommonsAuthorizedRestClientService, CommonsStreamableAuthorizedRestClientService, CommonsSimpleSinglePwSessionRestClientService, CommonsRestClientService, CommonsUserSessionRestClientService, CommonsBearerRestClientService, CommonsKeyRestClientService, CommonsUserPwSessionRestClientService, CommonsSessionRestClientService, ECommonsAuthorizationMethod, toECommonsAuthorizationMethod, fromECommonsAuthorizationMethod, isECommonsAuthorizationMethod, keyToECommonsAuthorizationMethod, ECOMMONS_AUTHORIZATION_METHODS };
|
|
14
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,uDAAuD,CAAC;AAC3G,OAAO,EAAE,qCAAqC,EAAE,MAAM,2DAA2D,CAAC;AAClH,OAAO,EAAE,kCAAkC,EAAE,MAAM,uDAAuD,CAAC;AAC3G,OAAO,EAAE,4CAA4C,EAAE,MAAM,kEAAkE,CAAC;AAChI,OAAO,EAAE,6CAA6C,EAAE,MAAM,qEAAqE,CAAC;AACpI,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AACtF,OAAO,EAAE,mCAAmC,EAAE,MAAM,yDAAyD,CAAC;AAC9G,OAAO,EAAE,8BAA8B,EAAE,MAAM,mDAAmD,CAAC;AACnG,OAAO,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,EAAE,qCAAqC,EAAE,MAAM,4DAA4D,CAAC;AACnH,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AACrG,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,EAC7B,+BAA+B,EAC/B,6BAA6B,EAC7B,gCAAgC,EAChC,8BAA8B,EAC/B,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EACN,kCAAkC,EAClC,qCAAqC,EACrC,kCAAkC,EAClC,4CAA4C,EAC5C,6CAA6C,EAC7C,wBAAwB,EACxB,mCAAmC,EACnC,8BAA8B,EAC9B,2BAA2B,EAC3B,qCAAqC,EACrC,+BAA+B,EAC/B,2BAA2B,EAC3B,6BAA6B,EAC7B,+BAA+B,EAC/B,6BAA6B,EAC7B,gCAAgC,EAChC,8BAA8B,EAE9B,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TEncodedObject, TEncoded } from 'tscommons-esm-core';
|
|
2
|
+
import { ICommonsHttpClientImplementation, ECommonsHttpContentType, TCommonsHttpRequestOptions } from 'tscommons-esm-http';
|
|
3
|
+
import { ECommonsAuthorizationMethod } from '../enums/ecommons-authorization-method.mjs';
|
|
4
|
+
import { CommonsRestClientService } from './commons-rest-client.service.mjs';
|
|
5
|
+
export declare class CommonsAuthorizedRestClientService extends CommonsRestClientService {
|
|
6
|
+
private authorizationMethod;
|
|
7
|
+
private authorizationValue;
|
|
8
|
+
constructor(implementation: ICommonsHttpClientImplementation, rootUrl: string, contentType?: ECommonsHttpContentType);
|
|
9
|
+
setAuthorization(method: ECommonsAuthorizationMethod | undefined, value: string | undefined): void;
|
|
10
|
+
hasAuthorization(): boolean;
|
|
11
|
+
protected patchHeaders<H extends TEncodedObject>(headers?: H): H | (H & {
|
|
12
|
+
'Authorization': string;
|
|
13
|
+
});
|
|
14
|
+
headRest<P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
15
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
16
|
+
options?: TCommonsHttpRequestOptions): Promise<void>;
|
|
17
|
+
getRest<T extends TEncoded = TEncoded, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
18
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
19
|
+
options?: TCommonsHttpRequestOptions): Promise<T>;
|
|
20
|
+
postRest<T extends TEncoded = TEncoded, B extends TEncodedObject = TEncodedObject, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, body: B, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
21
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
22
|
+
options?: TCommonsHttpRequestOptions): Promise<T>;
|
|
23
|
+
putRest<T extends TEncoded = TEncoded, B extends TEncodedObject = TEncodedObject, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, body: B, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
24
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
25
|
+
options?: TCommonsHttpRequestOptions): Promise<T>;
|
|
26
|
+
patchRest<T extends TEncoded = TEncoded, B extends TEncodedObject = TEncodedObject, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, body: B, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
27
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
28
|
+
options?: TCommonsHttpRequestOptions): Promise<T | undefined>;
|
|
29
|
+
deleteRest<T extends TEncoded = TEncoded, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
30
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
31
|
+
options?: TCommonsHttpRequestOptions): Promise<T | undefined>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ECommonsHttpContentType } from 'tscommons-esm-http';
|
|
2
|
+
import { fromECommonsAuthorizationMethod } from '../enums/ecommons-authorization-method.mjs';
|
|
3
|
+
import { CommonsRestClientService } from './commons-rest-client.service.mjs';
|
|
4
|
+
export class CommonsAuthorizedRestClientService extends CommonsRestClientService {
|
|
5
|
+
authorizationMethod;
|
|
6
|
+
authorizationValue;
|
|
7
|
+
constructor(implementation, rootUrl, contentType = ECommonsHttpContentType.FORM_URL) {
|
|
8
|
+
super(implementation, rootUrl, contentType);
|
|
9
|
+
}
|
|
10
|
+
setAuthorization(method, value) {
|
|
11
|
+
this.authorizationMethod = method;
|
|
12
|
+
this.authorizationValue = value;
|
|
13
|
+
}
|
|
14
|
+
hasAuthorization() {
|
|
15
|
+
return this.authorizationMethod !== undefined && this.authorizationValue !== undefined;
|
|
16
|
+
}
|
|
17
|
+
patchHeaders(headers) {
|
|
18
|
+
if (!this.authorizationMethod || !this.authorizationValue)
|
|
19
|
+
return { ...headers }; //eslint-disable-line @typescript-eslint/consistent-type-assertions
|
|
20
|
+
return {
|
|
21
|
+
...headers,
|
|
22
|
+
Authorization: `${fromECommonsAuthorizationMethod(this.authorizationMethod)} ${this.authorizationValue}`
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
headRest(script, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
26
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
27
|
+
options = {}) {
|
|
28
|
+
return super.headRest(script, params, this.patchHeaders(headers), options); // eslint-disable-line indent
|
|
29
|
+
}
|
|
30
|
+
getRest(script, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
31
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
32
|
+
options = {}) {
|
|
33
|
+
return super.getRest(script, params, this.patchHeaders(headers), options); // eslint-disable-line indent
|
|
34
|
+
}
|
|
35
|
+
postRest(script, body, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
36
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
37
|
+
options = {}) {
|
|
38
|
+
return super.postRest(script, body, params, this.patchHeaders(headers), options); // eslint-disable-line indent
|
|
39
|
+
}
|
|
40
|
+
putRest(script, body, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
41
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
42
|
+
options = {}) {
|
|
43
|
+
return super.putRest(script, body, params, this.patchHeaders(headers), options); // eslint-disable-line indent
|
|
44
|
+
}
|
|
45
|
+
patchRest(script, body, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
46
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
47
|
+
options = {}) {
|
|
48
|
+
return super.patchRest(script, body, params, this.patchHeaders(headers), options); // eslint-disable-line indent
|
|
49
|
+
}
|
|
50
|
+
deleteRest(script, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
51
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
52
|
+
options = {}) {
|
|
53
|
+
return super.deleteRest(script, params, this.patchHeaders(headers), options); // eslint-disable-line indent
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=commons-authorized-rest-client.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commons-authorized-rest-client.service.mjs","sourceRoot":"","sources":["../../src/services/commons-authorized-rest-client.service.mts"],"names":[],"mappings":"AACA,OAAO,EAAoC,uBAAuB,EAA8B,MAAM,oBAAoB,CAAC;AAE3H,OAAO,EAA+B,+BA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CAAC,6BAA6B;IACjC,CAAC;CACD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ICommonsHttpClientImplementation, ECommonsHttpContentType } from 'tscommons-esm-http';
|
|
2
|
+
import { CommonsAuthorizedRestClientService } from './commons-authorized-rest-client.service.mjs';
|
|
3
|
+
export declare class CommonsBearerRestClientService extends CommonsAuthorizedRestClientService {
|
|
4
|
+
constructor(implementation: ICommonsHttpClientImplementation, rootUrl: string, bearerToken: string, contentType?: ECommonsHttpContentType);
|
|
5
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ECommonsHttpContentType } from 'tscommons-esm-http';
|
|
2
|
+
import { ECommonsAuthorizationMethod } from '../enums/ecommons-authorization-method.mjs';
|
|
3
|
+
import { CommonsAuthorizedRestClientService } from './commons-authorized-rest-client.service.mjs';
|
|
4
|
+
export class CommonsBearerRestClientService extends CommonsAuthorizedRestClientService {
|
|
5
|
+
constructor(implementation, rootUrl, bearerToken, contentType = ECommonsHttpContentType.FORM_URL) {
|
|
6
|
+
super(implementation, rootUrl, contentType);
|
|
7
|
+
this.setAuthorization(ECommonsAuthorizationMethod.BEARER, bearerToken);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=commons-bearer-rest-client.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commons-bearer-rest-client.service.mjs","sourceRoot":"","sources":["../../src/services/commons-bearer-rest-client.service.mts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE/F,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAEzF,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AAElG,MAAM,OAAO,8BAA+B,SAAQ,kCAAkC;IACrF,YACE,cAAgD,EAChD,OAAe,EACf,WAAmB,EACnB,cAAuC,uBAAuB,CAAC,QAAQ;QAExE,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;QAE5C,IAAI,CAAC,gBAAgB,CACnB,2BAA2B,CAAC,MAAM,EAClC,WAAW,CACZ,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ECommonsHttpContentType, ICommonsHttpClientImplementation } from 'tscommons-esm-http';
|
|
2
|
+
import { CommonsAuthorizedRestClientService } from './commons-authorized-rest-client.service.mjs';
|
|
3
|
+
export declare class CommonsKeyRestClientService extends CommonsAuthorizedRestClientService {
|
|
4
|
+
constructor(implementation: ICommonsHttpClientImplementation, rootUrl: string, authKey: string, contentType?: ECommonsHttpContentType);
|
|
5
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ECommonsHttpContentType } from 'tscommons-esm-http';
|
|
2
|
+
import { ECommonsAuthorizationMethod } from '../enums/ecommons-authorization-method.mjs';
|
|
3
|
+
import { CommonsAuthorizedRestClientService } from './commons-authorized-rest-client.service.mjs';
|
|
4
|
+
export class CommonsKeyRestClientService extends CommonsAuthorizedRestClientService {
|
|
5
|
+
constructor(implementation, rootUrl, authKey, contentType = ECommonsHttpContentType.FORM_URL) {
|
|
6
|
+
super(implementation, rootUrl, contentType);
|
|
7
|
+
this.setAuthorization(ECommonsAuthorizationMethod.KEY, authKey);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=commons-key-rest-client.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commons-key-rest-client.service.mjs","sourceRoot":"","sources":["../../src/services/commons-key-rest-client.service.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAoC,MAAM,oBAAoB,CAAC;AAE/F,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAEzF,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AAElG,MAAM,OAAO,2BAA4B,SAAQ,kCAAkC;IAClF,YACE,cAAgD,EAChD,OAAe,EACf,OAAe,EACf,cAAuC,uBAAuB,CAAC,QAAQ;QAExE,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;QAE5C,IAAI,CAAC,gBAAgB,CACnB,2BAA2B,CAAC,GAAG,EAC/B,OAAO,CACR,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TEncodedObject, TEncoded } from 'tscommons-esm-core';
|
|
2
|
+
import { CommonsHttpClientService, ICommonsHttpClientImplementation, ECommonsHttpContentType, TCommonsHttpRequestOptions } from 'tscommons-esm-http';
|
|
3
|
+
export declare class CommonsRestClientService extends CommonsHttpClientService {
|
|
4
|
+
private rootUrl;
|
|
5
|
+
private contentType;
|
|
6
|
+
constructor(implementation: ICommonsHttpClientImplementation, rootUrl: string, contentType?: ECommonsHttpContentType);
|
|
7
|
+
headRest<P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
8
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
9
|
+
options?: TCommonsHttpRequestOptions): Promise<void>;
|
|
10
|
+
getRest<T extends TEncoded = TEncoded, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
11
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
12
|
+
options?: TCommonsHttpRequestOptions): Promise<T>;
|
|
13
|
+
postRest<T extends TEncoded = TEncoded, B extends TEncodedObject = TEncodedObject, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, body: B, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
14
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
15
|
+
options?: TCommonsHttpRequestOptions): Promise<T>;
|
|
16
|
+
putRest<T extends TEncoded = TEncoded, B extends TEncodedObject = TEncodedObject, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, body: B, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
17
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
18
|
+
options?: TCommonsHttpRequestOptions): Promise<T>;
|
|
19
|
+
patchRest<T extends TEncoded = TEncoded, B extends TEncodedObject = TEncodedObject, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, body: B, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
20
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
21
|
+
options?: TCommonsHttpRequestOptions): Promise<T | undefined>;
|
|
22
|
+
deleteRest<T extends TEncoded = TEncoded, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
23
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
24
|
+
options?: TCommonsHttpRequestOptions): Promise<T | undefined>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { CommonsHttpClientService, ECommonsHttpContentType, ECommonsHttpResponseDataType } from 'tscommons-esm-http';
|
|
2
|
+
export class CommonsRestClientService extends CommonsHttpClientService {
|
|
3
|
+
rootUrl;
|
|
4
|
+
contentType;
|
|
5
|
+
constructor(implementation, rootUrl, contentType = ECommonsHttpContentType.FORM_URL) {
|
|
6
|
+
super(implementation);
|
|
7
|
+
this.rootUrl = rootUrl;
|
|
8
|
+
this.contentType = contentType;
|
|
9
|
+
}
|
|
10
|
+
headRest(script, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
11
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
12
|
+
options = {}) {
|
|
13
|
+
return super.head(`${this.rootUrl}${script}`, params, headers, options);
|
|
14
|
+
}
|
|
15
|
+
async getRest(script, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
16
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
17
|
+
options = {}) {
|
|
18
|
+
const result = (await this.get(`${this.rootUrl}${script}`, params, headers, {
|
|
19
|
+
...options,
|
|
20
|
+
responseDataType: ECommonsHttpResponseDataType.STRING
|
|
21
|
+
}));
|
|
22
|
+
try {
|
|
23
|
+
return JSON.parse(result);
|
|
24
|
+
}
|
|
25
|
+
catch (_e) {
|
|
26
|
+
throw new Error(`Unable to decode JSON response from rest: ${result.substring(0, 255)}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async postRest(script, body, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
30
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
31
|
+
options = {}) {
|
|
32
|
+
const result = (await this.post(`${this.rootUrl}${script}`, body, params, headers, {
|
|
33
|
+
...options,
|
|
34
|
+
bodyDataEncoding: options.bodyDataEncoding || this.contentType,
|
|
35
|
+
responseDataType: ECommonsHttpResponseDataType.STRING
|
|
36
|
+
}));
|
|
37
|
+
try {
|
|
38
|
+
return JSON.parse(result);
|
|
39
|
+
}
|
|
40
|
+
catch (_e) {
|
|
41
|
+
throw new Error(`Unable to decode JSON response from rest: ${result.substring(0, 255)}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async putRest(script, body, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
45
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
46
|
+
options = {}) {
|
|
47
|
+
const result = (await this.put(`${this.rootUrl}${script}`, body, params, headers, {
|
|
48
|
+
...options,
|
|
49
|
+
bodyDataEncoding: options.bodyDataEncoding || this.contentType,
|
|
50
|
+
responseDataType: ECommonsHttpResponseDataType.STRING
|
|
51
|
+
}));
|
|
52
|
+
try {
|
|
53
|
+
return JSON.parse(result);
|
|
54
|
+
}
|
|
55
|
+
catch (_e) {
|
|
56
|
+
throw new Error(`Unable to decode JSON response from rest: ${result.substring(0, 255)}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async patchRest(script, body, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
60
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
61
|
+
options = {}) {
|
|
62
|
+
const result = (await this.patch(`${this.rootUrl}${script}`, body, params, headers, {
|
|
63
|
+
...options,
|
|
64
|
+
bodyDataEncoding: options.bodyDataEncoding || this.contentType,
|
|
65
|
+
responseDataType: ECommonsHttpResponseDataType.STRING
|
|
66
|
+
}));
|
|
67
|
+
if (result.length === 0)
|
|
68
|
+
return undefined;
|
|
69
|
+
try {
|
|
70
|
+
return JSON.parse(result);
|
|
71
|
+
}
|
|
72
|
+
catch (_e) {
|
|
73
|
+
throw new Error(`Unable to decode JSON response from rest: ${result.substring(0, 255)}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async deleteRest(script, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
77
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
78
|
+
options = {}) {
|
|
79
|
+
const result = (await this.delete(`${this.rootUrl}${script}`, params, headers, {
|
|
80
|
+
...options,
|
|
81
|
+
responseDataType: ECommonsHttpResponseDataType.STRING
|
|
82
|
+
}));
|
|
83
|
+
if (result.length === 0)
|
|
84
|
+
return undefined;
|
|
85
|
+
try {
|
|
86
|
+
return JSON.parse(result);
|
|
87
|
+
}
|
|
88
|
+
catch (_e) {
|
|
89
|
+
throw new Error(`Unable to decode JSON response from rest: ${result.substring(0, 255)}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=commons-rest-client.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commons-rest-client.service.mjs","sourceRoot":"","sources":["../../src/services/commons-rest-client.service.mts"],"names":[],"mappings":"AACA,OAAO,E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AAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,6CAA6C,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QAC1F,CAAC;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ICommonsHttpClientImplementation, ECommonsHttpContentType, TCommonsHttpRequestOptions } from 'tscommons-esm-http';
|
|
2
|
+
import { CommonsAuthorizedRestClientService } from './commons-authorized-rest-client.service.mjs';
|
|
3
|
+
export declare class CommonsSessionRestClientService extends CommonsAuthorizedRestClientService {
|
|
4
|
+
protected authRestCall: string;
|
|
5
|
+
private activeSession;
|
|
6
|
+
private debug;
|
|
7
|
+
constructor(implementation: ICommonsHttpClientImplementation, rootUrl: string, authRestCall: string, contentType?: ECommonsHttpContentType);
|
|
8
|
+
setDebug(state: boolean): void;
|
|
9
|
+
getSession(): string | undefined;
|
|
10
|
+
setSession(sid: string | undefined): void;
|
|
11
|
+
validate(options?: TCommonsHttpRequestOptions): Promise<boolean>;
|
|
12
|
+
logoff(options?: TCommonsHttpRequestOptions): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ECommonsHttpContentType } from 'tscommons-esm-http';
|
|
2
|
+
import { ECommonsAuthorizationMethod } from '../enums/ecommons-authorization-method.mjs';
|
|
3
|
+
import { CommonsAuthorizedRestClientService } from './commons-authorized-rest-client.service.mjs';
|
|
4
|
+
export class CommonsSessionRestClientService extends CommonsAuthorizedRestClientService {
|
|
5
|
+
authRestCall;
|
|
6
|
+
activeSession;
|
|
7
|
+
debug = false;
|
|
8
|
+
constructor(implementation, rootUrl, authRestCall, contentType = ECommonsHttpContentType.FORM_URL) {
|
|
9
|
+
super(implementation, rootUrl, contentType);
|
|
10
|
+
this.authRestCall = authRestCall;
|
|
11
|
+
}
|
|
12
|
+
setDebug(state) {
|
|
13
|
+
this.debug = state;
|
|
14
|
+
}
|
|
15
|
+
getSession() {
|
|
16
|
+
return this.activeSession;
|
|
17
|
+
}
|
|
18
|
+
setSession(sid) {
|
|
19
|
+
this.activeSession = sid;
|
|
20
|
+
if (sid) {
|
|
21
|
+
this.setAuthorization(ECommonsAuthorizationMethod.SESSION, this.activeSession);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
this.setAuthorization(undefined, undefined);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async validate(options = {}) {
|
|
28
|
+
if (!this.activeSession)
|
|
29
|
+
return false;
|
|
30
|
+
try {
|
|
31
|
+
await this.headRest(this.authRestCall, undefined, undefined, options);
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
if (this.debug && console)
|
|
38
|
+
console.log(e); // eslint-disable-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
|
39
|
+
this.setSession(undefined);
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async logoff(options = {}) {
|
|
44
|
+
await this.deleteRest(this.authRestCall, undefined, undefined, options);
|
|
45
|
+
this.setSession(undefined);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=commons-session-rest-client.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commons-session-rest-client.service.mjs","sourceRoot":"","sources":["../../src/services/commons-session-rest-client.service.mts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,uBAAuB,EAA8B,MAAM,oBAAoB,CAAC;AAE3H,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAEzF,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AAElG,MAAM,OAAO,+BAAgC,SAAQ,kCAAkC;IAO1E;IANJ,aAAa,CAAmB;IAChC,KAAK,GAAY,KAAK,CAAC;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AC,YAAY,EACjB,SAAS,EACT,SAAS,EACT,OAAO,CACR,CAAC;QAEF,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC;CACD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ICommonsHttpClientImplementation, ECommonsHttpContentType, TCommonsHttpRequestOptions } from 'tscommons-esm-http';
|
|
2
|
+
import { CommonsSessionRestClientService } from './commons-session-rest-client.service.mjs';
|
|
3
|
+
export declare class CommonsSimpleSinglePwSessionRestClientService extends CommonsSessionRestClientService {
|
|
4
|
+
constructor(implementation: ICommonsHttpClientImplementation, rootUrl: string, authRestCall: string, contentType?: ECommonsHttpContentType);
|
|
5
|
+
authenticate(password: string, options?: TCommonsHttpRequestOptions): Promise<boolean>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { commonsTypeHasPropertyString } from 'tscommons-esm-core';
|
|
2
|
+
import { ECommonsHttpContentType } from 'tscommons-esm-http';
|
|
3
|
+
import { CommonsSessionRestClientService } from './commons-session-rest-client.service.mjs';
|
|
4
|
+
export class CommonsSimpleSinglePwSessionRestClientService extends CommonsSessionRestClientService {
|
|
5
|
+
constructor(implementation, rootUrl, authRestCall, contentType = ECommonsHttpContentType.FORM_URL) {
|
|
6
|
+
super(implementation, rootUrl, authRestCall, contentType);
|
|
7
|
+
}
|
|
8
|
+
async authenticate(password, options = {}) {
|
|
9
|
+
this.setSession(undefined);
|
|
10
|
+
const result = await this.postRest(this.authRestCall, {
|
|
11
|
+
pw: password
|
|
12
|
+
}, undefined, undefined, options);
|
|
13
|
+
if (!commonsTypeHasPropertyString(result, 'sid'))
|
|
14
|
+
return false;
|
|
15
|
+
this.setSession(result.sid);
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=commons-simple-single-pw-session-rest-client.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commons-simple-single-pw-session-rest-client.service.mjs","sourceRoot":"","sources":["../../src/services/commons-simple-single-pw-session-rest-client.service.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAoC,uBAAuB,EAA8B,MAAM,oBAAoB,CAAC;AAE3H,OAAO,EAAE,+BAA+B,EAAE,MAAM,2CAA2C,CAAC;AAE5F,MAAM,OAAO,6CAA8C,SAAQ,+BAA+B;IACjG,YACE,cAAgD,EAChD,OAAe,EACf,YAAoB,EACpB,cAAuC,uBAAuB,CAAC,QAAQ;QAExE,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;IAC3D,CAAC;IAEM,KAAK,CAAC,YAAY,CACvB,QAAgB,EAChB,UAAsC,EAAE;QAEzC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAE3B,MAAM,MAAM,GAAY,MAAM,IAAI,CAAC,QAAQ,CAGzC,IAAI,CAAC,YAAY,EACjB;YACE,EAAE,EAAE,QAAQ;SACb,EACD,SAAS,EACT,SAAS,EACT,OAAO,CACR,CAAC;QACF,IAAI,CAAC,4BAA4B,CAAC,MAAM,EAAE,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QAE/D,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,GAAa,CAAC,CAAC;QAEtC,OAAO,IAAI,CAAC;IACb,CAAC;CACD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { TEncoded, TEncodedObject } from 'tscommons-esm-core';
|
|
2
|
+
import { ICommonsStreamableHttpClientImplementation, ECommonsHttpContentType, TCommonsHttpRequestOptions } from 'tscommons-esm-http';
|
|
3
|
+
import { TCommonsStreamableRestObservable } from '../types/tcommons-streamable-rest-observable.mjs';
|
|
4
|
+
import { ECommonsAuthorizationMethod } from '../enums/ecommons-authorization-method.mjs';
|
|
5
|
+
import { CommonsStreamableRestClientService } from './commons-streamable-rest-client.service.mjs';
|
|
6
|
+
export declare class CommonsStreamableAuthorizedRestClientService extends CommonsStreamableRestClientService {
|
|
7
|
+
private authorizationMethod;
|
|
8
|
+
private authorizationValue;
|
|
9
|
+
constructor(implementation: ICommonsStreamableHttpClientImplementation, rootUrl: string, contentType?: ECommonsHttpContentType);
|
|
10
|
+
setAuthorization(method: ECommonsAuthorizationMethod | undefined, value: string | undefined): void;
|
|
11
|
+
hasAuthorization(): boolean;
|
|
12
|
+
protected patchHeaders<H extends TEncodedObject>(headers?: H): H | (H & {
|
|
13
|
+
'Authorization': string;
|
|
14
|
+
});
|
|
15
|
+
headRest<P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
16
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
17
|
+
options?: TCommonsHttpRequestOptions): Pick<TCommonsStreamableRestObservable<undefined>, 'outcome'>;
|
|
18
|
+
getRest<T extends TEncoded = TEncoded, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, parseDataStream: (data: string | Uint8Array) => T, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
19
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
20
|
+
options?: TCommonsHttpRequestOptions): TCommonsStreamableRestObservable<T>;
|
|
21
|
+
postRest<T extends TEncoded = TEncoded, B extends TEncodedObject = TEncodedObject, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, body: B, parseDataStream: (data: string | Uint8Array) => T, 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): TCommonsStreamableRestObservable<T>;
|
|
24
|
+
putRest<T extends TEncoded = TEncoded, B extends TEncodedObject = TEncodedObject, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, body: B, parseDataStream: (data: string | Uint8Array) => T, 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): TCommonsStreamableRestObservable<T>;
|
|
27
|
+
patchRest<T extends TEncoded = TEncoded, B extends TEncodedObject = TEncodedObject, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, body: B, parseDataStream: (data: string | Uint8Array) => T, 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): TCommonsStreamableRestObservable<T>;
|
|
30
|
+
deleteRest<T extends TEncoded = TEncoded, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, parseDataStream: (data: string | Uint8Array) => T, 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): TCommonsStreamableRestObservable<T | undefined>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ECommonsHttpContentType } from 'tscommons-esm-http';
|
|
2
|
+
import { fromECommonsAuthorizationMethod } from '../enums/ecommons-authorization-method.mjs';
|
|
3
|
+
import { CommonsStreamableRestClientService } from './commons-streamable-rest-client.service.mjs';
|
|
4
|
+
export class CommonsStreamableAuthorizedRestClientService extends CommonsStreamableRestClientService {
|
|
5
|
+
authorizationMethod;
|
|
6
|
+
authorizationValue;
|
|
7
|
+
constructor(implementation, rootUrl, contentType = ECommonsHttpContentType.FORM_URL) {
|
|
8
|
+
super(implementation, rootUrl, contentType);
|
|
9
|
+
}
|
|
10
|
+
setAuthorization(method, value) {
|
|
11
|
+
this.authorizationMethod = method;
|
|
12
|
+
this.authorizationValue = value;
|
|
13
|
+
}
|
|
14
|
+
hasAuthorization() {
|
|
15
|
+
return this.authorizationMethod !== undefined && this.authorizationValue !== undefined;
|
|
16
|
+
}
|
|
17
|
+
patchHeaders(headers) {
|
|
18
|
+
if (!this.authorizationMethod || !this.authorizationValue)
|
|
19
|
+
return { ...headers }; //eslint-disable-line @typescript-eslint/consistent-type-assertions
|
|
20
|
+
return {
|
|
21
|
+
...headers,
|
|
22
|
+
Authorization: `${fromECommonsAuthorizationMethod(this.authorizationMethod)} ${this.authorizationValue}`
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
headRest(script, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
26
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
27
|
+
options = {}) {
|
|
28
|
+
return super.headRest(script, params, this.patchHeaders(headers), options); // eslint-disable-line indent
|
|
29
|
+
}
|
|
30
|
+
getRest(script, parseDataStream, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
31
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
32
|
+
options = {}) {
|
|
33
|
+
return super.getRest(script, parseDataStream, params, this.patchHeaders(headers), options); // eslint-disable-line indent
|
|
34
|
+
}
|
|
35
|
+
postRest(script, body, parseDataStream, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
36
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
37
|
+
options = {}) {
|
|
38
|
+
return super.postRest(script, body, parseDataStream, params, this.patchHeaders(headers), options); // eslint-disable-line indent
|
|
39
|
+
}
|
|
40
|
+
putRest(script, body, parseDataStream, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
41
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
42
|
+
options = {}) {
|
|
43
|
+
return super.putRest(script, body, parseDataStream, params, this.patchHeaders(headers), options); // eslint-disable-line indent
|
|
44
|
+
}
|
|
45
|
+
patchRest(script, body, parseDataStream, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
46
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
47
|
+
options = {}) {
|
|
48
|
+
return super.patchRest(script, body, parseDataStream, params, this.patchHeaders(headers), options); // eslint-disable-line indent
|
|
49
|
+
}
|
|
50
|
+
deleteRest(script, parseDataStream, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
51
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
52
|
+
options = {}) {
|
|
53
|
+
return super.deleteRest(script, parseDataStream, params, this.patchHeaders(headers), options); // eslint-disable-line indent
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=commons-streamable-authorized-rest-client.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commons-streamable-authorized-rest-client.service.mjs","sourceRoot":"","sources":["../../src/services/commons-streamable-authorized-rest-client.service.mts"],"names":[],"mappings":"AACA,OAAO,EAA8C,uBAAuB,EAA8B,MAAM,oBAAoB,CAAC;AAIrI,OAAO,EAA+B,+BAA+B,EAAE,MAAM,4CAA4C,CAAC;AAE1H,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AAElG,MAAM,OAAO,4CAA6C,SAAQ,kCAAkC;IAC3F,mBAAmB,CAAwC;IAC3D,kBAAkB,CAAmB;IAE7C,YACE,cAA0D,EAC1D,OAAe,EACf,cAAuC,uBAAuB,CAAC,QAAQ;QAExE,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IAC7C,CAAC;IAEM,gBAAgB,CACrB,MAA6C,EAC7C,KAAuB;QAExB,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC;QAClC,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;IACjC,CAAC;IAEM,gBAAgB;QACtB,OAAO,IAAI,CAAC,mBAAmB,KAAK,SAAS,IAAI,IAAI,CAAC,kBAAkB,KAAK,SAAS,CAAC;IACxF,CAAC;IAES,YAAY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UAAuB,SAAS,EAAE,qEAAqE;IACvG,UAAsC,EAAE;QAEzC,OAAO,KAAK,CAAC,OAAO,CAGlB,MAAM,EACN,IAAI,EACJ,eAAe,EACf,MAAM,EACN,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAC1B,OAAO,CACR,CAAC,CAAC,6BAA6B;IACjC,CAAC;IAEe,SAAS,CAMvB,MAAc,EACd,IAAO,EACP,eAA+C,EAC/C,SAAsB,SAAS,EAAE,oEAAoE;IACrG,UAAuB,SAAS,EAAE,qEAAqE;IACvG,UAAsC,EAAE;QAEzC,OAAO,KAAK,CAAC,SAAS,CAGpB,MAAM,EACN,IAAI,EACJ,eAAe,EACf,MAAM,EACN,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAC1B,OAAO,CACR,CAAC,CAAC,6BAA6B;IACjC,CAAC;IAEe,UAAU,CAKxB,MAAc,EACd,eAA+C,EAC/C,SAAsB,SAAS,EAAE,oEAAoE;IACrG,UAAuB,SAAS,EAAE,qEAAqE;IACvG,UAAsC,EAAE;QAEzC,OAAO,KAAK,CAAC,UAAU,CAGrB,MAAM,EACN,eAAe,EACf,MAAM,EACN,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAC1B,OAAO,CACR,CAAC,CAAC,6BAA6B;IACjC,CAAC;CACD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ICommonsStreamableHttpClientImplementation, ECommonsHttpContentType } from 'tscommons-esm-http';
|
|
2
|
+
import { CommonsStreamableAuthorizedRestClientService } from './commons-streamable-authorized-rest-client.service.mjs';
|
|
3
|
+
export declare class CommonsStreamableKeyRestClientService extends CommonsStreamableAuthorizedRestClientService {
|
|
4
|
+
constructor(implementation: ICommonsStreamableHttpClientImplementation, rootUrl: string, authKey: string, contentType?: ECommonsHttpContentType);
|
|
5
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ECommonsHttpContentType } from 'tscommons-esm-http';
|
|
2
|
+
import { ECommonsAuthorizationMethod } from '../enums/ecommons-authorization-method.mjs';
|
|
3
|
+
import { CommonsStreamableAuthorizedRestClientService } from './commons-streamable-authorized-rest-client.service.mjs';
|
|
4
|
+
export class CommonsStreamableKeyRestClientService extends CommonsStreamableAuthorizedRestClientService {
|
|
5
|
+
constructor(implementation, rootUrl, authKey, contentType = ECommonsHttpContentType.FORM_URL) {
|
|
6
|
+
super(implementation, rootUrl, contentType);
|
|
7
|
+
this.setAuthorization(ECommonsAuthorizationMethod.KEY, authKey);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=commons-streamable-key-rest-client.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commons-streamable-key-rest-client.service.mjs","sourceRoot":"","sources":["../../src/services/commons-streamable-key-rest-client.service.mts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAEzG,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAEzF,OAAO,EAAE,4CAA4C,EAAE,MAAM,yDAAyD,CAAC;AAEvH,MAAM,OAAO,qCAAsC,SAAQ,4CAA4C;IACtG,YACE,cAA0D,EAC1D,OAAe,EACf,OAAe,EACf,cAAuC,uBAAuB,CAAC,QAAQ;QAExE,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;QAE5C,IAAI,CAAC,gBAAgB,CACnB,2BAA2B,CAAC,GAAG,EAC/B,OAAO,CACR,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TEncoded, TEncodedObject } from 'tscommons-esm-core';
|
|
2
|
+
import { CommonsStreamableHttpClientService, ECommonsHttpContentType, ICommonsStreamableHttpClientImplementation, TCommonsHttpRequestOptions } from 'tscommons-esm-http';
|
|
3
|
+
import { TCommonsStreamableRestObservable } from '../types/tcommons-streamable-rest-observable.mjs';
|
|
4
|
+
export declare class CommonsStreamableRestClientService extends CommonsStreamableHttpClientService {
|
|
5
|
+
private rootUrl;
|
|
6
|
+
private contentType;
|
|
7
|
+
constructor(implementation: ICommonsStreamableHttpClientImplementation, rootUrl: string, contentType?: ECommonsHttpContentType);
|
|
8
|
+
headRest<P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
9
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
10
|
+
options?: TCommonsHttpRequestOptions): Pick<TCommonsStreamableRestObservable<undefined>, 'outcome'>;
|
|
11
|
+
getRest<T extends TEncoded = TEncoded, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, parseDataStream: (data: string | Uint8Array) => T, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
12
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
13
|
+
options?: TCommonsHttpRequestOptions, dataStreamErrorCallback?: (e: Error) => void): TCommonsStreamableRestObservable<T>;
|
|
14
|
+
postRest<T extends TEncoded = TEncoded, B extends TEncodedObject = TEncodedObject, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, body: B, parseDataStream: (data: string | Uint8Array) => T, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
15
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
16
|
+
options?: TCommonsHttpRequestOptions, dataStreamErrorCallback?: (e: Error) => void): TCommonsStreamableRestObservable<T>;
|
|
17
|
+
putRest<T extends TEncoded = TEncoded, B extends TEncodedObject = TEncodedObject, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, body: B, parseDataStream: (data: string | Uint8Array) => T, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
18
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
19
|
+
options?: TCommonsHttpRequestOptions, dataStreamErrorCallback?: (e: Error) => void): TCommonsStreamableRestObservable<T>;
|
|
20
|
+
patchRest<T extends TEncoded = TEncoded, B extends TEncodedObject = TEncodedObject, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, body: B, parseDataStream: (data: string | Uint8Array) => T, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
21
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
22
|
+
options?: TCommonsHttpRequestOptions, dataStreamErrorCallback?: (e: Error) => void): TCommonsStreamableRestObservable<T>;
|
|
23
|
+
deleteRest<T extends TEncoded = TEncoded, P extends TEncodedObject = TEncodedObject, H extends TEncodedObject = TEncodedObject>(script: string, parseDataStream: (data: string | Uint8Array) => T, params?: P | undefined, // the params can be explicitly undefined (none) as well as optional
|
|
24
|
+
headers?: H | undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
25
|
+
options?: TCommonsHttpRequestOptions, dataStreamErrorCallback?: (e: Error) => void): TCommonsStreamableRestObservable<T | undefined>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Subject } from 'rxjs';
|
|
2
|
+
import { CommonsStreamableHttpClientService, ECommonsHttpContentType, ECommonsHttpResponseDataType } from 'tscommons-esm-http';
|
|
3
|
+
function handleTypedDataStream(stream, parseDataStream, dataStreamErrorCallback) {
|
|
4
|
+
const typedDataStream = new Subject();
|
|
5
|
+
const subscription = stream.dataStream
|
|
6
|
+
.subscribe((data) => {
|
|
7
|
+
try {
|
|
8
|
+
const typed = parseDataStream(data);
|
|
9
|
+
typedDataStream.next(typed);
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
dataStreamErrorCallback(e);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
const promise = new Promise((resolve, reject) => {
|
|
16
|
+
void (async () => {
|
|
17
|
+
try {
|
|
18
|
+
const outcome = await stream.outcome;
|
|
19
|
+
resolve(outcome);
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
reject(e);
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
subscription.unsubscribe();
|
|
26
|
+
}
|
|
27
|
+
})();
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
dataStream: typedDataStream,
|
|
31
|
+
outcome: promise
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export class CommonsStreamableRestClientService extends CommonsStreamableHttpClientService {
|
|
35
|
+
rootUrl;
|
|
36
|
+
contentType;
|
|
37
|
+
constructor(implementation, rootUrl, contentType = ECommonsHttpContentType.FORM_URL) {
|
|
38
|
+
super(implementation);
|
|
39
|
+
this.rootUrl = rootUrl;
|
|
40
|
+
this.contentType = contentType;
|
|
41
|
+
}
|
|
42
|
+
headRest(script, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
43
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
44
|
+
options = {}) {
|
|
45
|
+
const stream = this.head(`${this.rootUrl}${script}`, params, headers, options);
|
|
46
|
+
return {
|
|
47
|
+
outcome: stream.outcome
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
getRest(script, parseDataStream, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
51
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
52
|
+
options = {}, dataStreamErrorCallback = (_e) => {
|
|
53
|
+
// do nothing
|
|
54
|
+
}) {
|
|
55
|
+
const stream = this.get(`${this.rootUrl}${script}`, params, headers, {
|
|
56
|
+
...options,
|
|
57
|
+
responseDataType: ECommonsHttpResponseDataType.STRING
|
|
58
|
+
});
|
|
59
|
+
return handleTypedDataStream(stream, parseDataStream, dataStreamErrorCallback);
|
|
60
|
+
}
|
|
61
|
+
postRest(script, body, parseDataStream, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
62
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
63
|
+
options = {}, dataStreamErrorCallback = (_e) => {
|
|
64
|
+
// do nothing
|
|
65
|
+
}) {
|
|
66
|
+
const stream = this.post(`${this.rootUrl}${script}`, body, params, headers, {
|
|
67
|
+
...options,
|
|
68
|
+
bodyDataEncoding: options.bodyDataEncoding || this.contentType,
|
|
69
|
+
responseDataType: ECommonsHttpResponseDataType.STRING
|
|
70
|
+
});
|
|
71
|
+
return handleTypedDataStream(stream, parseDataStream, dataStreamErrorCallback);
|
|
72
|
+
}
|
|
73
|
+
putRest(script, body, parseDataStream, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
74
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
75
|
+
options = {}, dataStreamErrorCallback = (_e) => {
|
|
76
|
+
// do nothing
|
|
77
|
+
}) {
|
|
78
|
+
const stream = this.put(`${this.rootUrl}${script}`, body, params, headers, {
|
|
79
|
+
...options,
|
|
80
|
+
bodyDataEncoding: options.bodyDataEncoding || this.contentType,
|
|
81
|
+
responseDataType: ECommonsHttpResponseDataType.STRING
|
|
82
|
+
});
|
|
83
|
+
return handleTypedDataStream(stream, parseDataStream, dataStreamErrorCallback);
|
|
84
|
+
}
|
|
85
|
+
patchRest(script, body, parseDataStream, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
86
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
87
|
+
options = {}, dataStreamErrorCallback = (_e) => {
|
|
88
|
+
// do nothing
|
|
89
|
+
}) {
|
|
90
|
+
const stream = this.patch(`${this.rootUrl}${script}`, body, params, headers, {
|
|
91
|
+
...options,
|
|
92
|
+
bodyDataEncoding: options.bodyDataEncoding || this.contentType,
|
|
93
|
+
responseDataType: ECommonsHttpResponseDataType.STRING
|
|
94
|
+
});
|
|
95
|
+
return handleTypedDataStream(stream, parseDataStream, dataStreamErrorCallback);
|
|
96
|
+
}
|
|
97
|
+
deleteRest(script, parseDataStream, params = undefined, // the params can be explicitly undefined (none) as well as optional
|
|
98
|
+
headers = undefined, // the headers can be explicitly undefined (none) as well as optional
|
|
99
|
+
options = {}, dataStreamErrorCallback = (_e) => {
|
|
100
|
+
// do nothing
|
|
101
|
+
}) {
|
|
102
|
+
const stream = this.delete(`${this.rootUrl}${script}`, params, headers, {
|
|
103
|
+
...options,
|
|
104
|
+
responseDataType: ECommonsHttpResponseDataType.STRING
|
|
105
|
+
});
|
|
106
|
+
return handleTypedDataStream(stream, parseDataStream, dataStreamErrorCallback);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=commons-streamable-rest-client.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commons-streamable-rest-client.service.mjs","sourceRoot":"","sources":["../../src/services/commons-streamable-rest-client.service.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAgB,MAAM,MAAM,CAAC;AAG7C,OAAO,EAAoB,kCAAkC,EAAE,uBAAuB,EAAE,4BAA4B,EAA4G,MAAM,oBAAoB,CAAC;AAI3P,SAAS,qBAAqB,CAC5B,MAAwC,EACxC,eAA+C,EAC/C,uBAA2C;IAE5C,MAAM,eAAe,GAAe,IAAI,OAAO,EAAK,CAAC;IAErD,MAAM,YAAY,GAAiB,MAAM,CAAC,UAAU;SACjD,SAAS,CAAC,CAAC,IAAuB,EAAQ,EAAE;QAC5C,IAAI,CAAC;YACJ,MAAM,KAAK,GAAM,eAAe,CAAC,IAAI,CAAC,CAAC;YACvC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,uBAAuB,CAAC,CAAU,CAAC,CAAC;QACrC,CAAC;IACF,CAAC,CAAC,CAAC;IAEL,MAAM,OAAO,GAAmC,IAAI,OAAO,CAAwB,CAAC,OAAiD,EAAE,MAA0B,EAAQ,EAAE;QAC1K,KAAK,CAAC,KAAK,IAAmB,EAAE;YAC/B,IAAI,CAAC;gBACJ,MAAM,OAAO,GAA0B,MAAM,MAAM,CAA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AS,CAMd,MAAc,EACd,IAAO,EACP,eAA+C,EAC/C,SAAsB,SAAS,EAAE,oEAAoE;IACrG,UAAuB,SAAS,EAAE,qEAAqE;IACvG,UAAsC,EAAE,EACxC,0BAA8C,CAAC,EAAS,EAAQ,EAAE;QACjE,aAAa;IACd,CAAC;QAEF,MAAM,MAAM,GAAqC,IAAI,CAAC,KAAK,CACzD,GAAG,IAAI,CAAC,OAAO,GAAG,MAAM,EAAE,EAC1B,IAAI,EACJ,MAAM,EACN,OAAO,EACP;YACE,GAAG,OAAO;YACV,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,IAAI,IAAI,CAAC,WAAW;YAC9D,gBAAgB,EAAE,4BAA4B,CAAC,MAAM;SACtD,CACF,CAAC;QAEF,OAAO,qBAAqB,CAC1B,MAAM,EACN,eAAe,EACf,uBAAuB,CACxB,CAAC;IACH,CAAC;IAEM,UAAU,CAKf,MAAc,EACd,eAA+C,EAC/C,SAAsB,SAAS,EAAE,oEAAoE;IACrG,UAAuB,SAAS,EAAE,qEAAqE;IACvG,UAAsC,EAAE,EACxC,0BAA8C,CAAC,EAAS,EAAQ,EAAE;QACjE,aAAa;IACd,CAAC;QAEF,MAAM,MAAM,GAAqC,IAAI,CAAC,MAAM,CAC1D,GAAG,IAAI,CAAC,OAAO,GAAG,MAAM,EAAE,EAC1B,MAAM,EACN,OAAO,EACP;YACE,GAAG,OAAO;YACV,gBAAgB,EAAE,4BAA4B,CAAC,MAAM;SACtD,CACF,CAAC;QAEF,OAAO,qBAAqB,CAC1B,MAAM,EACN,eAAe,EACf,uBAAuB,CACxB,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TEncodedObject } from 'tscommons-esm-core';
|
|
2
|
+
import { ICommonsHttpClientImplementation, ECommonsHttpContentType, TCommonsHttpRequestOptions } from 'tscommons-esm-http';
|
|
3
|
+
import { CommonsUserSessionRestClientService } from './commons-user-session-rest-client.service.mjs';
|
|
4
|
+
export declare class CommonsUserPwSessionRestClientService extends CommonsUserSessionRestClientService {
|
|
5
|
+
constructor(implementation: ICommonsHttpClientImplementation, rootUrl: string, authRestCall: string, contentType?: ECommonsHttpContentType);
|
|
6
|
+
logonWithPw(username: string, pw: string, data?: TEncodedObject, options?: TCommonsHttpRequestOptions): Promise<boolean>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ECommonsHttpContentType } from 'tscommons-esm-http';
|
|
2
|
+
import { CommonsUserSessionRestClientService } from './commons-user-session-rest-client.service.mjs';
|
|
3
|
+
export class CommonsUserPwSessionRestClientService extends CommonsUserSessionRestClientService {
|
|
4
|
+
constructor(implementation, rootUrl, authRestCall, contentType = ECommonsHttpContentType.FORM_URL) {
|
|
5
|
+
super(implementation, rootUrl, authRestCall, contentType);
|
|
6
|
+
}
|
|
7
|
+
async logonWithPw(username, pw, data = {}, options = {}) {
|
|
8
|
+
data['pw'] = pw;
|
|
9
|
+
return await this.logon(username, data, options);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=commons-user-pw-session-rest-client.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commons-user-pw-session-rest-client.service.mjs","sourceRoot":"","sources":["../../src/services/commons-user-pw-session-rest-client.service.mts"],"names":[],"mappings":"AACA,OAAO,EAAoC,uBAAuB,EAA8B,MAAM,oBAAoB,CAAC;AAE3H,OAAO,EAAE,mCAAmC,EAAE,MAAM,gDAAgD,CAAC;AAErG,MAAM,OAAO,qCAAsC,SAAQ,mCAAmC;IAC7F,YACE,cAAgD,EAChD,OAAe,EACf,YAAoB,EACpB,cAAuC,uBAAuB,CAAC,QAAQ;QAExE,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;IAC3D,CAAC;IAEM,KAAK,CAAC,WAAW,CACtB,QAAgB,EAChB,EAAU,EACV,OAAuB,EAAE,EACzB,UAAsC,EAAE;QAEzC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAEhB,OAAO,MAAM,IAAI,CAAC,KAAK,CACrB,QAAQ,EACR,IAAI,EACJ,OAAO,CACR,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TEncodedObject } from 'tscommons-esm-core';
|
|
2
|
+
import { ICommonsHttpClientImplementation, ECommonsHttpContentType, TCommonsHttpRequestOptions } from 'tscommons-esm-http';
|
|
3
|
+
import { CommonsSessionRestClientService } from './commons-session-rest-client.service.mjs';
|
|
4
|
+
export declare class CommonsUserSessionRestClientService extends CommonsSessionRestClientService {
|
|
5
|
+
constructor(implementation: ICommonsHttpClientImplementation, rootUrl: string, authRestCall: string, contentType?: ECommonsHttpContentType);
|
|
6
|
+
logon(username: string, data?: TEncodedObject, options?: TCommonsHttpRequestOptions): Promise<boolean>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { commonsTypeHasPropertyString } from 'tscommons-esm-core';
|
|
2
|
+
import { ECommonsHttpContentType } from 'tscommons-esm-http';
|
|
3
|
+
import { CommonsSessionRestClientService } from './commons-session-rest-client.service.mjs';
|
|
4
|
+
export class CommonsUserSessionRestClientService extends CommonsSessionRestClientService {
|
|
5
|
+
constructor(implementation, rootUrl, authRestCall, contentType = ECommonsHttpContentType.FORM_URL) {
|
|
6
|
+
super(implementation, rootUrl, authRestCall, contentType);
|
|
7
|
+
}
|
|
8
|
+
async logon(username, data = {}, options = {}) {
|
|
9
|
+
this.setSession(undefined);
|
|
10
|
+
const result = await this.postRest(`${this.authRestCall}/${username}`, data, undefined, undefined, options);
|
|
11
|
+
if (!commonsTypeHasPropertyString(result, 'sid'))
|
|
12
|
+
return false;
|
|
13
|
+
this.setSession(result['sid']);
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=commons-user-session-rest-client.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commons-user-session-rest-client.service.mjs","sourceRoot":"","sources":["../../src/services/commons-user-session-rest-client.service.mts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAoC,uBAAuB,EAA8B,MAAM,oBAAoB,CAAC;AAE3H,OAAO,EAAE,+BAA+B,EAAE,MAAM,2CAA2C,CAAC;AAE5F,MAAM,OAAO,mCAAoC,SAAQ,+BAA+B;IACvF,YACE,cAAgD,EAChD,OAAe,EACf,YAAoB,EACpB,cAAuC,uBAAuB,CAAC,QAAQ;QAExE,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;IAC3D,CAAC;IAEM,KAAK,CAAC,KAAK,CAChB,QAAgB,EAChB,OAAuB,EAAE,EACzB,UAAsC,EAAE;QAEzC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAE3B,MAAM,MAAM,GAAY,MAAM,IAAI,CAAC,QAAQ,CAGzC,GAAG,IAAI,CAAC,YAAY,IAAI,QAAQ,EAAE,EAClC,IAAI,EACJ,SAAS,EACT,SAAS,EACT,OAAO,CACR,CAAC;QACF,IAAI,CAAC,4BAA4B,CAAC,MAAM,EAAE,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QAE/D,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAW,CAAC,CAAC;QAEzC,OAAO,IAAI,CAAC;IACb,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tcommons-streamable-rest-observable.mjs","sourceRoot":"","sources":["../../src/types/tcommons-streamable-rest-observable.mts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tscommons-esm-rest",
|
|
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
|
+
"tscommons-esm-http": "^0.0.2"
|
|
31
|
+
}
|
|
32
|
+
}
|