@patch-adams/core 1.4.21 → 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.js CHANGED
@@ -384,7 +384,11 @@ var LrsBridgeConfigSchema = z.object({
384
384
  /** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
385
385
  lrsProxyEndpoint: z.string().optional(),
386
386
  /** Employee API endpoint URL for user identity lookup (e.g., https://node.example.com/admin_api/users/employees/) */
387
- employeeApiEndpoint: z.string().optional()
387
+ employeeApiEndpoint: z.string().optional(),
388
+ /** Document GUID for xAPI statement aggregation - baked into package at wrap time */
389
+ documentGuid: z.string().optional(),
390
+ /** Version GUID for xAPI statement aggregation - unique per export */
391
+ versionGuid: z.string().optional()
388
392
  });
389
393
  var BlockingAssetConfigSchema = z.object({
390
394
  /** Filename for the asset */
@@ -729,6 +733,8 @@ function generateLrsBridgeCode(options) {
729
733
  const employeeApiEndpoint = options.employeeApiEndpoint || "";
730
734
  const lrsAuth = options.lrsAuth || "";
731
735
  const lrsProxyEndpoint = options.lrsProxyEndpoint || "";
736
+ const documentGuid = options.documentGuid || "";
737
+ const versionGuid = options.versionGuid || "";
732
738
  return `
733
739
  // ==========================================================================
734
740
  // PATCH-ADAMS LRS BRIDGE v2.2.0
@@ -759,6 +765,8 @@ function generateLrsBridgeCode(options) {
759
765
  var EMPLOYEE_API_ENDPOINT = '${employeeApiEndpoint}';
760
766
  var LRS_AUTH = '${lrsAuth}';
761
767
  var LRS_PROXY_ENDPOINT = '${lrsProxyEndpoint}';
768
+ var DOCUMENT_GUID = '${documentGuid}';
769
+ var VERSION_GUID = '${versionGuid}';
762
770
 
763
771
  // Bravais LRS endpoint pattern: https://lrs-{tenant}.bravais.com/XAPI/statements
764
772
  // Example: core-acme.bravais.com -> lrs-acme.bravais.com
@@ -2404,6 +2412,17 @@ function generateLrsBridgeCode(options) {
2404
2412
  tenantHomepage: null // https://{tenant}.bravais.com format
2405
2413
  };
2406
2414
 
2415
+ // 0. Use baked-in GUIDs from Patch-Adams config (highest priority - set at wrap time)
2416
+ if (DOCUMENT_GUID) {
2417
+ info.guid = DOCUMENT_GUID;
2418
+ info.id = 'http://xyleme.com/bravais/document/' + DOCUMENT_GUID;
2419
+ log('Document GUID from baked-in config:', DOCUMENT_GUID);
2420
+ }
2421
+ if (VERSION_GUID) {
2422
+ info.versionGuid = VERSION_GUID;
2423
+ log('Version GUID from baked-in config:', VERSION_GUID);
2424
+ }
2425
+
2407
2426
  // 1. Extract shared link token and document ID from URL
2408
2427
  info.sharedLinkToken = extractSharedLinkToken();
2409
2428
  info.documentId = extractBravaisDocumentId();
@@ -2480,14 +2499,15 @@ function generateLrsBridgeCode(options) {
2480
2499
  info.title = document.title;
2481
2500
  }
2482
2501
 
2483
- // 7. Get from PA metadata if available
2484
- if (window.pa_patcher && window.pa_patcher.courseMetadata) {
2485
- var meta = window.pa_patcher.courseMetadata;
2486
- info.documentId = meta.documentId || meta.courseId || info.documentId;
2487
- info.guid = meta.guid || meta.courseGuid || info.guid;
2488
- info.versionGuid = meta.versionGuid || info.versionGuid;
2489
- info.title = meta.title || meta.courseTitle || info.title;
2490
- info.versionId = meta.versionId || info.versionId;
2502
+ // 7. Get from PA metadata if available (check both .courseMetadata and .course)
2503
+ var paMeta = (window.pa_patcher && window.pa_patcher.courseMetadata) ||
2504
+ (window.pa_patcher && window.pa_patcher.course) || null;
2505
+ if (paMeta) {
2506
+ info.documentId = paMeta.documentId || paMeta.courseId || info.documentId;
2507
+ if (!info.guid) info.guid = paMeta.guid || paMeta.courseGuid || null;
2508
+ if (!info.versionGuid) info.versionGuid = paMeta.versionGuid || null;
2509
+ info.title = (info.title === 'Rise Course') ? (paMeta.title || paMeta.courseTitle || info.title) : info.title;
2510
+ info.versionId = paMeta.versionId || info.versionId;
2491
2511
  }
2492
2512
 
2493
2513
  // 8. Build the course ID in Xyleme IRI format
@@ -4647,7 +4667,9 @@ function buildJsBeforeOptions(config, metadata) {
4647
4667
  autoDetectLrs: lrsBridgeConfig.autoDetectLrs,
4648
4668
  lrsAuth: lrsBridgeConfig.lrsAuth,
4649
4669
  lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint,
4650
- employeeApiEndpoint: lrsBridgeConfig.employeeApiEndpoint
4670
+ employeeApiEndpoint: lrsBridgeConfig.employeeApiEndpoint,
4671
+ documentGuid: lrsBridgeConfig.documentGuid,
4672
+ versionGuid: lrsBridgeConfig.versionGuid
4651
4673
  };
4652
4674
  return {
4653
4675
  remoteUrl: `${config.remoteDomain}/${config.localFolders.js}/${config.jsBefore.filename}`,