@learnpack/learnpack 5.0.347 → 5.0.348

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.
@@ -3271,6 +3271,7 @@ class ServeCommand extends SessionCommand_1.default {
3271
3271
  const addedLessons = [];
3272
3272
  let repairedTranslationsInLessons = 0;
3273
3273
  let repairedTranslationEntries = 0;
3274
+ let fixedLessons = 0;
3274
3275
  console.log(`📋 Checking ${syllabus.lessons.length} lessons in syllabus...`);
3275
3276
  // First pass: Check each lesson to see if it exists in the bucket and count files.
3276
3277
  // We try two possible folder names because they can differ by source:
@@ -3468,15 +3469,39 @@ class ServeCommand extends SessionCommand_1.default {
3468
3469
  repairedTranslationsInLessons += 1;
3469
3470
  }
3470
3471
  }
3472
+ // Fifth pass: fix lessons stuck in GENERATING or ERROR when the file exists in the bucket
3473
+ const primaryLanguage = syllabus.courseInfo.language || "en";
3474
+ for (const lesson of syllabus.lessons) {
3475
+ if (lesson.generated !== false)
3476
+ continue;
3477
+ if (lesson.status !== "GENERATING" && lesson.status !== "ERROR")
3478
+ continue;
3479
+ const candidateSlugs = [
3480
+ (0, creatorUtilities_2.slugify)(lesson.id + "-" + lesson.title),
3481
+ lesson.uid,
3482
+ ].filter(Boolean);
3483
+ const matchedSlug = candidateSlugs.find(s => translationsBySlug.has(s));
3484
+ if (!matchedSlug)
3485
+ continue;
3486
+ const langs = translationsBySlug.get(matchedSlug) || [];
3487
+ if (!langs.includes(primaryLanguage))
3488
+ continue;
3489
+ const prevStatus = lesson.status;
3490
+ lesson.generated = true;
3491
+ lesson.status = "DONE";
3492
+ fixedLessons += 1;
3493
+ console.log(`🔧 Fixed lesson: ${lesson.id} - "${lesson.title}" (was generated:false status:${prevStatus}, primary language "${primaryLanguage}" exists in bucket)`);
3494
+ }
3471
3495
  }
3472
3496
  catch (error) {
3473
3497
  console.error("⚠️ Could not reconcile lesson translations during syllabus sync:", error);
3474
3498
  }
3475
3499
  if (totalRemoved > 0 ||
3476
3500
  addedLessons.length > 0 ||
3477
- repairedTranslationsInLessons > 0) {
3501
+ repairedTranslationsInLessons > 0 ||
3502
+ fixedLessons > 0) {
3478
3503
  await saveSyllabus(courseSlug, syllabus, bucket);
3479
- console.log(`✅ Syllabus synchronized. Removed ${removedLessons.length} non-existent, ${duplicatesRemoved.length} duplicate(s); added ${addedLessons.length} from bucket; repaired translations in ${repairedTranslationsInLessons} lesson(s).`);
3504
+ console.log(`✅ Syllabus synchronized. Removed ${removedLessons.length} non-existent, ${duplicatesRemoved.length} duplicate(s); added ${addedLessons.length} from bucket; repaired translations in ${repairedTranslationsInLessons} lesson(s); fixed ${fixedLessons} stuck lesson(s).`);
3480
3505
  }
