@learnpack/learnpack 5.0.240 → 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
@@ -427,6 +427,7 @@ type TAssetMissing = {
427
427
  author: number
428
428
  preview: string
429
429
  readme_raw: string
430
+ all_translations: string[]
430
431
  }
431
432
 
432
433
  export const createAsset = async (token: string, asset: TAssetMissing) => {
@@ -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
  }
@@ -330,6 +330,28 @@ export const createStructuredPreviewReadme = async (
330
330
  return response.data
331
331
  }
332
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
+
333
355
  export async function createPreviewReadme(
334
356
  tutorialDir: string,
335
357
  packageInfo: PackageInfo,