@mo7yw4ng/openape 1.0.5 → 2.0.3

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.
Files changed (152) hide show
  1. package/bin/openape +29 -0
  2. package/bin/openape.js +29 -0
  3. package/package.json +22 -28
  4. package/LICENSE +0 -21
  5. package/README.md +0 -135
  6. package/esm/_dnt.polyfills.d.ts +0 -101
  7. package/esm/_dnt.polyfills.d.ts.map +0 -1
  8. package/esm/_dnt.polyfills.js +0 -127
  9. package/esm/_dnt.shims.d.ts +0 -6
  10. package/esm/_dnt.shims.d.ts.map +0 -1
  11. package/esm/_dnt.shims.js +0 -61
  12. package/esm/deno.d.ts +0 -25
  13. package/esm/deno.d.ts.map +0 -1
  14. package/esm/deno.js +0 -23
  15. package/esm/package.json +0 -3
  16. package/esm/src/commands/announcements.d.ts +0 -3
  17. package/esm/src/commands/announcements.d.ts.map +0 -1
  18. package/esm/src/commands/announcements.js +0 -134
  19. package/esm/src/commands/assignments.d.ts +0 -3
  20. package/esm/src/commands/assignments.d.ts.map +0 -1
  21. package/esm/src/commands/assignments.js +0 -230
  22. package/esm/src/commands/auth.d.ts +0 -3
  23. package/esm/src/commands/auth.d.ts.map +0 -1
  24. package/esm/src/commands/auth.js +0 -290
  25. package/esm/src/commands/calendar.d.ts +0 -3
  26. package/esm/src/commands/calendar.d.ts.map +0 -1
  27. package/esm/src/commands/calendar.js +0 -179
  28. package/esm/src/commands/courses.d.ts +0 -3
  29. package/esm/src/commands/courses.d.ts.map +0 -1
  30. package/esm/src/commands/courses.js +0 -348
  31. package/esm/src/commands/forums.d.ts +0 -3
  32. package/esm/src/commands/forums.d.ts.map +0 -1
  33. package/esm/src/commands/forums.js +0 -318
  34. package/esm/src/commands/grades.d.ts +0 -3
  35. package/esm/src/commands/grades.d.ts.map +0 -1
  36. package/esm/src/commands/grades.js +0 -121
  37. package/esm/src/commands/materials.d.ts +0 -3
  38. package/esm/src/commands/materials.d.ts.map +0 -1
  39. package/esm/src/commands/materials.js +0 -413
  40. package/esm/src/commands/quizzes.d.ts +0 -3
  41. package/esm/src/commands/quizzes.d.ts.map +0 -1
  42. package/esm/src/commands/quizzes.js +0 -271
  43. package/esm/src/commands/skills.d.ts +0 -3
  44. package/esm/src/commands/skills.d.ts.map +0 -1
  45. package/esm/src/commands/skills.js +0 -106
  46. package/esm/src/commands/upload.d.ts +0 -3
  47. package/esm/src/commands/upload.d.ts.map +0 -1
  48. package/esm/src/commands/upload.js +0 -58
  49. package/esm/src/commands/videos.d.ts +0 -3
  50. package/esm/src/commands/videos.d.ts.map +0 -1
  51. package/esm/src/commands/videos.js +0 -336
  52. package/esm/src/index.d.ts +0 -27
  53. package/esm/src/index.d.ts.map +0 -1
  54. package/esm/src/index.js +0 -160
  55. package/esm/src/lib/auth.d.ts +0 -47
  56. package/esm/src/lib/auth.d.ts.map +0 -1
  57. package/esm/src/lib/auth.js +0 -227
  58. package/esm/src/lib/config.d.ts +0 -6
  59. package/esm/src/lib/config.d.ts.map +0 -1
  60. package/esm/src/lib/config.js +0 -36
  61. package/esm/src/lib/logger.d.ts +0 -3
  62. package/esm/src/lib/logger.d.ts.map +0 -1
  63. package/esm/src/lib/logger.js +0 -27
  64. package/esm/src/lib/moodle.d.ts +0 -433
  65. package/esm/src/lib/moodle.d.ts.map +0 -1
  66. package/esm/src/lib/moodle.js +0 -1318
  67. package/esm/src/lib/session.d.ts +0 -8
  68. package/esm/src/lib/session.d.ts.map +0 -1
  69. package/esm/src/lib/session.js +0 -42
  70. package/esm/src/lib/token.d.ts +0 -38
  71. package/esm/src/lib/token.d.ts.map +0 -1
  72. package/esm/src/lib/token.js +0 -178
  73. package/esm/src/lib/types.d.ts +0 -189
  74. package/esm/src/lib/types.d.ts.map +0 -1
  75. package/esm/src/lib/types.js +0 -2
  76. package/esm/src/lib/utils.d.ts +0 -57
  77. package/esm/src/lib/utils.d.ts.map +0 -1
  78. package/esm/src/lib/utils.js +0 -129
  79. package/script/_dnt.polyfills.d.ts +0 -101
  80. package/script/_dnt.polyfills.d.ts.map +0 -1
  81. package/script/_dnt.polyfills.js +0 -130
  82. package/script/_dnt.shims.d.ts +0 -6
  83. package/script/_dnt.shims.d.ts.map +0 -1
  84. package/script/_dnt.shims.js +0 -65
  85. package/script/deno.d.ts +0 -25
  86. package/script/deno.d.ts.map +0 -1
  87. package/script/deno.js +0 -25
  88. package/script/package.json +0 -3
  89. package/script/src/commands/announcements.d.ts +0 -3
  90. package/script/src/commands/announcements.d.ts.map +0 -1
  91. package/script/src/commands/announcements.js +0 -140
  92. package/script/src/commands/assignments.d.ts +0 -3
  93. package/script/src/commands/assignments.d.ts.map +0 -1
  94. package/script/src/commands/assignments.js +0 -269
  95. package/script/src/commands/auth.d.ts +0 -3
  96. package/script/src/commands/auth.d.ts.map +0 -1
  97. package/script/src/commands/auth.js +0 -296
  98. package/script/src/commands/calendar.d.ts +0 -3
  99. package/script/src/commands/calendar.d.ts.map +0 -1
  100. package/script/src/commands/calendar.js +0 -185
  101. package/script/src/commands/courses.d.ts +0 -3
  102. package/script/src/commands/courses.d.ts.map +0 -1
  103. package/script/src/commands/courses.js +0 -354
  104. package/script/src/commands/forums.d.ts +0 -3
  105. package/script/src/commands/forums.d.ts.map +0 -1
  106. package/script/src/commands/forums.js +0 -324
  107. package/script/src/commands/grades.d.ts +0 -3
  108. package/script/src/commands/grades.d.ts.map +0 -1
  109. package/script/src/commands/grades.js +0 -127
  110. package/script/src/commands/materials.d.ts +0 -3
  111. package/script/src/commands/materials.d.ts.map +0 -1
  112. package/script/src/commands/materials.js +0 -419
  113. package/script/src/commands/quizzes.d.ts +0 -3
  114. package/script/src/commands/quizzes.d.ts.map +0 -1
  115. package/script/src/commands/quizzes.js +0 -277
  116. package/script/src/commands/skills.d.ts +0 -3
  117. package/script/src/commands/skills.d.ts.map +0 -1
  118. package/script/src/commands/skills.js +0 -112
  119. package/script/src/commands/upload.d.ts +0 -3
  120. package/script/src/commands/upload.d.ts.map +0 -1
  121. package/script/src/commands/upload.js +0 -64
  122. package/script/src/commands/videos.d.ts +0 -3
  123. package/script/src/commands/videos.d.ts.map +0 -1
  124. package/script/src/commands/videos.js +0 -342
  125. package/script/src/index.d.ts +0 -27
  126. package/script/src/index.d.ts.map +0 -1
  127. package/script/src/index.js +0 -167
  128. package/script/src/lib/auth.d.ts +0 -47
  129. package/script/src/lib/auth.d.ts.map +0 -1
  130. package/script/src/lib/auth.js +0 -269
  131. package/script/src/lib/config.d.ts +0 -6
  132. package/script/src/lib/config.d.ts.map +0 -1
  133. package/script/src/lib/config.js +0 -42
  134. package/script/src/lib/logger.d.ts +0 -3
  135. package/script/src/lib/logger.d.ts.map +0 -1
  136. package/script/src/lib/logger.js +0 -30
  137. package/script/src/lib/moodle.d.ts +0 -433
  138. package/script/src/lib/moodle.d.ts.map +0 -1
  139. package/script/src/lib/moodle.js +0 -1389
  140. package/script/src/lib/session.d.ts +0 -8
  141. package/script/src/lib/session.d.ts.map +0 -1
  142. package/script/src/lib/session.js +0 -45
  143. package/script/src/lib/token.d.ts +0 -38
  144. package/script/src/lib/token.d.ts.map +0 -1
  145. package/script/src/lib/token.js +0 -189
  146. package/script/src/lib/types.d.ts +0 -189
  147. package/script/src/lib/types.d.ts.map +0 -1
  148. package/script/src/lib/types.js +0 -3
  149. package/script/src/lib/utils.d.ts +0 -57
  150. package/script/src/lib/utils.d.ts.map +0 -1
  151. package/script/src/lib/utils.js +0 -175
  152. package/skills/openape/SKILL.md +0 -115
