@patch-adams/core 1.4.21 → 1.4.23

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 CHANGED
@@ -393,7 +393,11 @@ var LrsBridgeConfigSchema = zod.z.object({
393
393
  /** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
394
394
  lrsProxyEndpoint: zod.z.string().optional(),
395
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()
396
+ employeeApiEndpoint: zod.z.string().optional(),
397
+ /** Document GUID for xAPI statement aggregation - baked into package at wrap time */
398
+ documentGuid: zod.z.string().optional(),
399
+ /** Version GUID for xAPI statement aggregation - unique per export */
400
+ versionGuid: zod.z.string().optional()
397
401
  });
398
402
  var BlockingAssetConfigSchema = zod.z.object({
399
403
  /** Filename for the asset */
@@ -738,6 +742,8 @@ function generateLrsBridgeCode(options) {
738
742
  const employeeApiEndpoint = options.employeeApiEndpoint || "";
739
743
  const lrsAuth = options.lrsAuth || "";
740
744
  const lrsProxyEndpoint = options.lrsProxyEndpoint || "";
745
+ const documentGuid = options.documentGuid || "";
746
+ const versionGuid = options.versionGuid || "";
741
747
  return `
742
748
  // ==========================================================================
743
749
  // PATCH-ADAMS LRS BRIDGE v2.2.0
@@ -768,6 +774,8 @@ function generateLrsBridgeCode(options) {
768
774
  var EMPLOYEE_API_ENDPOINT = '${employeeApiEndpoint}';
769
775
  var LRS_AUTH = '${lrsAuth}';
770
776
  var LRS_PROXY_ENDPOINT = '${lrsProxyEndpoint}';
777
+ var DOCUMENT_GUID = '${documentGuid}';
778
+ var VERSION_GUID = '${versionGuid}';
771
779
 
772
780
  // Bravais LRS endpoint pattern: https://lrs-{tenant}.bravais.com/XAPI/statements
773
781
  // Example: core-acme.bravais.com -> lrs-acme.bravais.com
@@ -2413,6 +2421,17 @@ function generateLrsBridgeCode(options) {
2413
2421
  tenantHomepage: null // https://{tenant}.bravais.com format
2414
2422
  };
2415
2423
 
2424
+ // 0. Use baked-in GUIDs from Patch-Adams config (highest priority - set at wrap time)
2425
+ if (DOCUMENT_GUID) {
2426
+ info.guid = DOCUMENT_GUID;
2427
+ info.id = 'http://xyleme.com/bravais/document/' + DOCUMENT_GUID;
2428
+ log('Document GUID from baked-in config:', DOCUMENT_GUID);
2429
+ }
2430
+ if (VERSION_GUID) {
2431
+ info.versionGuid = VERSION_GUID;
2432
+ log('Version GUID from baked-in config:', VERSION_GUID);
2433
+ }
2434
+
2416
2435
  // 1. Extract shared link token and document ID from URL
2417
2436
  info.sharedLinkToken = extractSharedLinkToken();
2418
2437
  info.documentId = extractBravaisDocumentId();
@@ -2489,14 +2508,15 @@ function generateLrsBridgeCode(options) {
2489
2508
  info.title = document.title;
2490
2509
  }
2491
2510
 
2492
- // 7. Get from PA metadata if available
2493
- if (window.pa_patcher && window.pa_patcher.courseMetadata) {
2494
- var meta = window.pa_patcher.courseMetadata;
2495
- info.documentId = meta.documentId || meta.courseId || info.documentId;
2496
- info.guid = meta.guid || meta.courseGuid || info.guid;
2497
- info.versionGuid = meta.versionGuid || info.versionGuid;
2498
- info.title = meta.title || meta.courseTitle || info.title;
2499
- info.versionId = meta.versionId || info.versionId;
2511
+ // 7. Get from PA metadata if available (check both .courseMetadata and .course)
2512
+ var paMeta = (window.pa_patcher && window.pa_patcher.courseMetadata) ||
2513
+ (window.pa_patcher && window.pa_patcher.course) || null;
2514
+ if (paMeta) {
2515
+ info.documentId = paMeta.documentId || paMeta.courseId || info.documentId;
2516
+ if (!info.guid) info.guid = paMeta.guid || paMeta.courseGuid || null;
2517
+ if (!info.versionGuid) info.versionGuid = paMeta.versionGuid || null;
2518
+ info.title = (info.title === 'Rise Course') ? (paMeta.title || paMeta.courseTitle || info.title) : info.title;
2519
+ info.versionId = paMeta.versionId || info.versionId;
2500
2520
  }
2501
2521
 
2502
2522
  // 8. Build the course ID in Xyleme IRI format
@@ -3629,6 +3649,24 @@ function generateLrsBridgeCode(options) {
3629
3649
  * because the bridge initializes in <head> before LMSInitialize runs.
3630
3650
  */
3631
3651
  LRS.refreshActor = function(callback) {
3652
+ // Always-visible diagnostic: confirm refreshActor is being called and show SCORM data (TEMPORARY)
3653
+ if (window.console && window.console.info) {
3654
+ var scormId = 'n/a', scormName = 'n/a';
3655
+ if (LRS.scormApi) {
3656
+ try {
3657
+ scormId = LRS.scormApiType === '2004'
3658
+ ? LRS.scormApi.GetValue('cmi.learner_id')
3659
+ : LRS.scormApi.LMSGetValue('cmi.core.student_id');
3660
+ scormName = LRS.scormApiType === '2004'
3661
+ ? LRS.scormApi.GetValue('cmi.learner_name')
3662
+ : LRS.scormApi.LMSGetValue('cmi.core.student_name');
3663
+ } catch(e) { scormId = 'error'; scormName = 'error'; }
3664
+ }
3665
+ console.info('[PA-LRS] refreshActor called. SCORM API=' + (LRS.scormApi ? 'found' : 'MISSING') +
3666
+ ', student_id=' + scormId +
3667
+ ', student_name=' + scormName +
3668
+ ', previous actor=' + (LRS.actor ? LRS.actor.name : 'none'));
3669
+ }
3632
3670
  log('refreshActor called - re-extracting from SCORM...');
3633
3671
  var previousName = LRS.actor ? LRS.actor.name : 'none';
3634
3672
 
@@ -4376,10 +4414,13 @@ function generateLrsBridgeCode(options) {
4376
4414
  // Always-visible bridge summary (not gated by DEBUG)
4377
4415
  // This ensures diagnostics are available even in production builds
4378
4416
  if (window.console && window.console.info) {
4379
- console.info('[PA-LRS] Bridge: mode=' + LRS.mode +
4417
+ console.info('[PA-LRS] Bridge v' + LRS.version + ': mode=' + LRS.mode +
4380
4418
  ', endpoint=' + (LRS_ENDPOINT ? LRS_ENDPOINT.substring(0, 30) + '...' : 'NONE') +
4381
4419
  ', proxy=' + (LRS_PROXY_ENDPOINT ? 'yes' : 'no') +
4382
- ', actor=' + (LRS.actor ? (LRS.actor.name || 'anonymous') : 'none'));
4420
+ ', docGuid=' + (DOCUMENT_GUID || 'NONE') +
4421
+ ', verGuid=' + (VERSION_GUID || 'NONE') +
4422
+ ', actor=' + (LRS.actor ? (LRS.actor.name || 'anonymous') : 'none') +
4423
+ ', hasRefreshActor=' + (typeof LRS.refreshActor === 'function'));
4383
4424
  }
4384
4425
 
4385
4426
  // Set up event interceptors
@@ -4656,7 +4697,9 @@ function buildJsBeforeOptions(config, metadata) {
4656
4697
  autoDetectLrs: lrsBridgeConfig.autoDetectLrs,
4657
4698
  lrsAuth: lrsBridgeConfig.lrsAuth,
4658
4699
  lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint,
4659
- employeeApiEndpoint: lrsBridgeConfig.employeeApiEndpoint
4700
+ employeeApiEndpoint: lrsBridgeConfig.employeeApiEndpoint,
4701
+ documentGuid: lrsBridgeConfig.documentGuid,
4702
+ versionGuid: lrsBridgeConfig.versionGuid
4660
4703
  };
4661
4704
  return {
4662
4705
  remoteUrl: `${config.remoteDomain}/${config.localFolders.js}/${config.jsBefore.filename}`,