@opentabs-dev/opentabs-plugin-panda-express 0.0.74
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 +140 -0
- package/dist/adapter.iife.js +15117 -0
- package/dist/adapter.iife.js.map +7 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/dist/panda-api.d.ts +9 -0
- package/dist/panda-api.d.ts.map +1 -0
- package/dist/panda-api.js +88 -0
- package/dist/panda-api.js.map +1 -0
- package/dist/tools/add-product-to-basket.d.ts +21 -0
- package/dist/tools/add-product-to-basket.d.ts.map +1 -0
- package/dist/tools/add-product-to-basket.js +39 -0
- package/dist/tools/add-product-to-basket.js.map +1 -0
- package/dist/tools/apply-coupon.d.ts +19 -0
- package/dist/tools/apply-coupon.d.ts.map +1 -0
- package/dist/tools/apply-coupon.js +27 -0
- package/dist/tools/apply-coupon.js.map +1 -0
- package/dist/tools/cancel-order.d.ts +7 -0
- package/dist/tools/cancel-order.d.ts.map +1 -0
- package/dist/tools/cancel-order.js +25 -0
- package/dist/tools/cancel-order.js.map +1 -0
- package/dist/tools/create-basket.d.ts +19 -0
- package/dist/tools/create-basket.d.ts.map +1 -0
- package/dist/tools/create-basket.js +30 -0
- package/dist/tools/create-basket.js.map +1 -0
- package/dist/tools/find-restaurants.d.ts +28 -0
- package/dist/tools/find-restaurants.d.ts.map +1 -0
- package/dist/tools/find-restaurants.js +33 -0
- package/dist/tools/find-restaurants.js.map +1 -0
- package/dist/tools/get-basket.d.ts +25 -0
- package/dist/tools/get-basket.d.ts.map +1 -0
- package/dist/tools/get-basket.js +27 -0
- package/dist/tools/get-basket.js.map +1 -0
- package/dist/tools/get-billing-accounts.d.ts +11 -0
- package/dist/tools/get-billing-accounts.d.ts.map +1 -0
- package/dist/tools/get-billing-accounts.js +35 -0
- package/dist/tools/get-billing-accounts.js.map +1 -0
- package/dist/tools/get-checkout-summary.d.ts +13 -0
- package/dist/tools/get-checkout-summary.d.ts.map +1 -0
- package/dist/tools/get-checkout-summary.js +40 -0
- package/dist/tools/get-checkout-summary.js.map +1 -0
- package/dist/tools/get-favorites.d.ts +9 -0
- package/dist/tools/get-favorites.d.ts.map +1 -0
- package/dist/tools/get-favorites.js +22 -0
- package/dist/tools/get-favorites.js.map +1 -0
- package/dist/tools/get-loyalty-rewards.d.ts +12 -0
- package/dist/tools/get-loyalty-rewards.d.ts.map +1 -0
- package/dist/tools/get-loyalty-rewards.js +33 -0
- package/dist/tools/get-loyalty-rewards.js.map +1 -0
- package/dist/tools/get-product-modifiers.d.ts +17 -0
- package/dist/tools/get-product-modifiers.d.ts.map +1 -0
- package/dist/tools/get-product-modifiers.js +45 -0
- package/dist/tools/get-product-modifiers.js.map +1 -0
- package/dist/tools/get-recent-orders.d.ts +17 -0
- package/dist/tools/get-recent-orders.d.ts.map +1 -0
- package/dist/tools/get-recent-orders.js +22 -0
- package/dist/tools/get-recent-orders.js.map +1 -0
- package/dist/tools/get-restaurant-menu.d.ts +22 -0
- package/dist/tools/get-restaurant-menu.d.ts.map +1 -0
- package/dist/tools/get-restaurant-menu.js +27 -0
- package/dist/tools/get-restaurant-menu.js.map +1 -0
- package/dist/tools/get-restaurant.d.ts +26 -0
- package/dist/tools/get-restaurant.d.ts.map +1 -0
- package/dist/tools/get-restaurant.js +34 -0
- package/dist/tools/get-restaurant.js.map +1 -0
- package/dist/tools/get-user-profile.d.ts +11 -0
- package/dist/tools/get-user-profile.d.ts.map +1 -0
- package/dist/tools/get-user-profile.js +48 -0
- package/dist/tools/get-user-profile.js.map +1 -0
- package/dist/tools/navigate-to-checkout.d.ts +32 -0
- package/dist/tools/navigate-to-checkout.d.ts.map +1 -0
- package/dist/tools/navigate-to-checkout.js +112 -0
- package/dist/tools/navigate-to-checkout.js.map +1 -0
- package/dist/tools/remove-coupon.d.ts +18 -0
- package/dist/tools/remove-coupon.d.ts.map +1 -0
- package/dist/tools/remove-coupon.js +25 -0
- package/dist/tools/remove-coupon.js.map +1 -0
- package/dist/tools/schemas.d.ts +241 -0
- package/dist/tools/schemas.d.ts.map +1 -0
- package/dist/tools/schemas.js +168 -0
- package/dist/tools/schemas.js.map +1 -0
- package/dist/tools/update-product-quantity.d.ts +20 -0
- package/dist/tools/update-product-quantity.d.ts.map +1 -0
- package/dist/tools/update-product-quantity.js +34 -0
- package/dist/tools/update-product-quantity.js.map +1 -0
- package/dist/tools.json +1584 -0
- package/package.json +54 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const getCheckoutSummary: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{
|
|
3
|
+
basket_id: z.ZodString;
|
|
4
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
5
|
+
summary: z.ZodObject<{
|
|
6
|
+
basket_id: z.ZodString;
|
|
7
|
+
subtotal: z.ZodNumber;
|
|
8
|
+
tax: z.ZodNumber;
|
|
9
|
+
total: z.ZodNumber;
|
|
10
|
+
ready_time: z.ZodString;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
}, z.core.$strip>>;
|
|
13
|
+
//# sourceMappingURL=get-checkout-summary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-checkout-summary.d.ts","sourceRoot":"","sources":["../../src/tools/get-checkout-summary.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmBxB,eAAO,MAAM,kBAAkB;;;;;;;;;;kBA6B7B,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { defineTool } from '@opentabs-dev/plugin-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { api } from '../panda-api.js';
|
|
4
|
+
const checkoutSummarySchema = z.object({
|
|
5
|
+
basket_id: z.string().describe('Basket ID'),
|
|
6
|
+
subtotal: z.number().describe('Subtotal before tax'),
|
|
7
|
+
tax: z.number().describe('Tax amount'),
|
|
8
|
+
total: z.number().describe('Total amount including tax and fees'),
|
|
9
|
+
ready_time: z.string().describe('Estimated ready time'),
|
|
10
|
+
});
|
|
11
|
+
export const getCheckoutSummary = defineTool({
|
|
12
|
+
name: 'get_checkout_summary',
|
|
13
|
+
displayName: 'Get Checkout Summary',
|
|
14
|
+
description: 'Validate and get the checkout summary for a basket. Returns the total, tax, and estimated ready time. Call this before submitting an order to review the final totals.',
|
|
15
|
+
summary: 'Review order totals before checkout',
|
|
16
|
+
icon: 'receipt',
|
|
17
|
+
group: 'Orders',
|
|
18
|
+
input: z.object({
|
|
19
|
+
basket_id: z.string().describe('Basket ID (UUID)'),
|
|
20
|
+
}),
|
|
21
|
+
output: z.object({
|
|
22
|
+
summary: checkoutSummarySchema.describe('Checkout summary with totals'),
|
|
23
|
+
}),
|
|
24
|
+
handle: async (params) => {
|
|
25
|
+
const data = await api(`/baskets/${params.basket_id}/validate`, {
|
|
26
|
+
method: 'POST',
|
|
27
|
+
body: {},
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
summary: {
|
|
31
|
+
basket_id: data.basketid ?? params.basket_id,
|
|
32
|
+
subtotal: data.subtotal ?? 0,
|
|
33
|
+
tax: data.tax ?? 0,
|
|
34
|
+
total: data.total ?? 0,
|
|
35
|
+
ready_time: data.readytime ?? '',
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=get-checkout-summary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-checkout-summary.js","sourceRoot":"","sources":["../../src/tools/get-checkout-summary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC;IAC3C,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;IACpD,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC;IACtC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;IACjE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC;CACxD,CAAC,CAAC;AAUH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;IAC3C,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,sBAAsB;IACnC,WAAW,EACT,wKAAwK;IAC1K,OAAO,EAAE,qCAAqC;IAC9C,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,QAAQ;IACf,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;KACnD,CAAC;IACF,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,OAAO,EAAE,qBAAqB,CAAC,QAAQ,CAAC,8BAA8B,CAAC;KACxE,CAAC;IACF,MAAM,EAAE,KAAK,EAAC,MAAM,EAAC,EAAE;QACrB,MAAM,IAAI,GAAG,MAAM,GAAG,CAAgB,YAAY,MAAM,CAAC,SAAS,WAAW,EAAE;YAC7E,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,EAAE;SACT,CAAC,CAAC;QACH,OAAO;YACL,OAAO,EAAE;gBACP,SAAS,EAAE,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,SAAS;gBAC5C,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,CAAC;gBAC5B,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC;gBAClB,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC;gBACtB,UAAU,EAAE,IAAI,CAAC,SAAS,IAAI,EAAE;aACjC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const getFavorites: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{}, z.core.$strip>, z.ZodObject<{
|
|
3
|
+
favorites: z.ZodArray<z.ZodObject<{
|
|
4
|
+
id: z.ZodNumber;
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
vendor_id: z.ZodNumber;
|
|
7
|
+
}, z.core.$strip>>;
|
|
8
|
+
}, z.core.$strip>>;
|
|
9
|
+
//# sourceMappingURL=get-favorites.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-favorites.d.ts","sourceRoot":"","sources":["../../src/tools/get-favorites.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,YAAY;;;;;;kBAiBvB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineTool } from '@opentabs-dev/plugin-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { api, getRequiredAuthToken } from '../panda-api.js';
|
|
4
|
+
import { favoriteSchema, mapFavorite } from './schemas.js';
|
|
5
|
+
export const getFavorites = defineTool({
|
|
6
|
+
name: 'get_favorites',
|
|
7
|
+
displayName: 'Get Favorites',
|
|
8
|
+
description: "Get the authenticated user's saved favorite orders. Favorites can be quickly reordered. Requires the user to be logged in.",
|
|
9
|
+
summary: 'View your saved favorite orders',
|
|
10
|
+
icon: 'heart',
|
|
11
|
+
group: 'Account',
|
|
12
|
+
input: z.object({}),
|
|
13
|
+
output: z.object({
|
|
14
|
+
favorites: z.array(favoriteSchema).describe('List of saved favorites'),
|
|
15
|
+
}),
|
|
16
|
+
handle: async () => {
|
|
17
|
+
const authtoken = getRequiredAuthToken();
|
|
18
|
+
const data = await api(`/users/${authtoken}/faves`);
|
|
19
|
+
return { favorites: (data.faves ?? []).map(mapFavorite) };
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=get-favorites.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-favorites.js","sourceRoot":"","sources":["../../src/tools/get-favorites.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAoB,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE7E,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;IACrC,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,eAAe;IAC5B,WAAW,EACT,4HAA4H;IAC9H,OAAO,EAAE,iCAAiC;IAC1C,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACnB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,yBAAyB,CAAC;KACvE,CAAC;IACF,MAAM,EAAE,KAAK,IAAI,EAAE;QACjB,MAAM,SAAS,GAAG,oBAAoB,EAAE,CAAC;QACzC,MAAM,IAAI,GAAG,MAAM,GAAG,CAA4B,UAAU,SAAS,QAAQ,CAAC,CAAC;QAC/E,OAAO,EAAE,SAAS,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;IAC5D,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const getLoyaltyRewards: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{}, z.core.$strip>, z.ZodObject<{
|
|
3
|
+
rewards: z.ZodArray<z.ZodObject<{
|
|
4
|
+
id: z.ZodNumber;
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
description: z.ZodString;
|
|
7
|
+
image_url: z.ZodString;
|
|
8
|
+
points_required: z.ZodNumber;
|
|
9
|
+
}, z.core.$strip>>;
|
|
10
|
+
current_points: z.ZodNumber;
|
|
11
|
+
}, z.core.$strip>>;
|
|
12
|
+
//# sourceMappingURL=get-loyalty-rewards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-loyalty-rewards.d.ts","sourceRoot":"","sources":["../../src/tools/get-loyalty-rewards.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,iBAAiB;;;;;;;;;kBAgC5B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineTool } from '@opentabs-dev/plugin-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { loyaltyRewardSchema, mapLoyaltyReward } from './schemas.js';
|
|
4
|
+
export const getLoyaltyRewards = defineTool({
|
|
5
|
+
name: 'get_loyalty_rewards',
|
|
6
|
+
displayName: 'Get Loyalty Rewards',
|
|
7
|
+
description: 'Get available Panda Express loyalty rewards that can be redeemed with points. Reads from the local app state — requires the user to be logged in with an active rewards account.',
|
|
8
|
+
summary: 'View available loyalty rewards',
|
|
9
|
+
icon: 'gift',
|
|
10
|
+
group: 'Loyalty',
|
|
11
|
+
input: z.object({}),
|
|
12
|
+
output: z.object({
|
|
13
|
+
rewards: z.array(loyaltyRewardSchema).describe('Available loyalty rewards'),
|
|
14
|
+
current_points: z.number().int().describe('Current loyalty points balance'),
|
|
15
|
+
}),
|
|
16
|
+
handle: async () => {
|
|
17
|
+
try {
|
|
18
|
+
const root = localStorage.getItem('persist:root');
|
|
19
|
+
if (!root)
|
|
20
|
+
return { rewards: [], current_points: 0 };
|
|
21
|
+
const parsed = JSON.parse(root);
|
|
22
|
+
const loyalty = JSON.parse(parsed.loyalty ?? '{}');
|
|
23
|
+
const milestones = JSON.parse(parsed.loyaltyMilestonesUI ?? '{}');
|
|
24
|
+
const rewards = (loyalty.rewardStoreRedeemables?.entities ?? []).map(mapLoyaltyReward);
|
|
25
|
+
const currentPoints = milestones.currentPoints ?? loyalty.estimatedPoints ?? 0;
|
|
26
|
+
return { rewards, current_points: currentPoints };
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return { rewards: [], current_points: 0 };
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=get-loyalty-rewards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-loyalty-rewards.js","sourceRoot":"","sources":["../../src/tools/get-loyalty-rewards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAyB,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE5F,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;IAC1C,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,qBAAqB;IAClC,WAAW,EACT,kLAAkL;IACpL,OAAO,EAAE,gCAAgC;IACzC,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACnB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,QAAQ,CAAC,2BAA2B,CAAC;QAC3E,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,gCAAgC,CAAC;KAC5E,CAAC;IACF,MAAM,EAAE,KAAK,IAAI,EAAE;QACjB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;YAClD,IAAI,CAAC,IAAI;gBAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC;YACrD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAA2B,CAAC;YAC1D,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,IAAI,IAAI,CAGhD,CAAC;YACF,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,mBAAmB,IAAI,IAAI,CAE/D,CAAC;YACF,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,sBAAsB,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;YACvF,MAAM,aAAa,GAAG,UAAU,CAAC,aAAa,IAAI,OAAO,CAAC,eAAe,IAAI,CAAC,CAAC;YAC/E,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;QACpD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC;QAC5C,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const getProductModifiers: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{
|
|
3
|
+
product_id: z.ZodNumber;
|
|
4
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
5
|
+
groups: z.ZodArray<z.ZodObject<{
|
|
6
|
+
id: z.ZodNumber;
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
mandatory: z.ZodBoolean;
|
|
9
|
+
options: z.ZodArray<z.ZodObject<{
|
|
10
|
+
id: z.ZodNumber;
|
|
11
|
+
name: z.ZodString;
|
|
12
|
+
cost: z.ZodNumber;
|
|
13
|
+
is_default: z.ZodBoolean;
|
|
14
|
+
}, z.core.$strip>>;
|
|
15
|
+
}, z.core.$strip>>;
|
|
16
|
+
}, z.core.$strip>>;
|
|
17
|
+
//# sourceMappingURL=get-product-modifiers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-product-modifiers.d.ts","sourceRoot":"","sources":["../../src/tools/get-product-modifiers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA+BxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;kBA6B9B,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { defineTool } from '@opentabs-dev/plugin-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { api } from '../panda-api.js';
|
|
4
|
+
const modifierOptionSchema = z.object({
|
|
5
|
+
id: z.number().describe('Option ID — pass to add_product_to_basket in the options array'),
|
|
6
|
+
name: z.string().describe('Option name (e.g., "Chow Mein", "16.9oz")'),
|
|
7
|
+
cost: z.number().describe('Additional cost for this option (0 if included)'),
|
|
8
|
+
is_default: z.boolean().describe('Whether this option is selected by default'),
|
|
9
|
+
});
|
|
10
|
+
const modifierGroupSchema = z.object({
|
|
11
|
+
id: z.number().describe('Modifier group ID'),
|
|
12
|
+
name: z.string().describe('Group name (e.g., "Step 1", "Size")'),
|
|
13
|
+
mandatory: z.boolean().describe('Whether a selection is required from this group'),
|
|
14
|
+
options: z.array(modifierOptionSchema).describe('Available options in this group'),
|
|
15
|
+
});
|
|
16
|
+
export const getProductModifiers = defineTool({
|
|
17
|
+
name: 'get_product_modifiers',
|
|
18
|
+
displayName: 'Get Product Modifiers',
|
|
19
|
+
description: 'Get available modifier options for a menu product. Most products (bowls, plates, combos) require modifier selections (side, entree, drink choices). Use the returned option IDs when calling add_product_to_basket.',
|
|
20
|
+
summary: 'Get customization options for a menu item',
|
|
21
|
+
icon: 'list-checks',
|
|
22
|
+
group: 'Menu',
|
|
23
|
+
input: z.object({
|
|
24
|
+
product_id: z.number().int().describe('Product ID from get_restaurant_menu'),
|
|
25
|
+
}),
|
|
26
|
+
output: z.object({
|
|
27
|
+
groups: z.array(modifierGroupSchema).describe('Modifier groups with their options'),
|
|
28
|
+
}),
|
|
29
|
+
handle: async (params) => {
|
|
30
|
+
const data = await api(`/products/${params.product_id}/modifiers`);
|
|
31
|
+
const groups = (data.optiongroups ?? []).map(g => ({
|
|
32
|
+
id: g.id ?? 0,
|
|
33
|
+
name: g.description ?? '',
|
|
34
|
+
mandatory: g.mandatory ?? false,
|
|
35
|
+
options: (g.options ?? []).map(o => ({
|
|
36
|
+
id: o.id ?? 0,
|
|
37
|
+
name: o.name ?? '',
|
|
38
|
+
cost: o.cost ?? 0,
|
|
39
|
+
is_default: o.isdefault ?? false,
|
|
40
|
+
})),
|
|
41
|
+
}));
|
|
42
|
+
return { groups };
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=get-product-modifiers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-product-modifiers.js","sourceRoot":"","sources":["../../src/tools/get-product-modifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gEAAgE,CAAC;IACzF,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;IACtE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;IAC5E,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,4CAA4C,CAAC;CAC/E,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC;IAC5C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;IAChE,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;IAClF,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,QAAQ,CAAC,iCAAiC,CAAC;CACnF,CAAC,CAAC;AAgBH,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;IAC5C,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE,uBAAuB;IACpC,WAAW,EACT,qNAAqN;IACvN,OAAO,EAAE,2CAA2C;IACpD,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,MAAM;IACb,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;KAC7E,CAAC;IACF,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,QAAQ,CAAC,oCAAoC,CAAC;KACpF,CAAC;IACF,MAAM,EAAE,KAAK,EAAC,MAAM,EAAC,EAAE;QACrB,MAAM,IAAI,GAAG,MAAM,GAAG,CAAgC,aAAa,MAAM,CAAC,UAAU,YAAY,CAAC,CAAC;QAClG,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACjD,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC;YACb,IAAI,EAAE,CAAC,CAAC,WAAW,IAAI,EAAE;YACzB,SAAS,EAAE,CAAC,CAAC,SAAS,IAAI,KAAK;YAC/B,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBACnC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC;gBACb,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,EAAE;gBAClB,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC;gBACjB,UAAU,EAAE,CAAC,CAAC,SAAS,IAAI,KAAK;aACjC,CAAC,CAAC;SACJ,CAAC,CAAC,CAAC;QACJ,OAAO,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const getRecentOrders: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{}, z.core.$strip>, z.ZodObject<{
|
|
3
|
+
orders: z.ZodArray<z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
vendor_id: z.ZodNumber;
|
|
6
|
+
vendor_name: z.ZodString;
|
|
7
|
+
status: z.ZodString;
|
|
8
|
+
subtotal: z.ZodNumber;
|
|
9
|
+
sales_tax: z.ZodNumber;
|
|
10
|
+
total: z.ZodNumber;
|
|
11
|
+
delivery_mode: z.ZodString;
|
|
12
|
+
time_placed: z.ZodString;
|
|
13
|
+
time_ready: z.ZodString;
|
|
14
|
+
product_count: z.ZodNumber;
|
|
15
|
+
}, z.core.$strip>>;
|
|
16
|
+
}, z.core.$strip>>;
|
|
17
|
+
//# sourceMappingURL=get-recent-orders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-recent-orders.d.ts","sourceRoot":"","sources":["../../src/tools/get-recent-orders.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,eAAe;;;;;;;;;;;;;;kBAiB1B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineTool } from '@opentabs-dev/plugin-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { api, getRequiredAuthToken } from '../panda-api.js';
|
|
4
|
+
import { mapOrder, orderSchema } from './schemas.js';
|
|
5
|
+
export const getRecentOrders = defineTool({
|
|
6
|
+
name: 'get_recent_orders',
|
|
7
|
+
displayName: 'Get Recent Orders',
|
|
8
|
+
description: "Get the authenticated user's recent order history. Returns orders with restaurant info, totals, and status. Requires the user to be logged in.",
|
|
9
|
+
summary: 'View your recent Panda Express orders',
|
|
10
|
+
icon: 'history',
|
|
11
|
+
group: 'Account',
|
|
12
|
+
input: z.object({}),
|
|
13
|
+
output: z.object({
|
|
14
|
+
orders: z.array(orderSchema).describe('List of recent orders'),
|
|
15
|
+
}),
|
|
16
|
+
handle: async () => {
|
|
17
|
+
const authtoken = getRequiredAuthToken();
|
|
18
|
+
const data = await api(`/users/${authtoken}/recentorders`);
|
|
19
|
+
return { orders: (data.orders ?? []).map(mapOrder) };
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=get-recent-orders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-recent-orders.js","sourceRoot":"","sources":["../../src/tools/get-recent-orders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAiB,QAAQ,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEpE,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC;IACxC,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,mBAAmB;IAChC,WAAW,EACT,gJAAgJ;IAClJ,OAAO,EAAE,uCAAuC;IAChD,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACnB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,uBAAuB,CAAC;KAC/D,CAAC;IACF,MAAM,EAAE,KAAK,IAAI,EAAE;QACjB,MAAM,SAAS,GAAG,oBAAoB,EAAE,CAAC;QACzC,MAAM,IAAI,GAAG,MAAM,GAAG,CAA0B,UAAU,SAAS,eAAe,CAAC,CAAC;QACpF,OAAO,EAAE,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;IACvD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const getRestaurantMenu: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{
|
|
3
|
+
restaurant_id: z.ZodNumber;
|
|
4
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
5
|
+
categories: z.ZodArray<z.ZodObject<{
|
|
6
|
+
id: z.ZodNumber;
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
description: z.ZodString;
|
|
9
|
+
product_count: z.ZodNumber;
|
|
10
|
+
}, z.core.$strip>>;
|
|
11
|
+
products: z.ZodArray<z.ZodObject<{
|
|
12
|
+
id: z.ZodNumber;
|
|
13
|
+
name: z.ZodString;
|
|
14
|
+
description: z.ZodString;
|
|
15
|
+
cost: z.ZodNumber;
|
|
16
|
+
base_calories: z.ZodString;
|
|
17
|
+
max_calories: z.ZodString;
|
|
18
|
+
image_url: z.ZodString;
|
|
19
|
+
category: z.ZodString;
|
|
20
|
+
}, z.core.$strip>>;
|
|
21
|
+
}, z.core.$strip>>;
|
|
22
|
+
//# sourceMappingURL=get-restaurant-menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-restaurant-menu.d.ts","sourceRoot":"","sources":["../../src/tools/get-restaurant-menu.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAsBxB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;kBAwB5B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineTool } from '@opentabs-dev/plugin-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { api } from '../panda-api.js';
|
|
4
|
+
import { mapMenuCategory, mapMenuProduct, menuCategorySchema, menuProductSchema, } from './schemas.js';
|
|
5
|
+
export const getRestaurantMenu = defineTool({
|
|
6
|
+
name: 'get_restaurant_menu',
|
|
7
|
+
displayName: 'Get Restaurant Menu',
|
|
8
|
+
description: 'Get the full menu for a specific Panda Express restaurant. Returns categories (e.g., "Bigger Plates", "Sides") with their products including name, description, price, and calories.',
|
|
9
|
+
summary: 'Get menu for a Panda Express location',
|
|
10
|
+
icon: 'utensils',
|
|
11
|
+
group: 'Menu',
|
|
12
|
+
input: z.object({
|
|
13
|
+
restaurant_id: z.number().int().describe('Restaurant ID (from find_restaurants)'),
|
|
14
|
+
}),
|
|
15
|
+
output: z.object({
|
|
16
|
+
categories: z.array(menuCategorySchema).describe('Menu categories'),
|
|
17
|
+
products: z.array(menuProductSchema).describe('All menu products across categories'),
|
|
18
|
+
}),
|
|
19
|
+
handle: async (params) => {
|
|
20
|
+
const data = await api(`/restaurants/${params.restaurant_id}/menu`);
|
|
21
|
+
const imagePath = data.imagepath ?? '';
|
|
22
|
+
const categories = (data.categories ?? []).map(mapMenuCategory);
|
|
23
|
+
const products = (data.categories ?? []).flatMap(cat => (cat.products ?? []).map(p => mapMenuProduct(p, cat.name ?? '', imagePath)));
|
|
24
|
+
return { categories, products };
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=get-restaurant-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-restaurant-menu.js","sourceRoot":"","sources":["../../src/tools/get-restaurant-menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAEL,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AActB,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;IAC1C,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,qBAAqB;IAClC,WAAW,EACT,sLAAsL;IACxL,OAAO,EAAE,uCAAuC;IAChD,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,MAAM;IACb,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,uCAAuC,CAAC;KAClF,CAAC;IACF,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,QAAQ,CAAC,iBAAiB,CAAC;QACnE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,QAAQ,CAAC,qCAAqC,CAAC;KACrF,CAAC;IACF,MAAM,EAAE,KAAK,EAAC,MAAM,EAAC,EAAE;QACrB,MAAM,IAAI,GAAG,MAAM,GAAG,CAAU,gBAAgB,MAAM,CAAC,aAAa,OAAO,CAAC,CAAC;QAC7E,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;QACvC,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAChE,MAAM,QAAQ,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CACrD,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,SAAS,CAAC,CAAC,CAC5E,CAAC;QACF,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;IAClC,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const getRestaurant: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{
|
|
3
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
4
|
+
ext_ref: z.ZodOptional<z.ZodString>;
|
|
5
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
6
|
+
restaurant: z.ZodObject<{
|
|
7
|
+
id: z.ZodNumber;
|
|
8
|
+
name: z.ZodString;
|
|
9
|
+
slug: z.ZodString;
|
|
10
|
+
street_address: z.ZodString;
|
|
11
|
+
city: z.ZodString;
|
|
12
|
+
state: z.ZodString;
|
|
13
|
+
zip: z.ZodString;
|
|
14
|
+
phone: z.ZodString;
|
|
15
|
+
latitude: z.ZodNumber;
|
|
16
|
+
longitude: z.ZodNumber;
|
|
17
|
+
distance: z.ZodNumber;
|
|
18
|
+
is_available: z.ZodBoolean;
|
|
19
|
+
is_open: z.ZodBoolean;
|
|
20
|
+
can_deliver: z.ZodBoolean;
|
|
21
|
+
can_pickup: z.ZodBoolean;
|
|
22
|
+
delivery_fee: z.ZodString;
|
|
23
|
+
ext_ref: z.ZodString;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
}, z.core.$strip>>;
|
|
26
|
+
//# sourceMappingURL=get-restaurant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-restaurant.d.ts","sourceRoot":"","sources":["../../src/tools/get-restaurant.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;kBA4BxB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { defineTool, ToolError } from '@opentabs-dev/plugin-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { api } from '../panda-api.js';
|
|
4
|
+
import { mapRestaurant, restaurantSchema } from './schemas.js';
|
|
5
|
+
export const getRestaurant = defineTool({
|
|
6
|
+
name: 'get_restaurant',
|
|
7
|
+
displayName: 'Get Restaurant',
|
|
8
|
+
description: 'Get detailed information about a specific Panda Express restaurant by its URL slug or external reference number.',
|
|
9
|
+
summary: 'Get restaurant details by slug or ref',
|
|
10
|
+
icon: 'store',
|
|
11
|
+
group: 'Restaurants',
|
|
12
|
+
input: z.object({
|
|
13
|
+
slug: z.string().optional().describe('Restaurant URL slug (e.g., "fillmore-geary-px")'),
|
|
14
|
+
ext_ref: z.string().optional().describe('External reference number (e.g., "4226")'),
|
|
15
|
+
}),
|
|
16
|
+
output: z.object({
|
|
17
|
+
restaurant: restaurantSchema.describe('Restaurant details'),
|
|
18
|
+
}),
|
|
19
|
+
handle: async (params) => {
|
|
20
|
+
if (params.slug) {
|
|
21
|
+
const data = await api(`/restaurants/byslug/${params.slug}`);
|
|
22
|
+
return { restaurant: mapRestaurant(data) };
|
|
23
|
+
}
|
|
24
|
+
if (params.ext_ref) {
|
|
25
|
+
const data = await api(`/restaurants/byref/${params.ext_ref}`);
|
|
26
|
+
const restaurant = data.restaurants?.[0];
|
|
27
|
+
if (!restaurant)
|
|
28
|
+
throw ToolError.notFound(`No restaurant found with ext_ref "${params.ext_ref}"`);
|
|
29
|
+
return { restaurant: mapRestaurant(restaurant) };
|
|
30
|
+
}
|
|
31
|
+
throw ToolError.validation('Provide either slug or ext_ref');
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=get-restaurant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-restaurant.js","sourceRoot":"","sources":["../../src/tools/get-restaurant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAsB,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEnF,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC;IACtC,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EACT,kHAAkH;IACpH,OAAO,EAAE,uCAAuC;IAChD,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,aAAa;IACpB,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;QACvF,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;KACpF,CAAC;IACF,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,UAAU,EAAE,gBAAgB,CAAC,QAAQ,CAAC,oBAAoB,CAAC;KAC5D,CAAC;IACF,MAAM,EAAE,KAAK,EAAC,MAAM,EAAC,EAAE;QACrB,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAChB,MAAM,IAAI,GAAG,MAAM,GAAG,CAAgB,uBAAuB,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;YAC5E,OAAO,EAAE,UAAU,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7C,CAAC;QACD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,MAAM,IAAI,GAAG,MAAM,GAAG,CAAoC,sBAAsB,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;YAClG,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;YACzC,IAAI,CAAC,UAAU;gBAAE,MAAM,SAAS,CAAC,QAAQ,CAAC,qCAAqC,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC;YAClG,OAAO,EAAE,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC;QACnD,CAAC;QACD,MAAM,SAAS,CAAC,UAAU,CAAC,gCAAgC,CAAC,CAAC;IAC/D,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const getUserProfile: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{}, z.core.$strip>, z.ZodObject<{
|
|
3
|
+
profile: z.ZodObject<{
|
|
4
|
+
first_name: z.ZodString;
|
|
5
|
+
last_name: z.ZodString;
|
|
6
|
+
email: z.ZodString;
|
|
7
|
+
phone: z.ZodString;
|
|
8
|
+
is_loyalty_member: z.ZodBoolean;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
}, z.core.$strip>>;
|
|
11
|
+
//# sourceMappingURL=get-user-profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-user-profile.d.ts","sourceRoot":"","sources":["../../src/tools/get-user-profile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,eAAO,MAAM,cAAc;;;;;;;;kBA0CzB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { defineTool, ToolError } from '@opentabs-dev/plugin-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
const userProfileSchema = z.object({
|
|
4
|
+
first_name: z.string().describe('First name'),
|
|
5
|
+
last_name: z.string().describe('Last name'),
|
|
6
|
+
email: z.string().describe('Email address'),
|
|
7
|
+
phone: z.string().describe('Phone number'),
|
|
8
|
+
is_loyalty_member: z.boolean().describe('Whether the user is a Panda Rewards member'),
|
|
9
|
+
});
|
|
10
|
+
export const getUserProfile = defineTool({
|
|
11
|
+
name: 'get_user_profile',
|
|
12
|
+
displayName: 'Get User Profile',
|
|
13
|
+
description: "Get the currently logged-in user's profile information including name, email, phone, and loyalty membership status.",
|
|
14
|
+
summary: 'View your Panda Express account info',
|
|
15
|
+
icon: 'user',
|
|
16
|
+
group: 'Account',
|
|
17
|
+
input: z.object({}),
|
|
18
|
+
output: z.object({
|
|
19
|
+
profile: userProfileSchema.describe('User profile details'),
|
|
20
|
+
}),
|
|
21
|
+
handle: async () => {
|
|
22
|
+
try {
|
|
23
|
+
const root = localStorage.getItem('persist:root');
|
|
24
|
+
if (!root)
|
|
25
|
+
throw ToolError.auth('Not authenticated — please log in.');
|
|
26
|
+
const parsed = JSON.parse(root);
|
|
27
|
+
const appState = JSON.parse(parsed.appState ?? '{}');
|
|
28
|
+
const auth = appState.authentication;
|
|
29
|
+
if (!auth)
|
|
30
|
+
throw ToolError.auth('Not authenticated — please log in.');
|
|
31
|
+
return {
|
|
32
|
+
profile: {
|
|
33
|
+
first_name: auth.firstname ?? '',
|
|
34
|
+
last_name: auth.lastname ?? '',
|
|
35
|
+
email: auth.emailaddress ?? '',
|
|
36
|
+
phone: auth.phone ?? '',
|
|
37
|
+
is_loyalty_member: appState.isLoyaltyMode ?? false,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
if (err instanceof ToolError)
|
|
43
|
+
throw err;
|
|
44
|
+
throw ToolError.auth('Not authenticated — please log in.');
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=get-user-profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-user-profile.js","sourceRoot":"","sources":["../../src/tools/get-user-profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC;IAC7C,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC;IAC3C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC;IAC3C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC;IAC1C,iBAAiB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,4CAA4C,CAAC;CACtF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;IACvC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EACT,qHAAqH;IACvH,OAAO,EAAE,sCAAsC;IAC/C,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACnB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,OAAO,EAAE,iBAAiB,CAAC,QAAQ,CAAC,sBAAsB,CAAC;KAC5D,CAAC;IACF,MAAM,EAAE,KAAK,IAAI,EAAE;QACjB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;YAClD,IAAI,CAAC,IAAI;gBAAE,MAAM,SAAS,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;YACtE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAA2B,CAAC;YAC1D,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,IAAI,IAAI,CAQlD,CAAC;YACF,MAAM,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC;YACrC,IAAI,CAAC,IAAI;gBAAE,MAAM,SAAS,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;YACtE,OAAO;gBACL,OAAO,EAAE;oBACP,UAAU,EAAE,IAAI,CAAC,SAAS,IAAI,EAAE;oBAChC,SAAS,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE;oBAC9B,KAAK,EAAE,IAAI,CAAC,YAAY,IAAI,EAAE;oBAC9B,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE;oBACvB,iBAAiB,EAAE,QAAQ,CAAC,aAAa,IAAI,KAAK;iBACnD;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,SAAS;gBAAE,MAAM,GAAG,CAAC;YACxC,MAAM,SAAS,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Key used to stash the pending basket state across page navigations.
|
|
4
|
+
* The problem: writing to `persist:root` before navigating is unreliable because
|
|
5
|
+
* the SPA's in-memory Redux store flushes back to localStorage during page teardown,
|
|
6
|
+
* overwriting our write. The solution: store the desired state in a separate key,
|
|
7
|
+
* navigate to the bag page, then apply it on the new page before Redux hydrates.
|
|
8
|
+
* See `applyPendingBasket()` which runs at adapter IIFE load time in `index.ts`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const PENDING_BASKET_KEY = "__opentabs_pending_basket";
|
|
11
|
+
/**
|
|
12
|
+
* Apply a pending basket stashed by `navigate_to_checkout`.
|
|
13
|
+
* Called at adapter IIFE load time on every page load.
|
|
14
|
+
*
|
|
15
|
+
* The adapter runs at `document_idle` — after the SPA's scripts have already
|
|
16
|
+
* hydrated Redux from `persist:root`. Writing to `persist:root` at this point
|
|
17
|
+
* is useless because the SPA's in-memory store will overwrite it on the next flush.
|
|
18
|
+
*
|
|
19
|
+
* To handle this reliably: write the basket into `persist:root`, remove the
|
|
20
|
+
* pending key, then reload the page. The second load has no pending key so
|
|
21
|
+
* the reload doesn't loop, and the SPA hydrates with the correct basket data.
|
|
22
|
+
*/
|
|
23
|
+
export declare const applyPendingBasket: () => void;
|
|
24
|
+
export declare const navigateToCheckout: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{
|
|
25
|
+
basket_id: z.ZodString;
|
|
26
|
+
restaurant_name: z.ZodOptional<z.ZodString>;
|
|
27
|
+
restaurant_ext_ref: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
29
|
+
navigated: z.ZodBoolean;
|
|
30
|
+
url: z.ZodString;
|
|
31
|
+
}, z.core.$strip>>;
|
|
32
|
+
//# sourceMappingURL=navigate-to-checkout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigate-to-checkout.d.ts","sourceRoot":"","sources":["../../src/tools/navigate-to-checkout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,8BAA8B,CAAC;AAE9D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,QAAO,IAoCrC,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;kBAgE7B,CAAC"}
|