@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 +46 -0
- package/README.md +210 -0
- package/dist/index.cjs +953 -0
- package/dist/index.d.mts +92 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.mjs +907 -0
- package/package.json +69 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
declare enum CafeteriaType {
|
|
2
|
+
HAKSIK = "HAKSIK",
|
|
3
|
+
DODAM = "DODAM",
|
|
4
|
+
FACULTY = "FACULTY",
|
|
5
|
+
DORMITORY = "DORMITORY"
|
|
6
|
+
}
|
|
7
|
+
declare const CafeteriaStatus: {
|
|
8
|
+
readonly Open: "open";
|
|
9
|
+
readonly Closed: "closed";
|
|
10
|
+
};
|
|
11
|
+
type CafeteriaStatus = (typeof CafeteriaStatus)[keyof typeof CafeteriaStatus];
|
|
12
|
+
interface RawMenuData {
|
|
13
|
+
date: string;
|
|
14
|
+
cafeteria: CafeteriaType;
|
|
15
|
+
menuTexts: Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
type MenuMap = Record<string, string[]>;
|
|
18
|
+
interface DailyMenu {
|
|
19
|
+
date: string;
|
|
20
|
+
cafeteria: CafeteriaType;
|
|
21
|
+
status: CafeteriaStatus;
|
|
22
|
+
breakfast: MenuMap;
|
|
23
|
+
lunch: MenuMap;
|
|
24
|
+
dinner: MenuMap;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface FoodCrawlerSettings {
|
|
28
|
+
soongguriBaseUrl: string;
|
|
29
|
+
dormitoryBaseUrl: string;
|
|
30
|
+
haksikRcd: number;
|
|
31
|
+
dodamRcd: number;
|
|
32
|
+
facultyRcd: number;
|
|
33
|
+
timeoutMs: number;
|
|
34
|
+
}
|
|
35
|
+
declare const defaultSettings: FoodCrawlerSettings;
|
|
36
|
+
|
|
37
|
+
interface MenuScraper {
|
|
38
|
+
scrapeMenu(date: string): Promise<RawMenuData>;
|
|
39
|
+
}
|
|
40
|
+
interface MenuParser {
|
|
41
|
+
parseMenu(raw: RawMenuData): Promise<DailyMenu>;
|
|
42
|
+
}
|
|
43
|
+
interface CrawlerOptions {
|
|
44
|
+
cafeteria: CafeteriaType;
|
|
45
|
+
date: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type MenuDateInput = string | Date;
|
|
49
|
+
type MenuDate = string;
|
|
50
|
+
type ParserMode = "noop" | "gpt" | "custom";
|
|
51
|
+
interface MealClientOptions {
|
|
52
|
+
settings?: Partial<FoodCrawlerSettings>;
|
|
53
|
+
parser?: ParserMode;
|
|
54
|
+
gptApiKey?: string;
|
|
55
|
+
parserImpl?: MenuParser;
|
|
56
|
+
}
|
|
57
|
+
interface RangeOptions {
|
|
58
|
+
startInclusive?: boolean;
|
|
59
|
+
concurrency?: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
declare class MealClient {
|
|
63
|
+
private readonly service;
|
|
64
|
+
constructor(options?: MealClientOptions);
|
|
65
|
+
getRawMenu(cafeteria: CafeteriaType, date: MenuDateInput): Promise<RawMenuData>;
|
|
66
|
+
getDailyMenu(cafeteria: CafeteriaType, date: MenuDateInput): Promise<DailyMenu>;
|
|
67
|
+
getRawMenus(cafeteria: CafeteriaType, dates: MenuDateInput[], options?: RangeOptions): Promise<RawMenuData[]>;
|
|
68
|
+
getDailyMenus(cafeteria: CafeteriaType, dates: MenuDateInput[], options?: RangeOptions): Promise<DailyMenu[]>;
|
|
69
|
+
getRawMenusByRange(cafeteria: CafeteriaType, start: MenuDateInput, end: MenuDateInput, options?: RangeOptions): Promise<RawMenuData[]>;
|
|
70
|
+
getDailyMenusByRange(cafeteria: CafeteriaType, start: MenuDateInput, end: MenuDateInput, options?: RangeOptions): Promise<DailyMenu[]>;
|
|
71
|
+
}
|
|
72
|
+
declare const createMealClient: (options?: MealClientOptions) => MealClient;
|
|
73
|
+
|
|
74
|
+
declare const normalizeMenuDate: (input: MenuDateInput) => MenuDate;
|
|
75
|
+
declare const buildDateRange: (start: MenuDate, end: MenuDate) => MenuDate[];
|
|
76
|
+
|
|
77
|
+
type ErrorMetadata = Record<string, unknown>;
|
|
78
|
+
declare class BaseCafeteriaException extends Error {
|
|
79
|
+
readonly targetDate: string;
|
|
80
|
+
readonly cafeteria: string;
|
|
81
|
+
readonly rawData?: unknown | undefined;
|
|
82
|
+
context: ErrorMetadata;
|
|
83
|
+
constructor(targetDate: string, cafeteria: string, message: string, rawData?: unknown | undefined, context?: ErrorMetadata);
|
|
84
|
+
}
|
|
85
|
+
declare class HolidayException extends BaseCafeteriaException {
|
|
86
|
+
}
|
|
87
|
+
declare class MenuFetchException extends BaseCafeteriaException {
|
|
88
|
+
}
|
|
89
|
+
declare class MenuParseException extends BaseCafeteriaException {
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { BaseCafeteriaException, CafeteriaType, type CrawlerOptions, type DailyMenu, type FoodCrawlerSettings, HolidayException, MealClient, type MealClientOptions, type MenuDate, type MenuDateInput, MenuFetchException, MenuParseException, type MenuParser, type MenuScraper, type ParserMode, type RangeOptions, type RawMenuData, buildDateRange, createMealClient, defaultSettings, normalizeMenuDate };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
declare enum CafeteriaType {
|
|
2
|
+
HAKSIK = "HAKSIK",
|
|
3
|
+
DODAM = "DODAM",
|
|
4
|
+
FACULTY = "FACULTY",
|
|
5
|
+
DORMITORY = "DORMITORY"
|
|
6
|
+
}
|
|
7
|
+
declare const CafeteriaStatus: {
|
|
8
|
+
readonly Open: "open";
|
|
9
|
+
readonly Closed: "closed";
|
|
10
|
+
};
|
|
11
|
+
type CafeteriaStatus = (typeof CafeteriaStatus)[keyof typeof CafeteriaStatus];
|
|
12
|
+
interface RawMenuData {
|
|
13
|
+
date: string;
|
|
14
|
+
cafeteria: CafeteriaType;
|
|
15
|
+
menuTexts: Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
type MenuMap = Record<string, string[]>;
|
|
18
|
+
interface DailyMenu {
|
|
19
|
+
date: string;
|
|
20
|
+
cafeteria: CafeteriaType;
|
|
21
|
+
status: CafeteriaStatus;
|
|
22
|
+
breakfast: MenuMap;
|
|
23
|
+
lunch: MenuMap;
|
|
24
|
+
dinner: MenuMap;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface FoodCrawlerSettings {
|
|
28
|
+
soongguriBaseUrl: string;
|
|
29
|
+
dormitoryBaseUrl: string;
|
|
30
|
+
haksikRcd: number;
|
|
31
|
+
dodamRcd: number;
|
|
32
|
+
facultyRcd: number;
|
|
33
|
+
timeoutMs: number;
|
|
34
|
+
}
|
|
35
|
+
declare const defaultSettings: FoodCrawlerSettings;
|
|
36
|
+
|
|
37
|
+
interface MenuScraper {
|
|
38
|
+
scrapeMenu(date: string): Promise<RawMenuData>;
|
|
39
|
+
}
|
|
40
|
+
interface MenuParser {
|
|
41
|
+
parseMenu(raw: RawMenuData): Promise<DailyMenu>;
|
|
42
|
+
}
|
|
43
|
+
interface CrawlerOptions {
|
|
44
|
+
cafeteria: CafeteriaType;
|
|
45
|
+
date: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type MenuDateInput = string | Date;
|
|
49
|
+
type MenuDate = string;
|
|
50
|
+
type ParserMode = "noop" | "gpt" | "custom";
|
|
51
|
+
interface MealClientOptions {
|
|
52
|
+
settings?: Partial<FoodCrawlerSettings>;
|
|
53
|
+
parser?: ParserMode;
|
|
54
|
+
gptApiKey?: string;
|
|
55
|
+
parserImpl?: MenuParser;
|
|
56
|
+
}
|
|
57
|
+
interface RangeOptions {
|
|
58
|
+
startInclusive?: boolean;
|
|
59
|
+
concurrency?: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
declare class MealClient {
|
|
63
|
+
private readonly service;
|
|
64
|
+
constructor(options?: MealClientOptions);
|
|
65
|
+
getRawMenu(cafeteria: CafeteriaType, date: MenuDateInput): Promise<RawMenuData>;
|
|
66
|
+
getDailyMenu(cafeteria: CafeteriaType, date: MenuDateInput): Promise<DailyMenu>;
|
|
67
|
+
getRawMenus(cafeteria: CafeteriaType, dates: MenuDateInput[], options?: RangeOptions): Promise<RawMenuData[]>;
|
|
68
|
+
getDailyMenus(cafeteria: CafeteriaType, dates: MenuDateInput[], options?: RangeOptions): Promise<DailyMenu[]>;
|
|
69
|
+
getRawMenusByRange(cafeteria: CafeteriaType, start: MenuDateInput, end: MenuDateInput, options?: RangeOptions): Promise<RawMenuData[]>;
|
|
70
|
+
getDailyMenusByRange(cafeteria: CafeteriaType, start: MenuDateInput, end: MenuDateInput, options?: RangeOptions): Promise<DailyMenu[]>;
|
|
71
|
+
}
|
|
72
|
+
declare const createMealClient: (options?: MealClientOptions) => MealClient;
|
|
73
|
+
|
|
74
|
+
declare const normalizeMenuDate: (input: MenuDateInput) => MenuDate;
|
|
75
|
+
declare const buildDateRange: (start: MenuDate, end: MenuDate) => MenuDate[];
|
|
76
|
+
|
|
77
|
+
type ErrorMetadata = Record<string, unknown>;
|
|
78
|
+
declare class BaseCafeteriaException extends Error {
|
|
79
|
+
readonly targetDate: string;
|
|
80
|
+
readonly cafeteria: string;
|
|
81
|
+
readonly rawData?: unknown | undefined;
|
|
82
|
+
context: ErrorMetadata;
|
|
83
|
+
constructor(targetDate: string, cafeteria: string, message: string, rawData?: unknown | undefined, context?: ErrorMetadata);
|
|
84
|
+
}
|
|
85
|
+
declare class HolidayException extends BaseCafeteriaException {
|
|
86
|
+
}
|
|
87
|
+
declare class MenuFetchException extends BaseCafeteriaException {
|
|
88
|
+
}
|
|
89
|
+
declare class MenuParseException extends BaseCafeteriaException {
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { BaseCafeteriaException, CafeteriaType, type CrawlerOptions, type DailyMenu, type FoodCrawlerSettings, HolidayException, MealClient, type MealClientOptions, type MenuDate, type MenuDateInput, MenuFetchException, MenuParseException, type MenuParser, type MenuScraper, type ParserMode, type RangeOptions, type RawMenuData, buildDateRange, createMealClient, defaultSettings, normalizeMenuDate };
|