@nocios/crudify-ui 1.2.32 → 1.2.36

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.js CHANGED
@@ -3698,6 +3698,21 @@ var useCrudifyInstance = () => {
3698
3698
  console.log(`\u2705 useCrudifyInstance - ${operationName}: Crudify is ready`);
3699
3699
  }
3700
3700
  }, [isReady, waitForReady]);
3701
+ const ensureTokenSync = (0, import_react15.useCallback)(async () => {
3702
+ console.log("\u{1F504} useCrudifyInstance - ensureTokenSync: Starting token sync check");
3703
+ const { tokenManager: tokenManager2 } = await Promise.resolve().then(() => (init_TokenManager(), TokenManager_exports));
3704
+ const tmToken = tokenManager2.getToken();
3705
+ const crudifyToken = import_crudify_browser7.default.getToken?.();
3706
+ console.log(" - TokenManager token in sync check:", tmToken ? `${tmToken.substring(0, 20)}...` : "null");
3707
+ console.log(" - crudify token in sync check:", crudifyToken ? `${crudifyToken.substring(0, 20)}...` : "null");
3708
+ if (tmToken && tmToken !== crudifyToken) {
3709
+ console.log("\u{1F504} useCrudifyInstance - Forcing token sync for authenticated operation");
3710
+ import_crudify_browser7.default.setToken(tmToken);
3711
+ console.log(" - crudify token after sync:", import_crudify_browser7.default.getToken?.() ? `${import_crudify_browser7.default.getToken?.()?.substring(0, 20)}...` : "null");
3712
+ } else {
3713
+ console.log("\u{1F504} useCrudifyInstance - No token sync needed, tokens match or no token");
3714
+ }
3715
+ }, []);
3701
3716
  const getStructure = (0, import_react15.useCallback)(async (options) => {
3702
3717
  console.log("\u{1F4E1} useCrudifyInstance - getStructure: Starting");
3703
3718
  await ensureReady("getStructure");
@@ -3709,6 +3724,7 @@ var useCrudifyInstance = () => {
3709
3724
  console.log(" - TokenManager token:", tmToken ? `${tmToken.substring(0, 20)}...` : "null");
3710
3725
  console.log(" - crudify.getToken():", crudifyToken ? `${crudifyToken.substring(0, 20)}...` : "null");
3711
3726
  console.log(" - Tokens match:", tmToken === crudifyToken);
3727
+ await ensureTokenSync();
3712
3728
  console.log("\u{1F4E1} useCrudifyInstance - getStructure: Calling crudify.getStructure");
3713
3729
  const response = await import_crudify_browser7.default.getStructure(options);
3714
3730
  console.log("\u{1F4E1} useCrudifyInstance - getStructure: Response received", response);
@@ -3717,7 +3733,7 @@ var useCrudifyInstance = () => {
3717
3733
  console.error("\u{1F4E1} useCrudifyInstance - getStructure: Error", error);
3718
3734
  throw error;
3719
3735
  }
3720
- }, [ensureReady]);
3736
+ }, [ensureReady, ensureTokenSync]);
3721
3737
  const getStructurePublic = (0, import_react15.useCallback)(async (options) => {
3722
3738
  console.log("\u{1F4E1} useCrudifyInstance - getStructurePublic: Starting");
3723
3739
  await ensureReady("getStructurePublic");
@@ -3733,6 +3749,7 @@ var useCrudifyInstance = () => {
3733
3749
  }, [ensureReady]);
3734
3750
  const readItems = (0, import_react15.useCallback)(async (moduleKey, filter, options) => {
3735
3751
  await ensureReady("readItems");
3752
+ await ensureTokenSync();
3736
3753
  if (moduleKey === "__test_connection__") {
3737
3754
  console.error("\u{1F6A8} FOUND TEST CONNECTION CALL in useCrudifyInstance! Stack trace:");
3738
3755
  console.error(new Error().stack);
@@ -3744,7 +3761,7 @@ var useCrudifyInstance = () => {
3744
3761
  console.error("\u{1F4CA} useCrudifyInstance - readItems error:", error);
3745
3762
  throw error;
3746
3763
  }
3747
- }, [ensureReady]);
3764
+ }, [ensureReady, ensureTokenSync]);
3748
3765
  const readItem = (0, import_react15.useCallback)(async (moduleKey, filter, options) => {
3749
3766
  await ensureReady("readItem");
3750
3767
  try {
package/dist/index.mjs CHANGED
@@ -2410,6 +2410,21 @@ var useCrudifyInstance = () => {
2410
2410
  console.log(`\u2705 useCrudifyInstance - ${operationName}: Crudify is ready`);
2411
2411
  }
2412
2412
  }, [isReady, waitForReady]);
2413
+ const ensureTokenSync = useCallback4(async () => {
2414
+ console.log("\u{1F504} useCrudifyInstance - ensureTokenSync: Starting token sync check");
2415
+ const { tokenManager: tokenManager2 } = await import("./TokenManager-AYUNIXQU.mjs");
2416
+ const tmToken = tokenManager2.getToken();
2417
+ const crudifyToken = crudify5.getToken?.();
2418
+ console.log(" - TokenManager token in sync check:", tmToken ? `${tmToken.substring(0, 20)}...` : "null");
2419
+ console.log(" - crudify token in sync check:", crudifyToken ? `${crudifyToken.substring(0, 20)}...` : "null");
2420
+ if (tmToken && tmToken !== crudifyToken) {
2421
+ console.log("\u{1F504} useCrudifyInstance - Forcing token sync for authenticated operation");
2422
+ crudify5.setToken(tmToken);
2423
+ console.log(" - crudify token after sync:", crudify5.getToken?.() ? `${crudify5.getToken?.()?.substring(0, 20)}...` : "null");
2424
+ } else {
2425
+ console.log("\u{1F504} useCrudifyInstance - No token sync needed, tokens match or no token");
2426
+ }
2427
+ }, []);
2413
2428
  const getStructure = useCallback4(async (options) => {
2414
2429
  console.log("\u{1F4E1} useCrudifyInstance - getStructure: Starting");
2415
2430
  await ensureReady("getStructure");
@@ -2421,6 +2436,7 @@ var useCrudifyInstance = () => {
2421
2436
  console.log(" - TokenManager token:", tmToken ? `${tmToken.substring(0, 20)}...` : "null");
2422
2437
  console.log(" - crudify.getToken():", crudifyToken ? `${crudifyToken.substring(0, 20)}...` : "null");
2423
2438
  console.log(" - Tokens match:", tmToken === crudifyToken);
2439
+ await ensureTokenSync();
2424
2440
  console.log("\u{1F4E1} useCrudifyInstance - getStructure: Calling crudify.getStructure");
2425
2441
  const response = await crudify5.getStructure(options);
2426
2442
  console.log("\u{1F4E1} useCrudifyInstance - getStructure: Response received", response);
@@ -2429,7 +2445,7 @@ var useCrudifyInstance = () => {
2429
2445
  console.error("\u{1F4E1} useCrudifyInstance - getStructure: Error", error);
2430
2446
  throw error;
2431
2447
  }
2432
- }, [ensureReady]);
2448
+ }, [ensureReady, ensureTokenSync]);
2433
2449
  const getStructurePublic = useCallback4(async (options) => {
2434
2450
  console.log("\u{1F4E1} useCrudifyInstance - getStructurePublic: Starting");
2435
2451
  await ensureReady("getStructurePublic");
@@ -2445,6 +2461,7 @@ var useCrudifyInstance = () => {
2445
2461
  }, [ensureReady]);
2446
2462
  const readItems = useCallback4(async (moduleKey, filter, options) => {
2447
2463
  await ensureReady("readItems");
2464
+ await ensureTokenSync();
2448
2465
  if (moduleKey === "__test_connection__") {
2449
2466
  console.error("\u{1F6A8} FOUND TEST CONNECTION CALL in useCrudifyInstance! Stack trace:");
2450
2467
  console.error(new Error().stack);
@@ -2456,7 +2473,7 @@ var useCrudifyInstance = () => {
2456
2473
  console.error("\u{1F4CA} useCrudifyInstance - readItems error:", error);
2457
2474
  throw error;
2458
2475
  }
2459
- }, [ensureReady]);
2476
+ }, [ensureReady, ensureTokenSync]);
2460
2477
  const readItem = useCallback4(async (moduleKey, filter, options) => {
2461
2478
  await ensureReady("readItem");
2462
2479
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocios/crudify-ui",
3
- "version": "1.2.32",
3
+ "version": "1.2.36",
4
4
  "description": "Biblioteca de componentes UI para Crudify",
5
5
  "author": "Nocios",
6
6
  "license": "MIT",