@chukyo-umebo/web_parser 0.0.1

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 (82) hide show
  1. package/README.md +56 -0
  2. package/dist/cjs/albo/index.js +5 -0
  3. package/dist/cjs/albo/parser/albo.js +52 -0
  4. package/dist/cjs/albo/types/albo.js +19 -0
  5. package/dist/cjs/common/dom.js +116 -0
  6. package/dist/cjs/common/utils.js +13 -0
  7. package/dist/cjs/cubics/index.js +5 -0
  8. package/dist/cjs/cubics/parser/cubics.js +94 -0
  9. package/dist/cjs/cubics/types/cubics.js +38 -0
  10. package/dist/cjs/index.js +19 -0
  11. package/dist/cjs/manabo/index.js +23 -0
  12. package/dist/cjs/manabo/parser/manaboClass.js +428 -0
  13. package/dist/cjs/manabo/parser/manaboEntry.js +35 -0
  14. package/dist/cjs/manabo/parser/manaboMail.js +169 -0
  15. package/dist/cjs/manabo/parser/manaboNews.js +29 -0
  16. package/dist/cjs/manabo/parser/manaboTimetable.js +75 -0
  17. package/dist/cjs/manabo/types/manaboClass.js +126 -0
  18. package/dist/cjs/manabo/types/manaboEntry.js +21 -0
  19. package/dist/cjs/manabo/types/manaboMail.js +66 -0
  20. package/dist/cjs/manabo/types/manaboNews.js +11 -0
  21. package/dist/cjs/manabo/types/manaboTimetable.js +32 -0
  22. package/dist/esm/albo/index.d.ts +3 -0
  23. package/dist/esm/albo/index.d.ts.map +1 -0
  24. package/dist/esm/albo/index.js +1 -0
  25. package/dist/esm/albo/parser/albo.d.ts +4 -0
  26. package/dist/esm/albo/parser/albo.d.ts.map +1 -0
  27. package/dist/esm/albo/parser/albo.js +48 -0
  28. package/dist/esm/albo/types/albo.d.ts +34 -0
  29. package/dist/esm/albo/types/albo.d.ts.map +1 -0
  30. package/dist/esm/albo/types/albo.js +16 -0
  31. package/dist/esm/common/dom.d.ts +18 -0
  32. package/dist/esm/common/dom.d.ts.map +1 -0
  33. package/dist/esm/common/dom.js +99 -0
  34. package/dist/esm/common/utils.d.ts +3 -0
  35. package/dist/esm/common/utils.d.ts.map +1 -0
  36. package/dist/esm/common/utils.js +8 -0
  37. package/dist/esm/cubics/index.d.ts +3 -0
  38. package/dist/esm/cubics/index.d.ts.map +1 -0
  39. package/dist/esm/cubics/index.js +1 -0
  40. package/dist/esm/cubics/parser/cubics.d.ts +4 -0
  41. package/dist/esm/cubics/parser/cubics.d.ts.map +1 -0
  42. package/dist/esm/cubics/parser/cubics.js +90 -0
  43. package/dist/esm/cubics/types/cubics.d.ts +60 -0
  44. package/dist/esm/cubics/types/cubics.d.ts.map +1 -0
  45. package/dist/esm/cubics/types/cubics.js +35 -0
  46. package/dist/esm/index.d.ts +4 -0
  47. package/dist/esm/index.d.ts.map +1 -0
  48. package/dist/esm/index.js +3 -0
  49. package/dist/esm/manabo/index.d.ts +11 -0
  50. package/dist/esm/manabo/index.d.ts.map +1 -0
  51. package/dist/esm/manabo/index.js +5 -0
  52. package/dist/esm/manabo/parser/manaboClass.d.ts +9 -0
  53. package/dist/esm/manabo/parser/manaboClass.d.ts.map +1 -0
  54. package/dist/esm/manabo/parser/manaboClass.js +419 -0
  55. package/dist/esm/manabo/parser/manaboEntry.d.ts +5 -0
  56. package/dist/esm/manabo/parser/manaboEntry.d.ts.map +1 -0
  57. package/dist/esm/manabo/parser/manaboEntry.js +30 -0
  58. package/dist/esm/manabo/parser/manaboMail.d.ts +8 -0
  59. package/dist/esm/manabo/parser/manaboMail.d.ts.map +1 -0
  60. package/dist/esm/manabo/parser/manaboMail.js +161 -0
  61. package/dist/esm/manabo/parser/manaboNews.d.ts +4 -0
  62. package/dist/esm/manabo/parser/manaboNews.d.ts.map +1 -0
  63. package/dist/esm/manabo/parser/manaboNews.js +25 -0
  64. package/dist/esm/manabo/parser/manaboTimetable.d.ts +4 -0
  65. package/dist/esm/manabo/parser/manaboTimetable.d.ts.map +1 -0
  66. package/dist/esm/manabo/parser/manaboTimetable.js +71 -0
  67. package/dist/esm/manabo/types/manaboClass.d.ts +268 -0
  68. package/dist/esm/manabo/types/manaboClass.d.ts.map +1 -0
  69. package/dist/esm/manabo/types/manaboClass.js +123 -0
  70. package/dist/esm/manabo/types/manaboEntry.d.ts +21 -0
  71. package/dist/esm/manabo/types/manaboEntry.d.ts.map +1 -0
  72. package/dist/esm/manabo/types/manaboEntry.js +18 -0
  73. package/dist/esm/manabo/types/manaboMail.d.ts +95 -0
  74. package/dist/esm/manabo/types/manaboMail.d.ts.map +1 -0
  75. package/dist/esm/manabo/types/manaboMail.js +63 -0
  76. package/dist/esm/manabo/types/manaboNews.d.ts +13 -0
  77. package/dist/esm/manabo/types/manaboNews.d.ts.map +1 -0
  78. package/dist/esm/manabo/types/manaboNews.js +8 -0
  79. package/dist/esm/manabo/types/manaboTimetable.d.ts +57 -0
  80. package/dist/esm/manabo/types/manaboTimetable.d.ts.map +1 -0
  81. package/dist/esm/manabo/types/manaboTimetable.js +29 -0
  82. package/package.json +37 -0
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseManaboTimetable = void 0;
4
+ const dom_1 = require("../../common/dom");
5
+ const manaboTimetable_1 = require("../types/manaboTimetable");
6
+ const normalizeWhitespace = (value) => value.replace(/\s+/g, " ").trim();
7
+ const collectTextExcluding = (nodes, selector) => normalizeWhitespace(nodes
8
+ .filter((node) => !selector(node))
9
+ .map((node) => (0, dom_1.getTextContent)(node))
10
+ .join(" "));
11
+ const buildSlot = (cell, day) => {
12
+ const anchor = (0, dom_1.queryOne)("div.student a", cell);
13
+ if (!anchor) {
14
+ return {
15
+ day,
16
+ className: null,
17
+ teacher: null,
18
+ href: null,
19
+ };
20
+ }
21
+ const classNameElement = (0, dom_1.queryOne)("b", anchor);
22
+ const classNameText = normalizeWhitespace(classNameElement ? (0, dom_1.getTextContent)(classNameElement) : "");
23
+ const teacherText = collectTextExcluding(anchor.children ?? [], (node) => {
24
+ if (!(0, dom_1.isElement)(node))
25
+ return false;
26
+ return node.name === "b" || node.name === "a" || (node.name === "small" && (0, dom_1.elementHasClass)(node, "label"));
27
+ });
28
+ const teacherValue = teacherText.length ? teacherText : null;
29
+ return {
30
+ day,
31
+ className: classNameText.length ? classNameText : null,
32
+ teacher: teacherValue,
33
+ href: (0, dom_1.getAttribute)(anchor, "href"),
34
+ };
35
+ };
36
+ const buildPeriod = (row, days) => {
37
+ const periodLabel = normalizeWhitespace((0, dom_1.getTextContent)((0, dom_1.queryOne)("th.time", row)));
38
+ const cells = (0, dom_1.queryAll)("td", row);
39
+ const slots = cells.map((cell, index) => buildSlot(cell, days[index] ?? ""));
40
+ return {
41
+ period: periodLabel,
42
+ slots,
43
+ };
44
+ };
45
+ const parseManaboTimetable = (html) => {
46
+ const document = (0, dom_1.loadDocument)(html);
47
+ const title = normalizeWhitespace((0, dom_1.getTextContent)((0, dom_1.queryOne)("#time_table_name", document)));
48
+ const termAnchors = (0, dom_1.queryAll)(".calendar .nav-tabs a.a-load-timetable[archive_id]", document).map((anchor) => {
49
+ const enclosingLi = (0, dom_1.closest)(anchor, "li");
50
+ return {
51
+ archiveId: (0, dom_1.getAttribute)(anchor, "archive_id") ?? "",
52
+ label: normalizeWhitespace((0, dom_1.getTextContent)(anchor)),
53
+ active: (0, dom_1.elementHasClass)(anchor, "active") || (enclosingLi ? (0, dom_1.elementHasClass)(enclosingLi, "active") : false),
54
+ };
55
+ });
56
+ const viewModes = (0, dom_1.queryAll)(".panel-body .text-right a.a-load-timetable", document).map((anchor) => ({
57
+ archiveId: (0, dom_1.getAttribute)(anchor, "archive_id") ?? "",
58
+ mode: (0, dom_1.getAttribute)(anchor, "mode"),
59
+ label: normalizeWhitespace((0, dom_1.getTextContent)(anchor)),
60
+ active: (0, dom_1.elementHasClass)(anchor, "active"),
61
+ }));
62
+ const table = (0, dom_1.queryOne)(".table-calendar", document);
63
+ const dayHeaders = table ? (0, dom_1.queryAll)("thead tr th.data", table) : [];
64
+ const days = dayHeaders.map((element) => normalizeWhitespace((0, dom_1.getTextContent)(element)));
65
+ const periodRows = table ? (0, dom_1.queryAll)("tbody tr", table) : [];
66
+ const periods = periodRows.map((row) => buildPeriod(row, days));
67
+ return manaboTimetable_1.ManaboTimetableSchema.safeParse({
68
+ title,
69
+ terms: termAnchors,
70
+ viewModes,
71
+ days,
72
+ periods,
73
+ });
74
+ };
75
+ exports.parseManaboTimetable = parseManaboTimetable;
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ManaboClassQuizResultSchema = exports.ManaboClassQuizResultQuestionSchema = exports.ManaboClassSyllabusSchema = exports.ManaboClassSyllabusPlanItemSchema = exports.ManaboClassSyllabusReferenceSchema = exports.ManaboClassSyllabusTextbookSchema = exports.ManaboClassSyllabusEvaluationSchema = exports.ManaboClassNewsSchema = exports.ManaboClassNewsItemSchema = exports.ManaboClassEntrySchema = exports.ManaboClassEntryRowSchema = exports.ManaboClassContentSchema = exports.ManaboClassReportContentSchema = exports.ManaboClassFileContentSchema = exports.ManaboClassContentToggleAreaSchema = exports.ManaboClassContentContentSchema = exports.ManaboClassContentAttachedFileSchema = exports.ManaboClassContentActionSchema = exports.ManaboClassContentFileSchema = exports.ManaboClassContentDurationSchema = exports.ManaboClassContentIconSchema = exports.ManaboClassDirectorySchema = exports.ManaboClassDirectoryItemSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.ManaboClassDirectoryItemSchema = zod_1.z.object({
6
+ directoryId: zod_1.z.string(),
7
+ title: zod_1.z.string(),
8
+ });
9
+ exports.ManaboClassDirectorySchema = zod_1.z.object({
10
+ classId: zod_1.z.string(),
11
+ className: zod_1.z.string(),
12
+ directories: zod_1.z.array(exports.ManaboClassDirectoryItemSchema),
13
+ });
14
+ exports.ManaboClassContentIconSchema = zod_1.z.object({
15
+ pluginIconSrc: zod_1.z.string(),
16
+ isIconChecked: zod_1.z.boolean(),
17
+ });
18
+ exports.ManaboClassContentDurationSchema = zod_1.z.object({
19
+ label: zod_1.z.string(),
20
+ value: zod_1.z.string(),
21
+ });
22
+ exports.ManaboClassContentFileSchema = zod_1.z.object({
23
+ fileName: zod_1.z.string(),
24
+ href: zod_1.z.string(),
25
+ icon: zod_1.z.string(),
26
+ });
27
+ exports.ManaboClassContentActionSchema = zod_1.z.object({
28
+ title: zod_1.z.string(),
29
+ href: zod_1.z.string(),
30
+ });
31
+ exports.ManaboClassContentAttachedFileSchema = zod_1.z.object({
32
+ comment: zod_1.z.string(),
33
+ files: zod_1.z.array(exports.ManaboClassContentFileSchema),
34
+ duration: zod_1.z.array(exports.ManaboClassContentDurationSchema),
35
+ });
36
+ exports.ManaboClassContentContentSchema = zod_1.z.object({
37
+ title: zod_1.z.string(),
38
+ contentId: zod_1.z.string(),
39
+ pluginKey: zod_1.z.string(),
40
+ duration: zod_1.z.array(exports.ManaboClassContentDurationSchema),
41
+ });
42
+ exports.ManaboClassContentToggleAreaSchema = zod_1.z.object({
43
+ description: zod_1.z.string(),
44
+ isExpired: zod_1.z.boolean(),
45
+ isNotAvailableYet: zod_1.z.boolean(),
46
+ actions: zod_1.z.array(exports.ManaboClassContentActionSchema),
47
+ });
48
+ exports.ManaboClassFileContentSchema = zod_1.z.object({
49
+ type: zod_1.z.literal("file"),
50
+ icon: exports.ManaboClassContentIconSchema,
51
+ attachedFile: exports.ManaboClassContentAttachedFileSchema,
52
+ });
53
+ exports.ManaboClassReportContentSchema = zod_1.z.object({
54
+ type: zod_1.z.literal("report"),
55
+ icon: exports.ManaboClassContentIconSchema,
56
+ content: exports.ManaboClassContentContentSchema,
57
+ toggleArea: exports.ManaboClassContentToggleAreaSchema,
58
+ });
59
+ exports.ManaboClassContentSchema = zod_1.z.object({
60
+ contents: zod_1.z.array(zod_1.z.union([exports.ManaboClassFileContentSchema, exports.ManaboClassReportContentSchema])),
61
+ });
62
+ exports.ManaboClassEntryRowSchema = zod_1.z.object({
63
+ directory: zod_1.z.string(),
64
+ lectureDate: zod_1.z.string().nullable(),
65
+ status: zod_1.z.string(),
66
+ });
67
+ exports.ManaboClassEntrySchema = zod_1.z.object({
68
+ rows: zod_1.z.array(exports.ManaboClassEntryRowSchema),
69
+ });
70
+ exports.ManaboClassNewsItemSchema = zod_1.z.object({
71
+ id: zod_1.z.string().nullable(),
72
+ title: zod_1.z.string(),
73
+ bodyHtml: zod_1.z.string(),
74
+ });
75
+ exports.ManaboClassNewsSchema = zod_1.z.object({
76
+ items: zod_1.z.array(exports.ManaboClassNewsItemSchema),
77
+ });
78
+ exports.ManaboClassSyllabusEvaluationSchema = zod_1.z.object({
79
+ type: zod_1.z.string(),
80
+ weight: zod_1.z.string(),
81
+ });
82
+ exports.ManaboClassSyllabusTextbookSchema = zod_1.z.object({
83
+ type: zod_1.z.string(),
84
+ title: zod_1.z.string(),
85
+ });
86
+ exports.ManaboClassSyllabusReferenceSchema = zod_1.z.object({
87
+ title: zod_1.z.string(),
88
+ code: zod_1.z.string(),
89
+ });
90
+ exports.ManaboClassSyllabusPlanItemSchema = zod_1.z.object({
91
+ no: zod_1.z.number(),
92
+ item: zod_1.z.string(),
93
+ content: zod_1.z.string(),
94
+ });
95
+ exports.ManaboClassSyllabusSchema = zod_1.z.object({
96
+ object: zod_1.z.string(),
97
+ goal: zod_1.z.array(zod_1.z.string()),
98
+ method: zod_1.z.string(),
99
+ usedMethods: zod_1.z.array(zod_1.z.string()),
100
+ evaluation: zod_1.z.array(exports.ManaboClassSyllabusEvaluationSchema),
101
+ textbooks: zod_1.z.array(exports.ManaboClassSyllabusTextbookSchema),
102
+ references: zod_1.z.array(exports.ManaboClassSyllabusReferenceSchema),
103
+ officeHour: zod_1.z.string(),
104
+ plan: zod_1.z.array(exports.ManaboClassSyllabusPlanItemSchema),
105
+ comment: zod_1.z.string(),
106
+ prePostStudy: zod_1.z.string(),
107
+ });
108
+ exports.ManaboClassQuizResultQuestionSchema = zod_1.z.object({
109
+ page: zod_1.z.string(),
110
+ questionNumber: zod_1.z.string(),
111
+ questionText: zod_1.z.string(),
112
+ correctAnswer: zod_1.z.string(),
113
+ studentAnswer: zod_1.z.string(),
114
+ resultIconAlt: zod_1.z.string().nullable(),
115
+ resultIconSrc: zod_1.z.string().nullable(),
116
+ resultText: zod_1.z.string().nullable(),
117
+ teacherComment: zod_1.z.string().nullable(),
118
+ });
119
+ exports.ManaboClassQuizResultSchema = zod_1.z.object({
120
+ score: zod_1.z.object({
121
+ obtained: zod_1.z.number(),
122
+ total: zod_1.z.number(),
123
+ }),
124
+ totalItemsText: zod_1.z.string().nullable(),
125
+ questions: zod_1.z.array(exports.ManaboClassQuizResultQuestionSchema),
126
+ });
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ManaboEntryResponseSchema = exports.ManaboEntryFormSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.ManaboEntryFormSchema = zod_1.z.object({
6
+ action: zod_1.z.string(),
7
+ classId: zod_1.z.string(),
8
+ directoryId: zod_1.z.string(),
9
+ entryId: zod_1.z.string(),
10
+ uniqid: zod_1.z.string(),
11
+ messages: zod_1.z.array(zod_1.z.string()),
12
+ });
13
+ exports.ManaboEntryResponseSchema = zod_1.z.object({
14
+ success: zod_1.z.boolean(),
15
+ html: zod_1.z.string().nullable(),
16
+ error: zod_1.z.string().nullable(),
17
+ message: zod_1.z.string().nullable(),
18
+ data: zod_1.z.object({
19
+ is_accepted: zod_1.z.number(),
20
+ }),
21
+ });
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ManaboMailMemberSchema = exports.ManaboMailSendSchema = exports.ManaboMailViewSchema = exports.ManaboSentMailSchema = exports.ManaboSentMailItemSchema = exports.ManaboReceivedMailSchema = exports.ManaboReceivedMailItemSchema = exports.ManaboMailListPageSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.ManaboMailListPageSchema = zod_1.z.object({
6
+ label: zod_1.z.string(),
7
+ page: zod_1.z.string(),
8
+ active: zod_1.z.boolean(),
9
+ });
10
+ exports.ManaboReceivedMailItemSchema = zod_1.z.object({
11
+ id: zod_1.z.string(),
12
+ title: zod_1.z.string(),
13
+ statusIconAlt: zod_1.z.string().nullable(),
14
+ statusIconSrc: zod_1.z.string().nullable(),
15
+ mailLink: zod_1.z.string().nullable(),
16
+ senderName: zod_1.z.string().nullable(),
17
+ senderImage: zod_1.z.string().nullable(),
18
+ receivedAt: zod_1.z.string(),
19
+ });
20
+ exports.ManaboReceivedMailSchema = zod_1.z.object({
21
+ summary: zod_1.z.string().nullable(),
22
+ pages: zod_1.z.array(exports.ManaboMailListPageSchema),
23
+ mails: zod_1.z.array(exports.ManaboReceivedMailItemSchema),
24
+ });
25
+ exports.ManaboSentMailItemSchema = zod_1.z.object({
26
+ id: zod_1.z.string(),
27
+ title: zod_1.z.string(),
28
+ statusIconAlt: zod_1.z.string().nullable(),
29
+ statusIconSrc: zod_1.z.string().nullable(),
30
+ mailLink: zod_1.z.string().nullable(),
31
+ recipientName: zod_1.z.string().nullable(),
32
+ recipientImage: zod_1.z.string().nullable(),
33
+ sentAt: zod_1.z.string(),
34
+ unreadCount: zod_1.z.number(),
35
+ });
36
+ exports.ManaboSentMailSchema = zod_1.z.object({
37
+ summary: zod_1.z.string().nullable(),
38
+ mails: zod_1.z.array(exports.ManaboSentMailItemSchema),
39
+ });
40
+ exports.ManaboMailViewSchema = zod_1.z.object({
41
+ title: zod_1.z.string(),
42
+ replyMailId: zod_1.z.string().nullable(),
43
+ fromMemberId: zod_1.z.string().nullable(),
44
+ nextMailId: zod_1.z.string().nullable(),
45
+ senderName: zod_1.z.string(),
46
+ senderImage: zod_1.z.string().nullable(),
47
+ sentAt: zod_1.z.string(),
48
+ bodyHtml: zod_1.z.string(),
49
+ });
50
+ exports.ManaboMailSendSchema = zod_1.z.object({
51
+ modalTitle: zod_1.z.string(),
52
+ form: zod_1.z.object({
53
+ action: zod_1.z.string(),
54
+ replyMailId: zod_1.z.string().nullable(),
55
+ signature: zod_1.z.string().nullable(),
56
+ csrfToken: zod_1.z.string(),
57
+ }),
58
+ submitLabel: zod_1.z.string(),
59
+ });
60
+ exports.ManaboMailMemberSchema = zod_1.z.object({
61
+ members: zod_1.z.array(zod_1.z.object({
62
+ memberId: zod_1.z.string(),
63
+ name: zod_1.z.string(),
64
+ image: zod_1.z.string().nullable(),
65
+ })),
66
+ });
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ManaboNewsSchema = exports.ManaboNewsItemSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.ManaboNewsItemSchema = zod_1.z.object({
6
+ text: zod_1.z.string(),
7
+ });
8
+ exports.ManaboNewsSchema = zod_1.z.object({
9
+ message: zod_1.z.string().nullable(),
10
+ items: zod_1.z.array(exports.ManaboNewsItemSchema),
11
+ });
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ManaboTimetableSchema = exports.ManaboTimetableViewModeSchema = exports.ManaboTimetableTermSchema = exports.ManaboTimetablePeriodSchema = exports.ManaboTimetableSlotSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.ManaboTimetableSlotSchema = zod_1.z.object({
6
+ day: zod_1.z.string(),
7
+ className: zod_1.z.string().nullable(),
8
+ teacher: zod_1.z.string().nullable(),
9
+ href: zod_1.z.string().nullable(),
10
+ });
11
+ exports.ManaboTimetablePeriodSchema = zod_1.z.object({
12
+ period: zod_1.z.string(),
13
+ slots: zod_1.z.array(exports.ManaboTimetableSlotSchema),
14
+ });
15
+ exports.ManaboTimetableTermSchema = zod_1.z.object({
16
+ archiveId: zod_1.z.string(),
17
+ label: zod_1.z.string(),
18
+ active: zod_1.z.boolean(),
19
+ });
20
+ exports.ManaboTimetableViewModeSchema = zod_1.z.object({
21
+ archiveId: zod_1.z.string(),
22
+ mode: zod_1.z.string().nullable(),
23
+ label: zod_1.z.string(),
24
+ active: zod_1.z.boolean(),
25
+ });
26
+ exports.ManaboTimetableSchema = zod_1.z.object({
27
+ title: zod_1.z.string(),
28
+ terms: zod_1.z.array(exports.ManaboTimetableTermSchema),
29
+ viewModes: zod_1.z.array(exports.ManaboTimetableViewModeSchema),
30
+ days: zod_1.z.array(zod_1.z.string()),
31
+ periods: zod_1.z.array(exports.ManaboTimetablePeriodSchema),
32
+ });
@@ -0,0 +1,3 @@
1
+ export { parseCubicsPtNews } from "./parser/albo";
2
+ export { type CubicsPtNewsDTO, type CubicsPtNewsTabDTO, type CubicsPtNewsEntryDTO } from "./types/albo";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/albo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,kBAAkB,EAAE,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1 @@
1
+ export { parseCubicsPtNews } from "./parser/albo";
@@ -0,0 +1,4 @@
1
+ import { type CubicsPtNewsDTO } from "../types/albo";
2
+ import type { ZodSafeParseResult } from "zod";
3
+ export declare const parseCubicsPtNews: (html: string) => ZodSafeParseResult<CubicsPtNewsDTO>;
4
+ //# sourceMappingURL=albo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"albo.d.ts","sourceRoot":"","sources":["../../../../src/albo/parser/albo.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiD,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AACpG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,KAAK,CAAC;AAyB9C,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,KAAG,kBAAkB,CAAC,eAAe,CA+BlF,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { loadDocument, queryAll, queryOne, getAttribute, getTextContent, elementHasClass } from "../../common/dom";
2
+ import { CubicsPtNewsSchema } from "../types/albo";
3
+ import { normalizeWhitespace, extractFirstQuotedValue } from "../../common/utils";
4
+ const parseNewsEntry = (row) => {
5
+ const categoryImg = queryOne("th.category img", row);
6
+ const statusImg = queryOne("td.status img", row);
7
+ const headlineAnchor = queryOne("td.headline a", row);
8
+ if (!headlineAnchor) {
9
+ return null;
10
+ }
11
+ const title = normalizeWhitespace(getTextContent(headlineAnchor));
12
+ const onclick = getAttribute(headlineAnchor, "onclick") ?? "";
13
+ const href = getAttribute(headlineAnchor, "href");
14
+ const link = extractFirstQuotedValue(onclick) ?? href ?? null;
15
+ return {
16
+ category: getAttribute(categoryImg, "alt"),
17
+ status: getAttribute(statusImg, "alt") ?? getAttribute(statusImg, "src"),
18
+ title,
19
+ link,
20
+ };
21
+ };
22
+ export const parseCubicsPtNews = (html) => {
23
+ const document = loadDocument(html);
24
+ const tabs = queryAll("#tab_element li", document).map((tab) => {
25
+ const anchor = queryOne("a", tab);
26
+ const href = getAttribute(anchor, "href") ?? "";
27
+ const targetId = href.replace(/^#/, "");
28
+ const title = normalizeWhitespace(anchor ? getTextContent(anchor) : "");
29
+ const rows = queryAll(`#${targetId} table.tab-newslist tr`, document)
30
+ .map((row) => parseNewsEntry(row))
31
+ .filter((entry) => entry !== null);
32
+ return {
33
+ id: targetId,
34
+ title,
35
+ entries: rows,
36
+ active: elementHasClass(tab, "selected"),
37
+ };
38
+ });
39
+ const selectedTab = tabs.find((tab) => tab.active);
40
+ return CubicsPtNewsSchema.safeParse({
41
+ selectedTabId: selectedTab ? selectedTab.id : null,
42
+ tabs: tabs.map((tab) => ({
43
+ id: tab.id,
44
+ title: tab.title,
45
+ entries: tab.entries,
46
+ })),
47
+ });
48
+ };
@@ -0,0 +1,34 @@
1
+ import { z } from "zod";
2
+ export declare const CubicsPtNewsEntrySchema: z.ZodObject<{
3
+ category: z.ZodNullable<z.ZodString>;
4
+ status: z.ZodNullable<z.ZodString>;
5
+ title: z.ZodString;
6
+ link: z.ZodNullable<z.ZodString>;
7
+ }, z.core.$strip>;
8
+ export type CubicsPtNewsEntryDTO = z.infer<typeof CubicsPtNewsEntrySchema>;
9
+ export declare const CubicsPtNewsTabSchema: z.ZodObject<{
10
+ id: z.ZodString;
11
+ title: z.ZodString;
12
+ entries: z.ZodArray<z.ZodObject<{
13
+ category: z.ZodNullable<z.ZodString>;
14
+ status: z.ZodNullable<z.ZodString>;
15
+ title: z.ZodString;
16
+ link: z.ZodNullable<z.ZodString>;
17
+ }, z.core.$strip>>;
18
+ }, z.core.$strip>;
19
+ export type CubicsPtNewsTabDTO = z.infer<typeof CubicsPtNewsTabSchema>;
20
+ export declare const CubicsPtNewsSchema: z.ZodObject<{
21
+ selectedTabId: z.ZodNullable<z.ZodString>;
22
+ tabs: z.ZodArray<z.ZodObject<{
23
+ id: z.ZodString;
24
+ title: z.ZodString;
25
+ entries: z.ZodArray<z.ZodObject<{
26
+ category: z.ZodNullable<z.ZodString>;
27
+ status: z.ZodNullable<z.ZodString>;
28
+ title: z.ZodString;
29
+ link: z.ZodNullable<z.ZodString>;
30
+ }, z.core.$strip>>;
31
+ }, z.core.$strip>>;
32
+ }, z.core.$strip>;
33
+ export type CubicsPtNewsDTO = z.infer<typeof CubicsPtNewsSchema>;
34
+ //# sourceMappingURL=albo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"albo.d.ts","sourceRoot":"","sources":["../../../../src/albo/types/albo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,uBAAuB;;;;;iBAKlC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE3E,eAAO,MAAM,qBAAqB;;;;;;;;;iBAIhC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEvE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;iBAG7B,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { z } from "zod";
2
+ export const CubicsPtNewsEntrySchema = z.object({
3
+ category: z.string().nullable(),
4
+ status: z.string().nullable(),
5
+ title: z.string(),
6
+ link: z.string().nullable(),
7
+ });
8
+ export const CubicsPtNewsTabSchema = z.object({
9
+ id: z.string(),
10
+ title: z.string(),
11
+ entries: z.array(CubicsPtNewsEntrySchema),
12
+ });
13
+ export const CubicsPtNewsSchema = z.object({
14
+ selectedTabId: z.string().nullable(),
15
+ tabs: z.array(CubicsPtNewsTabSchema),
16
+ });
@@ -0,0 +1,18 @@
1
+ import type { AnyNode, Element, Document } from "domhandler";
2
+ type Root = Document | Element | AnyNode[] | null | undefined;
3
+ export declare const loadDocument: (html: string) => Document;
4
+ export declare const queryAll: (selector: string, root: Root) => Element[];
5
+ export declare const queryOne: (selector: string, root: Root) => Element | null;
6
+ export declare const getAttribute: (element: Element | null | undefined, name: string) => string | null;
7
+ export declare const getTextContent: (node: AnyNode | null | undefined) => string;
8
+ export declare const getInnerHtml: (element: Element | null | undefined) => string;
9
+ export declare const elementHasClass: (element: Element | null | undefined, className: string) => boolean;
10
+ export declare const closest: (element: Element | null | undefined, selector: string) => Element | null;
11
+ export declare const nextSiblingElement: (element: Element | null | undefined) => Element | null;
12
+ export declare const previousSiblingElement: (element: Element | null | undefined) => Element | null;
13
+ export declare const isElement: (node: AnyNode | null | undefined) => node is Element;
14
+ export declare const filterElements: (nodes: AnyNode[]) => Element[];
15
+ export declare const getChildrenElements: (element: Element | null | undefined) => Element[];
16
+ export declare const matches: (element: Element | null | undefined, selector: string) => boolean;
17
+ export { type Element } from "domhandler";
18
+ //# sourceMappingURL=dom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../../src/common/dom.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAI7D,KAAK,IAAI,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;AAe9D,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,QAA+B,CAAC;AAE5E,eAAO,MAAM,QAAQ,GAAI,UAAU,MAAM,EAAE,MAAM,IAAI,KAAG,OAAO,EAAwC,CAAC;AAExG,eAAO,MAAM,QAAQ,GAAI,UAAU,MAAM,EAAE,MAAM,IAAI,KAAG,OAAO,GAAG,IAA0C,CAAC;AAE7G,eAAO,MAAM,YAAY,GAAI,SAAS,OAAO,GAAG,IAAI,GAAG,SAAS,EAAE,MAAM,MAAM,KAAG,MAAM,GAAG,IAMzF,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,MAAM,OAAO,GAAG,IAAI,GAAG,SAAS,KAAG,MAKjE,CAAC;AAaF,eAAO,MAAM,YAAY,GAAI,SAAS,OAAO,GAAG,IAAI,GAAG,SAAS,KAAG,MASlE,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,SAAS,OAAO,GAAG,IAAI,GAAG,SAAS,EAAE,WAAW,MAAM,KAAG,OASxF,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,SAAS,OAAO,GAAG,IAAI,GAAG,SAAS,EAAE,UAAU,MAAM,KAAG,OAAO,GAAG,IAUzF,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,SAAS,OAAO,GAAG,IAAI,GAAG,SAAS,KAAG,OAAO,GAAG,IAMlF,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,SAAS,OAAO,GAAG,IAAI,GAAG,SAAS,KAAG,OAAO,GAAG,IAMtF,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,MAAM,OAAO,GAAG,IAAI,GAAG,SAAS,KAAG,IAAI,IAAI,OAAgC,CAAC;AAEtG,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,EAAE,KAAG,OAAO,EAA0D,CAAC;AAEpH,eAAO,MAAM,mBAAmB,GAAI,SAAS,OAAO,GAAG,IAAI,GAAG,SAAS,KAAG,OAAO,EAKhF,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,SAAS,OAAO,GAAG,IAAI,GAAG,SAAS,EAAE,UAAU,MAAM,KAAG,OAK/E,CAAC;AAEF,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,99 @@
1
+ import { parseDocument } from "htmlparser2";
2
+ import { selectAll, selectOne, is as matchesSelector } from "css-select";
3
+ import { getAttributeValue, getInnerHTML, textContent, isTag, getParent, nextElementSibling, prevElementSibling } from "domutils";
4
+ const toArray = (root) => {
5
+ if (!root) {
6
+ return [];
7
+ }
8
+ if (Array.isArray(root)) {
9
+ return root;
10
+ }
11
+ if ("children" in root && Array.isArray(root.children)) {
12
+ return root.children;
13
+ }
14
+ return [root];
15
+ };
16
+ export const loadDocument = (html) => parseDocument(html);
17
+ export const queryAll = (selector, root) => selectAll(selector, toArray(root));
18
+ export const queryOne = (selector, root) => selectOne(selector, toArray(root));
19
+ export const getAttribute = (element, name) => {
20
+ if (!element) {
21
+ return null;
22
+ }
23
+ const value = getAttributeValue(element, name);
24
+ return typeof value === "string" ? value : null;
25
+ };
26
+ export const getTextContent = (node) => {
27
+ if (!node) {
28
+ return "";
29
+ }
30
+ return textContent(node);
31
+ };
32
+ const decodeNumericEntities = (value) => value
33
+ .replace(/&#x([0-9a-fA-F]+);/g, (match, hex) => {
34
+ const codePoint = Number.parseInt(hex, 16);
35
+ return Number.isNaN(codePoint) ? match : String.fromCodePoint(codePoint);
36
+ })
37
+ .replace(/&#([0-9]+);/g, (match, dec) => {
38
+ const codePoint = Number.parseInt(dec, 10);
39
+ return Number.isNaN(codePoint) ? match : String.fromCodePoint(codePoint);
40
+ });
41
+ export const getInnerHtml = (element) => {
42
+ if (!element) {
43
+ return "";
44
+ }
45
+ const inner = getInnerHTML(element);
46
+ const decoded = decodeNumericEntities(inner);
47
+ const normalised = decoded.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
48
+ const withNbsp = normalised.replace(/\u00a0/g, "&nbsp;");
49
+ return withNbsp.replace(/\salt(?!\s*=)(?=[\s/>])/g, ' alt=""');
50
+ };
51
+ export const elementHasClass = (element, className) => {
52
+ if (!element) {
53
+ return false;
54
+ }
55
+ const classAttr = getAttribute(element, "class");
56
+ if (!classAttr) {
57
+ return false;
58
+ }
59
+ return classAttr.split(/\s+/).includes(className);
60
+ };
61
+ export const closest = (element, selector) => {
62
+ let current = element;
63
+ while (current) {
64
+ if (matchesSelector(current, selector)) {
65
+ return current;
66
+ }
67
+ const parent = getParent(current);
68
+ current = parent && isTag(parent) ? parent : null;
69
+ }
70
+ return null;
71
+ };
72
+ export const nextSiblingElement = (element) => {
73
+ if (!element) {
74
+ return null;
75
+ }
76
+ const sibling = nextElementSibling(element);
77
+ return sibling ?? null;
78
+ };
79
+ export const previousSiblingElement = (element) => {
80
+ if (!element) {
81
+ return null;
82
+ }
83
+ const sibling = prevElementSibling(element);
84
+ return sibling ?? null;
85
+ };
86
+ export const isElement = (node) => !!node && isTag(node);
87
+ export const filterElements = (nodes) => nodes.filter((node) => isTag(node));
88
+ export const getChildrenElements = (element) => {
89
+ if (!element) {
90
+ return [];
91
+ }
92
+ return filterElements(element.children ?? []);
93
+ };
94
+ export const matches = (element, selector) => {
95
+ if (!element) {
96
+ return false;
97
+ }
98
+ return matchesSelector(element, selector);
99
+ };
@@ -0,0 +1,3 @@
1
+ export declare const normalizeWhitespace: (value: string) => string;
2
+ export declare const extractFirstQuotedValue: (raw: string | undefined | null) => string | null;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/common/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,GAAI,OAAO,MAAM,KAAG,MAA2C,CAAC;AAEhG,eAAO,MAAM,uBAAuB,GAAI,KAAK,MAAM,GAAG,SAAS,GAAG,IAAI,KAAG,MAAM,GAAG,IAMjF,CAAC"}
@@ -0,0 +1,8 @@
1
+ export const normalizeWhitespace = (value) => value.replace(/\s+/g, " ").trim();
2
+ export const extractFirstQuotedValue = (raw) => {
3
+ if (!raw) {
4
+ return null;
5
+ }
6
+ const match = raw.match(/'([^']+)'/);
7
+ return match ? match[1] ?? null : null;
8
+ };
@@ -0,0 +1,3 @@
1
+ export { parseCubicsAsTimetable } from "./parser/cubics";
2
+ export { type CubicsAsTimetableSlotDTO, type CubicsAsTimetablePeriodDTO, type CubicsAsTimetableDTO } from "./types/cubics";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cubics/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,KAAK,wBAAwB,EAAE,KAAK,0BAA0B,EAAE,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1 @@
1
+ export { parseCubicsAsTimetable } from "./parser/cubics";
@@ -0,0 +1,4 @@
1
+ import { type CubicsAsTimetableDTO } from "../types/cubics";
2
+ import type { ZodSafeParseResult } from "zod";
3
+ export declare const parseCubicsAsTimetable: (html: string) => ZodSafeParseResult<CubicsAsTimetableDTO>;
4
+ //# sourceMappingURL=cubics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cubics.d.ts","sourceRoot":"","sources":["../../../../src/cubics/parser/cubics.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACrF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,KAAK,CAAC;AAG9C,eAAO,MAAM,sBAAsB,GAAI,MAAM,MAAM,KAAG,kBAAkB,CAAC,oBAAoB,CAuG5F,CAAC"}