@bluessu/meal-scraper 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,46 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2026 food-crawling-library contributors
5
+
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The GNU General Public License is a free, copyleft license for
12
+ software and other kinds of works.
13
+
14
+ The licenses for most software and other practical works are designed
15
+ to take away your freedom to share and change the works. By contrast,
16
+ the GNU General Public License is intended to guarantee your freedom to
17
+ share and change all versions of a program--to make sure it remains free
18
+ software for all its users. We, the Free Software Foundation, use the
19
+ GNU General Public License for most of our software; it applies to
20
+ a large part of the GNU operating system and to many other software systems
21
+ and works.
22
+
23
+ When we speak of free software, we are referring to freedom, not
24
+ price. Our General Public Licenses are designed to make sure that you
25
+ have the freedom to distribute copies of free software (and charge for
26
+ that service if you wish), that you receive source code or can get it
27
+ if you want it, that you can change the software or use pieces of it
28
+ in new free programs, and that you know you can do these things.
29
+
30
+ To protect your rights, we need to prevent others from denying you
31
+ these rights or asking you to surrender them. This is accomplished by
32
+ making requirements that forbid you to deny others these rights or to
33
+ ask them to surrender theirs.
34
+
35
+ For example, if you distribute copies of such a program, whether gratis
36
+ or for a fee, you must give the recipients all the rights that you
37
+ have received. You must make sure that they, too, receive or can get the
38
+ source code. And you must show them these terms so they know their rights.
39
+
40
+ Developers who use our licenses protect your rights in two ways: (1)
41
+ by clearly stating that there is no warranty for this free software. For
42
+ both users and authors to understand that there is no warranty; (2) by
43
+ making sure that modified versions of the software remain free.
44
+
45
+ For the full legal text and complete terms, use the official GNU license
46
+ text.
package/README.md ADDED
@@ -0,0 +1,210 @@
1
+ # @bluessu/meal-scraper
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@bluessu/meal-scraper.svg)](https://www.npmjs.com/package/@bluessu/meal-scraper)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@bluessu/meal-scraper.svg)](https://www.npmjs.com/package/@bluessu/meal-scraper)
5
+ [![license](https://img.shields.io/npm/l/@bluessu/meal-scraper.svg)](./LICENSE)
6
+ [![TypeScript](https://img.shields.io/badge/language-TypeScript-3178C6.svg?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
7
+
8
+ ## WIP (Working In Progress)
9
+
10
+ 현재 이 라이브러리는 개발 중인 상태입니다.
11
+
12
+ ## 프로젝트 출처
13
+
14
+ 이 프로젝트의 초기 구현은 [EAT-SSU/Food-Crawling](https://github.com/EAT-SSU/Food-Crawling) 내부 구현을 바탕으로 작성되었습니다.
15
+
16
+ ## 지원 환경
17
+
18
+ - Node.js: `>= 18`
19
+ - 공개 라이선스: GPL-3.0
20
+ - OpenAI 파서를 사용하려면 프로젝트에 `openai`가 별도 설치되어 있어야 합니다. (`openai`는 선택 의존성입니다)
21
+
22
+ ## 배포/릴리스
23
+
24
+ 패키지 배포는 다음 스크립트를 사용합니다.
25
+
26
+ ```bash
27
+ pnpm run release:patch
28
+ pnpm run release:minor
29
+ pnpm run release:major
30
+ ```
31
+
32
+ ## 설치
33
+
34
+ Using npm:
35
+
36
+ ```bash
37
+ npm i @bluessu/meal-scraper
38
+ ```
39
+
40
+ GPT 파서를 사용하려면 먼저 OpenAI 클라이언트를 설치하세요.
41
+
42
+ ```bash
43
+ pnpm add openai
44
+ ```
45
+
46
+ Using yarn
47
+
48
+ ```bash
49
+ yarn add @bluessu/meal-scraper
50
+ ```
51
+
52
+ Using pnpm:
53
+
54
+ ```bash
55
+ pnpm add @bluessu/meal-scraper
56
+ ```
57
+
58
+ ## 특징
59
+
60
+ - `createMealClient()` 또는 `new MealClient()`로 클라이언트 생성
61
+ - 단건 조회/배치 조회/범위 조회 지원
62
+ - 날짜 입력을 `string` 또는 `Date`로 유연하게 지원
63
+ - 내부 구현 분리로 공개 API가 간결하고 유지보수하기 쉬운 구조
64
+
65
+ ## 공개 API
66
+
67
+ `src/index.ts`에서 노출되는 주요 API는 다음과 같습니다.
68
+
69
+ - `MealClient`
70
+ - `createMealClient`
71
+ - `normalizeMenuDate`
72
+ - `buildDateRange`
73
+ - 타입
74
+ - `MenuDateInput`
75
+ - `MenuDate`
76
+ - `ParserMode`
77
+ - `MealClientOptions`
78
+ - `RangeOptions`
79
+ - 도메인/설정
80
+ - `CafeteriaType`
81
+ - `RawMenuData`
82
+ - `DailyMenu`
83
+ - `FoodCrawlerSettings`
84
+ - `defaultSettings`
85
+ - 예외
86
+ - `BaseCafeteriaException`
87
+ - `HolidayException`
88
+ - `MenuFetchException`
89
+ - `MenuParseException`
90
+
91
+ ## 기본 사용법
92
+
93
+ ```ts
94
+ import {
95
+ MealClient,
96
+ createMealClient,
97
+ CafeteriaType,
98
+ normalizeMenuDate,
99
+ buildDateRange,
100
+ } from "@bluessu/meal-scraper";
101
+
102
+ const client = createMealClient();
103
+ await client.getRawMenu(CafeteriaType.DODAM, new Date());
104
+ await client.getDailyMenu(CafeteriaType.HAKSIK, "2026-02-28");
105
+ await client.getDailyMenusByRange(CafeteriaType.FACULTY, "2026-02-28", "2026-03-02", {
106
+ concurrency: 3,
107
+ });
108
+ ```
109
+
110
+ ## Client 옵션
111
+
112
+ ```ts
113
+ export type ParserMode = "noop" | "gpt" | "custom";
114
+ ```
115
+
116
+ - `noop`(기본): 기본 파서(`NoopMenuParser`) 사용
117
+ - `gpt`: OpenAI 파서 사용 (`gptApiKey` 필수)
118
+ - `custom`: 직접 구현한 파서를 `parserImpl`로 주입
119
+
120
+ ```ts
121
+ import { createMealClient } from "@bluessu/meal-scraper";
122
+
123
+ // GPT 모드 예시 (키가 없으면 생성 단계에서 에러)
124
+ const gptClient = createMealClient({
125
+ parser: "gpt",
126
+ gptApiKey: process.env.OPENAI_API_KEY,
127
+ });
128
+
129
+ // 커스텀 파서 주입 예시
130
+ const customClient = createMealClient({
131
+ parser: "custom",
132
+ parserImpl: {
133
+ parseMenu: async (raw) => {
134
+ // 사용자 구현
135
+ return {
136
+ date: raw.date,
137
+ cafeteria: raw.cafeteria,
138
+ status: "open",
139
+ breakfast: {},
140
+ lunch: {},
141
+ dinner: {},
142
+ };
143
+ },
144
+ },
145
+ });
146
+ ```
147
+
148
+ ## 날짜 정규화 유틸
149
+
150
+ ```ts
151
+ import { normalizeMenuDate, buildDateRange } from "@bluessu/meal-scraper";
152
+
153
+ normalizeMenuDate("2026-02-28"); // "2026-02-28"
154
+ normalizeMenuDate(new Date(2026, 1, 28)); // "2026-02-28"
155
+
156
+ buildDateRange("2026-02-28", "2026-03-02"); // ["2026-02-28","2026-03-01","2026-03-02"]
157
+ ```
158
+
159
+ 지원 날짜 포맷은 내부적으로 모두 `YYYY-MM-DD`로 정규화됩니다.
160
+
161
+ ## API 목록
162
+
163
+ ### `MealClient`
164
+
165
+ - `getRawMenu(cafeteria, date): Promise<RawMenuData>`
166
+ - `getDailyMenu(cafeteria, date): Promise<DailyMenu>`
167
+ - `getRawMenus(cafeteria, dates, options?): Promise<RawMenuData[]>`
168
+ - `getDailyMenus(cafeteria, dates, options?): Promise<DailyMenu[]>`
169
+ - `getRawMenusByRange(cafeteria, start, end, options?): Promise<RawMenuData[]>`
170
+ - `getDailyMenusByRange(cafeteria, start, end, options?): Promise<DailyMenu[]>`
171
+
172
+ ### 옵션
173
+
174
+ - `RangeOptions`
175
+ - `startInclusive?: boolean` (기본값: `true`)
176
+ - `concurrency?: number` (기본값: `3`)
177
+
178
+ ## 에러 처리
179
+
180
+ ```ts
181
+ import { HolidayException, MenuFetchException } from "@bluessu/meal-scraper";
182
+
183
+ try {
184
+ const menu = await client.getDailyMenu(CafeteriaType.DORMITORY, "2026-02-28");
185
+ } catch (error) {
186
+ if (error instanceof HolidayException) {
187
+ console.log("휴일입니다");
188
+ } else if (error instanceof MenuFetchException) {
189
+ console.log("수집 실패");
190
+ } else {
191
+ console.error(error);
192
+ }
193
+ }
194
+ ```
195
+
196
+ ## 프로젝트 구조
197
+
198
+ 현재 공개 엔트리는 `src/index.ts`에 집중하고, 실제 구현은 내부 레이어로 분리되어 있습니다.
199
+
200
+ - `src/index.ts`: 라이브러리 바렐(export hub)
201
+ - `src/client/*`: 클라이언트 API 및 유틸
202
+ - `src/services/*`: 수집/파싱 오케스트레이션
203
+ - `src/repositories/*`: 사이트별 스크래퍼
204
+ - `src/parsers/*`: 파싱 전략
205
+ - `src/domain.ts`, `src/config.ts`, `src/errors.ts`: 도메인/설정/예외
206
+
207
+ ## 라이선스
208
+
209
+ GNU General Public License Version 3 (GPL-3.0) 입니다.
210
+ 라이선스 파일은 `LICENSE`를 확인하세요.