academe-kit 0.12.1 → 0.14.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/dist/index.cjs +85 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +213 -122
- package/dist/index.esm.js +85 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/services/ChallengeService.d.ts +0 -2
- package/dist/types/services/QuizService.d.ts +10 -10
- package/dist/types/services/StepService.d.ts +6 -6
- package/dist/types/services/UserProgressService.d.ts +8 -1
- package/dist/types/services/VitrineService.d.ts +51 -0
- package/dist/types/services/WatchlistService.d.ts +29 -0
- package/dist/types/services/index.d.ts +6 -0
- package/dist/types/services/userService.d.ts +31 -0
- package/dist/types/types/academe-api.d.ts +75 -102
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -4515,6 +4515,14 @@ function removeTrailingSlash(url) {
|
|
|
4515
4515
|
return url;
|
|
4516
4516
|
}
|
|
4517
4517
|
|
|
4518
|
+
const normalizeSerie = (s) => s?.serieId
|
|
4519
|
+
? {
|
|
4520
|
+
serieId: s.serieId,
|
|
4521
|
+
serieValue: s.serieValue ?? 0,
|
|
4522
|
+
serieLabel: s.serieLabel ?? `${s.serieValue ?? ""}º ANO`,
|
|
4523
|
+
level: s.level ?? "fundamental",
|
|
4524
|
+
}
|
|
4525
|
+
: null;
|
|
4518
4526
|
function createUserService(apiClient) {
|
|
4519
4527
|
return {
|
|
4520
4528
|
/**
|
|
@@ -4523,6 +4531,31 @@ function createUserService(apiClient) {
|
|
|
4523
4531
|
getMe() {
|
|
4524
4532
|
return apiClient.GET("/users/me");
|
|
4525
4533
|
},
|
|
4534
|
+
/**
|
|
4535
|
+
* Contexto de matrícula do usuário: turmas (para o perfil) + séries
|
|
4536
|
+
* distintas (para o seletor de séries da jornada) + escola atual. Fonte
|
|
4537
|
+
* única, deduplicada e ordenada no backend. Normaliza os campos opcionais do
|
|
4538
|
+
* OpenAPI. Espelha o app-academe (user.service.getMyEnrollment).
|
|
4539
|
+
*/
|
|
4540
|
+
async getMyEnrollment() {
|
|
4541
|
+
const res = await apiClient.GET("/users/me/classrooms");
|
|
4542
|
+
const data = res.data?.data;
|
|
4543
|
+
return {
|
|
4544
|
+
currentInstitutionId: data?.currentInstitutionId ?? null,
|
|
4545
|
+
classrooms: (data?.classrooms ?? []).map((c) => ({
|
|
4546
|
+
institutionClassroomId: c.institutionClassroomId ?? "",
|
|
4547
|
+
classroomId: c.classroomId ?? "",
|
|
4548
|
+
classroomName: c.classroomName ?? "",
|
|
4549
|
+
shiftName: c.shiftName ?? null,
|
|
4550
|
+
serie: normalizeSerie(c.serie ?? {}),
|
|
4551
|
+
institutionId: c.institutionId ?? "",
|
|
4552
|
+
institutionName: c.institutionName ?? null,
|
|
4553
|
+
})),
|
|
4554
|
+
series: (data?.series ?? [])
|
|
4555
|
+
.map((s) => normalizeSerie(s))
|
|
4556
|
+
.filter((s) => s !== null),
|
|
4557
|
+
};
|
|
4558
|
+
},
|
|
4526
4559
|
/**
|
|
4527
4560
|
* List all users with optional filters
|
|
4528
4561
|
*/
|
|
@@ -6404,15 +6437,26 @@ function createUserProgressService(apiClient) {
|
|
|
6404
6437
|
* `userId` é [Admin]: quando informado, retorna a jornada do usuário-alvo
|
|
6405
6438
|
* (ex.: backoffice visualizando a jornada de um aluno); omitido = jornada
|
|
6406
6439
|
* do próprio usuário autenticado.
|
|
6440
|
+
*
|
|
6441
|
+
* `institutionId` é a escola ATUAL: a jornada é POR ESCOLA (o usuário pode
|
|
6442
|
+
* estar em várias). Omitido = 1ª matrícula resolvida no backend.
|
|
6443
|
+
*
|
|
6444
|
+
* ⚠️ Ordem dos parâmetros: `institutionId` foi adicionado como 3º parâmetro
|
|
6445
|
+
* (após `userId`) para NÃO quebrar chamadas posicionais existentes — o
|
|
6446
|
+
* backoffice chama `getJourney(undefined, userId)`.
|
|
6407
6447
|
*/
|
|
6408
|
-
async getJourney(serieId, userId) {
|
|
6448
|
+
async getJourney(serieId, userId, institutionId) {
|
|
6409
6449
|
const query = {};
|
|
6410
6450
|
if (serieId)
|
|
6411
6451
|
query.serieId = serieId;
|
|
6412
6452
|
if (userId)
|
|
6413
6453
|
query.userId = userId;
|
|
6454
|
+
if (institutionId)
|
|
6455
|
+
query.institutionId = institutionId;
|
|
6414
6456
|
const res = await apiClient.GET("/user-challenge-progress/journey", {
|
|
6415
|
-
params: {
|
|
6457
|
+
params: {
|
|
6458
|
+
query: (Object.keys(query).length > 0 ? query : undefined),
|
|
6459
|
+
},
|
|
6416
6460
|
});
|
|
6417
6461
|
return res.data.data;
|
|
6418
6462
|
},
|
|
@@ -6489,6 +6533,43 @@ function createUserProgressService(apiClient) {
|
|
|
6489
6533
|
};
|
|
6490
6534
|
}
|
|
6491
6535
|
|
|
6536
|
+
function createVitrineService(apiClient) {
|
|
6537
|
+
return {
|
|
6538
|
+
/**
|
|
6539
|
+
* Home do aluno para a escola atual. `institutionId` omitido = 1ª matrícula
|
|
6540
|
+
* (o backend resolve). Recarregar ao trocar de escola no app.
|
|
6541
|
+
*/
|
|
6542
|
+
async getHome(institutionId) {
|
|
6543
|
+
const res = await apiClient.GET("/vitrine/home", {
|
|
6544
|
+
params: {
|
|
6545
|
+
query: institutionId ? { institutionId } : undefined,
|
|
6546
|
+
},
|
|
6547
|
+
});
|
|
6548
|
+
return (res.data?.data ?? { institutionId: null, playlists: [] });
|
|
6549
|
+
},
|
|
6550
|
+
};
|
|
6551
|
+
}
|
|
6552
|
+
|
|
6553
|
+
function createWatchlistService(apiClient) {
|
|
6554
|
+
return {
|
|
6555
|
+
/** Itens da "Minha lista" + contagem. */
|
|
6556
|
+
async getMine() {
|
|
6557
|
+
const res = await apiClient.GET("/me/watchlist");
|
|
6558
|
+
return (res.data?.data ?? { items: [], count: 0 });
|
|
6559
|
+
},
|
|
6560
|
+
/** Adiciona um conteúdo (idempotente). */
|
|
6561
|
+
async add(type, id) {
|
|
6562
|
+
await apiClient.PUT("/me/watchlist", { body: { type, id } });
|
|
6563
|
+
},
|
|
6564
|
+
/** Remove um conteúdo pelo alvo. */
|
|
6565
|
+
async remove(type, id) {
|
|
6566
|
+
await apiClient.DELETE("/me/watchlist/{type}/{id}", {
|
|
6567
|
+
params: { path: { type, id } },
|
|
6568
|
+
});
|
|
6569
|
+
},
|
|
6570
|
+
};
|
|
6571
|
+
}
|
|
6572
|
+
|
|
6492
6573
|
function createAcademeApiClient(baseUrl) {
|
|
6493
6574
|
return createClient({ baseUrl });
|
|
6494
6575
|
}
|
|
@@ -6516,6 +6597,8 @@ function createAcademeServices(apiClient) {
|
|
|
6516
6597
|
step: createStepService(apiClient),
|
|
6517
6598
|
submission: createSubmissionService(apiClient),
|
|
6518
6599
|
userProgress: createUserProgressService(apiClient),
|
|
6600
|
+
vitrine: createVitrineService(apiClient),
|
|
6601
|
+
watchlist: createWatchlistService(apiClient),
|
|
6519
6602
|
};
|
|
6520
6603
|
}
|
|
6521
6604
|
|