academe-kit 0.12.0 → 0.13.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.d.ts CHANGED
@@ -18247,6 +18247,30 @@ type GetUsersParams = {
18247
18247
  page?: number;
18248
18248
  limit?: number;
18249
18249
  };
18250
+ /** Série acessível ao aluno (item do seletor de séries da jornada). */
18251
+ type AccessibleSerie = {
18252
+ serieId: string;
18253
+ serieValue: number;
18254
+ serieLabel: string;
18255
+ level: "fundamental" | "medio";
18256
+ };
18257
+ /** Turma do aluno (resumo) — para a listagem de turmas no perfil. */
18258
+ type ClassroomSummary = {
18259
+ institutionClassroomId: string;
18260
+ classroomId: string;
18261
+ classroomName: string;
18262
+ shiftName: string | null;
18263
+ serie: AccessibleSerie | null;
18264
+ institutionId: string;
18265
+ institutionName: string | null;
18266
+ };
18267
+ /** Contexto de matrícula do usuário: turmas + escola atual + séries distintas. */
18268
+ type UserEnrollment = {
18269
+ classrooms: ClassroomSummary[];
18270
+ /** Escola atual resolvida pelo backend (1ª matrícula) — tem turma. */
18271
+ currentInstitutionId: string | null;
18272
+ series: AccessibleSerie[];
18273
+ };
18250
18274
  declare function createUserService(apiClient: AcademeApiClient): {
18251
18275
  /**
18252
18276
  * Get current authenticated user
@@ -18298,6 +18322,13 @@ declare function createUserService(apiClient: AcademeApiClient): {
18298
18322
  500: components["responses"]["ServerError"];
18299
18323
  };
18300
18324
  }> | undefined, `${string}/${string}`>>;
18325
+ /**
18326
+ * Contexto de matrícula do usuário: turmas (para o perfil) + séries
18327
+ * distintas (para o seletor de séries da jornada) + escola atual. Fonte
18328
+ * única, deduplicada e ordenada no backend. Normaliza os campos opcionais do
18329
+ * OpenAPI. Espelha o app-academe (user.service.getMyEnrollment).
18330
+ */
18331
+ getMyEnrollment(): Promise<UserEnrollment>;
18301
18332
  /**
18302
18333
  * List all users with optional filters
18303
18334
  */
@@ -27644,8 +27675,15 @@ declare function createUserProgressService(apiClient: AcademeApiClient): {
27644
27675
  * `userId` é [Admin]: quando informado, retorna a jornada do usuário-alvo
27645
27676
  * (ex.: backoffice visualizando a jornada de um aluno); omitido = jornada
27646
27677
  * do próprio usuário autenticado.
27678
+ *
27679
+ * `institutionId` é a escola ATUAL: a jornada é POR ESCOLA (o usuário pode
27680
+ * estar em várias). Omitido = 1ª matrícula resolvida no backend.
27681
+ *
27682
+ * ⚠️ Ordem dos parâmetros: `institutionId` foi adicionado como 3º parâmetro
27683
+ * (após `userId`) para NÃO quebrar chamadas posicionais existentes — o
27684
+ * backoffice chama `getJourney(undefined, userId)`.
27647
27685
  */
27648
- getJourney(serieId?: string, userId?: string): Promise<JourneyView>;
27686
+ getJourney(serieId?: string, userId?: string, institutionId?: string): Promise<JourneyView>;
27649
27687
  /**
27650
27688
  * Visão step-by-step do progresso do usuário em um desafio. Cada step traz
27651
27689
  * `myStartedAt`, `myCompletedAt` e (em desafios em grupo) os agregados do
@@ -27931,6 +27969,57 @@ declare function createUserProgressService(apiClient: AcademeApiClient): {
27931
27969
  };
27932
27970
  type UserProgressService = ReturnType<typeof createUserProgressService>;
27933
27971
 
27972
+ /**
27973
+ * Vitrine (Home) do aluno — rails/playlists estilo Netflix.
27974
+ * Consome `GET /vitrine/home` do api-academe-v2.
27975
+ *
27976
+ * ⚠️ O endpoint ainda NÃO está no OpenAPI gerado (`academe-api.ts`), então os
27977
+ * tipos abaixo são MANTIDOS À MÃO e a chamada usa cast — mesmo padrão de
27978
+ * `InstitutionService.setUserClassrooms`. Quando o backend expuser o schema,
27979
+ * regenerar os tipos e apertar.
27980
+ */
27981
+ type VitrineCardKind = "course" | "module" | "lesson" | "playlist";
27982
+ type VitrinePlaylistSource = "curated" | "continue_watching" | "trending" | "watchlist" | "recent" | "continue_playlist";
27983
+ type VitrineCardOrientation = "horizontal" | "vertical" | "square" | "fullImage";
27984
+ interface VitrineCard {
27985
+ kind: VitrineCardKind;
27986
+ id: string;
27987
+ courseId?: string | null;
27988
+ title: string;
27989
+ subtitle?: string | null;
27990
+ coverUrl?: string | null;
27991
+ durationSeconds?: number | null;
27992
+ progressPct?: number | null;
27993
+ courseTitle?: string | null;
27994
+ lessonLabel?: string | null;
27995
+ rank?: number | null;
27996
+ }
27997
+ interface VitrinePlaylist {
27998
+ id: string;
27999
+ title: string;
28000
+ subtitle: string | null;
28001
+ source: VitrinePlaylistSource;
28002
+ variant: "common" | "featured";
28003
+ cardOrientation: VitrineCardOrientation;
28004
+ itemsPerViewDesktop: number;
28005
+ itemsPerViewMobile: number;
28006
+ autoplay: boolean;
28007
+ style: Record<string, unknown>;
28008
+ items: VitrineCard[];
28009
+ }
28010
+ interface VitrineHome {
28011
+ institutionId: string | null;
28012
+ playlists: VitrinePlaylist[];
28013
+ }
28014
+ declare function createVitrineService(apiClient: AcademeApiClient): {
28015
+ /**
28016
+ * Home do aluno para a escola atual. `institutionId` omitido = 1ª matrícula
28017
+ * (o backend resolve). Recarregar ao trocar de escola no app.
28018
+ */
28019
+ getHome(institutionId?: string): Promise<VitrineHome>;
28020
+ };
28021
+ type VitrineService = ReturnType<typeof createVitrineService>;
28022
+
27934
28023
  type AcademeApiClient = ReturnType<typeof openapi_fetch__default<paths>>;
27935
28024
  declare function createAcademeApiClient(baseUrl: string): AcademeApiClient;
27936
28025
  interface AcademeServices {
@@ -27956,6 +28045,7 @@ interface AcademeServices {
27956
28045
  step: StepService;
27957
28046
  submission: SubmissionService;
27958
28047
  userProgress: UserProgressService;
28048
+ vitrine: VitrineService;
27959
28049
  }
27960
28050
 
27961
28051
  type AcademeKeycloakContextProps = {
@@ -28052,4 +28142,4 @@ declare enum NINA_ROLES {
28052
28142
  }
28053
28143
 
28054
28144
  export { AcademeAuthProvider, AcademeLoading, BACKOFFICE_ROLES, Button, CosmicDecor, CosmicStarsCanvas, DASHBOARD_ROLES, GLOBAL_ROLES, JourneyCrystalPin, JourneyStep, LogoA, MIKE_ROLES, NINA_ROLES, ProtectedApp, ProtectedComponent, ProtectedRouter, STREAMING_ROLES, Spinner, WIDGET_ROLES, academeApi_d as apiTypes, cn, createAcademeApiClient, index_d as types, useAcademeAuth, useProtectedAppColors };
28055
- export type { AcademeApiClient, AcademeKeycloakContextProps, AcademeLoadingColors, AcademeLoadingProps, AcademeLoadingTheme, AcademeServices, AcademeUser, ButtonProps, ChallengeUserQuizAttempt, ChallengeUserQuizAttemptsResponse, CosmicDecorProps, CosmicDecorVariant, CosmicPlanet, CosmicStarsCanvasProps, FrameKind, JourneyChallengeView, JourneyCrystalPinProps, JourneyStepProps, JourneyStepSize, JourneyStepType, JourneyStepView, JourneyView, KeycloakUser, LogoAProps, RequiredClientRoles, SecurityContextType, SecurityProviderProps };
28145
+ export type { AcademeApiClient, AcademeKeycloakContextProps, AcademeLoadingColors, AcademeLoadingProps, AcademeLoadingTheme, AcademeServices, AcademeUser, AccessibleSerie, ButtonProps, ChallengeUserQuizAttempt, ChallengeUserQuizAttemptsResponse, ClassroomSummary, CosmicDecorProps, CosmicDecorVariant, CosmicPlanet, CosmicStarsCanvasProps, FrameKind, JourneyChallengeView, JourneyCrystalPinProps, JourneyStepProps, JourneyStepSize, JourneyStepType, JourneyStepView, JourneyView, KeycloakUser, LogoAProps, RequiredClientRoles, SecurityContextType, SecurityProviderProps, UserEnrollment, VitrineCard, VitrineCardKind, VitrineCardOrientation, VitrineHome, VitrinePlaylist, VitrinePlaylistSource };
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,23 @@ 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
+
6490
6551
  function createAcademeApiClient(baseUrl) {
6491
6552
  return createClient({ baseUrl });
6492
6553
  }
@@ -6514,6 +6575,7 @@ function createAcademeServices(apiClient) {
6514
6575
  step: createStepService(apiClient),
6515
6576
  submission: createSubmissionService(apiClient),
6516
6577
  userProgress: createUserProgressService(apiClient),
6578
+ vitrine: createVitrineService(apiClient),
6517
6579
  };
6518
6580
  }
6519
6581