3481
3506
  else {
3482
3507
  console.log(`✅ Syllabus is already in sync. No changes.`);
@@ -3489,6 +3514,7 @@ class ServeCommand extends SessionCommand_1.default {
3489
3514
  removedLessons: removedLessons.length,
3490
3515
  duplicatesResolved: duplicatesRemoved.length,
3491
3516
  addedLessons: addedLessons.length,
3517
+ fixedLessons,
3492
3518
  repairedTranslationsInLessons,
3493
3519
  repairedTranslationEntries,
3494
3520
  removed: removedLessons,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@learnpack/learnpack",
3
3
  "description": "Seamlessly build, sell and/or take interactive & auto-graded tutorials, start learning now or build a new tutorial to your audience.",
4
- "version": "5.0.347",
4
+ "version": "5.0.348",
5
5
  "author": "Alejandro Sanchez @alesanchezr",
6
6
  "contributors": [
7
7
  {
@@ -4741,6 +4741,7 @@ class ServeCommand extends SessionCommand {
4741
4741
  }> = []
4742
4742
  let repairedTranslationsInLessons = 0
4743
4743
  let repairedTranslationEntries = 0
4744
+ let fixedLessons = 0
4744
4745
 
4745
4746
  console.log(
4746
4747
  `📋 Checking ${syllabus.lessons.length} lessons in syllabus...`
@@ -4983,6 +4984,35 @@ class ServeCommand extends SessionCommand {
4983
4984
  repairedTranslationsInLessons += 1
4984
4985
  }
4985
4986
  }
4987
+
4988
+ // Fifth pass: fix lessons stuck in GENERATING or ERROR when the file exists in the bucket
4989
+ const primaryLanguage = syllabus.courseInfo.language || "en"
4990
+ for (const lesson of syllabus.lessons) {
4991
+ if (lesson.generated !== false) continue
4992
+ if (lesson.status !== "GENERATING" && lesson.status !== "ERROR")
4993
+ continue
4994
+
4995
+ const candidateSlugs = [
4996
+ slugify(lesson.id + "-" + lesson.title),
4997
+ lesson.uid,
4998
+ ].filter(Boolean) as string[]
4999
+
5000
+ const matchedSlug = candidateSlugs.find(s =>
5001
+ translationsBySlug.has(s)
5002
+ )
5003
+ if (!matchedSlug) continue
5004
+
5005
+ const langs = translationsBySlug.get(matchedSlug) || []
5006
+ if (!langs.includes(primaryLanguage)) continue
5007
+
5008
+ const prevStatus = lesson.status
5009
+ lesson.generated = true
5010
+ lesson.status = "DONE"
5011
+ fixedLessons += 1
5012
+ console.log(
5013
+ `🔧 Fixed lesson: ${lesson.id} - "${lesson.title}" (was generated:false status:${prevStatus}, primary language "${primaryLanguage}" exists in bucket)`
5014
+ )
5015
+ }
4986
5016
  } catch (error) {
4987
5017
  console.error(
4988
5018
  "⚠️ Could not reconcile lesson translations during syllabus sync:",
@@ -4993,11 +5023,12 @@ class ServeCommand extends SessionCommand {
4993
5023
  if (
4994
5024
  totalRemoved > 0 ||
4995
5025
  addedLessons.length > 0 ||
4996
- repairedTranslationsInLessons > 0
5026
+ repairedTranslationsInLessons > 0 ||
5027
+ fixedLessons > 0
4997
5028
  ) {
4998
5029
  await saveSyllabus(courseSlug, syllabus, bucket)
4999
5030
  console.log(
5000
- `✅ Syllabus synchronized. Removed ${removedLessons.length} non-existent, ${duplicatesRemoved.length} duplicate(s); added ${addedLessons.length} from bucket; repaired translations in ${repairedTranslationsInLessons} lesson(s).`
5031
+ `✅ Syllabus synchronized. Removed ${removedLessons.length} non-existent, ${duplicatesRemoved.length} duplicate(s); added ${addedLessons.length} from bucket; repaired translations in ${repairedTranslationsInLessons} lesson(s); fixed ${fixedLessons} stuck lesson(s).`
5001
5032
  )
5002
5033
  } else {
5003
5034
  console.log(`✅ Syllabus is already in sync. No changes.`)
@@ -5011,6 +5042,7 @@ class ServeCommand extends SessionCommand {
5011
5042
  removedLessons: removedLessons.length,
5012
5043
  duplicatesResolved: duplicatesRemoved.length,
5013
5044
  addedLessons: addedLessons.length,
5045
+ fixedLessons,
5014
5046
  repairedTranslationsInLessons,
5015
5047
  repairedTranslationEntries,
5016
5048
  removed: removedLessons,