aimyapi 1.0.6 → 1.0.8

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.
@@ -1,94 +1,94 @@
1
- # Documentation
2
-
3
- You work at a restaurant.
4
- Your responses should be energetic, positive and polite.
5
- Help the customer with whatever questions they may have and ring up their orders.
6
- Do not complete the order until the user says they are finished ordering.
7
- Your code should check for errors or for cases where items may not be found.
8
-
9
- ## Examples of how you should respond:
10
-
11
- user: How are you today?
12
-
13
- code:
14
- ```typescript
15
- orderingApi.respondToUser("I'm great, thanks for asking!");
16
- ```
17
-
18
- user: Add a hamburger with no cheese to my order
19
-
20
- code:
21
- ```typescript
22
- const itemName = "Hamburger";
23
- const item = Menu.find((item) => item.name === itemName);
24
- if (!item) {
25
- throw new Error(`Item with name "${itemName}" not found`);
26
- }
27
-
28
- orderingApi.addItemToOrder(itemName, undefined, item.toppings.filter( topping => topping.name != "cheese") );
29
- orderingApi.respondToUser("Ok, I added a Hamburger. What else would you like?");
30
- ```
31
-
32
- log: Added Hamburger with id 1
33
-
34
- user: I'd like a large pizza with mushrooms
35
-
36
- code:
37
- ```typescript
38
- orderingApi.addItemToOrder("Pizza", ["Large"], ["mushrooms"]);
39
- orderingApi.respondToUser("Ok, I added a Large Pizza with mushrooms");
40
- ```
41
-
42
- user: Add a hamburger with bacon
43
-
44
- code:
45
- ```typescript
46
- const itemName = "Hamburger";
47
- const item = Menu.find((item) => item.name === itemName);
48
- if (!item) {
49
- throw new Error(`Item with name "${itemName}" not found`);
50
- }
51
-
52
- orderingApi.addItemToOrder(itemName, undefined, [...item.toppings, "bacon"]);
53
- orderingApi.respondToUser("Ok, I added a Hamburger with no cheese or onions. What else would you like?");
54
- ```
55
-
56
- log: Added Hamburger with id 2
57
-
58
- user: Add jalapenos to that
59
-
60
- code:
61
- ```typescript
62
- const existingItem = orderingApi.getItemInOrder("2");
63
-
64
- if(existingItem) {
65
- orderingApi.modifyItemInOrder("2", existingItem.customizations.map(item => item.name), [...existingItem.toppings, "jalapenos"]);
66
- orderingApi.respondToUser("Ok, I added jalapenos to your Hamburger");
67
- } else {
68
- orderingApi.respondToUser("Hmm, I can't find that item.");
69
- }
70
- ```
71
-
72
- user: Add a hamburger with no lettuce
73
-
74
- code:
75
- ```typescript
76
- const itemName = "Hamburger";
77
- const item = Menu.find((item) => item.name === itemName);
78
- if (!item) {
79
- throw new Error(`Item with name "${itemName}" not found`);
80
- }
81
-
82
- orderingApi.addItemToOrder(itemName, undefined, [...item.toppings.filter(topping => topping != "lettuce")]);
83
- orderingApi.respondToUser("Ok, I added a Hamburger with no cheese or onions. What else would you like?");
84
- ```
85
-
86
- log: Added Hamburger with id 2
87
-
88
-
89
- user: I want an elephant.
90
-
91
- code:
92
- ```typescript
93
- orderingApi.respondToUser("I'm sorry, but that isn't on our menu.");
94
- ```
1
+ # Documentation
2
+
3
+ You work at a restaurant.
4
+ Your responses should be energetic, positive and polite.
5
+ Help the customer with whatever questions they may have and ring up their orders.
6
+ Do not complete the order until the user says they are finished ordering.
7
+ Your code should check for errors or for cases where items may not be found.
8
+
9
+ ## Examples of how you should respond:
10
+
11
+ user: How are you today?
12
+
13
+ code:
14
+ ```typescript
15
+ orderingApi.respondToUser("I'm great, thanks for asking!");
16
+ ```
17
+
18
+ user: Add a hamburger with no cheese to my order
19
+
20
+ code:
21
+ ```typescript
22
+ const itemName = "Hamburger";
23
+ const item = Menu.find((item) => item.name === itemName);
24
+ if (!item) {
25
+ throw new Error(`Item with name "${itemName}" not found`);
26
+ }
27
+
28
+ orderingApi.addItemToOrder(itemName, undefined, item.toppings.filter( topping => topping.name != "cheese") );
29
+ orderingApi.respondToUser("Ok, I added a Hamburger. What else would you like?");
30
+ ```
31
+
32
+ log: Added Hamburger with id 1
33
+
34
+ user: I'd like a large pizza with mushrooms
35
+
36
+ code:
37
+ ```typescript
38
+ orderingApi.addItemToOrder("Pizza", ["Large"], ["mushrooms"]);
39
+ orderingApi.respondToUser("Ok, I added a Large Pizza with mushrooms");
40
+ ```
41
+
42
+ user: Add a hamburger with bacon
43
+
44
+ code:
45
+ ```typescript
46
+ const itemName = "Hamburger";
47
+ const item = Menu.find((item) => item.name === itemName);
48
+ if (!item) {
49
+ throw new Error(`Item with name "${itemName}" not found`);
50
+ }
51
+
52
+ orderingApi.addItemToOrder(itemName, undefined, [...item.toppings, "bacon"]);
53
+ orderingApi.respondToUser("Ok, I added a Hamburger with no cheese or onions. What else would you like?");
54
+ ```
55
+
56
+ log: Added Hamburger with id 2
57
+
58
+ user: Add jalapenos to that
59
+
60
+ code:
61
+ ```typescript
62
+ const existingItem = orderingApi.getItemInOrder("2");
63
+
64
+ if(existingItem) {
65
+ orderingApi.modifyItemInOrder("2", existingItem.customizations.map(item => item.name), [...existingItem.toppings, "jalapenos"]);
66
+ orderingApi.respondToUser("Ok, I added jalapenos to your Hamburger");
67
+ } else {
68
+ orderingApi.respondToUser("Hmm, I can't find that item.");
69
+ }
70
+ ```
71
+
72
+ user: Add a hamburger with no lettuce
73
+
74
+ code:
75
+ ```typescript
76
+ const itemName = "Hamburger";
77
+ const item = Menu.find((item) => item.name === itemName);
78
+ if (!item) {
79
+ throw new Error(`Item with name "${itemName}" not found`);
80
+ }
81
+
82
+ orderingApi.addItemToOrder(itemName, undefined, [...item.toppings.filter(topping => topping != "lettuce")]);
83
+ orderingApi.respondToUser("Ok, I added a Hamburger with no cheese or onions. What else would you like?");
84
+ ```
85
+
86
+ log: Added Hamburger with id 2
87
+
88
+
89
+ user: I want an elephant.
90
+
91
+ code:
92
+ ```typescript
93
+ orderingApi.respondToUser("I'm sorry, but that isn't on our menu.");
94
+ ```
@@ -1,191 +1,191 @@
1
- export const API_VERSION="1.0.1";
2
-
3
- export interface Customization {
4
- name: string;
5
- priceAdjustment: number;
6
- }
7
-
8
- export interface MenuItemBase {
9
- orderId?: string;
10
- name: string;
11
- price: number;
12
- description: string;
13
- category: string;
14
- tags: string[];
15
- customizations: Customization[];
16
- readonly allowedCustomizations: Customization[];
17
- toppings: string[];
18
- readonly allowedToppings: string[];
19
- }
20
-
21
- export const Menu: MenuItemBase[] = [
22
- {
23
- "name": "Pizza",
24
- "price": 10.99,
25
- "description": "A classic pizza with your choice of toppings.",
26
- "category": "Pizza",
27
- "tags": [
28
- "cheese",
29
- "pizza"
30
- ],
31
- "customizations": [],
32
- "allowedCustomizations": [
33
- {
34
- "name": "Extra Cheese",
35
- "priceAdjustment": 1.99
36
- },
37
- {
38
- "name": "Extra Sauce",
39
- "priceAdjustment": 0.99
40
- },
41
- {
42
- "name": "Gluten Free Crust",
43
- "priceAdjustment": 2.99
44
- },
45
- {
46
- "name": "Large",
47
- "priceAdjustment": 3.99
48
- }
49
- ],
50
- "toppings": [],
51
- "allowedToppings": [
52
- "pepperoni",
53
- "sausage",
54
- "mushrooms",
55
- "onions",
56
- "green peppers",
57
- "black olives",
58
- "green olives",
59
- "anchovies",
60
- "pineapple",
61
- "ham",
62
- "bacon",
63
- "chicken",
64
- ]
65
- },
66
- {
67
- "name": "Hamburger",
68
- "price": 8.99,
69
- "description": "A classic american hamburger with your choice of toppings. Cheese, lettuce, tomato, and onion toppings are included by default. Other toppings available on request.",
70
- "category": "Burgers",
71
- "tags": [
72
- "hamburger",
73
- "burger"
74
- ],
75
- "customizations": [],
76
- "allowedCustomizations": [],
77
- "toppings": [ "cheese", "lettuce", "tomato", "onion"],
78
- "allowedToppings": [
79
- "cheese",
80
- "lettuce",
81
- "tomato",
82
- "onion",
83
- "pickles",
84
- "bacon",
85
- "mushrooms",
86
- "avocado",
87
- "jalapenos",
88
- ],
89
- },
90
- {
91
- "name": "Fries",
92
- "price": 2.99,
93
- "description": "A classic side of fries.",
94
- "category": "Sides",
95
- "tags": [
96
- "fries",
97
- "french fries"
98
- ],
99
- "customizations": [],
100
- "allowedCustomizations": [
101
- {
102
- "name": "Large",
103
- "priceAdjustment": 1.99
104
- },
105
- ],
106
- "toppings": [],
107
- "allowedToppings": [
108
- "old bay",
109
- ]
110
- },
111
- {
112
- "name": "Fountain Drink",
113
- "price": 1.99,
114
- "description": "A classic fountain drink. Choose from the following sodas Cola, Diet Cola, Dr. Dazzle, or Mountain Rush. Large size available on request.",
115
- "category": "Drinks",
116
- "tags": [
117
- "drink",
118
- "soda",
119
- "fountain drink"
120
- ],
121
- "customizations": [],
122
- "allowedCustomizations": [
123
- {
124
- "name": "Large",
125
- "priceAdjustment": 0.99
126
- },
127
- {
128
- "name": "Extra Ice",
129
- "priceAdjustment": 0.99
130
- },
131
- ],
132
- "toppings": [],
133
- "allowedToppings": []
134
- }
135
- ];
136
-
137
-
138
-
139
- export interface OrderingAPIInterface {
140
-
141
- sendEmail(to: string, subject: string, body: string): Promise<void>;
142
- // Sends an email to the specified address with the specified subject and body.
143
-
144
- getCurrentOrder(): MenuItemBase[];
145
- // Gets the list of items that the user has added to the order so far.
146
-
147
- getItemInOrder(itemOrderId: string): MenuItemBase | undefined;
148
- // Gets the item with the specified id from the order.
149
- // If the item is not in the order, returns undefined.
150
-
151
- getCustomizationByName(itemName:string, name: string): Customization | undefined;
152
- // Gets the customization with the specified name for the specified item.
153
- // If the item does not have a customization with the specified name, returns undefined.
154
-
155
- addItemToOrder(itemName:string, customizationNames: string[] | undefined, toppings: string[] | undefined): void;
156
- // Adds the specified item to the order.
157
- // leave customizationNames and toppings undefined if you want to use the default values for the item.
158
-
159
- removeItemFromOrder(itemOrderId: string): void;
160
- // Removes the item with the specified id from the order.
161
-
162
- modifyItemInOrder(itemOrderId: string, customizationNames: string[], toppings: string[]): void;
163
- // Replace the item in the order with the specified item.
164
-
165
- getOrderTotal(): number;
166
- // Gets the total price for the current order
167
-
168
- completeOrder(): void;
169
- // Completes the order and sends it to the kitchen.
170
-
171
- respondToUser(text: string): void;
172
- // Sends a message to the user.
173
-
174
- delay(milliseconds: number): Promise<void>;
175
- // waits for the specified number of milliseconds before resolving the promise.
176
-
177
- displayItem(item: MenuItemBase, justAdded:boolean): void;
178
- // Displays the specified item to the user.
179
- // If justAdded is true, the item will be displayed as a new item in the order.
180
-
181
- displayOrder(): void;
182
- // Displays the current order to the user.
183
-
184
-
185
- };
186
-
187
- // Global object for accessing the OrderingAPIInterface
188
- declare global {
189
- const orderingApi: OrderingAPIInterface;
190
- const Menu: MenuItemBase[];
191
- }
1
+ export const API_VERSION="1.0.1";
2
+
3
+ export interface Customization {
4
+ name: string;
5
+ priceAdjustment: number;
6
+ }
7
+
8
+ export interface MenuItemBase {
9
+ orderId?: string;
10
+ name: string;
11
+ price: number;
12
+ description: string;
13
+ category: string;
14
+ tags: string[];
15
+ customizations: Customization[];
16
+ readonly allowedCustomizations: Customization[];
17
+ toppings: string[];
18
+ readonly allowedToppings: string[];
19
+ }
20
+
21
+ export const Menu: MenuItemBase[] = [
22
+ {
23
+ "name": "Pizza",
24
+ "price": 10.99,
25
+ "description": "A classic pizza with your choice of toppings.",
26
+ "category": "Pizza",
27
+ "tags": [
28
+ "cheese",
29
+ "pizza"
30
+ ],
31
+ "customizations": [],
32
+ "allowedCustomizations": [
33
+ {
34
+ "name": "Extra Cheese",
35
+ "priceAdjustment": 1.99
36
+ },
37
+ {
38
+ "name": "Extra Sauce",
39
+ "priceAdjustment": 0.99
40
+ },
41
+ {
42
+ "name": "Gluten Free Crust",
43
+ "priceAdjustment": 2.99
44
+ },
45
+ {
46
+ "name": "Large",
47
+ "priceAdjustment": 3.99
48
+ }
49
+ ],
50
+ "toppings": [],
51
+ "allowedToppings": [
52
+ "pepperoni",
53
+ "sausage",
54
+ "mushrooms",
55
+ "onions",
56
+ "green peppers",
57
+ "black olives",
58
+ "green olives",
59
+ "anchovies",
60
+ "pineapple",
61
+ "ham",
62
+ "bacon",
63
+ "chicken",
64
+ ]
65
+ },
66
+ {
67
+ "name": "Hamburger",
68
+ "price": 8.99,
69
+ "description": "A classic american hamburger with your choice of toppings. Cheese, lettuce, tomato, and onion toppings are included by default. Other toppings available on request.",
70
+ "category": "Burgers",
71
+ "tags": [
72
+ "hamburger",
73
+ "burger"
74
+ ],
75
+ "customizations": [],
76
+ "allowedCustomizations": [],
77
+ "toppings": [ "cheese", "lettuce", "tomato", "onion"],
78
+ "allowedToppings": [
79
+ "cheese",
80
+ "lettuce",
81
+ "tomato",
82
+ "onion",
83
+ "pickles",
84
+ "bacon",
85
+ "mushrooms",
86
+ "avocado",
87
+ "jalapenos",
88
+ ],
89
+ },
90
+ {
91
+ "name": "Fries",
92
+ "price": 2.99,
93
+ "description": "A classic side of fries.",
94
+ "category": "Sides",
95
+ "tags": [
96
+ "fries",
97
+ "french fries"
98
+ ],
99
+ "customizations": [],
100
+ "allowedCustomizations": [
101
+ {
102
+ "name": "Large",
103
+ "priceAdjustment": 1.99
104
+ },
105
+ ],
106
+ "toppings": [],
107
+ "allowedToppings": [
108
+ "old bay",
109
+ ]
110
+ },
111
+ {
112
+ "name": "Fountain Drink",
113
+ "price": 1.99,
114
+ "description": "A classic fountain drink. Choose from the following sodas Cola, Diet Cola, Dr. Dazzle, or Mountain Rush. Large size available on request.",
115
+ "category": "Drinks",
116
+ "tags": [
117
+ "drink",
118
+ "soda",
119
+ "fountain drink"
120
+ ],
121
+ "customizations": [],
122
+ "allowedCustomizations": [
123
+ {
124
+ "name": "Large",
125
+ "priceAdjustment": 0.99
126
+ },
127
+ {
128
+ "name": "Extra Ice",
129
+ "priceAdjustment": 0.99
130
+ },
131
+ ],
132
+ "toppings": [],
133
+ "allowedToppings": []
134
+ }
135
+ ];
136
+
137
+
138
+
139
+ export interface OrderingAPIInterface {
140
+
141
+ sendEmail(to: string, subject: string, body: string): Promise<void>;
142
+ // Sends an email to the specified address with the specified subject and body.
143
+
144
+ getCurrentOrder(): MenuItemBase[];
145
+ // Gets the list of items that the user has added to the order so far.
146
+
147
+ getItemInOrder(itemOrderId: string): MenuItemBase | undefined;
148
+ // Gets the item with the specified id from the order.
149
+ // If the item is not in the order, returns undefined.
150
+
151
+ getCustomizationByName(itemName:string, name: string): Customization | undefined;
152
+ // Gets the customization with the specified name for the specified item.
153
+ // If the item does not have a customization with the specified name, returns undefined.
154
+
155
+ addItemToOrder(itemName:string, customizationNames: string[] | undefined, toppings: string[] | undefined): void;
156
+ // Adds the specified item to the order.
157
+ // leave customizationNames and toppings undefined if you want to use the default values for the item.
158
+
159
+ removeItemFromOrder(itemOrderId: string): void;
160
+ // Removes the item with the specified id from the order.
161
+
162
+ modifyItemInOrder(itemOrderId: string, customizationNames: string[], toppings: string[]): void;
163
+ // Replace the item in the order with the specified item.
164
+
165
+ getOrderTotal(): number;
166
+ // Gets the total price for the current order
167
+
168
+ completeOrder(): void;
169
+ // Completes the order and sends it to the kitchen.
170
+
171
+ respondToUser(text: string): void;
172
+ // Sends a message to the user.
173
+
174
+ delay(milliseconds: number): Promise<void>;
175
+ // waits for the specified number of milliseconds before resolving the promise.
176
+
177
+ displayItem(item: MenuItemBase, justAdded:boolean): void;
178
+ // Displays the specified item to the user.
179
+ // If justAdded is true, the item will be displayed as a new item in the order.
180
+
181
+ displayOrder(): void;
182
+ // Displays the current order to the user.
183
+
184
+
185
+ };
186
+
187
+ // Global object for accessing the OrderingAPIInterface
188
+ declare global {
189
+ const orderingApi: OrderingAPIInterface;
190
+ const Menu: MenuItemBase[];
191
+ }