@striderlabs/mcp-buffalowildwings 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/README.md +125 -0
- package/dist/index.js +31143 -0
- package/package.json +43 -0
- package/server.json +20 -0
- package/src/index.ts +798 -0
- package/src/locations.ts +164 -0
- package/src/menu.ts +209 -0
- package/src/session.ts +84 -0
- package/tsconfig.json +14 -0
package/src/locations.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
export interface BWWLocation {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
address: string;
|
|
5
|
+
city: string;
|
|
6
|
+
state: string;
|
|
7
|
+
zip: string;
|
|
8
|
+
phone: string;
|
|
9
|
+
hours: {
|
|
10
|
+
monday: string;
|
|
11
|
+
tuesday: string;
|
|
12
|
+
wednesday: string;
|
|
13
|
+
thursday: string;
|
|
14
|
+
friday: string;
|
|
15
|
+
saturday: string;
|
|
16
|
+
sunday: string;
|
|
17
|
+
};
|
|
18
|
+
features: string[];
|
|
19
|
+
supportsPickup: boolean;
|
|
20
|
+
supportsDelivery: boolean;
|
|
21
|
+
supportsReservations: boolean;
|
|
22
|
+
waitTime?: string;
|
|
23
|
+
deliveryRadius?: number; // miles
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Representative locations — in production these would come from the BWW API
|
|
27
|
+
export const SAMPLE_LOCATIONS: BWWLocation[] = [
|
|
28
|
+
{
|
|
29
|
+
id: "bww-chicago-001",
|
|
30
|
+
name: "Buffalo Wild Wings - Chicago Downtown",
|
|
31
|
+
address: "100 W Randolph St",
|
|
32
|
+
city: "Chicago",
|
|
33
|
+
state: "IL",
|
|
34
|
+
zip: "60601",
|
|
35
|
+
phone: "(312) 555-0101",
|
|
36
|
+
hours: {
|
|
37
|
+
monday: "11:00 AM - 11:00 PM",
|
|
38
|
+
tuesday: "11:00 AM - 11:00 PM",
|
|
39
|
+
wednesday: "11:00 AM - 11:00 PM",
|
|
40
|
+
thursday: "11:00 AM - 12:00 AM",
|
|
41
|
+
friday: "11:00 AM - 1:00 AM",
|
|
42
|
+
saturday: "10:00 AM - 1:00 AM",
|
|
43
|
+
sunday: "10:00 AM - 11:00 PM",
|
|
44
|
+
},
|
|
45
|
+
features: ["Bar", "Game Day Specials", "Happy Hour", "Patio", "Full Bar"],
|
|
46
|
+
supportsPickup: true,
|
|
47
|
+
supportsDelivery: true,
|
|
48
|
+
supportsReservations: true,
|
|
49
|
+
waitTime: "15-20 min",
|
|
50
|
+
deliveryRadius: 3,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: "bww-chicago-002",
|
|
54
|
+
name: "Buffalo Wild Wings - Chicago Lincoln Park",
|
|
55
|
+
address: "1880 N Clybourn Ave",
|
|
56
|
+
city: "Chicago",
|
|
57
|
+
state: "IL",
|
|
58
|
+
zip: "60614",
|
|
59
|
+
phone: "(312) 555-0202",
|
|
60
|
+
hours: {
|
|
61
|
+
monday: "11:00 AM - 11:00 PM",
|
|
62
|
+
tuesday: "11:00 AM - 11:00 PM",
|
|
63
|
+
wednesday: "11:00 AM - 11:00 PM",
|
|
64
|
+
thursday: "11:00 AM - 12:00 AM",
|
|
65
|
+
friday: "11:00 AM - 1:00 AM",
|
|
66
|
+
saturday: "10:00 AM - 1:00 AM",
|
|
67
|
+
sunday: "10:00 AM - 11:00 PM",
|
|
68
|
+
},
|
|
69
|
+
features: ["Bar", "Game Day Specials", "Happy Hour", "Full Bar", "Private Events"],
|
|
70
|
+
supportsPickup: true,
|
|
71
|
+
supportsDelivery: true,
|
|
72
|
+
supportsReservations: false,
|
|
73
|
+
waitTime: "20-25 min",
|
|
74
|
+
deliveryRadius: 2.5,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: "bww-nyc-001",
|
|
78
|
+
name: "Buffalo Wild Wings - New York Times Square",
|
|
79
|
+
address: "256 W 40th St",
|
|
80
|
+
city: "New York",
|
|
81
|
+
state: "NY",
|
|
82
|
+
zip: "10018",
|
|
83
|
+
phone: "(212) 555-0303",
|
|
84
|
+
hours: {
|
|
85
|
+
monday: "11:00 AM - 12:00 AM",
|
|
86
|
+
tuesday: "11:00 AM - 12:00 AM",
|
|
87
|
+
wednesday: "11:00 AM - 12:00 AM",
|
|
88
|
+
thursday: "11:00 AM - 1:00 AM",
|
|
89
|
+
friday: "11:00 AM - 2:00 AM",
|
|
90
|
+
saturday: "10:00 AM - 2:00 AM",
|
|
91
|
+
sunday: "10:00 AM - 12:00 AM",
|
|
92
|
+
},
|
|
93
|
+
features: ["Bar", "Game Day Specials", "Happy Hour", "Full Bar", "Sports Lounge"],
|
|
94
|
+
supportsPickup: true,
|
|
95
|
+
supportsDelivery: true,
|
|
96
|
+
supportsReservations: true,
|
|
97
|
+
waitTime: "25-35 min",
|
|
98
|
+
deliveryRadius: 1.5,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: "bww-la-001",
|
|
102
|
+
name: "Buffalo Wild Wings - Los Angeles Hollywood",
|
|
103
|
+
address: "6801 Hollywood Blvd",
|
|
104
|
+
city: "Los Angeles",
|
|
105
|
+
state: "CA",
|
|
106
|
+
zip: "90028",
|
|
107
|
+
phone: "(323) 555-0404",
|
|
108
|
+
hours: {
|
|
109
|
+
monday: "11:00 AM - 11:00 PM",
|
|
110
|
+
tuesday: "11:00 AM - 11:00 PM",
|
|
111
|
+
wednesday: "11:00 AM - 11:00 PM",
|
|
112
|
+
thursday: "11:00 AM - 12:00 AM",
|
|
113
|
+
friday: "11:00 AM - 1:00 AM",
|
|
114
|
+
saturday: "10:00 AM - 1:00 AM",
|
|
115
|
+
sunday: "10:00 AM - 11:00 PM",
|
|
116
|
+
},
|
|
117
|
+
features: ["Bar", "Game Day Specials", "Happy Hour", "Patio", "Full Bar"],
|
|
118
|
+
supportsPickup: true,
|
|
119
|
+
supportsDelivery: true,
|
|
120
|
+
supportsReservations: true,
|
|
121
|
+
waitTime: "10-15 min",
|
|
122
|
+
deliveryRadius: 4,
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: "bww-houston-001",
|
|
126
|
+
name: "Buffalo Wild Wings - Houston Galleria",
|
|
127
|
+
address: "5015 Westheimer Rd",
|
|
128
|
+
city: "Houston",
|
|
129
|
+
state: "TX",
|
|
130
|
+
zip: "77056",
|
|
131
|
+
phone: "(713) 555-0505",
|
|
132
|
+
hours: {
|
|
133
|
+
monday: "11:00 AM - 11:00 PM",
|
|
134
|
+
tuesday: "11:00 AM - 11:00 PM",
|
|
135
|
+
wednesday: "11:00 AM - 11:00 PM",
|
|
136
|
+
thursday: "11:00 AM - 12:00 AM",
|
|
137
|
+
friday: "11:00 AM - 1:00 AM",
|
|
138
|
+
saturday: "10:00 AM - 1:00 AM",
|
|
139
|
+
sunday: "10:00 AM - 11:00 PM",
|
|
140
|
+
},
|
|
141
|
+
features: ["Bar", "Game Day Specials", "Happy Hour", "Patio", "Full Bar", "Private Events"],
|
|
142
|
+
supportsPickup: true,
|
|
143
|
+
supportsDelivery: true,
|
|
144
|
+
supportsReservations: true,
|
|
145
|
+
waitTime: "5-10 min",
|
|
146
|
+
deliveryRadius: 5,
|
|
147
|
+
},
|
|
148
|
+
];
|
|
149
|
+
|
|
150
|
+
export function searchLocations(query: string): BWWLocation[] {
|
|
151
|
+
const q = query.toLowerCase();
|
|
152
|
+
return SAMPLE_LOCATIONS.filter(
|
|
153
|
+
loc =>
|
|
154
|
+
loc.city.toLowerCase().includes(q) ||
|
|
155
|
+
loc.state.toLowerCase().includes(q) ||
|
|
156
|
+
loc.zip.includes(q) ||
|
|
157
|
+
loc.address.toLowerCase().includes(q) ||
|
|
158
|
+
loc.name.toLowerCase().includes(q)
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function getLocationById(id: string): BWWLocation | undefined {
|
|
163
|
+
return SAMPLE_LOCATIONS.find(loc => loc.id === id);
|
|
164
|
+
}
|
package/src/menu.ts
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
export interface WingFlavor {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
heatLevel: number; // 1-5
|
|
5
|
+
description: string;
|
|
6
|
+
isNew?: boolean;
|
|
7
|
+
isLimitedTime?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface MenuItem {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
category: string;
|
|
14
|
+
description: string;
|
|
15
|
+
basePrice: number;
|
|
16
|
+
options?: MenuItemOption[];
|
|
17
|
+
calories?: string;
|
|
18
|
+
isPopular?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface MenuItemOption {
|
|
22
|
+
name: string;
|
|
23
|
+
choices: { label: string; priceDelta?: number }[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const WING_FLAVORS: WingFlavor[] = [
|
|
27
|
+
{ id: "blazin", name: "Blazin'", heatLevel: 5, description: "Our hottest sauce — pure scorching heat for the boldest challengers." },
|
|
28
|
+
{ id: "mango-habanero", name: "Mango Habanero", heatLevel: 4, description: "Sweet mango heat with a fiery habanero finish." },
|
|
29
|
+
{ id: "spicy-garlic", name: "Spicy Garlic", heatLevel: 3, description: "Savory garlic with a medium spicy kick." },
|
|
30
|
+
{ id: "hot", name: "Hot", heatLevel: 3, description: "Classic buffalo-style hot sauce, a BWW staple." },
|
|
31
|
+
{ id: "medium", name: "Medium", heatLevel: 2, description: "A balanced blend of heat and flavor — the crowd-pleaser." },
|
|
32
|
+
{ id: "mild", name: "Mild", heatLevel: 1, description: "Light heat, full flavor. Great for sauce first-timers." },
|
|
33
|
+
{ id: "parmesan-garlic", name: "Parmesan Garlic", heatLevel: 1, description: "Rich, buttery parmesan with roasted garlic." },
|
|
34
|
+
{ id: "asian-zing", name: "Asian Zing", heatLevel: 2, description: "Sweet chili heat with Asian-inspired flavors." },
|
|
35
|
+
{ id: "honey-bbq", name: "Honey BBQ", heatLevel: 1, description: "Smoky, sweet BBQ with a touch of honey." },
|
|
36
|
+
{ id: "lemon-pepper", name: "Lemon Pepper", heatLevel: 1, description: "Bright citrus and bold pepper — fan favorite dry rub." },
|
|
37
|
+
{ id: "desert-heat", name: "Desert Heat", heatLevel: 2, description: "Southwestern-inspired heat with smoky undertones." },
|
|
38
|
+
{ id: "nashville-hot", name: "Nashville Hot", heatLevel: 4, description: "Southern-style cayenne heat inspired by Nashville tradition." },
|
|
39
|
+
{ id: "teriyaki", name: "Teriyaki", heatLevel: 1, description: "Sweet, savory Japanese-inspired glaze." },
|
|
40
|
+
{ id: "caribbean-jerk", name: "Caribbean Jerk", heatLevel: 3, description: "Allspice, thyme, and island heat." },
|
|
41
|
+
{ id: "jammin-jalapeno", name: "Jammin' Jalapeño", heatLevel: 3, description: "Jalapeño-forward with a fruity sweetness.", isNew: true },
|
|
42
|
+
{ id: "blazin-carolina-reaper", name: "Blazin' Carolina Reaper", heatLevel: 5, description: "Extreme heat with Carolina Reaper peppers. Spiciest on the menu.", isLimitedTime: true },
|
|
43
|
+
{ id: "garlic-parmesan", name: "Garlic Parmesan", heatLevel: 1, description: "Bold garlic, sharp parmesan — a classic boneless favorite." },
|
|
44
|
+
{ id: "sweet-bbq", name: "Sweet BBQ", heatLevel: 1, description: "Tangy and sweet, pure comfort BBQ flavor." },
|
|
45
|
+
{ id: "buffalo", name: "Buffalo", heatLevel: 2, description: "The original. Tangy vinegar-based buffalo sauce." },
|
|
46
|
+
{ id: "smoky-cheddar-bbq", name: "Smoky Cheddar BBQ", heatLevel: 1, description: "Creamy cheddar smoke married with classic BBQ.", isNew: true },
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
export const MENU_ITEMS: MenuItem[] = [
|
|
50
|
+
// Wings
|
|
51
|
+
{
|
|
52
|
+
id: "traditional-wings-6",
|
|
53
|
+
name: "Traditional Wings (6 ct)",
|
|
54
|
+
category: "Wings",
|
|
55
|
+
description: "Classic bone-in wings with your choice of sauce or dry rub.",
|
|
56
|
+
basePrice: 10.99,
|
|
57
|
+
options: [
|
|
58
|
+
{ name: "Sauce/Rub", choices: WING_FLAVORS.map(f => ({ label: f.name })) },
|
|
59
|
+
{ name: "Dipping Sauce", choices: [{ label: "Ranch" }, { label: "Bleu Cheese" }, { label: "Honey Mustard" }] }
|
|
60
|
+
],
|
|
61
|
+
calories: "430-900",
|
|
62
|
+
isPopular: true,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "traditional-wings-12",
|
|
66
|
+
name: "Traditional Wings (12 ct)",
|
|
67
|
+
category: "Wings",
|
|
68
|
+
description: "A dozen bone-in wings. Go all-in.",
|
|
69
|
+
basePrice: 19.99,
|
|
70
|
+
options: [
|
|
71
|
+
{ name: "Sauce/Rub", choices: WING_FLAVORS.map(f => ({ label: f.name })) },
|
|
72
|
+
{ name: "Dipping Sauce", choices: [{ label: "Ranch" }, { label: "Bleu Cheese" }, { label: "Honey Mustard" }] }
|
|
73
|
+
],
|
|
74
|
+
calories: "860-1800",
|
|
75
|
+
isPopular: true,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: "traditional-wings-18",
|
|
79
|
+
name: "Traditional Wings (18 ct)",
|
|
80
|
+
category: "Wings",
|
|
81
|
+
description: "18 bone-in wings — perfect for sharing or going solo champion-style.",
|
|
82
|
+
basePrice: 28.99,
|
|
83
|
+
options: [
|
|
84
|
+
{ name: "Sauce/Rub", choices: WING_FLAVORS.map(f => ({ label: f.name })) },
|
|
85
|
+
{ name: "Dipping Sauce", choices: [{ label: "Ranch" }, { label: "Bleu Cheese" }, { label: "Honey Mustard" }] }
|
|
86
|
+
],
|
|
87
|
+
calories: "1290-2700",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: "boneless-wings-6",
|
|
91
|
+
name: "Boneless Wings (6 ct)",
|
|
92
|
+
category: "Wings",
|
|
93
|
+
description: "Crispy all-white-meat boneless wings with your choice of sauce.",
|
|
94
|
+
basePrice: 9.99,
|
|
95
|
+
options: [
|
|
96
|
+
{ name: "Sauce/Rub", choices: WING_FLAVORS.map(f => ({ label: f.name })) },
|
|
97
|
+
{ name: "Dipping Sauce", choices: [{ label: "Ranch" }, { label: "Bleu Cheese" }, { label: "Honey Mustard" }] }
|
|
98
|
+
],
|
|
99
|
+
calories: "310-750",
|
|
100
|
+
isPopular: true,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
id: "boneless-wings-12",
|
|
104
|
+
name: "Boneless Wings (12 ct)",
|
|
105
|
+
category: "Wings",
|
|
106
|
+
description: "A dozen boneless wings for maximum flavor flexibility.",
|
|
107
|
+
basePrice: 17.99,
|
|
108
|
+
options: [
|
|
109
|
+
{ name: "Sauce/Rub", choices: WING_FLAVORS.map(f => ({ label: f.name })) },
|
|
110
|
+
{ name: "Dipping Sauce", choices: [{ label: "Ranch" }, { label: "Bleu Cheese" }, { label: "Honey Mustard" }] }
|
|
111
|
+
],
|
|
112
|
+
calories: "620-1500",
|
|
113
|
+
},
|
|
114
|
+
// Shareables
|
|
115
|
+
{
|
|
116
|
+
id: "loaded-tater-tots",
|
|
117
|
+
name: "Loaded Tater Tots",
|
|
118
|
+
category: "Shareables",
|
|
119
|
+
description: "Crispy tots loaded with cheddar, bacon, and sour cream.",
|
|
120
|
+
basePrice: 10.49,
|
|
121
|
+
calories: "1080",
|
|
122
|
+
isPopular: true,
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: "buffalo-chips-queso",
|
|
126
|
+
name: "Buffalo Chips & Queso",
|
|
127
|
+
category: "Shareables",
|
|
128
|
+
description: "Thick-cut kettle chips with warm queso and pico.",
|
|
129
|
+
basePrice: 9.49,
|
|
130
|
+
calories: "940",
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
id: "spinach-artichoke-dip",
|
|
134
|
+
name: "Spinach Artichoke Dip",
|
|
135
|
+
category: "Shareables",
|
|
136
|
+
description: "Warm, creamy dip with chips and pita.",
|
|
137
|
+
basePrice: 11.49,
|
|
138
|
+
calories: "820",
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
id: "mozzarella-sticks",
|
|
142
|
+
name: "Mozzarella Sticks",
|
|
143
|
+
category: "Shareables",
|
|
144
|
+
description: "Gooey mozzarella in a crispy breading, served with marinara.",
|
|
145
|
+
basePrice: 9.99,
|
|
146
|
+
calories: "750",
|
|
147
|
+
},
|
|
148
|
+
// Burgers & Sandwiches
|
|
149
|
+
{
|
|
150
|
+
id: "buffalo-ranch-chicken-sandwich",
|
|
151
|
+
name: "Buffalo Ranch Chicken Sandwich",
|
|
152
|
+
category: "Burgers & Sandwiches",
|
|
153
|
+
description: "Crispy chicken with Buffalo sauce and ranch on a brioche bun.",
|
|
154
|
+
basePrice: 13.99,
|
|
155
|
+
calories: "860",
|
|
156
|
+
isPopular: true,
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
id: "classic-burger",
|
|
160
|
+
name: "Classic Burger",
|
|
161
|
+
category: "Burgers & Sandwiches",
|
|
162
|
+
description: "Juicy beef patty with lettuce, tomato, onion, and pickles.",
|
|
163
|
+
basePrice: 12.99,
|
|
164
|
+
calories: "780",
|
|
165
|
+
},
|
|
166
|
+
// Salads
|
|
167
|
+
{
|
|
168
|
+
id: "grilled-chicken-salad",
|
|
169
|
+
name: "Grilled Chicken Salad",
|
|
170
|
+
category: "Salads",
|
|
171
|
+
description: "Grilled chicken over mixed greens with house dressing.",
|
|
172
|
+
basePrice: 13.49,
|
|
173
|
+
calories: "340-680",
|
|
174
|
+
},
|
|
175
|
+
// Desserts
|
|
176
|
+
{
|
|
177
|
+
id: "chocolate-fudge-cake",
|
|
178
|
+
name: "Chocolate Fudge Cake",
|
|
179
|
+
category: "Desserts",
|
|
180
|
+
description: "Warm, rich chocolate cake with vanilla ice cream.",
|
|
181
|
+
basePrice: 7.99,
|
|
182
|
+
calories: "1080",
|
|
183
|
+
},
|
|
184
|
+
// Drinks
|
|
185
|
+
{
|
|
186
|
+
id: "soft-drink",
|
|
187
|
+
name: "Fountain Drink",
|
|
188
|
+
category: "Drinks",
|
|
189
|
+
description: "Pepsi, Mountain Dew, Starry, and more.",
|
|
190
|
+
basePrice: 3.49,
|
|
191
|
+
options: [
|
|
192
|
+
{ name: "Size", choices: [{ label: "Regular" }, { label: "Large", priceDelta: 0.5 }] }
|
|
193
|
+
],
|
|
194
|
+
calories: "0-360",
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
id: "draft-beer",
|
|
198
|
+
name: "Draft Beer",
|
|
199
|
+
category: "Drinks",
|
|
200
|
+
description: "Rotating selection of domestic and craft drafts.",
|
|
201
|
+
basePrice: 5.99,
|
|
202
|
+
options: [
|
|
203
|
+
{ name: "Size", choices: [{ label: "Pint" }, { label: "Pitcher", priceDelta: 8.0 }] }
|
|
204
|
+
],
|
|
205
|
+
calories: "150-250",
|
|
206
|
+
},
|
|
207
|
+
];
|
|
208
|
+
|
|
209
|
+
export const CATEGORIES = [...new Set(MENU_ITEMS.map(i => i.category))];
|
package/src/session.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import os from "os";
|
|
4
|
+
|
|
5
|
+
export interface CartItem {
|
|
6
|
+
itemId: string;
|
|
7
|
+
name: string;
|
|
8
|
+
quantity: number;
|
|
9
|
+
unitPrice: number;
|
|
10
|
+
sauce?: string;
|
|
11
|
+
notes?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface SessionData {
|
|
15
|
+
locationId?: string;
|
|
16
|
+
locationName?: string;
|
|
17
|
+
orderType?: "pickup" | "delivery";
|
|
18
|
+
deliveryAddress?: string;
|
|
19
|
+
cart: CartItem[];
|
|
20
|
+
rewardsPhone?: string;
|
|
21
|
+
rewardsMemberId?: string;
|
|
22
|
+
rewardsPoints?: number;
|
|
23
|
+
orderId?: string;
|
|
24
|
+
orderStatus?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const CONFIG_DIR = path.join(os.homedir(), ".strider", "buffalowildwings");
|
|
28
|
+
const SESSION_FILE = path.join(CONFIG_DIR, "session.json");
|
|
29
|
+
|
|
30
|
+
function ensureDir(): void {
|
|
31
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
32
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function loadSession(): SessionData {
|
|
37
|
+
try {
|
|
38
|
+
ensureDir();
|
|
39
|
+
if (fs.existsSync(SESSION_FILE)) {
|
|
40
|
+
const raw = fs.readFileSync(SESSION_FILE, "utf-8");
|
|
41
|
+
return JSON.parse(raw) as SessionData;
|
|
42
|
+
}
|
|
43
|
+
} catch {
|
|
44
|
+
// ignore
|
|
45
|
+
}
|
|
46
|
+
return { cart: [] };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function saveSession(data: SessionData): void {
|
|
50
|
+
ensureDir();
|
|
51
|
+
fs.writeFileSync(SESSION_FILE, JSON.stringify(data, null, 2), "utf-8");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function clearSession(): void {
|
|
55
|
+
if (fs.existsSync(SESSION_FILE)) {
|
|
56
|
+
fs.unlinkSync(SESSION_FILE);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function getConfigDir(): string {
|
|
61
|
+
return CONFIG_DIR;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// In-memory session for the process lifetime (supplemented by disk persistence)
|
|
65
|
+
let _session: SessionData | null = null;
|
|
66
|
+
|
|
67
|
+
export function getSession(): SessionData {
|
|
68
|
+
if (!_session) {
|
|
69
|
+
_session = loadSession();
|
|
70
|
+
}
|
|
71
|
+
return _session;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function updateSession(updates: Partial<SessionData>): SessionData {
|
|
75
|
+
const session = getSession();
|
|
76
|
+
_session = { ...session, ...updates };
|
|
77
|
+
saveSession(_session);
|
|
78
|
+
return _session;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function resetSession(): void {
|
|
82
|
+
_session = { cart: [] };
|
|
83
|
+
clearSession();
|
|
84
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"declaration": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*"]
|
|
14
|
+
}
|