@learnpack/learnpack 5.0.362 → 5.0.364

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.
Files changed (55) hide show
  1. package/lib/commands/serve.js +444 -279
  2. package/lib/creatorDist/assets/{index-B7s5Nmq8.css → index-Cco3XhDR.css} +96 -0
  3. package/lib/creatorDist/assets/{index-CKg5uuoj.js → index-o3Cw0bsF.js} +69620 -66788
  4. package/lib/creatorDist/index.html +2 -2
  5. package/lib/models/creator.d.ts +1 -0
  6. package/lib/utils/api.d.ts +0 -9
  7. package/lib/utils/api.js +1 -65
  8. package/lib/utils/generationRetry.d.ts +48 -0
  9. package/lib/utils/generationRetry.js +81 -0
  10. package/lib/utils/interactivity/componentsGuide.d.ts +50 -0
  11. package/lib/utils/interactivity/componentsGuide.js +193 -0
  12. package/lib/utils/interactivity/interactivityPlan.d.ts +20 -0
  13. package/lib/utils/interactivity/interactivityPlan.js +33 -0
  14. package/lib/utils/interactivity/structuredComponents.d.ts +34 -0
  15. package/lib/utils/interactivity/structuredComponents.js +792 -0
  16. package/lib/utils/rigoActions.d.ts +1 -1
  17. package/lib/utils/rigoActions.js +2 -2
  18. package/package.json +1 -1
  19. package/src/commands/serve.ts +653 -397
  20. package/src/creator/package-lock.json +297 -3
  21. package/src/creator/package.json +1 -0
  22. package/src/creator/src/App.test.tsx +124 -1
  23. package/src/creator/src/App.tsx +52 -36
  24. package/src/creator/src/components/FileCard.tsx +63 -19
  25. package/src/creator/src/components/FileReadListener.test.tsx +128 -0
  26. package/src/creator/src/components/FileReadListener.tsx +75 -0
  27. package/src/creator/src/components/FileReviewModal.test.tsx +193 -0
  28. package/src/creator/src/components/FileReviewModal.tsx +128 -0
  29. package/src/creator/src/components/FileUploader.test.tsx +229 -0
  30. package/src/creator/src/components/FileUploader.tsx +212 -58
  31. package/src/creator/src/components/GenerationErrorCard.tsx +57 -0
  32. package/src/creator/src/components/MarkdownRenderer.tsx +4 -2
  33. package/src/creator/src/components/syllabus/SyllabusEditor.tsx +6 -9
  34. package/src/creator/src/index.css +45 -0
  35. package/src/creator/src/locales/en.json +27 -5
  36. package/src/creator/src/locales/es.json +27 -5
  37. package/src/creator/src/main.tsx +2 -0
  38. package/src/creator/src/utils/completionResult.test.ts +61 -0
  39. package/src/creator/src/utils/completionResult.ts +61 -2
  40. package/src/creator/src/utils/courseLanguage.test.ts +6 -0
  41. package/src/creator/src/utils/creationRequest.test.ts +53 -18
  42. package/src/creator/src/utils/creationRequest.ts +17 -12
  43. package/src/creator/src/utils/fileRead.ts +60 -0
  44. package/src/creator/src/utils/lib.ts +0 -5
  45. package/src/creator/src/utils/store.ts +0 -10
  46. package/src/creatorDist/assets/{index-B7s5Nmq8.css → index-Cco3XhDR.css} +96 -0
  47. package/src/creatorDist/assets/{index-CKg5uuoj.js → index-o3Cw0bsF.js} +69620 -66788
  48. package/src/creatorDist/index.html +2 -2
  49. package/src/models/creator.ts +87 -84
  50. package/src/utils/api.ts +0 -83
  51. package/src/utils/generationRetry.ts +100 -0
  52. package/src/utils/interactivity/componentsGuide.ts +294 -0
  53. package/src/utils/interactivity/interactivityPlan.ts +57 -0
  54. package/src/utils/interactivity/structuredComponents.ts +1004 -0
  55. package/src/utils/rigoActions.ts +3 -2
@@ -0,0 +1,57 @@
1
+ // Which interactivity template a lesson uses, and what happens when it fails.
2
+ //
3
+ // v2 (structured) returns component data that the CLI renders; v1 is the
4
+ // original template, which writes the component markdown itself. The webhook
5
+ // URL carries the template, because rigobot posts back to that exact URL and
6
+ // its error payload does not say it. How many retries a lesson gets is decided
7
+ // by utils/generationRetry.ts, as for the other generation phases.
8
+
9
+ export const INTERACTIVITY_V1_SLUG = "add-lesson-interactivy"
10
+ export const INTERACTIVITY_V2_SLUG = "add-lesson-interactivity-v2"
11
+
12
+ export type InteractivityTemplate = "v1" | "v2";
13
+
14
+ export const isInteractivityV2Enabled = (
15
+ env: Record<string, string | undefined> = process.env
16
+ ): boolean => env.INTERACTIVITY_V2 === "true"
17
+
18
+ export interface InteractivityRequest {
19
+ tpl: InteractivityTemplate;
20
+ slug: string;
21
+ webhookQuery: string;
22
+ }
23
+
24
+ export const planInteractivityRequest = ({
25
+ v2Enabled,
26
+ forceV1 = false,
27
+ }: {
28
+ v2Enabled: boolean;
29
+ forceV1?: boolean;
30
+ }): InteractivityRequest => {
31
+ const tpl: InteractivityTemplate = v2Enabled && !forceV1 ? "v2" : "v1"
32
+ return {
33
+ tpl,
34
+ slug: tpl === "v2" ? INTERACTIVITY_V2_SLUG : INTERACTIVITY_V1_SLUG,
35
+ webhookQuery: `?tpl=${tpl}`,
36
+ }
37
+ }
38
+
39
+ export interface InteractivityFailure {
40
+ // The failed job used the structured template.
41
+ fromV2: boolean;
42
+ // The error text that decides whether the lesson is retried.
43
+ retryStatusText: unknown;
44
+ }
45
+
46
+ // After a failed job. Every retry uses v1, so a problem of the new template
47
+ // never blocks a lesson. An error that would repeat normally stops the retries,
48
+ // but when the v2 template fails that says nothing about v1, so the error is
49
+ // not passed on and v1 gets its retry within the usual cap. Jobs started
50
+ // before this change have no query and count as v1.
51
+ export const describeInteractivityFailure = (
52
+ query: { tpl?: unknown },
53
+ statusText: unknown
54
+ ): InteractivityFailure => {
55
+ const fromV2 = query.tpl === "v2"
56
+ return { fromV2, retryStatusText: fromV2 ? undefined : statusText }
57
+ }