@christianriedl/rest 1.0.53 → 1.0.54
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/authorize.d.ts +57 -55
- package/dist/authorize.js +137 -131
- package/dist/authorize.js.map +1 -1
- package/dist/dummyOauth.d.ts +10 -10
- package/dist/dummyOauth.js +23 -23
- package/dist/iOauth.d.ts +7 -7
- package/dist/iOauth.js +2 -2
- package/dist/iRest.d.ts +35 -35
- package/dist/iRest.js +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/oauth.d.ts +40 -40
- package/dist/oauth.js +212 -212
- package/dist/oauth.js.map +1 -1
- package/dist/rest.d.ts +32 -32
- package/dist/rest.js +323 -323
- package/dist/rest.js.map +1 -1
- package/package.json +4 -4
package/dist/authorize.d.ts
CHANGED
|
@@ -1,55 +1,57 @@
|
|
|
1
|
-
import { ILocalStorage, ILogger, IAppConfig, IAppState, EScope, Dictionary, InjectionKey } from '@christianriedl/utils';
|
|
2
|
-
import { Rest } from './rest';
|
|
3
|
-
export declare const authorizeSymbol: InjectionKey<Authorize>;
|
|
4
|
-
export interface IAuthorizeResult {
|
|
5
|
-
mediaSecret: string;
|
|
6
|
-
smarthomeSecret: string;
|
|
7
|
-
googleMapsKey: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
get
|
|
44
|
-
set
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
1
|
+
import { ILocalStorage, ILogger, IAppConfig, IAppState, EScope, Dictionary, InjectionKey } from '@christianriedl/utils';
|
|
2
|
+
import { Rest } from './rest';
|
|
3
|
+
export declare const authorizeSymbol: InjectionKey<Authorize>;
|
|
4
|
+
export interface IAuthorizeResult {
|
|
5
|
+
mediaSecret: string;
|
|
6
|
+
smarthomeSecret: string;
|
|
7
|
+
googleMapsKey: string;
|
|
8
|
+
openAIKey: string;
|
|
9
|
+
bigEndian: boolean;
|
|
10
|
+
scopes: string;
|
|
11
|
+
user: string;
|
|
12
|
+
name: string;
|
|
13
|
+
password: string;
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface IAuthorizationResult {
|
|
17
|
+
scopes: string;
|
|
18
|
+
user: string;
|
|
19
|
+
name: string;
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
lastLogin: Date;
|
|
22
|
+
}
|
|
23
|
+
export interface IMeta {
|
|
24
|
+
scopes: EScope;
|
|
25
|
+
}
|
|
26
|
+
export interface IRoute {
|
|
27
|
+
path: string;
|
|
28
|
+
meta?: IMeta;
|
|
29
|
+
}
|
|
30
|
+
export declare class Authorize {
|
|
31
|
+
rest: Rest;
|
|
32
|
+
storage: ILocalStorage;
|
|
33
|
+
secretSmarthome: string;
|
|
34
|
+
secretMedia: string;
|
|
35
|
+
keyGoogleMaps: string;
|
|
36
|
+
keyOpenAI: string;
|
|
37
|
+
bigEndian: boolean;
|
|
38
|
+
routes: Dictionary<IRoute>;
|
|
39
|
+
password: string;
|
|
40
|
+
appConfig: IAppConfig;
|
|
41
|
+
appState: IAppState;
|
|
42
|
+
authorizations: IAuthorizationResult[];
|
|
43
|
+
get user(): string;
|
|
44
|
+
set user(value: string);
|
|
45
|
+
get name(): string;
|
|
46
|
+
set name(value: string);
|
|
47
|
+
constructor(url: string, storage: ILocalStorage, appConfig: IAppConfig, appState: IAppState, logger: ILogger);
|
|
48
|
+
setScopes(scopes: string): void;
|
|
49
|
+
setRoutes(routes: IRoute[]): void;
|
|
50
|
+
checkScopeNames(scopes: string[]): boolean;
|
|
51
|
+
checkScope(scopes: EScope): boolean;
|
|
52
|
+
checkRoute(path: string): boolean;
|
|
53
|
+
getAuthorizations(): Promise<IAuthorizationResult[]>;
|
|
54
|
+
authorize(user: string, password: string): Promise<IAuthorizeResult>;
|
|
55
|
+
login(user: string, password: string): Promise<IAuthorizeResult>;
|
|
56
|
+
processResult(res: IAuthorizeResult, all: boolean): void;
|
|
57
|
+
}
|
package/dist/authorize.js
CHANGED
|
@@ -1,132 +1,138 @@
|
|
|
1
|
-
import { EScope, Helper } from '@christianriedl/utils';
|
|
2
|
-
import { Rest } from './rest';
|
|
3
|
-
import { DummyOAuth } from './dummyOauth';
|
|
4
|
-
export const authorizeSymbol = Symbol('authorize');
|
|
5
|
-
export class Authorize {
|
|
6
|
-
rest;
|
|
7
|
-
storage;
|
|
8
|
-
secretSmarthome;
|
|
9
|
-
secretMedia;
|
|
10
|
-
keyGoogleMaps;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (route
|
|
70
|
-
return
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
this.
|
|
111
|
-
this.
|
|
112
|
-
this.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
1
|
+
import { EScope, Helper } from '@christianriedl/utils';
|
|
2
|
+
import { Rest } from './rest';
|
|
3
|
+
import { DummyOAuth } from './dummyOauth';
|
|
4
|
+
export const authorizeSymbol = Symbol('authorize');
|
|
5
|
+
export class Authorize {
|
|
6
|
+
rest;
|
|
7
|
+
storage;
|
|
8
|
+
secretSmarthome;
|
|
9
|
+
secretMedia;
|
|
10
|
+
keyGoogleMaps;
|
|
11
|
+
keyOpenAI;
|
|
12
|
+
bigEndian;
|
|
13
|
+
routes = {};
|
|
14
|
+
password;
|
|
15
|
+
appConfig;
|
|
16
|
+
appState;
|
|
17
|
+
authorizations = [];
|
|
18
|
+
get user() {
|
|
19
|
+
return this.appConfig.user;
|
|
20
|
+
}
|
|
21
|
+
set user(value) {
|
|
22
|
+
this.appConfig.user = value;
|
|
23
|
+
}
|
|
24
|
+
get name() {
|
|
25
|
+
return this.appConfig.name;
|
|
26
|
+
}
|
|
27
|
+
set name(value) {
|
|
28
|
+
this.appConfig.name = value;
|
|
29
|
+
}
|
|
30
|
+
constructor(url, storage, appConfig, appState, logger) {
|
|
31
|
+
this.rest = new Rest(url, 'same-origin', new DummyOAuth(), logger, true);
|
|
32
|
+
this.storage = storage;
|
|
33
|
+
this.appConfig = appConfig;
|
|
34
|
+
this.appState = appState;
|
|
35
|
+
this.secretMedia = storage.getItemString('secretMedia', '');
|
|
36
|
+
this.secretSmarthome = storage.getItemString('secretSmarthome', '');
|
|
37
|
+
this.keyGoogleMaps = storage.getItemString('keyGoogleMaps', '');
|
|
38
|
+
this.keyOpenAI = storage.getItemString('keyOpenAI', '');
|
|
39
|
+
this.password = storage.getItemString('password', '');
|
|
40
|
+
this.bigEndian = storage.getItemBoolean('bigEndian', true);
|
|
41
|
+
const scopes = storage.getItemString('scopes');
|
|
42
|
+
if (scopes)
|
|
43
|
+
this.setScopes(scopes);
|
|
44
|
+
}
|
|
45
|
+
setScopes(scopes) {
|
|
46
|
+
const splitScopes = scopes.split('|');
|
|
47
|
+
for (let i = 0; i < splitScopes.length; i++) {
|
|
48
|
+
this.appState.scopes = this.appState.scopes | Helper.stringToEnum(EScope, splitScopes[i]);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
setRoutes(routes) {
|
|
52
|
+
for (let i = 0; i < routes.length; i++) {
|
|
53
|
+
this.routes[routes[i].path] = routes[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
checkScopeNames(scopes) {
|
|
57
|
+
for (let i = 0; i < scopes.length; i++) {
|
|
58
|
+
const scope = Helper.stringToEnum(EScope, scopes[i]);
|
|
59
|
+
if ((scope & this.appState.scopes) == 0)
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
checkScope(scopes) {
|
|
65
|
+
return (this.appState.scopes & scopes) == scopes;
|
|
66
|
+
}
|
|
67
|
+
checkRoute(path) {
|
|
68
|
+
const route = this.routes[path];
|
|
69
|
+
if (!route)
|
|
70
|
+
return false;
|
|
71
|
+
if (route.meta)
|
|
72
|
+
return this.checkScope(route.meta.scopes);
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
async getAuthorizations() {
|
|
76
|
+
const result = await this.rest.getData("apiauth/authorizations");
|
|
77
|
+
if (result.ok && result.result) {
|
|
78
|
+
this.authorizations = result.result;
|
|
79
|
+
for (let i = 0; i < this.authorizations.length; i++) {
|
|
80
|
+
const auth = this.authorizations[i];
|
|
81
|
+
if (typeof auth.lastLogin === 'string')
|
|
82
|
+
auth.lastLogin == new Date(auth.lastLogin);
|
|
83
|
+
}
|
|
84
|
+
this.authorizations;
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
async authorize(user, password) {
|
|
89
|
+
const result = await this.rest.postDataEx("apiauth/authorize", { user: user, password: password });
|
|
90
|
+
if (result.ok && result.result) {
|
|
91
|
+
const res = result.result;
|
|
92
|
+
this.processResult(res, true);
|
|
93
|
+
return res;
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
async login(user, password) {
|
|
98
|
+
const result = await this.rest.postDataEx("apiauth/login", { user: user, password: password });
|
|
99
|
+
if (result.ok && result.result) {
|
|
100
|
+
const res = result.result;
|
|
101
|
+
this.processResult(res, false);
|
|
102
|
+
return res;
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
processResult(res, all) {
|
|
107
|
+
this.storage.setItem('scopes', res.scopes);
|
|
108
|
+
this.setScopes(res.scopes);
|
|
109
|
+
if (all) {
|
|
110
|
+
this.user = res.user;
|
|
111
|
+
this.name = res.name;
|
|
112
|
+
this.appConfig.save();
|
|
113
|
+
this.password = res.password;
|
|
114
|
+
this.storage.setItem('password', res.password);
|
|
115
|
+
}
|
|
116
|
+
if (this.secretMedia != res.mediaSecret) {
|
|
117
|
+
this.secretMedia = res.mediaSecret;
|
|
118
|
+
this.storage.setItem('secretMedia', res.mediaSecret);
|
|
119
|
+
}
|
|
120
|
+
if (this.secretSmarthome != res.smarthomeSecret) {
|
|
121
|
+
this.secretSmarthome = res.smarthomeSecret;
|
|
122
|
+
this.storage.setItem('secretSmarthome', res.smarthomeSecret);
|
|
123
|
+
}
|
|
124
|
+
if (this.keyGoogleMaps != res.googleMapsKey) {
|
|
125
|
+
this.keyGoogleMaps = res.googleMapsKey;
|
|
126
|
+
this.storage.setItem('keyGoogleMaps', res.googleMapsKey);
|
|
127
|
+
}
|
|
128
|
+
if (this.keyOpenAI != res.openAIKey) {
|
|
129
|
+
this.keyOpenAI = res.openAIKey;
|
|
130
|
+
this.storage.setItem('keyOpenAI', res.openAIKey);
|
|
131
|
+
}
|
|
132
|
+
if (this.bigEndian != res.bigEndian) {
|
|
133
|
+
this.bigEndian = res.bigEndian;
|
|
134
|
+
this.storage.setItem('bigEndian', res.bigEndian);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
132
138
|
//# sourceMappingURL=authorize.js.map
|
package/dist/authorize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorize.js","sourceRoot":"","sources":["../src/authorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiD,MAAM,EAAc,MAAM,EAAgB,MAAM,uBAAuB,CAAC;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C,aAAa,CAAC,CAAC;QAC7D,CAAC;QACD,IAAI,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;YAClC,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;YAC/B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;QACrD,CAAC;QACD,IAAI,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;YAClC,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;YAC/B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;QACrD,CAAC;IACL,CAAC;CACJ"}
|
package/dist/dummyOauth.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IOAuth } from './iOauth';
|
|
2
|
-
export declare class DummyOAuth implements IOAuth {
|
|
3
|
-
mode: RequestMode;
|
|
4
|
-
token: string;
|
|
5
|
-
clientId: string;
|
|
6
|
-
role: string;
|
|
7
|
-
constructor(mode?: RequestMode, role?: string);
|
|
8
|
-
getToken(): Promise<string>;
|
|
9
|
-
getAccessToken(clientId: string, clientSecret: string): Promise<boolean>;
|
|
10
|
-
}
|
|
1
|
+
import { IOAuth } from './iOauth';
|
|
2
|
+
export declare class DummyOAuth implements IOAuth {
|
|
3
|
+
mode: RequestMode;
|
|
4
|
+
token: string;
|
|
5
|
+
clientId: string;
|
|
6
|
+
role: string;
|
|
7
|
+
constructor(mode?: RequestMode, role?: string);
|
|
8
|
+
getToken(): Promise<string>;
|
|
9
|
+
getAccessToken(clientId: string, clientSecret: string): Promise<boolean>;
|
|
10
|
+
}
|
package/dist/dummyOauth.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export class DummyOAuth {
|
|
2
|
-
mode = "same-origin";
|
|
3
|
-
token = "";
|
|
4
|
-
clientId = "";
|
|
5
|
-
role = "";
|
|
6
|
-
constructor(mode, role) {
|
|
7
|
-
if (mode)
|
|
8
|
-
this.mode = mode;
|
|
9
|
-
if (role)
|
|
10
|
-
this.role = role;
|
|
11
|
-
}
|
|
12
|
-
getToken() {
|
|
13
|
-
return new Promise((resolve, reject) => {
|
|
14
|
-
resolve(this.token);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
getAccessToken(clientId, clientSecret) {
|
|
18
|
-
this.clientId = clientId;
|
|
19
|
-
return new Promise((resolve, reject) => {
|
|
20
|
-
resolve(true);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
1
|
+
export class DummyOAuth {
|
|
2
|
+
mode = "same-origin";
|
|
3
|
+
token = "";
|
|
4
|
+
clientId = "";
|
|
5
|
+
role = "";
|
|
6
|
+
constructor(mode, role) {
|
|
7
|
+
if (mode)
|
|
8
|
+
this.mode = mode;
|
|
9
|
+
if (role)
|
|
10
|
+
this.role = role;
|
|
11
|
+
}
|
|
12
|
+
getToken() {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
resolve(this.token);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
getAccessToken(clientId, clientSecret) {
|
|
18
|
+
this.clientId = clientId;
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
resolve(true);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
24
|
//# sourceMappingURL=dummyOauth.js.map
|
package/dist/iOauth.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export interface IOAuth {
|
|
2
|
-
mode: RequestMode;
|
|
3
|
-
clientId: string;
|
|
4
|
-
role: string;
|
|
5
|
-
getToken(): Promise<string>;
|
|
6
|
-
getAccessToken(clientId: string, clientSecret: string): Promise<boolean>;
|
|
7
|
-
}
|
|
1
|
+
export interface IOAuth {
|
|
2
|
+
mode: RequestMode;
|
|
3
|
+
clientId: string;
|
|
4
|
+
role: string;
|
|
5
|
+
getToken(): Promise<string>;
|
|
6
|
+
getAccessToken(clientId: string, clientSecret: string): Promise<boolean>;
|
|
7
|
+
}
|
package/dist/iOauth.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
;
|
|
2
|
-
export {};
|
|
1
|
+
;
|
|
2
|
+
export {};
|
|
3
3
|
//# sourceMappingURL=iOauth.js.map
|
package/dist/iRest.d.ts
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
[key: string]: T;
|
|
3
|
-
};
|
|
4
|
-
export interface IProblemResult {
|
|
5
|
-
statusCode: number;
|
|
6
|
-
errors: Dictionary<string> | string;
|
|
7
|
-
detail: string;
|
|
8
|
-
instance: string;
|
|
9
|
-
title: string;
|
|
10
|
-
type: string;
|
|
11
|
-
}
|
|
12
|
-
export interface IValueResult<T> {
|
|
13
|
-
result: T;
|
|
14
|
-
}
|
|
15
|
-
export interface IRestResult<T> {
|
|
16
|
-
statusCode: number;
|
|
17
|
-
ok: boolean;
|
|
18
|
-
statusText?: string;
|
|
19
|
-
headers?: Headers;
|
|
20
|
-
result?: IProblemResult | T | IValueResult<T>;
|
|
21
|
-
}
|
|
22
|
-
export interface IRest {
|
|
23
|
-
serviceUrl: string;
|
|
24
|
-
getData<T>(path: string, queryParameter?: Dictionary<any>, adjustResult?: (result: IRestResult<T>) => void): Promise<IRestResult<T>>;
|
|
25
|
-
postData<T>(path: string, data?: T): Promise<IRestResult<boolean>>;
|
|
26
|
-
postDataEx<T, R>(path: string, data?: T, adjustResult?: (result: IRestResult<R>) => void): Promise<IRestResult<R>>;
|
|
27
|
-
putData<T, R>(path: string, data?: T, adjustResult?: (result: IRestResult<R>) => void): Promise<IRestResult<R>>;
|
|
28
|
-
deleteData<T, R>(path: string, data?: T, adjustResult?: (result: IRestResult<R>) => void): Promise<IRestResult<R>>;
|
|
29
|
-
getBlob(path: string, mediaType: string, queryParameter?: Dictionary<any>, headers?: Dictionary<string>): Promise<IRestResult<Blob>>;
|
|
30
|
-
postBlob<RESP>(path: string, blob: Blob, mediaType?: string, responseType?: string): Promise<IRestResult<RESP>>;
|
|
31
|
-
toBoolean(result: Promise<IRestResult<boolean>>): Promise<boolean>;
|
|
32
|
-
toData<T>(result: Promise<IRestResult<T>>): Promise<T>;
|
|
33
|
-
toPromise<T>(data: T): Promise<T>;
|
|
34
|
-
}
|
|
35
|
-
export {};
|
|
1
|
+
type Dictionary<T> = {
|
|
2
|
+
[key: string]: T;
|
|
3
|
+
};
|
|
4
|
+
export interface IProblemResult {
|
|
5
|
+
statusCode: number;
|
|
6
|
+
errors: Dictionary<string> | string;
|
|
7
|
+
detail: string;
|
|
8
|
+
instance: string;
|
|
9
|
+
title: string;
|
|
10
|
+
type: string;
|
|
11
|
+
}
|
|
12
|
+
export interface IValueResult<T> {
|
|
13
|
+
result: T;
|
|
14
|
+
}
|
|
15
|
+
export interface IRestResult<T> {
|
|
16
|
+
statusCode: number;
|
|
17
|
+
ok: boolean;
|
|
18
|
+
statusText?: string;
|
|
19
|
+
headers?: Headers;
|
|
20
|
+
result?: IProblemResult | T | IValueResult<T>;
|
|
21
|
+
}
|
|
22
|
+
export interface IRest {
|
|
23
|
+
serviceUrl: string;
|
|
24
|
+
getData<T>(path: string, queryParameter?: Dictionary<any>, adjustResult?: (result: IRestResult<T>) => void): Promise<IRestResult<T>>;
|
|
25
|
+
postData<T>(path: string, data?: T): Promise<IRestResult<boolean>>;
|
|
26
|
+
postDataEx<T, R>(path: string, data?: T, adjustResult?: (result: IRestResult<R>) => void): Promise<IRestResult<R>>;
|
|
27
|
+
putData<T, R>(path: string, data?: T, adjustResult?: (result: IRestResult<R>) => void): Promise<IRestResult<R>>;
|
|
28
|
+
deleteData<T, R>(path: string, data?: T, adjustResult?: (result: IRestResult<R>) => void): Promise<IRestResult<R>>;
|
|
29
|
+
getBlob(path: string, mediaType: string, queryParameter?: Dictionary<any>, headers?: Dictionary<string>): Promise<IRestResult<Blob>>;
|
|
30
|
+
postBlob<RESP>(path: string, blob: Blob, mediaType?: string, responseType?: string): Promise<IRestResult<RESP>>;
|
|
31
|
+
toBoolean(result: Promise<IRestResult<boolean>>): Promise<boolean>;
|
|
32
|
+
toData<T>(result: Promise<IRestResult<T>>): Promise<T>;
|
|
33
|
+
toPromise<T>(data: T): Promise<T>;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
package/dist/iRest.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=iRest.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './rest';
|
|
2
|
-
export * from './oauth';
|
|
3
|
-
export * from './dummyOauth';
|
|
4
|
-
export * from './authorize';
|
|
1
|
+
export * from './rest';
|
|
2
|
+
export * from './oauth';
|
|
3
|
+
export * from './dummyOauth';
|
|
4
|
+
export * from './authorize';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './rest';
|
|
2
|
-
export * from './oauth';
|
|
3
|
-
export * from './dummyOauth';
|
|
4
|
-
export * from './authorize';
|
|
1
|
+
export * from './rest';
|
|
2
|
+
export * from './oauth';
|
|
3
|
+
export * from './dummyOauth';
|
|
4
|
+
export * from './authorize';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|