academe-kit 0.6.0 → 0.6.1

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 CHANGED
@@ -5772,6 +5772,54 @@ function createCourseService(apiClient) {
5772
5772
  };
5773
5773
  }
5774
5774
 
5775
+ function createStorageFileService(apiClient) {
5776
+ return {
5777
+ /**
5778
+ * Upload a new file
5779
+ * Note: This method requires FormData with a 'file' field
5780
+ */
5781
+ upload(file) {
5782
+ const formData = new FormData();
5783
+ formData.append("file", file);
5784
+ // Note: Route not typed in OpenAPI yet, using type assertion
5785
+ return apiClient.POST("/storage-files", {
5786
+ body: formData,
5787
+ bodySerializer: (body) => body,
5788
+ });
5789
+ },
5790
+ /**
5791
+ * List all storage files
5792
+ */
5793
+ getAll() {
5794
+ // Note: Route not typed in OpenAPI yet, using type assertion
5795
+ return apiClient.GET("/storage-files", {});
5796
+ },
5797
+ /**
5798
+ * Get storage file by ID
5799
+ */
5800
+ getById(id) {
5801
+ // Note: Route not typed in OpenAPI yet, using type assertion
5802
+ return apiClient.GET(`/storage-files/${id}`, {});
5803
+ },
5804
+ /**
5805
+ * Update storage file metadata
5806
+ */
5807
+ update(id, data) {
5808
+ // Note: Route not typed in OpenAPI yet, using type assertion
5809
+ return apiClient.PATCH(`/storage-files/${id}`, {
5810
+ body: data,
5811
+ });
5812
+ },
5813
+ /**
5814
+ * Delete storage file
5815
+ */
5816
+ delete(id) {
5817
+ // Note: Route not typed in OpenAPI yet, using type assertion
5818
+ return apiClient.DELETE(`/storage-files/${id}`, {});
5819
+ },
5820
+ };
5821
+ }
5822
+
5775
5823
  function createAcademeApiClient(baseUrl) {
5776
5824
  return createClient({ baseUrl });
5777
5825
  }
@@ -5793,6 +5841,7 @@ function createAcademeServices(apiClient) {
5793
5841
  certificateTemplate: createCertificateTemplateService(apiClient),
5794
5842
  seatCode: createSeatCodeService(apiClient),
5795
5843
  product: createProductService(apiClient),
5844
+ storageFile: createStorageFileService(apiClient),
5796
5845
  };
5797
5846
  }
5798
5847
 
@@ -5853,6 +5902,7 @@ const SecurityProvider = ({ apiBaseUrl = "https://stg-api.academe.com.br", skipA
5853
5902
  const [currentUser, setCurrentUser] = React2.useState(null);
5854
5903
  const hasTriedSignInSilent = React2.useRef(false);
5855
5904
  const [isTokenReady, setIsTokenReady] = React2.useState(false);
5905
+ const [isRefreshing, setIsRefreshing] = React2.useState(false);
5856
5906
  // --- Estado para autenticação mobile ---
5857
5907
  const [isMobileAuth, setIsMobileAuth] = React2.useState(false);
5858
5908
  const [mobileToken, setMobileToken] = React2.useState(undefined);
@@ -6004,6 +6054,7 @@ const SecurityProvider = ({ apiBaseUrl = "https://stg-api.academe.com.br", skipA
6004
6054
  email: profile?.email || "",
6005
6055
  name: profile?.given_name || "",
6006
6056
  lastName: profile?.family_name || "",
6057
+ avatar_url: decodedAccessToken?.avatar_url
6007
6058
  };
6008
6059
  }, [userProfile, isMobileAuth, decodedAccessToken]);
6009
6060
  const hasRealmRole = React2.useCallback((role) => {
@@ -6071,8 +6122,10 @@ const SecurityProvider = ({ apiBaseUrl = "https://stg-api.academe.com.br", skipA
6071
6122
  isMobileAuth,
6072
6123
  ]);
6073
6124
  const refreshUserData = React2.useCallback(async () => {
6125
+ setIsRefreshing(true);
6074
6126
  if (effectiveIsAuthenticated) {
6075
6127
  if (skipApiUserFetch) {
6128
+ await auth.signinSilent();
6076
6129
  const academeUser = {
6077
6130
  keycloakUser: getKeycloakUser(),
6078
6131
  };
@@ -6093,6 +6146,7 @@ const SecurityProvider = ({ apiBaseUrl = "https://stg-api.academe.com.br", skipA
6093
6146
  console.error("[SecurityProvider] Error refreshing user data:", error);
6094
6147
  }
6095
6148
  }
6149
+ setIsRefreshing(false);
6096
6150
  }, [effectiveIsAuthenticated, getKeycloakUser, services, skipApiUserFetch]);
6097
6151
  // --- 5. Ações de Auth ---
6098
6152
  // SignOut para modo OIDC (web normal)
@@ -6148,7 +6202,7 @@ const SecurityProvider = ({ apiBaseUrl = "https://stg-api.academe.com.br", skipA
6148
6202
  }, [isMobileAuth]);
6149
6203
  // Memoizar o value do context para evitar re-renders desnecessários
6150
6204
  const contextValue = React2.useMemo(() => ({
6151
- isInitialized: isMobileAuth ? true : !isLoading,
6205
+ isInitialized: isMobileAuth ? true : (!isLoading || isRefreshing),
6152
6206
  isTokenReady,
6153
6207
  isMobileAuth,
6154
6208
  user: currentUser,