@singularlogic/coreplatts 0.0.22 → 0.0.23
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 +1 -1
- package/dist/index.js +200 -196
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -251,4 +251,4 @@ declare class Client implements IClient$1 {
|
|
|
251
251
|
|
|
252
252
|
type IClient = IClient$1;
|
|
253
253
|
|
|
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 };
|
|
254
|
+
export { type Bucket, Client, type DisplayGroup, type ErrorReport, File$1 as File, type FileModel, Folder, 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,6 +68,8 @@ var __async = (__this, __arguments, generator) => {
|
|
|
68
68
|
var index_exports = {};
|
|
69
69
|
__export(index_exports, {
|
|
70
70
|
Client: () => Client,
|
|
71
|
+
File: () => File,
|
|
72
|
+
Folder: () => Folder,
|
|
71
73
|
Role: () => Role,
|
|
72
74
|
mergeGroupsByIdName: () => mergeGroupsByIdName
|
|
73
75
|
});
|
|
@@ -100,9 +102,6 @@ var Role = /* @__PURE__ */ ((Role2) => {
|
|
|
100
102
|
return Role2;
|
|
101
103
|
})(Role || {});
|
|
102
104
|
|
|
103
|
-
// src/client.ts
|
|
104
|
-
var import_axios = __toESM(require("axios"));
|
|
105
|
-
|
|
106
105
|
// src/apis/base.consumer.ts
|
|
107
106
|
var BaseConsumer = class {
|
|
108
107
|
constructor(_httpClient, _requestPath) {
|
|
@@ -188,128 +187,91 @@ var BaseConsumer = class {
|
|
|
188
187
|
}
|
|
189
188
|
};
|
|
190
189
|
|
|
191
|
-
// src/apis/
|
|
192
|
-
var _namespace = "
|
|
193
|
-
var
|
|
194
|
-
// private _accountBase:string;
|
|
190
|
+
// src/apis/management/file.consumer.ts
|
|
191
|
+
var _namespace = "file";
|
|
192
|
+
var FileConsumer = class extends BaseConsumer {
|
|
195
193
|
constructor(_httpClient) {
|
|
196
194
|
super(_httpClient, _namespace);
|
|
197
|
-
this._client = _httpClient;
|
|
198
195
|
}
|
|
199
|
-
|
|
200
|
-
|
|
196
|
+
getFileByID(id, token) {
|
|
197
|
+
return this.getOne(`/info/${id}`, null, token).then(
|
|
198
|
+
(resp) => {
|
|
199
|
+
return new File(resp, this._httpClient);
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
initUpload(file, fileSize, chunckSize, token) {
|
|
204
|
+
const config = {
|
|
201
205
|
headers: {
|
|
202
|
-
"Content-Type": "application/
|
|
206
|
+
"Content-Type": "application/json",
|
|
207
|
+
"Authorization": `Bearer ${token}`,
|
|
208
|
+
"Chunk-Size": String(chunckSize),
|
|
209
|
+
"File-Size": String(fileSize)
|
|
203
210
|
}
|
|
204
211
|
};
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
};
|
|
209
|
-
return this._client.post(this.path, data, config).then((resp) => {
|
|
210
|
-
return resp.data;
|
|
212
|
+
return this._httpClient.post(this.path + "/upload/initialize", file, config).then((resp) => resp.data).catch((error) => {
|
|
213
|
+
console.error(`\u274C Error in posting:`, error);
|
|
214
|
+
return null;
|
|
211
215
|
});
|
|
212
216
|
}
|
|
213
|
-
|
|
214
|
-
return this.
|
|
217
|
+
closeUplaod(wrapper, token) {
|
|
218
|
+
return this.post("/upload/complete", wrapper, void 0, token);
|
|
215
219
|
}
|
|
216
|
-
|
|
217
|
-
|
|
220
|
+
initDownload(fileId, token) {
|
|
221
|
+
const config = {
|
|
218
222
|
headers: {
|
|
219
|
-
"
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
"password": password,
|
|
225
|
-
"last_name": lastName,
|
|
226
|
-
"first_name": firstName
|
|
223
|
+
"Authorization": `Bearer ${token}`,
|
|
224
|
+
"Content-Type": "application/json"
|
|
225
|
+
},
|
|
226
|
+
timeout: 0
|
|
227
|
+
// disables timeout
|
|
227
228
|
};
|
|
228
|
-
return this.
|
|
229
|
+
return this._httpClient.get(this.path + `/download/initialize/${fileId}`, config).then((resp) => {
|
|
230
|
+
if (resp.data && resp.data.internal_status) {
|
|
231
|
+
console.error(`\u274C Error in response:`, resp.data.internal_status);
|
|
232
|
+
throw new Error("Download initialization failed: " + resp.data.internal_status);
|
|
233
|
+
}
|
|
229
234
|
return resp.data;
|
|
230
|
-
}).catch((
|
|
231
|
-
console.
|
|
235
|
+
}).catch((error) => {
|
|
236
|
+
console.error(`\u274C Error in request:`, error);
|
|
237
|
+
throw new Error("Download initialization failed: " + error.message);
|
|
232
238
|
});
|
|
233
239
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
var _namespace2 = "group/";
|
|
238
|
-
var GroupConsumer = class extends BaseConsumer {
|
|
239
|
-
constructor(_httpClient) {
|
|
240
|
-
super(_httpClient, _namespace2);
|
|
241
|
-
this._client = _httpClient;
|
|
242
|
-
}
|
|
243
|
-
getAllGroups(token) {
|
|
244
|
-
return this.getMany("all", null, token);
|
|
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;
|
|
240
|
+
download(concurrent_limit = 5) {
|
|
241
|
+
return __async(this, null, function* () {
|
|
242
|
+
return new Blob();
|
|
252
243
|
});
|
|
253
244
|
}
|
|
254
|
-
|
|
255
|
-
return this
|
|
256
|
-
|
|
257
|
-
getGroupByID(id, token) {
|
|
258
|
-
return this.getOne("id/" + id, null, token);
|
|
259
|
-
}
|
|
260
|
-
getGroupByName(name, token) {
|
|
261
|
-
return this.getOne("name/" + name, null, token);
|
|
262
|
-
}
|
|
263
|
-
postGroup(name, token) {
|
|
264
|
-
const postGroup = {
|
|
265
|
-
name,
|
|
266
|
-
path: "/",
|
|
267
|
-
subGroups: [],
|
|
268
|
-
attributes: {},
|
|
269
|
-
id: void 0
|
|
270
|
-
};
|
|
271
|
-
return this.post("", postGroup, void 0, token);
|
|
272
|
-
}
|
|
273
|
-
addUsers(group_name, input, token) {
|
|
274
|
-
let payload = {
|
|
275
|
-
users: Object.entries(input).map(([email, role]) => ({
|
|
276
|
-
[email]: { admin: role === "admin" /* ADMIN */ }
|
|
277
|
-
}))
|
|
278
|
-
};
|
|
279
|
-
let config = {
|
|
280
|
-
headers: {
|
|
281
|
-
"Content-Type": "application/json",
|
|
282
|
-
"Authorization": "Bearer " + token
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
this._client.post(this.path + "name/" + group_name, payload, config);
|
|
245
|
+
store(_0) {
|
|
246
|
+
return __async(this, arguments, function* (path, concurrent_limit = 5, chunk_size = 5 * 1024 * 1024) {
|
|
247
|
+
});
|
|
286
248
|
}
|
|
287
|
-
|
|
288
|
-
return this
|
|
249
|
+
rename(new_name) {
|
|
250
|
+
return __async(this, null, function* () {
|
|
251
|
+
});
|
|
289
252
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
var _namespace3 = "bucket";
|
|
294
|
-
var BucketConsumer = class extends BaseConsumer {
|
|
295
|
-
constructor(_httpClient) {
|
|
296
|
-
super(_httpClient, _namespace3);
|
|
253
|
+
changeType(new_type) {
|
|
254
|
+
return __async(this, null, function* () {
|
|
255
|
+
});
|
|
297
256
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
_id: id,
|
|
302
|
-
creation_date: void 0
|
|
303
|
-
};
|
|
304
|
-
return this.post("", postBucket, void 0, token);
|
|
257
|
+
updateDescription(new_description) {
|
|
258
|
+
return __async(this, null, function* () {
|
|
259
|
+
});
|
|
305
260
|
}
|
|
306
|
-
|
|
307
|
-
|
|
261
|
+
// async copyTo(destination_name?: string, destination_id?: string, new_name?: string): Promise<IFile | null> {
|
|
262
|
+
// // implement later
|
|
263
|
+
// return null;
|
|
264
|
+
// }
|
|
265
|
+
moveTo(destination_name, destination_id, new_name) {
|
|
266
|
+
return __async(this, null, function* () {
|
|
267
|
+
});
|
|
308
268
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
269
|
+
// async delete(): Promise<boolean> {
|
|
270
|
+
// // implement later
|
|
271
|
+
// return false;
|
|
272
|
+
// }
|
|
273
|
+
checkRequestStatus() {
|
|
274
|
+
return __async(this, null, function* () {
|
|
313
275
|
return null;
|
|
314
276
|
});
|
|
315
277
|
}
|
|
@@ -563,98 +525,8 @@ var File = class {
|
|
|
563
525
|
// }
|
|
564
526
|
};
|
|
565
527
|
|
|
566
|
-
// src/apis/management/file.consumer.ts
|
|
567
|
-
var _namespace4 = "file";
|
|
568
|
-
var FileConsumer = class extends BaseConsumer {
|
|
569
|
-
constructor(_httpClient) {
|
|
570
|
-
super(_httpClient, _namespace4);
|
|
571
|
-
}
|
|
572
|
-
getFileByID(id, token) {
|
|
573
|
-
return this.getOne(`/info/${id}`, null, token).then(
|
|
574
|
-
(resp) => {
|
|
575
|
-
return new File(resp, this._httpClient);
|
|
576
|
-
}
|
|
577
|
-
);
|
|
578
|
-
}
|
|
579
|
-
initUpload(file, fileSize, chunckSize, token) {
|
|
580
|
-
const config = {
|
|
581
|
-
headers: {
|
|
582
|
-
"Content-Type": "application/json",
|
|
583
|
-
"Authorization": `Bearer ${token}`,
|
|
584
|
-
"Chunk-Size": String(chunckSize),
|
|
585
|
-
"File-Size": String(fileSize)
|
|
586
|
-
}
|
|
587
|
-
};
|
|
588
|
-
return this._httpClient.post(this.path + "/upload/initialize", file, config).then((resp) => resp.data).catch((error) => {
|
|
589
|
-
console.error(`\u274C Error in posting:`, error);
|
|
590
|
-
return null;
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
closeUplaod(wrapper, token) {
|
|
594
|
-
return this.post("/upload/complete", wrapper, void 0, token);
|
|
595
|
-
}
|
|
596
|
-
initDownload(fileId, token) {
|
|
597
|
-
const config = {
|
|
598
|
-
headers: {
|
|
599
|
-
"Authorization": `Bearer ${token}`,
|
|
600
|
-
"Content-Type": "application/json"
|
|
601
|
-
},
|
|
602
|
-
timeout: 0
|
|
603
|
-
// disables timeout
|
|
604
|
-
};
|
|
605
|
-
return this._httpClient.get(this.path + `/download/initialize/${fileId}`, config).then((resp) => {
|
|
606
|
-
if (resp.data && resp.data.internal_status) {
|
|
607
|
-
console.error(`\u274C Error in response:`, resp.data.internal_status);
|
|
608
|
-
throw new Error("Download initialization failed: " + resp.data.internal_status);
|
|
609
|
-
}
|
|
610
|
-
return resp.data;
|
|
611
|
-
}).catch((error) => {
|
|
612
|
-
console.error(`\u274C Error in request:`, error);
|
|
613
|
-
throw new Error("Download initialization failed: " + error.message);
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
download(concurrent_limit = 5) {
|
|
617
|
-
return __async(this, null, function* () {
|
|
618
|
-
return new Blob();
|
|
619
|
-
});
|
|
620
|
-
}
|
|
621
|
-
store(_0) {
|
|
622
|
-
return __async(this, arguments, function* (path, concurrent_limit = 5, chunk_size = 5 * 1024 * 1024) {
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
rename(new_name) {
|
|
626
|
-
return __async(this, null, function* () {
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
changeType(new_type) {
|
|
630
|
-
return __async(this, null, function* () {
|
|
631
|
-
});
|
|
632
|
-
}
|
|
633
|
-
updateDescription(new_description) {
|
|
634
|
-
return __async(this, null, function* () {
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
// async copyTo(destination_name?: string, destination_id?: string, new_name?: string): Promise<IFile | null> {
|
|
638
|
-
// // implement later
|
|
639
|
-
// return null;
|
|
640
|
-
// }
|
|
641
|
-
moveTo(destination_name, destination_id, new_name) {
|
|
642
|
-
return __async(this, null, function* () {
|
|
643
|
-
});
|
|
644
|
-
}
|
|
645
|
-
// async delete(): Promise<boolean> {
|
|
646
|
-
// // implement later
|
|
647
|
-
// return false;
|
|
648
|
-
// }
|
|
649
|
-
checkRequestStatus() {
|
|
650
|
-
return __async(this, null, function* () {
|
|
651
|
-
return null;
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
};
|
|
655
|
-
|
|
656
528
|
// src/apis/management/folder.factory.ts
|
|
657
|
-
var
|
|
529
|
+
var _namespace2 = "folder";
|
|
658
530
|
var Folder = class {
|
|
659
531
|
constructor(struct, _httpClient) {
|
|
660
532
|
this._httpClient = _httpClient;
|
|
@@ -693,7 +565,7 @@ var Folder = class {
|
|
|
693
565
|
"Authorization": "Bearer " + token
|
|
694
566
|
}
|
|
695
567
|
};
|
|
696
|
-
return this._httpClient.get(this._managementURL + "/" +
|
|
568
|
+
return this._httpClient.get(this._managementURL + "/" + _namespace2 + "/list", config).then((resp) => {
|
|
697
569
|
return resp.data;
|
|
698
570
|
}).catch((error) => {
|
|
699
571
|
console.error(`\u274C Can't retrieve requsted entity:`, error);
|
|
@@ -804,6 +676,136 @@ var Folder = class {
|
|
|
804
676
|
// }
|
|
805
677
|
};
|
|
806
678
|
|
|
679
|
+
// src/client.ts
|
|
680
|
+
var import_axios = __toESM(require("axios"));
|
|
681
|
+
|
|
682
|
+
// src/apis/account/user.consumer.ts
|
|
683
|
+
var _namespace3 = "user/";
|
|
684
|
+
var UserConsumer = class extends BaseConsumer {
|
|
685
|
+
// private _accountBase:string;
|
|
686
|
+
constructor(_httpClient) {
|
|
687
|
+
super(_httpClient, _namespace3);
|
|
688
|
+
this._client = _httpClient;
|
|
689
|
+
}
|
|
690
|
+
login(email, password) {
|
|
691
|
+
let config = {
|
|
692
|
+
headers: {
|
|
693
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
let data = {
|
|
697
|
+
"username": email,
|
|
698
|
+
"password": password
|
|
699
|
+
};
|
|
700
|
+
return this._client.post(this.path, data, config).then((resp) => {
|
|
701
|
+
return resp.data;
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
getUser(token) {
|
|
705
|
+
return this.getOne("", null, token);
|
|
706
|
+
}
|
|
707
|
+
register(email, password, firstName, lastName) {
|
|
708
|
+
let config = {
|
|
709
|
+
headers: {
|
|
710
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
let data = {
|
|
714
|
+
"email": email,
|
|
715
|
+
"password": password,
|
|
716
|
+
"last_name": lastName,
|
|
717
|
+
"first_name": firstName
|
|
718
|
+
};
|
|
719
|
+
return this._client.post(this.path + "/register/", data, config).then((resp) => {
|
|
720
|
+
return resp.data;
|
|
721
|
+
}).catch((err) => {
|
|
722
|
+
console.log(err);
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
|
|
727
|
+
// src/apis/account/group.consumer.ts
|
|
728
|
+
var _namespace4 = "group/";
|
|
729
|
+
var GroupConsumer = class extends BaseConsumer {
|
|
730
|
+
constructor(_httpClient) {
|
|
731
|
+
super(_httpClient, _namespace4);
|
|
732
|
+
this._client = _httpClient;
|
|
733
|
+
}
|
|
734
|
+
getAllGroups(token) {
|
|
735
|
+
return this.getMany("all", null, token);
|
|
736
|
+
}
|
|
737
|
+
getGroupUsers(gname, gid, token) {
|
|
738
|
+
let addPath = "";
|
|
739
|
+
addPath = addPath + (gname ? `?name=${gname}` : "") + (gid ? `?id=${gid}` : "");
|
|
740
|
+
return this._httpClient.get(this.path + "describe" + addPath, { headers: { "Authorization": "Bearer " + token } }).then((resp) => resp.data).catch((error) => {
|
|
741
|
+
console.error(`\u274C Error in posting:`, error);
|
|
742
|
+
return null;
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
getUserGroups(token) {
|
|
746
|
+
return this.getMany("", null, token);
|
|
747
|
+
}
|
|
748
|
+
getGroupByID(id, token) {
|
|
749
|
+
return this.getOne("id/" + id, null, token);
|
|
750
|
+
}
|
|
751
|
+
getGroupByName(name, token) {
|
|
752
|
+
return this.getOne("name/" + name, null, token);
|
|
753
|
+
}
|
|
754
|
+
postGroup(name, token) {
|
|
755
|
+
const postGroup = {
|
|
756
|
+
name,
|
|
757
|
+
path: "/",
|
|
758
|
+
subGroups: [],
|
|
759
|
+
attributes: {},
|
|
760
|
+
id: void 0
|
|
761
|
+
};
|
|
762
|
+
return this.post("", postGroup, void 0, token);
|
|
763
|
+
}
|
|
764
|
+
addUsers(group_name, input, token) {
|
|
765
|
+
let payload = {
|
|
766
|
+
users: Object.entries(input).map(([email, role]) => ({
|
|
767
|
+
[email]: { admin: role === "admin" /* ADMIN */ }
|
|
768
|
+
}))
|
|
769
|
+
};
|
|
770
|
+
let config = {
|
|
771
|
+
headers: {
|
|
772
|
+
"Content-Type": "application/json",
|
|
773
|
+
"Authorization": "Bearer " + token
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
this._client.post(this.path + "name/" + group_name, payload, config);
|
|
777
|
+
}
|
|
778
|
+
deleteGroup(id, token) {
|
|
779
|
+
return this.delete("id/" + id, token);
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
|
|
783
|
+
// src/apis/management/bucket.consumer.ts
|
|
784
|
+
var _namespace5 = "bucket";
|
|
785
|
+
var BucketConsumer = class extends BaseConsumer {
|
|
786
|
+
constructor(_httpClient) {
|
|
787
|
+
super(_httpClient, _namespace5);
|
|
788
|
+
}
|
|
789
|
+
postBucket(id, name, token) {
|
|
790
|
+
const postBucket = {
|
|
791
|
+
name,
|
|
792
|
+
_id: id,
|
|
793
|
+
creation_date: void 0
|
|
794
|
+
};
|
|
795
|
+
return this.post("", postBucket, void 0, token);
|
|
796
|
+
}
|
|
797
|
+
deleteBucket(id, token) {
|
|
798
|
+
return this.delete("/" + id, token);
|
|
799
|
+
}
|
|
800
|
+
getBucketInfo(gid, token) {
|
|
801
|
+
let addPath = gid ? `?id=${gid}` : "";
|
|
802
|
+
return this._httpClient.get(this.path + addPath, { headers: { "Authorization": "Bearer " + token } }).then((resp) => resp.data).catch((error) => {
|
|
803
|
+
console.error(`\u274C Error in posting:`, error);
|
|
804
|
+
return null;
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
|
|
807
809
|
// src/apis/management/folder.consumer.ts
|
|
808
810
|
var _namespace6 = "folder";
|
|
809
811
|
var FolderConsumer = class extends BaseConsumer {
|
|
@@ -1007,6 +1009,8 @@ var Client = class {
|
|
|
1007
1009
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1008
1010
|
0 && (module.exports = {
|
|
1009
1011
|
Client,
|
|
1012
|
+
File,
|
|
1013
|
+
Folder,
|
|
1010
1014
|
Role,
|
|
1011
1015
|
mergeGroupsByIdName
|
|
1012
1016
|
});
|