@patch-adams/core 1.4.19 → 1.4.20

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/cli.cjs CHANGED
@@ -391,7 +391,9 @@ var LrsBridgeConfigSchema = zod.z.object({
391
391
  /** Basic auth credentials for LRS (Base64 encoded "username:password") - used when no cookie session exists */
392
392
  lrsAuth: zod.z.string().optional(),
393
393
  /** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
394
- lrsProxyEndpoint: zod.z.string().optional()
394
+ lrsProxyEndpoint: zod.z.string().optional(),
395
+ /** Employee API endpoint URL for user identity lookup (e.g., https://node.example.com/admin_api/users/employees/) */
396
+ employeeApiEndpoint: zod.z.string().optional()
395
397
  });
396
398
  var BlockingAssetConfigSchema = zod.z.object({
397
399
  /** Filename for the asset */
@@ -1612,12 +1614,32 @@ function generateLrsBridgeCode(options) {
1612
1614
  return;
1613
1615
  }
1614
1616
 
1615
- // Cache check
1617
+ // In-memory cache check
1616
1618
  if (employeeLookupFetched && employeeLookupData) {
1617
1619
  callback(employeeLookupData);
1618
1620
  return;
1619
1621
  }
1620
1622
 
1623
+ // localStorage cache check (persists across page loads / sessions)
1624
+ var cacheKey = 'pa_employee_' + employeeId;
1625
+ try {
1626
+ var cached = localStorage.getItem(cacheKey);
1627
+ if (cached) {
1628
+ var parsed = JSON.parse(cached);
1629
+ // TTL: 7 days = 604800000 ms
1630
+ if (parsed.timestamp && (Date.now() - parsed.timestamp) < 604800000) {
1631
+ log('Employee data from localStorage cache');
1632
+ employeeLookupData = parsed;
1633
+ employeeLookupFetched = true;
1634
+ callback(parsed);
1635
+ return;
1636
+ }
1637
+ localStorage.removeItem(cacheKey);
1638
+ }
1639
+ } catch (e) {
1640
+ // localStorage unavailable (private browsing, iframe restrictions)
1641
+ }
1642
+
1621
1643
  // Build URL: endpoint should end with ? or include query param structure
1622
1644
  var apiUrl = EMPLOYEE_API_ENDPOINT + (EMPLOYEE_API_ENDPOINT.indexOf('?') >= 0 ? '&' : '?') + 'q=' + encodeURIComponent(employeeId);
1623
1645
  log('Fetching employee data from:', apiUrl);
@@ -1649,6 +1671,14 @@ function generateLrsBridgeCode(options) {
1649
1671
  employeeId: employee.emp_id || employee.employeeId || employee.employee_id || employeeId
1650
1672
  };
1651
1673
  log('Parsed employee data:', employeeLookupData);
1674
+ // Persist to localStorage for cross-session caching
1675
+ try {
1676
+ var cacheData = {};
1677
+ for (var k in employeeLookupData) { if (employeeLookupData.hasOwnProperty(k)) cacheData[k] = employeeLookupData[k]; }
1678
+ cacheData.timestamp = Date.now();
1679
+ localStorage.setItem(cacheKey, JSON.stringify(cacheData));
1680
+ log('Employee data cached in localStorage');
1681
+ } catch (e) { /* localStorage unavailable */ }
1652
1682
  callback(employeeLookupData);
1653
1683
  } else {
1654
1684
  callback(null);
@@ -4597,7 +4627,8 @@ function buildJsBeforeOptions(config, metadata) {
4597
4627
  courseHomepage: lrsBridgeConfig.courseHomepage,
4598
4628
  autoDetectLrs: lrsBridgeConfig.autoDetectLrs,
4599
4629
  lrsAuth: lrsBridgeConfig.lrsAuth,
4600
- lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint
4630
+ lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint,
4631
+ employeeApiEndpoint: lrsBridgeConfig.employeeApiEndpoint
4601
4632
  };
4602
4633
  return {
4603
4634
  remoteUrl: `${config.remoteDomain}/${config.localFolders.js}/${config.jsBefore.filename}`,