@learnpack/learnpack 5.0.186 → 5.0.191
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/README.md +13 -13
- package/lib/commands/init.js +2 -2
- package/lib/commands/serve.d.ts +2 -1
- package/lib/commands/serve.js +9 -53
- package/lib/creatorDist/assets/index-Bnq3eZ3T.css +1 -1641
- package/lib/creatorDist/assets/index-CXaPa6wN.js +273 -0
- package/lib/creatorDist/index.html +1 -1
- package/lib/utils/rigoActions.d.ts +4 -4
- package/lib/utils/rigoActions.js +14 -8
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/init.ts +23 -15
- package/src/commands/serve.ts +36 -80
- package/src/creator/src/App.tsx +3 -2
- package/src/creator/src/components/FileUploader.tsx +87 -10
- package/src/creator/src/components/Login.tsx +24 -18
- package/src/creator/src/components/syllabus/SyllabusEditor.tsx +47 -34
- package/src/creator/src/utils/rigo.ts +7 -6
- package/src/creatorDist/assets/index-Bnq3eZ3T.css +1 -1641
- package/src/creatorDist/assets/index-CXaPa6wN.js +273 -0
- package/src/creatorDist/index.html +1 -1
- package/src/utils/rigoActions.ts +28 -14
- package/lib/creatorDist/assets/index-Cq3XE9_M.js +0 -35362
- package/src/creatorDist/assets/index-Cq3XE9_M.js +0 -35362
@@ -10,7 +10,7 @@
|
|
10
10
|
/>
|
11
11
|
|
12
12
|
<title>Learnpack Creator: Craft tutorials in seconds!</title>
|
13
|
-
<script type="module" crossorigin src="/creator/assets/index-
|
13
|
+
<script type="module" crossorigin src="/creator/assets/index-CXaPa6wN.js"></script>
|
14
14
|
<link rel="stylesheet" crossorigin href="/creator/assets/index-Bnq3eZ3T.css">
|
15
15
|
</head>
|
16
16
|
<body>
|
@@ -7,7 +7,7 @@ type TCreateReadmeInputs = {
|
|
7
7
|
include_quiz: string;
|
8
8
|
lesson_description: string;
|
9
9
|
};
|
10
|
-
export declare const createReadme: (token: string, inputs: TCreateReadmeInputs) => Promise<any>;
|
10
|
+
export declare const createReadme: (token: string, inputs: TCreateReadmeInputs, purpose: string) => Promise<any>;
|
11
11
|
export declare const hasCreatorPermission: (token: string) => Promise<boolean>;
|
12
12
|
type TGenerateImageParams = {
|
13
13
|
prompt: string;
|
@@ -42,7 +42,7 @@ type TCreateCodingReadmeInputs = {
|
|
42
42
|
title: string;
|
43
43
|
lesson_description: string;
|
44
44
|
};
|
45
|
-
export declare const createCodingReadme: (token: string, inputs: TCreateCodingReadmeInputs) => Promise<any>;
|
45
|
+
export declare const createCodingReadme: (token: string, inputs: TCreateCodingReadmeInputs, purpose: string) => Promise<any>;
|
46
46
|
type TReadmeCreatorInputs = {
|
47
47
|
tutorial_description: string;
|
48
48
|
list_of_exercises: string;
|
@@ -51,7 +51,7 @@ type TReadmeCreatorInputs = {
|
|
51
51
|
lesson_description: string;
|
52
52
|
kind: string;
|
53
53
|
};
|
54
|
-
export declare const readmeCreator: (token: string, inputs: TReadmeCreatorInputs) => Promise<any>;
|
54
|
+
export declare const readmeCreator: (token: string, inputs: TReadmeCreatorInputs, purpose: string) => Promise<any>;
|
55
55
|
export declare function createPreviewReadme(tutorialDir: string, packageInfo: PackageInfo, rigoToken: string, readmeContents: string[]): Promise<void>;
|
56
56
|
type TReduceReadmeInputs = {
|
57
57
|
lesson: string;
|
@@ -60,7 +60,7 @@ type TReduceReadmeInputs = {
|
|
60
60
|
fkgl_results: string;
|
61
61
|
expected_grade_level: string;
|
62
62
|
};
|
63
|
-
export declare function makeReadmeReadable(rigoToken: string, inputs: TReduceReadmeInputs): Promise<any>;
|
63
|
+
export declare function makeReadmeReadable(rigoToken: string, inputs: TReduceReadmeInputs, purpose: string): Promise<any>;
|
64
64
|
export declare const isValidRigoToken: (rigobotToken: string) => Promise<boolean>;
|
65
65
|
type TGenerateCourseShortNameInputs = {
|
66
66
|
learnJSON: string;
|
package/lib/utils/rigoActions.js
CHANGED
@@ -10,12 +10,13 @@ const console_1 = require("../utils/console");
|
|
10
10
|
const fs = require("fs");
|
11
11
|
const path = require("path");
|
12
12
|
const api_1 = require("./api");
|
13
|
-
const createReadme = async (token, inputs) => {
|
13
|
+
const createReadme = async (token, inputs, purpose) => {
|
14
14
|
try {
|
15
15
|
const response = await axios_1.default.post(`${api_1.RIGOBOT_HOST}/v1/prompting/completion/423/`, {
|
16
16
|
inputs,
|
17
|
-
include_purpose_objective:
|
17
|
+
include_purpose_objective: true,
|
18
18
|
execute_async: false,
|
19
|
+
purpose_slug: purpose,
|
19
20
|
}, {
|
20
21
|
headers: {
|
21
22
|
"Content-Type": "application/json",
|
@@ -130,8 +131,13 @@ const createCodeFile = async (token, inputs) => {
|
|
130
131
|
return response.data;
|
131
132
|
};
|
132
133
|
exports.createCodeFile = createCodeFile;
|
133
|
-
const createCodingReadme = async (token, inputs) => {
|
134
|
-
const response = await axios_1.default.post(`${api_1.RIGOBOT_HOST}/v1/prompting/completion/489/`, {
|
134
|
+
const createCodingReadme = async (token, inputs, purpose) => {
|
135
|
+
const response = await axios_1.default.post(`${api_1.RIGOBOT_HOST}/v1/prompting/completion/489/`, {
|
136
|
+
inputs,
|
137
|
+
include_purpose_objective: true,
|
138
|
+
purpose_slug: purpose,
|
139
|
+
execute_async: false,
|
140
|
+
}, {
|
135
141
|
headers: {
|
136
142
|
"Content-Type": "application/json",
|
137
143
|
Authorization: "Token " + token,
|
@@ -140,7 +146,7 @@ const createCodingReadme = async (token, inputs) => {
|
|
140
146
|
return response.data;
|
141
147
|
};
|
142
148
|
exports.createCodingReadme = createCodingReadme;
|
143
|
-
const readmeCreator = async (token, inputs) => {
|
149
|
+
const readmeCreator = async (token, inputs, purpose) => {
|
144
150
|
if (inputs.kind === "quiz" || inputs.kind === "read") {
|
145
151
|
const createReadmeInputs = {
|
146
152
|
title: inputs.title,
|
@@ -150,7 +156,7 @@ const readmeCreator = async (token, inputs) => {
|
|
150
156
|
include_quiz: inputs.kind === "quiz" ? "true" : "false",
|
151
157
|
lesson_description: inputs.lesson_description,
|
152
158
|
};
|
153
|
-
return (0, exports.createReadme)(token, createReadmeInputs);
|
159
|
+
return (0, exports.createReadme)(token, createReadmeInputs, purpose);
|
154
160
|
}
|
155
161
|
if (inputs.kind === "code") {
|
156
162
|
return (0, exports.createCodingReadme)(token, {
|
@@ -159,7 +165,7 @@ const readmeCreator = async (token, inputs) => {
|
|
159
165
|
list_of_exercises: inputs.list_of_exercises,
|
160
166
|
tutorial_description: inputs.tutorial_description,
|
161
167
|
lesson_description: inputs.lesson_description,
|
162
|
-
});
|
168
|
+
}, purpose);
|
163
169
|
}
|
164
170
|
throw new Error("Invalid kind of lesson");
|
165
171
|
};
|
@@ -172,7 +178,7 @@ async function createPreviewReadme(tutorialDir, packageInfo, rigoToken, readmeCo
|
|
172
178
|
});
|
173
179
|
fs.writeFileSync(path.join(tutorialDir, readmeFilename), readmeContent.answer);
|
174
180
|
}
|
175
|
-
async function makeReadmeReadable(rigoToken, inputs) {
|
181
|
+
async function makeReadmeReadable(rigoToken, inputs, purpose) {
|
176
182
|
try {
|
177
183
|
const response = await axios_1.default.post(`${api_1.RIGOBOT_HOST}/v1/prompting/completion/588/`, { inputs, include_purpose_objective: false, execute_async: false }, {
|
178
184
|
headers: {
|
package/oclif.manifest.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":"5.0.
|
1
|
+
{"version":"5.0.191","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":[]}}}
|
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.
|
4
|
+
"version": "5.0.191",
|
5
5
|
"author": "Alejandro Sanchez @alesanchezr",
|
6
6
|
"contributors": [
|
7
7
|
{
|
package/src/commands/init.ts
CHANGED
@@ -91,14 +91,18 @@ async function processExercise(
|
|
91
91
|
const { exNumber, exTitle, kind, description } = getExInfo(exercise)
|
92
92
|
const exerciseDir = path.join(exercisesDir, `${exNumber}-${exTitle}`)
|
93
93
|
|
94
|
-
const readme = await readmeCreator(
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
94
|
+
const readme = await readmeCreator(
|
95
|
+
rigoToken,
|
96
|
+
{
|
97
|
+
title: `${exNumber} - ${exTitle}`,
|
98
|
+
output_lang: "en",
|
99
|
+
list_of_exercises: steps.join(","),
|
100
|
+
tutorial_description: packageContext,
|
101
|
+
lesson_description: description,
|
102
|
+
kind: kind.toLowerCase(),
|
103
|
+
},
|
104
|
+
"learnpack-lesson-writer"
|
105
|
+
)
|
102
106
|
|
103
107
|
const duration = durationByKind[kind.toLowerCase()]
|
104
108
|
let attempts = 0
|
@@ -117,13 +121,17 @@ async function processExercise(
|
|
117
121
|
)
|
118
122
|
|
119
123
|
// eslint-disable-next-line
|
120
|
-
const reducedReadme = await makeReadmeReadable(
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
124
|
+
const reducedReadme = await makeReadmeReadable(
|
125
|
+
rigoToken,
|
126
|
+
{
|
127
|
+
lesson: readability.body,
|
128
|
+
number_of_words: readability.minutes.toString(),
|
129
|
+
expected_number_words: PARAMS.max_words.toString(),
|
130
|
+
fkgl_results: JSON.stringify(readability.fkglResult),
|
131
|
+
expected_grade_level: PARAMS.expected_grade_level,
|
132
|
+
},
|
133
|
+
"learnpack-lesson-writer"
|
134
|
+
)
|
127
135
|
|
128
136
|
// console.log("REDUCED README START", reducedReadme, "REDUCED README END")
|
129
137
|
|
package/src/commands/serve.ts
CHANGED
@@ -107,9 +107,9 @@ const uploadImageToBucket = async (
|
|
107
107
|
}
|
108
108
|
|
109
109
|
const PARAMS = {
|
110
|
-
expected_grade_level: "
|
111
|
-
max_fkgl:
|
112
|
-
max_words:
|
110
|
+
expected_grade_level: "8",
|
111
|
+
max_fkgl: 10,
|
112
|
+
max_words: 250,
|
113
113
|
max_rewrite_attempts: 2,
|
114
114
|
max_title_length: 50,
|
115
115
|
}
|
@@ -156,7 +156,8 @@ export async function processExercise(
|
|
156
156
|
packageContext: string,
|
157
157
|
exercise: Lesson,
|
158
158
|
exercisesDir: string,
|
159
|
-
courseSlug: string
|
159
|
+
courseSlug: string,
|
160
|
+
purposeSlug: string
|
160
161
|
): Promise<string> {
|
161
162
|
// const tid = toast.loading("Generating lesson...")
|
162
163
|
const exSlug = slugify(exercise.id + "-" + exercise.title)
|
@@ -179,14 +180,18 @@ export async function processExercise(
|
|
179
180
|
`${targetDir}/${readmeFilename}`
|
180
181
|
)
|
181
182
|
|
182
|
-
const readme = await readmeCreator(
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
183
|
+
const readme = await readmeCreator(
|
184
|
+
rigoToken,
|
185
|
+
{
|
186
|
+
title: `${exercise.id} - ${exercise.title}`,
|
187
|
+
output_lang: "en",
|
188
|
+
list_of_exercises: JSON.stringify(steps),
|
189
|
+
tutorial_description: packageContext,
|
190
|
+
lesson_description: exercise.description,
|
191
|
+
kind: exercise.type.toLowerCase(),
|
192
|
+
},
|
193
|
+
purposeSlug
|
194
|
+
)
|
190
195
|
|
191
196
|
const duration = exercise.duration
|
192
197
|
let attempts = 0
|
@@ -203,13 +208,17 @@ export async function processExercise(
|
|
203
208
|
})
|
204
209
|
|
205
210
|
// eslint-disable-next-line
|
206
|
-
const reducedReadme = await makeReadmeReadable(
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
211
|
+
const reducedReadme = await makeReadmeReadable(
|
212
|
+
rigoToken,
|
213
|
+
{
|
214
|
+
lesson: readability.body,
|
215
|
+
number_of_words: readability.minutes.toString(),
|
216
|
+
expected_number_words: PARAMS.max_words.toString(),
|
217
|
+
fkgl_results: JSON.stringify(readability.fkglResult),
|
218
|
+
expected_grade_level: PARAMS.expected_grade_level,
|
219
|
+
},
|
220
|
+
purposeSlug
|
221
|
+
)
|
213
222
|
|
214
223
|
if (!reducedReadme)
|
215
224
|
break
|
@@ -217,7 +226,7 @@ break
|
|
217
226
|
readability = checkReadability(
|
218
227
|
reducedReadme.parsed.content,
|
219
228
|
PARAMS.max_words,
|
220
|
-
duration ||
|
229
|
+
duration || 2
|
221
230
|
)
|
222
231
|
|
223
232
|
attempts++
|
@@ -281,6 +290,7 @@ type FormState = {
|
|
281
290
|
currentStep: string
|
282
291
|
title: string
|
283
292
|
technologies?: string[]
|
293
|
+
purpose: string
|
284
294
|
}
|
285
295
|
|
286
296
|
type Syllabus = {
|
@@ -547,65 +557,6 @@ export default class ServeCommand extends SessionCommand {
|
|
547
557
|
}
|
548
558
|
)
|
549
559
|
|
550
|
-
app.post("/read-document", upload.single("file"), async (req, res) => {
|
551
|
-
console.log("READING A DOCUMENT")
|
552
|
-
const publicToken = req.header("x-public-token")
|
553
|
-
if (!publicToken) {
|
554
|
-
return res.status(400).json({ error: "Public token is required" })
|
555
|
-
}
|
556
|
-
|
557
|
-
try {
|
558
|
-
// eslint-disable-next-line
|
559
|
-
// @ts-ignore
|
560
|
-
if (!req.file) {
|
561
|
-
return res.status(400).json({ error: "Missing file" })
|
562
|
-
}
|
563
|
-
|
564
|
-
console.log("PUBLIC TOKEN", publicToken)
|
565
|
-
|
566
|
-
const resultId = `document-read-${Date.now()}-${Math.floor(
|
567
|
-
Math.random() * 1e6
|
568
|
-
)}`
|
569
|
-
|
570
|
-
const webhookUrl = `${deploymentURL}/notifications/${resultId}`
|
571
|
-
console.log("WEBHOOK URL", webhookUrl)
|
572
|
-
// Construir form-data para enviar al servidor proxy
|
573
|
-
const formData = new FormData()
|
574
|
-
// eslint-disable-next-line
|
575
|
-
// @ts-ignore
|
576
|
-
formData.append("file", req.file.buffer, {
|
577
|
-
// eslint-disable-next-line
|
578
|
-
// @ts-ignore
|
579
|
-
filename: req.file.originalname,
|
580
|
-
// eslint-disable-next-line
|
581
|
-
// @ts-ignore
|
582
|
-
contentType: req.file.mimetype,
|
583
|
-
})
|
584
|
-
formData.append("webhook_callback_url", webhookUrl)
|
585
|
-
|
586
|
-
try {
|
587
|
-
const response = await axios.post(
|
588
|
-
`${RIGOBOT_HOST}/v1/learnpack/public/tools/read-document`,
|
589
|
-
formData,
|
590
|
-
{
|
591
|
-
headers: {
|
592
|
-
...formData.getHeaders(),
|
593
|
-
Authorization: `Token ${publicToken.trim()}`,
|
594
|
-
},
|
595
|
-
}
|
596
|
-
)
|
597
|
-
} catch (error) {
|
598
|
-
console.error("❌ Error in /read-document:", error)
|
599
|
-
return res.status(500).json({ error: (error as Error).message })
|
600
|
-
}
|
601
|
-
|
602
|
-
return res.json({ notificationId: resultId, status: "PROCESSING" })
|
603
|
-
} catch (error) {
|
604
|
-
console.error("❌ Error in /read-document:", error)
|
605
|
-
return res.status(500).json({ error: (error as Error).message })
|
606
|
-
}
|
607
|
-
})
|
608
|
-
|
609
560
|
app.post("/notifications/:id", async (req, res) => {
|
610
561
|
console.log("Receiving a webhook to notification id", req.params.id)
|
611
562
|
const { id } = req.params
|
@@ -1009,6 +960,10 @@ export default class ServeCommand extends SessionCommand {
|
|
1009
960
|
)
|
1010
961
|
console.log("🔄 Learn.json uploaded to bucket to", tutorialDir)
|
1011
962
|
|
963
|
+
console.log(
|
964
|
+
"🔄 Processing lessons with purpose",
|
965
|
+
syllabus.courseInfo.purpose
|
966
|
+
)
|
1012
967
|
const lessonsPromises = syllabus.lessons.map(lesson =>
|
1013
968
|
processExercise(
|
1014
969
|
bucket,
|
@@ -1017,7 +972,8 @@ export default class ServeCommand extends SessionCommand {
|
|
1017
972
|
JSON.stringify(syllabus.courseInfo),
|
1018
973
|
lesson,
|
1019
974
|
tutorialDir + "/exercises",
|
1020
|
-
slugify(syllabus.courseInfo.title)
|
975
|
+
slugify(syllabus.courseInfo.title),
|
976
|
+
syllabus.courseInfo.purpose
|
1021
977
|
)
|
1022
978
|
)
|
1023
979
|
const readmeContents = await Promise.all(lessonsPromises)
|
package/src/creator/src/App.tsx
CHANGED
@@ -122,8 +122,9 @@ function App() {
|
|
122
122
|
courseInfo: `${JSON.stringify(formState)} `,
|
123
123
|
prevInteractions: "",
|
124
124
|
},
|
125
|
-
auth.publicToken,
|
126
|
-
formState.purpose
|
125
|
+
auth.rigoToken ? auth.rigoToken : auth.publicToken,
|
126
|
+
formState.purpose || "learnpack-lesson-writer",
|
127
|
+
auth.rigoToken ? false : true
|
127
128
|
)
|
128
129
|
const lessons = res.parsed.listOfSteps.map((lesson: any) => {
|
129
130
|
return parseLesson(lesson, [])
|
@@ -4,6 +4,70 @@ import { ContentCard } from "./ContentCard"
|
|
4
4
|
import useStore from "../utils/store"
|
5
5
|
import toast from "react-hot-toast"
|
6
6
|
import CreatorSocket from "../utils/socket"
|
7
|
+
import { DEV_MODE, RIGOBOT_HOST } from "../utils/constants"
|
8
|
+
import axios from "axios"
|
9
|
+
|
10
|
+
|
11
|
+
// `
|
12
|
+
// app.post("/read-document", upload.single("file"), async (req, res) => {
|
13
|
+
// console.log("READING A DOCUMENT")
|
14
|
+
// const publicToken = req.header("x-public-token")
|
15
|
+
// if (!publicToken) {
|
16
|
+
// return res.status(400).json({ error: "Public token is required" })
|
17
|
+
// }
|
18
|
+
|
19
|
+
// try {
|
20
|
+
// // eslint-disable-next-line
|
21
|
+
// // @ts-ignore
|
22
|
+
// if (!req.file) {
|
23
|
+
// return res.status(400).json({ error: "Missing file" })
|
24
|
+
// }
|
25
|
+
|
26
|
+
// console.log("PUBLIC TOKEN", publicToken)
|
27
|
+
|
28
|
+
// const resultId = `document-read-${Date.now()}-${Math.floor(
|
29
|
+
// Math.random() * 1e6
|
30
|
+
// )}`
|
31
|
+
|
32
|
+
// const webhookUrl = `${deploymentURL}/notifications/${resultId}`
|
33
|
+
// console.log("WEBHOOK URL", webhookUrl)
|
34
|
+
// // Construir form-data para enviar al servidor proxy
|
35
|
+
// const formData = new FormData()
|
36
|
+
// // eslint-disable-next-line
|
37
|
+
// // @ts-ignore
|
38
|
+
// formData.append("file", req.file.buffer, {
|
39
|
+
// // eslint-disable-next-line
|
40
|
+
// // @ts-ignore
|
41
|
+
// filename: req.file.originalname,
|
42
|
+
// // eslint-disable-next-line
|
43
|
+
// // @ts-ignore
|
44
|
+
// contentType: req.file.mimetype,
|
45
|
+
// })
|
46
|
+
// formData.append("webhook_callback_url", webhookUrl)
|
47
|
+
|
48
|
+
// try {
|
49
|
+
// const response = await axios.post(
|
50
|
+
// `${RIGOBOT_HOST}/v1/learnpack/public/tools/read-document`,
|
51
|
+
// formData,
|
52
|
+
// {
|
53
|
+
// headers: {
|
54
|
+
// ...formData.getHeaders(),
|
55
|
+
// Authorization: `Token ${publicToken.trim()}`,
|
56
|
+
// },
|
57
|
+
// }
|
58
|
+
// )
|
59
|
+
// } catch (error) {
|
60
|
+
// console.error("❌ Error in /read-document:", error)
|
61
|
+
// return res.status(500).json({ error: (error as Error).message })
|
62
|
+
// }
|
63
|
+
|
64
|
+
// return res.json({ notificationId: resultId, status: "PROCESSING" })
|
65
|
+
// } catch (error) {
|
66
|
+
// console.error("❌ Error in /read-document:", error)
|
67
|
+
// return res.status(500).json({ error: (error as Error).message })
|
68
|
+
// }
|
69
|
+
// })
|
70
|
+
// `
|
7
71
|
|
8
72
|
const socketClient = new CreatorSocket("")
|
9
73
|
|
@@ -128,24 +192,37 @@ const FileUploader: React.FC<FileUploaderProps> = ({
|
|
128
192
|
const formData = new FormData()
|
129
193
|
formData.append("file", file)
|
130
194
|
|
195
|
+
const resultId = `document-read-${Date.now()}-${Math.floor(
|
196
|
+
Math.random() * 1e6
|
197
|
+
)}`
|
198
|
+
|
199
|
+
const webhookUrl = `${
|
200
|
+
DEV_MODE
|
201
|
+
? "https://9cw5zmww-3000.use2.devtunnels.ms"
|
202
|
+
: window.location.origin
|
203
|
+
}/notifications/${resultId}`
|
204
|
+
formData.append("webhook_callback_url", webhookUrl)
|
205
|
+
|
131
206
|
const loadingToast = toast.loading(`Processing ${file.name}...`)
|
132
207
|
try {
|
133
|
-
const res = await
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
208
|
+
const res = await axios.post(
|
209
|
+
`${RIGOBOT_HOST}/v1/learnpack/public/tools/read-document`,
|
210
|
+
formData,
|
211
|
+
{
|
212
|
+
headers: {
|
213
|
+
Authorization: `Token ${publicToken.trim()}`,
|
214
|
+
},
|
215
|
+
}
|
216
|
+
)
|
140
217
|
|
141
|
-
if (
|
142
|
-
const data =
|
218
|
+
if (res.status >= 300) throw new Error(`Failed to read ${file.name}`)
|
219
|
+
const data = res.data
|
143
220
|
toast.success(`Processing ${file.name}`, { id: loadingToast })
|
144
221
|
return {
|
145
222
|
name,
|
146
223
|
text: "",
|
147
224
|
status: data.status,
|
148
|
-
notificationId:
|
225
|
+
notificationId: resultId,
|
149
226
|
}
|
150
227
|
} catch (err: any) {
|
151
228
|
toast.error(`❌ ${file.name} failed: ${err.message}`, {
|
@@ -29,27 +29,33 @@ export default function Login({ onFinish }: { onFinish: () => void }) {
|
|
29
29
|
e.preventDefault()
|
30
30
|
setIsLoading(true)
|
31
31
|
const tid = toast.loading("Logging in…")
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
try {
|
33
|
+
if (!email || !password) {
|
34
|
+
setIsLoading(false)
|
35
|
+
toast.error("Please fill all fields", { id: tid })
|
36
|
+
return
|
37
|
+
}
|
38
|
+
const resp = await login4Geeks({ email, password })
|
39
|
+
if (!resp) {
|
40
|
+
setIsLoading(false)
|
41
|
+
toast.error("Invalid credentials", { id: tid })
|
42
|
+
return
|
43
|
+
}
|
44
|
+
toast.success("Logged in successfully", { id: tid })
|
45
|
+
setAuth({
|
46
|
+
bcToken: resp.token,
|
47
|
+
userId: resp.user.id,
|
48
|
+
rigoToken: resp.rigobot.key,
|
49
|
+
user: resp.user,
|
50
|
+
publicToken: "",
|
51
|
+
})
|
39
52
|
setIsLoading(false)
|
53
|
+
onFinish()
|
54
|
+
} catch (error) {
|
55
|
+
console.error(error)
|
40
56
|
toast.error("Invalid credentials", { id: tid })
|
41
|
-
|
57
|
+
setIsLoading(false)
|
42
58
|
}
|
43
|
-
toast.success("Logged in successfully", { id: tid })
|
44
|
-
setAuth({
|
45
|
-
bcToken: resp.token,
|
46
|
-
userId: resp.user.id,
|
47
|
-
rigoToken: resp.rigobot.key,
|
48
|
-
user: resp.user,
|
49
|
-
publicToken: "",
|
50
|
-
})
|
51
|
-
setIsLoading(false)
|
52
|
-
onFinish()
|
53
59
|
}
|
54
60
|
|
55
61
|
// Signup handler
|