@patch-adams/core 1.4.20 → 1.4.22
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 -10
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +60 -10
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +63 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +63 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -45,7 +45,11 @@ var LrsBridgeConfigSchema = zod.z.object({
|
|
|
45
45
|
/** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
|
|
46
46
|
lrsProxyEndpoint: zod.z.string().optional(),
|
|
47
47
|
/** Employee API endpoint URL for user identity lookup (e.g., https://node.example.com/admin_api/users/employees/) */
|
|
48
|
-
employeeApiEndpoint: zod.z.string().optional()
|
|
48
|
+
employeeApiEndpoint: zod.z.string().optional(),
|
|
49
|
+
/** Document GUID for xAPI statement aggregation - baked into package at wrap time */
|
|
50
|
+
documentGuid: zod.z.string().optional(),
|
|
51
|
+
/** Version GUID for xAPI statement aggregation - unique per export */
|
|
52
|
+
versionGuid: zod.z.string().optional()
|
|
49
53
|
});
|
|
50
54
|
var BlockingAssetConfigSchema = zod.z.object({
|
|
51
55
|
/** Filename for the asset */
|
|
@@ -390,7 +394,9 @@ var DEFAULT_LRS_OPTIONS = {
|
|
|
390
394
|
autoDetectLrs: true,
|
|
391
395
|
employeeApiEndpoint: "",
|
|
392
396
|
lrsAuth: "",
|
|
393
|
-
lrsProxyEndpoint: ""
|
|
397
|
+
lrsProxyEndpoint: "",
|
|
398
|
+
documentGuid: "",
|
|
399
|
+
versionGuid: ""
|
|
394
400
|
};
|
|
395
401
|
function generateLrsBridgeCode(options) {
|
|
396
402
|
if (!options.enabled) {
|
|
@@ -404,6 +410,8 @@ function generateLrsBridgeCode(options) {
|
|
|
404
410
|
const employeeApiEndpoint = options.employeeApiEndpoint || "";
|
|
405
411
|
const lrsAuth = options.lrsAuth || "";
|
|
406
412
|
const lrsProxyEndpoint = options.lrsProxyEndpoint || "";
|
|
413
|
+
const documentGuid = options.documentGuid || "";
|
|
414
|
+
const versionGuid = options.versionGuid || "";
|
|
407
415
|
return `
|
|
408
416
|
// ==========================================================================
|
|
409
417
|
// PATCH-ADAMS LRS BRIDGE v2.2.0
|
|
@@ -434,6 +442,8 @@ function generateLrsBridgeCode(options) {
|
|
|
434
442
|
var EMPLOYEE_API_ENDPOINT = '${employeeApiEndpoint}';
|
|
435
443
|
var LRS_AUTH = '${lrsAuth}';
|
|
436
444
|
var LRS_PROXY_ENDPOINT = '${lrsProxyEndpoint}';
|
|
445
|
+
var DOCUMENT_GUID = '${documentGuid}';
|
|
446
|
+
var VERSION_GUID = '${versionGuid}';
|
|
437
447
|
|
|
438
448
|
// Bravais LRS endpoint pattern: https://lrs-{tenant}.bravais.com/XAPI/statements
|
|
439
449
|
// Example: core-acme.bravais.com -> lrs-acme.bravais.com
|
|
@@ -2079,6 +2089,17 @@ function generateLrsBridgeCode(options) {
|
|
|
2079
2089
|
tenantHomepage: null // https://{tenant}.bravais.com format
|
|
2080
2090
|
};
|
|
2081
2091
|
|
|
2092
|
+
// 0. Use baked-in GUIDs from Patch-Adams config (highest priority - set at wrap time)
|
|
2093
|
+
if (DOCUMENT_GUID) {
|
|
2094
|
+
info.guid = DOCUMENT_GUID;
|
|
2095
|
+
info.id = 'http://xyleme.com/bravais/document/' + DOCUMENT_GUID;
|
|
2096
|
+
log('Document GUID from baked-in config:', DOCUMENT_GUID);
|
|
2097
|
+
}
|
|
2098
|
+
if (VERSION_GUID) {
|
|
2099
|
+
info.versionGuid = VERSION_GUID;
|
|
2100
|
+
log('Version GUID from baked-in config:', VERSION_GUID);
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2082
2103
|
// 1. Extract shared link token and document ID from URL
|
|
2083
2104
|
info.sharedLinkToken = extractSharedLinkToken();
|
|
2084
2105
|
info.documentId = extractBravaisDocumentId();
|
|
@@ -2155,14 +2176,15 @@ function generateLrsBridgeCode(options) {
|
|
|
2155
2176
|
info.title = document.title;
|
|
2156
2177
|
}
|
|
2157
2178
|
|
|
2158
|
-
// 7. Get from PA metadata if available
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
info.
|
|
2163
|
-
info.
|
|
2164
|
-
info.
|
|
2165
|
-
info.
|
|
2179
|
+
// 7. Get from PA metadata if available (check both .courseMetadata and .course)
|
|
2180
|
+
var paMeta = (window.pa_patcher && window.pa_patcher.courseMetadata) ||
|
|
2181
|
+
(window.pa_patcher && window.pa_patcher.course) || null;
|
|
2182
|
+
if (paMeta) {
|
|
2183
|
+
info.documentId = paMeta.documentId || paMeta.courseId || info.documentId;
|
|
2184
|
+
if (!info.guid) info.guid = paMeta.guid || paMeta.courseGuid || null;
|
|
2185
|
+
if (!info.versionGuid) info.versionGuid = paMeta.versionGuid || null;
|
|
2186
|
+
info.title = (info.title === 'Rise Course') ? (paMeta.title || paMeta.courseTitle || info.title) : info.title;
|
|
2187
|
+
info.versionId = paMeta.versionId || info.versionId;
|
|
2166
2188
|
}
|
|
2167
2189
|
|
|
2168
2190
|
// 8. Build the course ID in Xyleme IRI format
|
|
@@ -3289,6 +3311,34 @@ function generateLrsBridgeCode(options) {
|
|
|
3289
3311
|
sendStatement(statement);
|
|
3290
3312
|
};
|
|
3291
3313
|
|
|
3314
|
+
/**
|
|
3315
|
+
* Re-extract actor from SCORM after LMSInitialize has been called.
|
|
3316
|
+
* Call this from the SCORM wrapper after scormInit() succeeds,
|
|
3317
|
+
* because the bridge initializes in <head> before LMSInitialize runs.
|
|
3318
|
+
*/
|
|
3319
|
+
LRS.refreshActor = function(callback) {
|
|
3320
|
+
log('refreshActor called - re-extracting from SCORM...');
|
|
3321
|
+
var previousName = LRS.actor ? LRS.actor.name : 'none';
|
|
3322
|
+
|
|
3323
|
+
// Re-run sync extraction (SCORM data should now be available)
|
|
3324
|
+
var newActor = extractActor();
|
|
3325
|
+
|
|
3326
|
+
if (isValidActor(newActor) && newActor.account && newActor.account.name !== 'unknown') {
|
|
3327
|
+
log('refreshActor: got valid actor:', newActor.name, newActor.account ? newActor.account.name : '');
|
|
3328
|
+
// Enhance with email lookup (async)
|
|
3329
|
+
extractActorAsync(function(enhancedActor) {
|
|
3330
|
+
if (window.console && window.console.info) {
|
|
3331
|
+
console.info('[PA-LRS] Actor refreshed: ' + previousName + ' -> ' + enhancedActor.name +
|
|
3332
|
+
(enhancedActor.mbox ? ' (' + enhancedActor.mbox + ')' : ''));
|
|
3333
|
+
}
|
|
3334
|
+
if (callback) callback(enhancedActor);
|
|
3335
|
+
});
|
|
3336
|
+
} else {
|
|
3337
|
+
log('refreshActor: no valid actor found after re-extraction');
|
|
3338
|
+
if (callback) callback(LRS.actor);
|
|
3339
|
+
}
|
|
3340
|
+
};
|
|
3341
|
+
|
|
3292
3342
|
// Course terminated/exited
|
|
3293
3343
|
LRS.courseTerminated = function() {
|
|
3294
3344
|
// Calculate duration
|
|
@@ -4294,7 +4344,9 @@ function buildJsBeforeOptions(config, metadata) {
|
|
|
4294
4344
|
autoDetectLrs: lrsBridgeConfig.autoDetectLrs,
|
|
4295
4345
|
lrsAuth: lrsBridgeConfig.lrsAuth,
|
|
4296
4346
|
lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint,
|
|
4297
|
-
employeeApiEndpoint: lrsBridgeConfig.employeeApiEndpoint
|
|
4347
|
+
employeeApiEndpoint: lrsBridgeConfig.employeeApiEndpoint,
|
|
4348
|
+
documentGuid: lrsBridgeConfig.documentGuid,
|
|
4349
|
+
versionGuid: lrsBridgeConfig.versionGuid
|
|
4298
4350
|
};
|
|
4299
4351
|
return {
|
|
4300
4352
|
remoteUrl: `${config.remoteDomain}/${config.localFolders.js}/${config.jsBefore.filename}`,
|