Repository navigation
Expand file tree
/
Copy pathindex.ts
More file actions
88 lines (82 loc) · 3.33 KB
/
Copy pathindex.ts
File metadata and controls
88 lines (82 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import { Worker, j } from "@notionhq/workers";
import type {
CurrentOrderForDateInput,
CurrentOrderForDateResult,
DayMealsResult,
OrderMealInput,
OrderMealResult,
} from "./forkable.js";
import { ForkableClient } from "./forkable.js";
const worker = new Worker();
export default worker;
function getClient(): ForkableClient {
const sessionCookie = process.env.FORKABLE_SESSION_COOKIE;
if (!sessionCookie) {
throw new Error("FORKABLE_SESSION_COOKIE environment variable is required");
}
return new ForkableClient(sessionCookie);
}
type GetRestaurantsAndMealsInput = {
date: string;
[key: string]: string;
};
worker.tool<GetRestaurantsAndMealsInput, DayMealsResult>("getRestaurantsAndMealsForDate", {
title: "Get Restaurants And Meals For Date",
description:
"Returns every available Forkable restaurant and orderable meal for a specific date (YYYY-MM-DD), grouped by delivery location. Use the returned mealId and menuId for exact ordering.",
schema: j.object({
date: j.string().describe("The delivery date to inspect in YYYY-MM-DD format."),
}),
execute: async ({ date }) => {
return getClient().getRestaurantsAndMealsForDate(date);
},
});
worker.tool<CurrentOrderForDateInput, CurrentOrderForDateResult>("getCurrentOrderForDate", {
title: "Get Current Order For Date",
description:
"Returns your current Forkable order for a specific date, grouped by delivery location. Use locationId or locationName to narrow it to one office when needed.",
schema: j.object({
date: j.string().describe("The delivery date to inspect in YYYY-MM-DD format."),
locationId: j.number().nullable().describe("Optional Forkable location/meal club ID filter."),
locationName: j
.string()
.nullable()
.describe("Optional delivery location name filter, such as 'Notion - NY'."),
}),
execute: async (input) => {
return getClient().getCurrentOrderForDate(input);
},
});
worker.tool<OrderMealInput, OrderMealResult>("orderMealForDate", {
title: "Order Meal For Date",
description:
"Orders or replaces a Forkable meal for a specific date. Prefer passing exact mealId + menuId from getRestaurantsAndMealsForDate. mealName search is also supported, and location or restaurant filters can disambiguate.",
schema: j.object({
date: j.string().describe("The delivery date to order for in YYYY-MM-DD format."),
mealName: j
.string()
.nullable()
.describe("Meal name search string. Use this or exact mealId + menuId."),
mealId: j.number().nullable().describe("Exact Forkable meal item ID."),
menuId: j.number().nullable().describe("Exact Forkable menu ID for the selected meal."),
restaurantName: j.string().nullable().describe("Optional restaurant name filter."),
locationId: j.number().nullable().describe("Optional Forkable location/meal club ID filter."),
locationName: j
.string()
.nullable()
.describe("Optional delivery location name filter, such as 'Notion - NY'."),
instructions: j.string().nullable().describe("Optional special instructions for the order."),
selections: j
.array(
j.object({
modifier: j.string().describe("Modifier name, such as 'Choose Side'."),
option: j.string().describe("Chosen option for that modifier."),
}),
)
.nullable()
.describe("Optional modifier selections to apply to the ordered meal."),
}),
execute: async (input) => {
return getClient().orderMealForDate(input);
},
});