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