@magda/auth-api-client 1.1.0-alpha.2 → 1.1.0-alpha.3
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/index.d.ts +280 -0
- package/dist/index.js +29859 -0
- package/package.json +2 -2
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
|
|
2
|
+
declare class ApiClient {
|
|
3
|
+
private jwt;
|
|
4
|
+
private requestInitOption;
|
|
5
|
+
private baseUrl;
|
|
6
|
+
constructor(baseUrl: string, jwtSecret?: string, userId?: string);
|
|
7
|
+
getMergeRequestInitOption(extraOptions?: RequestInit): RequestInit;
|
|
8
|
+
processJsonResponse<T = any>(res: Response): Promise<T>;
|
|
9
|
+
/**
|
|
10
|
+
* Get the data of a user.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} userId
|
|
13
|
+
* @returns {Promise<Maybe<User>>}
|
|
14
|
+
* @memberof ApiClient
|
|
15
|
+
*/
|
|
16
|
+
getUser(userId: string): Promise<Maybe<RequiredKeys<User, "id">>>;
|
|
17
|
+
/**
|
|
18
|
+
* Get the data of a user.
|
|
19
|
+
* (Deprecated) This is the public facing API and will return less fields.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} userId
|
|
22
|
+
* @returns {Promise<Maybe<User>>}
|
|
23
|
+
* @memberof ApiClient
|
|
24
|
+
*/
|
|
25
|
+
getUserPublic(userId: string): Promise<Maybe<RequiredKeys<User, "id">>>;
|
|
26
|
+
/**
|
|
27
|
+
* Lookup user by source (identity provider) & sourceId (identity ID)
|
|
28
|
+
*
|
|
29
|
+
* @param {string} source
|
|
30
|
+
* @param {string} sourceId
|
|
31
|
+
* @returns {Promise<Maybe<User>>}
|
|
32
|
+
* @memberof ApiClient
|
|
33
|
+
*/
|
|
34
|
+
lookupUser(source: string, sourceId: string): Promise<Maybe<RequiredKeys<User, "id">>>;
|
|
35
|
+
/**
|
|
36
|
+
* create a user
|
|
37
|
+
*
|
|
38
|
+
* @param {User} user
|
|
39
|
+
* @returns {Promise<User>}
|
|
40
|
+
* @memberof ApiClient
|
|
41
|
+
*/
|
|
42
|
+
createUser(user: User): Promise<RequiredKeys<User, "id">>;
|
|
43
|
+
/**
|
|
44
|
+
* Add Roles to a user.
|
|
45
|
+
* Returns a list of current role ids of the user.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} userId
|
|
48
|
+
* @param {string[]} roleIds
|
|
49
|
+
* @returns {Promise<string[]>}
|
|
50
|
+
* @memberof ApiClient
|
|
51
|
+
*/
|
|
52
|
+
addUserRoles(userId: string, roleIds: string[]): Promise<string[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Remove a list roles from a user.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} userId
|
|
57
|
+
* @param {string[]} roleIds
|
|
58
|
+
* @returns {Promise<void>}
|
|
59
|
+
* @memberof ApiClient
|
|
60
|
+
*/
|
|
61
|
+
deleteUserRoles(userId: string, roleIds: string[]): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Get all roles of a user
|
|
64
|
+
*
|
|
65
|
+
* @param {string} userId
|
|
66
|
+
* @returns {Promise<Role[]>}
|
|
67
|
+
* @memberof ApiClient
|
|
68
|
+
*/
|
|
69
|
+
getUserRoles(userId: string): Promise<Role[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Get all permissions of a user
|
|
72
|
+
*
|
|
73
|
+
* @param {string} userId
|
|
74
|
+
* @returns {Promise<Permission[]>}
|
|
75
|
+
* @memberof ApiClient
|
|
76
|
+
*/
|
|
77
|
+
getUserPermissions(userId: string): Promise<Permission[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Get all permissions of a role
|
|
80
|
+
*
|
|
81
|
+
* @param {string} roleId
|
|
82
|
+
* @returns {Promise<Permission[]>}
|
|
83
|
+
* @memberof ApiClient
|
|
84
|
+
*/
|
|
85
|
+
getRolePermissions(roleId: string): Promise<Permission[]>;
|
|
86
|
+
/**
|
|
87
|
+
* List OrgUnits at certain org tree level.
|
|
88
|
+
* Optionally provide a test Org Unit Id that will be used to test the relationship with each of returned orgUnit item.
|
|
89
|
+
* Possible Value: 'ancestor', 'descendant', 'equal', 'unrelated'
|
|
90
|
+
*
|
|
91
|
+
* @param {string} orgLevel The level number (starts from 1) where org Units of the tree are taken horizontally.
|
|
92
|
+
* @param {string} [relationshipOrgUnitId] Optional; The org unit id that is used to test the relationship with each of returned orgUnit item.
|
|
93
|
+
* @returns {Promise<OrgUnit[]>}
|
|
94
|
+
* @memberof ApiClient
|
|
95
|
+
*/
|
|
96
|
+
getOrgUnitsByLevel(orgLevel: number, relationshipOrgUnitId?: string): Promise<OrgUnit[]>;
|
|
97
|
+
/**
|
|
98
|
+
* Get orgunits by name
|
|
99
|
+
*
|
|
100
|
+
* @param {string} nodeName
|
|
101
|
+
* @param {boolean} [leafNodesOnly=false] Whether only leaf nodes should be returned
|
|
102
|
+
* @param {string} [relationshipOrgUnitId] Optional; The org unit id that is used to test the relationship with each of returned orgUnit item.
|
|
103
|
+
* @returns {Promise<OrgUnit[]>}
|
|
104
|
+
* @memberof ApiClient
|
|
105
|
+
*/
|
|
106
|
+
getOrgUnitsByName(nodeName: string, leafNodesOnly?: boolean, relationshipOrgUnitId?: string): Promise<OrgUnit[]>;
|
|
107
|
+
/**
|
|
108
|
+
* Gets the root organisation unit (top of the tree).
|
|
109
|
+
*
|
|
110
|
+
* @returns {Promise<OrgUnit>}
|
|
111
|
+
* @memberof ApiClient
|
|
112
|
+
*/
|
|
113
|
+
getRootOrgUnit(): Promise<OrgUnit>;
|
|
114
|
+
/**
|
|
115
|
+
* Gets the details of the node with its id.
|
|
116
|
+
*
|
|
117
|
+
* @param {string} nodeId
|
|
118
|
+
* @returns {Promise<OrgUnit>}
|
|
119
|
+
* @memberof ApiClient
|
|
120
|
+
*/
|
|
121
|
+
getOrgUnitById(nodeId: string): Promise<OrgUnit>;
|
|
122
|
+
/**
|
|
123
|
+
* Gets all the children immediately below the requested node. If the node doesn't exist, returns an empty list.
|
|
124
|
+
*
|
|
125
|
+
* @param {string} nodeId
|
|
126
|
+
* @returns {Promise<OrgUnit[]>}
|
|
127
|
+
* @memberof ApiClient
|
|
128
|
+
*/
|
|
129
|
+
getImmediateOrgUnitChildren(nodeId: string): Promise<OrgUnit[]>;
|
|
130
|
+
/**
|
|
131
|
+
* Gets all the children below the requested node recursively. If node doesn't exist, returns an empty list.
|
|
132
|
+
*
|
|
133
|
+
* @param {string} nodeId
|
|
134
|
+
* @returns {Promise<OrgUnit[]>}
|
|
135
|
+
* @memberof ApiClient
|
|
136
|
+
*/
|
|
137
|
+
getAllOrgUnitChildren(nodeId: string): Promise<OrgUnit[]>;
|
|
138
|
+
private handleGetResult;
|
|
139
|
+
}
|
|
140
|
+
export default ApiClient;
|
|
141
|
+
|
|
142
|
+
declare interface Eq<T> {
|
|
143
|
+
equals(t: T): boolean;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
declare interface Functor<T> {
|
|
147
|
+
fmap<U>(f: (t: T) => U): Functor<U>;
|
|
148
|
+
lift<U>(f: (t: T) => U): Functor<U>;
|
|
149
|
+
map<U>(f: (t: T) => U): Functor<U>;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export declare class Maybe<T> implements Monad<T>, Functor<T>, Eq<Maybe<T>> {
|
|
153
|
+
private type;
|
|
154
|
+
private value;
|
|
155
|
+
constructor(type: MaybeType, value?: T);
|
|
156
|
+
static sequence<T>(t: {
|
|
157
|
+
[k: string]: Maybe<T>;
|
|
158
|
+
}): Maybe<{
|
|
159
|
+
[k: string]: T;
|
|
160
|
+
}>;
|
|
161
|
+
static all: (t: {
|
|
162
|
+
[k: string]: Maybe<any>;
|
|
163
|
+
}) => Maybe<{
|
|
164
|
+
[k: string]: any;
|
|
165
|
+
}>;
|
|
166
|
+
static maybe<T>(t: T): Maybe<T>;
|
|
167
|
+
static just<T>(t: T): Maybe<T>;
|
|
168
|
+
static nothing<T>(): Maybe<T>;
|
|
169
|
+
unit<U>(u: U): Maybe<U>;
|
|
170
|
+
bind<U>(f: (t: T) => Maybe<U>): Maybe<U>;
|
|
171
|
+
of: <U>(u: U) => Maybe<U>;
|
|
172
|
+
chain: <U>(f: (t: T) => Maybe<U>) => Maybe<U>;
|
|
173
|
+
fmap<U>(f: (t: T) => U): Maybe<U>;
|
|
174
|
+
lift: <U>(f: (t: T) => U) => Maybe<U>;
|
|
175
|
+
map: <U>(f: (t: T) => U) => Maybe<U>;
|
|
176
|
+
caseOf<U>(patterns: MaybePatterns<T, U>): U;
|
|
177
|
+
defaulting(defaultValue: T): Maybe<T>;
|
|
178
|
+
equals(other: Maybe<T>): any;
|
|
179
|
+
valueOr<U extends T>(defaultValue: U): T | U;
|
|
180
|
+
valueOrCompute<U extends T>(defaultValueFunction: () => U): T | U;
|
|
181
|
+
valueOrThrow(error?: Error): T;
|
|
182
|
+
do(patterns?: OptionalMaybePatterns<T, void>): Maybe<T>;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
declare interface MaybePatterns<T, U> {
|
|
186
|
+
just: (t: T) => U;
|
|
187
|
+
nothing: () => U;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
declare enum MaybeType {
|
|
191
|
+
Nothing = 0,
|
|
192
|
+
Just = 1,
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
declare interface Monad<T> {
|
|
196
|
+
unit<U>(t: U): Monad<U>;
|
|
197
|
+
bind<U>(f: (t: T) => Monad<U>): Monad<U>;
|
|
198
|
+
of<U>(t: U): Monad<U>;
|
|
199
|
+
chain<U>(f: (t: T) => Monad<U>): Monad<U>;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export declare interface Operation {
|
|
203
|
+
id: string;
|
|
204
|
+
uri: string;
|
|
205
|
+
name: string;
|
|
206
|
+
description?: string;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
declare interface OptionalMaybePatterns<T, U> {
|
|
210
|
+
just?: (t: T) => U;
|
|
211
|
+
nothing?: () => U;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export declare interface OrgUnit {
|
|
215
|
+
id?: string;
|
|
216
|
+
name?: string;
|
|
217
|
+
description?: string;
|
|
218
|
+
relationship?: OrgUnitRelationshipType;
|
|
219
|
+
left?: number;
|
|
220
|
+
right?: number;
|
|
221
|
+
createBy?: string;
|
|
222
|
+
createTime?: Date;
|
|
223
|
+
editBy?: string;
|
|
224
|
+
editTime?: Date;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export declare type OrgUnitRelationshipType = "ancestor" | "descendant" | "equal" | "unrelated";
|
|
228
|
+
|
|
229
|
+
export declare interface Permission {
|
|
230
|
+
id: string;
|
|
231
|
+
name: string;
|
|
232
|
+
description?: string;
|
|
233
|
+
resourceId: string;
|
|
234
|
+
resourceUri: string;
|
|
235
|
+
userOwnershipConstraint: boolean;
|
|
236
|
+
orgUnitOwnershipConstraint: boolean;
|
|
237
|
+
preAuthorisedConstraint: boolean;
|
|
238
|
+
operations: Operation[];
|
|
239
|
+
createBy?: string;
|
|
240
|
+
createTime?: Date;
|
|
241
|
+
editBy?: string;
|
|
242
|
+
editTime?: Date;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export declare interface PublicUser {
|
|
246
|
+
id?: string;
|
|
247
|
+
displayName: string;
|
|
248
|
+
photoURL?: string;
|
|
249
|
+
isAdmin: boolean;
|
|
250
|
+
roles?: Role[];
|
|
251
|
+
permissions?: Permission[];
|
|
252
|
+
managingOrgUnitIds?: string[];
|
|
253
|
+
orgUnitId?: string;
|
|
254
|
+
orgUnit?: OrgUnit;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
declare type RequiredKeys<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
258
|
+
|
|
259
|
+
export declare interface Role {
|
|
260
|
+
id: string;
|
|
261
|
+
name: string;
|
|
262
|
+
permissionIds: string[];
|
|
263
|
+
description?: string;
|
|
264
|
+
createBy?: string;
|
|
265
|
+
createTime?: Date;
|
|
266
|
+
editBy?: string;
|
|
267
|
+
editTime?: Date;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export declare interface User extends PublicUser {
|
|
271
|
+
email: string;
|
|
272
|
+
source: string;
|
|
273
|
+
sourceId: string;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export declare interface UserToken {
|
|
277
|
+
id: string;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export { }
|