academe-kit 0.5.4 → 0.5.6
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.cjs +272 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1038 -0
- package/dist/index.esm.js +272 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/types/services/CertificateService.d.ts +49 -0
- package/dist/types/services/CertificateTemplateService.d.ts +232 -0
- package/dist/types/services/QuizService.d.ts +759 -1
- package/dist/types/services/index.d.ts +5 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5334,6 +5334,181 @@ function createQuizService(apiClient) {
|
|
|
5334
5334
|
params: { path: { id } },
|
|
5335
5335
|
});
|
|
5336
5336
|
},
|
|
5337
|
+
// ============================================================================
|
|
5338
|
+
// Quiz Questions
|
|
5339
|
+
// ============================================================================
|
|
5340
|
+
/**
|
|
5341
|
+
* List all quiz questions
|
|
5342
|
+
*/
|
|
5343
|
+
getQuestions(params) {
|
|
5344
|
+
return apiClient.GET('/quiz-questions', {
|
|
5345
|
+
params: {
|
|
5346
|
+
query: params,
|
|
5347
|
+
},
|
|
5348
|
+
});
|
|
5349
|
+
},
|
|
5350
|
+
/**
|
|
5351
|
+
* Get quiz question by ID
|
|
5352
|
+
*/
|
|
5353
|
+
getQuestionById(id) {
|
|
5354
|
+
return apiClient.GET('/quiz-questions/{id}', {
|
|
5355
|
+
params: { path: { id } },
|
|
5356
|
+
});
|
|
5357
|
+
},
|
|
5358
|
+
/**
|
|
5359
|
+
* Create a new quiz question
|
|
5360
|
+
*/
|
|
5361
|
+
createQuestion(data) {
|
|
5362
|
+
return apiClient.POST('/quiz-questions', {
|
|
5363
|
+
body: data,
|
|
5364
|
+
});
|
|
5365
|
+
},
|
|
5366
|
+
/**
|
|
5367
|
+
* Update quiz question
|
|
5368
|
+
*/
|
|
5369
|
+
updateQuestion(id, data) {
|
|
5370
|
+
return apiClient.PATCH('/quiz-questions/{id}', {
|
|
5371
|
+
params: { path: { id } },
|
|
5372
|
+
body: data,
|
|
5373
|
+
});
|
|
5374
|
+
},
|
|
5375
|
+
/**
|
|
5376
|
+
* Delete quiz question
|
|
5377
|
+
*/
|
|
5378
|
+
deleteQuestion(id) {
|
|
5379
|
+
return apiClient.DELETE('/quiz-questions/{id}', {
|
|
5380
|
+
params: { path: { id } },
|
|
5381
|
+
});
|
|
5382
|
+
},
|
|
5383
|
+
// ============================================================================
|
|
5384
|
+
// Quiz Question Answers
|
|
5385
|
+
// ============================================================================
|
|
5386
|
+
/**
|
|
5387
|
+
* List all quiz question answers
|
|
5388
|
+
*/
|
|
5389
|
+
getQuestionAnswers(params) {
|
|
5390
|
+
return apiClient.GET('/quiz-question-answers', {
|
|
5391
|
+
params: {
|
|
5392
|
+
query: params,
|
|
5393
|
+
},
|
|
5394
|
+
});
|
|
5395
|
+
},
|
|
5396
|
+
/**
|
|
5397
|
+
* Get quiz question answer by ID
|
|
5398
|
+
*/
|
|
5399
|
+
getQuestionAnswerById(id) {
|
|
5400
|
+
return apiClient.GET('/quiz-question-answers/{id}', {
|
|
5401
|
+
params: { path: { id } },
|
|
5402
|
+
});
|
|
5403
|
+
},
|
|
5404
|
+
/**
|
|
5405
|
+
* Create a new quiz question answer
|
|
5406
|
+
*/
|
|
5407
|
+
createQuestionAnswer(data) {
|
|
5408
|
+
return apiClient.POST('/quiz-question-answers', {
|
|
5409
|
+
body: data,
|
|
5410
|
+
});
|
|
5411
|
+
},
|
|
5412
|
+
/**
|
|
5413
|
+
* Update quiz question answer
|
|
5414
|
+
*/
|
|
5415
|
+
updateQuestionAnswer(id, data) {
|
|
5416
|
+
return apiClient.PATCH('/quiz-question-answers/{id}', {
|
|
5417
|
+
params: { path: { id } },
|
|
5418
|
+
body: data,
|
|
5419
|
+
});
|
|
5420
|
+
},
|
|
5421
|
+
/**
|
|
5422
|
+
* Delete quiz question answer
|
|
5423
|
+
*/
|
|
5424
|
+
deleteQuestionAnswer(id) {
|
|
5425
|
+
return apiClient.DELETE('/quiz-question-answers/{id}', {
|
|
5426
|
+
params: { path: { id } },
|
|
5427
|
+
});
|
|
5428
|
+
},
|
|
5429
|
+
// ============================================================================
|
|
5430
|
+
// Quiz Attempts
|
|
5431
|
+
// ============================================================================
|
|
5432
|
+
/**
|
|
5433
|
+
* List all quiz attempts
|
|
5434
|
+
*/
|
|
5435
|
+
getAttempts(params) {
|
|
5436
|
+
return apiClient.GET('/quiz-attempts', {
|
|
5437
|
+
params: {
|
|
5438
|
+
query: params,
|
|
5439
|
+
},
|
|
5440
|
+
});
|
|
5441
|
+
},
|
|
5442
|
+
/**
|
|
5443
|
+
* Get quiz attempt by ID
|
|
5444
|
+
*/
|
|
5445
|
+
getAttemptById(id) {
|
|
5446
|
+
return apiClient.GET('/quiz-attempts/{id}', {
|
|
5447
|
+
params: { path: { id } },
|
|
5448
|
+
});
|
|
5449
|
+
},
|
|
5450
|
+
/**
|
|
5451
|
+
* Create a new quiz attempt
|
|
5452
|
+
*/
|
|
5453
|
+
createAttempt(data) {
|
|
5454
|
+
return apiClient.POST('/quiz-attempts', {
|
|
5455
|
+
body: data,
|
|
5456
|
+
});
|
|
5457
|
+
},
|
|
5458
|
+
/**
|
|
5459
|
+
* Update quiz attempt
|
|
5460
|
+
*/
|
|
5461
|
+
updateAttempt(id, data) {
|
|
5462
|
+
return apiClient.PATCH('/quiz-attempts/{id}', {
|
|
5463
|
+
params: { path: { id } },
|
|
5464
|
+
body: data,
|
|
5465
|
+
});
|
|
5466
|
+
},
|
|
5467
|
+
/**
|
|
5468
|
+
* Delete quiz attempt
|
|
5469
|
+
*/
|
|
5470
|
+
deleteAttempt(id) {
|
|
5471
|
+
return apiClient.DELETE('/quiz-attempts/{id}', {
|
|
5472
|
+
params: { path: { id } },
|
|
5473
|
+
});
|
|
5474
|
+
},
|
|
5475
|
+
// ============================================================================
|
|
5476
|
+
// Quiz Attempt Answers
|
|
5477
|
+
// ============================================================================
|
|
5478
|
+
/**
|
|
5479
|
+
* List all quiz attempt answers
|
|
5480
|
+
*/
|
|
5481
|
+
getAttemptAnswers(params) {
|
|
5482
|
+
return apiClient.GET('/quiz-attempt-answers', {
|
|
5483
|
+
params: {
|
|
5484
|
+
query: params,
|
|
5485
|
+
},
|
|
5486
|
+
});
|
|
5487
|
+
},
|
|
5488
|
+
/**
|
|
5489
|
+
* Get quiz attempt answer by ID
|
|
5490
|
+
*/
|
|
5491
|
+
getAttemptAnswerById(id) {
|
|
5492
|
+
return apiClient.GET('/quiz-attempt-answers/{id}', {
|
|
5493
|
+
params: { path: { id } },
|
|
5494
|
+
});
|
|
5495
|
+
},
|
|
5496
|
+
/**
|
|
5497
|
+
* Submit a quiz attempt answer
|
|
5498
|
+
*/
|
|
5499
|
+
createAttemptAnswer(data) {
|
|
5500
|
+
return apiClient.POST('/quiz-attempt-answers', {
|
|
5501
|
+
body: data,
|
|
5502
|
+
});
|
|
5503
|
+
},
|
|
5504
|
+
/**
|
|
5505
|
+
* Delete quiz attempt answer
|
|
5506
|
+
*/
|
|
5507
|
+
deleteAttemptAnswer(id) {
|
|
5508
|
+
return apiClient.DELETE('/quiz-attempt-answers/{id}', {
|
|
5509
|
+
params: { path: { id } },
|
|
5510
|
+
});
|
|
5511
|
+
},
|
|
5337
5512
|
};
|
|
5338
5513
|
}
|
|
5339
5514
|
|
|
@@ -5348,6 +5523,14 @@ function createCertificateService(apiClient) {
|
|
|
5348
5523
|
getAll() {
|
|
5349
5524
|
return apiClient.GET("/certificates");
|
|
5350
5525
|
},
|
|
5526
|
+
/**
|
|
5527
|
+
* Get current user's certificates
|
|
5528
|
+
*/
|
|
5529
|
+
getMyCertificates(query) {
|
|
5530
|
+
return apiClient.GET('/certificates/me', {
|
|
5531
|
+
params: { query },
|
|
5532
|
+
});
|
|
5533
|
+
},
|
|
5351
5534
|
/**
|
|
5352
5535
|
* Get certificate by ID
|
|
5353
5536
|
*/
|
|
@@ -5384,6 +5567,54 @@ function createCertificateService(apiClient) {
|
|
|
5384
5567
|
};
|
|
5385
5568
|
}
|
|
5386
5569
|
|
|
5570
|
+
function createCertificateTemplateService(apiClient) {
|
|
5571
|
+
return {
|
|
5572
|
+
/**
|
|
5573
|
+
* List all certificate templates
|
|
5574
|
+
*/
|
|
5575
|
+
getAll(params) {
|
|
5576
|
+
return apiClient.GET('/certificate-templates', {
|
|
5577
|
+
params: {
|
|
5578
|
+
query: params,
|
|
5579
|
+
},
|
|
5580
|
+
});
|
|
5581
|
+
},
|
|
5582
|
+
/**
|
|
5583
|
+
* Get certificate template by ID
|
|
5584
|
+
*/
|
|
5585
|
+
getById(id) {
|
|
5586
|
+
return apiClient.GET('/certificate-templates/{id}', {
|
|
5587
|
+
params: { path: { id } },
|
|
5588
|
+
});
|
|
5589
|
+
},
|
|
5590
|
+
/**
|
|
5591
|
+
* Create a new certificate template
|
|
5592
|
+
*/
|
|
5593
|
+
create(data) {
|
|
5594
|
+
return apiClient.POST('/certificate-templates', {
|
|
5595
|
+
body: data,
|
|
5596
|
+
});
|
|
5597
|
+
},
|
|
5598
|
+
/**
|
|
5599
|
+
* Update certificate template
|
|
5600
|
+
*/
|
|
5601
|
+
update(id, data) {
|
|
5602
|
+
return apiClient.PATCH('/certificate-templates/{id}', {
|
|
5603
|
+
params: { path: { id } },
|
|
5604
|
+
body: data,
|
|
5605
|
+
});
|
|
5606
|
+
},
|
|
5607
|
+
/**
|
|
5608
|
+
* Delete certificate template
|
|
5609
|
+
*/
|
|
5610
|
+
delete(id) {
|
|
5611
|
+
return apiClient.DELETE('/certificate-templates/{id}', {
|
|
5612
|
+
params: { path: { id } },
|
|
5613
|
+
});
|
|
5614
|
+
},
|
|
5615
|
+
};
|
|
5616
|
+
}
|
|
5617
|
+
|
|
5387
5618
|
function createSeatCodeService(apiClient) {
|
|
5388
5619
|
return {
|
|
5389
5620
|
getAll(institutionId, options) {
|
|
@@ -5559,6 +5790,7 @@ function createAcademeServices(apiClient) {
|
|
|
5559
5790
|
group: createGroupService(apiClient),
|
|
5560
5791
|
quiz: createQuizService(apiClient),
|
|
5561
5792
|
certificate: createCertificateService(apiClient),
|
|
5793
|
+
certificateTemplate: createCertificateTemplateService(apiClient),
|
|
5562
5794
|
seatCode: createSeatCodeService(apiClient),
|
|
5563
5795
|
product: createProductService(apiClient),
|
|
5564
5796
|
};
|
|
@@ -5623,15 +5855,50 @@ const SecurityProvider = ({ apiBaseUrl = "https://stg-api.academe.com.br", skipA
|
|
|
5623
5855
|
// Ref para armazenar o resolver da Promise de token
|
|
5624
5856
|
const tokenReadyResolverRef = React2.useRef(null);
|
|
5625
5857
|
const tokenReadyPromiseRef = React2.useRef(null);
|
|
5858
|
+
// Estados para controle de token injetado pelo mobile
|
|
5859
|
+
const [mobileToken, setMobileToken] = React2.useState(undefined);
|
|
5860
|
+
const [isMobileWebView, setIsMobileWebView] = React2.useState(false);
|
|
5626
5861
|
// Extrair valores primitivos do auth para usar como dependências estáveis
|
|
5627
5862
|
const isAuthenticated = auth.isAuthenticated;
|
|
5628
5863
|
const isLoading = auth.isLoading;
|
|
5629
5864
|
const activeNavigator = auth.activeNavigator;
|
|
5630
|
-
const
|
|
5865
|
+
const oidcAccessToken = auth.user?.access_token;
|
|
5631
5866
|
const userProfile = auth.user?.profile;
|
|
5632
5867
|
const userProfileSub = auth.user?.profile?.sub;
|
|
5868
|
+
// Token a ser usado: prioriza mobile, depois OIDC
|
|
5869
|
+
const accessToken = isMobileWebView ? mobileToken : oidcAccessToken;
|
|
5870
|
+
// --- 0. Detectar Mobile WebView e escutar eventos de token ---
|
|
5871
|
+
React2.useEffect(() => {
|
|
5872
|
+
// Verificar se já tem token injetado (Android - injeta antes do load)
|
|
5873
|
+
if (typeof window !== "undefined" && window.keycloakConfig?.fromMobile) {
|
|
5874
|
+
setIsMobileWebView(true);
|
|
5875
|
+
setMobileToken(window.keycloakConfig.token);
|
|
5876
|
+
}
|
|
5877
|
+
// Escutar evento de injeção (iOS - pode injetar após o load)
|
|
5878
|
+
const handleInjection = (event) => {
|
|
5879
|
+
setIsMobileWebView(true);
|
|
5880
|
+
setMobileToken(event.detail.token);
|
|
5881
|
+
};
|
|
5882
|
+
// Escutar evento de refresh do token
|
|
5883
|
+
const handleTokenRefresh = (event) => {
|
|
5884
|
+
setMobileToken(event.detail.token);
|
|
5885
|
+
};
|
|
5886
|
+
if (typeof window !== "undefined") {
|
|
5887
|
+
window.addEventListener("keycloakConfigInjected", handleInjection);
|
|
5888
|
+
window.addEventListener("keycloakTokenRefreshed", handleTokenRefresh);
|
|
5889
|
+
}
|
|
5890
|
+
return () => {
|
|
5891
|
+
if (typeof window !== "undefined") {
|
|
5892
|
+
window.removeEventListener("keycloakConfigInjected", handleInjection);
|
|
5893
|
+
window.removeEventListener("keycloakTokenRefreshed", handleTokenRefresh);
|
|
5894
|
+
}
|
|
5895
|
+
};
|
|
5896
|
+
}, []);
|
|
5633
5897
|
// --- 1. Silent Check Inicial (Check SSO) ---
|
|
5634
5898
|
React2.useEffect(() => {
|
|
5899
|
+
// Não tentar silent login no mobile WebView
|
|
5900
|
+
if (isMobileWebView)
|
|
5901
|
+
return;
|
|
5635
5902
|
if (!isAuthenticated &&
|
|
5636
5903
|
!isLoading &&
|
|
5637
5904
|
!activeNavigator &&
|
|
@@ -5642,7 +5909,7 @@ const SecurityProvider = ({ apiBaseUrl = "https://stg-api.academe.com.br", skipA
|
|
|
5642
5909
|
});
|
|
5643
5910
|
}
|
|
5644
5911
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5645
|
-
}, [isAuthenticated, isLoading, activeNavigator]);
|
|
5912
|
+
}, [isAuthenticated, isLoading, activeNavigator, isMobileWebView]);
|
|
5646
5913
|
// --- 2. Configuração de API e Services ---
|
|
5647
5914
|
// Ref para armazenar o token atual (acessível no middleware)
|
|
5648
5915
|
const currentTokenRef = React2.useRef(undefined);
|
|
@@ -5819,7 +6086,7 @@ const SecurityProvider = ({ apiBaseUrl = "https://stg-api.academe.com.br", skipA
|
|
|
5819
6086
|
user: currentUser,
|
|
5820
6087
|
refreshUserData,
|
|
5821
6088
|
signOut,
|
|
5822
|
-
isAuthenticated: () => isAuthenticated,
|
|
6089
|
+
isAuthenticated: () => isMobileWebView ? !!mobileToken : isAuthenticated,
|
|
5823
6090
|
hasSchool,
|
|
5824
6091
|
goToLogin,
|
|
5825
6092
|
hasRealmRole,
|
|
@@ -5841,6 +6108,8 @@ const SecurityProvider = ({ apiBaseUrl = "https://stg-api.academe.com.br", skipA
|
|
|
5841
6108
|
accessToken,
|
|
5842
6109
|
apiClient,
|
|
5843
6110
|
services,
|
|
6111
|
+
isMobileWebView,
|
|
6112
|
+
mobileToken,
|
|
5844
6113
|
]);
|
|
5845
6114
|
return (jsxRuntime.jsx(SecurityContext.Provider, { value: contextValue, children: children }));
|
|
5846
6115
|
};
|