@edraj/tsdmart 1.0.13 → 1.0.15
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/index.ts +100 -60
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -327,26 +327,38 @@ export default class Dmart {
|
|
|
327
327
|
static baseURL = "http://localhost:8282";
|
|
328
328
|
|
|
329
329
|
public static async login(shortname: string, password: string) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
330
|
+
try {
|
|
331
|
+
const {data} = await axios.post<
|
|
332
|
+
ApiResponse & { records: Array<LoginResponseRecord> }
|
|
333
|
+
>(`${this.baseURL}/user/login`, {shortname, password}, {headers});
|
|
334
|
+
return data;
|
|
335
|
+
} catch (error: any) {
|
|
336
|
+
throw new Error(error.response.data)
|
|
337
|
+
}
|
|
334
338
|
}
|
|
335
339
|
|
|
336
340
|
public static async loginBy(credentials: any, password: string) {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
+
try {
|
|
342
|
+
const {data} = await axios.post<
|
|
343
|
+
ApiResponse & { records: Array<LoginResponseRecord> }
|
|
344
|
+
>(`${this.baseURL}/user/login`, {...credentials, password}, {headers});
|
|
345
|
+
return data;
|
|
346
|
+
} catch (error: any) {
|
|
347
|
+
throw new Error(error.response.data)
|
|
348
|
+
}
|
|
341
349
|
}
|
|
342
350
|
|
|
343
351
|
public static async logout() {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
352
|
+
try {
|
|
353
|
+
const {data} = await axios.post<ApiResponse>(
|
|
354
|
+
`${this.baseURL}/user/logout`,
|
|
355
|
+
{},
|
|
356
|
+
{headers}
|
|
357
|
+
);
|
|
358
|
+
return data;
|
|
359
|
+
} catch (error: any) {
|
|
360
|
+
throw new Error(error.response.data)
|
|
361
|
+
}
|
|
350
362
|
}
|
|
351
363
|
|
|
352
364
|
public static async create_user(request: any) {
|
|
@@ -358,7 +370,7 @@ export default class Dmart {
|
|
|
358
370
|
);
|
|
359
371
|
return data;
|
|
360
372
|
} catch (error: any) {
|
|
361
|
-
|
|
373
|
+
throw new Error(error.response.data)
|
|
362
374
|
}
|
|
363
375
|
}
|
|
364
376
|
|
|
@@ -371,7 +383,7 @@ export default class Dmart {
|
|
|
371
383
|
);
|
|
372
384
|
return data;
|
|
373
385
|
} catch (error: any) {
|
|
374
|
-
|
|
386
|
+
throw new Error(error.response.data)
|
|
375
387
|
}
|
|
376
388
|
}
|
|
377
389
|
|
|
@@ -383,7 +395,7 @@ export default class Dmart {
|
|
|
383
395
|
);
|
|
384
396
|
return data;
|
|
385
397
|
} catch (error: any) {
|
|
386
|
-
|
|
398
|
+
throw new Error(error.response.data)
|
|
387
399
|
}
|
|
388
400
|
}
|
|
389
401
|
|
|
@@ -407,7 +419,7 @@ export default class Dmart {
|
|
|
407
419
|
}
|
|
408
420
|
return data;
|
|
409
421
|
} catch (error: any) {
|
|
410
|
-
|
|
422
|
+
throw new Error(error.response.data)
|
|
411
423
|
}
|
|
412
424
|
}
|
|
413
425
|
|
|
@@ -424,8 +436,8 @@ export default class Dmart {
|
|
|
424
436
|
{headers, timeout: 3000}
|
|
425
437
|
);
|
|
426
438
|
return data;
|
|
427
|
-
} catch (
|
|
428
|
-
|
|
439
|
+
} catch (error: any) {
|
|
440
|
+
throw new Error(error.response.data)
|
|
429
441
|
}
|
|
430
442
|
}
|
|
431
443
|
|
|
@@ -441,7 +453,7 @@ export default class Dmart {
|
|
|
441
453
|
);
|
|
442
454
|
return data;
|
|
443
455
|
} catch (error: any) {
|
|
444
|
-
|
|
456
|
+
throw new Error(error.response.data)
|
|
445
457
|
}
|
|
446
458
|
}
|
|
447
459
|
|
|
@@ -454,7 +466,7 @@ export default class Dmart {
|
|
|
454
466
|
);
|
|
455
467
|
return data;
|
|
456
468
|
} catch (error: any) {
|
|
457
|
-
|
|
469
|
+
throw new Error(error.response.data)
|
|
458
470
|
}
|
|
459
471
|
}
|
|
460
472
|
|
|
@@ -467,7 +479,7 @@ export default class Dmart {
|
|
|
467
479
|
);
|
|
468
480
|
return data;
|
|
469
481
|
} catch (error: any) {
|
|
470
|
-
|
|
482
|
+
throw new Error(error.response.data)
|
|
471
483
|
}
|
|
472
484
|
}
|
|
473
485
|
|
|
@@ -490,7 +502,7 @@ export default class Dmart {
|
|
|
490
502
|
);
|
|
491
503
|
return data;
|
|
492
504
|
} catch (error: any) {
|
|
493
|
-
throw new Error(error.response.data
|
|
505
|
+
throw new Error(error.response.data)
|
|
494
506
|
}
|
|
495
507
|
}
|
|
496
508
|
|
|
@@ -530,13 +542,17 @@ export default class Dmart {
|
|
|
530
542
|
|
|
531
543
|
const headers = {"Content-Type": "multipart/form-data"};
|
|
532
544
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
545
|
+
try {
|
|
546
|
+
const {data} = await axios.post<ApiResponse>(
|
|
547
|
+
`${this.baseURL}/managed/resource_with_payload`,
|
|
548
|
+
form_data,
|
|
549
|
+
{headers}
|
|
550
|
+
);
|
|
538
551
|
|
|
539
|
-
|
|
552
|
+
return data;
|
|
553
|
+
} catch (error: any) {
|
|
554
|
+
throw new Error(error.response.data)
|
|
555
|
+
}
|
|
540
556
|
}
|
|
541
557
|
|
|
542
558
|
|
|
@@ -568,7 +584,7 @@ export default class Dmart {
|
|
|
568
584
|
);
|
|
569
585
|
return data;
|
|
570
586
|
} catch (error: any) {
|
|
571
|
-
|
|
587
|
+
throw new Error(error.response.data)
|
|
572
588
|
}
|
|
573
589
|
}
|
|
574
590
|
|
|
@@ -619,10 +635,14 @@ export default class Dmart {
|
|
|
619
635
|
}
|
|
620
636
|
|
|
621
637
|
public static async get_space_health(space_name: string) {
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
638
|
+
try {
|
|
639
|
+
const {data} = await axios.get<
|
|
640
|
+
ApiQueryResponse & { attributes: { folders_report: Object } }
|
|
641
|
+
>(`${this.baseURL}/managed/health/${space_name}`, {headers});
|
|
642
|
+
return data;
|
|
643
|
+
} catch (error: any) {
|
|
644
|
+
throw new Error(error.response.data)
|
|
645
|
+
}
|
|
626
646
|
}
|
|
627
647
|
|
|
628
648
|
public static async get_attachment_content(
|
|
@@ -632,11 +652,15 @@ export default class Dmart {
|
|
|
632
652
|
shortname: string,
|
|
633
653
|
scope: string = "managed"
|
|
634
654
|
) {
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
655
|
+
try {
|
|
656
|
+
const {data} = await axios.get<any>(
|
|
657
|
+
`${this.baseURL}/${scope}/payload/${resource_type}/${space_name}/${subpath}/${shortname}`,
|
|
658
|
+
{headers}
|
|
659
|
+
);
|
|
660
|
+
return data;
|
|
661
|
+
} catch (error: any) {
|
|
662
|
+
throw new Error(error.response.data)
|
|
663
|
+
}
|
|
640
664
|
}
|
|
641
665
|
|
|
642
666
|
public static async get_payload(
|
|
@@ -647,11 +671,15 @@ export default class Dmart {
|
|
|
647
671
|
ext: string = ".json",
|
|
648
672
|
scope: string = "managed"
|
|
649
673
|
) {
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
674
|
+
try {
|
|
675
|
+
const {data} = await axios.get<any>(
|
|
676
|
+
`${this.baseURL}/${scope}/payload/${resource_type}/${space_name}/${subpath}/${shortname}${ext}`,
|
|
677
|
+
{headers}
|
|
678
|
+
);
|
|
679
|
+
return data;
|
|
680
|
+
} catch (error: any) {
|
|
681
|
+
throw new Error(error.response.data)
|
|
682
|
+
}
|
|
655
683
|
}
|
|
656
684
|
|
|
657
685
|
public static async get_payload_content(
|
|
@@ -662,11 +690,15 @@ export default class Dmart {
|
|
|
662
690
|
ext: string = ".json",
|
|
663
691
|
scope: string = "managed"
|
|
664
692
|
) {
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
693
|
+
try {
|
|
694
|
+
const {data} = await axios.get<any>(
|
|
695
|
+
`${this.baseURL}/${scope}/payload/${resource_type}/${space_name}/${subpath}/${shortname}${ext}`,
|
|
696
|
+
{headers}
|
|
697
|
+
);
|
|
698
|
+
return data;
|
|
699
|
+
}catch (error: any) {
|
|
700
|
+
throw new Error(error.response.data)
|
|
701
|
+
}
|
|
670
702
|
}
|
|
671
703
|
|
|
672
704
|
public static async progress_ticket(
|
|
@@ -694,7 +726,7 @@ export default class Dmart {
|
|
|
694
726
|
);
|
|
695
727
|
return data;
|
|
696
728
|
} catch (error: any) {
|
|
697
|
-
|
|
729
|
+
throw new Error(error.response.data)
|
|
698
730
|
}
|
|
699
731
|
}
|
|
700
732
|
|
|
@@ -712,21 +744,29 @@ export default class Dmart {
|
|
|
712
744
|
);
|
|
713
745
|
return data;
|
|
714
746
|
} catch (error: any) {
|
|
715
|
-
|
|
747
|
+
throw new Error(error.response.data)
|
|
716
748
|
}
|
|
717
749
|
}
|
|
718
750
|
|
|
719
751
|
public static async get_manifest() {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
752
|
+
try {
|
|
753
|
+
const {data} = await axios.get<any>(`${this.baseURL}/info/manifest`, {
|
|
754
|
+
headers,
|
|
755
|
+
});
|
|
756
|
+
return data;
|
|
757
|
+
} catch (error: any) {
|
|
758
|
+
throw new Error(error.response.data)
|
|
759
|
+
}
|
|
724
760
|
}
|
|
725
761
|
|
|
726
762
|
public static async get_settings() {
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
763
|
+
try{
|
|
764
|
+
const {data} = await axios.get<any>(`${this.baseURL}/info/settings`, {
|
|
765
|
+
headers,
|
|
766
|
+
});
|
|
767
|
+
return data;
|
|
768
|
+
} catch (error: any) {
|
|
769
|
+
throw new Error(error.response.data)
|
|
770
|
+
}
|
|
731
771
|
}
|
|
732
772
|
}
|