moodle-cli 0.9.3 → 0.9.5

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/dist/moodle.js CHANGED
@@ -4666,6 +4666,10 @@ async function submitAssignmentFiles(deps, request) {
4666
4666
  checked_at: timestamp(deps)
4667
4667
  };
4668
4668
  }
4669
+ function submissionReceiptOf(value) {
4670
+ const receipt = record2(value);
4671
+ return { ...receipt, files: receipt.files ?? [], uploads: receipt.uploads ?? [], removed: receipt.removed ?? [], limits: receipt.limits ?? {} };
4672
+ }
4669
4673
  function parseSubmissionForm(html, deps) {
4670
4674
  const root = parse4(html);
4671
4675
  const form = formWithAction(root, "savesubmission");
@@ -4687,8 +4691,6 @@ function parseSubmissionForm(html, deps) {
4687
4691
  const repositories = (Array.isArray(picker.repositories) ? picker.repositories : Object.values(record2(picker.repositories))).map(record2);
4688
4692
  const upload = repositories.find((repo) => repo.type === "upload");
4689
4693
  if (!upload || upload.id === void 0) throw deps.fail("The site does not allow direct file uploads for this assignment.");
4690
- const accepted = options.accepted_types;
4691
- const acceptedTypes = Array.isArray(accepted) ? accepted.map(String).filter(Boolean) : accepted === void 0 || accepted === "*" ? "*" : [String(accepted)];
4692
4694
  return {
4693
4695
  action: resolveUrl(deps.baseUrl, form.getAttribute("action") || `${deps.baseUrl}${ASSIGN_VIEW_PATH}`),
4694
4696
  fields: fields2,
@@ -4702,7 +4704,7 @@ function parseSubmissionForm(html, deps) {
4702
4704
  maxBytes: integer(options.maxbytes),
4703
4705
  areaMaxBytes: integer(options.areamaxbytes),
4704
4706
  maxFiles: integer(options.maxfiles),
4705
- acceptedTypes: acceptedTypes.length === 1 && acceptedTypes[0] === "*" ? "*" : acceptedTypes,
4707
+ acceptedTypes: acceptedTypesOf(options.accepted_types),
4706
4708
  ...statementOf(form)
4707
4709
  };
4708
4710
  }
@@ -4800,6 +4802,11 @@ function filemanagerOptions(html, itemid) {
4800
4802
  }
4801
4803
  return null;
4802
4804
  }
4805
+ function acceptedTypesOf(value) {
4806
+ const list2 = Array.isArray(value) ? value : isRecord4(value) ? Object.values(value) : value === void 0 ? [] : [value];
4807
+ const types = list2.map((type) => String(type).trim()).filter(Boolean);
4808
+ return types.length === 0 || types.includes("*") ? "*" : types;
4809
+ }
4803
4810
  function balancedObject(text2, start) {
4804
4811
  if (text2[start] !== "{") return null;
4805
4812
  let depth = 0;
@@ -6825,7 +6832,7 @@ function standaloneAssetUrl(version, platform2, arch2) {
6825
6832
  }
6826
6833
 
6827
6834
  // src/version.ts
6828
- var VERSION = "0.9.3";
6835
+ var VERSION = "0.9.5";
6829
6836
 
6830
6837
  // src/update-check.ts
6831
6838
  var UPDATE_CACHE_FILENAME = "update-check.json";
@@ -11664,7 +11671,7 @@ ${tryLines(["moodle due", "moodle units", "moodle --help"])}`}
11664
11671
  const service = createIntentService(createMoodleGateway(client));
11665
11672
  const args = { files: files.map((file2) => resolveSubmissionPath(file2, io.cwd ?? process.cwd())), final: Boolean(options.final), replace: Boolean(options.replace), accept_statement: Boolean(options.acceptStatement) };
11666
11673
  const plan = await choose(() => service.run("submit", { ref: ref2, ...args, dry_run: true }), (id2) => service.run("submit", { ref: id2, ...args, dry_run: true }));
11667
- const planned = plan.submission;
11674
+ const planned = submissionReceiptOf(plan.submission);
11668
11675
  if (program.opts().dryRun) return runtime.output(plan, () => formatSubmissionReceipt(planned), options);
11669
11676
  if (!await confirm({ summary: submissionSummary(planned, args.final, theme()) }, { yes: Boolean(program.opts().yes), dryRun: false, interactive })) return;
11670
11677
  const spin = interactive ? createUi3({ input: io.stdin ?? process.stdin, output: stderr, interactive: true }).spinner() : void 0;
@@ -11674,7 +11681,7 @@ ${tryLines(["moodle due", "moodle units", "moodle --help"])}`}
11674
11681
  try {
11675
11682
  const live = createIntentService(createMoodleGateway(client, { onSubmitProgress: (message) => spin?.message(message) }));
11676
11683
  result = await live.run("submit", { ref: planned.id, ...args, dry_run: false });
11677
- const receipt = result.submission;
11684
+ const receipt = submissionReceiptOf(result.submission);
11678
11685
  spin?.stop(receipt.uploads.length ? `Uploaded ${receipt.uploads.map((file2) => file2.name).join(", ")} to ${receipt.name}` : `Submitted ${receipt.name}`);
11679
11686
  } catch (error) {
11680
11687
  spin?.error("The upload did not complete");
@@ -11682,7 +11689,7 @@ ${tryLines(["moodle due", "moodle units", "moodle --help"])}`}
11682
11689
  } finally {
11683
11690
  runtime.busy = false;
11684
11691
  }
11685
- await runtime.output(result, () => formatSubmissionReceipt(result.submission), options);
11692
+ await runtime.output(result, () => formatSubmissionReceipt(submissionReceiptOf(result.submission)), options);
11686
11693
  });
11687
11694
  const quiz = program.command("quiz").description("Take a quiz: start an attempt, answer questions, finish it. Beta.").summary("Take a quiz (beta)");
11688
11695
  quiz.addHelpText("after", `
@@ -26469,7 +26469,7 @@ function stringValue(value) {
26469
26469
  }
26470
26470
 
26471
26471
  // src/version.ts
26472
- var VERSION = "0.9.3";
26472
+ var VERSION = "0.9.5";
26473
26473
 
26474
26474
  // src/worker/http.ts
26475
26475
  var HEALTH_PATH = "/healthz";
@@ -27991,8 +27991,6 @@ function parseSubmissionForm(html, deps) {
27991
27991
  const repositories = (Array.isArray(picker.repositories) ? picker.repositories : Object.values(record2(picker.repositories))).map(record2);
27992
27992
  const upload = repositories.find((repo) => repo.type === "upload");
27993
27993
  if (!upload || upload.id === void 0) throw deps.fail("The site does not allow direct file uploads for this assignment.");
27994
- const accepted = options.accepted_types;
27995
- const acceptedTypes = Array.isArray(accepted) ? accepted.map(String).filter(Boolean) : accepted === void 0 || accepted === "*" ? "*" : [String(accepted)];
27996
27994
  return {
27997
27995
  action: resolveUrl(deps.baseUrl, form.getAttribute("action") || `${deps.baseUrl}${ASSIGN_VIEW_PATH}`),
27998
27996
  fields: fields2,
@@ -28006,7 +28004,7 @@ function parseSubmissionForm(html, deps) {
28006
28004
  maxBytes: integer2(options.maxbytes),
28007
28005
  areaMaxBytes: integer2(options.areamaxbytes),
28008
28006
  maxFiles: integer2(options.maxfiles),
28009
- acceptedTypes: acceptedTypes.length === 1 && acceptedTypes[0] === "*" ? "*" : acceptedTypes,
28007
+ acceptedTypes: acceptedTypesOf(options.accepted_types),
28010
28008
  ...statementOf(form)
28011
28009
  };
28012
28010
  }
@@ -28104,6 +28102,11 @@ function filemanagerOptions(html, itemid) {
28104
28102
  }
28105
28103
  return null;
28106
28104
  }
28105
+ function acceptedTypesOf(value) {
28106
+ const list2 = Array.isArray(value) ? value : isRecord5(value) ? Object.values(value) : value === void 0 ? [] : [value];
28107
+ const types = list2.map((type) => String(type).trim()).filter(Boolean);
28108
+ return types.length === 0 || types.includes("*") ? "*" : types;
28109
+ }
28107
28110
  function balancedObject(text, start) {
28108
28111
  if (text[start] !== "{") return null;
28109
28112
  let depth = 0;
@@ -26469,7 +26469,7 @@ function stringValue(value) {
26469
26469
  }
26470
26470
 
26471
26471
  // src/version.ts
26472
- var VERSION = "0.9.3";
26472
+ var VERSION = "0.9.5";
26473
26473
 
26474
26474
  // src/worker/http.ts
26475
26475
  var HEALTH_PATH = "/healthz";
@@ -27991,8 +27991,6 @@ function parseSubmissionForm(html, deps) {
27991
27991
  const repositories = (Array.isArray(picker.repositories) ? picker.repositories : Object.values(record2(picker.repositories))).map(record2);
27992
27992
  const upload = repositories.find((repo) => repo.type === "upload");
27993
27993
  if (!upload || upload.id === void 0) throw deps.fail("The site does not allow direct file uploads for this assignment.");
27994
- const accepted = options.accepted_types;
27995
- const acceptedTypes = Array.isArray(accepted) ? accepted.map(String).filter(Boolean) : accepted === void 0 || accepted === "*" ? "*" : [String(accepted)];
27996
27994
  return {
27997
27995
  action: resolveUrl(deps.baseUrl, form.getAttribute("action") || `${deps.baseUrl}${ASSIGN_VIEW_PATH}`),
27998
27996
  fields: fields2,
@@ -28006,7 +28004,7 @@ function parseSubmissionForm(html, deps) {
28006
28004
  maxBytes: integer2(options.maxbytes),
28007
28005
  areaMaxBytes: integer2(options.areamaxbytes),
28008
28006
  maxFiles: integer2(options.maxfiles),
28009
- acceptedTypes: acceptedTypes.length === 1 && acceptedTypes[0] === "*" ? "*" : acceptedTypes,
28007
+ acceptedTypes: acceptedTypesOf(options.accepted_types),
28010
28008
  ...statementOf(form)
28011
28009
  };
28012
28010
  }
@@ -28104,6 +28102,11 @@ function filemanagerOptions(html, itemid) {
28104
28102
  }
28105
28103
  return null;
28106
28104
  }
28105
+ function acceptedTypesOf(value) {
28106
+ const list2 = Array.isArray(value) ? value : isRecord5(value) ? Object.values(value) : value === void 0 ? [] : [value];
28107
+ const types = list2.map((type) => String(type).trim()).filter(Boolean);
28108
+ return types.length === 0 || types.includes("*") ? "*" : types;
28109
+ }
28107
28110
  function balancedObject(text, start) {
28108
28111
  if (text[start] !== "{") return null;
28109
28112
  let depth = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moodle-cli",
3
- "version": "0.9.3",
3
+ "version": "0.9.5",
4
4
  "description": "Moodle for terminals and AI agents: deadlines, grades, files, feedback and quiz reviews from your browser session, plus a private MCP server on Cloudflare",
5
5
  "license": "MIT",
6
6
  "type": "module",