@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.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 */
|
|
@@ -748,6 +750,12 @@ function generateLrsBridgeCode(options) {
|
|
|
748
750
|
'use strict';
|
|
749
751
|
|
|
750
752
|
var DEBUG = ${options.debug};
|
|
753
|
+
// Allow URL-based debug toggle: ?pa_debug=1 or #pa_debug
|
|
754
|
+
try {
|
|
755
|
+
if (window.location.search.indexOf('pa_debug') > -1 || window.location.hash.indexOf('pa_debug') > -1) {
|
|
756
|
+
DEBUG = true;
|
|
757
|
+
}
|
|
758
|
+
} catch (e) {}
|
|
751
759
|
var TRACK_MEDIA = ${options.trackMedia};
|
|
752
760
|
var TRACK_NAVIGATION = ${options.trackNavigation};
|
|
753
761
|
var TRACK_QUIZZES = ${options.trackQuizzes};
|
|
@@ -1606,12 +1614,32 @@ function generateLrsBridgeCode(options) {
|
|
|
1606
1614
|
return;
|
|
1607
1615
|
}
|
|
1608
1616
|
|
|
1609
|
-
//
|
|
1617
|
+
// In-memory cache check
|
|
1610
1618
|
if (employeeLookupFetched && employeeLookupData) {
|
|
1611
1619
|
callback(employeeLookupData);
|
|
1612
1620
|
return;
|
|
1613
1621
|
}
|
|
1614
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
|
+
|
|
1615
1643
|
// Build URL: endpoint should end with ? or include query param structure
|
|
1616
1644
|
var apiUrl = EMPLOYEE_API_ENDPOINT + (EMPLOYEE_API_ENDPOINT.indexOf('?') >= 0 ? '&' : '?') + 'q=' + encodeURIComponent(employeeId);
|
|
1617
1645
|
log('Fetching employee data from:', apiUrl);
|
|
@@ -1643,6 +1671,14 @@ function generateLrsBridgeCode(options) {
|
|
|
1643
1671
|
employeeId: employee.emp_id || employee.employeeId || employee.employee_id || employeeId
|
|
1644
1672
|
};
|
|
1645
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 */ }
|
|
1646
1682
|
callback(employeeLookupData);
|
|
1647
1683
|
} else {
|
|
1648
1684
|
callback(null);
|
|
@@ -3119,6 +3155,17 @@ function generateLrsBridgeCode(options) {
|
|
|
3119
3155
|
function sendStatement(statement) {
|
|
3120
3156
|
log('Sending statement:', statement.verb.display['en-US'] || statement.verb.id, statement);
|
|
3121
3157
|
|
|
3158
|
+
// Log first statement visibly (not gated by DEBUG) for production diagnostics
|
|
3159
|
+
if (LRS.stats.statementsSent === 0 && LRS.stats.statementsFailed === 0 && LRS.stats.statementsQueued === 0) {
|
|
3160
|
+
if (window.console && window.console.info) {
|
|
3161
|
+
var verb = statement.verb.display ? (statement.verb.display['en-US'] || statement.verb.id) : statement.verb.id;
|
|
3162
|
+
console.info('[PA-LRS] First statement: verb=' + verb +
|
|
3163
|
+
', endpoint=' + (LRS_ENDPOINT || 'NONE') +
|
|
3164
|
+
', proxy=' + (LRS_PROXY_ENDPOINT ? 'yes' : 'no') +
|
|
3165
|
+
', mode=' + LRS.mode);
|
|
3166
|
+
}
|
|
3167
|
+
}
|
|
3168
|
+
|
|
3122
3169
|
// Store in event log
|
|
3123
3170
|
LRS.eventLog.push({
|
|
3124
3171
|
statement: statement,
|
|
@@ -4298,6 +4345,15 @@ function generateLrsBridgeCode(options) {
|
|
|
4298
4345
|
LRS.mode = 'offline';
|
|
4299
4346
|
}
|
|
4300
4347
|
|
|
4348
|
+
// Always-visible bridge summary (not gated by DEBUG)
|
|
4349
|
+
// This ensures diagnostics are available even in production builds
|
|
4350
|
+
if (window.console && window.console.info) {
|
|
4351
|
+
console.info('[PA-LRS] Bridge: mode=' + LRS.mode +
|
|
4352
|
+
', endpoint=' + (LRS_ENDPOINT ? LRS_ENDPOINT.substring(0, 30) + '...' : 'NONE') +
|
|
4353
|
+
', proxy=' + (LRS_PROXY_ENDPOINT ? 'yes' : 'no') +
|
|
4354
|
+
', actor=' + (LRS.actor ? (LRS.actor.name || 'anonymous') : 'none'));
|
|
4355
|
+
}
|
|
4356
|
+
|
|
4301
4357
|
// Set up event interceptors
|
|
4302
4358
|
setupMediaInterceptors();
|
|
4303
4359
|
setupNavigationInterceptors();
|
|
@@ -4571,7 +4627,8 @@ function buildJsBeforeOptions(config, metadata) {
|
|
|
4571
4627
|
courseHomepage: lrsBridgeConfig.courseHomepage,
|
|
4572
4628
|
autoDetectLrs: lrsBridgeConfig.autoDetectLrs,
|
|
4573
4629
|
lrsAuth: lrsBridgeConfig.lrsAuth,
|
|
4574
|
-
lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint
|
|
4630
|
+
lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint,
|
|
4631
|
+
employeeApiEndpoint: lrsBridgeConfig.employeeApiEndpoint
|
|
4575
4632
|
};
|
|
4576
4633
|
return {
|
|
4577
4634
|
remoteUrl: `${config.remoteDomain}/${config.localFolders.js}/${config.jsBefore.filename}`,
|