@nocios/crudify-ui 1.1.0 → 1.2.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.mjs CHANGED
@@ -1,3 +1,17 @@
1
+ import {
2
+ CrudifyDataProvider,
3
+ configurationManager,
4
+ crudifyInitializer,
5
+ decodeJwtSafely,
6
+ getCookie,
7
+ getCurrentUserEmail,
8
+ isTokenExpired,
9
+ secureLocalStorage,
10
+ secureSessionStorage,
11
+ tokenManager,
12
+ useCrudifyDataContext
13
+ } from "./chunk-ZV5J7FRE.mjs";
14
+
1
15
  // src/index.ts
2
16
  import { default as default2 } from "@nocios/crudify-browser";
3
17
  export * from "@nocios/crudify-browser";
@@ -156,14 +170,6 @@ var useCrudify = () => {
156
170
 
157
171
  // src/components/CrudifyLogin/context/LoginStateProvider.tsx
158
172
  import { createContext as createContext3, useContext as useContext3, useReducer, useEffect as useEffect3 } from "react";
159
-
160
- // src/components/CrudifyLogin/utils/cookies.ts
161
- var getCookie = (name) => {
162
- const match = document.cookie.match(new RegExp("(^|;)\\s*" + name + "=([^;]+)"));
163
- return match ? match[2] : null;
164
- };
165
-
166
- // src/components/CrudifyLogin/context/LoginStateProvider.tsx
167
173
  import { jsx as jsx3 } from "react/jsx-runtime";
168
174
  var initialState = {
169
175
  currentScreen: "login",
@@ -351,8 +357,8 @@ var LoginStateProvider = ({
351
357
  dispatch({ type: "SET_SEARCH_PARAMS", payload: paramsObject });
352
358
  }
353
359
  }, [initialScreen]);
354
- const setScreen = (screen2, params) => {
355
- dispatch({ type: "SET_SCREEN", payload: { screen: screen2, params } });
360
+ const setScreen = (screen, params) => {
361
+ dispatch({ type: "SET_SCREEN", payload: { screen, params } });
356
362
  };
357
363
  const updateFormData = (data) => {
358
364
  dispatch({ type: "UPDATE_FORM_DATA", payload: data });
@@ -386,118 +392,9 @@ var useLoginState = () => {
386
392
  };
387
393
 
388
394
  // src/components/CrudifyLogin/Forms/LoginForm.tsx
389
- import { useEffect as useEffect5, useRef } from "react";
395
+ import { useEffect as useEffect4, useRef } from "react";
390
396
  import { Typography, TextField, Button, Box, CircularProgress, Alert, Link } from "@mui/material";
391
397
 
392
- // src/components/CrudifyLogin/utils/secureStorage.ts
393
- import CryptoJS from "crypto-js";
394
- var SecureStorage = class {
395
- constructor(storageType = "sessionStorage") {
396
- this.encryptionKey = this.generateEncryptionKey();
397
- this.storage = storageType === "localStorage" ? window.localStorage : window.sessionStorage;
398
- }
399
- generateEncryptionKey() {
400
- const browserFingerprint = [
401
- navigator.userAgent,
402
- navigator.language,
403
- (/* @__PURE__ */ new Date()).getTimezoneOffset(),
404
- screen.colorDepth,
405
- screen.width,
406
- screen.height,
407
- "crudify-login"
408
- ].join("|");
409
- return CryptoJS.SHA256(browserFingerprint).toString();
410
- }
411
- setItem(key, value, expiryMinutes) {
412
- try {
413
- const encrypted = CryptoJS.AES.encrypt(value, this.encryptionKey).toString();
414
- this.storage.setItem(key, encrypted);
415
- if (expiryMinutes) {
416
- const expiryTime = (/* @__PURE__ */ new Date()).getTime() + expiryMinutes * 60 * 1e3;
417
- this.storage.setItem(`${key}_expiry`, expiryTime.toString());
418
- }
419
- } catch (error) {
420
- console.error("Failed to encrypt and store data:", error);
421
- }
422
- }
423
- getItem(key) {
424
- try {
425
- const expiryKey = `${key}_expiry`;
426
- const expiry = this.storage.getItem(expiryKey);
427
- if (expiry) {
428
- const expiryTime = parseInt(expiry, 10);
429
- if ((/* @__PURE__ */ new Date()).getTime() > expiryTime) {
430
- this.removeItem(key);
431
- return null;
432
- }
433
- }
434
- const encrypted = this.storage.getItem(key);
435
- if (!encrypted) return null;
436
- const decrypted = CryptoJS.AES.decrypt(encrypted, this.encryptionKey);
437
- const result = decrypted.toString(CryptoJS.enc.Utf8);
438
- if (!result) {
439
- console.warn("Failed to decrypt stored data - may be corrupted");
440
- this.removeItem(key);
441
- return null;
442
- }
443
- return result;
444
- } catch (error) {
445
- console.error("Failed to decrypt data:", error);
446
- this.removeItem(key);
447
- return null;
448
- }
449
- }
450
- removeItem(key) {
451
- this.storage.removeItem(key);
452
- this.storage.removeItem(`${key}_expiry`);
453
- }
454
- setToken(token) {
455
- try {
456
- const parts = token.split(".");
457
- if (parts.length === 3) {
458
- const payload = JSON.parse(atob(parts[1]));
459
- if (payload.exp) {
460
- const expiryTime = payload.exp * 1e3;
461
- const now = (/* @__PURE__ */ new Date()).getTime();
462
- const minutesUntilExpiry = Math.floor((expiryTime - now) / (60 * 1e3));
463
- if (minutesUntilExpiry > 0) {
464
- this.setItem("authToken", token, minutesUntilExpiry);
465
- return;
466
- }
467
- }
468
- }
469
- } catch (error) {
470
- console.warn("Failed to parse token expiry, using default expiry");
471
- }
472
- this.setItem("authToken", token, 24 * 60);
473
- }
474
- getToken() {
475
- const token = this.getItem("authToken");
476
- if (token) {
477
- try {
478
- const parts = token.split(".");
479
- if (parts.length === 3) {
480
- const payload = JSON.parse(atob(parts[1]));
481
- if (payload.exp) {
482
- const now = Math.floor(Date.now() / 1e3);
483
- if (payload.exp < now) {
484
- this.removeItem("authToken");
485
- return null;
486
- }
487
- }
488
- }
489
- } catch (error) {
490
- console.warn("Failed to validate token expiry");
491
- this.removeItem("authToken");
492
- return null;
493
- }
494
- }
495
- return token;
496
- }
497
- };
498
- var secureSessionStorage = new SecureStorage("sessionStorage");
499
- var secureLocalStorage = new SecureStorage("localStorage");
500
-
501
398
  // src/utils/errorHandler.ts
502
399
  var ERROR_CODES = {
503
400
  // Authentication Errors
@@ -768,1044 +665,6 @@ function handleCrudifyError(error) {
768
665
  ];
769
666
  }
770
667
 
771
- // src/providers/CrudifyDataProvider.tsx
772
- import { createContext as createContext4, useContext as useContext4, useEffect as useEffect4, useState as useState3, useCallback } from "react";
773
-
774
- // src/core/ConfigurationManager.ts
775
- var _ConfigurationManager = class _ConfigurationManager {
776
- constructor() {
777
- this.resolvedConfig = null;
778
- this.configError = null;
779
- }
780
- /**
781
- * Singleton pattern to ensure consistent configuration across the app
782
- */
783
- static getInstance() {
784
- if (!_ConfigurationManager.instance) {
785
- _ConfigurationManager.instance = new _ConfigurationManager();
786
- }
787
- return _ConfigurationManager.instance;
788
- }
789
- /**
790
- * Reset the singleton instance (useful for testing)
791
- */
792
- static resetInstance() {
793
- _ConfigurationManager.instance = null;
794
- }
795
- /**
796
- * Resolve configuration from all sources with proper priority
797
- */
798
- resolveConfig(propsConfig = {}) {
799
- if (this.resolvedConfig && this.isConfigStillValid(propsConfig)) {
800
- return this.resolvedConfig;
801
- }
802
- try {
803
- this.configError = null;
804
- const envConfig = this.getEnvConfig();
805
- const cookieConfig = this.getCookieConfig();
806
- const configSource = {
807
- env: "default",
808
- publicApiKey: "default",
809
- loginActions: "default",
810
- appName: "default",
811
- logo: "default",
812
- colors: "default"
813
- };
814
- const env = this.resolveValue("env", propsConfig.env, envConfig.env, cookieConfig.env, "prod", configSource);
815
- const publicApiKey = this.resolveValue("publicApiKey", propsConfig.publicApiKey, envConfig.publicApiKey, cookieConfig.publicApiKey, void 0, configSource);
816
- const loginActions = this.resolveValue("loginActions", propsConfig.loginActions, envConfig.loginActions, cookieConfig.loginActions, [], configSource);
817
- const appName = this.resolveValue("appName", propsConfig.appName, envConfig.appName, cookieConfig.appName, "Crudify App", configSource);
818
- const logo = this.resolveValue("logo", propsConfig.logo, envConfig.logo, cookieConfig.logo, "", configSource);
819
- const colors = this.resolveValue("colors", propsConfig.colors, envConfig.colors, cookieConfig.colors, {}, configSource);
820
- if (!publicApiKey) {
821
- throw new Error(
822
- "publicApiKey is required. Provide it via:\n1. Props: <CrudifyDataProvider publicApiKey={...} />\n2. Environment: VITE_TEST_PUBLIC_API_KEY\n3. Cookie: publicApiKey"
823
- );
824
- }
825
- this.resolvedConfig = {
826
- env,
827
- publicApiKey,
828
- loginActions,
829
- appName,
830
- logo,
831
- colors,
832
- configSource,
833
- rawConfig: {
834
- props: propsConfig,
835
- env: envConfig,
836
- cookies: cookieConfig
837
- }
838
- };
839
- console.log("\u{1F527} ConfigurationManager - Configuration resolved:", {
840
- config: {
841
- env: this.resolvedConfig.env,
842
- publicApiKey: `${this.resolvedConfig.publicApiKey.substring(0, 8)}...`,
843
- appName: this.resolvedConfig.appName,
844
- loginActionsCount: this.resolvedConfig.loginActions.length
845
- },
846
- sources: this.resolvedConfig.configSource
847
- });
848
- return this.resolvedConfig;
849
- } catch (error) {
850
- this.configError = error instanceof Error ? error.message : "Unknown configuration error";
851
- console.error("\u{1F527} ConfigurationManager - Configuration error:", this.configError);
852
- this.resolvedConfig = {
853
- env: "prod",
854
- publicApiKey: "",
855
- loginActions: [],
856
- appName: "Crudify App",
857
- logo: "",
858
- colors: {},
859
- configSource: {
860
- env: "default",
861
- publicApiKey: "default",
862
- loginActions: "default",
863
- appName: "default",
864
- logo: "default",
865
- colors: "default"
866
- },
867
- rawConfig: {
868
- props: propsConfig,
869
- env: {},
870
- cookies: {},
871
- error: this.configError
872
- }
873
- };
874
- return this.resolvedConfig;
875
- }
876
- }
877
- /**
878
- * Check if current configuration is still valid for the given props
879
- */
880
- isConfigStillValid(propsConfig) {
881
- if (!this.resolvedConfig) return false;
882
- const currentProps = this.resolvedConfig.rawConfig.props;
883
- return JSON.stringify(currentProps) === JSON.stringify(propsConfig);
884
- }
885
- /**
886
- * Resolve a single config value with priority and source tracking
887
- */
888
- resolveValue(key, propsValue, envValue, cookieValue, defaultValue, configSource) {
889
- if (propsValue !== void 0) {
890
- configSource[key] = "props";
891
- return propsValue;
892
- }
893
- if (envValue !== void 0) {
894
- configSource[key] = "env";
895
- return envValue;
896
- }
897
- if (cookieValue !== void 0) {
898
- configSource[key] = "cookies";
899
- return cookieValue;
900
- }
901
- configSource[key] = "default";
902
- return defaultValue;
903
- }
904
- /**
905
- * Get configuration from environment variables
906
- */
907
- getEnvConfig() {
908
- const config = {};
909
- try {
910
- } catch (error) {
911
- console.warn("\u{1F527} ConfigurationManager - Environment variables not available:", error);
912
- }
913
- return config;
914
- }
915
- /**
916
- * Get configuration from cookies (multi-tenant support)
917
- */
918
- getCookieConfig() {
919
- const config = {};
920
- try {
921
- const env = getCookie("environment");
922
- if (env && ["dev", "stg", "prod"].includes(env)) {
923
- config.env = env;
924
- }
925
- const publicApiKey = getCookie("publicApiKey");
926
- if (publicApiKey) {
927
- config.publicApiKey = publicApiKey;
928
- }
929
- const appName = getCookie("appName");
930
- if (appName) {
931
- config.appName = appName;
932
- }
933
- const loginActions = getCookie("loginActions");
934
- if (loginActions) {
935
- config.loginActions = loginActions.split(",").map((action) => action.trim()).filter(Boolean);
936
- }
937
- const logo = getCookie("logo");
938
- if (logo) {
939
- config.logo = logo;
940
- }
941
- const colors = getCookie("colors");
942
- if (colors) {
943
- try {
944
- config.colors = JSON.parse(colors);
945
- } catch (error) {
946
- console.warn("\u{1F527} ConfigurationManager - Failed to parse colors from cookie:", error);
947
- }
948
- }
949
- } catch (error) {
950
- console.warn("\u{1F527} ConfigurationManager - Error reading cookies:", error);
951
- }
952
- return config;
953
- }
954
- /**
955
- * Get the current resolved configuration
956
- */
957
- getConfig() {
958
- return this.resolvedConfig;
959
- }
960
- /**
961
- * Get any configuration errors
962
- */
963
- getConfigError() {
964
- return this.configError;
965
- }
966
- /**
967
- * Check if configuration is valid (no errors and has required fields)
968
- */
969
- isConfigured() {
970
- return this.resolvedConfig !== null && this.configError === null && !!this.resolvedConfig.publicApiKey;
971
- }
972
- /**
973
- * Clear the current configuration (useful for testing or reconfiguration)
974
- */
975
- clearConfig() {
976
- this.resolvedConfig = null;
977
- this.configError = null;
978
- }
979
- };
980
- _ConfigurationManager.instance = null;
981
- var ConfigurationManager = _ConfigurationManager;
982
- var configurationManager = ConfigurationManager.getInstance();
983
-
984
- // src/core/CrudifyInitializer.ts
985
- import crudify2 from "@nocios/crudify-browser";
986
- var _CrudifyInitializer = class _CrudifyInitializer {
987
- constructor() {
988
- this.state = {
989
- isInitialized: false,
990
- isInitializing: false,
991
- initializationError: null,
992
- config: null,
993
- initializationPromise: null
994
- };
995
- console.log("\u{1F680} CrudifyInitializer - Instance created");
996
- }
997
- /**
998
- * Singleton pattern to ensure global initialization coordination
999
- */
1000
- static getInstance() {
1001
- if (!_CrudifyInitializer.instance) {
1002
- _CrudifyInitializer.instance = new _CrudifyInitializer();
1003
- }
1004
- return _CrudifyInitializer.instance;
1005
- }
1006
- /**
1007
- * Reset the singleton instance (useful for testing)
1008
- */
1009
- static resetInstance() {
1010
- _CrudifyInitializer.instance = null;
1011
- }
1012
- /**
1013
- * Initialize crudify with the given configuration
1014
- * This method is idempotent and thread-safe
1015
- */
1016
- async initialize(config) {
1017
- if (this.state.isInitialized && this.isConfigurationSame(config)) {
1018
- console.log("\u{1F680} CrudifyInitializer - Already initialized with same config");
1019
- return;
1020
- }
1021
- if (this.state.isInitializing && this.state.initializationPromise) {
1022
- console.log("\u{1F680} CrudifyInitializer - Waiting for ongoing initialization");
1023
- await this.state.initializationPromise;
1024
- return;
1025
- }
1026
- if (this.state.isInitialized && !this.isConfigurationSame(config)) {
1027
- console.log("\u{1F680} CrudifyInitializer - Configuration changed, re-initializing");
1028
- this.reset();
1029
- }
1030
- this.state.isInitializing = true;
1031
- this.state.initializationError = null;
1032
- this.state.initializationPromise = this.performInitialization(config);
1033
- try {
1034
- await this.state.initializationPromise;
1035
- this.state.isInitialized = true;
1036
- this.state.config = { ...config };
1037
- console.log("\u{1F680} CrudifyInitializer - Initialization completed successfully");
1038
- } catch (error) {
1039
- this.state.initializationError = error instanceof Error ? error.message : "Unknown initialization error";
1040
- console.error("\u{1F680} CrudifyInitializer - Initialization failed:", this.state.initializationError);
1041
- throw error;
1042
- } finally {
1043
- this.state.isInitializing = false;
1044
- this.state.initializationPromise = null;
1045
- }
1046
- }
1047
- /**
1048
- * Perform the actual initialization process
1049
- */
1050
- async performInitialization(config) {
1051
- if (!config.publicApiKey) {
1052
- throw new Error("publicApiKey is required for crudify initialization");
1053
- }
1054
- console.log("\u{1F680} CrudifyInitializer - Starting initialization with config:", {
1055
- env: config.env,
1056
- publicApiKey: `${config.publicApiKey.substring(0, 8)}...`,
1057
- appName: config.appName
1058
- });
1059
- try {
1060
- const environment = config.env || "prod";
1061
- console.log("\u{1F680} CrudifyInitializer - Step 1: Configuring environment:", environment);
1062
- await crudify2.config(environment);
1063
- console.log("\u{1F680} CrudifyInitializer - Step 2: Initializing with API key");
1064
- await crudify2.init(config.publicApiKey, "none");
1065
- console.log("\u{1F680} CrudifyInitializer - Step 3: Verifying initialization");
1066
- await this.verifyInitialization();
1067
- console.log("\u{1F680} CrudifyInitializer - All initialization steps completed");
1068
- } catch (error) {
1069
- console.error("\u{1F680} CrudifyInitializer - Initialization failed at step:", error);
1070
- throw new Error(
1071
- `Crudify initialization failed: ${error instanceof Error ? error.message : "Unknown error"}. Please check your configuration (env: ${config.env || "prod"}, publicApiKey: ${config.publicApiKey ? "provided" : "missing"})`
1072
- );
1073
- }
1074
- }
1075
- /**
1076
- * Verify that crudify is properly initialized by checking core methods
1077
- */
1078
- async verifyInitialization() {
1079
- const requiredMethods = ["readItems", "readItem", "createItem", "updateItem", "deleteItem", "login", "transaction"];
1080
- const missingMethods = [];
1081
- for (const method of requiredMethods) {
1082
- if (typeof crudify2[method] !== "function") {
1083
- missingMethods.push(method);
1084
- }
1085
- }
1086
- if (missingMethods.length > 0) {
1087
- throw new Error(
1088
- `Crudify initialization incomplete. Missing methods: ${missingMethods.join(", ")}. This usually indicates a configuration or network issue.`
1089
- );
1090
- }
1091
- console.log("\u{1F680} CrudifyInitializer - Verification successful (test call skipped for performance)");
1092
- }
1093
- /**
1094
- * Check if the given configuration is the same as the current one
1095
- */
1096
- isConfigurationSame(config) {
1097
- if (!this.state.config) return false;
1098
- return this.state.config.env === config.env && this.state.config.publicApiKey === config.publicApiKey;
1099
- }
1100
- /**
1101
- * Reset the initialization state (useful for testing or configuration changes)
1102
- */
1103
- reset() {
1104
- console.log("\u{1F680} CrudifyInitializer - Resetting initialization state");
1105
- this.state = {
1106
- isInitialized: false,
1107
- isInitializing: false,
1108
- initializationError: null,
1109
- config: null,
1110
- initializationPromise: null
1111
- };
1112
- }
1113
- /**
1114
- * Get the current initialization status
1115
- */
1116
- getStatus() {
1117
- return {
1118
- isInitialized: this.state.isInitialized,
1119
- isInitializing: this.state.isInitializing,
1120
- initializationError: this.state.initializationError,
1121
- config: this.state.config
1122
- };
1123
- }
1124
- /**
1125
- * Check if crudify is ready to use
1126
- */
1127
- isReady() {
1128
- return this.state.isInitialized && !this.state.initializationError;
1129
- }
1130
- /**
1131
- * Get the current initialization error, if any
1132
- */
1133
- getError() {
1134
- return this.state.initializationError;
1135
- }
1136
- /**
1137
- * Force re-initialization (useful when configuration changes)
1138
- */
1139
- async reinitialize(config) {
1140
- console.log("\u{1F680} CrudifyInitializer - Forcing re-initialization");
1141
- this.reset();
1142
- await this.initialize(config);
1143
- }
1144
- /**
1145
- * Check if initialization is currently in progress
1146
- */
1147
- isInitializing() {
1148
- return this.state.isInitializing;
1149
- }
1150
- /**
1151
- * Wait for any ongoing initialization to complete
1152
- */
1153
- async waitForInitialization() {
1154
- if (this.state.initializationPromise) {
1155
- await this.state.initializationPromise;
1156
- }
1157
- }
1158
- };
1159
- _CrudifyInitializer.instance = null;
1160
- var CrudifyInitializer = _CrudifyInitializer;
1161
- var crudifyInitializer = CrudifyInitializer.getInstance();
1162
-
1163
- // src/core/TokenManager.ts
1164
- import crudify3 from "@nocios/crudify-browser";
1165
-
1166
- // src/utils/jwtUtils.ts
1167
- var decodeJwtSafely = (token) => {
1168
- try {
1169
- const parts = token.split(".");
1170
- if (parts.length !== 3) {
1171
- console.warn("Invalid JWT format: token must have 3 parts");
1172
- return null;
1173
- }
1174
- const payload = parts[1];
1175
- const paddedPayload = payload + "=".repeat((4 - payload.length % 4) % 4);
1176
- const decodedPayload = JSON.parse(atob(paddedPayload));
1177
- return decodedPayload;
1178
- } catch (error) {
1179
- console.warn("Failed to decode JWT token:", error);
1180
- return null;
1181
- }
1182
- };
1183
- var getCurrentUserEmail = () => {
1184
- try {
1185
- let token = null;
1186
- token = sessionStorage.getItem("authToken");
1187
- console.log("\u{1F50D} getCurrentUserEmail - authToken:", token ? `${token.substring(0, 20)}...` : null);
1188
- if (!token) {
1189
- token = sessionStorage.getItem("token");
1190
- console.log("\u{1F50D} getCurrentUserEmail - token:", token ? `${token.substring(0, 20)}...` : null);
1191
- }
1192
- if (!token) {
1193
- token = localStorage.getItem("authToken") || localStorage.getItem("token");
1194
- console.log("\u{1F50D} getCurrentUserEmail - localStorage:", token ? `${token.substring(0, 20)}...` : null);
1195
- }
1196
- if (!token) {
1197
- console.warn("\u{1F50D} getCurrentUserEmail - No token found in any storage");
1198
- return null;
1199
- }
1200
- const payload = decodeJwtSafely(token);
1201
- if (!payload) {
1202
- console.warn("\u{1F50D} getCurrentUserEmail - Failed to decode token");
1203
- return null;
1204
- }
1205
- const email = payload.email || payload["cognito:username"] || null;
1206
- console.log("\u{1F50D} getCurrentUserEmail - Extracted email:", email);
1207
- return email;
1208
- } catch (error) {
1209
- console.warn("Failed to get current user email:", error);
1210
- return null;
1211
- }
1212
- };
1213
- var isTokenExpired = (token) => {
1214
- try {
1215
- const payload = decodeJwtSafely(token);
1216
- if (!payload || !payload.exp) return true;
1217
- const currentTime = Math.floor(Date.now() / 1e3);
1218
- return payload.exp < currentTime;
1219
- } catch {
1220
- return true;
1221
- }
1222
- };
1223
-
1224
- // src/core/TokenManager.ts
1225
- var _TokenManager = class _TokenManager {
1226
- constructor() {
1227
- this.TOKEN_KEY = "authToken";
1228
- // Compatible with crudia-ui
1229
- this.tokenCache = null;
1230
- this.parsedTokenCache = null;
1231
- this.expirationCheckInterval = null;
1232
- this.storageEventListener = null;
1233
- this.initializeTokenManager();
1234
- }
1235
- /**
1236
- * Singleton pattern to ensure consistent token management
1237
- */
1238
- static getInstance() {
1239
- if (!_TokenManager.instance) {
1240
- _TokenManager.instance = new _TokenManager();
1241
- }
1242
- return _TokenManager.instance;
1243
- }
1244
- /**
1245
- * Reset the singleton instance (useful for testing)
1246
- */
1247
- static resetInstance() {
1248
- if (_TokenManager.instance) {
1249
- _TokenManager.instance.cleanup();
1250
- }
1251
- _TokenManager.instance = null;
1252
- }
1253
- /**
1254
- * Initialize the token manager with storage synchronization
1255
- */
1256
- initializeTokenManager() {
1257
- console.log("\u{1F510} TokenManager - Initializing token management");
1258
- this.migrateFromLocalStorage();
1259
- this.loadTokenFromStorage();
1260
- this.setupExpirationCheck();
1261
- this.setupStorageListener();
1262
- console.log("\u{1F510} TokenManager - Initialization complete");
1263
- }
1264
- /**
1265
- * Migrate tokens from localStorage to sessionStorage for better security
1266
- * This ensures compatibility with older implementations
1267
- */
1268
- migrateFromLocalStorage() {
1269
- try {
1270
- const legacyKeys = ["authToken", "token", "jwt", "jwtToken"];
1271
- for (const key of legacyKeys) {
1272
- const token = localStorage.getItem(key);
1273
- if (token && !secureSessionStorage.getToken()) {
1274
- console.log(`\u{1F510} TokenManager - Migrating token from localStorage key: ${key}`);
1275
- secureSessionStorage.setToken(token);
1276
- localStorage.removeItem(key);
1277
- break;
1278
- }
1279
- }
1280
- } catch (error) {
1281
- console.warn("\u{1F510} TokenManager - Token migration failed:", error);
1282
- }
1283
- }
1284
- /**
1285
- * Load token from storage and synchronize with crudify
1286
- */
1287
- loadTokenFromStorage() {
1288
- console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Entry point - loading token from storage");
1289
- try {
1290
- console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Getting token from secure session storage");
1291
- const storedToken = secureSessionStorage.getToken();
1292
- console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Stored token exists:", !!storedToken);
1293
- if (storedToken && this.isTokenValid(storedToken)) {
1294
- console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Stored token is valid, updating cache");
1295
- this.tokenCache = storedToken;
1296
- this.parsedTokenCache = this.parseToken(storedToken);
1297
- this.syncTokenWithCrudify(storedToken);
1298
- console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Token loaded from storage and synchronized");
1299
- } else if (storedToken) {
1300
- console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Stored token exists but is invalid/expired, clearing");
1301
- this.clearToken();
1302
- } else {
1303
- console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: No stored token found");
1304
- }
1305
- } catch (error) {
1306
- console.warn("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Error loading token from storage:", error);
1307
- this.clearToken();
1308
- }
1309
- }
1310
- /**
1311
- * Set up automatic token expiration checking
1312
- */
1313
- setupExpirationCheck() {
1314
- this.expirationCheckInterval = window.setInterval(() => {
1315
- if (this.tokenCache && !this.isTokenValid(this.tokenCache)) {
1316
- console.log("\u{1F510} TokenManager - Token expired, clearing automatically");
1317
- this.clearToken();
1318
- }
1319
- }, 3e4);
1320
- }
1321
- /**
1322
- * Set up storage event listener for cross-tab synchronization
1323
- */
1324
- setupStorageListener() {
1325
- this.storageEventListener = (event) => {
1326
- if (event.key === this.TOKEN_KEY) {
1327
- console.log("\u{1F510} TokenManager - Token change detected from another tab");
1328
- this.loadTokenFromStorage();
1329
- }
1330
- };
1331
- window.addEventListener("storage", this.storageEventListener);
1332
- }
1333
- /**
1334
- * Set a new JWT token with automatic synchronization
1335
- */
1336
- setToken(token) {
1337
- console.log("\u{1F510} TokenManager - SET_TOKEN: Entry point - setting token:", token ? "provided" : "null");
1338
- try {
1339
- if (!token) {
1340
- console.log("\u{1F510} TokenManager - SET_TOKEN: No token provided, clearing token");
1341
- this.clearToken();
1342
- return;
1343
- }
1344
- console.log("\u{1F510} TokenManager - SET_TOKEN: Validating token before setting");
1345
- if (!this.isTokenValid(token)) {
1346
- console.warn("\u{1F510} TokenManager - SET_TOKEN: Attempted to set invalid or expired token");
1347
- this.clearToken();
1348
- return;
1349
- }
1350
- console.log("\u{1F510} TokenManager - SET_TOKEN: Token is valid, updating cache");
1351
- this.tokenCache = token;
1352
- this.parsedTokenCache = this.parseToken(token);
1353
- console.log("\u{1F510} TokenManager - SET_TOKEN: Storing token in secure storage");
1354
- secureSessionStorage.setToken(token);
1355
- console.log("\u{1F510} TokenManager - SET_TOKEN: Synchronizing with crudify");
1356
- this.syncTokenWithCrudify(token);
1357
- console.log("\u{1F510} TokenManager - SET_TOKEN: Token set and synchronized successfully");
1358
- } catch (error) {
1359
- console.error("\u{1F510} TokenManager - SET_TOKEN: Error setting token:", error);
1360
- this.clearToken();
1361
- }
1362
- }
1363
- /**
1364
- * Get the current JWT token
1365
- */
1366
- getToken() {
1367
- console.log("\u{1F510} TokenManager - GET_TOKEN: Entry point - checking cache");
1368
- if (this.tokenCache) {
1369
- console.log("\u{1F510} TokenManager - GET_TOKEN: Cache exists, validating token");
1370
- if (this.isTokenValid(this.tokenCache)) {
1371
- console.log("\u{1F510} TokenManager - GET_TOKEN: Cache valid, returning cached token");
1372
- return this.tokenCache;
1373
- } else {
1374
- console.log("\u{1F510} TokenManager - GET_TOKEN: Cache invalid, clearing cache");
1375
- this.tokenCache = null;
1376
- }
1377
- } else {
1378
- console.log("\u{1F510} TokenManager - GET_TOKEN: No cache, loading from storage");
1379
- }
1380
- console.log("\u{1F510} TokenManager - GET_TOKEN: Loading from storage");
1381
- this.loadTokenFromStorage();
1382
- console.log("\u{1F510} TokenManager - GET_TOKEN: Returning final token:", !!this.tokenCache);
1383
- return this.tokenCache;
1384
- }
1385
- /**
1386
- * Parse the current JWT token
1387
- */
1388
- parseToken(token) {
1389
- console.log("\u{1F510} TokenManager - PARSE_TOKEN: Entry point - parsing token");
1390
- const targetToken = token !== void 0 ? token : this.tokenCache;
1391
- console.log("\u{1F510} TokenManager - PARSE_TOKEN: Target token exists:", !!targetToken);
1392
- if (!targetToken) {
1393
- console.log("\u{1F510} TokenManager - PARSE_TOKEN: No target token, returning null");
1394
- return null;
1395
- }
1396
- if (this.tokenCache === targetToken && this.parsedTokenCache) {
1397
- console.log("\u{1F510} TokenManager - PARSE_TOKEN: Returning cached parsed token");
1398
- return this.parsedTokenCache;
1399
- }
1400
- console.log("\u{1F510} TokenManager - PARSE_TOKEN: Cache miss, parsing token with decodeJwtSafely");
1401
- const parsed = decodeJwtSafely(targetToken);
1402
- console.log("\u{1F510} TokenManager - PARSE_TOKEN: Token parsed successfully:", !!parsed);
1403
- if (targetToken === this.tokenCache) {
1404
- console.log("\u{1F510} TokenManager - PARSE_TOKEN: Updating parsed token cache");
1405
- this.parsedTokenCache = parsed;
1406
- }
1407
- return parsed;
1408
- }
1409
- /**
1410
- * Check if a token is valid (properly formatted and not expired)
1411
- */
1412
- isTokenValid(token) {
1413
- console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Entry point - checking token validity");
1414
- const targetToken = token !== void 0 ? token : this.tokenCache;
1415
- console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Target token exists:", !!targetToken);
1416
- if (!targetToken) {
1417
- console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: No token, returning false");
1418
- return false;
1419
- }
1420
- try {
1421
- console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Checking if token is expired");
1422
- if (isTokenExpired(targetToken)) {
1423
- console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Token is expired, returning false");
1424
- return false;
1425
- }
1426
- console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Token not expired, checking if can be parsed");
1427
- const parsed = decodeJwtSafely(targetToken);
1428
- const isValid = parsed !== null;
1429
- console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Token parsing result:", isValid);
1430
- return isValid;
1431
- } catch (error) {
1432
- console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Error validating token:", error);
1433
- return false;
1434
- }
1435
- }
1436
- /**
1437
- * Get token expiration time as Date object
1438
- */
1439
- getTokenExpiration() {
1440
- const token = this.getToken();
1441
- if (!token) return null;
1442
- const parsed = this.parseToken(token);
1443
- if (!parsed?.exp) return null;
1444
- return new Date(parsed.exp * 1e3);
1445
- }
1446
- /**
1447
- * Clear the current token from all storages and crudify
1448
- */
1449
- clearToken() {
1450
- console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Entry point - clearing all tokens");
1451
- try {
1452
- console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Clearing cache");
1453
- this.tokenCache = null;
1454
- this.parsedTokenCache = null;
1455
- console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Clearing from secure storage");
1456
- secureSessionStorage.removeItem(this.TOKEN_KEY);
1457
- console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Clearing from crudify");
1458
- crudify3.setToken("");
1459
- console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Token cleared from all storages successfully");
1460
- } catch (error) {
1461
- console.warn("\u{1F510} TokenManager - CLEAR_TOKEN: Error clearing token:", error);
1462
- }
1463
- }
1464
- /**
1465
- * Synchronize token with crudify library
1466
- */
1467
- syncTokenWithCrudify(token) {
1468
- try {
1469
- crudify3.setToken(token);
1470
- console.log("\u{1F510} TokenManager - Token synchronized with crudify");
1471
- } catch (error) {
1472
- console.warn("\u{1F510} TokenManager - Failed to sync token with crudify:", error);
1473
- }
1474
- }
1475
- /**
1476
- * Refresh token (placeholder for future implementation)
1477
- */
1478
- async refreshToken() {
1479
- throw new Error("Token refresh not yet implemented");
1480
- }
1481
- /**
1482
- * Get user information from the current token
1483
- */
1484
- getUserInfo() {
1485
- const parsed = this.parseToken();
1486
- if (!parsed) {
1487
- return {
1488
- email: null,
1489
- userId: null,
1490
- userIdentifier: null,
1491
- username: null
1492
- };
1493
- }
1494
- return {
1495
- email: parsed.email || null,
1496
- userId: parsed.sub || null,
1497
- userIdentifier: parsed["cognito:username"] || parsed.email || parsed.sub || null,
1498
- username: parsed["cognito:username"] || null
1499
- };
1500
- }
1501
- /**
1502
- * Check if user is currently authenticated
1503
- */
1504
- isAuthenticated() {
1505
- return this.isTokenValid();
1506
- }
1507
- /**
1508
- * Get time until token expires in minutes
1509
- */
1510
- getTimeUntilExpiration() {
1511
- const expiration = this.getTokenExpiration();
1512
- if (!expiration) return null;
1513
- const now = /* @__PURE__ */ new Date();
1514
- const minutesUntilExpiry = Math.floor((expiration.getTime() - now.getTime()) / (60 * 1e3));
1515
- return Math.max(0, minutesUntilExpiry);
1516
- }
1517
- /**
1518
- * Cleanup resources (call when the component unmounts)
1519
- */
1520
- cleanup() {
1521
- if (this.expirationCheckInterval) {
1522
- window.clearInterval(this.expirationCheckInterval);
1523
- this.expirationCheckInterval = null;
1524
- }
1525
- if (this.storageEventListener) {
1526
- window.removeEventListener("storage", this.storageEventListener);
1527
- this.storageEventListener = null;
1528
- }
1529
- console.log("\u{1F510} TokenManager - Cleanup completed");
1530
- }
1531
- /**
1532
- * Get debug information about the current token state
1533
- */
1534
- getDebugInfo() {
1535
- const token = this.getToken();
1536
- const parsed = this.parseToken();
1537
- const expiration = this.getTokenExpiration();
1538
- return {
1539
- hasToken: !!token,
1540
- tokenLength: token?.length || 0,
1541
- isValid: this.isTokenValid(),
1542
- isAuthenticated: this.isAuthenticated(),
1543
- expiration: expiration?.toISOString() || null,
1544
- minutesUntilExpiry: this.getTimeUntilExpiration(),
1545
- userInfo: this.getUserInfo(),
1546
- parsedTokenKeys: parsed ? Object.keys(parsed) : []
1547
- };
1548
- }
1549
- };
1550
- _TokenManager.instance = null;
1551
- var TokenManager = _TokenManager;
1552
- var tokenManager = TokenManager.getInstance();
1553
-
1554
- // src/providers/CrudifyDataProvider.tsx
1555
- import { jsx as jsx4 } from "react/jsx-runtime";
1556
- var CrudifyDataContext = createContext4(null);
1557
- var CrudifyDataProvider = ({
1558
- children,
1559
- env,
1560
- publicApiKey,
1561
- loginActions,
1562
- appName,
1563
- logo,
1564
- colors
1565
- }) => {
1566
- const [config, setConfig] = useState3(null);
1567
- const [isConfigured, setIsConfigured] = useState3(false);
1568
- const [configError, setConfigError] = useState3(null);
1569
- const [isInitialized, setIsInitialized] = useState3(false);
1570
- const [isInitializing, setIsInitializing] = useState3(false);
1571
- const [initializationError, setInitializationError] = useState3(null);
1572
- const [isAuthenticated, setIsAuthenticated] = useState3(false);
1573
- const [token, setTokenState] = useState3(null);
1574
- const [user, setUser] = useState3(null);
1575
- const [tokenExpiration, setTokenExpiration] = useState3(null);
1576
- const initializeConfiguration = useCallback(() => {
1577
- try {
1578
- console.log("\u{1F30D} CrudifyDataProvider - Initializing configuration");
1579
- const propsConfig = {
1580
- env,
1581
- publicApiKey,
1582
- loginActions,
1583
- appName,
1584
- logo,
1585
- colors
1586
- };
1587
- const resolvedConfig = configurationManager.resolveConfig(propsConfig);
1588
- const error = configurationManager.getConfigError();
1589
- setConfig(resolvedConfig);
1590
- setConfigError(error);
1591
- setIsConfigured(configurationManager.isConfigured());
1592
- console.log("\u{1F30D} CrudifyDataProvider - Configuration initialized:", {
1593
- isConfigured: configurationManager.isConfigured(),
1594
- error,
1595
- sources: resolvedConfig.configSource
1596
- });
1597
- return resolvedConfig;
1598
- } catch (error) {
1599
- const errorMessage = error instanceof Error ? error.message : "Configuration initialization failed";
1600
- console.error("\u{1F30D} CrudifyDataProvider - Configuration error:", errorMessage);
1601
- setConfigError(errorMessage);
1602
- setIsConfigured(false);
1603
- return null;
1604
- }
1605
- }, [env, publicApiKey, loginActions, appName, logo, colors]);
1606
- const initializeCrudify = useCallback(async (resolvedConfig) => {
1607
- if (!resolvedConfig || !resolvedConfig.publicApiKey) {
1608
- setInitializationError("Cannot initialize crudify without valid configuration");
1609
- return;
1610
- }
1611
- try {
1612
- setIsInitializing(true);
1613
- setInitializationError(null);
1614
- console.log("\u{1F680} CrudifyDataProvider - Starting crudify initialization");
1615
- await crudifyInitializer.initialize({
1616
- env: resolvedConfig.env,
1617
- publicApiKey: resolvedConfig.publicApiKey,
1618
- loginActions: resolvedConfig.loginActions,
1619
- appName: resolvedConfig.appName,
1620
- logo: resolvedConfig.logo,
1621
- colors: resolvedConfig.colors
1622
- });
1623
- setIsInitialized(true);
1624
- console.log("\u{1F680} CrudifyDataProvider - Crudify initialization completed");
1625
- } catch (error) {
1626
- const errorMessage = error instanceof Error ? error.message : "Crudify initialization failed";
1627
- console.error("\u{1F680} CrudifyDataProvider - Initialization error:", errorMessage);
1628
- setInitializationError(errorMessage);
1629
- setIsInitialized(false);
1630
- } finally {
1631
- setIsInitializing(false);
1632
- }
1633
- }, []);
1634
- const updateAuthenticationState = useCallback(() => {
1635
- console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Starting authentication state update");
1636
- try {
1637
- console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Getting token from TokenManager");
1638
- const currentToken = tokenManager.getToken();
1639
- console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Token retrieved:", !!currentToken);
1640
- console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Parsing token");
1641
- const parsedUser = tokenManager.parseToken();
1642
- console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Token parsed:", !!parsedUser);
1643
- console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Getting expiration");
1644
- const expiration = tokenManager.getTokenExpiration();
1645
- console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Expiration retrieved:", !!expiration);
1646
- console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Checking authentication");
1647
- const authenticated = tokenManager.isAuthenticated();
1648
- console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Authentication checked:", authenticated);
1649
- console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Updating state variables");
1650
- setTokenState(currentToken);
1651
- setUser(parsedUser);
1652
- setTokenExpiration(expiration);
1653
- setIsAuthenticated(authenticated);
1654
- console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Authentication state updated successfully:", {
1655
- hasToken: !!currentToken,
1656
- isAuthenticated: authenticated,
1657
- userEmail: parsedUser?.email || null,
1658
- expiration: expiration?.toISOString() || null
1659
- });
1660
- } catch (error) {
1661
- console.error("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Error updating authentication state:", error);
1662
- }
1663
- }, []);
1664
- const setToken = useCallback((newToken) => {
1665
- console.log("\u{1F510} CrudifyDataProvider - SET_TOKEN_CALLBACK: ===== STARTING TOKEN SET =====");
1666
- console.log("\u{1F510} CrudifyDataProvider - SET_TOKEN_CALLBACK: New token:", newToken ? `${newToken.substring(0, 20)}...` : "null");
1667
- console.log("\u{1F510} CrudifyDataProvider - SET_TOKEN_CALLBACK: Setting token in TokenManager...");
1668
- tokenManager.setToken(newToken);
1669
- console.log("\u{1F510} CrudifyDataProvider - SET_TOKEN_CALLBACK: Updating state using newToken directly");
1670
- if (newToken) {
1671
- const parsedUser = tokenManager.parseToken(newToken);
1672
- const expiration = tokenManager.getTokenExpiration();
1673
- const authenticated = tokenManager.isTokenValid(newToken);
1674
- console.log("\u{1F510} CrudifyDataProvider - SET_TOKEN_CALLBACK: Setting state values:");
1675
- console.log(" - setTokenState:", newToken ? `${newToken.substring(0, 20)}...` : "null");
1676
- console.log(" - setUser:", parsedUser?.email || "null");
1677
- console.log(" - setIsAuthenticated:", authenticated);
1678
- setTokenState(newToken);
1679
- setUser(parsedUser);
1680
- setTokenExpiration(expiration);
1681
- setIsAuthenticated(authenticated);
1682
- console.log("\u{1F510} CrudifyDataProvider - SET_TOKEN_CALLBACK: \u2705 Token set, state updated", {
1683
- hasToken: true,
1684
- isAuthenticated: authenticated,
1685
- userEmail: parsedUser?.email || null
1686
- });
1687
- } else {
1688
- console.log("\u{1F510} CrudifyDataProvider - SET_TOKEN_CALLBACK: Clearing all states");
1689
- setTokenState(null);
1690
- setUser(null);
1691
- setTokenExpiration(null);
1692
- setIsAuthenticated(false);
1693
- console.log("\u{1F510} CrudifyDataProvider - SET_TOKEN_CALLBACK: \u2705 Token cleared, state reset");
1694
- }
1695
- console.log("\u{1F510} CrudifyDataProvider - SET_TOKEN_CALLBACK: ===== TOKEN SET COMPLETE =====");
1696
- }, []);
1697
- const logout = useCallback(() => {
1698
- console.log("\u{1F510} CrudifyDataProvider - LOGOUT_CALLBACK: Logging out user");
1699
- tokenManager.clearToken();
1700
- console.log("\u{1F510} CrudifyDataProvider - LOGOUT_CALLBACK: Updating state directly");
1701
- setTokenState(null);
1702
- setUser(null);
1703
- setTokenExpiration(null);
1704
- setIsAuthenticated(false);
1705
- console.log("\u{1F510} CrudifyDataProvider - LOGOUT_CALLBACK: User logged out, state cleared");
1706
- }, []);
1707
- const refreshConfig = useCallback(() => {
1708
- console.log("\u{1F30D} CrudifyDataProvider - Refreshing configuration");
1709
- configurationManager.clearConfig();
1710
- const newConfig = initializeConfiguration();
1711
- if (newConfig && newConfig.publicApiKey) {
1712
- initializeCrudify(newConfig);
1713
- }
1714
- }, [initializeConfiguration, initializeCrudify]);
1715
- const reinitialize = useCallback(async () => {
1716
- if (!config || !config.publicApiKey) {
1717
- console.warn("\u{1F680} CrudifyDataProvider - Cannot reinitialize without valid configuration");
1718
- return;
1719
- }
1720
- console.log("\u{1F680} CrudifyDataProvider - Force reinitializing crudify");
1721
- crudifyInitializer.reset();
1722
- await initializeCrudify(config);
1723
- }, [config, initializeCrudify]);
1724
- const getDebugInfo = useCallback(() => {
1725
- return {
1726
- provider: {
1727
- isConfigured,
1728
- configError,
1729
- isInitialized,
1730
- isInitializing,
1731
- initializationError,
1732
- isAuthenticated
1733
- },
1734
- configuration: {
1735
- config: config ? {
1736
- env: config.env,
1737
- publicApiKey: `${config.publicApiKey.substring(0, 8)}...`,
1738
- appName: config.appName,
1739
- loginActionsCount: config.loginActions.length,
1740
- hasLogo: !!config.logo,
1741
- colorsCount: Object.keys(config.colors).length
1742
- } : null,
1743
- sources: config?.configSource || null,
1744
- rawConfig: config?.rawConfig || null
1745
- },
1746
- authentication: {
1747
- hasToken: !!token,
1748
- tokenLength: token?.length || 0,
1749
- userEmail: user?.email || null,
1750
- userId: user?.sub || null,
1751
- expiration: tokenExpiration?.toISOString() || null,
1752
- minutesUntilExpiry: tokenManager.getTimeUntilExpiration()
1753
- },
1754
- tokenManager: tokenManager.getDebugInfo(),
1755
- crudifyInitializer: crudifyInitializer.getStatus()
1756
- };
1757
- }, [isConfigured, configError, isInitialized, isInitializing, initializationError, isAuthenticated, config, token, user, tokenExpiration]);
1758
- useEffect4(() => {
1759
- console.log("\u{1F30D} CrudifyDataProvider - Provider mounting, starting initialization");
1760
- const resolvedConfig = initializeConfiguration();
1761
- updateAuthenticationState();
1762
- if (resolvedConfig && resolvedConfig.publicApiKey) {
1763
- initializeCrudify(resolvedConfig);
1764
- }
1765
- return () => {
1766
- console.log("\u{1F30D} CrudifyDataProvider - Provider unmounting, cleaning up");
1767
- tokenManager.cleanup();
1768
- };
1769
- }, []);
1770
- useEffect4(() => {
1771
- console.log("\u{1F510} CrudifyDataProvider - INITIAL_AUTH_EFFECT: Loading initial authentication state");
1772
- updateAuthenticationState();
1773
- }, []);
1774
- const contextValue = {
1775
- // Configuration
1776
- config,
1777
- isConfigured,
1778
- configError,
1779
- configSource: config ? JSON.stringify(config.configSource) : "none",
1780
- // Initialization
1781
- isInitialized,
1782
- isInitializing,
1783
- initializationError,
1784
- // Authentication
1785
- isAuthenticated,
1786
- token,
1787
- user,
1788
- tokenExpiration,
1789
- // Actions
1790
- setToken,
1791
- logout,
1792
- refreshConfig,
1793
- reinitialize,
1794
- // Debug
1795
- getDebugInfo
1796
- };
1797
- return /* @__PURE__ */ jsx4(CrudifyDataContext.Provider, { value: contextValue, children });
1798
- };
1799
- var useCrudifyDataContext = () => {
1800
- const context = useContext4(CrudifyDataContext);
1801
- if (!context) {
1802
- throw new Error(
1803
- "useCrudifyDataContext must be used within a CrudifyDataProvider. Make sure to wrap your app with <CrudifyDataProvider>."
1804
- );
1805
- }
1806
- return context;
1807
- };
1808
-
1809
668
  // src/hooks/useCrudifyAuth.ts
1810
669
  var useCrudifyAuth = () => {
1811
670
  const {
@@ -1836,9 +695,9 @@ var useCrudifyAuth = () => {
1836
695
  };
1837
696
 
1838
697
  // src/components/CrudifyLogin/Forms/LoginForm.tsx
1839
- import { Fragment, jsx as jsx5, jsxs } from "react/jsx-runtime";
698
+ import { Fragment, jsx as jsx4, jsxs } from "react/jsx-runtime";
1840
699
  var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError, redirectUrl = "/" }) => {
1841
- const { crudify: crudify8 } = useCrudify();
700
+ const { crudify: crudify6 } = useCrudify();
1842
701
  const { state, updateFormData, setFieldError, clearErrors, setLoading } = useLoginState();
1843
702
  const { setToken } = useCrudifyAuth();
1844
703
  const { t } = useTranslation();
@@ -1855,7 +714,7 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
1855
714
  }
1856
715
  return redirectUrl || "/";
1857
716
  };
