@nocios/crudify-ui 1.2.16 → 1.2.22
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.
|
@@ -32,13 +32,17 @@ var _ConfigurationManager = class _ConfigurationManager {
|
|
|
32
32
|
* Resolve configuration from all sources with proper priority
|
|
33
33
|
*/
|
|
34
34
|
resolveConfig(propsConfig = {}) {
|
|
35
|
+
console.log("\u{1F50D} ConfigurationManager - resolveConfig called with props:", propsConfig);
|
|
35
36
|
if (this.resolvedConfig && this.isConfigStillValid(propsConfig)) {
|
|
37
|
+
console.log("\u{1F50D} ConfigurationManager - Using cached config");
|
|
36
38
|
return this.resolvedConfig;
|
|
37
39
|
}
|
|
38
40
|
try {
|
|
39
41
|
this.configError = null;
|
|
40
42
|
const envConfig = this.getEnvConfig();
|
|
41
43
|
const cookieConfig = this.getCookieConfig();
|
|
44
|
+
console.log("\u{1F50D} ConfigurationManager - envConfig:", envConfig);
|
|
45
|
+
console.log("\u{1F50D} ConfigurationManager - cookieConfig:", cookieConfig);
|
|
42
46
|
const configSource = {
|
|
43
47
|
env: "default",
|
|
44
48
|
publicApiKey: "default",
|
|
@@ -53,6 +57,10 @@ var _ConfigurationManager = class _ConfigurationManager {
|
|
|
53
57
|
const appName = this.resolveValue("appName", propsConfig.appName, envConfig.appName, cookieConfig.appName, "Crudify App", configSource);
|
|
54
58
|
const logo = this.resolveValue("logo", propsConfig.logo, envConfig.logo, cookieConfig.logo, "", configSource);
|
|
55
59
|
const colors = this.resolveValue("colors", propsConfig.colors, envConfig.colors, cookieConfig.colors, {}, configSource);
|
|
60
|
+
console.log("\u{1F50D} ConfigurationManager - Resolved values:");
|
|
61
|
+
console.log(" - publicApiKey:", publicApiKey, "from:", configSource.publicApiKey);
|
|
62
|
+
console.log(" - env:", env, "from:", configSource.env);
|
|
63
|
+
console.log(" - loginActions:", loginActions, "from:", configSource.loginActions);
|
|
56
64
|
if (!publicApiKey) {
|
|
57
65
|
throw new Error(
|
|
58
66
|
"publicApiKey es requerido. Proporci\xF3nalo v\xEDa:\n1. Props: <CrudifyDataProvider publicApiKey={...} />\n2. Variable de entorno: VITE_TEST_PUBLIC_API_KEY\n3. Cookie: publicApiKey"
|
|
@@ -945,6 +953,14 @@ var CrudifyDataProvider = ({
|
|
|
945
953
|
logo,
|
|
946
954
|
colors
|
|
947
955
|
}) => {
|
|
956
|
+
console.log("\u{1F50D} CrudifyDataProvider - Received props:", {
|
|
957
|
+
env,
|
|
958
|
+
publicApiKey,
|
|
959
|
+
loginActions,
|
|
960
|
+
appName,
|
|
961
|
+
logo,
|
|
962
|
+
colors
|
|
963
|
+
});
|
|
948
964
|
const [config, setConfig] = useState(null);
|
|
949
965
|
const [isConfigured, setIsConfigured] = useState(false);
|
|
950
966
|
const [configError, setConfigError] = useState(null);
|
package/dist/index.js
CHANGED
|
@@ -189,13 +189,17 @@ var init_ConfigurationManager = __esm({
|
|
|
189
189
|
* Resolve configuration from all sources with proper priority
|
|
190
190
|
*/
|
|
191
191
|
resolveConfig(propsConfig = {}) {
|
|
192
|
+
console.log("\u{1F50D} ConfigurationManager - resolveConfig called with props:", propsConfig);
|
|
192
193
|
if (this.resolvedConfig && this.isConfigStillValid(propsConfig)) {
|
|
194
|
+
console.log("\u{1F50D} ConfigurationManager - Using cached config");
|
|
193
195
|
return this.resolvedConfig;
|
|
194
196
|
}
|
|
195
197
|
try {
|
|
196
198
|
this.configError = null;
|
|
197
199
|
const envConfig = this.getEnvConfig();
|
|
198
200
|
const cookieConfig = this.getCookieConfig();
|
|
201
|
+
console.log("\u{1F50D} ConfigurationManager - envConfig:", envConfig);
|
|
202
|
+
console.log("\u{1F50D} ConfigurationManager - cookieConfig:", cookieConfig);
|
|
199
203
|
const configSource = {
|
|
200
204
|
env: "default",
|
|
201
205
|
publicApiKey: "default",
|
|
@@ -210,6 +214,10 @@ var init_ConfigurationManager = __esm({
|
|
|
210
214
|
const appName = this.resolveValue("appName", propsConfig.appName, envConfig.appName, cookieConfig.appName, "Crudify App", configSource);
|
|
211
215
|
const logo = this.resolveValue("logo", propsConfig.logo, envConfig.logo, cookieConfig.logo, "", configSource);
|
|
212
216
|
const colors = this.resolveValue("colors", propsConfig.colors, envConfig.colors, cookieConfig.colors, {}, configSource);
|
|
217
|
+
console.log("\u{1F50D} ConfigurationManager - Resolved values:");
|
|
218
|
+
console.log(" - publicApiKey:", publicApiKey, "from:", configSource.publicApiKey);
|
|
219
|
+
console.log(" - env:", env, "from:", configSource.env);
|
|
220
|
+
console.log(" - loginActions:", loginActions, "from:", configSource.loginActions);
|
|
213
221
|
if (!publicApiKey) {
|
|
214
222
|
throw new Error(
|
|
215
223
|
"publicApiKey es requerido. Proporci\xF3nalo v\xEDa:\n1. Props: <CrudifyDataProvider publicApiKey={...} />\n2. Variable de entorno: VITE_TEST_PUBLIC_API_KEY\n3. Cookie: publicApiKey"
|
|
@@ -1029,6 +1037,14 @@ var init_CrudifyDataProvider = __esm({
|
|
|
1029
1037
|
logo,
|
|
1030
1038
|
colors
|
|
1031
1039
|
}) => {
|
|
1040
|
+
console.log("\u{1F50D} CrudifyDataProvider - Received props:", {
|
|
1041
|
+
env,
|
|
1042
|
+
publicApiKey,
|
|
1043
|
+
loginActions,
|
|
1044
|
+
appName,
|
|
1045
|
+
logo,
|
|
1046
|
+
colors
|
|
1047
|
+
});
|
|
1032
1048
|
const [config, setConfig] = (0, import_react5.useState)(null);
|
|
1033
1049
|
const [isConfigured, setIsConfigured] = (0, import_react5.useState)(false);
|
|
1034
1050
|
const [configError, setConfigError] = (0, import_react5.useState)(null);
|
|
@@ -1365,13 +1381,18 @@ var CrudifyProvider = ({ config, children }) => {
|
|
|
1365
1381
|
const [error, setError] = (0, import_react3.useState)(null);
|
|
1366
1382
|
const [isInitialized, setIsInitialized] = (0, import_react3.useState)(false);
|
|
1367
1383
|
const [initializationKey, setInitializationKey] = (0, import_react3.useState)("");
|
|
1384
|
+
console.log("\u{1F50D} CrudifyProvider - Received config:", config);
|
|
1368
1385
|
(0, import_react3.useEffect)(() => {
|
|
1386
|
+
console.log("\u{1F50D} CrudifyProvider - useEffect - config.publicApiKey:", config.publicApiKey);
|
|
1387
|
+
console.log("\u{1F50D} CrudifyProvider - useEffect - full config:", config);
|
|
1369
1388
|
if (!config.publicApiKey) {
|
|
1389
|
+
console.log("\u274C CrudifyProvider - No publicApiKey provided, setting error");
|
|
1370
1390
|
setError("No publicApiKey provided");
|
|
1371
1391
|
setIsLoading(false);
|
|
1372
1392
|
setIsInitialized(false);
|
|
1373
1393
|
return;
|
|
1374
1394
|
}
|
|
1395
|
+
console.log("\u2705 CrudifyProvider - publicApiKey found, proceeding with initialization");
|
|
1375
1396
|
const currentKey = `${config.publicApiKey}-${config.env}`;
|
|
1376
1397
|
if (currentKey === initializationKey && isInitialized) {
|
|
1377
1398
|
setIsLoading(false);
|
|
@@ -2767,13 +2788,43 @@ var CrudifyInitializer2 = ({ children, fallback }) => {
|
|
|
2767
2788
|
// src/components/CrudifyLogin/hooks/useCrudifyLogin.ts
|
|
2768
2789
|
var import_react10 = require("react");
|
|
2769
2790
|
init_cookies();
|
|
2791
|
+
|
|
2792
|
+
// src/hooks/useCrudifyConfig.ts
|
|
2793
|
+
init_CrudifyDataProvider();
|
|
2794
|
+
var useCrudifyConfig = () => {
|
|
2795
|
+
const {
|
|
2796
|
+
config,
|
|
2797
|
+
isConfigured,
|
|
2798
|
+
configError,
|
|
2799
|
+
configSource,
|
|
2800
|
+
refreshConfig,
|
|
2801
|
+
getDebugInfo
|
|
2802
|
+
} = useCrudifyDataContext();
|
|
2803
|
+
return {
|
|
2804
|
+
config,
|
|
2805
|
+
isConfigured,
|
|
2806
|
+
configError,
|
|
2807
|
+
configSource,
|
|
2808
|
+
rawConfig: config?.rawConfig || {},
|
|
2809
|
+
refreshConfig,
|
|
2810
|
+
getDebugInfo
|
|
2811
|
+
};
|
|
2812
|
+
};
|
|
2813
|
+
|
|
2814
|
+
// src/components/CrudifyLogin/hooks/useCrudifyLogin.ts
|
|
2770
2815
|
var useCrudifyLogin = (config, _options = {}) => {
|
|
2816
|
+
const { config: dataProviderConfig, isConfigured } = useCrudifyConfig();
|
|
2817
|
+
console.log("\u{1F50D} useCrudifyLogin - Input config:", config);
|
|
2818
|
+
console.log("\u{1F50D} useCrudifyLogin - DataProvider config:", dataProviderConfig);
|
|
2819
|
+
console.log("\u{1F50D} useCrudifyLogin - IsConfigured:", isConfigured);
|
|
2771
2820
|
const finalConfig = (0, import_react10.useMemo)(() => {
|
|
2772
|
-
const publicApiKey = config.publicApiKey || getCookie("publicApiKey") || null;
|
|
2773
|
-
|
|
2821
|
+
const publicApiKey = config.publicApiKey || (isConfigured ? dataProviderConfig?.publicApiKey : null) || getCookie("publicApiKey") || null;
|
|
2822
|
+
console.log("\u{1F50D} useCrudifyLogin - Resolved publicApiKey:", publicApiKey);
|
|
2823
|
+
console.log("\u{1F50D} useCrudifyLogin - Sources - props:", config.publicApiKey, "dataProvider:", dataProviderConfig?.publicApiKey, "cookie:", getCookie("publicApiKey"));
|
|
2824
|
+
const rawEnv = config.env || (isConfigured ? dataProviderConfig?.env : null) || getCookie("environment") || "prod";
|
|
2774
2825
|
const env = ["dev", "stg", "prod"].includes(rawEnv) ? rawEnv : "prod";
|
|
2775
|
-
const appName = config.appName || getCookie("appName") || "Crudia";
|
|
2776
|
-
const loginActions = config.loginActions || (() => {
|
|
2826
|
+
const appName = config.appName || (isConfigured ? dataProviderConfig?.appName : null) || getCookie("appName") || "Crudia";
|
|
2827
|
+
const loginActions = config.loginActions || (isConfigured ? dataProviderConfig?.loginActions : null) || (() => {
|
|
2777
2828
|
try {
|
|
2778
2829
|
const cookieValue = getCookie("loginActions");
|
|
2779
2830
|
return cookieValue ? cookieValue.split(",").map((action) => action.trim()).filter(Boolean) : [];
|
|
@@ -2781,13 +2832,15 @@ var useCrudifyLogin = (config, _options = {}) => {
|
|
|
2781
2832
|
return [];
|
|
2782
2833
|
}
|
|
2783
2834
|
})();
|
|
2784
|
-
|
|
2835
|
+
const finalResult = {
|
|
2785
2836
|
publicApiKey,
|
|
2786
2837
|
env,
|
|
2787
2838
|
appName,
|
|
2788
2839
|
loginActions
|
|
2789
2840
|
};
|
|
2790
|
-
|
|
2841
|
+
console.log("\u{1F50D} useCrudifyLogin - Final config result:", finalResult);
|
|
2842
|
+
return finalResult;
|
|
2843
|
+
}, [config, dataProviderConfig, isConfigured]);
|
|
2791
2844
|
return { config: finalConfig };
|
|
2792
2845
|
};
|
|
2793
2846
|
|
|
@@ -2931,8 +2984,8 @@ var useUserProfile = (options = {}) => {
|
|
|
2931
2984
|
setError(null);
|
|
2932
2985
|
}
|
|
2933
2986
|
const response = await import_crudify_browser4.default.readItems("users", {
|
|
2934
|
-
|
|
2935
|
-
limit: 1
|
|
2987
|
+
filter: { email: userEmail },
|
|
2988
|
+
pagination: { limit: 1 }
|
|
2936
2989
|
});
|
|
2937
2990
|
if (currentRequestId === requestIdRef.current && mountedRef.current && !abortController.signal.aborted) {
|
|
2938
2991
|
if (response.success && response.data && response.data.length > 0) {
|
|
@@ -2955,7 +3008,22 @@ var useUserProfile = (options = {}) => {
|
|
|
2955
3008
|
createdAt: userData.createdAt,
|
|
2956
3009
|
updatedAt: userData.updatedAt,
|
|
2957
3010
|
// Include any custom fields
|
|
2958
|
-
...Object.keys(userData).filter(
|
|
3011
|
+
...Object.keys(userData).filter(
|
|
3012
|
+
(key) => ![
|
|
3013
|
+
"id",
|
|
3014
|
+
"email",
|
|
3015
|
+
"username",
|
|
3016
|
+
"firstName",
|
|
3017
|
+
"lastName",
|
|
3018
|
+
"fullName",
|
|
3019
|
+
"role",
|
|
3020
|
+
"permissions",
|
|
3021
|
+
"isActive",
|
|
3022
|
+
"lastLogin",
|
|
3023
|
+
"createdAt",
|
|
3024
|
+
"updatedAt"
|
|
3025
|
+
].includes(key)
|
|
3026
|
+
).reduce((acc, key) => ({ ...acc, [key]: userData[key] }), {})
|
|
2959
3027
|
}
|
|
2960
3028
|
};
|
|
2961
3029
|
setExtendedData(additionalData);
|
|
@@ -3203,12 +3271,7 @@ var import_crudify_browser5 = __toESM(require("@nocios/crudify-browser"));
|
|
|
3203
3271
|
init_CrudifyDataProvider();
|
|
3204
3272
|
var useCrudifyUser = (options = {}) => {
|
|
3205
3273
|
const { autoFetch = true, retryOnError = false, maxRetries = 3 } = options;
|
|
3206
|
-
const {
|
|
3207
|
-
isAuthenticated,
|
|
3208
|
-
isInitialized,
|
|
3209
|
-
user: jwtUser,
|
|
3210
|
-
token
|
|
3211
|
-
} = useCrudifyDataContext();
|
|
3274
|
+
const { isAuthenticated, isInitialized, user: jwtUser, token } = useCrudifyDataContext();
|
|
3212
3275
|
const [userProfile, setUserProfile] = (0, import_react13.useState)(null);
|
|
3213
3276
|
const [profileLoading, setProfileLoading] = (0, import_react13.useState)(false);
|
|
3214
3277
|
const [profileError, setProfileError] = (0, import_react13.useState)(null);
|
|
@@ -3276,8 +3339,8 @@ var useCrudifyUser = (options = {}) => {
|
|
|
3276
3339
|
}
|
|
3277
3340
|
console.log("\u{1F464} useCrudifyUser - Fetching profile data from database");
|
|
3278
3341
|
const response = await import_crudify_browser5.default.readItems("users", {
|
|
3279
|
-
|
|
3280
|
-
limit: 1
|
|
3342
|
+
filter: { email: userEmail2 },
|
|
3343
|
+
pagination: { limit: 1 }
|
|
3281
3344
|
});
|
|
3282
3345
|
console.log("\u{1F464} useCrudifyUser - Database response:", response);
|
|
3283
3346
|
if (currentRequestId === requestIdRef.current && mountedRef.current && !abortController.signal.aborted) {
|
|
@@ -3301,20 +3364,22 @@ var useCrudifyUser = (options = {}) => {
|
|
|
3301
3364
|
createdAt: userData.createdAt,
|
|
3302
3365
|
updatedAt: userData.updatedAt,
|
|
3303
3366
|
// Include any custom fields
|
|
3304
|
-
...Object.keys(userData).filter(
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3367
|
+
...Object.keys(userData).filter(
|
|
3368
|
+
(key) => ![
|
|
3369
|
+
"id",
|
|
3370
|
+
"email",
|
|
3371
|
+
"username",
|
|
3372
|
+
"firstName",
|
|
3373
|
+
"lastName",
|
|
3374
|
+
"fullName",
|
|
3375
|
+
"role",
|
|
3376
|
+
"permissions",
|
|
3377
|
+
"isActive",
|
|
3378
|
+
"lastLogin",
|
|
3379
|
+
"createdAt",
|
|
3380
|
+
"updatedAt"
|
|
3381
|
+
].includes(key)
|
|
3382
|
+
).reduce((acc, key) => ({ ...acc, [key]: userData[key] }), {})
|
|
3318
3383
|
}
|
|
3319
3384
|
};
|
|
3320
3385
|
setExtendedData(extended);
|
|
@@ -3556,28 +3621,6 @@ var useCrudifyData = () => {
|
|
|
3556
3621
|
};
|
|
3557
3622
|
};
|
|
3558
3623
|
|
|
3559
|
-
// src/hooks/useCrudifyConfig.ts
|
|
3560
|
-
init_CrudifyDataProvider();
|
|
3561
|
-
var useCrudifyConfig = () => {
|
|
3562
|
-
const {
|
|
3563
|
-
config,
|
|
3564
|
-
isConfigured,
|
|
3565
|
-
configError,
|
|
3566
|
-
configSource,
|
|
3567
|
-
refreshConfig,
|
|
3568
|
-
getDebugInfo
|
|
3569
|
-
} = useCrudifyDataContext();
|
|
3570
|
-
return {
|
|
3571
|
-
config,
|
|
3572
|
-
isConfigured,
|
|
3573
|
-
configError,
|
|
3574
|
-
configSource,
|
|
3575
|
-
rawConfig: config?.rawConfig || {},
|
|
3576
|
-
refreshConfig,
|
|
3577
|
-
getDebugInfo
|
|
3578
|
-
};
|
|
3579
|
-
};
|
|
3580
|
-
|
|
3581
3624
|
// src/hooks/useCrudifyInstance.ts
|
|
3582
3625
|
var import_react15 = require("react");
|
|
3583
3626
|
var import_crudify_browser7 = __toESM(require("@nocios/crudify-browser"));
|
package/dist/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
secureSessionStorage,
|
|
11
11
|
tokenManager,
|
|
12
12
|
useCrudifyDataContext
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-UAYA54B3.mjs";
|
|
14
14
|
|
|
15
15
|
// src/index.ts
|
|
16
16
|
import { default as default2 } from "@nocios/crudify-browser";
|
|
@@ -117,13 +117,18 @@ var CrudifyProvider = ({ config, children }) => {
|
|
|
117
117
|
const [error, setError] = useState2(null);
|
|
118
118
|
const [isInitialized, setIsInitialized] = useState2(false);
|
|
119
119
|
const [initializationKey, setInitializationKey] = useState2("");
|
|
120
|
+
console.log("\u{1F50D} CrudifyProvider - Received config:", config);
|
|
120
121
|
useEffect2(() => {
|
|
122
|
+
console.log("\u{1F50D} CrudifyProvider - useEffect - config.publicApiKey:", config.publicApiKey);
|
|
123
|
+
console.log("\u{1F50D} CrudifyProvider - useEffect - full config:", config);
|
|
121
124
|
if (!config.publicApiKey) {
|
|
125
|
+
console.log("\u274C CrudifyProvider - No publicApiKey provided, setting error");
|
|
122
126
|
setError("No publicApiKey provided");
|
|
123
127
|
setIsLoading(false);
|
|
124
128
|
setIsInitialized(false);
|
|
125
129
|
return;
|
|
126
130
|
}
|
|
131
|
+
console.log("\u2705 CrudifyProvider - publicApiKey found, proceeding with initialization");
|
|
127
132
|
const currentKey = `${config.publicApiKey}-${config.env}`;
|
|
128
133
|
if (currentKey === initializationKey && isInitialized) {
|
|
129
134
|
setIsLoading(false);
|
|
@@ -1515,13 +1520,42 @@ var CrudifyInitializer = ({ children, fallback }) => {
|
|
|
1515
1520
|
|
|
1516
1521
|
// src/components/CrudifyLogin/hooks/useCrudifyLogin.ts
|
|
1517
1522
|
import { useMemo as useMemo2 } from "react";
|
|
1523
|
+
|
|
1524
|
+
// src/hooks/useCrudifyConfig.ts
|
|
1525
|
+
var useCrudifyConfig = () => {
|
|
1526
|
+
const {
|
|
1527
|
+
config,
|
|
1528
|
+
isConfigured,
|
|
1529
|
+
configError,
|
|
1530
|
+
configSource,
|
|
1531
|
+
refreshConfig,
|
|
1532
|
+
getDebugInfo
|
|
1533
|
+
} = useCrudifyDataContext();
|
|
1534
|
+
return {
|
|
1535
|
+
config,
|
|
1536
|
+
isConfigured,
|
|
1537
|
+
configError,
|
|
1538
|
+
configSource,
|
|
1539
|
+
rawConfig: config?.rawConfig || {},
|
|
1540
|
+
refreshConfig,
|
|
1541
|
+
getDebugInfo
|
|
1542
|
+
};
|
|
1543
|
+
};
|
|
1544
|
+
|
|
1545
|
+
// src/components/CrudifyLogin/hooks/useCrudifyLogin.ts
|
|
1518
1546
|
var useCrudifyLogin = (config, _options = {}) => {
|
|
1547
|
+
const { config: dataProviderConfig, isConfigured } = useCrudifyConfig();
|
|
1548
|
+
console.log("\u{1F50D} useCrudifyLogin - Input config:", config);
|
|
1549
|
+
console.log("\u{1F50D} useCrudifyLogin - DataProvider config:", dataProviderConfig);
|
|
1550
|
+
console.log("\u{1F50D} useCrudifyLogin - IsConfigured:", isConfigured);
|
|
1519
1551
|
const finalConfig = useMemo2(() => {
|
|
1520
|
-
const publicApiKey = config.publicApiKey || getCookie("publicApiKey") || null;
|
|
1521
|
-
|
|
1552
|
+
const publicApiKey = config.publicApiKey || (isConfigured ? dataProviderConfig?.publicApiKey : null) || getCookie("publicApiKey") || null;
|
|
1553
|
+
console.log("\u{1F50D} useCrudifyLogin - Resolved publicApiKey:", publicApiKey);
|
|
1554
|
+
console.log("\u{1F50D} useCrudifyLogin - Sources - props:", config.publicApiKey, "dataProvider:", dataProviderConfig?.publicApiKey, "cookie:", getCookie("publicApiKey"));
|
|
1555
|
+
const rawEnv = config.env || (isConfigured ? dataProviderConfig?.env : null) || getCookie("environment") || "prod";
|
|
1522
1556
|
const env = ["dev", "stg", "prod"].includes(rawEnv) ? rawEnv : "prod";
|
|
1523
|
-
const appName = config.appName || getCookie("appName") || "Crudia";
|
|
1524
|
-
const loginActions = config.loginActions || (() => {
|
|
1557
|
+
const appName = config.appName || (isConfigured ? dataProviderConfig?.appName : null) || getCookie("appName") || "Crudia";
|
|
1558
|
+
const loginActions = config.loginActions || (isConfigured ? dataProviderConfig?.loginActions : null) || (() => {
|
|
1525
1559
|
try {
|
|
1526
1560
|
const cookieValue = getCookie("loginActions");
|
|
1527
1561
|
return cookieValue ? cookieValue.split(",").map((action) => action.trim()).filter(Boolean) : [];
|
|
@@ -1529,13 +1563,15 @@ var useCrudifyLogin = (config, _options = {}) => {
|
|
|
1529
1563
|
return [];
|
|
1530
1564
|
}
|
|
1531
1565
|
})();
|
|
1532
|
-
|
|
1566
|
+
const finalResult = {
|
|
1533
1567
|
publicApiKey,
|
|
1534
1568
|
env,
|
|
1535
1569
|
appName,
|
|
1536
1570
|
loginActions
|
|
1537
1571
|
};
|
|
1538
|
-
|
|
1572
|
+
console.log("\u{1F50D} useCrudifyLogin - Final config result:", finalResult);
|
|
1573
|
+
return finalResult;
|
|
1574
|
+
}, [config, dataProviderConfig, isConfigured]);
|
|
1539
1575
|
return { config: finalConfig };
|
|
1540
1576
|
};
|
|
1541
1577
|
|
|
@@ -1704,8 +1740,8 @@ var useUserProfile = (options = {}) => {
|
|
|
1704
1740
|
setError(null);
|
|
1705
1741
|
}
|
|
1706
1742
|
const response = await crudify2.readItems("users", {
|
|
1707
|
-
|
|
1708
|
-
limit: 1
|
|
1743
|
+
filter: { email: userEmail },
|
|
1744
|
+
pagination: { limit: 1 }
|
|
1709
1745
|
});
|
|
1710
1746
|
if (currentRequestId === requestIdRef.current && mountedRef.current && !abortController.signal.aborted) {
|
|
1711
1747
|
if (response.success && response.data && response.data.length > 0) {
|
|
@@ -1728,7 +1764,22 @@ var useUserProfile = (options = {}) => {
|
|
|
1728
1764
|
createdAt: userData.createdAt,
|
|
1729
1765
|
updatedAt: userData.updatedAt,
|
|
1730
1766
|
// Include any custom fields
|
|
1731
|
-
...Object.keys(userData).filter(
|
|
1767
|
+
...Object.keys(userData).filter(
|
|
1768
|
+
(key) => ![
|
|
1769
|
+
"id",
|
|
1770
|
+
"email",
|
|
1771
|
+
"username",
|
|
1772
|
+
"firstName",
|
|
1773
|
+
"lastName",
|
|
1774
|
+
"fullName",
|
|
1775
|
+
"role",
|
|
1776
|
+
"permissions",
|
|
1777
|
+
"isActive",
|
|
1778
|
+
"lastLogin",
|
|
1779
|
+
"createdAt",
|
|
1780
|
+
"updatedAt"
|
|
1781
|
+
].includes(key)
|
|
1782
|
+
).reduce((acc, key) => ({ ...acc, [key]: userData[key] }), {})
|
|
1732
1783
|
}
|
|
1733
1784
|
};
|
|
1734
1785
|
setExtendedData(additionalData);
|
|
@@ -1972,12 +2023,7 @@ import { useState as useState8, useEffect as useEffect8, useCallback as useCallb
|
|
|
1972
2023
|
import crudify3 from "@nocios/crudify-browser";
|
|
1973
2024
|
var useCrudifyUser = (options = {}) => {
|
|
1974
2025
|
const { autoFetch = true, retryOnError = false, maxRetries = 3 } = options;
|
|
1975
|
-
const {
|
|
1976
|
-
isAuthenticated,
|
|
1977
|
-
isInitialized,
|
|
1978
|
-
user: jwtUser,
|
|
1979
|
-
token
|
|
1980
|
-
} = useCrudifyDataContext();
|
|
2026
|
+
const { isAuthenticated, isInitialized, user: jwtUser, token } = useCrudifyDataContext();
|
|
1981
2027
|
const [userProfile, setUserProfile] = useState8(null);
|
|
1982
2028
|
const [profileLoading, setProfileLoading] = useState8(false);
|
|
1983
2029
|
const [profileError, setProfileError] = useState8(null);
|
|
@@ -2045,8 +2091,8 @@ var useCrudifyUser = (options = {}) => {
|
|
|
2045
2091
|
}
|
|
2046
2092
|
console.log("\u{1F464} useCrudifyUser - Fetching profile data from database");
|
|
2047
2093
|
const response = await crudify3.readItems("users", {
|
|
2048
|
-
|
|
2049
|
-
limit: 1
|
|
2094
|
+
filter: { email: userEmail2 },
|
|
2095
|
+
pagination: { limit: 1 }
|
|
2050
2096
|
});
|
|
2051
2097
|
console.log("\u{1F464} useCrudifyUser - Database response:", response);
|
|
2052
2098
|
if (currentRequestId === requestIdRef.current && mountedRef.current && !abortController.signal.aborted) {
|
|
@@ -2070,20 +2116,22 @@ var useCrudifyUser = (options = {}) => {
|
|
|
2070
2116
|
createdAt: userData.createdAt,
|
|
2071
2117
|
updatedAt: userData.updatedAt,
|
|
2072
2118
|
// Include any custom fields
|
|
2073
|
-
...Object.keys(userData).filter(
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2119
|
+
...Object.keys(userData).filter(
|
|
2120
|
+
(key) => ![
|
|
2121
|
+
"id",
|
|
2122
|
+
"email",
|
|
2123
|
+
"username",
|
|
2124
|
+
"firstName",
|
|
2125
|
+
"lastName",
|
|
2126
|
+
"fullName",
|
|
2127
|
+
"role",
|
|
2128
|
+
"permissions",
|
|
2129
|
+
"isActive",
|
|
2130
|
+
"lastLogin",
|
|
2131
|
+
"createdAt",
|
|
2132
|
+
"updatedAt"
|
|
2133
|
+
].includes(key)
|
|
2134
|
+
).reduce((acc, key) => ({ ...acc, [key]: userData[key] }), {})
|
|
2087
2135
|
}
|
|
2088
2136
|
};
|
|
2089
2137
|
setExtendedData(extended);
|
|
@@ -2324,27 +2372,6 @@ var useCrudifyData = () => {
|
|
|
2324
2372
|
};
|
|
2325
2373
|
};
|
|
2326
2374
|
|
|
2327
|
-
// src/hooks/useCrudifyConfig.ts
|
|
2328
|
-
var useCrudifyConfig = () => {
|
|
2329
|
-
const {
|
|
2330
|
-
config,
|
|
2331
|
-
isConfigured,
|
|
2332
|
-
configError,
|
|
2333
|
-
configSource,
|
|
2334
|
-
refreshConfig,
|
|
2335
|
-
getDebugInfo
|
|
2336
|
-
} = useCrudifyDataContext();
|
|
2337
|
-
return {
|
|
2338
|
-
config,
|
|
2339
|
-
isConfigured,
|
|
2340
|
-
configError,
|
|
2341
|
-
configSource,
|
|
2342
|
-
rawConfig: config?.rawConfig || {},
|
|
2343
|
-
refreshConfig,
|
|
2344
|
-
getDebugInfo
|
|
2345
|
-
};
|
|
2346
|
-
};
|
|
2347
|
-
|
|
2348
2375
|
// src/hooks/useCrudifyInstance.ts
|
|
2349
2376
|
import { useCallback as useCallback4 } from "react";
|
|
2350
2377
|
import crudify5 from "@nocios/crudify-browser";
|
|
@@ -2370,7 +2397,7 @@ var useCrudifyInstance = () => {
|
|
|
2370
2397
|
}
|
|
2371
2398
|
try {
|
|
2372
2399
|
console.log("\u{1F504} useCrudifyInstance - waitForReady: Using CrudifyInitializer.waitForInitialization()");
|
|
2373
|
-
const { crudifyInitializer: crudifyInitializer2 } = await import("./CrudifyDataProvider-
|
|
2400
|
+
const { crudifyInitializer: crudifyInitializer2 } = await import("./CrudifyDataProvider-VQUGF4OL.mjs");
|
|
2374
2401
|
await crudifyInitializer2.waitForInitialization();
|
|
2375
2402
|
console.log("\u2705 useCrudifyInstance - waitForReady: CrudifyInitializer completed");
|
|
2376
2403
|
if (!crudifyInitializer2.isReady()) {
|
|
@@ -2512,7 +2539,7 @@ var useCrudifyInstance = () => {
|
|
|
2512
2539
|
};
|
|
2513
2540
|
var getCrudifyInstanceAsync = async () => {
|
|
2514
2541
|
console.log("\u{1F504} getCrudifyInstanceAsync - Starting");
|
|
2515
|
-
const { crudifyInitializer: crudifyInitializer2 } = await import("./CrudifyDataProvider-
|
|
2542
|
+
const { crudifyInitializer: crudifyInitializer2 } = await import("./CrudifyDataProvider-VQUGF4OL.mjs");
|
|
2516
2543
|
console.log("\u{1F504} getCrudifyInstanceAsync - Checking if ready");
|
|
2517
2544
|
console.log(" - crudifyInitializer.isReady():", crudifyInitializer2.isReady());
|
|
2518
2545
|
console.log(" - crudifyInitializer.getStatus():", crudifyInitializer2.getStatus());
|
|
@@ -2531,7 +2558,7 @@ var getCrudifyInstanceAsync = async () => {
|
|
|
2531
2558
|
return crudify5;
|
|
2532
2559
|
};
|
|
2533
2560
|
var getCrudifyInstanceSync = async () => {
|
|
2534
|
-
const { crudifyInitializer: crudifyInitializer2 } = await import("./CrudifyDataProvider-
|
|
2561
|
+
const { crudifyInitializer: crudifyInitializer2 } = await import("./CrudifyDataProvider-VQUGF4OL.mjs");
|
|
2535
2562
|
if (!crudifyInitializer2.isReady()) {
|
|
2536
2563
|
throw new Error("Crudify not ready. Use getCrudifyInstanceAsync() or call this from within a React component using useCrudifyInstance()");
|
|
2537
2564
|
}
|