@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/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
- if (window.pa_patcher && window.pa_patcher.courseMetadata) {
2160
- var meta = window.pa_patcher.courseMetadata;
2161
- info.documentId = meta.documentId || meta.courseId || info.documentId;
2162
- info.guid = meta.guid || meta.courseGuid || info.guid;
2163
- info.versionGuid = meta.versionGuid || info.versionGuid;
2164
- info.title = meta.title || meta.courseTitle || info.title;
2165
- info.versionId = meta.versionId || info.versionId;
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
@@ -3295,6 +3317,24 @@ function generateLrsBridgeCode(options) {
3295
3317
  * because the bridge initializes in <head> before LMSInitialize runs.
3296
3318
  */
3297
3319
  LRS.refreshActor = function(callback) {
3320
+ // Always-visible diagnostic: confirm refreshActor is being called and show SCORM data (TEMPORARY)
3321
+ if (window.console && window.console.info) {
3322
+ var scormId = 'n/a', scormName = 'n/a';
3323
+ if (LRS.scormApi) {
3324
+ try {
3325
+ scormId = LRS.scormApiType === '2004'
3326
+ ? LRS.scormApi.GetValue('cmi.learner_id')
3327
+ : LRS.scormApi.LMSGetValue('cmi.core.student_id');
3328
+ scormName = LRS.scormApiType === '2004'
3329
+ ? LRS.scormApi.GetValue('cmi.learner_name')
3330
+ : LRS.scormApi.LMSGetValue('cmi.core.student_name');
3331
+ } catch(e) { scormId = 'error'; scormName = 'error'; }
3332
+ }
3333
+ console.info('[PA-LRS] refreshActor called. SCORM API=' + (LRS.scormApi ? 'found' : 'MISSING') +
3334
+ ', student_id=' + scormId +
3335
+ ', student_name=' + scormName +
3336
+ ', previous actor=' + (LRS.actor ? LRS.actor.name : 'none'));
3337
+ }
3298
3338
  log('refreshActor called - re-extracting from SCORM...');
3299
3339
  var previousName = LRS.actor ? LRS.actor.name : 'none';
3300
3340
 
@@ -4042,10 +4082,13 @@ function generateLrsBridgeCode(options) {
4042
4082
  // Always-visible bridge summary (not gated by DEBUG)
4043
4083
  // This ensures diagnostics are available even in production builds
4044
4084
  if (window.console && window.console.info) {
4045
- console.info('[PA-LRS] Bridge: mode=' + LRS.mode +
4085
+ console.info('[PA-LRS] Bridge v' + LRS.version + ': mode=' + LRS.mode +
4046
4086
  ', endpoint=' + (LRS_ENDPOINT ? LRS_ENDPOINT.substring(0, 30) + '...' : 'NONE') +
4047
4087
  ', proxy=' + (LRS_PROXY_ENDPOINT ? 'yes' : 'no') +
4048
- ', actor=' + (LRS.actor ? (LRS.actor.name || 'anonymous') : 'none'));
4088
+ ', docGuid=' + (DOCUMENT_GUID || 'NONE') +
4089
+ ', verGuid=' + (VERSION_GUID || 'NONE') +
4090
+ ', actor=' + (LRS.actor ? (LRS.actor.name || 'anonymous') : 'none') +
4091
+ ', hasRefreshActor=' + (typeof LRS.refreshActor === 'function'));
4049
4092
  }
4050
4093
 
4051
4094
  // Set up event interceptors
@@ -4322,7 +4365,9 @@ function buildJsBeforeOptions(config, metadata) {
4322
4365
  autoDetectLrs: lrsBridgeConfig.autoDetectLrs,
4323
4366
  lrsAuth: lrsBridgeConfig.lrsAuth,
4324
4367
  lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint,
4325
- employeeApiEndpoint: lrsBridgeConfig.employeeApiEndpoint
4368
+ employeeApiEndpoint: lrsBridgeConfig.employeeApiEndpoint,
4369
+ documentGuid: lrsBridgeConfig.documentGuid,
4370
+ versionGuid: lrsBridgeConfig.versionGuid
4326
4371
  };
4327
4372
  return {
4328
4373
  remoteUrl: `${config.remoteDomain}/${config.localFolders.js}/${config.jsBefore.filename}`,