@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 +34 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +34 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +34 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +34 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -382,7 +382,9 @@ var LrsBridgeConfigSchema = z.object({
|
|
|
382
382
|
/** Basic auth credentials for LRS (Base64 encoded "username:password") - used when no cookie session exists */
|
|
383
383
|
lrsAuth: z.string().optional(),
|
|
384
384
|
/** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
|
|
385
|
-
lrsProxyEndpoint: z.string().optional()
|
|
385
|
+
lrsProxyEndpoint: z.string().optional(),
|
|
386
|
+
/** Employee API endpoint URL for user identity lookup (e.g., https://node.example.com/admin_api/users/employees/) */
|
|
387
|
+
employeeApiEndpoint: z.string().optional()
|
|
386
388
|
});
|
|
387
389
|
var BlockingAssetConfigSchema = z.object({
|
|
388
390
|
/** Filename for the asset */
|
|
@@ -1603,12 +1605,32 @@ function generateLrsBridgeCode(options) {
|
|
|
1603
1605
|
return;
|
|
1604
1606
|
}
|
|
1605
1607
|
|
|
1606
|
-
//
|
|
1608
|
+
// In-memory cache check
|
|
1607
1609
|
if (employeeLookupFetched && employeeLookupData) {
|
|
1608
1610
|
callback(employeeLookupData);
|
|
1609
1611
|
return;
|
|
1610
1612
|
}
|
|
1611
1613
|
|
|
1614
|
+
// localStorage cache check (persists across page loads / sessions)
|
|
1615
|
+
var cacheKey = 'pa_employee_' + employeeId;
|
|
1616
|
+
try {
|
|
1617
|
+
var cached = localStorage.getItem(cacheKey);
|
|
1618
|
+
if (cached) {
|
|
1619
|
+
var parsed = JSON.parse(cached);
|
|
1620
|
+
// TTL: 7 days = 604800000 ms
|
|
1621
|
+
if (parsed.timestamp && (Date.now() - parsed.timestamp) < 604800000) {
|
|
1622
|
+
log('Employee data from localStorage cache');
|
|
1623
|
+
employeeLookupData = parsed;
|
|
1624
|
+
employeeLookupFetched = true;
|
|
1625
|
+
callback(parsed);
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1628
|
+
localStorage.removeItem(cacheKey);
|
|
1629
|
+
}
|
|
1630
|
+
} catch (e) {
|
|
1631
|
+
// localStorage unavailable (private browsing, iframe restrictions)
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1612
1634
|
// Build URL: endpoint should end with ? or include query param structure
|
|
1613
1635
|
var apiUrl = EMPLOYEE_API_ENDPOINT + (EMPLOYEE_API_ENDPOINT.indexOf('?') >= 0 ? '&' : '?') + 'q=' + encodeURIComponent(employeeId);
|
|
1614
1636
|
log('Fetching employee data from:', apiUrl);
|
|
@@ -1640,6 +1662,14 @@ function generateLrsBridgeCode(options) {
|
|
|
1640
1662
|
employeeId: employee.emp_id || employee.employeeId || employee.employee_id || employeeId
|
|
1641
1663
|
};
|
|
1642
1664
|
log('Parsed employee data:', employeeLookupData);
|
|
1665
|
+
// Persist to localStorage for cross-session caching
|
|
1666
|
+
try {
|
|
1667
|
+
var cacheData = {};
|
|
1668
|
+
for (var k in employeeLookupData) { if (employeeLookupData.hasOwnProperty(k)) cacheData[k] = employeeLookupData[k]; }
|
|
1669
|
+
cacheData.timestamp = Date.now();
|
|
1670
|
+
localStorage.setItem(cacheKey, JSON.stringify(cacheData));
|
|
1671
|
+
log('Employee data cached in localStorage');
|
|
1672
|
+
} catch (e) { /* localStorage unavailable */ }
|
|
1643
1673
|
callback(employeeLookupData);
|
|
1644
1674
|
} else {
|
|
1645
1675
|
callback(null);
|
|
@@ -4588,7 +4618,8 @@ function buildJsBeforeOptions(config, metadata) {
|
|
|
4588
4618
|
courseHomepage: lrsBridgeConfig.courseHomepage,
|
|
4589
4619
|
autoDetectLrs: lrsBridgeConfig.autoDetectLrs,
|
|
4590
4620
|
lrsAuth: lrsBridgeConfig.lrsAuth,
|
|
4591
|
-
lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint
|
|
4621
|
+
lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint,
|
|
4622
|
+
employeeApiEndpoint: lrsBridgeConfig.employeeApiEndpoint
|
|
4592
4623
|
};
|
|
4593
4624
|
return {
|
|
4594
4625
|
remoteUrl: `${config.remoteDomain}/${config.localFolders.js}/${config.jsBefore.filename}`,
|