@edraj/tsdmart 5.1.0 → 5.2.0
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/dmart.model.ts +12 -9
- package/dmart.service.ts +676 -796
- package/index.ts +0 -2
- package/package.json +1 -1
- package/tsconfig.json +1 -5
- package/config.ts +0 -9
package/dmart.service.ts
CHANGED
|
@@ -1,796 +1,676 @@
|
|
|
1
|
-
import {AxiosInstance} from "axios";
|
|
2
|
-
import {
|
|
3
|
-
ActionRequest,
|
|
4
|
-
ActionRequestRecord,
|
|
5
|
-
ActionResponse,
|
|
6
|
-
ApiQueryResponse,
|
|
7
|
-
ApiResponse,
|
|
8
|
-
ConfirmOTPRequest,
|
|
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
|
-
|
|
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
|
-
|
|
70
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
headers
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
*
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
*
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
*
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
*
|
|
221
|
-
* @
|
|
222
|
-
* @
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
request
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
/**
|
|
470
|
-
* Retrieves
|
|
471
|
-
* @
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
*
|
|
485
|
-
* @
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
)
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
);
|
|
526
|
-
return
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
/**
|
|
530
|
-
*
|
|
531
|
-
* @param
|
|
532
|
-
* @returns Promise resolving to
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
*
|
|
577
|
-
* @
|
|
578
|
-
* @
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
*
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
/**
|
|
650
|
-
*
|
|
651
|
-
* @
|
|
652
|
-
* @
|
|
653
|
-
*/
|
|
654
|
-
public static async
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
*
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
const requestHeaders = {...headers};
|
|
678
|
-
if (acceptLanguage) {
|
|
679
|
-
requestHeaders['Accept-Language'] = acceptLanguage;
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
683
|
-
'user/otp-request',
|
|
684
|
-
request,
|
|
685
|
-
{headers: requestHeaders}
|
|
686
|
-
);
|
|
687
|
-
return data;
|
|
688
|
-
} catch (error: any) {
|
|
689
|
-
throw error;
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
/**
|
|
694
|
-
* Sends an OTP (One-Time Password) request for login purposes
|
|
695
|
-
* @param request - SendOTPRequest containing recipient information for login OTP
|
|
696
|
-
* @param acceptLanguage - Optional language preference for the OTP message (default: null)
|
|
697
|
-
* @returns Promise resolving to ApiResponse with OTP login request result
|
|
698
|
-
* @throws Error if OTP login request fails
|
|
699
|
-
*/
|
|
700
|
-
public static async otpRequestLogin(
|
|
701
|
-
request: SendOTPRequest,
|
|
702
|
-
acceptLanguage: string | null = null
|
|
703
|
-
) {
|
|
704
|
-
try {
|
|
705
|
-
const requestHeaders = {...headers};
|
|
706
|
-
if (acceptLanguage) {
|
|
707
|
-
requestHeaders['Accept-Language'] = acceptLanguage;
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
711
|
-
'user/otp-request-login',
|
|
712
|
-
request,
|
|
713
|
-
{headers: requestHeaders}
|
|
714
|
-
);
|
|
715
|
-
return data;
|
|
716
|
-
} catch (error: any) {
|
|
717
|
-
throw error;
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
/**
|
|
722
|
-
* Initiates a password reset request for a user
|
|
723
|
-
* @param request - PasswordResetRequest containing user identification for password reset
|
|
724
|
-
* @returns Promise resolving to ApiResponse with password reset request result
|
|
725
|
-
* @throws Error if password reset request fails
|
|
726
|
-
*/
|
|
727
|
-
public static async passwordResetRequest(request: PasswordResetRequest) {
|
|
728
|
-
try {
|
|
729
|
-
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
730
|
-
'user/password-reset-request',
|
|
731
|
-
request,
|
|
732
|
-
{headers}
|
|
733
|
-
);
|
|
734
|
-
return data;
|
|
735
|
-
} catch (error: any) {
|
|
736
|
-
throw error;
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
/**
|
|
741
|
-
* Confirms an OTP (One-Time Password) code provided by the user
|
|
742
|
-
* @param request - ConfirmOTPRequest containing the OTP code and verification details
|
|
743
|
-
* @returns Promise resolving to ApiResponse with OTP confirmation result
|
|
744
|
-
* @throws Error if OTP confirmation fails
|
|
745
|
-
*/
|
|
746
|
-
public static async confirmOtp(request: ConfirmOTPRequest) {
|
|
747
|
-
try {
|
|
748
|
-
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
749
|
-
'user/otp-confirm',
|
|
750
|
-
request,
|
|
751
|
-
{headers}
|
|
752
|
-
);
|
|
753
|
-
return data;
|
|
754
|
-
} catch (error: any) {
|
|
755
|
-
throw error;
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
/**
|
|
760
|
-
* Resets a user's account or session state
|
|
761
|
-
* @param shortname - The shortname (username) of the user to reset
|
|
762
|
-
* @returns Promise resolving to ApiResponse with user reset result
|
|
763
|
-
* @throws Error if user reset fails
|
|
764
|
-
*/
|
|
765
|
-
public static async userReset(shortname: string) {
|
|
766
|
-
try {
|
|
767
|
-
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
768
|
-
'user/reset',
|
|
769
|
-
{shortname},
|
|
770
|
-
{headers}
|
|
771
|
-
);
|
|
772
|
-
return data;
|
|
773
|
-
} catch (error: any) {
|
|
774
|
-
throw error;
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
/**
|
|
779
|
-
* Validates a password against system password policies and requirements
|
|
780
|
-
* @param password - The password string to validate
|
|
781
|
-
* @returns Promise resolving to ApiResponse with validation result
|
|
782
|
-
* @throws Error if password validation fails
|
|
783
|
-
*/
|
|
784
|
-
public static async validatePassword(password: string) {
|
|
785
|
-
try {
|
|
786
|
-
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
787
|
-
'user/validate_password',
|
|
788
|
-
{password},
|
|
789
|
-
{headers}
|
|
790
|
-
);
|
|
791
|
-
return data;
|
|
792
|
-
} catch (error: any) {
|
|
793
|
-
throw error;
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
}
|
|
1
|
+
import {AxiosInstance} from "axios";
|
|
2
|
+
import {
|
|
3
|
+
ActionRequest,
|
|
4
|
+
ActionRequestRecord,
|
|
5
|
+
ActionResponse,
|
|
6
|
+
ApiQueryResponse,
|
|
7
|
+
ApiResponse,
|
|
8
|
+
ConfirmOTPRequest,
|
|
9
|
+
DmartScope,
|
|
10
|
+
FetchDataAssetRequest,
|
|
11
|
+
GetAttachmentURLRequest,
|
|
12
|
+
GetChildrenRequest,
|
|
13
|
+
GetPayloadRequest,
|
|
14
|
+
headers,
|
|
15
|
+
LoginResponse,
|
|
16
|
+
PasswordResetRequest,
|
|
17
|
+
ProfileResponse,
|
|
18
|
+
ProgressTicketRequest,
|
|
19
|
+
QueryRequest,
|
|
20
|
+
QueryType,
|
|
21
|
+
ResourcesFromCSVRequest,
|
|
22
|
+
ResponseEntry,
|
|
23
|
+
RetrieveEntryRequest,
|
|
24
|
+
SendOTPRequest,
|
|
25
|
+
SortType,
|
|
26
|
+
Status,
|
|
27
|
+
SubmitRequest,
|
|
28
|
+
UploadWithPayloadRequest,
|
|
29
|
+
} from "./dmart.model";
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
export class Dmart {
|
|
33
|
+
static axiosDmartInstance: AxiosInstance;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Sets the Axios instance to be used for all HTTP requests
|
|
37
|
+
* @param axiosInstance - The Axios instance to use for API calls
|
|
38
|
+
*/
|
|
39
|
+
static setAxiosInstance(axiosInstance: AxiosInstance) {
|
|
40
|
+
Dmart.axiosDmartInstance = axiosInstance;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Gets the current Axios instance
|
|
45
|
+
* @returns The configured Axios instance
|
|
46
|
+
* @throws Error if no Axios instance has been set
|
|
47
|
+
*/
|
|
48
|
+
public static getAxiosInstance(): AxiosInstance {
|
|
49
|
+
if (!Dmart.axiosDmartInstance) {
|
|
50
|
+
throw new Error("Axios instance is not set. Please set it using setAxiosInstance method.");
|
|
51
|
+
}
|
|
52
|
+
return Dmart.axiosDmartInstance;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Gets the current headers object used for API requests
|
|
57
|
+
* @returns The headers object containing request headers
|
|
58
|
+
*/
|
|
59
|
+
public static getHeaders() {
|
|
60
|
+
return headers;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Updates the headers object with new headers
|
|
65
|
+
* @param newHeaders - Object containing headers to merge with existing headers
|
|
66
|
+
*/
|
|
67
|
+
public static setHeaders(newHeaders: Record<string, string>) {
|
|
68
|
+
Object.assign(headers, newHeaders);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Gets the base URL from the Axios instance
|
|
73
|
+
* @returns The base URL string
|
|
74
|
+
* @throws Error if no Axios instance has been set
|
|
75
|
+
*/
|
|
76
|
+
public static getBaseURL() {
|
|
77
|
+
return Dmart.getAxiosInstance().defaults.baseURL;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Sets the base URL for the Axios instance
|
|
82
|
+
* @param url - The base URL to set
|
|
83
|
+
*/
|
|
84
|
+
public static setBaseURL(url: string) {
|
|
85
|
+
Dmart.getAxiosInstance().defaults.baseURL = url;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Gets the current authentication token
|
|
90
|
+
* @returns The token string without the "Bearer " prefix, or null if not set
|
|
91
|
+
*/
|
|
92
|
+
public static getToken() {
|
|
93
|
+
return headers["Authorization"] ? headers["Authorization"].replace("Bearer ", "") : null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Sets the authentication token in the headers
|
|
98
|
+
* @param token - The JWT token to use for authentication
|
|
99
|
+
*/
|
|
100
|
+
public static setToken(token: string) {
|
|
101
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Authenticates a user with shortname and password
|
|
106
|
+
* @param shortname - The user's shortname (username)
|
|
107
|
+
* @param password - The user's password
|
|
108
|
+
* @returns Promise resolving to LoginResponse containing authentication data and access token
|
|
109
|
+
*/
|
|
110
|
+
public static async login(shortname: string, password: string) {
|
|
111
|
+
const response = await Dmart.axiosDmartInstance.post<LoginResponse>(
|
|
112
|
+
'user/login',
|
|
113
|
+
{shortname, password},
|
|
114
|
+
{headers}
|
|
115
|
+
);
|
|
116
|
+
const data: LoginResponse = response.data;
|
|
117
|
+
if (data.status === Status.success && data.records.length > 0) {
|
|
118
|
+
headers["Authorization"] = "Bearer " + data.records[0]?.attributes.access_token;
|
|
119
|
+
}
|
|
120
|
+
return data;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Authenticates a user with custom credentials and password
|
|
125
|
+
* @param credentials - Object containing login credentials (e.g., email, phone, etc.)
|
|
126
|
+
* @param password - The user's password
|
|
127
|
+
* @returns Promise resolving to LoginResponse containing authentication data and access token
|
|
128
|
+
*/
|
|
129
|
+
public static async loginBy(credentials: Record<string, string>, password: string) {
|
|
130
|
+
const response = await Dmart.axiosDmartInstance.post<LoginResponse>(
|
|
131
|
+
'user/login',
|
|
132
|
+
{...credentials, password},
|
|
133
|
+
{headers}
|
|
134
|
+
);
|
|
135
|
+
const data: LoginResponse = response.data;
|
|
136
|
+
if (data.status === Status.success && data.records.length > 0) {
|
|
137
|
+
headers["Authorization"] =
|
|
138
|
+
"Bearer " + data.records[0]?.attributes.access_token;
|
|
139
|
+
}
|
|
140
|
+
return data;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Logs out the current user session
|
|
145
|
+
* @returns Promise resolving to ApiResponse indicating logout status
|
|
146
|
+
*/
|
|
147
|
+
public static async logout() {
|
|
148
|
+
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
149
|
+
'user/logout',
|
|
150
|
+
{},
|
|
151
|
+
{headers}
|
|
152
|
+
);
|
|
153
|
+
return data;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Creates a new user account
|
|
158
|
+
* @param request - ActionRequestRecord containing user creation data
|
|
159
|
+
* @returns Promise resolving to ActionResponse with creation result
|
|
160
|
+
*/
|
|
161
|
+
public static async createUser(request: ActionRequestRecord) {
|
|
162
|
+
const {data} = await Dmart.axiosDmartInstance.post<ActionResponse>(
|
|
163
|
+
'user/create',
|
|
164
|
+
request,
|
|
165
|
+
{headers}
|
|
166
|
+
);
|
|
167
|
+
return data;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Updates an existing user's profile information
|
|
172
|
+
* @param request - ActionRequestRecord containing user update data
|
|
173
|
+
* @returns Promise resolving to ActionResponse with update result
|
|
174
|
+
*/
|
|
175
|
+
public static async updateUser(request: ActionRequestRecord) {
|
|
176
|
+
const {data} = await Dmart.axiosDmartInstance.post<ActionResponse>(
|
|
177
|
+
'user/profile',
|
|
178
|
+
request,
|
|
179
|
+
{headers}
|
|
180
|
+
);
|
|
181
|
+
return data;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Checks if a user property value already exists in the system
|
|
186
|
+
* @param prop - The property name to check (e.g., 'email', 'shortname')
|
|
187
|
+
* @param value - The value to check for existence
|
|
188
|
+
* @returns Promise resolving to ResponseEntry indicating if the value exists
|
|
189
|
+
*/
|
|
190
|
+
public static async checkExisting(prop: string, value: string) {
|
|
191
|
+
const {data} = await Dmart.axiosDmartInstance.get<ResponseEntry>(
|
|
192
|
+
`user/check-existing?${prop}=${value}`,
|
|
193
|
+
{headers}
|
|
194
|
+
);
|
|
195
|
+
return data;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Retrieves the current user's profile information
|
|
200
|
+
* @returns Promise resolving to ProfileResponse containing user profile data, permissions, and roles
|
|
201
|
+
*/
|
|
202
|
+
public static async getProfile() {
|
|
203
|
+
const {data} = await Dmart.axiosDmartInstance.get<ProfileResponse>('user/profile', {
|
|
204
|
+
headers,
|
|
205
|
+
});
|
|
206
|
+
if (typeof localStorage !== "undefined" && data.status === "success") {
|
|
207
|
+
localStorage.setItem(
|
|
208
|
+
"permissions",
|
|
209
|
+
JSON.stringify((data?.records ?? [{}])[0]?.attributes.permissions)
|
|
210
|
+
);
|
|
211
|
+
localStorage.setItem(
|
|
212
|
+
"roles",
|
|
213
|
+
JSON.stringify((data?.records ?? [{}])[0]?.attributes?.["roles"])
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
return data;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Executes a query against the Dmart API to retrieve data
|
|
221
|
+
* @param query - QueryRequest object containing query parameters, filters, and sorting options
|
|
222
|
+
* @param scope - The scope for the query (default: DmartScope.managed)
|
|
223
|
+
* @returns Promise resolving to ApiQueryResponse with query results or null
|
|
224
|
+
*/
|
|
225
|
+
public static async query(
|
|
226
|
+
query: QueryRequest,
|
|
227
|
+
scope: DmartScope = DmartScope.managed
|
|
228
|
+
): Promise<ApiQueryResponse | null> {
|
|
229
|
+
if (query.type !== QueryType.spaces) {
|
|
230
|
+
query.sort_type = query.sort_type || SortType.ascending;
|
|
231
|
+
query.sort_by = query.sort_by || "created_at";
|
|
232
|
+
}
|
|
233
|
+
query.subpath = query.subpath.replace(/\/+/g, "/");
|
|
234
|
+
const {data} = await Dmart.axiosDmartInstance.post<ApiQueryResponse>(
|
|
235
|
+
`${scope}/query`,
|
|
236
|
+
query,
|
|
237
|
+
{headers}
|
|
238
|
+
);
|
|
239
|
+
return data;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Exports query results as CSV format
|
|
244
|
+
* @param query - Query object with parameters for CSV export
|
|
245
|
+
* @returns Promise resolving to ApiQueryResponse containing CSV data
|
|
246
|
+
*/
|
|
247
|
+
public static async csv(query: QueryRequest): Promise<ApiQueryResponse> {
|
|
248
|
+
query.sort_type = query.sort_type || SortType.ascending;
|
|
249
|
+
query.sort_by = "created_at";
|
|
250
|
+
query.subpath = query.subpath.replace(/\/+/g, "/");
|
|
251
|
+
const {data} = await Dmart.axiosDmartInstance.post<ApiQueryResponse>(
|
|
252
|
+
'managed/csv',
|
|
253
|
+
query,
|
|
254
|
+
{headers}
|
|
255
|
+
);
|
|
256
|
+
return data;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Creates resources from an uploaded CSV file
|
|
261
|
+
* @param request - ResourcesFromCSVRequest containing file data and resource configuration
|
|
262
|
+
* @returns Promise resolving to ApiResponse with creation results
|
|
263
|
+
*/
|
|
264
|
+
public static async resourcesFromCsv(
|
|
265
|
+
request: ResourcesFromCSVRequest
|
|
266
|
+
) {
|
|
267
|
+
let csvUrl = `/managed/resources_from_csv/${request.resourceType}/${request.space_name}/${request.subpath}`;
|
|
268
|
+
const params: Record<string, boolean> = {};
|
|
269
|
+
if (request.schema) {
|
|
270
|
+
csvUrl += `/${request.schema}`;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const formdata = new FormData();
|
|
274
|
+
formdata.append("resources_file", request.payload);
|
|
275
|
+
|
|
276
|
+
if (request.isUpdate) {
|
|
277
|
+
params['is_update'] = request.isUpdate;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const multipartHeaders = {...headers, "Content-Type": "multipart/form-data"};
|
|
281
|
+
|
|
282
|
+
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
283
|
+
csvUrl,
|
|
284
|
+
formdata,
|
|
285
|
+
{headers: multipartHeaders, params}
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
return data;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// /** LEGACY, DEPRECATED CODE, DO NOT USE
|
|
292
|
+
// * Performs space-level operations (create, update, delete spaces)
|
|
293
|
+
// * @param action - ActionRequest containing the operation details for space management
|
|
294
|
+
// * @returns Promise resolving to ActionResponse with operation result
|
|
295
|
+
// */
|
|
296
|
+
// public static async space(action: ActionRequest): Promise<ActionResponse> {
|
|
297
|
+
// const {data} = await Dmart.axiosDmartInstance.post<ActionResponse>(
|
|
298
|
+
// 'managed/space',
|
|
299
|
+
// action,
|
|
300
|
+
// {headers}
|
|
301
|
+
// );
|
|
302
|
+
// return data;
|
|
303
|
+
// }
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Executes a general request action against the Dmart API
|
|
307
|
+
* @param action - ActionRequest containing the request details and parameters
|
|
308
|
+
* @returns Promise resolving to ActionResponse with request result
|
|
309
|
+
*/
|
|
310
|
+
public static async request(action: ActionRequest): Promise<ActionResponse> {
|
|
311
|
+
const res = await Dmart.axiosDmartInstance.post<ActionResponse>('managed/request', action, {
|
|
312
|
+
headers,
|
|
313
|
+
});
|
|
314
|
+
return res?.data;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Retrieves a specific entry from the Dmart system
|
|
319
|
+
* @param request - RetrieveEntryRequest containing entry identification and retrieval options
|
|
320
|
+
* @param scope - The scope for the retrieval (default: DmartScope.managed)
|
|
321
|
+
* @returns Promise resolving to ResponseEntry with entry data or null if not found
|
|
322
|
+
*/
|
|
323
|
+
public static async retrieveEntry(
|
|
324
|
+
request: RetrieveEntryRequest,
|
|
325
|
+
scope: DmartScope = DmartScope.managed
|
|
326
|
+
): Promise<ResponseEntry | null> {
|
|
327
|
+
if (request.validate_schema === null) {
|
|
328
|
+
request.validate_schema = true;
|
|
329
|
+
}
|
|
330
|
+
if (!request.subpath || request.subpath === "/") request.subpath = "__root__";
|
|
331
|
+
const url = `${scope}/entry/${request.resource_type}/${request.space_name}/${request.subpath}/${request.shortname}?retrieve_json_payload=${request.retrieve_json_payload}&retrieve_attachments=${request.retrieve_attachments}&validate_schema=${request.validate_schema}`;
|
|
332
|
+
const {data} = await Dmart.axiosDmartInstance.get<ResponseEntry>(
|
|
333
|
+
`${url.replace(/\/+/g, "/")}`,
|
|
334
|
+
{headers}
|
|
335
|
+
);
|
|
336
|
+
return data;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Uploads a resource with an attached payload file
|
|
342
|
+
* @param request - UploadWithPayloadRequest containing resource data and payload file
|
|
343
|
+
* @param scope - The scope for the upload operation (default: DmartScope.managed)
|
|
344
|
+
* @returns Promise resolving to ApiResponse with upload result
|
|
345
|
+
*/
|
|
346
|
+
public static async uploadWithPayload(
|
|
347
|
+
request: UploadWithPayloadRequest,
|
|
348
|
+
scope: DmartScope = DmartScope.managed
|
|
349
|
+
) {
|
|
350
|
+
const request_record_body: Record<string, any> = {
|
|
351
|
+
resource_type: request.resource_type,
|
|
352
|
+
subpath: request.subpath,
|
|
353
|
+
shortname: request.shortname,
|
|
354
|
+
attributes: request.attributes ?? {},
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
if (!request.attributes || Object.keys(request.attributes).length === 0) {
|
|
358
|
+
request_record_body['attributes'] = {is_active: true, payload: {body: {}}};
|
|
359
|
+
} else {
|
|
360
|
+
if (!Object.keys(request.attributes).includes('is_active')) {
|
|
361
|
+
request_record_body['attributes'].is_active = true;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const request_record = new Blob([JSON.stringify(request_record_body)], {
|
|
366
|
+
type: "application/json",
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
const form_data = new FormData();
|
|
370
|
+
form_data.append("space_name", request.space_name);
|
|
371
|
+
form_data.append("request_record", request_record);
|
|
372
|
+
form_data.append("payload_file", request.payload_file);
|
|
373
|
+
|
|
374
|
+
const _headers = {...headers, "Content-Type": "multipart/form-data"};
|
|
375
|
+
|
|
376
|
+
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
377
|
+
`${scope}/resource_with_payload`,
|
|
378
|
+
form_data,
|
|
379
|
+
{headers: _headers}
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
return data;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Fetches data assets from the Dmart system with optional SQL query filtering
|
|
387
|
+
* @param request - FetchDataAssetRequest containing asset identification and query parameters
|
|
388
|
+
* @returns Promise resolving to data asset response
|
|
389
|
+
*/
|
|
390
|
+
public static async fetchDataAsset(
|
|
391
|
+
request: FetchDataAssetRequest,
|
|
392
|
+
) {
|
|
393
|
+
const {data} = await Dmart.axiosDmartInstance.post(
|
|
394
|
+
'managed/data-asset',
|
|
395
|
+
{
|
|
396
|
+
space_name: request.spaceName,
|
|
397
|
+
resource_type: request.resourceType,
|
|
398
|
+
data_asset_type: request.dataAssetType,
|
|
399
|
+
subpath: request.subpath,
|
|
400
|
+
shortname: request.shortname,
|
|
401
|
+
query_string: request.query_string ?? "SELECT * FROM file",
|
|
402
|
+
filter_data_assets: request.filter_data_assets,
|
|
403
|
+
},
|
|
404
|
+
{headers}
|
|
405
|
+
);
|
|
406
|
+
return data;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Retrieves a list of all available spaces in the system
|
|
411
|
+
* @returns Promise resolving to ApiResponse containing spaces data or null
|
|
412
|
+
*/
|
|
413
|
+
public static async getSpaces(): Promise<ApiResponse | null> {
|
|
414
|
+
return await this.query({
|
|
415
|
+
type: QueryType.spaces,
|
|
416
|
+
space_name: "management",
|
|
417
|
+
subpath: "/",
|
|
418
|
+
search: "",
|
|
419
|
+
limit: 100,
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Gets child resources within a specified space and subpath
|
|
425
|
+
* @param request - GetChildrenRequest containing search parameters and filters
|
|
426
|
+
* @returns Promise resolving to ApiResponse with child resources or null
|
|
427
|
+
*/
|
|
428
|
+
public static async getChildren(
|
|
429
|
+
request: GetChildrenRequest
|
|
430
|
+
): Promise<ApiResponse | null> {
|
|
431
|
+
if (request.limit === null) {
|
|
432
|
+
request.limit = 20;
|
|
433
|
+
}
|
|
434
|
+
if (request.offset === null) {
|
|
435
|
+
request.offset = 0;
|
|
436
|
+
}
|
|
437
|
+
if (request.restrict_types === null) {
|
|
438
|
+
request.restrict_types = [];
|
|
439
|
+
}
|
|
440
|
+
return await this.query({
|
|
441
|
+
type: QueryType.search,
|
|
442
|
+
space_name: request.space_name,
|
|
443
|
+
subpath: request.subpath,
|
|
444
|
+
filter_types: request.restrict_types,
|
|
445
|
+
exact_subpath: true,
|
|
446
|
+
search: request.search,
|
|
447
|
+
limit: request.limit,
|
|
448
|
+
offset: request.offset,
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Generates a URL for accessing attachment resources
|
|
454
|
+
* @param request - GetAttachmentURLRequest containing attachment identification parameters
|
|
455
|
+
* @param scope - The scope for the attachment URL (default: DmartScope.managed)
|
|
456
|
+
* @returns String URL for accessing the attachment
|
|
457
|
+
*/
|
|
458
|
+
public static getAttachmentUrl(
|
|
459
|
+
request: GetAttachmentURLRequest,
|
|
460
|
+
scope: DmartScope = DmartScope.managed
|
|
461
|
+
) {
|
|
462
|
+
const subpath = request.subpath.replace(
|
|
463
|
+
/\/+$/,
|
|
464
|
+
""
|
|
465
|
+
);
|
|
466
|
+
return `${Dmart.getAxiosInstance().defaults.baseURL}` + `/${scope}/payload/${request.resource_type}/${request.space_name}/${subpath}/${request.parent_shortname}/${request.shortname}${request.ext === null ? "" : `.${request.ext}`}`.replaceAll('//', '/');
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Retrieves health information and statistics for a specific space
|
|
471
|
+
* @param space_name - The name of the space to check health for
|
|
472
|
+
* @returns Promise resolving to ApiQueryResponse with health data and folders report
|
|
473
|
+
*/
|
|
474
|
+
public static async getSpaceHealth(space_name: string) {
|
|
475
|
+
const {data} = await Dmart.axiosDmartInstance.get<
|
|
476
|
+
ApiQueryResponse & { attributes: { folders_report: Record<string, unknown> } }
|
|
477
|
+
>(`managed/health/${space_name}`, {headers});
|
|
478
|
+
return data;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Retrieves payload data for a specific resource
|
|
483
|
+
* @param request - GetPayloadRequest containing payload identification parameters
|
|
484
|
+
* @param scope - The scope for the payload retrieval (default: DmartScope.managed)
|
|
485
|
+
* @returns Promise resolving to payload data
|
|
486
|
+
*/
|
|
487
|
+
public static async getPayload(
|
|
488
|
+
request: GetPayloadRequest,
|
|
489
|
+
scope: DmartScope = DmartScope.managed
|
|
490
|
+
) {
|
|
491
|
+
let url = `${scope}/payload/${request.resource_type}/${request.space_name}/${request.subpath}/${request.shortname}`;
|
|
492
|
+
|
|
493
|
+
if (request.schemaShortname) {
|
|
494
|
+
url += `.${request.schemaShortname}`;
|
|
495
|
+
}
|
|
496
|
+
url += `.${request.ext}`;
|
|
497
|
+
const {data} = await Dmart.axiosDmartInstance.get<any>(
|
|
498
|
+
url,
|
|
499
|
+
{headers}
|
|
500
|
+
);
|
|
501
|
+
return data;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Updates the progress of a ticket with resolution and comments
|
|
506
|
+
* @param request - ProgressTicketRequest containing ticket identification and update data
|
|
507
|
+
* @returns Promise resolving to ApiQueryResponse with progress update result
|
|
508
|
+
*/
|
|
509
|
+
public static async progressTicket(
|
|
510
|
+
request: ProgressTicketRequest
|
|
511
|
+
) {
|
|
512
|
+
const payload: Record<string, string> = {};
|
|
513
|
+
if (request.resolution) {
|
|
514
|
+
payload['resolution'] = request.resolution;
|
|
515
|
+
}
|
|
516
|
+
if (request.comment) {
|
|
517
|
+
payload['comment'] = request.comment;
|
|
518
|
+
}
|
|
519
|
+
const {data} = await Dmart.axiosDmartInstance.put<
|
|
520
|
+
ApiQueryResponse & { attributes: { folders_report: Record<string, unknown> } }
|
|
521
|
+
>(
|
|
522
|
+
`managed/progress-ticket/${request.space_name}/${request.subpath}/${request.shortname}/${request.action}`,
|
|
523
|
+
payload,
|
|
524
|
+
{headers}
|
|
525
|
+
);
|
|
526
|
+
return data;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Submits data to a public endpoint with optional workflow processing
|
|
531
|
+
* @param request - SubmitRequest containing submission data and routing information
|
|
532
|
+
* @returns Promise resolving to submission response data
|
|
533
|
+
*/
|
|
534
|
+
public static async submit(
|
|
535
|
+
request: SubmitRequest
|
|
536
|
+
) {
|
|
537
|
+
let url = `public/submit/${request.spaceName}`;
|
|
538
|
+
if (request.resourceType) {
|
|
539
|
+
url += `/${request.resourceType}`;
|
|
540
|
+
}
|
|
541
|
+
if (request.workflowShortname) {
|
|
542
|
+
url += `/${request.workflowShortname}`;
|
|
543
|
+
}
|
|
544
|
+
url += `/${request.schemaShortname}/${request.subpath}`;
|
|
545
|
+
const {data} = await Dmart.axiosDmartInstance.post(
|
|
546
|
+
url,
|
|
547
|
+
request.record,
|
|
548
|
+
{headers}
|
|
549
|
+
);
|
|
550
|
+
return data;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Retrieves the system manifest containing configuration and metadata
|
|
555
|
+
* @returns Promise resolving to manifest data
|
|
556
|
+
*/
|
|
557
|
+
public static async getManifest() {
|
|
558
|
+
const {data} = await Dmart.axiosDmartInstance.get<any>('info/manifest', {
|
|
559
|
+
headers,
|
|
560
|
+
});
|
|
561
|
+
return data;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Retrieves the system settings and configuration
|
|
566
|
+
* @returns Promise resolving to settings data
|
|
567
|
+
*/
|
|
568
|
+
public static async getSettings() {
|
|
569
|
+
const {data} = await Dmart.axiosDmartInstance.get<any>('info/settings', {
|
|
570
|
+
headers,
|
|
571
|
+
});
|
|
572
|
+
return data;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Sends an OTP (One-Time Password) request to a user
|
|
577
|
+
* @param request - SendOTPRequest containing recipient information
|
|
578
|
+
* @param acceptLanguage - Optional language preference for the OTP message (default: null)
|
|
579
|
+
* @returns Promise resolving to ApiResponse with OTP request result
|
|
580
|
+
*/
|
|
581
|
+
public static async otpRequest(
|
|
582
|
+
request: SendOTPRequest,
|
|
583
|
+
acceptLanguage: string | null = null
|
|
584
|
+
) {
|
|
585
|
+
const requestHeaders = {...headers};
|
|
586
|
+
if (acceptLanguage) {
|
|
587
|
+
requestHeaders['Accept-Language'] = acceptLanguage;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
591
|
+
'user/otp-request',
|
|
592
|
+
request,
|
|
593
|
+
{headers: requestHeaders}
|
|
594
|
+
);
|
|
595
|
+
return data;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Sends an OTP (One-Time Password) request for login purposes
|
|
600
|
+
* @param request - SendOTPRequest containing recipient information for login OTP
|
|
601
|
+
* @param acceptLanguage - Optional language preference for the OTP message (default: null)
|
|
602
|
+
* @returns Promise resolving to ApiResponse with OTP login request result
|
|
603
|
+
*/
|
|
604
|
+
public static async otpRequestLogin(
|
|
605
|
+
request: SendOTPRequest,
|
|
606
|
+
acceptLanguage: string | null = null
|
|
607
|
+
) {
|
|
608
|
+
const requestHeaders = {...headers};
|
|
609
|
+
if (acceptLanguage) {
|
|
610
|
+
requestHeaders['Accept-Language'] = acceptLanguage;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
614
|
+
'user/otp-request-login',
|
|
615
|
+
request,
|
|
616
|
+
{headers: requestHeaders}
|
|
617
|
+
);
|
|
618
|
+
return data;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Initiates a password reset request for a user
|
|
623
|
+
* @param request - PasswordResetRequest containing user identification for password reset
|
|
624
|
+
* @returns Promise resolving to ApiResponse with password reset request result
|
|
625
|
+
*/
|
|
626
|
+
public static async passwordResetRequest(request: PasswordResetRequest) {
|
|
627
|
+
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
628
|
+
'user/password-reset-request',
|
|
629
|
+
request,
|
|
630
|
+
{headers}
|
|
631
|
+
);
|
|
632
|
+
return data;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Confirms an OTP (One-Time Password) code provided by the user
|
|
637
|
+
* @param request - ConfirmOTPRequest containing the OTP code and verification details
|
|
638
|
+
* @returns Promise resolving to ApiResponse with OTP confirmation result
|
|
639
|
+
*/
|
|
640
|
+
public static async confirmOtp(request: ConfirmOTPRequest) {
|
|
641
|
+
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
642
|
+
'user/otp-confirm',
|
|
643
|
+
request,
|
|
644
|
+
{headers}
|
|
645
|
+
);
|
|
646
|
+
return data;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Resets a user's account or session state
|
|
651
|
+
* @param shortname - The shortname (username) of the user to reset
|
|
652
|
+
* @returns Promise resolving to ApiResponse with user reset result
|
|
653
|
+
*/
|
|
654
|
+
public static async userReset(shortname: string) {
|
|
655
|
+
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
656
|
+
'user/reset',
|
|
657
|
+
{shortname},
|
|
658
|
+
{headers}
|
|
659
|
+
);
|
|
660
|
+
return data;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Validates a password against system password policies and requirements
|
|
665
|
+
* @param password - The password string to validate
|
|
666
|
+
* @returns Promise resolving to ApiResponse with validation result
|
|
667
|
+
*/
|
|
668
|
+
public static async validatePassword(password: string) {
|
|
669
|
+
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
670
|
+
'user/validate_password',
|
|
671
|
+
{password},
|
|
672
|
+
{headers}
|
|
673
|
+
);
|
|
674
|
+
return data;
|
|
675
|
+
}
|
|
676
|
+
}
|