1858
- useEffect5(() => {
717
+ useEffect4(() => {
1859
718
  const timer = setTimeout(() => {
1860
719
  if (usernameInputRef.current) usernameInputRef.current.focus();
1861
720
  }, 100);
@@ -1890,10 +749,10 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
1890
749
  clearErrors();
1891
750
  setLoading(true);
1892
751
  try {
1893
- if (!crudify8) {
752
+ if (!crudify6) {
1894
753
  throw new Error("Crudify not initialized");
1895
754
  }
1896
- const response = await crudify8.login(state.formData.username, state.formData.password);
755
+ const response = await crudify6.login(state.formData.username, state.formData.password);
1897
756
  setLoading(false);
1898
757
  if (response.success) {
1899
758
  console.log("\u{1F510} LoginForm - Login successful, setting tokens");
@@ -1954,7 +813,7 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
1954
813
  sx: { width: "100%", display: "flex", flexDirection: "column", gap: 2 },
1955
814
  children: [
1956
815
  /* @__PURE__ */ jsxs(Box, { sx: { mb: 1 }, children: [
1957
- /* @__PURE__ */ jsx5(
816
+ /* @__PURE__ */ jsx4(
1958
817
  Typography,
1959
818
  {
1960
819
  variant: "body2",
@@ -1964,7 +823,7 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
1964
823
  children: t("login.usernameOrEmailLabel")
1965
824
  }
1966
825
  ),
1967
- /* @__PURE__ */ jsx5(
826
+ /* @__PURE__ */ jsx4(
1968
827
  TextField,
1969
828
  {
1970
829
  fullWidth: true,
@@ -1984,7 +843,7 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
1984
843
  )
1985
844
  ] }),
1986
845
  /* @__PURE__ */ jsxs(Box, { sx: { mb: 1 }, children: [
1987
- /* @__PURE__ */ jsx5(
846
+ /* @__PURE__ */ jsx4(
1988
847
  Typography,
1989
848
  {
1990
849
  variant: "body2",
@@ -1994,7 +853,7 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
1994
853
  children: t("login.passwordLabel")
1995
854
  }
1996
855
  ),
1997
- /* @__PURE__ */ jsx5(
856
+ /* @__PURE__ */ jsx4(
1998
857
  TextField,
1999
858
  {
2000
859
  fullWidth: true,
@@ -2012,7 +871,7 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
2012
871
  }
2013
872
  )
2014
873
  ] }),
2015
- state.config.loginActions?.includes("forgotPassword") && /* @__PURE__ */ jsx5(Box, { sx: { display: "flex", justifyContent: "flex-end", alignItems: "center" }, children: /* @__PURE__ */ jsx5(
874
+ state.config.loginActions?.includes("forgotPassword") && /* @__PURE__ */ jsx4(Box, { sx: { display: "flex", justifyContent: "flex-end", alignItems: "center" }, children: /* @__PURE__ */ jsx4(
2016
875
  Link,
2017
876
  {
2018
877
  sx: { cursor: "pointer" },
@@ -2024,15 +883,15 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
2024
883
  children: t("login.forgotPasswordLink")
2025
884
  }
2026
885
  ) }),
2027
- /* @__PURE__ */ jsx5(Button, { disabled: state.loading, type: "submit", fullWidth: true, variant: "contained", color: "primary", sx: { mt: 1, mb: 2 }, children: state.loading ? /* @__PURE__ */ jsx5(CircularProgress, { size: 20 }) : t("login.loginButton") })
886
+ /* @__PURE__ */ jsx4(Button, { disabled: state.loading, type: "submit", fullWidth: true, variant: "contained", color: "primary", sx: { mt: 1, mb: 2 }, children: state.loading ? /* @__PURE__ */ jsx4(CircularProgress, { size: 20 }) : t("login.loginButton") })
2028
887
  ]
2029
888
  }
2030
889
  ),
2031
- /* @__PURE__ */ jsx5(Box, { children: state.errors.global && state.errors.global.length > 0 && state.errors.global.map((error, index) => /* @__PURE__ */ jsx5(Alert, { variant: "filled", sx: { mt: 2 }, severity: "error", children: /* @__PURE__ */ jsx5("div", { children: error }) }, index)) }),
890
+ /* @__PURE__ */ jsx4(Box, { children: state.errors.global && state.errors.global.length > 0 && state.errors.global.map((error, index) => /* @__PURE__ */ jsx4(Alert, { variant: "filled", sx: { mt: 2 }, severity: "error", children: /* @__PURE__ */ jsx4("div", { children: error }) }, index)) }),
2032
891
  state.config.loginActions?.includes("createUser") && /* @__PURE__ */ jsxs(Typography, { variant: "body2", align: "center", sx: { color: "text.secondary", mt: 3 }, children: [
2033
892
  t("login.noAccountPrompt"),
2034
893
  " ",
2035
- /* @__PURE__ */ jsx5(
894
+ /* @__PURE__ */ jsx4(
2036
895
  Link,
2037
896
  {
2038
897
  sx: { cursor: "pointer" },
@@ -2052,17 +911,17 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
2052
911
  var LoginForm_default = LoginForm;
2053
912
 
2054
913
  // src/components/CrudifyLogin/Forms/ForgotPasswordForm.tsx
2055
- import { useState as useState4 } from "react";
914
+ import { useState as useState3 } from "react";
2056
915
  import { Typography as Typography2, TextField as TextField2, Button as Button2, Box as Box2, CircularProgress as CircularProgress2, Alert as Alert2, Link as Link2 } from "@mui/material";
2057
- import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
916
+ import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
2058
917
  var ForgotPasswordForm = ({ onScreenChange, onError }) => {
2059
- const { crudify: crudify8 } = useCrudify();
2060
- const [email, setEmail] = useState4("");
2061
- const [loading, setLoading] = useState4(false);
2062
- const [errors, setErrors] = useState4([]);
2063
- const [helperTextEmail, setHelperTextEmail] = useState4(null);
2064
- const [emailSent, setEmailSent] = useState4(false);
2065
- const [codeAlreadyExists, setCodeAlreadyExists] = useState4(false);
918
+ const { crudify: crudify6 } = useCrudify();
919
+ const [email, setEmail] = useState3("");
920
+ const [loading, setLoading] = useState3(false);
921
+ const [errors, setErrors] = useState3([]);
922
+ const [helperTextEmail, setHelperTextEmail] = useState3(null);
923
+ const [emailSent, setEmailSent] = useState3(false);
924
+ const [codeAlreadyExists, setCodeAlreadyExists] = useState3(false);
2066
925
  const { t } = useTranslation();
2067
926
  const translateError = (parsedError) => {
2068
927
  const possibleKeys = [
@@ -2085,7 +944,7 @@ var ForgotPasswordForm = ({ onScreenChange, onError }) => {
2085
944
  return emailRegex.test(email2);
2086
945
  };
2087
946
  const handleSubmit = async () => {
2088
- if (loading || !crudify8) return;
947
+ if (loading || !crudify6) return;
2089
948
  setErrors([]);
2090
949
  setHelperTextEmail(null);
2091
950
  if (!email) {
@@ -2099,7 +958,7 @@ var ForgotPasswordForm = ({ onScreenChange, onError }) => {
2099
958
  setLoading(true);
2100
959
  try {
2101
960
  const data = [{ operation: "requestPasswordReset", data: { email } }];
2102
- const response = await crudify8.transaction(data);
961
+ const response = await crudify6.transaction(data);
2103
962
  if (response.success) {
2104
963
  if (response.data && response.data.existingCodeValid) {
2105
964
  setCodeAlreadyExists(true);
@@ -2141,23 +1000,23 @@ var ForgotPasswordForm = ({ onScreenChange, onError }) => {
2141
1000
  onScreenChange?.("checkCode", { email });
2142
1001
  };
2143
1002
  if (emailSent || codeAlreadyExists) {
2144
- return /* @__PURE__ */ jsx6(Fragment2, { children: /* @__PURE__ */ jsxs2(Box2, { sx: { width: "100%", display: "flex", flexDirection: "column", gap: 2, textAlign: "center" }, children: [
1003
+ return /* @__PURE__ */ jsx5(Fragment2, { children: /* @__PURE__ */ jsxs2(Box2, { sx: { width: "100%", display: "flex", flexDirection: "column", gap: 2, textAlign: "center" }, children: [
2145
1004
  /* @__PURE__ */ jsxs2(Box2, { sx: { mb: 2 }, children: [
2146
- /* @__PURE__ */ jsx6(Typography2, { variant: "h5", component: "h1", sx: { mb: 1, fontWeight: 600 }, children: codeAlreadyExists ? t("forgotPassword.codeAlreadyExistsMessage") : t("forgotPassword.emailSentMessage") }),
2147
- /* @__PURE__ */ jsx6(Typography2, { variant: "body2", sx: { color: codeAlreadyExists ? "success.main" : "grey.600" }, children: codeAlreadyExists ? t("forgotPassword.checkEmailInstructions") : t("forgotPassword.checkEmailInstructions") })
1005
+ /* @__PURE__ */ jsx5(Typography2, { variant: "h5", component: "h1", sx: { mb: 1, fontWeight: 600 }, children: codeAlreadyExists ? t("forgotPassword.codeAlreadyExistsMessage") : t("forgotPassword.emailSentMessage") }),
1006
+ /* @__PURE__ */ jsx5(Typography2, { variant: "body2", sx: { color: codeAlreadyExists ? "success.main" : "grey.600" }, children: codeAlreadyExists ? t("forgotPassword.checkEmailInstructions") : t("forgotPassword.checkEmailInstructions") })
2148
1007
  ] }),
2149
- /* @__PURE__ */ jsx6(Button2, { type: "button", onClick: handleGoToCheckCode, fullWidth: true, variant: "contained", color: "primary", sx: { mt: 2, mb: 2 }, children: t("forgotPassword.enterCodeLink") }),
2150
- /* @__PURE__ */ jsx6(Box2, { sx: { display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ jsx6(Link2, { sx: { cursor: "pointer" }, onClick: handleBack, variant: "body2", color: "secondary", children: t("common.back") }) })
1008
+ /* @__PURE__ */ jsx5(Button2, { type: "button", onClick: handleGoToCheckCode, fullWidth: true, variant: "contained", color: "primary", sx: { mt: 2, mb: 2 }, children: t("forgotPassword.enterCodeLink") }),
1009
+ /* @__PURE__ */ jsx5(Box2, { sx: { display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ jsx5(Link2, { sx: { cursor: "pointer" }, onClick: handleBack, variant: "body2", color: "secondary", children: t("common.back") }) })
2151
1010
  ] }) });
2152
1011
  }
2153
1012
  return /* @__PURE__ */ jsxs2(Fragment2, { children: [
2154
1013
  /* @__PURE__ */ jsxs2(Box2, { component: "form", noValidate: true, sx: { width: "100%", display: "flex", flexDirection: "column", gap: 2 }, children: [
2155
1014
  /* @__PURE__ */ jsxs2(Box2, { sx: { mb: 2 }, children: [
2156
- /* @__PURE__ */ jsx6(Typography2, { variant: "h5", component: "h1", sx: { mb: 1, fontWeight: 600 }, children: t("forgotPassword.title") }),
2157
- /* @__PURE__ */ jsx6(Typography2, { variant: "body2", sx: { color: "grey.600" }, children: t("forgotPassword.instructions") })
1015
+ /* @__PURE__ */ jsx5(Typography2, { variant: "h5", component: "h1", sx: { mb: 1, fontWeight: 600 }, children: t("forgotPassword.title") }),
1016
+ /* @__PURE__ */ jsx5(Typography2, { variant: "body2", sx: { color: "grey.600" }, children: t("forgotPassword.instructions") })
2158
1017
  ] }),
2159
1018
  /* @__PURE__ */ jsxs2(Box2, { sx: { mb: 1 }, children: [
2160
- /* @__PURE__ */ jsx6(
1019
+ /* @__PURE__ */ jsx5(
2161
1020
  Typography2,
2162
1021
  {
2163
1022
  variant: "body2",
@@ -2167,7 +1026,7 @@ var ForgotPasswordForm = ({ onScreenChange, onError }) => {
2167
1026
  children: t("forgotPassword.emailLabel")
2168
1027
  }
2169
1028
  ),
2170
- /* @__PURE__ */ jsx6(
1029
+ /* @__PURE__ */ jsx5(
2171
1030
  TextField2,
2172
1031
  {
2173
1032
  fullWidth: true,
@@ -2185,37 +1044,37 @@ var ForgotPasswordForm = ({ onScreenChange, onError }) => {
2185
1044
  }
2186
1045
  )
2187
1046
  ] }),
2188
- /* @__PURE__ */ jsx6(Button2, { disabled: loading, type: "button", onClick: handleSubmit, fullWidth: true, variant: "contained", color: "primary", sx: { mt: 2, mb: 2 }, children: loading ? /* @__PURE__ */ jsx6(CircularProgress2, { size: 20 }) : t("forgotPassword.sendCodeButton") }),
1047
+ /* @__PURE__ */ jsx5(Button2, { disabled: loading, type: "button", onClick: handleSubmit, fullWidth: true, variant: "contained", color: "primary", sx: { mt: 2, mb: 2 }, children: loading ? /* @__PURE__ */ jsx5(CircularProgress2, { size: 20 }) : t("forgotPassword.sendCodeButton") }),
2189
1048
  /* @__PURE__ */ jsxs2(Box2, { sx: { display: "flex", justifyContent: "center", alignItems: "center", gap: 2 }, children: [
2190
- /* @__PURE__ */ jsx6(Link2, { sx: { cursor: "pointer" }, onClick: handleBack, variant: "body2", color: "secondary", children: t("common.back") }),
2191
- /* @__PURE__ */ jsx6(Typography2, { variant: "body2", sx: { color: "grey.400" }, children: "\u2022" }),
2192
- /* @__PURE__ */ jsx6(Link2, { sx: { cursor: "pointer" }, onClick: handleGoToCheckCode, variant: "body2", color: "secondary", children: t("login.alreadyHaveCodeLink") })
1049
+ /* @__PURE__ */ jsx5(Link2, { sx: { cursor: "pointer" }, onClick: handleBack, variant: "body2", color: "secondary", children: t("common.back") }),
1050
+ /* @__PURE__ */ jsx5(Typography2, { variant: "body2", sx: { color: "grey.400" }, children: "\u2022" }),
1051
+ /* @__PURE__ */ jsx5(Link2, { sx: { cursor: "pointer" }, onClick: handleGoToCheckCode, variant: "body2", color: "secondary", children: t("login.alreadyHaveCodeLink") })
2193
1052
  ] })
2194
1053
  ] }),
2195
- /* @__PURE__ */ jsx6(Box2, { children: errors.length > 0 && errors.map((error, index) => /* @__PURE__ */ jsx6(Alert2, { variant: "filled", sx: { mt: 2 }, severity: "error", children: error }, index)) })
1054
+ /* @__PURE__ */ jsx5(Box2, { children: errors.length > 0 && errors.map((error, index) => /* @__PURE__ */ jsx5(Alert2, { variant: "filled", sx: { mt: 2 }, severity: "error", children: error }, index)) })
2196
1055
  ] });
2197
1056
  };
2198
1057
  var ForgotPasswordForm_default = ForgotPasswordForm;
2199
1058
 
2200
1059
  // src/components/CrudifyLogin/Forms/ResetPasswordForm.tsx
2201
- import { useState as useState5, useEffect as useEffect6 } from "react";
1060
+ import { useState as useState4, useEffect as useEffect5 } from "react";
2202
1061
  import { Typography as Typography3, TextField as TextField3, Button as Button3, Box as Box3, CircularProgress as CircularProgress3, Alert as Alert3, Link as Link3 } from "@mui/material";
2203
- import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
1062
+ import { Fragment as Fragment3, jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
2204
1063
  var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess }) => {
2205
- const { crudify: crudify8 } = useCrudify();
2206
- const [newPassword, setNewPassword] = useState5("");
2207
- const [confirmPassword, setConfirmPassword] = useState5("");
2208
- const [loading, setLoading] = useState5(false);
2209
- const [errors, setErrors] = useState5([]);
2210
- const [helperTextNewPassword, setHelperTextNewPassword] = useState5(null);
2211
- const [helperTextConfirmPassword, setHelperTextConfirmPassword] = useState5(null);
2212
- const [email, setEmail] = useState5("");
2213
- const [code, setCode] = useState5("");
2214
- const [fromCodeVerification, setFromCodeVerification] = useState5(false);
2215
- const [validatingCode, setValidatingCode] = useState5(true);
2216
- const [codeValidated, setCodeValidated] = useState5(false);
2217
- const [pendingValidation, setPendingValidation] = useState5(null);
2218
- const [isValidating, setIsValidating] = useState5(false);
1064
+ const { crudify: crudify6 } = useCrudify();
1065
+ const [newPassword, setNewPassword] = useState4("");
1066
+ const [confirmPassword, setConfirmPassword] = useState4("");
1067
+ const [loading, setLoading] = useState4(false);
1068
+ const [errors, setErrors] = useState4([]);
1069
+ const [helperTextNewPassword, setHelperTextNewPassword] = useState4(null);
1070
+ const [helperTextConfirmPassword, setHelperTextConfirmPassword] = useState4(null);
1071
+ const [email, setEmail] = useState4("");
1072
+ const [code, setCode] = useState4("");
1073
+ const [fromCodeVerification, setFromCodeVerification] = useState4(false);
1074
+ const [validatingCode, setValidatingCode] = useState4(true);
1075
+ const [codeValidated, setCodeValidated] = useState4(false);
1076
+ const [pendingValidation, setPendingValidation] = useState4(null);
1077
+ const [isValidating, setIsValidating] = useState4(false);
2219
1078
  const { t } = useTranslation();
2220
1079
  const translateError = (parsedError) => {
2221
1080
  const possibleKeys = [
@@ -2240,7 +1099,7 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
2240
1099
  }
2241
1100
  return searchParams[key] || null;
2242
1101
  };
2243
- useEffect6(() => {
1102
+ useEffect5(() => {
2244
1103
  if (!searchParams) {
2245
1104
  return;
2246
1105
  }
@@ -2282,9 +1141,9 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
2282
1141
  setErrors([t("resetPassword.invalidCode")]);
2283
1142
  setValidatingCode(false);
2284
1143
  setTimeout(() => onScreenChange?.("forgotPassword"), 3e3);
2285
- }, [searchParams, crudify8, t, onScreenChange]);
2286
- useEffect6(() => {
2287
- if (crudify8 && pendingValidation && !isValidating) {
1144
+ }, [searchParams, crudify6, t, onScreenChange]);
1145
+ useEffect5(() => {
1146
+ if (crudify6 && pendingValidation && !isValidating) {
2288
1147
  setIsValidating(true);
2289
1148
  const validateCode = async (emailToValidate, codeToValidate) => {
2290
1149
  try {
@@ -2294,7 +1153,7 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
2294
1153
  data: { email: emailToValidate, codePassword: codeToValidate }
2295
1154
  }
2296
1155
  ];
2297
- const response = await crudify8.transaction(data);
1156
+ const response = await crudify6.transaction(data);
2298
1157
  if (response.data && Array.isArray(response.data)) {
2299
1158
  const validationResult = response.data[0];
2300
1159
  if (validationResult && validationResult.response && validationResult.response.status === "OK") {
@@ -2323,7 +1182,7 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
2323
1182
  };
2324
1183
  validateCode(pendingValidation.email, pendingValidation.code);
2325
1184
  }
2326
- }, [crudify8, pendingValidation, t, onScreenChange]);
1185
+ }, [crudify6, pendingValidation, t, onScreenChange]);
2327
1186
  const validatePassword = (password) => {
2328
1187
  if (password.length < 8) {
2329
1188
  return t("resetPassword.passwordTooShort");
@@ -2331,7 +1190,7 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
2331
1190
  return null;
2332
1191
  };
2333
1192
  const handleSubmit = async () => {
2334
- if (loading || !crudify8) return;
1193
+ if (loading || !crudify6) return;
2335
1194
  setErrors([]);
2336
1195
  setHelperTextNewPassword(null);
2337
1196
  setHelperTextConfirmPassword(null);
@@ -2362,7 +1221,7 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
2362
1221
  data: { email, codePassword: code, newPassword }
2363
1222
  }
2364
1223
  ];
2365
- const response = await crudify8.transaction(data);
1224
+ const response = await crudify6.transaction(data);
2366
1225
  if (response.success) {
2367
1226
  setErrors([]);
2368
1227
  setTimeout(() => {
@@ -2391,19 +1250,19 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
2391
1250
  }
2392
1251
  };
2393
1252
  if (validatingCode) {
2394
- return /* @__PURE__ */ jsx7(Box3, { sx: { display: "flex", justifyContent: "center", alignItems: "center", minHeight: "300px" }, children: /* @__PURE__ */ jsx7(CircularProgress3, {}) });
1253
+ return /* @__PURE__ */ jsx6(Box3, { sx: { display: "flex", justifyContent: "center", alignItems: "center", minHeight: "300px" }, children: /* @__PURE__ */ jsx6(CircularProgress3, {}) });
2395
1254
  }
2396
1255
  if (!codeValidated) {
2397
- return /* @__PURE__ */ jsx7(Box3, { children: errors.length > 0 && errors.map((error, index) => /* @__PURE__ */ jsx7(Alert3, { variant: "filled", sx: { mt: 2 }, severity: "error", children: error }, index)) });
1256
+ return /* @__PURE__ */ jsx6(Box3, { children: errors.length > 0 && errors.map((error, index) => /* @__PURE__ */ jsx6(Alert3, { variant: "filled", sx: { mt: 2 }, severity: "error", children: error }, index)) });
2398
1257
  }
2399
1258
  return /* @__PURE__ */ jsxs3(Fragment3, { children: [
2400
1259
  /* @__PURE__ */ jsxs3(Box3, { component: "form", noValidate: true, sx: { width: "100%", display: "flex", flexDirection: "column", gap: 2 }, children: [
2401
1260
  /* @__PURE__ */ jsxs3(Box3, { sx: { mb: 2 }, children: [
2402
- /* @__PURE__ */ jsx7(Typography3, { variant: "h5", component: "h1", sx: { mb: 1, fontWeight: 600 }, children: t("resetPassword.title") }),
2403
- /* @__PURE__ */ jsx7(Typography3, { variant: "body2", sx: { color: "grey.600" }, children: t("resetPassword.instructions") })
1261
+ /* @__PURE__ */ jsx6(Typography3, { variant: "h5", component: "h1", sx: { mb: 1, fontWeight: 600 }, children: t("resetPassword.title") }),
1262
+ /* @__PURE__ */ jsx6(Typography3, { variant: "body2", sx: { color: "grey.600" }, children: t("resetPassword.instructions") })
2404
1263
  ] }),
2405
1264
  /* @__PURE__ */ jsxs3(Box3, { sx: { mb: 1 }, children: [
2406
- /* @__PURE__ */ jsx7(
1265
+ /* @__PURE__ */ jsx6(
2407
1266
  Typography3,
2408
1267
  {
2409
1268
  variant: "body2",
@@ -2413,7 +1272,7 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
2413
1272
  children: t("resetPassword.newPasswordLabel")
2414
1273
  }
2415
1274
  ),
2416
- /* @__PURE__ */ jsx7(
1275
+ /* @__PURE__ */ jsx6(
2417
1276
  TextField3,
2418
1277
  {
2419
1278
  fullWidth: true,
@@ -2432,7 +1291,7 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
2432
1291
  )
2433
1292
  ] }),
2434
1293
  /* @__PURE__ */ jsxs3(Box3, { sx: { mb: 1 }, children: [
2435
- /* @__PURE__ */ jsx7(
1294
+ /* @__PURE__ */ jsx6(
2436
1295
  Typography3,
2437
1296
  {
2438
1297
  variant: "body2",
@@ -2442,7 +1301,7 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
2442
1301
  children: t("resetPassword.confirmPasswordLabel")
2443
1302
  }
2444
1303
  ),
2445
- /* @__PURE__ */ jsx7(
1304
+ /* @__PURE__ */ jsx6(
2446
1305
  TextField3,
2447
1306
  {
2448
1307
  fullWidth: true,
@@ -2460,25 +1319,25 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
2460
1319
  }
2461
1320
  )
2462
1321
  ] }),
2463
- /* @__PURE__ */ jsx7(Button3, { disabled: loading, type: "button", onClick: handleSubmit, fullWidth: true, variant: "contained", color: "primary", sx: { mt: 2, mb: 2 }, children: loading ? /* @__PURE__ */ jsx7(CircularProgress3, { size: 20 }) : t("resetPassword.resetPasswordButton") }),
2464
- /* @__PURE__ */ jsx7(Box3, { sx: { display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ jsx7(Link3, { sx: { cursor: "pointer" }, onClick: handleBack, variant: "body2", color: "secondary", children: t("common.back") }) })
1322
+ /* @__PURE__ */ jsx6(Button3, { disabled: loading, type: "button", onClick: handleSubmit, fullWidth: true, variant: "contained", color: "primary", sx: { mt: 2, mb: 2 }, children: loading ? /* @__PURE__ */ jsx6(CircularProgress3, { size: 20 }) : t("resetPassword.resetPasswordButton") }),
1323
+ /* @__PURE__ */ jsx6(Box3, { sx: { display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ jsx6(Link3, { sx: { cursor: "pointer" }, onClick: handleBack, variant: "body2", color: "secondary", children: t("common.back") }) })
2465
1324
  ] }),
2466
- /* @__PURE__ */ jsx7(Box3, { children: errors.length > 0 && errors.map((error, index) => /* @__PURE__ */ jsx7(Alert3, { variant: "filled", sx: { mt: 2 }, severity: "error", children: error }, index)) })
1325
+ /* @__PURE__ */ jsx6(Box3, { children: errors.length > 0 && errors.map((error, index) => /* @__PURE__ */ jsx6(Alert3, { variant: "filled", sx: { mt: 2 }, severity: "error", children: error }, index)) })
2467
1326
  ] });
2468
1327
  };
2469
1328
  var ResetPasswordForm_default = ResetPasswordForm;
2470
1329
 
2471
1330
  // src/components/CrudifyLogin/Forms/CheckCodeForm.tsx
2472
- import { useState as useState6, useEffect as useEffect7 } from "react";
1331
+ import { useState as useState5, useEffect as useEffect6 } from "react";
2473
1332
  import { Typography as Typography4, TextField as TextField4, Button as Button4, Box as Box4, CircularProgress as CircularProgress4, Alert as Alert4, Link as Link4 } from "@mui/material";
2474
- import { Fragment as Fragment4, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
1333
+ import { Fragment as Fragment4, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
2475
1334
  var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
2476
- const { crudify: crudify8 } = useCrudify();
2477
- const [code, setCode] = useState6("");
2478
- const [loading, setLoading] = useState6(false);
2479
- const [errors, setErrors] = useState6([]);
2480
- const [helperTextCode, setHelperTextCode] = useState6(null);
2481
- const [email, setEmail] = useState6("");
1335
+ const { crudify: crudify6 } = useCrudify();
1336
+ const [code, setCode] = useState5("");
1337
+ const [loading, setLoading] = useState5(false);
1338
+ const [errors, setErrors] = useState5([]);
1339
+ const [helperTextCode, setHelperTextCode] = useState5(null);
1340
+ const [email, setEmail] = useState5("");
2482
1341
  const { t } = useTranslation();
2483
1342
  const getParam = (key) => {
2484
1343
  if (!searchParams) return null;
@@ -2503,7 +1362,7 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
2503
1362
  }
2504
1363
  return parsedError.message || t("error.unknown");
2505
1364
  };
2506
- useEffect7(() => {
1365
+ useEffect6(() => {
2507
1366
  const emailParam = getParam("email");
2508
1367
  if (emailParam) {
2509
1368
  setEmail(emailParam);
@@ -2512,7 +1371,7 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
2512
1371
  }
2513
1372
  }, [searchParams, onScreenChange]);
2514
1373
  const handleSubmit = async () => {
2515
- if (loading || !crudify8) return;
1374
+ if (loading || !crudify6) return;
2516
1375
  setErrors([]);
2517
1376
  setHelperTextCode(null);
2518
1377
  if (!code) {
@@ -2531,7 +1390,7 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
2531
1390
  data: { email, codePassword: code }
2532
1391
  }
2533
1392
  ];
2534
- const response = await crudify8.transaction(data);
1393
+ const response = await crudify6.transaction(data);
2535
1394
  if (response.success) {
2536
1395
  onScreenChange?.("resetPassword", { email, code, fromCodeVerification: "true" });
2537
1396
  } else {
@@ -2560,11 +1419,11 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
2560
1419
  return /* @__PURE__ */ jsxs4(Fragment4, { children: [
2561
1420
  /* @__PURE__ */ jsxs4(Box4, { component: "form", noValidate: true, sx: { width: "100%", display: "flex", flexDirection: "column", gap: 2 }, children: [
2562
1421
  /* @__PURE__ */ jsxs4(Box4, { sx: { mb: 2 }, children: [
2563
- /* @__PURE__ */ jsx8(Typography4, { variant: "h5", component: "h1", sx: { mb: 1, fontWeight: 600 }, children: t("checkCode.title") }),
2564
- /* @__PURE__ */ jsx8(Typography4, { variant: "body2", sx: { color: "grey.600" }, children: t("checkCode.instructions") })
1422
+ /* @__PURE__ */ jsx7(Typography4, { variant: "h5", component: "h1", sx: { mb: 1, fontWeight: 600 }, children: t("checkCode.title") }),
1423
+ /* @__PURE__ */ jsx7(Typography4, { variant: "body2", sx: { color: "grey.600" }, children: t("checkCode.instructions") })
2565
1424
  ] }),
2566
1425
  /* @__PURE__ */ jsxs4(Box4, { sx: { mb: 1 }, children: [
2567
- /* @__PURE__ */ jsx8(
1426
+ /* @__PURE__ */ jsx7(
2568
1427
  Typography4,
2569
1428
  {
2570
1429
  variant: "body2",
@@ -2574,7 +1433,7 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
2574
1433
  children: t("checkCode.codeLabel")
2575
1434
  }
2576
1435
  ),
2577
- /* @__PURE__ */ jsx8(
1436
+ /* @__PURE__ */ jsx7(
2578
1437
  TextField4,
2579
1438
  {
2580
1439
  fullWidth: true,
@@ -2595,7 +1454,7 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
2595
1454
  }
2596
1455
  )
2597
1456
  ] }),
2598
- /* @__PURE__ */ jsx8(
1457
+ /* @__PURE__ */ jsx7(
2599
1458
  Button4,
2600
1459
  {
2601
1460
  disabled: loading || code.length !== 6,
@@ -2605,20 +1464,20 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
2605
1464
  variant: "contained",
2606
1465
  color: "primary",
2607
1466
  sx: { mt: 2, mb: 2 },
2608
- children: loading ? /* @__PURE__ */ jsx8(CircularProgress4, { size: 20 }) : t("checkCode.verifyButton")
1467
+ children: loading ? /* @__PURE__ */ jsx7(CircularProgress4, { size: 20 }) : t("checkCode.verifyButton")
2609
1468
  }
2610
1469
  ),
2611
- /* @__PURE__ */ jsx8(Box4, { sx: { display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ jsx8(Link4, { sx: { cursor: "pointer" }, onClick: handleBack, variant: "body2", color: "secondary", children: t("common.back") }) })
1470
+ /* @__PURE__ */ jsx7(Box4, { sx: { display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ jsx7(Link4, { sx: { cursor: "pointer" }, onClick: handleBack, variant: "body2", color: "secondary", children: t("common.back") }) })
2612
1471
  ] }),
2613
- /* @__PURE__ */ jsx8(Box4, { children: errors.length > 0 && errors.map((error, index) => /* @__PURE__ */ jsx8(Alert4, { sx: { mt: 2 }, severity: "error", children: error }, index)) })
1472
+ /* @__PURE__ */ jsx7(Box4, { children: errors.length > 0 && errors.map((error, index) => /* @__PURE__ */ jsx7(Alert4, { sx: { mt: 2 }, severity: "error", children: error }, index)) })
2614
1473
  ] });
2615
1474
  };
2616
1475
  var CheckCodeForm_default = CheckCodeForm;
2617
1476
 
2618
1477
  // src/components/CrudifyLogin/components/CrudifyInitializer.tsx
2619
1478
  import { Box as Box5, CircularProgress as CircularProgress5, Alert as Alert5, Typography as Typography5 } from "@mui/material";
2620
- import { Fragment as Fragment5, jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
2621
- var CrudifyInitializer2 = ({ children, fallback }) => {
1479
+ import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1480
+ var CrudifyInitializer = ({ children, fallback }) => {
2622
1481
  const { isLoading, error, isInitialized } = useCrudify();
2623
1482
  const { t } = useTranslation();
2624
1483
  if (isLoading) {
@@ -2634,14 +1493,14 @@ var CrudifyInitializer2 = ({ children, fallback }) => {
2634
1493
  gap: 2
2635
1494
  },
2636
1495
  children: [
2637
- /* @__PURE__ */ jsx9(CircularProgress5, {}),
2638
- /* @__PURE__ */ jsx9(Typography5, { variant: "body2", color: "text.secondary", children: t("login.initializing") !== "login.initializing" ? t("login.initializing") : "Initializing..." })
1496
+ /* @__PURE__ */ jsx8(CircularProgress5, {}),
1497
+ /* @__PURE__ */ jsx8(Typography5, { variant: "body2", color: "text.secondary", children: t("login.initializing") !== "login.initializing" ? t("login.initializing") : "Initializing..." })
2639
1498
  ]
2640
1499
  }
2641
1500
  );
2642
1501
  }
2643
1502
  if (error) {
2644
- return /* @__PURE__ */ jsx9(Alert5, { severity: "error", sx: { mt: 2 }, children: /* @__PURE__ */ jsxs5(Typography5, { variant: "body2", children: [
1503
+ return /* @__PURE__ */ jsx8(Alert5, { severity: "error", sx: { mt: 2 }, children: /* @__PURE__ */ jsxs5(Typography5, { variant: "body2", children: [
2645
1504
  t("login.initializationError") !== "login.initializationError" ? t("login.initializationError") : "Initialization error",
2646
1505
  ":",
2647
1506
  " ",
@@ -2649,9 +1508,9 @@ var CrudifyInitializer2 = ({ children, fallback }) => {
2649
1508
  ] }) });
2650
1509
  }
2651
1510
  if (!isInitialized) {
2652
- return /* @__PURE__ */ jsx9(Alert5, { severity: "warning", sx: { mt: 2 }, children: /* @__PURE__ */ jsx9(Typography5, { variant: "body2", children: t("login.notInitialized") !== "login.notInitialized" ? t("login.notInitialized") : "System not initialized" }) });
1511
+ return /* @__PURE__ */ jsx8(Alert5, { severity: "warning", sx: { mt: 2 }, children: /* @__PURE__ */ jsx8(Typography5, { variant: "body2", children: t("login.notInitialized") !== "login.notInitialized" ? t("login.notInitialized") : "System not initialized" }) });
2653
1512
  }
2654
- return /* @__PURE__ */ jsx9(Fragment5, { children });
1513
+ return /* @__PURE__ */ jsx8(Fragment5, { children });
2655
1514
  };
2656
1515
 
2657
1516
  // src/components/CrudifyLogin/hooks/useCrudifyLogin.ts
@@ -2681,7 +1540,7 @@ var useCrudifyLogin = (config, _options = {}) => {
2681
1540
  };
2682
1541
 
2683
1542
  // src/components/CrudifyLogin/index.tsx
2684
- import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
1543
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
2685
1544
  var CrudifyLoginInternal = ({
2686
1545
  onScreenChange,
2687
1546
  onExternalNavigate,
@@ -2691,15 +1550,15 @@ var CrudifyLoginInternal = ({
2691
1550
  }) => {
2692
1551
  const { t } = useTranslation();
2693
1552
  const { state, setScreen } = useLoginState();
2694
- const handleScreenChange = (screen2, params) => {
1553
+ const handleScreenChange = (screen, params) => {
2695
1554
  let finalParams = params;
2696
- if (screen2 === "login") {
1555
+ if (screen === "login") {
2697
1556
  finalParams = {};
2698
- } else if (screen2 === "forgotPassword" && !params) {
1557
+ } else if (screen === "forgotPassword" && !params) {
2699
1558
  finalParams = {};
2700
1559
  }
2701
- setScreen(screen2, finalParams);
2702
- onScreenChange?.(screen2, finalParams);
1560
+ setScreen(screen, finalParams);
1561
+ onScreenChange?.(screen, finalParams);
2703
1562
  };
2704
1563
  const renderCurrentForm = () => {
2705
1564
  const commonProps = {
@@ -2710,11 +1569,11 @@ var CrudifyLoginInternal = ({
2710
1569
  };
2711
1570
  switch (state.currentScreen) {
2712
1571
  case "forgotPassword":
2713
- return /* @__PURE__ */ jsx10(ForgotPasswordForm_default, { ...commonProps });
1572
+ return /* @__PURE__ */ jsx9(ForgotPasswordForm_default, { ...commonProps });
2714
1573
  case "checkCode":
2715
- return /* @__PURE__ */ jsx10(CheckCodeForm_default, { ...commonProps, searchParams: state.searchParams });
1574
+ return /* @__PURE__ */ jsx9(CheckCodeForm_default, { ...commonProps, searchParams: state.searchParams });
2716
1575
  case "resetPassword":
2717
- return /* @__PURE__ */ jsx10(
1576
+ return /* @__PURE__ */ jsx9(
2718
1577
  ResetPasswordForm_default,
2719
1578
  {
2720
1579
  ...commonProps,
@@ -2725,11 +1584,11 @@ var CrudifyLoginInternal = ({
2725
1584
  }
2726
1585
  );
2727
1586
  default:
2728
- return /* @__PURE__ */ jsx10(LoginForm_default, { ...commonProps, onLoginSuccess });
1587
+ return /* @__PURE__ */ jsx9(LoginForm_default, { ...commonProps, onLoginSuccess });
2729
1588
  }
2730
1589
  };
2731
- return /* @__PURE__ */ jsxs6(CrudifyInitializer2, { children: [
2732
- /* @__PURE__ */ jsx10(Box6, { sx: { display: "flex", justifyContent: "center", mb: 3 }, children: /* @__PURE__ */ jsx10(
1590
+ return /* @__PURE__ */ jsxs6(CrudifyInitializer, { children: [
1591
+ /* @__PURE__ */ jsx9(Box6, { sx: { display: "flex", justifyContent: "center", mb: 3 }, children: /* @__PURE__ */ jsx9(
2733
1592
  "img",
2734
1593
  {
2735
1594
  src: state.config.logo || "/nocios-default.png",
@@ -2745,7 +1604,7 @@ var CrudifyLoginInternal = ({
2745
1604
  }
2746
1605
  }
2747
1606
  ) }),
2748
- state.config.appName && /* @__PURE__ */ jsx10(
1607
+ state.config.appName && /* @__PURE__ */ jsx9(
2749
1608
  Typography6,
2750
1609
  {
2751
1610
  variant: "h6",
@@ -2771,7 +1630,7 @@ var CrudifyLogin = ({
2771
1630
  ...props
2772
1631
  }) => {
2773
1632
  const { config: finalConfig } = useCrudifyLogin(config);
2774
- return /* @__PURE__ */ jsx10(I18nProvider, { translations, translationsUrl, language, children: /* @__PURE__ */ jsx10(CrudifyProvider, { config: finalConfig, children: /* @__PURE__ */ jsx10(LoginStateProvider, { config, initialScreen, autoReadFromCookies, children: /* @__PURE__ */ jsx10(CrudifyLoginInternal, { config, ...props }) }) }) });
1633
+ return /* @__PURE__ */ jsx9(I18nProvider, { translations, translationsUrl, language, children: /* @__PURE__ */ jsx9(CrudifyProvider, { config: finalConfig, children: /* @__PURE__ */ jsx9(LoginStateProvider, { config, initialScreen, autoReadFromCookies, children: /* @__PURE__ */ jsx9(CrudifyLoginInternal, { config, ...props }) }) }) });
2775
1634
  };
2776
1635
  var CrudifyLogin_default = CrudifyLogin;
2777
1636
 
@@ -2806,25 +1665,25 @@ import {
2806
1665
  } from "@mui/icons-material";
2807
1666
 
2808
1667
  // src/hooks/useUserProfile.ts
2809
- import { useState as useState7, useEffect as useEffect8, useCallback as useCallback2, useRef as useRef2 } from "react";
2810
- import crudify4 from "@nocios/crudify-browser";
1668
+ import { useState as useState6, useEffect as useEffect7, useCallback, useRef as useRef2 } from "react";
1669
+ import crudify2 from "@nocios/crudify-browser";
2811
1670
  var useUserProfile = (options = {}) => {
2812
1671
  const { autoFetch = true, retryOnError = false, maxRetries = 3 } = options;
2813
- const [userProfile, setUserProfile] = useState7(null);
2814
- const [loading, setLoading] = useState7(false);
2815
- const [error, setError] = useState7(null);
2816
- const [extendedData, setExtendedData] = useState7({});
1672
+ const [userProfile, setUserProfile] = useState6(null);
1673
+ const [loading, setLoading] = useState6(false);
1674
+ const [error, setError] = useState6(null);
1675
+ const [extendedData, setExtendedData] = useState6({});
2817
1676
  const abortControllerRef = useRef2(null);
2818
1677
  const mountedRef = useRef2(true);
2819
1678
  const requestIdRef = useRef2(0);
2820
1679
  const retryCountRef = useRef2(0);
2821
- const clearProfile = useCallback2(() => {
1680
+ const clearProfile = useCallback(() => {
2822
1681
  setUserProfile(null);
2823
1682
  setError(null);
2824
1683
  setLoading(false);
2825
1684
  setExtendedData({});
2826
1685
  }, []);
2827
- const refreshProfile = useCallback2(async () => {
1686
+ const refreshProfile = useCallback(async () => {
2828
1687
  const userEmail = getCurrentUserEmail();
2829
1688
  if (!userEmail) {
2830
1689
  if (mountedRef.current) {
@@ -2844,7 +1703,7 @@ var useUserProfile = (options = {}) => {
2844
1703
  setLoading(true);
2845
1704
  setError(null);
2846
1705
  }
2847
- const response = await crudify4.readItems("users", {
1706
+ const response = await crudify2.readItems("users", {
2848
1707
  where: { email: userEmail },
2849
1708
  limit: 1
2850
1709
  });
@@ -2910,12 +1769,12 @@ var useUserProfile = (options = {}) => {
2910
1769
  }
2911
1770
  }
2912
1771
  }, [retryOnError, maxRetries]);
2913
- useEffect8(() => {
1772
+ useEffect7(() => {
2914
1773
  if (autoFetch) {
2915
1774
  refreshProfile();
2916
1775
  }
2917
1776
  }, [autoFetch, refreshProfile]);
2918
- useEffect8(() => {
1777
+ useEffect7(() => {
2919
1778
  mountedRef.current = true;
2920
1779
  return () => {
2921
1780
  mountedRef.current = false;
@@ -2936,8 +1795,8 @@ var useUserProfile = (options = {}) => {
2936
1795
  };
2937
1796
 
2938
1797
  // src/components/UserProfile/UserProfileDisplay.tsx
2939
- import { useState as useState8 } from "react";
2940
- import { Fragment as Fragment6, jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
1798
+ import { useState as useState7 } from "react";
1799
+ import { Fragment as Fragment6, jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
2941
1800
  var UserProfileDisplay = ({
2942
1801
  showExtendedData = true,
2943
1802
  showProfileCard = true,
@@ -2948,11 +1807,11 @@ var UserProfileDisplay = ({
2948
1807
  retryOnError: true,
2949
1808
  maxRetries: 3
2950
1809
  });
2951
- const [showAllFields, setShowAllFields] = useState8(false);
1810
+ const [showAllFields, setShowAllFields] = useState7(false);
2952
1811
  if (loading) {
2953
1812
  return /* @__PURE__ */ jsxs7(Box7, { display: "flex", justifyContent: "center", alignItems: "center", p: 3, children: [
2954
- /* @__PURE__ */ jsx11(CircularProgress6, {}),
2955
- /* @__PURE__ */ jsx11(Typography7, { variant: "body2", sx: { ml: 2 }, children: "Cargando perfil de usuario..." })
1813
+ /* @__PURE__ */ jsx10(CircularProgress6, {}),
1814
+ /* @__PURE__ */ jsx10(Typography7, { variant: "body2", sx: { ml: 2 }, children: "Cargando perfil de usuario..." })
2956
1815
  ] });
2957
1816
  }
2958
1817
  if (error) {
@@ -2960,7 +1819,7 @@ var UserProfileDisplay = ({
2960
1819
  Alert6,
2961
1820
  {
2962
1821
  severity: "error",
2963
- action: /* @__PURE__ */ jsx11(IconButton, { color: "inherit", size: "small", onClick: refreshProfile, children: /* @__PURE__ */ jsx11(Typography7, { variant: "caption", children: "Reintentar" }) }),
1822
+ action: /* @__PURE__ */ jsx10(IconButton, { color: "inherit", size: "small", onClick: refreshProfile, children: /* @__PURE__ */ jsx10(Typography7, { variant: "caption", children: "Reintentar" }) }),
2964
1823
  children: [
2965
1824
  "Error al cargar el perfil: ",
2966
1825
  error
@@ -2969,7 +1828,7 @@ var UserProfileDisplay = ({
2969
1828
  );
2970
1829
  }
2971
1830
  if (!userProfile) {
2972
- return /* @__PURE__ */ jsx11(Alert6, { severity: "warning", children: "No se encontr\xF3 informaci\xF3n del usuario" });
1831
+ return /* @__PURE__ */ jsx10(Alert6, { severity: "warning", children: "No se encontr\xF3 informaci\xF3n del usuario" });
2973
1832
  }
2974
1833
  const displayData = extendedData?.displayData || {};
2975
1834
  const totalFields = extendedData?.totalFields || 0;
@@ -2995,11 +1854,11 @@ var UserProfileDisplay = ({
2995
1854
  return String(value);
2996
1855
  };
2997
1856
  const basicFields = [
2998
- { key: "id", label: "ID", icon: /* @__PURE__ */ jsx11(Badge, {}) },
2999
- { key: "email", label: "Email", icon: /* @__PURE__ */ jsx11(Email, {}) },
3000
- { key: "username", label: "Usuario", icon: /* @__PURE__ */ jsx11(Person, {}) },
3001
- { key: "fullName", label: "Nombre completo", icon: /* @__PURE__ */ jsx11(AccountCircle, {}) },
3002
- { key: "role", label: "Rol", icon: /* @__PURE__ */ jsx11(Security, {}) }
1857
+ { key: "id", label: "ID", icon: /* @__PURE__ */ jsx10(Badge, {}) },
1858
+ { key: "email", label: "Email", icon: /* @__PURE__ */ jsx10(Email, {}) },
1859
+ { key: "username", label: "Usuario", icon: /* @__PURE__ */ jsx10(Person, {}) },
1860
+ { key: "fullName", label: "Nombre completo", icon: /* @__PURE__ */ jsx10(AccountCircle, {}) },
1861
+ { key: "role", label: "Rol", icon: /* @__PURE__ */ jsx10(Security, {}) }
3003
1862
  ];
3004
1863
  const extendedFields = [
3005
1864
  { key: "firstName", label: "Nombre" },
@@ -3012,9 +1871,9 @@ var UserProfileDisplay = ({
3012
1871
  const knownFields = [...basicFields.map((f) => f.key), ...extendedFields.map((f) => f.key), "permissions"];
3013
1872
  const customFields = Object.keys(displayData).filter((key) => !knownFields.includes(key)).map((key) => ({ key, label: key }));
3014
1873
  return /* @__PURE__ */ jsxs7(Box7, { children: [
3015
- showProfileCard && /* @__PURE__ */ jsx11(Card, { sx: { mb: 2 }, children: /* @__PURE__ */ jsxs7(CardContent, { children: [
1874
+ showProfileCard && /* @__PURE__ */ jsx10(Card, { sx: { mb: 2 }, children: /* @__PURE__ */ jsxs7(CardContent, { children: [
3016
1875
  /* @__PURE__ */ jsxs7(Box7, { display: "flex", alignItems: "center", mb: 2, children: [
3017
- /* @__PURE__ */ jsx11(
1876
+ /* @__PURE__ */ jsx10(
3018
1877
  Avatar,
3019
1878
  {
3020
1879
  src: displayData.avatar,
@@ -3023,9 +1882,9 @@ var UserProfileDisplay = ({
3023
1882
  }
3024
1883
  ),
3025
1884
  /* @__PURE__ */ jsxs7(Box7, { children: [
3026
- /* @__PURE__ */ jsx11(Typography7, { variant: "h6", children: displayData.fullName || displayData.username || displayData.email }),
3027
- /* @__PURE__ */ jsx11(Typography7, { variant: "body2", color: "text.secondary", children: displayData.role || "Usuario" }),
3028
- displayData.isActive !== void 0 && /* @__PURE__ */ jsx11(
1885
+ /* @__PURE__ */ jsx10(Typography7, { variant: "h6", children: displayData.fullName || displayData.username || displayData.email }),
1886
+ /* @__PURE__ */ jsx10(Typography7, { variant: "body2", color: "text.secondary", children: displayData.role || "Usuario" }),
1887
+ displayData.isActive !== void 0 && /* @__PURE__ */ jsx10(
3029
1888
  Chip,
3030
1889
  {
3031
1890
  label: displayData.isActive ? "Activo" : "Inactivo",
@@ -3036,35 +1895,35 @@ var UserProfileDisplay = ({
3036
1895
  )
3037
1896
  ] })
3038
1897
  ] }),
3039
- /* @__PURE__ */ jsx11(Box7, { display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(250px, 1fr))", gap: 2, children: basicFields.map(
1898
+ /* @__PURE__ */ jsx10(Box7, { display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(250px, 1fr))", gap: 2, children: basicFields.map(
3040
1899
  ({ key, label, icon }) => displayData[key] ? /* @__PURE__ */ jsxs7(Box7, { display: "flex", alignItems: "center", children: [
3041
- /* @__PURE__ */ jsx11(Box7, { sx: { mr: 1, color: "text.secondary" }, children: icon }),
1900
+ /* @__PURE__ */ jsx10(Box7, { sx: { mr: 1, color: "text.secondary" }, children: icon }),
3042
1901
  /* @__PURE__ */ jsxs7(Box7, { children: [
3043
- /* @__PURE__ */ jsx11(Typography7, { variant: "caption", color: "text.secondary", children: label }),
3044
- /* @__PURE__ */ jsx11(Typography7, { variant: "body2", children: renderFieldValue(key, displayData[key]) })
1902
+ /* @__PURE__ */ jsx10(Typography7, { variant: "caption", color: "text.secondary", children: label }),
1903
+ /* @__PURE__ */ jsx10(Typography7, { variant: "body2", children: renderFieldValue(key, displayData[key]) })
3045
1904
  ] })
3046
1905
  ] }, key) : null
3047
1906
  ) }),
3048
1907
  displayData.permissions && Array.isArray(displayData.permissions) && displayData.permissions.length > 0 && /* @__PURE__ */ jsxs7(Box7, { mt: 2, children: [
3049
- /* @__PURE__ */ jsx11(Typography7, { variant: "caption", color: "text.secondary", display: "block", children: "Permisos" }),
1908
+ /* @__PURE__ */ jsx10(Typography7, { variant: "caption", color: "text.secondary", display: "block", children: "Permisos" }),
3050
1909
  /* @__PURE__ */ jsxs7(Box7, { display: "flex", flexWrap: "wrap", gap: 0.5, mt: 0.5, children: [
3051
- displayData.permissions.slice(0, 5).map((permission, index) => /* @__PURE__ */ jsx11(Chip, { label: permission, size: "small", variant: "outlined" }, index)),
3052
- displayData.permissions.length > 5 && /* @__PURE__ */ jsx11(Chip, { label: `+${displayData.permissions.length - 5} m\xE1s`, size: "small" })
1910
+ displayData.permissions.slice(0, 5).map((permission, index) => /* @__PURE__ */ jsx10(Chip, { label: permission, size: "small", variant: "outlined" }, index)),
1911
+ displayData.permissions.length > 5 && /* @__PURE__ */ jsx10(Chip, { label: `+${displayData.permissions.length - 5} m\xE1s`, size: "small" })
3053
1912
  ] })
3054
1913
  ] })
3055
1914
  ] }) }),
3056
- showExtendedData && /* @__PURE__ */ jsx11(Card, { children: /* @__PURE__ */ jsxs7(CardContent, { children: [
1915
+ showExtendedData && /* @__PURE__ */ jsx10(Card, { children: /* @__PURE__ */ jsxs7(CardContent, { children: [
3057
1916
  /* @__PURE__ */ jsxs7(Box7, { display: "flex", justifyContent: "space-between", alignItems: "center", mb: 2, children: [
3058
1917
  /* @__PURE__ */ jsxs7(Typography7, { variant: "h6", display: "flex", alignItems: "center", children: [
3059
- /* @__PURE__ */ jsx11(Info, { sx: { mr: 1 } }),
1918
+ /* @__PURE__ */ jsx10(Info, { sx: { mr: 1 } }),
3060
1919
  "Informaci\xF3n Detallada"
3061
1920
  ] }),
3062
- /* @__PURE__ */ jsx11(Chip, { label: `${totalFields} campos totales`, size: "small" })
1921
+ /* @__PURE__ */ jsx10(Chip, { label: `${totalFields} campos totales`, size: "small" })
3063
1922
  ] }),
3064
1923
  /* @__PURE__ */ jsxs7(List, { dense: true, children: [
3065
1924
  extendedFields.map(({ key, label }) => displayData[key] !== void 0 && /* @__PURE__ */ jsxs7(ListItem, { divider: true, children: [
3066
- /* @__PURE__ */ jsx11(ListItemIcon, { children: /* @__PURE__ */ jsx11(Schedule, { fontSize: "small" }) }),
3067
- /* @__PURE__ */ jsx11(
1925
+ /* @__PURE__ */ jsx10(ListItemIcon, { children: /* @__PURE__ */ jsx10(Schedule, { fontSize: "small" }) }),
1926
+ /* @__PURE__ */ jsx10(
3068
1927
  ListItemText,
3069
1928
  {
3070
1929
  primary: label,
@@ -3073,8 +1932,8 @@ var UserProfileDisplay = ({
3073
1932
  )
3074
1933
  ] }, key)),
3075
1934
  customFields.length > 0 && /* @__PURE__ */ jsxs7(Fragment6, { children: [
3076
- /* @__PURE__ */ jsx11(Divider, { sx: { my: 1 } }),
3077
- /* @__PURE__ */ jsx11(ListItem, { children: /* @__PURE__ */ jsx11(
1935
+ /* @__PURE__ */ jsx10(Divider, { sx: { my: 1 } }),
1936
+ /* @__PURE__ */ jsx10(ListItem, { children: /* @__PURE__ */ jsx10(
3078
1937
  ListItemText,
3079
1938
  {
3080
1939
  primary: /* @__PURE__ */ jsxs7(Box7, { display: "flex", justifyContent: "space-between", alignItems: "center", children: [
@@ -3083,11 +1942,11 @@ var UserProfileDisplay = ({
3083
1942
  customFields.length,
3084
1943
  ")"
3085
1944
  ] }),
3086
- /* @__PURE__ */ jsx11(IconButton, { size: "small", onClick: () => setShowAllFields(!showAllFields), children: showAllFields ? /* @__PURE__ */ jsx11(ExpandLess, {}) : /* @__PURE__ */ jsx11(ExpandMore, {}) })
1945
+ /* @__PURE__ */ jsx10(IconButton, { size: "small", onClick: () => setShowAllFields(!showAllFields), children: showAllFields ? /* @__PURE__ */ jsx10(ExpandLess, {}) : /* @__PURE__ */ jsx10(ExpandMore, {}) })
3087
1946
  ] })
3088
1947
  }
3089
1948
  ) }),
3090
- /* @__PURE__ */ jsx11(Collapse, { in: showAllFields, children: customFields.map(({ key, label }) => /* @__PURE__ */ jsx11(ListItem, { sx: { pl: 4 }, children: /* @__PURE__ */ jsx11(
1949
+ /* @__PURE__ */ jsx10(Collapse, { in: showAllFields, children: customFields.map(({ key, label }) => /* @__PURE__ */ jsx10(ListItem, { sx: { pl: 4 }, children: /* @__PURE__ */ jsx10(
3091
1950
  ListItemText,
3092
1951
  {
3093
1952
  primary: label,
@@ -3101,7 +1960,7 @@ var UserProfileDisplay = ({
3101
1960
  "\xDAltima actualizaci\xF3n: ",
3102
1961
  formatDate(displayData.updatedAt)
3103
1962
  ] }),
3104
- /* @__PURE__ */ jsx11(IconButton, { size: "small", onClick: refreshProfile, disabled: loading, children: /* @__PURE__ */ jsx11(Typography7, { variant: "caption", children: "Actualizar" }) })
1963
+ /* @__PURE__ */ jsx10(IconButton, { size: "small", onClick: refreshProfile, disabled: loading, children: /* @__PURE__ */ jsx10(Typography7, { variant: "caption", children: "Actualizar" }) })
3105
1964
  ] })
3106
1965
  ] }) })
3107
1966
  ] });
@@ -3109,8 +1968,8 @@ var UserProfileDisplay = ({
3109
1968
  var UserProfileDisplay_default = UserProfileDisplay;
3110
1969
 
3111
1970
  // src/hooks/useCrudifyUser.ts
3112
- import { useState as useState9, useEffect as useEffect9, useCallback as useCallback3, useRef as useRef3 } from "react";
3113
- import crudify5 from "@nocios/crudify-browser";
1971
+ import { useState as useState8, useEffect as useEffect8, useCallback as useCallback2, useRef as useRef3 } from "react";
1972
+ import crudify3 from "@nocios/crudify-browser";
3114
1973
  var useCrudifyUser = (options = {}) => {
3115
1974
  const { autoFetch = true, retryOnError = false, maxRetries = 3 } = options;
3116
1975
  const {
@@ -3119,10 +1978,10 @@ var useCrudifyUser = (options = {}) => {
3119
1978
  user: jwtUser,
3120
1979
  token
3121
1980
  } = useCrudifyDataContext();
3122
- const [userProfile, setUserProfile] = useState9(null);
3123
- const [profileLoading, setProfileLoading] = useState9(false);
3124
- const [profileError, setProfileError] = useState9(null);
3125
- const [extendedData, setExtendedData] = useState9({
1981
+ const [userProfile, setUserProfile] = useState8(null);
1982
+ const [profileLoading, setProfileLoading] = useState8(false);
1983
+ const [profileError, setProfileError] = useState8(null);
1984
+ const [extendedData, setExtendedData] = useState8({
3126
1985
  fullProfile: null,
3127
1986
  totalFields: 0,
3128
1987
  displayData: {}
@@ -3131,7 +1990,7 @@ var useCrudifyUser = (options = {}) => {
3131
1990
  const mountedRef = useRef3(true);
3132
1991
  const requestIdRef = useRef3(0);
3133
1992
  const retryCountRef = useRef3(0);
3134
- const getUserInfoFromJWT = useCallback3(() => {
1993
+ const getUserInfoFromJWT = useCallback2(() => {
3135
1994
  if (!jwtUser) {
3136
1995
  return {
3137
1996
  userEmail: null,
@@ -3145,7 +2004,7 @@ var useCrudifyUser = (options = {}) => {
3145
2004
  userIdentifier: jwtUser["cognito:username"] || jwtUser.email || jwtUser.sub || null
3146
2005
  };
3147
2006
  }, [jwtUser]);
3148
- const clearProfile = useCallback3(() => {
2007
+ const clearProfile = useCallback2(() => {
3149
2008
  setUserProfile(null);
3150
2009
  setProfileError(null);
3151
2010
  setProfileLoading(false);
@@ -3156,7 +2015,7 @@ var useCrudifyUser = (options = {}) => {
3156
2015
  });
3157
2016
  retryCountRef.current = 0;
3158
2017
  }, []);
3159
- const refreshProfile = useCallback3(async () => {
2018
+ const refreshProfile = useCallback2(async () => {
3160
2019
  const { userEmail: userEmail2 } = getUserInfoFromJWT();
3161
2020
  console.log("\u{1F464} useCrudifyUser - Refreshing profile for:", userEmail2);
3162
2021
  if (!userEmail2) {
@@ -3185,7 +2044,7 @@ var useCrudifyUser = (options = {}) => {
3185
2044
  setProfileError(null);
3186
2045
  }
3187
2046
  console.log("\u{1F464} useCrudifyUser - Fetching profile data from database");
3188
- const response = await crudify5.readItems("users", {
2047
+ const response = await crudify3.readItems("users", {
3189
2048
  where: { email: userEmail2 },
3190
2049
  limit: 1
3191
2050
  });
@@ -3277,14 +2136,14 @@ var useCrudifyUser = (options = {}) => {
3277
2136
  }
3278
2137
  }
3279
2138
  }, [isInitialized, getUserInfoFromJWT, retryOnError, maxRetries]);
3280
- useEffect9(() => {
2139
+ useEffect8(() => {
3281
2140
  if (autoFetch && isAuthenticated && isInitialized) {
3282
2141
  refreshProfile();
3283
2142
  } else if (!isAuthenticated) {
3284
2143
  clearProfile();
3285
2144
  }
3286
2145
  }, [autoFetch, isAuthenticated, isInitialized, refreshProfile, clearProfile]);
3287
- useEffect9(() => {
2146
+ useEffect8(() => {
3288
2147
  mountedRef.current = true;
3289
2148
  return () => {
3290
2149
  mountedRef.current = false;
@@ -3313,18 +2172,18 @@ var useCrudifyUser = (options = {}) => {
3313
2172
  };
3314
2173
 
3315
2174
  // src/hooks/useCrudifyData.ts
3316
- import { useCallback as useCallback4 } from "react";
3317
- import crudify6 from "@nocios/crudify-browser";
2175
+ import { useCallback as useCallback3 } from "react";
2176
+ import crudify4 from "@nocios/crudify-browser";
3318
2177
  var useCrudifyData = () => {
3319
2178
  const {
3320
2179
  isInitialized,
3321
2180
  isInitializing,
3322
2181
  initializationError
3323
2182
  } = useCrudifyDataContext();
3324
- const isReady = useCallback4(() => {
2183
+ const isReady = useCallback3(() => {
3325
2184
  return isInitialized && !initializationError && !isInitializing;
3326
2185
  }, [isInitialized, initializationError, isInitializing]);
3327
- const waitForReady = useCallback4(async () => {
2186
+ const waitForReady = useCallback3(async () => {
3328
2187
  if (isReady()) return;
3329
2188
  if (initializationError) {
3330
2189
  throw new Error(`Crudify initialization failed: ${initializationError}`);
@@ -3348,13 +2207,13 @@ var useCrudifyData = () => {
3348
2207
  check();
3349
2208
  });
3350
2209
  }, [isReady, initializationError]);
3351
- const ensureReady = useCallback4((operationName) => {
2210
+ const ensureReady = useCallback3((operationName) => {
3352
2211
  if (!isReady()) {
3353
2212
  const error = initializationError ? `Crudify initialization failed: ${initializationError}` : isInitializing ? "Crudify is still initializing. Please wait." : "Crudify is not initialized";
3354
2213
  throw new Error(`Cannot perform ${operationName}: ${error}`);
3355
2214
  }
3356
2215
  }, [isReady, initializationError, isInitializing]);
3357
- const readItems = useCallback4(async (moduleKey, filter, options) => {
2216
+ const readItems = useCallback3(async (moduleKey, filter, options) => {
3358
2217
  ensureReady("readItems");
3359
2218
  console.log("\u{1F4CA} useCrudifyData - readItems called with:");
3360
2219
  console.log(" - moduleKey:", moduleKey);
@@ -3365,7 +2224,7 @@ var useCrudifyData = () => {
3365
2224
  console.error(new Error().stack);
3366
2225
  }
3367
2226
  try {
3368
- const response = await crudify6.readItems(moduleKey, filter || {}, options);
2227
+ const response = await crudify4.readItems(moduleKey, filter || {}, options);
3369
2228
  console.log("\u{1F4CA} useCrudifyData - readItems response:", response);
3370
2229
  return response;
3371
2230
  } catch (error) {
@@ -3373,11 +2232,11 @@ var useCrudifyData = () => {
3373
2232
  throw error;
3374
2233
  }
3375
2234
  }, [ensureReady]);
3376
- const readItem = useCallback4(async (moduleKey, filter, options) => {
2235
+ const readItem = useCallback3(async (moduleKey, filter, options) => {
3377
2236
  ensureReady("readItem");
3378
2237
  console.log("\u{1F4CA} useCrudifyData - readItem:", { moduleKey, filter, options });
3379
2238
  try {
3380
- const response = await crudify6.readItem(moduleKey, filter, options);
2239
+ const response = await crudify4.readItem(moduleKey, filter, options);
3381
2240
  console.log("\u{1F4CA} useCrudifyData - readItem response:", response);
3382
2241
  return response;
3383
2242
  } catch (error) {
@@ -3385,11 +2244,11 @@ var useCrudifyData = () => {
3385
2244
  throw error;
3386
2245
  }
3387
2246
  }, [ensureReady]);
3388
- const createItem = useCallback4(async (moduleKey, data, options) => {
2247
+ const createItem = useCallback3(async (moduleKey, data, options) => {
3389
2248
  ensureReady("createItem");
3390
2249
  console.log("\u{1F4CA} useCrudifyData - createItem:", { moduleKey, data, options });
3391
2250
  try {
3392
- const response = await crudify6.createItem(moduleKey, data, options);
2251
+ const response = await crudify4.createItem(moduleKey, data, options);
3393
2252
  console.log("\u{1F4CA} useCrudifyData - createItem response:", response);
3394
2253
  return response;
3395
2254
  } catch (error) {
@@ -3397,11 +2256,11 @@ var useCrudifyData = () => {
3397
2256
  throw error;
3398
2257
  }
3399
2258
  }, [ensureReady]);
3400
- const updateItem = useCallback4(async (moduleKey, data, options) => {
2259
+ const updateItem = useCallback3(async (moduleKey, data, options) => {
3401
2260
  ensureReady("updateItem");
3402
2261
  console.log("\u{1F4CA} useCrudifyData - updateItem:", { moduleKey, data, options });
3403
2262
  try {
3404
- const response = await crudify6.updateItem(moduleKey, data, options);
2263
+ const response = await crudify4.updateItem(moduleKey, data, options);
3405
2264
  console.log("\u{1F4CA} useCrudifyData - updateItem response:", response);
3406
2265
  return response;
3407
2266
  } catch (error) {
@@ -3409,11 +2268,11 @@ var useCrudifyData = () => {
3409
2268
  throw error;
3410
2269
  }
3411
2270
  }, [ensureReady]);
3412
- const deleteItem = useCallback4(async (moduleKey, id, options) => {
2271
+ const deleteItem = useCallback3(async (moduleKey, id, options) => {
3413
2272
  ensureReady("deleteItem");
3414
2273
  console.log("\u{1F4CA} useCrudifyData - deleteItem:", { moduleKey, id, options });
3415
2274
  try {
3416
- const response = await crudify6.deleteItem(moduleKey, id, options);
2275
+ const response = await crudify4.deleteItem(moduleKey, id, options);
3417
2276
  console.log("\u{1F4CA} useCrudifyData - deleteItem response:", response);
3418
2277
  return response;
3419
2278
  } catch (error) {
@@ -3421,11 +2280,11 @@ var useCrudifyData = () => {
3421
2280
  throw error;
3422
2281
  }
3423
2282
  }, [ensureReady]);
3424
- const transaction = useCallback4(async (operations, options) => {
2283
+ const transaction = useCallback3(async (operations, options) => {
3425
2284
  ensureReady("transaction");
3426
2285
  console.log("\u{1F4CA} useCrudifyData - transaction:", { operations, options });
3427
2286
  try {
3428
- const response = await crudify6.transaction(operations, options);
2287
+ const response = await crudify4.transaction(operations, options);
3429
2288
  console.log("\u{1F4CA} useCrudifyData - transaction response:", response);
3430
2289
  return response;
3431
2290
  } catch (error) {
@@ -3433,11 +2292,11 @@ var useCrudifyData = () => {
3433
2292
  throw error;
3434
2293
  }
3435
2294
  }, [ensureReady]);
3436
- const login = useCallback4(async (email, password) => {
2295
+ const login = useCallback3(async (email, password) => {
3437
2296
  ensureReady("login");
3438
2297
  console.log("\u{1F4CA} useCrudifyData - login:", { email });
3439
2298
  try {
3440
- const response = await crudify6.login(email, password);
2299
+ const response = await crudify4.login(email, password);
3441
2300
  console.log("\u{1F4CA} useCrudifyData - login response:", response);
3442
2301
  return response;
3443
2302
  } catch (error) {
@@ -3487,8 +2346,8 @@ var useCrudifyConfig = () => {
3487
2346
  };
3488
2347
 
3489
2348
  // src/hooks/useCrudifyInstance.ts
3490
- import { useCallback as useCallback5 } from "react";
3491
- import crudify7 from "@nocios/crudify-browser";
2349
+ import { useCallback as useCallback4 } from "react";
2350
+ import crudify5 from "@nocios/crudify-browser";
3492
2351
  var useCrudifyInstance = () => {
3493
2352
  const {
3494
2353
  isInitialized,
@@ -3496,43 +2355,47 @@ var useCrudifyInstance = () => {
3496
2355
  initializationError
3497
2356
  } = useCrudifyDataContext();
3498
2357
  const isReady = isInitialized && !initializationError && !isInitializing;
3499
- const waitForReady = useCallback5(async () => {
3500
- if (isReady) return;
2358
+ const waitForReady = useCallback4(async () => {
2359
+ console.log("\u{1F504} useCrudifyInstance - waitForReady: Starting wait");
2360
+ console.log(" - isReady:", isReady);
2361
+ console.log(" - isInitialized:", isInitialized);
2362
+ console.log(" - isInitializing:", isInitializing);
2363
+ console.log(" - initializationError:", initializationError);
2364
+ if (isReady) {
2365
+ console.log("\u2705 useCrudifyInstance - waitForReady: Already ready, returning immediately");
2366
+ return;
2367
+ }
3501
2368
  if (initializationError) {
3502
2369
  throw new Error(`Crudify initialization failed: ${initializationError}`);
3503
2370
  }
3504
- return new Promise((resolve, reject) => {
3505
- const maxWaitTime = 1e4;
3506
- const checkInterval = 100;
3507
- let elapsed = 0;
3508
- const check = () => {
3509
- if (isInitialized && !initializationError && !isInitializing) {
3510
- resolve();
3511
- } else if (initializationError) {
3512
- reject(new Error(`Crudify initialization failed: ${initializationError}`));
3513
- } else if (elapsed >= maxWaitTime) {
3514
- reject(new Error("Timeout waiting for crudify initialization"));
3515
- } else {
3516
- elapsed += checkInterval;
3517
- setTimeout(check, checkInterval);
3518
- }
3519
- };
3520
- check();
3521
- });
2371
+ try {
2372
+ console.log("\u{1F504} useCrudifyInstance - waitForReady: Using CrudifyInitializer.waitForInitialization()");
2373
+ const { crudifyInitializer: crudifyInitializer2 } = await import("./CrudifyDataProvider-F6UCGYUF.mjs");
2374
+ await crudifyInitializer2.waitForInitialization();
2375
+ console.log("\u2705 useCrudifyInstance - waitForReady: CrudifyInitializer completed");
2376
+ if (!crudifyInitializer2.isReady()) {
2377
+ const error = crudifyInitializer2.getError();
2378
+ throw new Error(`Crudify initialization failed: ${error || "Unknown error"}`);
2379
+ }
2380
+ console.log("\u2705 useCrudifyInstance - waitForReady: Verification successful");
2381
+ } catch (error) {
2382
+ console.error("\u274C useCrudifyInstance - waitForReady: Error during wait:", error);
2383
+ throw error;
2384
+ }
3522
2385
  }, [isReady, initializationError, isInitialized, isInitializing]);
3523
- const ensureReady = useCallback5(async (operationName) => {
2386
+ const ensureReady = useCallback4(async (operationName) => {
3524
2387
  if (!isReady) {
3525
2388
  console.log(`\u{1F504} useCrudifyInstance - ${operationName}: Waiting for crudify to be ready...`);
3526
2389
  await waitForReady();
3527
2390
  console.log(`\u2705 useCrudifyInstance - ${operationName}: Crudify is ready`);
3528
2391
  }
3529
2392
  }, [isReady, waitForReady]);
3530
- const getStructure = useCallback5(async (options) => {
2393
+ const getStructure = useCallback4(async (options) => {
3531
2394
  console.log("\u{1F4E1} useCrudifyInstance - getStructure: Starting");
3532
2395
  await ensureReady("getStructure");
3533
2396
  try {
3534
2397
  console.log("\u{1F4E1} useCrudifyInstance - getStructure: Calling crudify.getStructure");
3535
- const response = await crudify7.getStructure(options);
2398
+ const response = await crudify5.getStructure(options);
3536
2399
  console.log("\u{1F4E1} useCrudifyInstance - getStructure: Response received", response);
3537
2400
  return response;
3538
2401
  } catch (error) {
@@ -3540,12 +2403,12 @@ var useCrudifyInstance = () => {
3540
2403
  throw error;
3541
2404
  }
3542
2405
  }, [ensureReady]);
3543
- const getStructurePublic = useCallback5(async (options) => {
2406
+ const getStructurePublic = useCallback4(async (options) => {
3544
2407
  console.log("\u{1F4E1} useCrudifyInstance - getStructurePublic: Starting");
3545
2408
  await ensureReady("getStructurePublic");
3546
2409
  try {
3547
2410
  console.log("\u{1F4E1} useCrudifyInstance - getStructurePublic: Calling crudify.getStructurePublic");
3548
- const response = await crudify7.getStructurePublic(options);
2411
+ const response = await crudify5.getStructurePublic(options);
3549
2412
  console.log("\u{1F4E1} useCrudifyInstance - getStructurePublic: Response received", response);
3550
2413
  return response;
3551
2414
  } catch (error) {
@@ -3553,74 +2416,74 @@ var useCrudifyInstance = () => {
3553
2416
  throw error;
3554
2417
  }
3555
2418
  }, [ensureReady]);
3556
- const readItems = useCallback5(async (moduleKey, filter, options) => {
2419
+ const readItems = useCallback4(async (moduleKey, filter, options) => {
3557
2420
  await ensureReady("readItems");
3558
2421
  if (moduleKey === "__test_connection__") {
3559
2422
  console.error("\u{1F6A8} FOUND TEST CONNECTION CALL in useCrudifyInstance! Stack trace:");
3560
2423
  console.error(new Error().stack);
3561
2424
  }
3562
2425
  try {
3563
- const response = await crudify7.readItems(moduleKey, filter || {}, options);
2426
+ const response = await crudify5.readItems(moduleKey, filter || {}, options);
3564
2427
  return response;
3565
2428
  } catch (error) {
3566
2429
  console.error("\u{1F4CA} useCrudifyInstance - readItems error:", error);
3567
2430
  throw error;
3568
2431
  }
3569
2432
  }, [ensureReady]);
3570
- const readItem = useCallback5(async (moduleKey, filter, options) => {
2433
+ const readItem = useCallback4(async (moduleKey, filter, options) => {
3571
2434
  await ensureReady("readItem");
3572
2435
  try {
3573
- const response = await crudify7.readItem(moduleKey, filter, options);
2436
+ const response = await crudify5.readItem(moduleKey, filter, options);
3574
2437
  return response;
3575
2438
  } catch (error) {
3576
2439
  console.error("\u{1F4CA} useCrudifyInstance - readItem error:", error);
3577
2440
  throw error;
3578
2441
  }
3579
2442
  }, [ensureReady]);
3580
- const createItem = useCallback5(async (moduleKey, data, options) => {
2443
+ const createItem = useCallback4(async (moduleKey, data, options) => {
3581
2444
  await ensureReady("createItem");
3582
2445
  try {
3583
- const response = await crudify7.createItem(moduleKey, data, options);
2446
+ const response = await crudify5.createItem(moduleKey, data, options);
3584
2447
  return response;
3585
2448
  } catch (error) {
3586
2449
  console.error("\u{1F4CA} useCrudifyInstance - createItem error:", error);
3587
2450
  throw error;
3588
2451
  }
3589
2452
  }, [ensureReady]);
3590
- const updateItem = useCallback5(async (moduleKey, data, options) => {
2453
+ const updateItem = useCallback4(async (moduleKey, data, options) => {
3591
2454
  await ensureReady("updateItem");
3592
2455
  try {
3593
- const response = await crudify7.updateItem(moduleKey, data, options);
2456
+ const response = await crudify5.updateItem(moduleKey, data, options);
3594
2457
  return response;
3595
2458
  } catch (error) {
3596
2459
  console.error("\u{1F4CA} useCrudifyInstance - updateItem error:", error);
3597
2460
  throw error;
3598
2461
  }
3599
2462
  }, [ensureReady]);
3600
- const deleteItem = useCallback5(async (moduleKey, id, options) => {
2463
+ const deleteItem = useCallback4(async (moduleKey, id, options) => {
3601
2464
  await ensureReady("deleteItem");
3602
2465
  try {
3603
- const response = await crudify7.deleteItem(moduleKey, id, options);
2466
+ const response = await crudify5.deleteItem(moduleKey, id, options);
3604
2467
  return response;
3605
2468
  } catch (error) {
3606
2469
  console.error("\u{1F4CA} useCrudifyInstance - deleteItem error:", error);
3607
2470
  throw error;
3608
2471
  }
3609
2472
  }, [ensureReady]);
3610
- const transaction = useCallback5(async (operations, options) => {
2473
+ const transaction = useCallback4(async (operations, options) => {
3611
2474
  await ensureReady("transaction");
3612
2475
  try {
3613
- const response = await crudify7.transaction(operations, options);
2476
+ const response = await crudify5.transaction(operations, options);
3614
2477
  return response;
3615
2478
  } catch (error) {
3616
2479
  console.error("\u{1F4CA} useCrudifyInstance - transaction error:", error);
3617
2480
  throw error;
3618
2481
  }
3619
2482
  }, [ensureReady]);
3620
- const login = useCallback5(async (email, password) => {
2483
+ const login = useCallback4(async (email, password) => {
3621
2484
  await ensureReady("login");
3622
2485
  try {
3623
- const response = await crudify7.login(email, password);
2486
+ const response = await crudify5.login(email, password);
3624
2487
  return response;
3625
2488
  } catch (error) {
3626
2489
  console.error("\u{1F4CA} useCrudifyInstance - login error:", error);
@@ -3647,6 +2510,33 @@ var useCrudifyInstance = () => {
3647
2510
  waitForReady
3648
2511
  };
3649
2512
  };
2513
+ var getCrudifyInstanceAsync = async () => {
2514
+ console.log("\u{1F504} getCrudifyInstanceAsync - Starting");
2515
+ const { crudifyInitializer: crudifyInitializer2 } = await import("./CrudifyDataProvider-F6UCGYUF.mjs");
2516
+ console.log("\u{1F504} getCrudifyInstanceAsync - Checking if ready");
2517
+ console.log(" - crudifyInitializer.isReady():", crudifyInitializer2.isReady());
2518
+ console.log(" - crudifyInitializer.getStatus():", crudifyInitializer2.getStatus());
2519
+ if (!crudifyInitializer2.isReady()) {
2520
+ console.log("\u{1F504} getCrudifyInstanceAsync - Waiting for crudify initialization...");
2521
+ await crudifyInitializer2.waitForInitialization();
2522
+ if (!crudifyInitializer2.isReady()) {
2523
+ const error = crudifyInitializer2.getError();
2524
+ throw new Error(`Crudify initialization failed: ${error || "Unknown error after waiting"}`);
2525
+ }
2526
+ console.log("\u2705 getCrudifyInstanceAsync - Crudify is ready after waiting");
2527
+ } else {
2528
+ console.log("\u2705 getCrudifyInstanceAsync - Already ready, no wait needed");
2529
+ }
2530
+ console.log("\u2705 getCrudifyInstanceAsync - Returning crudify instance");
2531
+ return crudify5;
2532
+ };
2533
+ var getCrudifyInstanceSync = async () => {
2534
+ const { crudifyInitializer: crudifyInitializer2 } = await import("./CrudifyDataProvider-F6UCGYUF.mjs");
2535
+ if (!crudifyInitializer2.isReady()) {
2536
+ throw new Error("Crudify not ready. Use getCrudifyInstanceAsync() or call this from within a React component using useCrudifyInstance()");
2537
+ }
2538
+ return crudify5;
2539
+ };
3650
2540
  export {
3651
2541
  CrudifyDataProvider,
3652
2542
  CrudifyLogin_default as CrudifyLogin,
@@ -3658,6 +2548,8 @@ export {
3658
2548
  crudifyInitializer,
3659
2549
  decodeJwtSafely,
3660
2550
  getCookie,
2551
+ getCrudifyInstanceAsync,
2552
+ getCrudifyInstanceSync,
3661
2553
  getCurrentUserEmail,
3662
2554
  getErrorMessage,
3663
2555
  handleCrudifyError,