@learnpack/learnpack 5.0.238 → 5.0.244

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/src/ui/app.tar.gz CHANGED
Binary file
package/src/utils/api.ts CHANGED
@@ -426,6 +426,8 @@ type TAssetMissing = {
426
426
  owner: number
427
427
  author: number
428
428
  preview: string
429
+ readme_raw: string
430
+ all_translations: string[]
429
431
  }
430
432
 
431
433
  export const createAsset = async (token: string, asset: TAssetMissing) => {
@@ -454,6 +456,7 @@ export const createAsset = async (token: string, asset: TAssetMissing) => {
454
456
  translations: [asset.lang],
455
457
  learnpack_deploy_url: asset.learnpack_deploy_url,
456
458
  technologies: asset.technologies,
459
+ readme_raw: asset.readme_raw,
457
460
  }
458
461
  const url = `https://breathecode.herokuapp.com/v1/registry/asset/me`
459
462
  const headers = {
@@ -22,8 +22,7 @@ export function initSocketIO(server: any) {
22
22
 
23
23
  socket.on("register", (data: { courseSlug: string }) => {
24
24
  const { courseSlug } = data
25
- if (!courseSlug)
26
- return
25
+ if (!courseSlug) return
27
26
 
28
27
  if (!courseSocketMap.has(courseSlug)) {
29
28
  courseSocketMap.set(courseSlug, new Set())
@@ -35,8 +34,7 @@ return
35
34
 
36
35
  socket.on("registerNotification", (data: { notificationId: string }) => {
37
36
  const { notificationId } = data
38
- if (!notificationId)
39
- return
37
+ if (!notificationId) return
40
38
 
41
39
  if (!notificationSocketMap.has(notificationId)) {
42
40
  notificationSocketMap.set(notificationId, new Set())
@@ -63,31 +61,39 @@ return
63
61
 
64
62
  export function emitToCourse(courseSlug: string, event: string, payload: any) {
65
63
  const socketIds = courseSocketMap.get(courseSlug)
66
- if (!socketIds || socketIds.size === 0)
67
- return
64
+ if (!socketIds || socketIds.size === 0) return
68
65
 
69
66
  for (const id of socketIds) {
70
67
  const socket = socketStore.get(id)
71
- if (socket)
72
- socket.emit(event, payload)
68
+ if (socket) socket.emit(event, payload)
73
69
  }
74
70
  }
75
71
 
76
- export function emitToNotification(notificationId: string, payload: any) {
77
- console.log("Emitting to notification", notificationId, payload)
72
+ export function emitToNotification(
73
+ notificationId: string,
74
+ payload: any,
75
+ retry = 0
76
+ ) {
78
77
  const socketIds = notificationSocketMap.get(notificationId)
79
- if (!socketIds || socketIds.size === 0)
80
- return
78
+ if (!socketIds || socketIds.size === 0) {
79
+ if (retry > 3) {
80
+ console.log("❌ Notification", notificationId, "not found")
81
+ return
82
+ }
83
+
84
+ setTimeout(() => {
85
+ emitToNotification(notificationId, payload, retry + 1)
86
+ }, 3000)
87
+ return
88
+ }
81
89
 
82
90
  for (const id of socketIds) {
83
91
  const socket = socketStore.get(id)
84
- if (socket)
85
- socket.emit(notificationId, payload)
92
+ if (socket) socket.emit(notificationId, payload)
86
93
  }
87
94
  }
88
95
 
89
96
  export function getSocketIO() {
90
- if (!io)
91
- throw new Error("Socket.IO not initialized")
97
+ if (!io) throw new Error("Socket.IO not initialized")
92
98
  return io
93
99
  }
@@ -72,17 +72,21 @@ export const hasCreatorPermission = async (token: string) => {
72
72
 
73
73
  type TGenerateImageParams = {
74
74
  prompt: string
75
+ callbackUrl: string
75
76
  }
76
77
 
77
78
  export const generateImage = async (
78
79
  token: string,
79
- { prompt }: TGenerateImageParams
80
+ { prompt, callbackUrl }: TGenerateImageParams
80
81
  ) => {
81
82
  try {
82
83
  const response = await axios.post(
83
84
  `${RIGOBOT_HOST}/v1/learnpack/tools/images`,
84
85
  {
85
86
  prompt,
87
+ webhook_callback_url: callbackUrl,
88
+ provider: "bfl",
89
+ model: "flux-pro-1.1",
86
90
  },
87
91
  {
88
92
  headers: {
@@ -299,6 +303,55 @@ export const readmeCreator = async (
299
303
  throw new Error("Invalid kind of lesson")
300
304
  }
301
305
 
306
+ type TCreateStructuredPreviewReadmeInputs = {
307
+ tutorial_info: string
308
+ }
309
+
310
+ export const createStructuredPreviewReadme = async (
311
+ token: string,
312
+ inputs: TCreateStructuredPreviewReadmeInputs,
313
+ webhookUrl?: string
314
+ ) => {
315
+ const response = await axios.post(
316
+ `${RIGOBOT_HOST}/v1/prompting/completion/write-course-introduction-readme/`,
317
+ {
318
+ inputs: inputs,
319
+ include_purpose_objective: false,
320
+ webhook_url: webhookUrl,
321
+ },
322
+ {
323
+ headers: {
324
+ "Content-Type": "application/json",
325
+ Authorization: "Token " + token,
326
+ },
327
+ }
328
+ )
329
+
330
+ return response.data
331
+ }
332
+
333
+ export const translateCourseMetadata = async (
334
+ token: string,
335
+ inputs: {
336
+ title: string
337
+ description: string
338
+ destination_lang_code: string
339
+ }
340
+ ) => {
341
+ const response = await axios.post(
342
+ `${RIGOBOT_HOST}/v1/prompting/completion/translate-course-metadata/`,
343
+ { inputs, include_purpose_objective: false, execute_async: false },
344
+ {
345
+ headers: {
346
+ "Content-Type": "application/json",
347
+ Authorization: "Token " + token,
348
+ },
349
+ }
350
+ )
351
+
352
+ return response.data
353
+ }
354
+
302
355
  export async function createPreviewReadme(
303
356
  tutorialDir: string,
304
357
  packageInfo: PackageInfo,
@@ -1 +0,0 @@
1
- {"version":"5.0.236","commands":{"audit":{"id":"audit","description":"learnpack audit is the command in charge of creating an auditory of the repository\n...\nlearnpack audit checks for the following information in a repository:\n 1. The configuration object has slug, repository and description. (Error)\n 2. The command learnpack clean has been run. (Error)\n 3. If a markdown or test file doesn't have any content. (Error)\n 4. The links are accessing to valid servers. (Error)\n 5. The relative images are working (If they have the shortest path to the image or if the images exists in the assets). (Error)\n 6. The external images are working (If they are pointing to a valid server). (Error)\n 7. The exercises directory names are valid. (Error)\n 8. If an exercise doesn't have a README file. (Error)\n 9. The exercises array (Of the config file) has content. (Error)\n 10. The exercses have the same translations. (Warning)\n 11. The .gitignore file exists. (Warning)\n 12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"strict":{"name":"strict","type":"boolean","char":"s","description":"strict mode","allowNo":false}},"args":[]},"breakToken":{"id":"breakToken","description":"Break the token","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"grading":{"name":"grading","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"clean":{"id":"clean","description":"Clean the configuration object\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[]},"download":{"id":"download","description":"Describe the command here\n...\nExtra documentation goes here\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"init":{"id":"init","description":"Create a new learning package: Book, Tutorial or Exercise","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"grading":{"name":"grading","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"login":{"id":"login","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"logout":{"id":"logout","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"publish":{"id":"publish","description":"Builds the project by copying necessary files and directories into a zip file","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"strict":{"name":"strict","type":"boolean","char":"s","description":"strict mode","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"serve":{"id":"serve","description":"Runs a small server to build tutorials","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"server port"},"host":{"name":"host","type":"option","char":"h","description":"server host"},"debug":{"name":"debug","type":"boolean","char":"d","description":"debugger mode for more verbage","allowNo":false}},"args":[]},"start":{"id":"start","description":"Runs a small server with all the exercise instructions","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"server port"},"host":{"name":"host","type":"option","char":"h","description":"server host"},"disableGrading":{"name":"disableGrading","type":"boolean","char":"D","description":"disble grading functionality","allowNo":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Watch for file changes","allowNo":false},"editor":{"name":"editor","type":"option","char":"e","description":"[preview, extension]","options":["extension","preview"]},"version":{"name":"version","type":"option","char":"v","description":"E.g: 1.0.1"},"grading":{"name":"grading","type":"option","char":"g","description":"[isolated, incremental]","options":["isolated","incremental"]},"debug":{"name":"debug","type":"boolean","char":"d","description":"debugger mode for more verbage","allowNo":false}},"args":[]},"test":{"id":"test","description":"Test exercises","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[{"name":"exerciseSlug","description":"The name of the exercise to test","required":false,"hidden":false}]},"translate":{"id":"translate","description":"List all the lessons, the user is able of select many of them to translate to the given languages","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[]}}}