@singularlogic/coreplatts 0.0.17 → 0.0.20
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 +18 -4
- package/dist/index.js +58 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -138,6 +138,20 @@ interface Group {
|
|
|
138
138
|
[key: string]: any[];
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
|
+
interface DisplayGroup {
|
|
142
|
+
id: string;
|
|
143
|
+
name: string;
|
|
144
|
+
description?: string;
|
|
145
|
+
tags?: string[];
|
|
146
|
+
numberOfDatasets?: number;
|
|
147
|
+
numberOfResources?: number;
|
|
148
|
+
totalSize?: number;
|
|
149
|
+
numUsers?: number;
|
|
150
|
+
users?: string[];
|
|
151
|
+
}
|
|
152
|
+
type UsersPart = Pick<DisplayGroup, "id" | "name" | "numUsers" | "users">;
|
|
153
|
+
type StatsPart = Omit<DisplayGroup, "numUsers" | "users">;
|
|
154
|
+
declare function mergeGroupsByIdName(stats: StatsPart[], users: UsersPart[]): DisplayGroup[];
|
|
141
155
|
declare enum Role {
|
|
142
156
|
ADMIN,
|
|
143
157
|
MEMBER
|
|
@@ -163,7 +177,7 @@ type TokenProvider = () => string | Promise<string>;
|
|
|
163
177
|
interface IClient$1 {
|
|
164
178
|
login(email: string, password: string): Promise<OidcToken>;
|
|
165
179
|
myUser(token?: string): Promise<User>;
|
|
166
|
-
allOrganizations(token?: string): Promise<
|
|
180
|
+
allOrganizations(token?: string): Promise<DisplayGroup[]>;
|
|
167
181
|
myOrganizations(token?: string): Promise<Group[]>;
|
|
168
182
|
organizationByID(id: string, token?: string): Promise<Group>;
|
|
169
183
|
organizationByName(name: string, token?: string): Promise<Group>;
|
|
@@ -215,9 +229,9 @@ declare class Client implements IClient$1 {
|
|
|
215
229
|
*
|
|
216
230
|
* But the best pattern is: do not pass token in SPA and let interceptor handle it.
|
|
217
231
|
*/
|
|
218
|
-
totalInfo(
|
|
232
|
+
totalInfo(): Promise<TotalInfo>;
|
|
219
233
|
myUser(token?: string): Promise<User>;
|
|
220
|
-
allOrganizations(token?: string): Promise<
|
|
234
|
+
allOrganizations(token?: string): Promise<DisplayGroup[]>;
|
|
221
235
|
myOrganizations(token?: string): Promise<Group[]>;
|
|
222
236
|
organizationByID(id: string, token?: string): Promise<Group>;
|
|
223
237
|
organizationByName(name: string, token?: string): Promise<Group>;
|
|
@@ -237,4 +251,4 @@ declare class Client implements IClient$1 {
|
|
|
237
251
|
|
|
238
252
|
type IClient = IClient$1;
|
|
239
253
|
|
|
240
|
-
export { type Bucket, Client, type ErrorReport, type FileModel, type FolderList, type FolderModel, type Group, type IClient, type Meta, type MultipartWrapper, type OidcToken, type PartInfo, Role, type TotalInfo, type Updated, type User, type UserRoles };
|
|
254
|
+
export { type Bucket, Client, type DisplayGroup, type ErrorReport, type FileModel, type FolderList, type FolderModel, type Group, type IClient, type Meta, type MultipartWrapper, type OidcToken, type PartInfo, Role, type StatsPart, type TotalInfo, type Updated, type User, type UserRoles, type UsersPart, mergeGroupsByIdName };
|
package/dist/index.js
CHANGED
|
@@ -68,11 +68,32 @@ var __async = (__this, __arguments, generator) => {
|
|
|
68
68
|
var index_exports = {};
|
|
69
69
|
__export(index_exports, {
|
|
70
70
|
Client: () => Client,
|
|
71
|
-
Role: () => Role
|
|
71
|
+
Role: () => Role,
|
|
72
|
+
mergeGroupsByIdName: () => mergeGroupsByIdName
|
|
72
73
|
});
|
|
73
74
|
module.exports = __toCommonJS(index_exports);
|
|
74
75
|
|
|
75
76
|
// src/models/group.account.models.ts
|
|
77
|
+
function mergeGroupsByIdName(stats, users) {
|
|
78
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
79
|
+
const key = (g) => {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
return `${(_a = g.id) != null ? _a : ""}||${(_b = g.name) != null ? _b : ""}`;
|
|
82
|
+
};
|
|
83
|
+
for (const g of stats) {
|
|
84
|
+
byKey.set(key(g), __spreadValues({}, g));
|
|
85
|
+
}
|
|
86
|
+
for (const u of users) {
|
|
87
|
+
const k = key(u);
|
|
88
|
+
const existing = byKey.get(k);
|
|
89
|
+
if (existing) {
|
|
90
|
+
byKey.set(k, __spreadProps(__spreadValues({}, existing), { users: u.users, numUsers: u.numUsers }));
|
|
91
|
+
} else {
|
|
92
|
+
byKey.set(k, __spreadValues({}, u));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return Array.from(byKey.values());
|
|
96
|
+
}
|
|
76
97
|
var Role = /* @__PURE__ */ ((Role2) => {
|
|
77
98
|
Role2["ADMIN"] = "admin";
|
|
78
99
|
Role2["MEMBER"] = "member";
|
|
@@ -222,6 +243,14 @@ var GroupConsumer = class extends BaseConsumer {
|
|
|
222
243
|
getAllGroups(token) {
|
|
223
244
|
return this.getMany("all", null, token);
|
|
224
245
|
}
|
|
246
|
+
getGroupUsers(gname, gid, token) {
|
|
247
|
+
let addPath = "";
|
|
248
|
+
addPath = addPath + (gname ? `?name=${gname}` : "") + (gid ? `?id=${gid}` : "");
|
|
249
|
+
return this._httpClient.get(this.path + "/describe" + addPath, { headers: { "Authorization": "Bearer " + token } }).then((resp) => resp.data).catch((error) => {
|
|
250
|
+
console.error(`\u274C Error in posting:`, error);
|
|
251
|
+
return null;
|
|
252
|
+
});
|
|
253
|
+
}
|
|
225
254
|
getUserGroups(token) {
|
|
226
255
|
return this.getMany("", null, token);
|
|
227
256
|
}
|
|
@@ -277,6 +306,13 @@ var BucketConsumer = class extends BaseConsumer {
|
|
|
277
306
|
deleteBucket(id, token) {
|
|
278
307
|
return this.delete("/" + id, token);
|
|
279
308
|
}
|
|
309
|
+
getBucketInfo(gid, token) {
|
|
310
|
+
let addPath = gid ? `?id=${gid}` : "";
|
|
311
|
+
return this._httpClient.get(this.path + addPath, { headers: { "Authorization": "Bearer " + token } }).then((resp) => resp.data).catch((error) => {
|
|
312
|
+
console.error(`\u274C Error in posting:`, error);
|
|
313
|
+
return null;
|
|
314
|
+
});
|
|
315
|
+
}
|
|
280
316
|
};
|
|
281
317
|
|
|
282
318
|
// src/utils/utils.ts
|
|
@@ -792,6 +828,17 @@ var FolderConsumer = class extends BaseConsumer {
|
|
|
792
828
|
}
|
|
793
829
|
};
|
|
794
830
|
|
|
831
|
+
// src/apis/management/public.consumer.ts
|
|
832
|
+
var _namespace7 = "public";
|
|
833
|
+
var PublicConsumer = class extends BaseConsumer {
|
|
834
|
+
constructor(_httpClient) {
|
|
835
|
+
super(_httpClient, _namespace7);
|
|
836
|
+
}
|
|
837
|
+
totalInfo() {
|
|
838
|
+
return this.getOne("/total", void 0, void 0);
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
|
|
795
842
|
// src/client.ts
|
|
796
843
|
var Client = class {
|
|
797
844
|
constructor(managementURL, accountURL) {
|
|
@@ -805,6 +852,7 @@ var Client = class {
|
|
|
805
852
|
this._groupConsumer = new GroupConsumer(axiosAccount);
|
|
806
853
|
this._bucketConsumer = new BucketConsumer(axiosManagement);
|
|
807
854
|
this._folderConsumer = new FolderConsumer(axiosManagement);
|
|
855
|
+
this._publicConsumer = new PublicConsumer(axiosManagement);
|
|
808
856
|
}
|
|
809
857
|
/**
|
|
810
858
|
* Set a token provider (Keycloak-friendly).
|
|
@@ -875,7 +923,7 @@ var Client = class {
|
|
|
875
923
|
// -----------------------------
|
|
876
924
|
// Public APIs
|
|
877
925
|
// -----------------------------
|
|
878
|
-
totalInfo(
|
|
926
|
+
totalInfo() {
|
|
879
927
|
return this._publicConsumer.totalInfo();
|
|
880
928
|
}
|
|
881
929
|
// -----------------------------
|
|
@@ -885,7 +933,12 @@ var Client = class {
|
|
|
885
933
|
return this._userConsumer.getUser(token);
|
|
886
934
|
}
|
|
887
935
|
allOrganizations(token) {
|
|
888
|
-
return
|
|
936
|
+
return Promise.all([
|
|
937
|
+
this._bucketConsumer.getBucketInfo(void 0, token),
|
|
938
|
+
this._groupConsumer.getGroupUsers(void 0, void 0, token)
|
|
939
|
+
]).then(
|
|
940
|
+
([stats, users]) => mergeGroupsByIdName(stats != null ? stats : [], users != null ? users : [])
|
|
941
|
+
);
|
|
889
942
|
}
|
|
890
943
|
myOrganizations(token) {
|
|
891
944
|
return this._groupConsumer.getUserGroups(token);
|
|
@@ -954,5 +1007,6 @@ var Client = class {
|
|
|
954
1007
|
// Annotate the CommonJS export names for ESM import in node:
|
|
955
1008
|
0 && (module.exports = {
|
|
956
1009
|
Client,
|
|
957
|
-
Role
|
|
1010
|
+
Role,
|
|
1011
|
+
mergeGroupsByIdName
|
|
958
1012
|
});
|