@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/index.d.cts
CHANGED
|
@@ -32,6 +32,8 @@ declare const LrsBridgeConfigSchema: z.ZodObject<{
|
|
|
32
32
|
lrsAuth: z.ZodOptional<z.ZodString>;
|
|
33
33
|
/** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
|
|
34
34
|
lrsProxyEndpoint: z.ZodOptional<z.ZodString>;
|
|
35
|
+
/** Employee API endpoint URL for user identity lookup (e.g., https://node.example.com/admin_api/users/employees/) */
|
|
36
|
+
employeeApiEndpoint: z.ZodOptional<z.ZodString>;
|
|
35
37
|
}, "strip", z.ZodTypeAny, {
|
|
36
38
|
enabled: boolean;
|
|
37
39
|
trackMedia: boolean;
|
|
@@ -46,6 +48,7 @@ declare const LrsBridgeConfigSchema: z.ZodObject<{
|
|
|
46
48
|
courseHomepage?: string | undefined;
|
|
47
49
|
lrsAuth?: string | undefined;
|
|
48
50
|
lrsProxyEndpoint?: string | undefined;
|
|
51
|
+
employeeApiEndpoint?: string | undefined;
|
|
49
52
|
}, {
|
|
50
53
|
enabled?: boolean | undefined;
|
|
51
54
|
trackMedia?: boolean | undefined;
|
|
@@ -60,6 +63,7 @@ declare const LrsBridgeConfigSchema: z.ZodObject<{
|
|
|
60
63
|
autoDetectLrs?: boolean | undefined;
|
|
61
64
|
lrsAuth?: string | undefined;
|
|
62
65
|
lrsProxyEndpoint?: string | undefined;
|
|
66
|
+
employeeApiEndpoint?: string | undefined;
|
|
63
67
|
}>;
|
|
64
68
|
/**
|
|
65
69
|
* Configuration for a blocking asset (CSS before, JS before)
|
|
@@ -227,6 +231,8 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
|
|
|
227
231
|
lrsAuth: z.ZodOptional<z.ZodString>;
|
|
228
232
|
/** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
|
|
229
233
|
lrsProxyEndpoint: z.ZodOptional<z.ZodString>;
|
|
234
|
+
/** Employee API endpoint URL for user identity lookup (e.g., https://node.example.com/admin_api/users/employees/) */
|
|
235
|
+
employeeApiEndpoint: z.ZodOptional<z.ZodString>;
|
|
230
236
|
}, "strip", z.ZodTypeAny, {
|
|
231
237
|
enabled: boolean;
|
|
232
238
|
trackMedia: boolean;
|
|
@@ -241,6 +247,7 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
|
|
|
241
247
|
courseHomepage?: string | undefined;
|
|
242
248
|
lrsAuth?: string | undefined;
|
|
243
249
|
lrsProxyEndpoint?: string | undefined;
|
|
250
|
+
employeeApiEndpoint?: string | undefined;
|
|
244
251
|
}, {
|
|
245
252
|
enabled?: boolean | undefined;
|
|
246
253
|
trackMedia?: boolean | undefined;
|
|
@@ -255,6 +262,7 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
|
|
|
255
262
|
autoDetectLrs?: boolean | undefined;
|
|
256
263
|
lrsAuth?: string | undefined;
|
|
257
264
|
lrsProxyEndpoint?: string | undefined;
|
|
265
|
+
employeeApiEndpoint?: string | undefined;
|
|
258
266
|
}>>;
|
|
259
267
|
/** Plugin configurations - each plugin is keyed by its name */
|
|
260
268
|
plugins: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -309,6 +317,7 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
|
|
|
309
317
|
courseHomepage?: string | undefined;
|
|
310
318
|
lrsAuth?: string | undefined;
|
|
311
319
|
lrsProxyEndpoint?: string | undefined;
|
|
320
|
+
employeeApiEndpoint?: string | undefined;
|
|
312
321
|
};
|
|
313
322
|
plugins: Record<string, z.objectOutputType<{
|
|
314
323
|
/** Whether this plugin is enabled */
|
|
@@ -356,6 +365,7 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
|
|
|
356
365
|
autoDetectLrs?: boolean | undefined;
|
|
357
366
|
lrsAuth?: string | undefined;
|
|
358
367
|
lrsProxyEndpoint?: string | undefined;
|
|
368
|
+
employeeApiEndpoint?: string | undefined;
|
|
359
369
|
} | undefined;
|
|
360
370
|
plugins?: Record<string, z.objectInputType<{
|
|
361
371
|
/** Whether this plugin is enabled */
|
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ declare const LrsBridgeConfigSchema: z.ZodObject<{
|
|
|
32
32
|
lrsAuth: z.ZodOptional<z.ZodString>;
|
|
33
33
|
/** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
|
|
34
34
|
lrsProxyEndpoint: z.ZodOptional<z.ZodString>;
|
|
35
|
+
/** Employee API endpoint URL for user identity lookup (e.g., https://node.example.com/admin_api/users/employees/) */
|
|
36
|
+
employeeApiEndpoint: z.ZodOptional<z.ZodString>;
|
|
35
37
|
}, "strip", z.ZodTypeAny, {
|
|
36
38
|
enabled: boolean;
|
|
37
39
|
trackMedia: boolean;
|
|
@@ -46,6 +48,7 @@ declare const LrsBridgeConfigSchema: z.ZodObject<{
|
|
|
46
48
|
courseHomepage?: string | undefined;
|
|
47
49
|
lrsAuth?: string | undefined;
|
|
48
50
|
lrsProxyEndpoint?: string | undefined;
|
|
51
|
+
employeeApiEndpoint?: string | undefined;
|
|
49
52
|
}, {
|
|
50
53
|
enabled?: boolean | undefined;
|
|
51
54
|
trackMedia?: boolean | undefined;
|
|
@@ -60,6 +63,7 @@ declare const LrsBridgeConfigSchema: z.ZodObject<{
|
|
|
60
63
|
autoDetectLrs?: boolean | undefined;
|
|
61
64
|
lrsAuth?: string | undefined;
|
|
62
65
|
lrsProxyEndpoint?: string | undefined;
|
|
66
|
+
employeeApiEndpoint?: string | undefined;
|
|
63
67
|
}>;
|
|
64
68
|
/**
|
|
65
69
|
* Configuration for a blocking asset (CSS before, JS before)
|
|
@@ -227,6 +231,8 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
|
|
|
227
231
|
lrsAuth: z.ZodOptional<z.ZodString>;
|
|
228
232
|
/** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
|
|
229
233
|
lrsProxyEndpoint: z.ZodOptional<z.ZodString>;
|
|
234
|
+
/** Employee API endpoint URL for user identity lookup (e.g., https://node.example.com/admin_api/users/employees/) */
|
|
235
|
+
employeeApiEndpoint: z.ZodOptional<z.ZodString>;
|
|
230
236
|
}, "strip", z.ZodTypeAny, {
|
|
231
237
|
enabled: boolean;
|
|
232
238
|
trackMedia: boolean;
|
|
@@ -241,6 +247,7 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
|
|
|
241
247
|
courseHomepage?: string | undefined;
|
|
242
248
|
lrsAuth?: string | undefined;
|
|
243
249
|
lrsProxyEndpoint?: string | undefined;
|
|
250
|
+
employeeApiEndpoint?: string | undefined;
|
|
244
251
|
}, {
|
|
245
252
|
enabled?: boolean | undefined;
|
|
246
253
|
trackMedia?: boolean | undefined;
|
|
@@ -255,6 +262,7 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
|
|
|
255
262
|
autoDetectLrs?: boolean | undefined;
|
|
256
263
|
lrsAuth?: string | undefined;
|
|
257
264
|
lrsProxyEndpoint?: string | undefined;
|
|
265
|
+
employeeApiEndpoint?: string | undefined;
|
|
258
266
|
}>>;
|
|
259
267
|
/** Plugin configurations - each plugin is keyed by its name */
|
|
260
268
|
plugins: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -309,6 +317,7 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
|
|
|
309
317
|
courseHomepage?: string | undefined;
|
|
310
318
|
lrsAuth?: string | undefined;
|
|
311
319
|
lrsProxyEndpoint?: string | undefined;
|
|
320
|
+
employeeApiEndpoint?: string | undefined;
|
|
312
321
|
};
|
|
313
322
|
plugins: Record<string, z.objectOutputType<{
|
|
314
323
|
/** Whether this plugin is enabled */
|
|
@@ -356,6 +365,7 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
|
|
|
356
365
|
autoDetectLrs?: boolean | undefined;
|
|
357
366
|
lrsAuth?: string | undefined;
|
|
358
367
|
lrsProxyEndpoint?: string | undefined;
|
|
368
|
+
employeeApiEndpoint?: string | undefined;
|
|
359
369
|
} | undefined;
|
|
360
370
|
plugins?: Record<string, z.objectInputType<{
|
|
361
371
|
/** Whether this plugin is enabled */
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,9 @@ var LrsBridgeConfigSchema = z.object({
|
|
|
35
35
|
/** Basic auth credentials for LRS (Base64 encoded "username:password") - used when no cookie session exists */
|
|
36
36
|
lrsAuth: z.string().optional(),
|
|
37
37
|
/** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
|
|
38
|
-
lrsProxyEndpoint: z.string().optional()
|
|
38
|
+
lrsProxyEndpoint: z.string().optional(),
|
|
39
|
+
/** Employee API endpoint URL for user identity lookup (e.g., https://node.example.com/admin_api/users/employees/) */
|
|
40
|
+
employeeApiEndpoint: z.string().optional()
|
|
39
41
|
});
|
|
40
42
|
var BlockingAssetConfigSchema = z.object({
|
|
41
43
|
/** Filename for the asset */
|
|
@@ -406,6 +408,12 @@ function generateLrsBridgeCode(options) {
|
|
|
406
408
|
'use strict';
|
|
407
409
|
|
|
408
410
|
var DEBUG = ${options.debug};
|
|
411
|
+
// Allow URL-based debug toggle: ?pa_debug=1 or #pa_debug
|
|
412
|
+
try {
|
|
413
|
+
if (window.location.search.indexOf('pa_debug') > -1 || window.location.hash.indexOf('pa_debug') > -1) {
|
|
414
|
+
DEBUG = true;
|
|
415
|
+
}
|
|
416
|
+
} catch (e) {}
|
|
409
417
|
var TRACK_MEDIA = ${options.trackMedia};
|
|
410
418
|
var TRACK_NAVIGATION = ${options.trackNavigation};
|
|
411
419
|
var TRACK_QUIZZES = ${options.trackQuizzes};
|
|
@@ -1264,12 +1272,32 @@ function generateLrsBridgeCode(options) {
|
|
|
1264
1272
|
return;
|
|
1265
1273
|
}
|
|
1266
1274
|
|
|
1267
|
-
//
|
|
1275
|
+
// In-memory cache check
|
|
1268
1276
|
if (employeeLookupFetched && employeeLookupData) {
|
|
1269
1277
|
callback(employeeLookupData);
|
|
1270
1278
|
return;
|
|
1271
1279
|
}
|
|
1272
1280
|
|
|
1281
|
+
// localStorage cache check (persists across page loads / sessions)
|
|
1282
|
+
var cacheKey = 'pa_employee_' + employeeId;
|
|
1283
|
+
try {
|
|
1284
|
+
var cached = localStorage.getItem(cacheKey);
|
|
1285
|
+
if (cached) {
|
|
1286
|
+
var parsed = JSON.parse(cached);
|
|
1287
|
+
// TTL: 7 days = 604800000 ms
|
|
1288
|
+
if (parsed.timestamp && (Date.now() - parsed.timestamp) < 604800000) {
|
|
1289
|
+
log('Employee data from localStorage cache');
|
|
1290
|
+
employeeLookupData = parsed;
|
|
1291
|
+
employeeLookupFetched = true;
|
|
1292
|
+
callback(parsed);
|
|
1293
|
+
return;
|
|
1294
|
+
}
|
|
1295
|
+
localStorage.removeItem(cacheKey);
|
|
1296
|
+
}
|
|
1297
|
+
} catch (e) {
|
|
1298
|
+
// localStorage unavailable (private browsing, iframe restrictions)
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1273
1301
|
// Build URL: endpoint should end with ? or include query param structure
|
|
1274
1302
|
var apiUrl = EMPLOYEE_API_ENDPOINT + (EMPLOYEE_API_ENDPOINT.indexOf('?') >= 0 ? '&' : '?') + 'q=' + encodeURIComponent(employeeId);
|
|
1275
1303
|
log('Fetching employee data from:', apiUrl);
|
|
@@ -1301,6 +1329,14 @@ function generateLrsBridgeCode(options) {
|
|
|
1301
1329
|
employeeId: employee.emp_id || employee.employeeId || employee.employee_id || employeeId
|
|
1302
1330
|
};
|
|
1303
1331
|
log('Parsed employee data:', employeeLookupData);
|
|
1332
|
+
// Persist to localStorage for cross-session caching
|
|
1333
|
+
try {
|
|
1334
|
+
var cacheData = {};
|
|
1335
|
+
for (var k in employeeLookupData) { if (employeeLookupData.hasOwnProperty(k)) cacheData[k] = employeeLookupData[k]; }
|
|
1336
|
+
cacheData.timestamp = Date.now();
|
|
1337
|
+
localStorage.setItem(cacheKey, JSON.stringify(cacheData));
|
|
1338
|
+
log('Employee data cached in localStorage');
|
|
1339
|
+
} catch (e) { /* localStorage unavailable */ }
|
|
1304
1340
|
callback(employeeLookupData);
|
|
1305
1341
|
} else {
|
|
1306
1342
|
callback(null);
|
|
@@ -2777,6 +2813,17 @@ function generateLrsBridgeCode(options) {
|
|
|
2777
2813
|
function sendStatement(statement) {
|
|
2778
2814
|
log('Sending statement:', statement.verb.display['en-US'] || statement.verb.id, statement);
|
|
2779
2815
|
|
|
2816
|
+
// Log first statement visibly (not gated by DEBUG) for production diagnostics
|
|
2817
|
+
if (LRS.stats.statementsSent === 0 && LRS.stats.statementsFailed === 0 && LRS.stats.statementsQueued === 0) {
|
|
2818
|
+
if (window.console && window.console.info) {
|
|
2819
|
+
var verb = statement.verb.display ? (statement.verb.display['en-US'] || statement.verb.id) : statement.verb.id;
|
|
2820
|
+
console.info('[PA-LRS] First statement: verb=' + verb +
|
|
2821
|
+
', endpoint=' + (LRS_ENDPOINT || 'NONE') +
|
|
2822
|
+
', proxy=' + (LRS_PROXY_ENDPOINT ? 'yes' : 'no') +
|
|
2823
|
+
', mode=' + LRS.mode);
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
|
|
2780
2827
|
// Store in event log
|
|
2781
2828
|
LRS.eventLog.push({
|
|
2782
2829
|
statement: statement,
|
|
@@ -3956,6 +4003,15 @@ function generateLrsBridgeCode(options) {
|
|
|
3956
4003
|
LRS.mode = 'offline';
|
|
3957
4004
|
}
|
|
3958
4005
|
|
|
4006
|
+
// Always-visible bridge summary (not gated by DEBUG)
|
|
4007
|
+
// This ensures diagnostics are available even in production builds
|
|
4008
|
+
if (window.console && window.console.info) {
|
|
4009
|
+
console.info('[PA-LRS] Bridge: mode=' + LRS.mode +
|
|
4010
|
+
', endpoint=' + (LRS_ENDPOINT ? LRS_ENDPOINT.substring(0, 30) + '...' : 'NONE') +
|
|
4011
|
+
', proxy=' + (LRS_PROXY_ENDPOINT ? 'yes' : 'no') +
|
|
4012
|
+
', actor=' + (LRS.actor ? (LRS.actor.name || 'anonymous') : 'none'));
|
|
4013
|
+
}
|
|
4014
|
+
|
|
3959
4015
|
// Set up event interceptors
|
|
3960
4016
|
setupMediaInterceptors();
|
|
3961
4017
|
setupNavigationInterceptors();
|
|
@@ -4229,7 +4285,8 @@ function buildJsBeforeOptions(config, metadata) {
|
|
|
4229
4285
|
courseHomepage: lrsBridgeConfig.courseHomepage,
|
|
4230
4286
|
autoDetectLrs: lrsBridgeConfig.autoDetectLrs,
|
|
4231
4287
|
lrsAuth: lrsBridgeConfig.lrsAuth,
|
|
4232
|
-
lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint
|
|
4288
|
+
lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint,
|
|
4289
|
+
employeeApiEndpoint: lrsBridgeConfig.employeeApiEndpoint
|
|
4233
4290
|
};
|
|
4234
4291
|
return {
|
|
4235
4292
|
remoteUrl: `${config.remoteDomain}/${config.localFolders.js}/${config.jsBefore.filename}`,
|