@learnpack/learnpack 5.0.202 → 5.0.209

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
@@ -122,13 +122,14 @@ export function checkReadability(
122
122
  export const slugify = (text: string) => {
123
123
  return text
124
124
  .toString()
125
- .normalize("NFD")
126
- .replace(/[\u0300-\u036F]/g, "") // Elimina acentos
125
+ .normalize("NFD") // Remove accents
126
+ .replace(/[\u0300-\u036F]/g, "") // Remove diacritics
127
127
  .toLowerCase()
128
128
  .trim()
129
- .replace(/\s+/g, "-")
130
- .replace(/["*/:<>?\\|]/g, "")
131
- .replace(/-+/g, "-")
129
+ .replace(/[^\d\s._a-z-]/g, "") // Hyphen at the end, no escape needed
130
+ .replace(/\s+/g, "-") // Replace spaces with hyphens
131
+ .replace(/-+/g, "-") // Remove duplicate hyphens
132
+ .replace(/^-+|-+$/g, "") // Trim hyphens from start/end
132
133
  }
133
134
 
134
135
  export const getExInfo = (title: string) => {
@@ -13,21 +13,24 @@ type TCreateReadmeInputs = {
13
13
  tutorial_description: string
14
14
  include_quiz: string
15
15
  lesson_description: string
16
+ prev_lesson: string
16
17
  }
17
18
 
18
19
  export const createReadme = async (
19
20
  token: string,
20
21
  inputs: TCreateReadmeInputs,
21
- purpose: string
22
+ purpose: string,
23
+ webhookUrl?: string
22
24
  ) => {
23
25
  try {
24
26
  const response = await axios.post(
25
- `${RIGOBOT_HOST}/v1/prompting/completion/423/`,
27
+ `${RIGOBOT_HOST}/v1/prompting/completion/create-sequencial-readme/`,
26
28
  {
27
29
  inputs,
28
30
  include_purpose_objective: true,
29
- execute_async: false,
31
+ execute_async: !!webhookUrl,
30
32
  purpose_slug: purpose,
33
+ webhook_url: webhookUrl,
31
34
  },
32
35
  {
33
36
  headers: {
@@ -57,8 +60,7 @@ export const hasCreatorPermission = async (token: string) => {
57
60
  )
58
61
 
59
62
  // If the status code is 403, it means no permission
60
- if (response.status === 403)
61
- return false
63
+ if (response.status === 403) return false
62
64
 
63
65
  Console.debug("The user is a creator! 🎉")
64
66
  return true
@@ -216,24 +218,27 @@ export const createCodeFile = async (
216
218
  }
217
219
 
218
220
  type TCreateCodingReadmeInputs = {
219
- tutorial_description: string
220
- list_of_exercises: string
221
- output_lang: string
222
221
  title: string
222
+ output_lang: string
223
+ prev_lesson: string
224
+ tutorial_info: string
225
+ list_of_exercises: string
223
226
  lesson_description: string
224
227
  }
225
228
  export const createCodingReadme = async (
226
229
  token: string,
227
230
  inputs: TCreateCodingReadmeInputs,
228
- purpose: string
231
+ purpose: string,
232
+ webhookUrl?: string
229
233
  ) => {
230
234
  const response = await axios.post(
231
- `${RIGOBOT_HOST}/v1/prompting/completion/489/`,
235
+ `${RIGOBOT_HOST}/v1/prompting/completion/create-coding-exercise/`,
232
236
  {
233
237
  inputs,
234
238
  include_purpose_objective: true,
235
239
  purpose_slug: purpose,
236
- execute_async: false,
240
+ execute_async: !!webhookUrl,
241
+ webhook_url: webhookUrl,
237
242
  },
238
243
  {
239
244
  headers: {
@@ -253,12 +258,14 @@ type TReadmeCreatorInputs = {
253
258
  title: string
254
259
  lesson_description: string
255
260
  kind: string
261
+ last_lesson: string
256
262
  }
257
263
 
258
264
  export const readmeCreator = async (
259
265
  token: string,
260
266
  inputs: TReadmeCreatorInputs,
261
- purpose: string
267
+ purpose: string,
268
+ webhookUrl?: string
262
269
  ) => {
263
270
  if (inputs.kind === "quiz" || inputs.kind === "read") {
264
271
  const createReadmeInputs: TCreateReadmeInputs = {
@@ -268,8 +275,9 @@ export const readmeCreator = async (
268
275
  tutorial_description: inputs.tutorial_description,
269
276
  include_quiz: inputs.kind === "quiz" ? "true" : "false",
270
277
  lesson_description: inputs.lesson_description,
278
+ prev_lesson: inputs.last_lesson,
271
279
  }
272
- return createReadme(token, createReadmeInputs, purpose)
280
+ return createReadme(token, createReadmeInputs, purpose, webhookUrl)
273
281
  }
274
282
 
275
283
  if (inputs.kind === "code") {
@@ -279,10 +287,12 @@ export const readmeCreator = async (
279
287
  title: inputs.title,
280
288
  output_lang: inputs.output_lang,
281
289
  list_of_exercises: inputs.list_of_exercises,
282
- tutorial_description: inputs.tutorial_description,
290
+ tutorial_info: inputs.tutorial_description,
283
291
  lesson_description: inputs.lesson_description,
292
+ prev_lesson: inputs.last_lesson,
284
293
  },
285
- purpose
294
+ purpose,
295
+ webhookUrl
286
296
  )
287
297
  }
288
298