@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,5 @@
1
+ import { type ManaboEntryFormDTO, type ManaboEntryResponseDTO } from "../types/manaboEntry";
2
+ import type { ZodSafeParseResult } from "zod";
3
+ export declare const parseManaboEntryForm: (html: string) => ZodSafeParseResult<ManaboEntryFormDTO>;
4
+ export declare const parseManaboEntryResponse: (json: string) => ZodSafeParseResult<ManaboEntryResponseDTO>;
5
+ //# sourceMappingURL=manaboEntry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manaboEntry.d.ts","sourceRoot":"","sources":["../../../../src/manabo/parser/manaboEntry.ts"],"names":[],"mappings":"AACA,OAAO,EAAoD,KAAK,kBAAkB,EAAE,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9I,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,KAAK,CAAC;AAI9C,eAAO,MAAM,oBAAoB,GAAI,MAAM,MAAM,KAAG,kBAAkB,CAAC,kBAAkB,CAkBxF,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,MAAM,MAAM,KAAG,kBAAkB,CAAC,sBAAsB,CAQhG,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { loadDocument, queryAll, queryOne, getAttribute, getTextContent } from "../../common/dom";
2
+ import { ManaboEntryFormSchema, ManaboEntryResponseSchema } from "../types/manaboEntry";
3
+ const normalizeWhitespace = (value) => value.replace(/\s+/g, " ").trim();
4
+ export const parseManaboEntryForm = (html) => {
5
+ const document = loadDocument(html);
6
+ const form = queryOne("#form-entry", document);
7
+ const messages = form
8
+ ? queryAll("p", form)
9
+ .map((element) => normalizeWhitespace(getTextContent(element)))
10
+ .filter((message) => message.length > 0)
11
+ : [];
12
+ return ManaboEntryFormSchema.safeParse({
13
+ action: getAttribute(queryOne('input[name="action"]', form ?? null), "value") ?? "",
14
+ classId: getAttribute(queryOne('input[name="class_id"]', form ?? null), "value") ?? "",
15
+ directoryId: getAttribute(queryOne('input[name="directory_id"]', form ?? null), "value") ?? "",
16
+ entryId: getAttribute(queryOne('input[name="entry_id"]', form ?? null), "value") ?? "",
17
+ uniqid: getAttribute(queryOne('input[name="uniqid"]', form ?? null), "value") ?? "",
18
+ messages,
19
+ });
20
+ };
21
+ export const parseManaboEntryResponse = (json) => {
22
+ let parsed;
23
+ try {
24
+ parsed = JSON.parse(json);
25
+ }
26
+ catch {
27
+ parsed = undefined;
28
+ }
29
+ return ManaboEntryResponseSchema.safeParse(parsed);
30
+ };
@@ -0,0 +1,8 @@
1
+ import { type ManaboMailMemberDTO, type ManaboMailSendDTO, type ManaboMailViewDTO, type ManaboReceivedMailDTO, type ManaboSentMailDTO } from "../types/manaboMail";
2
+ import type { ZodSafeParseResult } from "zod";
3
+ export declare const parseManaboReceivedMail: (html: string) => ZodSafeParseResult<ManaboReceivedMailDTO>;
4
+ export declare const parseManaboSentMail: (html: string) => ZodSafeParseResult<ManaboSentMailDTO>;
5
+ export declare const parseManaboMailView: (html: string) => ZodSafeParseResult<ManaboMailViewDTO>;
6
+ export declare const parseManaboMailSend: (html: string) => ZodSafeParseResult<ManaboMailSendDTO>;
7
+ export declare const parseManaboMailMember: (html: string) => ZodSafeParseResult<ManaboMailMemberDTO>;
8
+ //# sourceMappingURL=manaboMail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manaboMail.d.ts","sourceRoot":"","sources":["../../../../src/manabo/parser/manaboMail.ts"],"names":[],"mappings":"AAEA,OAAO,EAMH,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,KAAK,CAAC;AAwC9C,eAAO,MAAM,uBAAuB,GAAI,MAAM,MAAM,KAAG,kBAAkB,CAAC,qBAAqB,CAmC9F,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,KAAG,kBAAkB,CAAC,iBAAiB,CAsCtF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,KAAG,kBAAkB,CAAC,iBAAiB,CAoCtF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,KAAG,kBAAkB,CAAC,iBAAiB,CAetF,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,MAAM,MAAM,KAAG,kBAAkB,CAAC,mBAAmB,CAkB1F,CAAC"}
@@ -0,0 +1,161 @@
1
+ import { loadDocument, queryAll, queryOne, getAttribute, getTextContent, getInnerHtml, elementHasClass, isElement } from "../../common/dom";
2
+ import { ManaboMailMemberSchema, ManaboMailSendSchema, ManaboMailViewSchema, ManaboReceivedMailSchema, ManaboSentMailSchema, } from "../types/manaboMail";
3
+ const normalizeWhitespace = (value) => value.replace(/\s+/g, " ").trim();
4
+ const collectTextExcluding = (nodes, exclude) => normalizeWhitespace(nodes
5
+ .filter((node) => !exclude(node))
6
+ .map((node) => getTextContent(node))
7
+ .join(" "));
8
+ const extractPagination = (document) => {
9
+ const summaryElement = queryOne(".row.margin-top-md .col-sm-2", document);
10
+ const summaryText = normalizeWhitespace(getTextContent(summaryElement));
11
+ const pages = queryAll("ul.pagination li", document)
12
+ .map((li) => {
13
+ const anchor = queryOne("a", li);
14
+ const labelSource = anchor ?? queryOne("span", li);
15
+ const label = normalizeWhitespace(getTextContent(labelSource));
16
+ return {
17
+ label,
18
+ page: anchor ? getAttribute(anchor, "page") ?? label : label,
19
+ active: (anchor ? elementHasClass(anchor, "active") : false) || elementHasClass(li, "active"),
20
+ };
21
+ })
22
+ .filter((page) => page.label.length > 0);
23
+ return {
24
+ summary: summaryText.length ? summaryText : null,
25
+ pages,
26
+ };
27
+ };
28
+ export const parseManaboReceivedMail = (html) => {
29
+ const document = loadDocument(html);
30
+ const { summary, pages } = extractPagination(document);
31
+ const mails = queryAll("table.table-default tbody tr", document).map((row) => {
32
+ const cells = queryAll("td", row);
33
+ const checkbox = queryOne('input[type="checkbox"]', row);
34
+ const mailId = getAttribute(checkbox, "value") ?? getAttribute(checkbox, "name") ?? "";
35
+ const titleAnchor = queryOne("td.title a.a-mail-view", row);
36
+ const statusIcon = queryOne("td.title img.icon", row);
37
+ const senderCell = cells[2];
38
+ const senderImage = getAttribute(queryOne("img", senderCell ?? null), "src");
39
+ const humanSender = queryOne("span.margin-left-sm", senderCell ?? null);
40
+ const classSender = queryOne("a", senderCell ?? null);
41
+ const senderName = normalizeWhitespace(getTextContent(humanSender ?? classSender ?? null));
42
+ const receivedAt = normalizeWhitespace(getTextContent(cells[3] ?? null));
43
+ const statusAltRaw = normalizeWhitespace(getAttribute(statusIcon, "alt") ?? "");
44
+ return {
45
+ id: mailId,
46
+ title: normalizeWhitespace(getTextContent(titleAnchor)),
47
+ statusIconAlt: statusAltRaw.length ? statusAltRaw : null,
48
+ statusIconSrc: getAttribute(statusIcon, "src"),
49
+ mailLink: getAttribute(titleAnchor, "href"),
50
+ senderName: senderName.length ? senderName : null,
51
+ senderImage,
52
+ receivedAt,
53
+ };
54
+ });
55
+ return ManaboReceivedMailSchema.safeParse({
56
+ summary,
57
+ pages,
58
+ mails,
59
+ });
60
+ };
61
+ export const parseManaboSentMail = (html) => {
62
+ const document = loadDocument(html);
63
+ const summaryRaw = normalizeWhitespace(getTextContent(queryOne(".row.margin-top-md .col-sm-2", document)));
64
+ const mails = queryAll("table.table-default tbody tr", document).map((row) => {
65
+ const cells = queryAll("td", row);
66
+ const checkbox = queryOne('input[type="checkbox"]', row);
67
+ const mailId = getAttribute(checkbox, "value") ?? getAttribute(checkbox, "name") ?? "";
68
+ const titleCell = cells[1];
69
+ const titleAnchor = queryOne("a.a-mail-view", titleCell ?? null);
70
+ const statusIcon = queryOne("img.icon", titleCell ?? null);
71
+ const recipientCell = cells[2];
72
+ const recipientImage = getAttribute(queryOne("img", recipientCell ?? null), "src");
73
+ const humanSender = queryOne("span.margin-left-sm", recipientCell ?? null);
74
+ const classSender = queryOne("a", recipientCell ?? null);
75
+ const recipientName = normalizeWhitespace(getTextContent(humanSender ?? classSender ?? null));
76
+ const sentAt = normalizeWhitespace(getTextContent(cells[3] ?? null));
77
+ const unreadCountRaw = normalizeWhitespace(getTextContent(cells[4] ?? null));
78
+ const unreadCount = Number(unreadCountRaw.replace(/[^\d]/g, "")) || 0;
79
+ const statusAltRaw = normalizeWhitespace(getAttribute(statusIcon, "alt") ?? "");
80
+ return {
81
+ id: mailId,
82
+ title: normalizeWhitespace(getTextContent(titleAnchor)),
83
+ statusIconAlt: statusAltRaw.length ? statusAltRaw : null,
84
+ statusIconSrc: getAttribute(statusIcon, "src"),
85
+ mailLink: getAttribute(titleAnchor, "href"),
86
+ recipientName: recipientName.length ? recipientName : null,
87
+ recipientImage,
88
+ sentAt,
89
+ unreadCount,
90
+ };
91
+ });
92
+ return ManaboSentMailSchema.safeParse({
93
+ summary: summaryRaw.length ? summaryRaw : null,
94
+ mails,
95
+ });
96
+ };
97
+ export const parseManaboMailView = (html) => {
98
+ const document = loadDocument(html);
99
+ const title = normalizeWhitespace(getTextContent(queryOne(".modal-title", document)));
100
+ const replyButton = queryOne(".a-reply-mail", document);
101
+ const nextButton = queryOne(".a-reopen-mail", document);
102
+ const senderBlocks = queryAll(".modal-body .margin-top-lg", document);
103
+ const senderBlock = senderBlocks[0];
104
+ const bodyBlock = senderBlocks[1];
105
+ const senderImage = getAttribute(queryOne("img", senderBlock ?? null), "src");
106
+ const senderName = normalizeWhitespace(getTextContent(queryOne("b", senderBlock ?? null)));
107
+ const sentAtRaw = senderBlock
108
+ ? collectTextExcluding(senderBlock.children ?? [], (node) => {
109
+ if (!isElement(node)) {
110
+ return false;
111
+ }
112
+ const name = node.name.toLowerCase();
113
+ return name === "a" || name === "script";
114
+ })
115
+ : "";
116
+ const sentAt = normalizeWhitespace(sentAtRaw);
117
+ const bodyHtml = bodyBlock ? getInnerHtml(bodyBlock).trim() : "";
118
+ return ManaboMailViewSchema.safeParse({
119
+ title,
120
+ replyMailId: getAttribute(replyButton, "reply_mail_id"),
121
+ fromMemberId: getAttribute(replyButton, "from_member_id"),
122
+ nextMailId: getAttribute(nextButton, "mail_id"),
123
+ senderName,
124
+ senderImage,
125
+ sentAt,
126
+ bodyHtml,
127
+ });
128
+ };
129
+ export const parseManaboMailSend = (html) => {
130
+ const document = loadDocument(html);
131
+ const modalTitle = normalizeWhitespace(getTextContent(queryOne(".modal-title", document)));
132
+ const form = queryOne("#form-mail", document);
133
+ return ManaboMailSendSchema.safeParse({
134
+ modalTitle,
135
+ form: {
136
+ action: getAttribute(queryOne('input[name="action"]', form ?? null), "value") ?? "",
137
+ replyMailId: getAttribute(queryOne('input[name="reply_mail_id"]', form ?? null), "value"),
138
+ signature: getAttribute(queryOne('input[name="signature"]', form ?? null), "value"),
139
+ csrfToken: getAttribute(queryOne('input[name="csrf_token"]', form ?? null), "value") ?? "",
140
+ },
141
+ submitLabel: normalizeWhitespace(getTextContent(queryOne(".button-send-mail", document))),
142
+ });
143
+ };
144
+ export const parseManaboMailMember = (html) => {
145
+ const document = loadDocument(html);
146
+ const members = queryAll(".div-mail-members li", document)
147
+ .map((item) => {
148
+ const anchor = queryOne("a.a-set-mail-member", item);
149
+ const name = normalizeWhitespace(getTextContent(anchor));
150
+ const image = getAttribute(queryOne("img", item), "src");
151
+ return {
152
+ memberId: getAttribute(anchor, "member_id") ?? "",
153
+ name,
154
+ image,
155
+ };
156
+ })
157
+ .filter((member) => member.memberId.length > 0);
158
+ return ManaboMailMemberSchema.safeParse({
159
+ members,
160
+ });
161
+ };
@@ -0,0 +1,4 @@
1
+ import { type ManaboNewsDTO } from "../types/manaboNews";
2
+ import type { ZodSafeParseResult } from "zod";
3
+ export declare const parseManaboNews: (html: string) => ZodSafeParseResult<ManaboNewsDTO>;
4
+ //# sourceMappingURL=manaboNews.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manaboNews.d.ts","sourceRoot":"","sources":["../../../../src/manabo/parser/manaboNews.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,KAAK,CAAC;AAI9C,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,kBAAkB,CAAC,aAAa,CAuB9E,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { loadDocument, queryAll, queryOne, getTextContent } from "../../common/dom";
2
+ import { ManaboNewsSchema } from "../types/manaboNews";
3
+ const normalizeWhitespace = (value) => value.replace(/\s+/g, " ").trim();
4
+ export const parseManaboNews = (html) => {
5
+ const document = loadDocument(html);
6
+ const rows = queryAll(".table-info tbody tr", document);
7
+ const items = [];
8
+ let message = null;
9
+ rows.forEach((row) => {
10
+ const text = normalizeWhitespace(getTextContent(row));
11
+ if (!text.length) {
12
+ return;
13
+ }
14
+ if (queryOne("a", row)) {
15
+ items.push({ text });
16
+ }
17
+ else {
18
+ message = text;
19
+ }
20
+ });
21
+ return ManaboNewsSchema.safeParse({
22
+ message,
23
+ items,
24
+ });
25
+ };
@@ -0,0 +1,4 @@
1
+ import { type ManaboTimetableDTO } from "../types/manaboTimetable";
2
+ import type { ZodSafeParseResult } from "zod";
3
+ export declare const parseManaboTimetable: (html: string) => ZodSafeParseResult<ManaboTimetableDTO>;
4
+ //# sourceMappingURL=manaboTimetable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manaboTimetable.d.ts","sourceRoot":"","sources":["../../../../src/manabo/parser/manaboTimetable.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyB,KAAK,kBAAkB,EAA8D,MAAM,0BAA0B,CAAC;AACtJ,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,KAAK,CAAC;AAkD9C,eAAO,MAAM,oBAAoB,GAAI,MAAM,MAAM,KAAG,kBAAkB,CAAC,kBAAkB,CAmCxF,CAAC"}
@@ -0,0 +1,71 @@
1
+ import { loadDocument, queryAll, queryOne, getAttribute, getTextContent, elementHasClass, closest, isElement } from "../../common/dom";
2
+ import { ManaboTimetableSchema } from "../types/manaboTimetable";
3
+ const normalizeWhitespace = (value) => value.replace(/\s+/g, " ").trim();
4
+ const collectTextExcluding = (nodes, selector) => normalizeWhitespace(nodes
5
+ .filter((node) => !selector(node))
6
+ .map((node) => getTextContent(node))
7
+ .join(" "));
8
+ const buildSlot = (cell, day) => {
9
+ const anchor = queryOne("div.student a", cell);
10
+ if (!anchor) {
11
+ return {
12
+ day,
13
+ className: null,
14
+ teacher: null,
15
+ href: null,
16
+ };
17
+ }
18
+ const classNameElement = queryOne("b", anchor);
19
+ const classNameText = normalizeWhitespace(classNameElement ? getTextContent(classNameElement) : "");
20
+ const teacherText = collectTextExcluding(anchor.children ?? [], (node) => {
21
+ if (!isElement(node))
22
+ return false;
23
+ return node.name === "b" || node.name === "a" || (node.name === "small" && elementHasClass(node, "label"));
24
+ });
25
+ const teacherValue = teacherText.length ? teacherText : null;
26
+ return {
27
+ day,
28
+ className: classNameText.length ? classNameText : null,
29
+ teacher: teacherValue,
30
+ href: getAttribute(anchor, "href"),
31
+ };
32
+ };
33
+ const buildPeriod = (row, days) => {
34
+ const periodLabel = normalizeWhitespace(getTextContent(queryOne("th.time", row)));
35
+ const cells = queryAll("td", row);
36
+ const slots = cells.map((cell, index) => buildSlot(cell, days[index] ?? ""));
37
+ return {
38
+ period: periodLabel,
39
+ slots,
40
+ };
41
+ };
42
+ export const parseManaboTimetable = (html) => {
43
+ const document = loadDocument(html);
44
+ const title = normalizeWhitespace(getTextContent(queryOne("#time_table_name", document)));
45
+ const termAnchors = queryAll(".calendar .nav-tabs a.a-load-timetable[archive_id]", document).map((anchor) => {
46
+ const enclosingLi = closest(anchor, "li");
47
+ return {
48
+ archiveId: getAttribute(anchor, "archive_id") ?? "",
49
+ label: normalizeWhitespace(getTextContent(anchor)),
50
+ active: elementHasClass(anchor, "active") || (enclosingLi ? elementHasClass(enclosingLi, "active") : false),
51
+ };
52
+ });
53
+ const viewModes = queryAll(".panel-body .text-right a.a-load-timetable", document).map((anchor) => ({
54
+ archiveId: getAttribute(anchor, "archive_id") ?? "",
55
+ mode: getAttribute(anchor, "mode"),
56
+ label: normalizeWhitespace(getTextContent(anchor)),
57
+ active: elementHasClass(anchor, "active"),
58
+ }));
59
+ const table = queryOne(".table-calendar", document);
60
+ const dayHeaders = table ? queryAll("thead tr th.data", table) : [];
61
+ const days = dayHeaders.map((element) => normalizeWhitespace(getTextContent(element)));
62
+ const periodRows = table ? queryAll("tbody tr", table) : [];
63
+ const periods = periodRows.map((row) => buildPeriod(row, days));
64
+ return ManaboTimetableSchema.safeParse({
65
+ title,
66
+ terms: termAnchors,
67
+ viewModes,
68
+ days,
69
+ periods,
70
+ });
71
+ };
@@ -0,0 +1,268 @@
1
+ import { z } from "zod";
2
+ export declare const ManaboClassDirectoryItemSchema: z.ZodObject<{
3
+ directoryId: z.ZodString;
4
+ title: z.ZodString;
5
+ }, z.core.$strip>;
6
+ export type ManaboClassDirectoryItemDTO = z.infer<typeof ManaboClassDirectoryItemSchema>;
7
+ export declare const ManaboClassDirectorySchema: z.ZodObject<{
8
+ classId: z.ZodString;
9
+ className: z.ZodString;
10
+ directories: z.ZodArray<z.ZodObject<{
11
+ directoryId: z.ZodString;
12
+ title: z.ZodString;
13
+ }, z.core.$strip>>;
14
+ }, z.core.$strip>;
15
+ export type ManaboClassDirectoryDTO = z.infer<typeof ManaboClassDirectorySchema>;
16
+ export declare const ManaboClassContentIconSchema: z.ZodObject<{
17
+ pluginIconSrc: z.ZodString;
18
+ isIconChecked: z.ZodBoolean;
19
+ }, z.core.$strip>;
20
+ export type ManaboClassContentIconDTO = z.infer<typeof ManaboClassContentIconSchema>;
21
+ export declare const ManaboClassContentDurationSchema: z.ZodObject<{
22
+ label: z.ZodString;
23
+ value: z.ZodString;
24
+ }, z.core.$strip>;
25
+ export type ManaboClassContentDurationDTO = z.infer<typeof ManaboClassContentDurationSchema>;
26
+ export declare const ManaboClassContentFileSchema: z.ZodObject<{
27
+ fileName: z.ZodString;
28
+ href: z.ZodString;
29
+ icon: z.ZodString;
30
+ }, z.core.$strip>;
31
+ export type ManaboClassContentFileDTO = z.infer<typeof ManaboClassContentFileSchema>;
32
+ export declare const ManaboClassContentActionSchema: z.ZodObject<{
33
+ title: z.ZodString;
34
+ href: z.ZodString;
35
+ }, z.core.$strip>;
36
+ export type ManaboClassContentActionDTO = z.infer<typeof ManaboClassContentActionSchema>;
37
+ export declare const ManaboClassContentAttachedFileSchema: z.ZodObject<{
38
+ comment: z.ZodString;
39
+ files: z.ZodArray<z.ZodObject<{
40
+ fileName: z.ZodString;
41
+ href: z.ZodString;
42
+ icon: z.ZodString;
43
+ }, z.core.$strip>>;
44
+ duration: z.ZodArray<z.ZodObject<{
45
+ label: z.ZodString;
46
+ value: z.ZodString;
47
+ }, z.core.$strip>>;
48
+ }, z.core.$strip>;
49
+ export type ManaboClassContentAttachedFileDTO = z.infer<typeof ManaboClassContentAttachedFileSchema>;
50
+ export declare const ManaboClassContentContentSchema: z.ZodObject<{
51
+ title: z.ZodString;
52
+ contentId: z.ZodString;
53
+ pluginKey: z.ZodString;
54
+ duration: z.ZodArray<z.ZodObject<{
55
+ label: z.ZodString;
56
+ value: z.ZodString;
57
+ }, z.core.$strip>>;
58
+ }, z.core.$strip>;
59
+ export type ManaboClassContentContentDTO = z.infer<typeof ManaboClassContentContentSchema>;
60
+ export declare const ManaboClassContentToggleAreaSchema: z.ZodObject<{
61
+ description: z.ZodString;
62
+ isExpired: z.ZodBoolean;
63
+ isNotAvailableYet: z.ZodBoolean;
64
+ actions: z.ZodArray<z.ZodObject<{
65
+ title: z.ZodString;
66
+ href: z.ZodString;
67
+ }, z.core.$strip>>;
68
+ }, z.core.$strip>;
69
+ export declare const ManaboClassFileContentSchema: z.ZodObject<{
70
+ type: z.ZodLiteral<"file">;
71
+ icon: z.ZodObject<{
72
+ pluginIconSrc: z.ZodString;
73
+ isIconChecked: z.ZodBoolean;
74
+ }, z.core.$strip>;
75
+ attachedFile: z.ZodObject<{
76
+ comment: z.ZodString;
77
+ files: z.ZodArray<z.ZodObject<{
78
+ fileName: z.ZodString;
79
+ href: z.ZodString;
80
+ icon: z.ZodString;
81
+ }, z.core.$strip>>;
82
+ duration: z.ZodArray<z.ZodObject<{
83
+ label: z.ZodString;
84
+ value: z.ZodString;
85
+ }, z.core.$strip>>;
86
+ }, z.core.$strip>;
87
+ }, z.core.$strip>;
88
+ export type ManaboClassFileContentDTO = z.infer<typeof ManaboClassFileContentSchema>;
89
+ export declare const ManaboClassReportContentSchema: z.ZodObject<{
90
+ type: z.ZodLiteral<"report">;
91
+ icon: z.ZodObject<{
92
+ pluginIconSrc: z.ZodString;
93
+ isIconChecked: z.ZodBoolean;
94
+ }, z.core.$strip>;
95
+ content: z.ZodObject<{
96
+ title: z.ZodString;
97
+ contentId: z.ZodString;
98
+ pluginKey: z.ZodString;
99
+ duration: z.ZodArray<z.ZodObject<{
100
+ label: z.ZodString;
101
+ value: z.ZodString;
102
+ }, z.core.$strip>>;
103
+ }, z.core.$strip>;
104
+ toggleArea: z.ZodObject<{
105
+ description: z.ZodString;
106
+ isExpired: z.ZodBoolean;
107
+ isNotAvailableYet: z.ZodBoolean;
108
+ actions: z.ZodArray<z.ZodObject<{
109
+ title: z.ZodString;
110
+ href: z.ZodString;
111
+ }, z.core.$strip>>;
112
+ }, z.core.$strip>;
113
+ }, z.core.$strip>;
114
+ export type ManaboClassReportContentDTO = z.infer<typeof ManaboClassReportContentSchema>;
115
+ export declare const ManaboClassContentSchema: z.ZodObject<{
116
+ contents: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
117
+ type: z.ZodLiteral<"file">;
118
+ icon: z.ZodObject<{
119
+ pluginIconSrc: z.ZodString;
120
+ isIconChecked: z.ZodBoolean;
121
+ }, z.core.$strip>;
122
+ attachedFile: z.ZodObject<{
123
+ comment: z.ZodString;
124
+ files: z.ZodArray<z.ZodObject<{
125
+ fileName: z.ZodString;
126
+ href: z.ZodString;
127
+ icon: z.ZodString;
128
+ }, z.core.$strip>>;
129
+ duration: z.ZodArray<z.ZodObject<{
130
+ label: z.ZodString;
131
+ value: z.ZodString;
132
+ }, z.core.$strip>>;
133
+ }, z.core.$strip>;
134
+ }, z.core.$strip>, z.ZodObject<{
135
+ type: z.ZodLiteral<"report">;
136
+ icon: z.ZodObject<{
137
+ pluginIconSrc: z.ZodString;
138
+ isIconChecked: z.ZodBoolean;
139
+ }, z.core.$strip>;
140
+ content: z.ZodObject<{
141
+ title: z.ZodString;
142
+ contentId: z.ZodString;
143
+ pluginKey: z.ZodString;
144
+ duration: z.ZodArray<z.ZodObject<{
145
+ label: z.ZodString;
146
+ value: z.ZodString;
147
+ }, z.core.$strip>>;
148
+ }, z.core.$strip>;
149
+ toggleArea: z.ZodObject<{
150
+ description: z.ZodString;
151
+ isExpired: z.ZodBoolean;
152
+ isNotAvailableYet: z.ZodBoolean;
153
+ actions: z.ZodArray<z.ZodObject<{
154
+ title: z.ZodString;
155
+ href: z.ZodString;
156
+ }, z.core.$strip>>;
157
+ }, z.core.$strip>;
158
+ }, z.core.$strip>]>>;
159
+ }, z.core.$strip>;
160
+ export type ManaboClassContentDTO = z.infer<typeof ManaboClassContentSchema>;
161
+ export declare const ManaboClassEntryRowSchema: z.ZodObject<{
162
+ directory: z.ZodString;
163
+ lectureDate: z.ZodNullable<z.ZodString>;
164
+ status: z.ZodString;
165
+ }, z.core.$strip>;
166
+ export type ManaboClassEntryRowDTO = z.infer<typeof ManaboClassEntryRowSchema>;
167
+ export declare const ManaboClassEntrySchema: z.ZodObject<{
168
+ rows: z.ZodArray<z.ZodObject<{
169
+ directory: z.ZodString;
170
+ lectureDate: z.ZodNullable<z.ZodString>;
171
+ status: z.ZodString;
172
+ }, z.core.$strip>>;
173
+ }, z.core.$strip>;
174
+ export type ManaboClassEntryDTO = z.infer<typeof ManaboClassEntrySchema>;
175
+ export declare const ManaboClassNewsItemSchema: z.ZodObject<{
176
+ id: z.ZodNullable<z.ZodString>;
177
+ title: z.ZodString;
178
+ bodyHtml: z.ZodString;
179
+ }, z.core.$strip>;
180
+ export type ManaboClassNewsItemDTO = z.infer<typeof ManaboClassNewsItemSchema>;
181
+ export declare const ManaboClassNewsSchema: z.ZodObject<{
182
+ items: z.ZodArray<z.ZodObject<{
183
+ id: z.ZodNullable<z.ZodString>;
184
+ title: z.ZodString;
185
+ bodyHtml: z.ZodString;
186
+ }, z.core.$strip>>;
187
+ }, z.core.$strip>;
188
+ export type ManaboClassNewsDTO = z.infer<typeof ManaboClassNewsSchema>;
189
+ export declare const ManaboClassSyllabusEvaluationSchema: z.ZodObject<{
190
+ type: z.ZodString;
191
+ weight: z.ZodString;
192
+ }, z.core.$strip>;
193
+ export type ManaboClassSyllabusEvaluationDTO = z.infer<typeof ManaboClassSyllabusEvaluationSchema>;
194
+ export declare const ManaboClassSyllabusTextbookSchema: z.ZodObject<{
195
+ type: z.ZodString;
196
+ title: z.ZodString;
197
+ }, z.core.$strip>;
198
+ export type ManaboClassSyllabusTextbookDTO = z.infer<typeof ManaboClassSyllabusTextbookSchema>;
199
+ export declare const ManaboClassSyllabusReferenceSchema: z.ZodObject<{
200
+ title: z.ZodString;
201
+ code: z.ZodString;
202
+ }, z.core.$strip>;
203
+ export type ManaboClassSyllabusReferenceDTO = z.infer<typeof ManaboClassSyllabusReferenceSchema>;
204
+ export declare const ManaboClassSyllabusPlanItemSchema: z.ZodObject<{
205
+ no: z.ZodNumber;
206
+ item: z.ZodString;
207
+ content: z.ZodString;
208
+ }, z.core.$strip>;
209
+ export type ManaboClassSyllabusPlanItemDTO = z.infer<typeof ManaboClassSyllabusPlanItemSchema>;
210
+ export declare const ManaboClassSyllabusSchema: z.ZodObject<{
211
+ object: z.ZodString;
212
+ goal: z.ZodArray<z.ZodString>;
213
+ method: z.ZodString;
214
+ usedMethods: z.ZodArray<z.ZodString>;
215
+ evaluation: z.ZodArray<z.ZodObject<{
216
+ type: z.ZodString;
217
+ weight: z.ZodString;
218
+ }, z.core.$strip>>;
219
+ textbooks: z.ZodArray<z.ZodObject<{
220
+ type: z.ZodString;
221
+ title: z.ZodString;
222
+ }, z.core.$strip>>;
223
+ references: z.ZodArray<z.ZodObject<{
224
+ title: z.ZodString;
225
+ code: z.ZodString;
226
+ }, z.core.$strip>>;
227
+ officeHour: z.ZodString;
228
+ plan: z.ZodArray<z.ZodObject<{
229
+ no: z.ZodNumber;
230
+ item: z.ZodString;
231
+ content: z.ZodString;
232
+ }, z.core.$strip>>;
233
+ comment: z.ZodString;
234
+ prePostStudy: z.ZodString;
235
+ }, z.core.$strip>;
236
+ export type ManaboClassSyllabusDTO = z.infer<typeof ManaboClassSyllabusSchema>;
237
+ export declare const ManaboClassQuizResultQuestionSchema: z.ZodObject<{
238
+ page: z.ZodString;
239
+ questionNumber: z.ZodString;
240
+ questionText: z.ZodString;
241
+ correctAnswer: z.ZodString;
242
+ studentAnswer: z.ZodString;
243
+ resultIconAlt: z.ZodNullable<z.ZodString>;
244
+ resultIconSrc: z.ZodNullable<z.ZodString>;
245
+ resultText: z.ZodNullable<z.ZodString>;
246
+ teacherComment: z.ZodNullable<z.ZodString>;
247
+ }, z.core.$strip>;
248
+ export type ManaboClassQuizResultQuestionDTO = z.infer<typeof ManaboClassQuizResultQuestionSchema>;
249
+ export declare const ManaboClassQuizResultSchema: z.ZodObject<{
250
+ score: z.ZodObject<{
251
+ obtained: z.ZodNumber;
252
+ total: z.ZodNumber;
253
+ }, z.core.$strip>;
254
+ totalItemsText: z.ZodNullable<z.ZodString>;
255
+ questions: z.ZodArray<z.ZodObject<{
256
+ page: z.ZodString;
257
+ questionNumber: z.ZodString;
258
+ questionText: z.ZodString;
259
+ correctAnswer: z.ZodString;
260
+ studentAnswer: z.ZodString;
261
+ resultIconAlt: z.ZodNullable<z.ZodString>;
262
+ resultIconSrc: z.ZodNullable<z.ZodString>;
263
+ resultText: z.ZodNullable<z.ZodString>;
264
+ teacherComment: z.ZodNullable<z.ZodString>;
265
+ }, z.core.$strip>>;
266
+ }, z.core.$strip>;
267
+ export type ManaboClassQuizResultDTO = z.infer<typeof ManaboClassQuizResultSchema>;
268
+ //# sourceMappingURL=manaboClass.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manaboClass.d.ts","sourceRoot":"","sources":["../../../../src/manabo/types/manaboClass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,8BAA8B;;;iBAGzC,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAEzF,eAAO,MAAM,0BAA0B;;;;;;;iBAIrC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAEjF,eAAO,MAAM,4BAA4B;;;iBAGvC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAErF,eAAO,MAAM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