@patch-adams/core 1.4.32 → 1.4.34
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 +38 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +37 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +38 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +37 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -794,6 +794,11 @@ declare class ManifestUpdater {
|
|
|
794
794
|
* Uses string manipulation to preserve original XML formatting exactly
|
|
795
795
|
*/
|
|
796
796
|
private updateImsManifest;
|
|
797
|
+
/**
|
|
798
|
+
* Update the manifest identifier attribute to a new value.
|
|
799
|
+
* Used to ensure every course has a unique identifier (e.g., project UUID).
|
|
800
|
+
*/
|
|
801
|
+
updateIdentifier(zip: AdmZip, newIdentifier: string): boolean;
|
|
797
802
|
/**
|
|
798
803
|
* Get the file paths that will be added to the package
|
|
799
804
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -794,6 +794,11 @@ declare class ManifestUpdater {
|
|
|
794
794
|
* Uses string manipulation to preserve original XML formatting exactly
|
|
795
795
|
*/
|
|
796
796
|
private updateImsManifest;
|
|
797
|
+
/**
|
|
798
|
+
* Update the manifest identifier attribute to a new value.
|
|
799
|
+
* Used to ensure every course has a unique identifier (e.g., project UUID).
|
|
800
|
+
*/
|
|
801
|
+
updateIdentifier(zip: AdmZip, newIdentifier: string): boolean;
|
|
797
802
|
/**
|
|
798
803
|
* Get the file paths that will be added to the package
|
|
799
804
|
*/
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,10 @@ import { z } from 'zod';
|
|
|
2
2
|
import { existsSync, readFileSync } from 'fs';
|
|
3
3
|
import { resolve, extname } from 'path';
|
|
4
4
|
import { pathToFileURL } from 'url';
|
|
5
|
+
import crypto, { createHash } from 'crypto';
|
|
5
6
|
import AdmZip from 'adm-zip';
|
|
6
7
|
import archiver from 'archiver';
|
|
7
8
|
import { PassThrough } from 'stream';
|
|
8
|
-
import { createHash } from 'crypto';
|
|
9
9
|
import chalk from 'chalk';
|
|
10
10
|
|
|
11
11
|
// src/config/schema.ts
|
|
@@ -1294,8 +1294,8 @@ function generateLrsBridgeCode(options) {
|
|
|
1294
1294
|
var cached = localStorage.getItem(cacheKey);
|
|
1295
1295
|
if (cached) {
|
|
1296
1296
|
var parsed = JSON.parse(cached);
|
|
1297
|
-
// TTL: 7 days = 604800000 ms
|
|
1298
|
-
if (parsed.timestamp && (Date.now() - parsed.timestamp) < 604800000) {
|
|
1297
|
+
// TTL: 7 days = 604800000 ms; also invalidate if missing bravaisUserId (old cache)
|
|
1298
|
+
if (parsed.timestamp && (Date.now() - parsed.timestamp) < 604800000 && parsed.bravaisUserId) {
|
|
1299
1299
|
log('Employee data from localStorage cache');
|
|
1300
1300
|
employeeLookupData = parsed;
|
|
1301
1301
|
employeeLookupFetched = true;
|
|
@@ -5110,6 +5110,22 @@ $1</resource>`
|
|
|
5110
5110
|
return [];
|
|
5111
5111
|
}
|
|
5112
5112
|
}
|
|
5113
|
+
/**
|
|
5114
|
+
* Update the manifest identifier attribute to a new value.
|
|
5115
|
+
* Used to ensure every course has a unique identifier (e.g., project UUID).
|
|
5116
|
+
*/
|
|
5117
|
+
updateIdentifier(zip, newIdentifier) {
|
|
5118
|
+
const entry = zip.getEntry("imsmanifest.xml");
|
|
5119
|
+
if (!entry) return false;
|
|
5120
|
+
const xml = entry.getData().toString("utf-8");
|
|
5121
|
+
const updated = xml.replace(
|
|
5122
|
+
/(<manifest[^>]+identifier\s*=\s*["'])[^"']+(["'])/i,
|
|
5123
|
+
`$1${newIdentifier}$2`
|
|
5124
|
+
);
|
|
5125
|
+
if (updated === xml) return false;
|
|
5126
|
+
zip.updateFile("imsmanifest.xml", Buffer.from(updated, "utf-8"));
|
|
5127
|
+
return true;
|
|
5128
|
+
}
|
|
5113
5129
|
/**
|
|
5114
5130
|
* Get the file paths that will be added to the package
|
|
5115
5131
|
*/
|
|
@@ -5924,6 +5940,24 @@ var Patcher = class {
|
|
|
5924
5940
|
if (metadata.description) console.log(` - Description: ${metadata.description.substring(0, 50)}...`);
|
|
5925
5941
|
if (metadata.language) console.log(` - Language: ${metadata.language}`);
|
|
5926
5942
|
if (metadata.masteryScore !== null) console.log(` - Mastery Score: ${metadata.masteryScore}`);
|
|
5943
|
+
const configDocGuid = this.config.lrsBridge?.documentGuid;
|
|
5944
|
+
if (configDocGuid) {
|
|
5945
|
+
console.log(`[Patcher] Overriding courseId with documentGuid: ${configDocGuid}`);
|
|
5946
|
+
metadata.courseId = configDocGuid;
|
|
5947
|
+
metadata.courseIdSource = "manifest";
|
|
5948
|
+
result.courseId = configDocGuid;
|
|
5949
|
+
if (this.manifestUpdater.updateIdentifier(zip, configDocGuid)) {
|
|
5950
|
+
console.log(`[Patcher] Updated manifest identifier to: ${configDocGuid}`);
|
|
5951
|
+
}
|
|
5952
|
+
} else if (metadata.courseIdSource === "fallback") {
|
|
5953
|
+
const generated = crypto.randomUUID();
|
|
5954
|
+
console.log(`[Patcher] No course identifier found, generating UUID: ${generated}`);
|
|
5955
|
+
metadata.courseId = generated;
|
|
5956
|
+
result.courseId = generated;
|
|
5957
|
+
if (this.manifestUpdater.updateIdentifier(zip, generated)) {
|
|
5958
|
+
console.log(`[Patcher] Wrote generated UUID to manifest identifier`);
|
|
5959
|
+
}
|
|
5960
|
+
}
|
|
5927
5961
|
const htmlInjector = this.getHtmlInjector(toolInfo.tool);
|
|
5928
5962
|
htmlInjector.setMetadata(metadata);
|
|
5929
5963
|
let fetchedFallbacks = {};
|