@@ -1,101 +0,0 @@
1
- /**
2
- * Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
3
- * but instead of using npm to install additional dependencies,
4
- * this approach manually consolidates cjs/mjs/d.ts into a single file.
5
- *
6
- * Note that this code might be imported multiple times
7
- * (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
8
- * or Node.js might dynamically clear the cache and then force a require).
9
- * Therefore, it's important to avoid redundant writes to global objects.
10
- * Additionally, consider that commonjs is used alongside esm,
11
- * so the two ponyfill functions are stored independently in two separate global objects.
12
- */
13
- import { createRequire } from "node:module";
14
- import { type URL } from "node:url";
15
- declare global {
16
- interface ImportMeta {
17
- /** A string representation of the fully qualified module URL. When the
18
- * module is loaded locally, the value will be a file URL (e.g.
19
- * `file:///path/module.ts`).
20
- *
21
- * You can also parse the string as a URL to determine more information about
22
- * how the current module was loaded. For example to determine if a module was
23
- * local or not:
24
- *
25
- * ```ts
26
- * const url = new URL(import.meta.url);
27
- * if (url.protocol === "file:") {
28
- * console.log("this module was loaded locally");
29
- * }
30
- * ```
31
- */
32
- url: string;
33
- /**
34
- * A function that returns resolved specifier as if it would be imported
35
- * using `import(specifier)`.
36
- *
37
- * ```ts
38
- * console.log(import.meta.resolve("./foo.js"));
39
- * // file:///dev/foo.js
40
- * ```
41
- *
42
- * @param specifier The module specifier to resolve relative to `parent`.
43
- * @param parent The absolute parent module URL to resolve from.
44
- * @returns The absolute (`file:`) URL string for the resolved module.
45
- */
46
- resolve(specifier: string, parent?: string | URL | undefined): string;
47
- /** A flag that indicates if the current module is the main module that was
48
- * called when starting the program under Deno.
49
- *
50
- * ```ts
51
- * if (import.meta.main) {
52
- * // this was loaded as the main module, maybe do some bootstrapping
53
- * }
54
- * ```
55
- */
56
- main: boolean;
57
- /** The absolute path of the current module.
58
- *
59
- * This property is only provided for local modules (ie. using `file://` URLs).
60
- *
61
- * Example:
62
- * ```
63
- * // Unix
64
- * console.log(import.meta.filename); // /home/alice/my_module.ts
65
- *
66
- * // Windows
67
- * console.log(import.meta.filename); // C:\alice\my_module.ts
68
- * ```
69
- */
70
- filename: string;
71
- /** The absolute path of the directory containing the current module.
72
- *
73
- * This property is only provided for local modules (ie. using `file://` URLs).
74
- *
75
- * * Example:
76
- * ```
77
- * // Unix
78
- * console.log(import.meta.dirname); // /home/alice
79
- *
80
- * // Windows
81
- * console.log(import.meta.dirname); // C:\alice
82
- * ```
83
- */
84
- dirname: string;
85
- }
86
- }
87
- type NodeRequest = ReturnType<typeof createRequire>;
88
- type NodeModule = NonNullable<NodeRequest["main"]>;
89
- interface ImportMetaPonyfillCommonjs {
90
- (require: NodeRequest, module: NodeModule): ImportMeta;
91
- }
92
- interface ImportMetaPonyfillEsmodule {
93
- (importMeta: ImportMeta): ImportMeta;
94
- }
95
- interface ImportMetaPonyfill extends ImportMetaPonyfillCommonjs, ImportMetaPonyfillEsmodule {
96
- }
97
- export declare let import_meta_ponyfill_commonjs: ImportMetaPonyfillCommonjs;
98
- export declare let import_meta_ponyfill_esmodule: ImportMetaPonyfillEsmodule;
99
- export declare let import_meta_ponyfill: ImportMetaPonyfill;
100
- export {};
101
- //# sourceMappingURL=_dnt.polyfills.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAgC,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAGlE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,UAAU;QAClB;;;;;;;;;;;;;;WAcG;QACH,GAAG,EAAE,MAAM,CAAC;QACZ;;;;;;;;;;;;WAYG;QACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,MAAM,CAAC;QACtE;;;;;;;;WAQG;QACH,IAAI,EAAE,OAAO,CAAC;QAEd;;;;;;;;;;;;WAYG;QACH,QAAQ,EAAE,MAAM,CAAC;QAEjB;;;;;;;;;;;;WAYG;QACH,OAAO,EAAE,MAAM,CAAC;KACjB;CACF;AAED,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACpD,KAAK,UAAU,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;AACnD,UAAU,0BAA0B;IAClC,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;CACxD;AACD,UAAU,0BAA0B;IAClC,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;CACtC;AACD,UAAU,kBACR,SAAQ,0BAA0B,EAAE,0BAA0B;CAC/D;AAiBD,eAAO,IAAI,6BAA6B,EA2BnC,0BAA0B,CAAC;AAMhC,eAAO,IAAI,6BAA6B,EA4DnC,0BAA0B,CAAC;AAMhC,eAAO,IAAI,oBAAoB,EAoB1B,kBAAkB,CAAC"}
@@ -1,130 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.import_meta_ponyfill = exports.import_meta_ponyfill_esmodule = exports.import_meta_ponyfill_commonjs = void 0;
4
- /**
5
- * Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
6
- * but instead of using npm to install additional dependencies,
7
- * this approach manually consolidates cjs/mjs/d.ts into a single file.
8
- *
9
- * Note that this code might be imported multiple times
10
- * (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
11
- * or Node.js might dynamically clear the cache and then force a require).
12
- * Therefore, it's important to avoid redundant writes to global objects.
13
- * Additionally, consider that commonjs is used alongside esm,
14
- * so the two ponyfill functions are stored independently in two separate global objects.
15
- */
16
- //@ts-ignore
17
- const node_module_1 = require("node:module");
18
- //@ts-ignore
19
- const node_url_1 = require("node:url");
20
- //@ts-ignore
21
- const node_path_1 = require("node:path");
22
- const defineGlobalPonyfill = (symbolFor, fn) => {
23
- if (!Reflect.has(globalThis, Symbol.for(symbolFor))) {
24
- Object.defineProperty(globalThis, Symbol.for(symbolFor), {
25
- configurable: true,
26
- get() {
27
- return fn;
28
- },
29
- });
30
- }
31
- };
32
- exports.import_meta_ponyfill_commonjs = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-commonjs")) ??
33
- (() => {
34
- const moduleImportMetaWM = new WeakMap();
35
- return (require, module) => {
36
- let importMetaCache = moduleImportMetaWM.get(module);
37
- if (importMetaCache == null) {
38
- const importMeta = Object.assign(Object.create(null), {
39
- url: (0, node_url_1.pathToFileURL)(module.filename).href,
40
- main: require.main == module,
41
- resolve: (specifier, parentURL = importMeta.url) => {
42
- return (0, node_url_1.pathToFileURL)((importMeta.url === parentURL
43
- ? require
44
- : (0, node_module_1.createRequire)(parentURL))
45
- .resolve(specifier)).href;
46
- },
47
- filename: module.filename,
48
- dirname: module.path,
49
- });
50
- moduleImportMetaWM.set(module, importMeta);
51
- importMetaCache = importMeta;
52
- }
53
- return importMetaCache;
54
- };
55
- })());
56
- defineGlobalPonyfill("import-meta-ponyfill-commonjs", exports.import_meta_ponyfill_commonjs);
57
- exports.import_meta_ponyfill_esmodule = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-esmodule")) ??
58
- ((importMeta) => {
59
- const resolveFunStr = String(importMeta.resolve);
60
- const shimWs = new WeakSet();
61
- //@ts-ignore
62
- const mainUrl = ("file:///" + process.argv[1].replace(/\\/g, "/"))
63
- .replace(/\/{3,}/, "///");
64
- const commonShim = (importMeta) => {
65
- if (typeof importMeta.main !== "boolean") {
66
- importMeta.main = importMeta.url === mainUrl;
67
- }
68
- if (typeof importMeta.filename !== "string") {
69
- importMeta.filename = (0, node_url_1.fileURLToPath)(importMeta.url);
70
- importMeta.dirname = (0, node_path_1.dirname)(importMeta.filename);
71
- }
72
- };
73
- if (
74
- // v16.2.0+, v14.18.0+: Add support for WHATWG URL object to parentURL parameter.
75
- resolveFunStr === "undefined" ||
76
- // v20.0.0+, v18.19.0+"" This API now returns a string synchronously instead of a Promise.
77
- resolveFunStr.startsWith("async")
78
- // enable by --experimental-import-meta-resolve flag
79
- ) {
80
- exports.import_meta_ponyfill_esmodule = (importMeta) => {
81
- if (!shimWs.has(importMeta)) {
82
- shimWs.add(importMeta);
83
- const importMetaUrlRequire = {
84
- url: importMeta.url,
85
- require: (0, node_module_1.createRequire)(importMeta.url),
86
- };
87
- importMeta.resolve = function resolve(specifier, parentURL = importMeta.url) {
88
- return (0, node_url_1.pathToFileURL)((importMetaUrlRequire.url === parentURL
89
- ? importMetaUrlRequire.require
90
- : (0, node_module_1.createRequire)(parentURL)).resolve(specifier)).href;
91
- };
92
- commonShim(importMeta);
93
- }
94
- return importMeta;
95
- };
96
- }
97
- else {
98
- /// native support
99
- exports.import_meta_ponyfill_esmodule = (importMeta) => {
100
- if (!shimWs.has(importMeta)) {
101
- shimWs.add(importMeta);
102
- commonShim(importMeta);
103
- }
104
- return importMeta;
105
- };
106
- }
107
- return (0, exports.import_meta_ponyfill_esmodule)(importMeta);
108
- }));
109
- defineGlobalPonyfill("import-meta-ponyfill-esmodule", exports.import_meta_ponyfill_esmodule);
110
- exports.import_meta_ponyfill = ((...args) => {
111
- const _MODULE = (() => {
112
- if (typeof require === "function" && typeof module === "object") {
113
- return "commonjs";
114
- }
115
- else {
116
- // eval("typeof import.meta");
117
- return "esmodule";
118
- }
119
- })();
120
- if (_MODULE === "commonjs") {
121
- //@ts-ignore
122
- exports.import_meta_ponyfill = (r, m) => (0, exports.import_meta_ponyfill_commonjs)(r, m);
123
- }
124
- else {
125
- //@ts-ignore
126
- exports.import_meta_ponyfill = (im) => (0, exports.import_meta_ponyfill_esmodule)(im);
127
- }
128
- //@ts-ignore
129
- return (0, exports.import_meta_ponyfill)(...args);
130
- });
@@ -1,6 +0,0 @@
1
- import { Deno } from "@deno/shim-deno";
2
- export { Deno } from "@deno/shim-deno";
3
- export declare const dntGlobalThis: Omit<typeof globalThis, "Deno"> & {
4
- Deno: typeof Deno;
5
- };
6
- //# sourceMappingURL=_dnt.shims.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAKvC,eAAO,MAAM,aAAa;;CAA2C,CAAC"}
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dntGlobalThis = exports.Deno = void 0;
4
- const shim_deno_1 = require("@deno/shim-deno");
5
- var shim_deno_2 = require("@deno/shim-deno");
6
- Object.defineProperty(exports, "Deno", { enumerable: true, get: function () { return shim_deno_2.Deno; } });
7
- const dntGlobals = {
8
- Deno: shim_deno_1.Deno,
9
- };
10
- exports.dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
11
- function createMergeProxy(baseObj, extObj) {
12
- return new Proxy(baseObj, {
13
- get(_target, prop, _receiver) {
14
- if (prop in extObj) {
15
- return extObj[prop];
16
- }
17
- else {
18
- return baseObj[prop];
19
- }
20
- },
21
- set(_target, prop, value) {
22
- if (prop in extObj) {
23
- delete extObj[prop];
24
- }
25
- baseObj[prop] = value;
26
- return true;
27
- },
28
- deleteProperty(_target, prop) {
29
- let success = false;
30
- if (prop in extObj) {
31
- delete extObj[prop];
32
- success = true;
33
- }
34
- if (prop in baseObj) {
35
- delete baseObj[prop];
36
- success = true;
37
- }
38
- return success;
39
- },
40
- ownKeys(_target) {
41
- const baseKeys = Reflect.ownKeys(baseObj);
42
- const extKeys = Reflect.ownKeys(extObj);
43
- const extKeysSet = new Set(extKeys);
44
- return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
45
- },
46
- defineProperty(_target, prop, desc) {
47
- if (prop in extObj) {
48
- delete extObj[prop];
49
- }
50
- Reflect.defineProperty(baseObj, prop, desc);
51
- return true;
52
- },
53
- getOwnPropertyDescriptor(_target, prop) {
54
- if (prop in extObj) {
55
- return Reflect.getOwnPropertyDescriptor(extObj, prop);
56
- }
57
- else {
58
- return Reflect.getOwnPropertyDescriptor(baseObj, prop);
59
- }
60
- },
61
- has(_target, prop) {
62
- return prop in extObj || prop in baseObj;
63
- },
64
- });
65
- }
package/script/deno.d.ts DELETED
@@ -1,25 +0,0 @@
1
- declare namespace _default {
2
- let name: string;
3
- let version: string;
4
- let description: string;
5
- let license: string;
6
- let exports: string;
7
- let tasks: {
8
- dev: string;
9
- compile: string;
10
- "build:npm": string;
11
- };
12
- let imports: {
13
- "@deno/dnt": string;
14
- commander: string;
15
- "playwright-core": string;
16
- "node-html-parser": string;
17
- };
18
- let nodeModulesDir: string;
19
- namespace compilerOptions {
20
- let lib: string[];
21
- }
22
- let unstable: string[];
23
- }
24
- export default _default;
25
- //# sourceMappingURL=deno.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deno.d.ts","sourceRoot":"","sources":["../src/deno.js"],"names":[],"mappings":""}
package/script/deno.js DELETED
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = {
4
- "name": "@openape/openape",
5
- "version": "1.0.5",
6
- "description": "CLI tool for CYCU i-Learning platform",
7
- "license": "MIT",
8
- "exports": "./src/index.ts",
9
- "tasks": {
10
- "dev": "deno run --allow-all --sloppy-imports --watch src/index.ts",
11
- "compile": "deno compile --allow-all --no-check --sloppy-imports --output dist/OpenApe.exe src/index.ts",
12
- "build:npm": "deno run -A src/build_npm.ts"
13
- },
14
- "imports": {
15
- "@deno/dnt": "jsr:@deno/dnt@^0.42.3",
16
- "commander": "npm:commander@^12.1.0",
17
- "playwright-core": "npm:playwright-core@^1.48.0",
18
- "node-html-parser": "npm:node-html-parser@^6.1.13"
19
- },
20
- "nodeModulesDir": "auto",
21
- "compilerOptions": {
22
- "lib": ["ES2022", "DOM", "deno.ns"]
23
- },
24
- "unstable": ["sloppy-imports"]
25
- };
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -1,3 +0,0 @@
1
- import { Command } from "commander";
2
- export declare function registerAnnouncementsCommand(program: Command): void;
3
- //# sourceMappingURL=announcements.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"announcements.d.ts","sourceRoot":"","sources":["../../../src/src/commands/announcements.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqBpC,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAoJnE"}
@@ -1,140 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.registerAnnouncementsCommand = registerAnnouncementsCommand;
7
- const utils_js_1 = require("../lib/utils.js");
8
- const moodle_js_1 = require("../lib/moodle.js");
9
- const logger_js_1 = require("../lib/logger.js");
10
- const token_js_1 = require("../lib/token.js");
11
- const node_path_1 = __importDefault(require("node:path"));
12
- const node_fs_1 = __importDefault(require("node:fs"));
13
- function registerAnnouncementsCommand(program) {
14
- const announcementsCmd = program.command("announcements");
15
- announcementsCmd.description("Announcement operations");
16
- // Helper to get output format from global or local options
17
- function getOutputFormat(command) {
18
- const opts = command.optsWithGlobals();
19
- return opts.output || "json";
20
- }
21
- // Pure API context - no browser required (fast!)
22
- async function createApiContext(options, command) {
23
- const opts = command?.optsWithGlobals ? command.optsWithGlobals() : options;
24
- const outputFormat = getOutputFormat(command || { optsWithGlobals: () => ({ output: "json" }) });
25
- const silent = outputFormat === "json" && !opts.verbose;
26
- const log = (0, logger_js_1.createLogger)(opts.verbose, silent, outputFormat);
27
- const baseDir = (0, utils_js_1.getBaseDir)();
28
- const sessionPath = node_path_1.default.resolve(baseDir, ".auth", "storage-state.json");
29
- // Check if session exists
30
- if (!node_fs_1.default.existsSync(sessionPath)) {
31
- console.error("未找到登入 session。請先執行 'openape login' 進行登入。");
32
- log.info(`Session 預期位置: ${sessionPath}`);
33
- return null;
34
- }
35
- // Try to load WS token
36
- const wsToken = (0, token_js_1.loadWsToken)(sessionPath);
37
- if (!wsToken) {
38
- console.error("未找到 WS token。請先執行 'openape login' 進行登入。");
39
- return null;
40
- }
41
- return {
42
- log,
43
- session: {
44
- wsToken,
45
- moodleBaseUrl: "https://ilearning.cycu.edu.tw",
46
- },
47
- };
48
- }
49
- announcementsCmd
50
- .command("list-all")
51
- .description("List all announcements across all courses")
52
- .option("--level <type>", "Course level: in_progress (default) | all", "in_progress")
53
- .option("--unread-only", "Show only unread announcements")
54
- .option("--limit <n>", "Maximum number of announcements to show", "20")
55
- .option("--output <format>", "Output format: json|csv|table|silent")
56
- .action(async (options, command) => {
57
- const limit = parseInt(options.limit, 10);
58
- const apiContext = await createApiContext(options, command);
59
- if (!apiContext) {
60
- process.exitCode = 1;
61
- return;
62
- }
63
- // Get site info to retrieve userid
64
- const siteInfo = await (0, moodle_js_1.getSiteInfoApi)(apiContext.session);
65
- // Get messages for the current user
66
- const messages = await (0, moodle_js_1.getMessagesApi)(apiContext.session, siteInfo.userid, {
67
- limitnum: limit,
68
- });
69
- // Convert messages to announcement format
70
- const allAnnouncements = messages.map(m => ({
71
- course_id: 0, // Messages don't have courseId
72
- course_name: "Notifications",
73
- id: m.id,
74
- subject: m.subject,
75
- author: `User ${m.useridfrom}`,
76
- authorId: m.useridfrom,
77
- createdAt: m.timecreated,
78
- modifiedAt: m.timecreated,
79
- unread: false, // Messages API doesn't provide unread status
80
- forumId: 0,
81
- }));
82
- // Sort by created date (newest first)
83
- allAnnouncements.sort((a, b) => b.createdAt - a.createdAt);
84
- // Apply limit
85
- let filteredAnnouncements = allAnnouncements.slice(0, limit);
86
- console.log(JSON.stringify({
87
- status: "success",
88
- timestamp: new Date().toISOString(),
89
- level: options.level,
90
- total_announcements: allAnnouncements.length,
91
- shown: filteredAnnouncements.length,
92
- }));
93
- for (const a of filteredAnnouncements) {
94
- console.log(JSON.stringify({
95
- course_id: a.course_id,
96
- course_name: a.course_name,
97
- id: a.id,
98
- subject: a.subject,
99
- author: a.author,
100
- author_id: a.authorId,
101
- created_at: (0, utils_js_1.formatTimestamp)(a.createdAt),
102
- modified_at: (0, utils_js_1.formatTimestamp)(a.modifiedAt),
103
- unread: a.unread,
104
- }));
105
- }
106
- });
107
- announcementsCmd
108
- .command("read")
109
- .description("Read a specific announcement (shows full content)")
110
- .argument("<announcement-id>", "Discussion ID of the announcement")
111
- .option("--output <format>", "Output format: json|csv|table|silent")
112
- .action(async (announcementId, options, command) => {
113
- const apiContext = await createApiContext(options, command);
114
- if (!apiContext) {
115
- process.exitCode = 1;
116
- return;
117
- }
118
- const posts = await (0, moodle_js_1.getDiscussionPostsApi)(apiContext.session, parseInt(announcementId, 10));
119
- if (posts.length === 0) {
120
- apiContext.log.error(`Announcement not found: ${announcementId}`);
121
- process.exitCode = 1;
122
- return;
123
- }
124
- const firstPost = posts[0];
125
- const output = {
126
- status: "success",
127
- timestamp: new Date().toISOString(),
128
- announcement: {
129
- id: announcementId,
130
- subject: firstPost.subject,
131
- author: firstPost.author,
132
- author_id: firstPost.authorId,
133
- created_at: (0, utils_js_1.formatTimestamp)(firstPost.created),
134
- modified_at: (0, utils_js_1.formatTimestamp)(firstPost.modified),
135
- message: firstPost.message,
136
- },
137
- };
138
- console.log(JSON.stringify(output));
139
- });
140
- }
@@ -1,3 +0,0 @@
1
- import { Command } from "commander";
2
- export declare function registerAssignmentsCommand(program: Command): void;
3
- //# sourceMappingURL=assignments.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"assignments.d.ts","sourceRoot":"","sources":["../../../src/src/commands/assignments.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA0PjE"}