@patch-adams/core 1.4.18 → 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 +60 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +60 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +60 -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 +60 -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 */
|
|
@@ -739,6 +741,12 @@ function generateLrsBridgeCode(options) {
|
|
|
739
741
|
'use strict';
|
|
740
742
|
|
|
741
743
|
var DEBUG = ${options.debug};
|
|
744
|
+
// Allow URL-based debug toggle: ?pa_debug=1 or #pa_debug
|
|
745
|
+
try {
|
|
746
|
+
if (window.location.search.indexOf('pa_debug') > -1 || window.location.hash.indexOf('pa_debug') > -1) {
|
|
747
|
+
DEBUG = true;
|
|
748
|
+
}
|
|
749
|
+
} catch (e) {}
|
|
742
750
|
var TRACK_MEDIA = ${options.trackMedia};
|
|
743
751
|
var TRACK_NAVIGATION = ${options.trackNavigation};
|
|
744
752
|
var TRACK_QUIZZES = ${options.trackQuizzes};
|
|
@@ -1597,12 +1605,32 @@ function generateLrsBridgeCode(options) {
|
|
|
1597
1605
|
return;
|
|
1598
1606
|
}
|
|
1599
1607
|
|
|
1600
|
-
//
|
|
1608
|
+
// In-memory cache check
|
|
1601
1609
|
if (employeeLookupFetched && employeeLookupData) {
|
|
1602
1610
|
callback(employeeLookupData);
|
|
1603
1611
|
return;
|
|
1604
1612
|
}
|
|
1605
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
|
+
|
|
1606
1634
|
// Build URL: endpoint should end with ? or include query param structure
|
|
1607
1635
|
var apiUrl = EMPLOYEE_API_ENDPOINT + (EMPLOYEE_API_ENDPOINT.indexOf('?') >= 0 ? '&' : '?') + 'q=' + encodeURIComponent(employeeId);
|
|
1608
1636
|
log('Fetching employee data from:', apiUrl);
|
|
@@ -1634,6 +1662,14 @@ function generateLrsBridgeCode(options) {
|
|
|
1634
1662
|
employeeId: employee.emp_id || employee.employeeId || employee.employee_id || employeeId
|
|
1635
1663
|
};
|
|
1636
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 */ }
|
|
1637
1673
|
callback(employeeLookupData);
|
|
1638
1674
|
} else {
|
|
1639
1675
|
callback(null);
|
|
@@ -3110,6 +3146,17 @@ function generateLrsBridgeCode(options) {
|
|
|
3110
3146
|
function sendStatement(statement) {
|
|
3111
3147
|
log('Sending statement:', statement.verb.display['en-US'] || statement.verb.id, statement);
|
|
3112
3148
|
|
|
3149
|
+
// Log first statement visibly (not gated by DEBUG) for production diagnostics
|
|
3150
|
+
if (LRS.stats.statementsSent === 0 && LRS.stats.statementsFailed === 0 && LRS.stats.statementsQueued === 0) {
|
|
3151
|
+
if (window.console && window.console.info) {
|
|
3152
|
+
var verb = statement.verb.display ? (statement.verb.display['en-US'] || statement.verb.id) : statement.verb.id;
|
|
3153
|
+
console.info('[PA-LRS] First statement: verb=' + verb +
|
|
3154
|
+
', endpoint=' + (LRS_ENDPOINT || 'NONE') +
|
|
3155
|
+
', proxy=' + (LRS_PROXY_ENDPOINT ? 'yes' : 'no') +
|
|
3156
|
+
', mode=' + LRS.mode);
|
|
3157
|
+
}
|
|
3158
|
+
}
|
|
3159
|
+
|
|
3113
3160
|
// Store in event log
|
|
3114
3161
|
LRS.eventLog.push({
|
|
3115
3162
|
statement: statement,
|
|
@@ -4289,6 +4336,15 @@ function generateLrsBridgeCode(options) {
|
|
|
4289
4336
|
LRS.mode = 'offline';
|
|
4290
4337
|
}
|
|
4291
4338
|
|
|
4339
|
+
// Always-visible bridge summary (not gated by DEBUG)
|
|
4340
|
+
// This ensures diagnostics are available even in production builds
|
|
4341
|
+
if (window.console && window.console.info) {
|
|
4342
|
+
console.info('[PA-LRS] Bridge: mode=' + LRS.mode +
|
|
4343
|
+
', endpoint=' + (LRS_ENDPOINT ? LRS_ENDPOINT.substring(0, 30) + '...' : 'NONE') +
|
|
4344
|
+
', proxy=' + (LRS_PROXY_ENDPOINT ? 'yes' : 'no') +
|
|
4345
|
+
', actor=' + (LRS.actor ? (LRS.actor.name || 'anonymous') : 'none'));
|
|
4346
|
+
}
|
|
4347
|
+
|
|
4292
4348
|
// Set up event interceptors
|
|
4293
4349
|
setupMediaInterceptors();
|
|
4294
4350
|
setupNavigationInterceptors();
|
|
@@ -4562,7 +4618,8 @@ function buildJsBeforeOptions(config, metadata) {
|
|
|
4562
4618
|
courseHomepage: lrsBridgeConfig.courseHomepage,
|
|
4563
4619
|
autoDetectLrs: lrsBridgeConfig.autoDetectLrs,
|
|
4564
4620
|
lrsAuth: lrsBridgeConfig.lrsAuth,
|
|
4565
|
-
lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint
|
|
4621
|
+
lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint,
|
|
4622
|
+
employeeApiEndpoint: lrsBridgeConfig.employeeApiEndpoint
|
|
4566
4623
|
};
|
|
4567
4624
|
return {
|
|
4568
4625
|
remoteUrl: `${config.remoteDomain}/${config.localFolders.js}/${config.jsBefore.filename}`,
|