@authenty/authapi-types 1.0.19 → 1.0.21
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 +244 -66
- package/dist/index.js +27 -9
- package/package.json +1 -1
- package/src/index.ts +248 -63
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,22 @@ export declare namespace AuthApi {
|
|
|
45
45
|
Bundle?: Bundle;
|
|
46
46
|
}[];
|
|
47
47
|
};
|
|
48
|
+
type Teacher = {
|
|
49
|
+
id: number;
|
|
50
|
+
fullname: string;
|
|
51
|
+
resume: string;
|
|
52
|
+
email: string;
|
|
53
|
+
avatar_l: string;
|
|
54
|
+
date_c: string;
|
|
55
|
+
date_r: string | null;
|
|
56
|
+
active: boolean;
|
|
57
|
+
notif_newPupil: boolean;
|
|
58
|
+
};
|
|
59
|
+
enum TeacherType {
|
|
60
|
+
DEFAULT_TEACHER = 0,
|
|
61
|
+
AUXILIAR_TEACHER = 1,
|
|
62
|
+
PARTICIPATION = 2
|
|
63
|
+
}
|
|
48
64
|
type Course = {
|
|
49
65
|
id: number;
|
|
50
66
|
type: number;
|
|
@@ -69,6 +85,14 @@ export declare namespace AuthApi {
|
|
|
69
85
|
email_after?: string;
|
|
70
86
|
date_c: string;
|
|
71
87
|
date_r?: string | null;
|
|
88
|
+
scholar_courses_teacher?: {
|
|
89
|
+
id: number;
|
|
90
|
+
courseID: number;
|
|
91
|
+
teacherID: number;
|
|
92
|
+
type: TeacherType;
|
|
93
|
+
Course?: Course;
|
|
94
|
+
Teacher?: Teacher;
|
|
95
|
+
};
|
|
72
96
|
};
|
|
73
97
|
type Consultancy = {
|
|
74
98
|
id: number;
|
|
@@ -210,6 +234,36 @@ export declare namespace AuthApi {
|
|
|
210
234
|
deletedAt: Date | null;
|
|
211
235
|
userID: number;
|
|
212
236
|
};
|
|
237
|
+
type Session = {
|
|
238
|
+
id: string;
|
|
239
|
+
hash?: string;
|
|
240
|
+
pin1?: string;
|
|
241
|
+
pin2?: string;
|
|
242
|
+
trust: boolean;
|
|
243
|
+
userID: number;
|
|
244
|
+
User?: LocalUser;
|
|
245
|
+
ip: string;
|
|
246
|
+
os: string;
|
|
247
|
+
browser: string;
|
|
248
|
+
creation_ts: number;
|
|
249
|
+
update_ts: number;
|
|
250
|
+
last_ts: number;
|
|
251
|
+
active: boolean;
|
|
252
|
+
data: string;
|
|
253
|
+
Licenses?: License[];
|
|
254
|
+
};
|
|
255
|
+
type License = {
|
|
256
|
+
id: number;
|
|
257
|
+
purchaseID: number;
|
|
258
|
+
Purchase?: Purchase;
|
|
259
|
+
levelID: number | null;
|
|
260
|
+
ProductLevel?: ProductLevel;
|
|
261
|
+
sessionID: number | null;
|
|
262
|
+
Session?: MediaSession;
|
|
263
|
+
got_at: number;
|
|
264
|
+
renew_at: number;
|
|
265
|
+
released_at: number | null;
|
|
266
|
+
};
|
|
213
267
|
type LogEntry = {
|
|
214
268
|
appId: string;
|
|
215
269
|
logCode: number;
|
|
@@ -334,6 +388,7 @@ export declare namespace AuthApi {
|
|
|
334
388
|
reqStat: number;
|
|
335
389
|
success: boolean;
|
|
336
390
|
data: T;
|
|
391
|
+
headers?: Headers;
|
|
337
392
|
msg: string;
|
|
338
393
|
};
|
|
339
394
|
namespace auth {
|
|
@@ -357,79 +412,197 @@ export declare namespace AuthApi {
|
|
|
357
412
|
type GET = objects.LocalUser[];
|
|
358
413
|
}
|
|
359
414
|
namespace user {
|
|
360
|
-
type
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
namespace updateConfig {
|
|
366
|
-
type PUT = {
|
|
367
|
-
msg?: string;
|
|
415
|
+
type POST = objects.LocalUser;
|
|
416
|
+
namespace $userId {
|
|
417
|
+
type GET = objects.LocalUser & {
|
|
418
|
+
Wallets?: objects.Wallet[];
|
|
419
|
+
PurchasesShares?: objects.PurchaseShare[];
|
|
368
420
|
};
|
|
369
|
-
}
|
|
370
|
-
namespace updateAdmin {
|
|
371
421
|
type PUT = objects.LocalUser;
|
|
372
|
-
|
|
373
|
-
namespace license {
|
|
374
|
-
type PUT = {
|
|
375
|
-
availableLicenses: number;
|
|
376
|
-
heldLicenses: number;
|
|
377
|
-
usedLicenses: number;
|
|
378
|
-
msg?: string;
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
namespace purchase {
|
|
383
|
-
namespace create {
|
|
384
|
-
type POST = {
|
|
422
|
+
type DELETE = {
|
|
385
423
|
msg?: string;
|
|
386
|
-
purchase: objects.Purchase;
|
|
387
|
-
url?: string;
|
|
388
424
|
};
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
namespace sync {
|
|
392
|
-
type POST = objects.Purchase & {
|
|
425
|
+
namespace updateConfig {
|
|
426
|
+
type PUT = {
|
|
393
427
|
msg?: string;
|
|
394
428
|
};
|
|
395
429
|
}
|
|
430
|
+
namespace updateAdmin {
|
|
431
|
+
type PUT = objects.LocalUser;
|
|
432
|
+
}
|
|
433
|
+
namespace license {
|
|
434
|
+
type GET = {
|
|
435
|
+
msg?: string;
|
|
436
|
+
license: objects.License;
|
|
437
|
+
};
|
|
438
|
+
namespace release {
|
|
439
|
+
type POST = {
|
|
440
|
+
msg?: string;
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
namespace licenses {
|
|
445
|
+
type GET = objects.License[];
|
|
446
|
+
namespace revokeAll {
|
|
447
|
+
type POST = {
|
|
448
|
+
msg: string;
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
namespace availableProducts {
|
|
453
|
+
type GET = auxiliarTypes.availableSoftware[];
|
|
454
|
+
}
|
|
455
|
+
namespace purchase {
|
|
456
|
+
type POST = {
|
|
457
|
+
msg?: string;
|
|
458
|
+
code: number;
|
|
459
|
+
purchase?: objects.Purchase;
|
|
460
|
+
url?: string;
|
|
461
|
+
};
|
|
462
|
+
namespace $purchaseId {
|
|
463
|
+
type GET = objects.Purchase;
|
|
464
|
+
type PUT = objects.Purchase;
|
|
465
|
+
type DELETE = {
|
|
466
|
+
msg?: string;
|
|
467
|
+
};
|
|
468
|
+
namespace sync {
|
|
469
|
+
type POST = {
|
|
470
|
+
msg: string;
|
|
471
|
+
purchase?: objects.Purchase;
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
namespace getFromGateway {
|
|
475
|
+
type GET = objects.PaymentSystem.PG_Purchase;
|
|
476
|
+
}
|
|
477
|
+
namespace cancel {
|
|
478
|
+
type POST = {
|
|
479
|
+
msg?: string;
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
namespace purchases {
|
|
485
|
+
type GET = objects.Purchase[];
|
|
486
|
+
namespace getByProduct {
|
|
487
|
+
type GET = {
|
|
488
|
+
ownPurchases: objects.Purchase[];
|
|
489
|
+
sharedPurchases: objects.Purchase[];
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
namespace sessions {
|
|
494
|
+
type GET = (objects.Session & {
|
|
495
|
+
Licenses: objects.License[];
|
|
496
|
+
})[];
|
|
497
|
+
namespace renew {
|
|
498
|
+
type GET = {
|
|
499
|
+
msg: string;
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
namespace revokeAllLicenses {
|
|
503
|
+
type GET = {
|
|
504
|
+
msg: string;
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
}
|
|
396
508
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
}
|
|
403
|
-
type DELETE = {
|
|
404
|
-
msg?: string;
|
|
509
|
+
}
|
|
510
|
+
namespace bundle {
|
|
511
|
+
type POST = {
|
|
512
|
+
msg: string;
|
|
513
|
+
Bundle?: objects.Bundle;
|
|
405
514
|
};
|
|
406
|
-
namespace
|
|
407
|
-
type GET = objects.
|
|
515
|
+
namespace $bundleId {
|
|
516
|
+
type GET = objects.Bundle;
|
|
517
|
+
type PUT = objects.Bundle;
|
|
518
|
+
type DELETE = {
|
|
519
|
+
msg: string;
|
|
520
|
+
};
|
|
521
|
+
namespace paymentMethod {
|
|
522
|
+
type POST = {
|
|
523
|
+
msg: string;
|
|
524
|
+
PaymentMethod: objects.PaymentMethod;
|
|
525
|
+
};
|
|
526
|
+
namespace $paymentMethodId {
|
|
527
|
+
type GET = objects.PaymentMethod;
|
|
528
|
+
type PUT = objects.PaymentMethod;
|
|
529
|
+
type DELETE = {
|
|
530
|
+
msg: string;
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
}
|
|
408
534
|
}
|
|
409
535
|
}
|
|
410
|
-
namespace
|
|
411
|
-
type
|
|
412
|
-
purchases: objects.Purchase[];
|
|
413
|
-
pagination: {
|
|
414
|
-
page: number;
|
|
415
|
-
pageSize: number;
|
|
416
|
-
count: number;
|
|
417
|
-
};
|
|
418
|
-
};
|
|
536
|
+
namespace bundles {
|
|
537
|
+
type GET = objects.Bundle[];
|
|
419
538
|
}
|
|
420
539
|
namespace product {
|
|
421
|
-
type
|
|
422
|
-
|
|
540
|
+
type POST = {
|
|
541
|
+
msg: string;
|
|
542
|
+
product?: objects.Product;
|
|
543
|
+
};
|
|
544
|
+
namespace $productId {
|
|
545
|
+
type GET = objects.Product;
|
|
546
|
+
type PUT = objects.Product;
|
|
547
|
+
type DELETE = {
|
|
548
|
+
msg: string;
|
|
549
|
+
};
|
|
550
|
+
}
|
|
423
551
|
}
|
|
424
552
|
namespace products {
|
|
425
553
|
type GET = objects.Product[];
|
|
554
|
+
namespace featured {
|
|
555
|
+
type GET = objects.Product[];
|
|
556
|
+
}
|
|
426
557
|
}
|
|
427
|
-
namespace
|
|
428
|
-
type POST =
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
msg?: string;
|
|
558
|
+
namespace course {
|
|
559
|
+
type POST = {
|
|
560
|
+
msg: string;
|
|
561
|
+
course?: objects.Course;
|
|
432
562
|
};
|
|
563
|
+
namespace $courseId {
|
|
564
|
+
type GET = objects.Course;
|
|
565
|
+
type PUT = objects.Course;
|
|
566
|
+
type DELETE = {
|
|
567
|
+
msg: string;
|
|
568
|
+
};
|
|
569
|
+
namespace teachers {
|
|
570
|
+
type GET = objects.Teacher[];
|
|
571
|
+
}
|
|
572
|
+
namespace enroll {
|
|
573
|
+
type POST = {
|
|
574
|
+
msg?: string;
|
|
575
|
+
url?: string;
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
namespace courses {
|
|
581
|
+
type GET = objects.Course[];
|
|
582
|
+
namespace teachers {
|
|
583
|
+
type GET = objects.Teacher[];
|
|
584
|
+
}
|
|
585
|
+
namespace teacher {
|
|
586
|
+
namespace $teacherId {
|
|
587
|
+
type GET = objects.Teacher;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
namespace consultancy {
|
|
592
|
+
namespace $consultancyId {
|
|
593
|
+
type GET = objects.Consultancy;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
namespace consultancies {
|
|
597
|
+
type GET = objects.Consultancy[];
|
|
598
|
+
namespace consultors {
|
|
599
|
+
type GET = objects.Teacher[];
|
|
600
|
+
}
|
|
601
|
+
namespace consultor {
|
|
602
|
+
namespace $consultorId {
|
|
603
|
+
type GET = objects.Teacher;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
433
606
|
}
|
|
434
607
|
namespace logs {
|
|
435
608
|
type POST_SEARCH = {
|
|
@@ -566,22 +739,27 @@ export declare namespace AuthApi {
|
|
|
566
739
|
checkHealth(): Promise<boolean>;
|
|
567
740
|
users: {
|
|
568
741
|
list: () => Promise<responses.ApiResponse<responses.users.GET>>;
|
|
569
|
-
get: (userId: number, includePurchases?: boolean) => Promise<responses.ApiResponse<responses.user.GET>>;
|
|
742
|
+
get: (userId: number, includePurchases?: boolean) => Promise<responses.ApiResponse<responses.user.$userId.GET>>;
|
|
570
743
|
update: (userId: number, userData: Partial<objects.LocalUser>) => Promise<responses.ApiResponse<objects.LocalUser>>;
|
|
571
744
|
updateConfig: (obj: {
|
|
572
745
|
id: number;
|
|
573
746
|
config_ihm_showRates?: boolean;
|
|
574
|
-
}) => Promise<responses.ApiResponse<responses.user.updateConfig.PUT>>;
|
|
747
|
+
}) => Promise<responses.ApiResponse<responses.user.$userId.updateConfig.PUT>>;
|
|
575
748
|
updateAdmin: (userId: number, isAdmin: boolean) => Promise<responses.ApiResponse<objects.LocalUser>>;
|
|
576
|
-
license:
|
|
749
|
+
license: {
|
|
750
|
+
list: (userId: number) => Promise<responses.ApiResponse<responses.user.$userId.licenses.GET>>;
|
|
751
|
+
get: (userId: number) => Promise<responses.ApiResponse<responses.user.$userId.license.GET>>;
|
|
752
|
+
release: (userId: number) => Promise<responses.ApiResponse<responses.user.$userId.license.release.POST>>;
|
|
753
|
+
revokeAll: (userId: number) => Promise<responses.ApiResponse<responses.user.$userId.licenses.revokeAll.POST>>;
|
|
754
|
+
};
|
|
577
755
|
};
|
|
578
756
|
purchases: {
|
|
579
|
-
new: (paymentMethodId: number, userId: number) => Promise<responses.ApiResponse<responses.purchase.
|
|
580
|
-
sync: (purchaseId: number, userId: number, async?: boolean) => Promise<responses.ApiResponse<responses.purchase.
|
|
581
|
-
update: (userId: number, purchase: objects.Purchase) => Promise<responses.ApiResponse<
|
|
582
|
-
cancel: (purchaseId: number, userId: number) => Promise<responses.ApiResponse<
|
|
583
|
-
delete: (purchaseId: number, userId: number) => Promise<responses.ApiResponse<responses.purchase.DELETE>>;
|
|
584
|
-
list: (
|
|
757
|
+
new: (paymentMethodId: number, userId: number) => Promise<responses.ApiResponse<responses.user.$userId.purchase.POST>>;
|
|
758
|
+
sync: (purchaseId: number, userId: number, async?: boolean) => Promise<responses.ApiResponse<responses.user.$userId.purchase.$purchaseId.sync.POST>>;
|
|
759
|
+
update: (userId: number, purchase: objects.Purchase) => Promise<responses.ApiResponse<objects.Purchase>>;
|
|
760
|
+
cancel: (purchaseId: number, userId: number) => Promise<responses.ApiResponse<responses.user.$userId.purchase.$purchaseId.cancel.POST>>;
|
|
761
|
+
delete: (purchaseId: number, userId: number) => Promise<responses.ApiResponse<responses.user.$userId.purchase.$purchaseId.DELETE>>;
|
|
762
|
+
list: (userId: number) => Promise<responses.ApiResponse<responses.user.$userId.purchases.GET>>;
|
|
585
763
|
getFromGateway: (purchaseId: number, userId: number, async?: boolean) => Promise<responses.ApiResponse<objects.PaymentSystem.PG_Purchase>>;
|
|
586
764
|
};
|
|
587
765
|
products: {
|
|
@@ -590,9 +768,9 @@ export declare namespace AuthApi {
|
|
|
590
768
|
update: (productId: number, productData: any) => Promise<responses.ApiResponse<objects.Product>>;
|
|
591
769
|
};
|
|
592
770
|
paymentMethods: {
|
|
593
|
-
create: (id: number, paymentMethodData: objects.PaymentMethod) => Promise<responses.ApiResponse<
|
|
771
|
+
create: (id: number, paymentMethodData: objects.PaymentMethod) => Promise<responses.ApiResponse<responses.bundle.$bundleId.paymentMethod.POST>>;
|
|
594
772
|
update: (id: number, paymentMethodId: number, paymentMethodData: objects.PaymentMethod) => Promise<responses.ApiResponse<objects.PaymentMethod>>;
|
|
595
|
-
delete: (id: number, paymentMethodId: number) => Promise<responses.ApiResponse<responses.paymentMethod.DELETE>>;
|
|
773
|
+
delete: (id: number, paymentMethodId: number) => Promise<responses.ApiResponse<responses.bundle.$bundleId.paymentMethod.$paymentMethodId.DELETE>>;
|
|
596
774
|
};
|
|
597
775
|
aux: {
|
|
598
776
|
countries: () => Promise<responses.ApiResponse<responses.aux.countries.GET>>;
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,12 @@ var AuthApi;
|
|
|
34
34
|
BundleType[BundleType["SYMBOLIC_COURSE"] = 2] = "SYMBOLIC_COURSE";
|
|
35
35
|
BundleType[BundleType["SYMBOLIC_CONSULTANCY"] = 3] = "SYMBOLIC_CONSULTANCY";
|
|
36
36
|
})(BundleType = objects.BundleType || (objects.BundleType = {}));
|
|
37
|
+
let TeacherType;
|
|
38
|
+
(function (TeacherType) {
|
|
39
|
+
TeacherType[TeacherType["DEFAULT_TEACHER"] = 0] = "DEFAULT_TEACHER";
|
|
40
|
+
TeacherType[TeacherType["AUXILIAR_TEACHER"] = 1] = "AUXILIAR_TEACHER";
|
|
41
|
+
TeacherType[TeacherType["PARTICIPATION"] = 2] = "PARTICIPATION";
|
|
42
|
+
})(TeacherType = objects.TeacherType || (objects.TeacherType = {}));
|
|
37
43
|
let PaymentSystem;
|
|
38
44
|
(function (PaymentSystem) {
|
|
39
45
|
let PG_PurchaseLicenseStatus;
|
|
@@ -147,13 +153,24 @@ var AuthApi;
|
|
|
147
153
|
updateAdmin: async (userId, isAdmin) => {
|
|
148
154
|
return await this.request('PUT', `user/${userId}/admin`, { isAdmin });
|
|
149
155
|
},
|
|
150
|
-
license:
|
|
151
|
-
|
|
156
|
+
license: {
|
|
157
|
+
list: async (userId) => {
|
|
158
|
+
return await this.request('GET', `user/${userId}/licenses`, {});
|
|
159
|
+
},
|
|
160
|
+
get: async (userId) => {
|
|
161
|
+
return await this.request('GET', `user/${userId}/license`, {});
|
|
162
|
+
},
|
|
163
|
+
release: async (userId) => {
|
|
164
|
+
return await this.request('POST', `user/${userId}/license/release`, {});
|
|
165
|
+
},
|
|
166
|
+
revokeAll: async (userId) => {
|
|
167
|
+
return await this.request('GET', `user/${userId}/licenses/revokeAll`, {});
|
|
168
|
+
}
|
|
152
169
|
}
|
|
153
170
|
};
|
|
154
171
|
this.purchases = {
|
|
155
172
|
new: async (paymentMethodId, userId) => {
|
|
156
|
-
return await this.request('POST', `user/${userId}/purchase
|
|
173
|
+
return await this.request('POST', `user/${userId}/purchase`, { paymentMethodId });
|
|
157
174
|
},
|
|
158
175
|
sync: async (purchaseId, userId, async = false) => {
|
|
159
176
|
return await this.request('POST', `user/${userId}/purchase/${purchaseId}/sync`, { async });
|
|
@@ -162,13 +179,13 @@ var AuthApi;
|
|
|
162
179
|
return await this.request('PUT', `user/${userId}/purchase/${purchase.id}`, purchase);
|
|
163
180
|
},
|
|
164
181
|
cancel: async (purchaseId, userId) => {
|
|
165
|
-
return await this.request('
|
|
182
|
+
return await this.request('POST', `user/${userId}/purchase/${purchaseId}/cancel`, {});
|
|
166
183
|
},
|
|
167
184
|
delete: async (purchaseId, userId) => {
|
|
168
185
|
return await this.request('DELETE', `user/${userId}/purchase/${purchaseId}`, {});
|
|
169
186
|
},
|
|
170
|
-
list: async (
|
|
171
|
-
return await this.request('
|
|
187
|
+
list: async (userId) => {
|
|
188
|
+
return await this.request('GET', `user/${userId}/purchases`, {});
|
|
172
189
|
},
|
|
173
190
|
getFromGateway: async (purchaseId, userId, async = false) => {
|
|
174
191
|
return await this.request('GET', `user/${userId}/purchase/${purchaseId}/getFromGateway`, {});
|
|
@@ -187,13 +204,13 @@ var AuthApi;
|
|
|
187
204
|
};
|
|
188
205
|
this.paymentMethods = {
|
|
189
206
|
create: async (id, paymentMethodData) => {
|
|
190
|
-
return await this.request('POST', `bundle/${id}/
|
|
207
|
+
return await this.request('POST', `bundle/${id}/paymentMethod`, paymentMethodData);
|
|
191
208
|
},
|
|
192
209
|
update: async (id, paymentMethodId, paymentMethodData) => {
|
|
193
|
-
return await this.request('PUT', `bundle/${id}/
|
|
210
|
+
return await this.request('PUT', `bundle/${id}/paymentMethod/${paymentMethodId}`, paymentMethodData);
|
|
194
211
|
},
|
|
195
212
|
delete: async (id, paymentMethodId) => {
|
|
196
|
-
return await this.request('DELETE', `bundle/${id}/
|
|
213
|
+
return await this.request('DELETE', `bundle/${id}/paymentMethod/${paymentMethodId}`, {});
|
|
197
214
|
}
|
|
198
215
|
};
|
|
199
216
|
this.aux = {
|
|
@@ -345,6 +362,7 @@ var AuthApi;
|
|
|
345
362
|
fetchOptions.body = JSON.stringify(params);
|
|
346
363
|
}
|
|
347
364
|
response = await fetch(url, fetchOptions);
|
|
365
|
+
result.headers = response.headers;
|
|
348
366
|
// Atualiza tokens se presentes nos headers
|
|
349
367
|
const newToken = response.headers.get('authorization');
|
|
350
368
|
if (newToken) {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -52,6 +52,23 @@ export namespace AuthApi {
|
|
|
52
52
|
}[];
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
export type Teacher = {
|
|
56
|
+
id: number,
|
|
57
|
+
fullname: string,
|
|
58
|
+
resume: string,
|
|
59
|
+
email: string,
|
|
60
|
+
avatar_l: string,
|
|
61
|
+
date_c: string,
|
|
62
|
+
date_r: string | null,
|
|
63
|
+
active: boolean,
|
|
64
|
+
notif_newPupil: boolean
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export enum TeacherType {
|
|
68
|
+
DEFAULT_TEACHER = 0,
|
|
69
|
+
AUXILIAR_TEACHER = 1,
|
|
70
|
+
PARTICIPATION = 2
|
|
71
|
+
}
|
|
55
72
|
export type Course = {
|
|
56
73
|
id: number;
|
|
57
74
|
type: number;
|
|
@@ -76,6 +93,14 @@ export namespace AuthApi {
|
|
|
76
93
|
email_after?: string;
|
|
77
94
|
date_c: string;
|
|
78
95
|
date_r?: string | null;
|
|
96
|
+
scholar_courses_teacher?: {
|
|
97
|
+
id: number,
|
|
98
|
+
courseID: number,
|
|
99
|
+
teacherID: number,
|
|
100
|
+
type: TeacherType,
|
|
101
|
+
Course?: Course,
|
|
102
|
+
Teacher?: Teacher
|
|
103
|
+
}
|
|
79
104
|
}
|
|
80
105
|
|
|
81
106
|
export type Consultancy = {
|
|
@@ -228,6 +253,36 @@ export namespace AuthApi {
|
|
|
228
253
|
deletedAt: Date | null,
|
|
229
254
|
userID: number
|
|
230
255
|
}
|
|
256
|
+
export type Session = {
|
|
257
|
+
id: string,
|
|
258
|
+
hash?: string,
|
|
259
|
+
pin1?: string,
|
|
260
|
+
pin2?: string,
|
|
261
|
+
trust: boolean,
|
|
262
|
+
userID: number,
|
|
263
|
+
User?: LocalUser,
|
|
264
|
+
ip: string,
|
|
265
|
+
os: string,
|
|
266
|
+
browser: string,
|
|
267
|
+
creation_ts: number,
|
|
268
|
+
update_ts: number,
|
|
269
|
+
last_ts: number,
|
|
270
|
+
active: boolean,
|
|
271
|
+
data: string,
|
|
272
|
+
Licenses?: License[]
|
|
273
|
+
}
|
|
274
|
+
export type License = {
|
|
275
|
+
id: number,
|
|
276
|
+
purchaseID: number,
|
|
277
|
+
Purchase?: Purchase,
|
|
278
|
+
levelID: number | null,
|
|
279
|
+
ProductLevel?: ProductLevel,
|
|
280
|
+
sessionID: number | null,
|
|
281
|
+
Session?: MediaSession,
|
|
282
|
+
got_at: number,
|
|
283
|
+
renew_at: number,
|
|
284
|
+
released_at: number | null
|
|
285
|
+
}
|
|
231
286
|
|
|
232
287
|
// Tipos para logs do sistema
|
|
233
288
|
export type LogEntry = {
|
|
@@ -383,6 +438,7 @@ export namespace AuthApi {
|
|
|
383
438
|
reqStat: number;
|
|
384
439
|
success: boolean;
|
|
385
440
|
data: T;
|
|
441
|
+
headers?: Headers;
|
|
386
442
|
msg: string;
|
|
387
443
|
}
|
|
388
444
|
|
|
@@ -403,65 +459,183 @@ export namespace AuthApi {
|
|
|
403
459
|
}
|
|
404
460
|
|
|
405
461
|
export namespace user {
|
|
406
|
-
|
|
407
|
-
export type
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
export type
|
|
411
|
-
}
|
|
412
|
-
export namespace updateAdmin {
|
|
462
|
+
|
|
463
|
+
export type POST = objects.LocalUser;
|
|
464
|
+
export namespace $userId {
|
|
465
|
+
|
|
466
|
+
export type GET = objects.LocalUser & { Wallets?: objects.Wallet[]; PurchasesShares?: objects.PurchaseShare[] };
|
|
413
467
|
export type PUT = objects.LocalUser;
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
export
|
|
417
|
-
|
|
418
|
-
|
|
468
|
+
export type DELETE = {msg?:string};
|
|
469
|
+
|
|
470
|
+
export namespace updateConfig {
|
|
471
|
+
export type PUT = { msg?: string };
|
|
472
|
+
}
|
|
473
|
+
export namespace updateAdmin {
|
|
474
|
+
export type PUT = objects.LocalUser;
|
|
475
|
+
}
|
|
476
|
+
export namespace license {
|
|
477
|
+
// export type PUT = { availableLicenses: number; heldLicenses: number; usedLicenses: number; msg?: string };
|
|
478
|
+
export type GET = { msg?: string, license: objects.License}
|
|
479
|
+
|
|
480
|
+
export namespace release {
|
|
481
|
+
export type POST = {msg?:string}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
export namespace licenses {
|
|
485
|
+
export type GET = objects.License[]
|
|
486
|
+
export namespace revokeAll {
|
|
487
|
+
export type POST = {msg: string}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
export namespace availableProducts {
|
|
492
|
+
export type GET = auxiliarTypes.availableSoftware[]
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
export namespace purchase {
|
|
496
|
+
|
|
497
|
+
export type POST = {
|
|
498
|
+
msg?: string;
|
|
499
|
+
code: number,
|
|
500
|
+
purchase?: objects.Purchase;
|
|
501
|
+
url?: string
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
export namespace $purchaseId {
|
|
505
|
+
export type GET = objects.Purchase;
|
|
506
|
+
export type PUT = objects.Purchase;
|
|
507
|
+
export type DELETE = { msg?: string };
|
|
508
|
+
|
|
509
|
+
export namespace sync {
|
|
510
|
+
export type POST = {
|
|
511
|
+
msg:string,
|
|
512
|
+
purchase?: objects.Purchase
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
export namespace getFromGateway {
|
|
516
|
+
export type GET = objects.PaymentSystem.PG_Purchase;
|
|
517
|
+
}
|
|
518
|
+
export namespace cancel {
|
|
519
|
+
export type POST = {msg?:string};
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
}
|
|
525
|
+
export namespace purchases {
|
|
526
|
+
|
|
527
|
+
export type GET = objects.Purchase[];
|
|
528
|
+
|
|
529
|
+
export namespace getByProduct {
|
|
530
|
+
export type GET = {
|
|
531
|
+
ownPurchases: objects.Purchase[],
|
|
532
|
+
sharedPurchases: objects.Purchase[]
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
419
536
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
537
|
+
export namespace sessions {
|
|
538
|
+
export type GET = (objects.Session & {
|
|
539
|
+
Licenses: objects.License[]
|
|
540
|
+
})[]
|
|
541
|
+
export namespace renew {
|
|
542
|
+
export type GET = {msg:string}
|
|
543
|
+
}
|
|
544
|
+
export namespace revokeAllLicenses {
|
|
545
|
+
export type GET = {msg:string}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
423
548
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
export namespace bundle {
|
|
552
|
+
export type POST = {msg:string, Bundle?: objects.Bundle};
|
|
553
|
+
export namespace $bundleId {
|
|
554
|
+
export type GET = objects.Bundle;
|
|
555
|
+
export type PUT = objects.Bundle;
|
|
556
|
+
export type DELETE = {msg:string};
|
|
557
|
+
|
|
558
|
+
export namespace paymentMethod {
|
|
559
|
+
export type POST = {msg:string, PaymentMethod: objects.PaymentMethod};
|
|
560
|
+
export namespace $paymentMethodId {
|
|
561
|
+
export type GET = objects.PaymentMethod;
|
|
562
|
+
export type PUT = objects.PaymentMethod;
|
|
563
|
+
export type DELETE = {msg:string};
|
|
564
|
+
}
|
|
427
565
|
}
|
|
428
566
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
567
|
+
}
|
|
568
|
+
export namespace bundles {
|
|
569
|
+
export type GET = objects.Bundle[]
|
|
570
|
+
}
|
|
571
|
+
export namespace product {
|
|
572
|
+
export type POST = {msg:string, product?:objects.Product};
|
|
573
|
+
export namespace $productId {
|
|
574
|
+
export type GET = objects.Product;
|
|
575
|
+
export type PUT = objects.Product;
|
|
576
|
+
export type DELETE = {msg:string};
|
|
432
577
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
578
|
+
}
|
|
579
|
+
export namespace products {
|
|
580
|
+
export type GET = objects.Product[];
|
|
581
|
+
export namespace featured {
|
|
582
|
+
export type GET = objects.Product[];
|
|
436
583
|
}
|
|
437
584
|
}
|
|
438
585
|
|
|
439
|
-
export namespace
|
|
440
|
-
export type
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
586
|
+
export namespace course {
|
|
587
|
+
export type POST = {msg:string, course?:objects.Course};
|
|
588
|
+
export namespace $courseId {
|
|
589
|
+
export type GET = objects.Course;
|
|
590
|
+
export type PUT = objects.Course;
|
|
591
|
+
export type DELETE = {msg:string};
|
|
592
|
+
|
|
593
|
+
export namespace teachers {
|
|
594
|
+
export type GET = objects.Teacher[]
|
|
595
|
+
}
|
|
596
|
+
export namespace enroll {
|
|
597
|
+
export type POST = {msg?:string, url?: string}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
448
600
|
}
|
|
601
|
+
export namespace courses {
|
|
602
|
+
export type GET = objects.Course[]
|
|
449
603
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
604
|
+
export namespace teachers {
|
|
605
|
+
export type GET = objects.Teacher[]
|
|
606
|
+
}
|
|
607
|
+
export namespace teacher {
|
|
608
|
+
export namespace $teacherId {
|
|
609
|
+
export type GET = objects.Teacher
|
|
610
|
+
}
|
|
611
|
+
}
|
|
453
612
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
export
|
|
613
|
+
|
|
614
|
+
export namespace consultancy {
|
|
615
|
+
export namespace $consultancyId {
|
|
616
|
+
export type GET = objects.Consultancy;
|
|
617
|
+
}
|
|
457
618
|
}
|
|
619
|
+
export namespace consultancies {
|
|
620
|
+
|
|
621
|
+
export type GET = objects.Consultancy[];
|
|
458
622
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
export
|
|
623
|
+
export namespace consultors {
|
|
624
|
+
export type GET = objects.Teacher[];
|
|
625
|
+
}
|
|
626
|
+
export namespace consultor {
|
|
627
|
+
export namespace $consultorId {
|
|
628
|
+
export type GET = objects.Teacher;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
463
631
|
}
|
|
464
632
|
|
|
633
|
+
// export namespace paymentMethod {
|
|
634
|
+
// export type POST = objects.PaymentMethod;
|
|
635
|
+
// export type PUT = objects.PaymentMethod;
|
|
636
|
+
// export type DELETE = { msg?: string };
|
|
637
|
+
// }
|
|
638
|
+
|
|
465
639
|
export namespace logs {
|
|
466
640
|
|
|
467
641
|
export type POST_SEARCH = {
|
|
@@ -659,7 +833,7 @@ export namespace AuthApi {
|
|
|
659
833
|
}
|
|
660
834
|
|
|
661
835
|
response = await fetch(url, fetchOptions);
|
|
662
|
-
|
|
836
|
+
result.headers = response.headers;
|
|
663
837
|
// Atualiza tokens se presentes nos headers
|
|
664
838
|
const newToken = response.headers.get('authorization');
|
|
665
839
|
if (newToken) {
|
|
@@ -791,43 +965,54 @@ export namespace AuthApi {
|
|
|
791
965
|
return await this.request<responses.users.GET>('GET', 'users', {});
|
|
792
966
|
},
|
|
793
967
|
get: async (userId: number, includePurchases: boolean = true) => {
|
|
794
|
-
return await this.request<responses.user.GET>('GET', `user/${userId}?includePurchases=${includePurchases}`, {});
|
|
968
|
+
return await this.request<responses.user.$userId.GET>('GET', `user/${userId}?includePurchases=${includePurchases}`, {});
|
|
795
969
|
},
|
|
796
970
|
update: async (userId: number, userData: Partial<objects.LocalUser>) => {
|
|
797
|
-
return await this.request<responses.user.PUT>('PUT', `user/${userId}`, userData);
|
|
971
|
+
return await this.request<responses.user.$userId.PUT>('PUT', `user/${userId}`, userData);
|
|
798
972
|
},
|
|
799
973
|
updateConfig: async ( obj:{id: number, config_ihm_showRates?: boolean} ) => {
|
|
800
|
-
return await this.request<responses.user.updateConfig.PUT>('PUT', `user/${obj.id}/config`, obj);
|
|
974
|
+
return await this.request<responses.user.$userId.updateConfig.PUT>('PUT', `user/${obj.id}/config`, obj);
|
|
801
975
|
},
|
|
802
976
|
updateAdmin: async (userId: number, isAdmin: boolean) => {
|
|
803
|
-
return await this.request<responses.user.updateAdmin.PUT>('PUT', `user/${userId}/admin`, { isAdmin });
|
|
977
|
+
return await this.request<responses.user.$userId.updateAdmin.PUT>('PUT', `user/${userId}/admin`, { isAdmin });
|
|
804
978
|
},
|
|
805
|
-
license:
|
|
806
|
-
|
|
979
|
+
license: {
|
|
980
|
+
list: async (userId:number) => {
|
|
981
|
+
return await this.request<responses.user.$userId.licenses.GET>('GET', `user/${userId}/licenses`, {});
|
|
982
|
+
},
|
|
983
|
+
get: async (userId:number) => {
|
|
984
|
+
return await this.request<responses.user.$userId.license.GET>('GET', `user/${userId}/license`, {});
|
|
985
|
+
},
|
|
986
|
+
release: async (userId:number) => {
|
|
987
|
+
return await this.request<responses.user.$userId.license.release.POST>('POST', `user/${userId}/license/release`, {});
|
|
988
|
+
},
|
|
989
|
+
revokeAll: async (userId:number) => {
|
|
990
|
+
return await this.request<responses.user.$userId.licenses.revokeAll.POST>('GET', `user/${userId}/licenses/revokeAll`, {});
|
|
991
|
+
}
|
|
807
992
|
}
|
|
808
993
|
}
|
|
809
994
|
|
|
810
995
|
public purchases = {
|
|
811
996
|
new: async (paymentMethodId: number, userId: number) => {
|
|
812
|
-
return await this.request<responses.purchase.
|
|
997
|
+
return await this.request<responses.user.$userId.purchase.POST>('POST', `user/${userId}/purchase`, {paymentMethodId});
|
|
813
998
|
},
|
|
814
999
|
sync: async (purchaseId: number, userId: number, async: boolean = false) => {
|
|
815
|
-
return await this.request<responses.purchase.
|
|
1000
|
+
return await this.request<responses.user.$userId.purchase.$purchaseId.sync.POST>('POST', `user/${userId}/purchase/${purchaseId}/sync`, { async });
|
|
816
1001
|
},
|
|
817
1002
|
update: async (userId: number, purchase: objects.Purchase) => {
|
|
818
|
-
return await this.request<responses.purchase.PUT>('PUT', `user/${userId}/purchase/${purchase.id}`, purchase );
|
|
1003
|
+
return await this.request<responses.user.$userId.purchase.$purchaseId.PUT>('PUT', `user/${userId}/purchase/${purchase.id}`, purchase );
|
|
819
1004
|
},
|
|
820
1005
|
cancel: async (purchaseId: number, userId: number) => {
|
|
821
|
-
return await this.request<responses.purchase.cancel.
|
|
1006
|
+
return await this.request<responses.user.$userId.purchase.$purchaseId.cancel.POST>('POST', `user/${userId}/purchase/${purchaseId}/cancel`, {} );
|
|
822
1007
|
},
|
|
823
1008
|
delete: async (purchaseId: number, userId: number) => {
|
|
824
|
-
return await this.request<responses.purchase.DELETE>('DELETE', `user/${userId}/purchase/${purchaseId}`, { });
|
|
1009
|
+
return await this.request<responses.user.$userId.purchase.$purchaseId.DELETE>('DELETE', `user/${userId}/purchase/${purchaseId}`, { });
|
|
825
1010
|
},
|
|
826
|
-
list: async (
|
|
827
|
-
return await this.request<responses.purchases.
|
|
1011
|
+
list: async (userId: number) => {
|
|
1012
|
+
return await this.request<responses.user.$userId.purchases.GET>('GET', `user/${userId}/purchases`, { });
|
|
828
1013
|
},
|
|
829
1014
|
getFromGateway: async (purchaseId: number, userId: number, async: boolean = false) => {
|
|
830
|
-
return await this.request<responses.purchase.getFromGateway.GET>('GET', `user/${userId}/purchase/${purchaseId}/getFromGateway`, {});
|
|
1015
|
+
return await this.request<responses.user.$userId.purchase.$purchaseId.getFromGateway.GET>('GET', `user/${userId}/purchase/${purchaseId}/getFromGateway`, {});
|
|
831
1016
|
},
|
|
832
1017
|
}
|
|
833
1018
|
|
|
@@ -837,23 +1022,23 @@ export namespace AuthApi {
|
|
|
837
1022
|
return await this.request<responses.products.GET>('GET', 'products', {});
|
|
838
1023
|
},
|
|
839
1024
|
get: async (productId: number) => {
|
|
840
|
-
return await this.request<responses.product.GET>('GET', `product/${productId}`, { mode: 'admin' });
|
|
1025
|
+
return await this.request<responses.product.$productId.GET>('GET', `product/${productId}`, { mode: 'admin' });
|
|
841
1026
|
},
|
|
842
1027
|
update: async (productId: number, productData: any) => {
|
|
843
|
-
return await this.request<responses.product.PUT>('PUT', `product/${productId}`, productData);
|
|
1028
|
+
return await this.request<responses.product.$productId.PUT>('PUT', `product/${productId}`, productData);
|
|
844
1029
|
}
|
|
845
1030
|
}
|
|
846
1031
|
|
|
847
1032
|
public paymentMethods = {
|
|
848
1033
|
|
|
849
1034
|
create: async (id: number, paymentMethodData: objects.PaymentMethod) => {
|
|
850
|
-
return await this.request<responses.paymentMethod.POST>('POST', `bundle/${id}/
|
|
1035
|
+
return await this.request<responses.bundle.$bundleId.paymentMethod.POST>('POST', `bundle/${id}/paymentMethod`, paymentMethodData);
|
|
851
1036
|
},
|
|
852
1037
|
update: async (id: number, paymentMethodId: number, paymentMethodData: objects.PaymentMethod) => {
|
|
853
|
-
return await this.request<responses.paymentMethod.PUT>('PUT', `bundle/${id}/
|
|
1038
|
+
return await this.request<responses.bundle.$bundleId.paymentMethod.$paymentMethodId.PUT>('PUT', `bundle/${id}/paymentMethod/${paymentMethodId}`, paymentMethodData);
|
|
854
1039
|
},
|
|
855
1040
|
delete: async (id: number, paymentMethodId: number) => {
|
|
856
|
-
return await this.request<responses.paymentMethod.DELETE>('DELETE', `bundle/${id}/
|
|
1041
|
+
return await this.request<responses.bundle.$bundleId.paymentMethod.$paymentMethodId.DELETE>('DELETE', `bundle/${id}/paymentMethod/${paymentMethodId}`, {});
|
|
857
1042
|
}
|
|
858
1043
|
}
|
|
859
1044
|
|