@chanaka_nakandala/integration-agent 1.0.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.
Files changed (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +87 -0
  3. package/dist/cache/file-cache.d.ts +10 -0
  4. package/dist/cache/file-cache.d.ts.map +1 -0
  5. package/dist/cache/file-cache.js +79 -0
  6. package/dist/cache/file-cache.js.map +1 -0
  7. package/dist/cli/init-command.d.ts +2 -0
  8. package/dist/cli/init-command.d.ts.map +1 -0
  9. package/dist/cli/init-command.js +115 -0
  10. package/dist/cli/init-command.js.map +1 -0
  11. package/dist/index.d.ts +3 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +493 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/scrapers/docs-scraper.d.ts +28 -0
  16. package/dist/scrapers/docs-scraper.d.ts.map +1 -0
  17. package/dist/scrapers/docs-scraper.js +200 -0
  18. package/dist/scrapers/docs-scraper.js.map +1 -0
  19. package/dist/search/keyword-search.d.ts +39 -0
  20. package/dist/search/keyword-search.d.ts.map +1 -0
  21. package/dist/search/keyword-search.js +127 -0
  22. package/dist/search/keyword-search.js.map +1 -0
  23. package/dist/tools/code-generation-tool.d.ts +33 -0
  24. package/dist/tools/code-generation-tool.d.ts.map +1 -0
  25. package/dist/tools/code-generation-tool.js +62 -0
  26. package/dist/tools/code-generation-tool.js.map +1 -0
  27. package/dist/tools/search-result-formatter.d.ts +27 -0
  28. package/dist/tools/search-result-formatter.d.ts.map +1 -0
  29. package/dist/tools/search-result-formatter.js +89 -0
  30. package/dist/tools/search-result-formatter.js.map +1 -0
  31. package/dist/tools/search-tool.d.ts +9 -0
  32. package/dist/tools/search-tool.d.ts.map +1 -0
  33. package/dist/tools/search-tool.js +32 -0
  34. package/dist/tools/search-tool.js.map +1 -0
  35. package/dist/tools/template-loader.d.ts +54 -0
  36. package/dist/tools/template-loader.d.ts.map +1 -0
  37. package/dist/tools/template-loader.js +148 -0
  38. package/dist/tools/template-loader.js.map +1 -0
  39. package/dist/types/search.d.ts +21 -0
  40. package/dist/types/search.d.ts.map +1 -0
  41. package/dist/types/search.js +2 -0
  42. package/dist/types/search.js.map +1 -0
  43. package/package.json +63 -0
  44. package/templates/README.md +98 -0
  45. package/templates/authenticate/curl.template +97 -0
  46. package/templates/authenticate/java.template +155 -0
  47. package/templates/authenticate/python.template +111 -0
  48. package/templates/authenticate/typescript.template +98 -0
  49. package/templates/create_menu/curl.template +145 -0
  50. package/templates/create_menu/java.template +285 -0
  51. package/templates/create_menu/python.template +159 -0
  52. package/templates/create_menu/typescript.template +184 -0
  53. package/templates/receive_order/curl.template +138 -0
  54. package/templates/receive_order/java.template +263 -0
  55. package/templates/receive_order/python.template +157 -0
  56. package/templates/receive_order/typescript.template +194 -0
  57. package/templates/update_item_availability/curl.template +143 -0
  58. package/templates/update_item_availability/java.template +279 -0
  59. package/templates/update_item_availability/python.template +203 -0
  60. package/templates/update_item_availability/typescript.template +194 -0
  61. package/templates/update_order_status/curl.template +138 -0
  62. package/templates/update_order_status/java.template +202 -0
  63. package/templates/update_order_status/python.template +142 -0
  64. package/templates/update_order_status/typescript.template +139 -0
@@ -0,0 +1,202 @@
1
+ /**
2
+ * Grubtech Order Status Update - Java (Spring Boot)
3
+ *
4
+ * This example demonstrates how to update order status in Grubtech.
5
+ *
6
+ * Prerequisites:
7
+ * - Java 17+
8
+ * - Spring Boot 3.x
9
+ * - Spring WebFlux (for WebClient)
10
+ *
11
+ * Replace the following placeholders:
12
+ * - {{AUTH_TOKEN}}: Access token from authentication step
13
+ * - {{ORDER_ID}}: The Grubtech order ID to update
14
+ * - {{NEW_STATUS}}: The new status value
15
+ */
16
+
17
+ package com.example.grubtech;
18
+
19
+ import org.springframework.http.HttpHeaders;
20
+ import org.springframework.http.MediaType;
21
+ import org.springframework.stereotype.Service;
22
+ import org.springframework.web.reactive.function.client.WebClient;
23
+ import reactor.core.publisher.Mono;
24
+
25
+ import java.time.Instant;
26
+ import java.util.HashMap;
27
+ import java.util.Map;
28
+
29
+ @Service
30
+ public class GrubtechOrderStatusService {
31
+
32
+ private static final String AUTH_TOKEN = "{{AUTH_TOKEN}}";
33
+ private static final String BASE_URL = "https://api.grubtech.io";
34
+
35
+ private final WebClient webClient;
36
+
37
+ /**
38
+ * Valid order status values
39
+ */
40
+ public enum OrderStatus {
41
+ ACCEPTED("accepted"),
42
+ PREPARING("preparing"),
43
+ READY("ready"),
44
+ DELIVERED("delivered"),
45
+ CANCELLED("cancelled");
46
+
47
+ private final String value;
48
+
49
+ OrderStatus(String value) {
50
+ this.value = value;
51
+ }
52
+
53
+ public String getValue() {
54
+ return value;
55
+ }
56
+ }
57
+
58
+ public GrubtechOrderStatusService() {
59
+ this.webClient = WebClient.builder()
60
+ .baseUrl(BASE_URL)
61
+ .build();
62
+ }
63
+
64
+ /**
65
+ * Update order status in Grubtech
66
+ *
67
+ * @param orderId The Grubtech order ID
68
+ * @param newStatus The new status value
69
+ * @param notes Optional notes about the status change
70
+ * @return Status update response
71
+ */
72
+ public StatusUpdateResponse updateOrderStatus(
73
+ String orderId,
74
+ OrderStatus newStatus,
75
+ String notes
76
+ ) {
77
+ try {
78
+ // Construct status update payload
79
+ Map<String, Object> payload = new HashMap<>();
80
+ payload.put("orderId", orderId);
81
+ payload.put("status", newStatus.getValue());
82
+ payload.put("timestamp", Instant.now().toString());
83
+
84
+ if (notes != null && !notes.isEmpty()) {
85
+ payload.put("notes", notes);
86
+ }
87
+
88
+ System.out.println("Updating order " + orderId + " to status: " + newStatus.getValue());
89
+
90
+ // Make status update request
91
+ StatusUpdateResponse response = webClient.put()
92
+ .uri("/v1/orders/" + orderId + "/status")
93
+ .header(HttpHeaders.AUTHORIZATION, "Bearer " + AUTH_TOKEN)
94
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
95
+ .bodyValue(payload)
96
+ .retrieve()
97
+ .onStatus(
98
+ status -> !status.is2xxSuccessful(),
99
+ clientResponse -> clientResponse.bodyToMono(String.class)
100
+ .flatMap(errorBody -> Mono.error(
101
+ new RuntimeException(
102
+ "Status update failed: " +
103
+ clientResponse.statusCode() +
104
+ " - " + errorBody
105
+ )
106
+ ))
107
+ )
108
+ .bodyToMono(StatusUpdateResponse.class)
109
+ .block();
110
+
111
+ if (response == null) {
112
+ throw new RuntimeException("No response received from status update");
113
+ }
114
+
115
+ System.out.println("✅ Order status updated successfully!");
116
+ System.out.println("Order ID: " + response.getOrderId());
117
+ System.out.println("New Status: " + response.getStatus());
118
+ System.out.println("Updated At: " + response.getUpdatedAt());
119
+
120
+ return response;
121
+
122
+ } catch (Exception e) {
123
+ System.err.println("❌ Status update error: " + e.getMessage());
124
+ throw e;
125
+ }
126
+ }
127
+
128
+ /**
129
+ * Example: Update order through typical workflow
130
+ *
131
+ * @param orderId The Grubtech order ID
132
+ */
133
+ public void orderWorkflowExample(String orderId) {
134
+ try {
135
+ // Step 1: Accept the order
136
+ updateOrderStatus(orderId, OrderStatus.ACCEPTED, "Order confirmed");
137
+
138
+ // Step 2: Start preparing
139
+ updateOrderStatus(orderId, OrderStatus.PREPARING, "Chef started cooking");
140
+
141
+ // Step 3: Mark as ready
142
+ updateOrderStatus(orderId, OrderStatus.READY, "Order ready for pickup");
143
+
144
+ // Step 4: Mark as delivered
145
+ updateOrderStatus(orderId, OrderStatus.DELIVERED, "Order delivered to customer");
146
+
147
+ System.out.println("✅ Order workflow completed!");
148
+
149
+ } catch (Exception e) {
150
+ System.err.println("❌ Workflow error: " + e.getMessage());
151
+
152
+ // If something goes wrong, cancel the order
153
+ updateOrderStatus(orderId, OrderStatus.CANCELLED, "Unable to fulfill order");
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Response model for status update
159
+ */
160
+ public static class StatusUpdateResponse {
161
+ private boolean success;
162
+ private String orderId;
163
+ private String status;
164
+ private String updatedAt;
165
+ private String message;
166
+
167
+ // Getters and setters
168
+ public boolean isSuccess() { return success; }
169
+ public void setSuccess(boolean success) { this.success = success; }
170
+
171
+ public String getOrderId() { return orderId; }
172
+ public void setOrderId(String orderId) { this.orderId = orderId; }
173
+
174
+ public String getStatus() { return status; }
175
+ public void setStatus(String status) { this.status = status; }
176
+
177
+ public String getUpdatedAt() { return updatedAt; }
178
+ public void setUpdatedAt(String updatedAt) { this.updatedAt = updatedAt; }
179
+
180
+ public String getMessage() { return message; }
181
+ public void setMessage(String message) { this.message = message; }
182
+ }
183
+
184
+ // Main method for testing
185
+ public static void main(String[] args) {
186
+ try {
187
+ GrubtechOrderStatusService service = new GrubtechOrderStatusService();
188
+
189
+ String orderId = "{{ORDER_ID}}";
190
+ OrderStatus newStatus = OrderStatus.PREPARING; // Change to {{NEW_STATUS}}
191
+
192
+ // Single status update
193
+ service.updateOrderStatus(orderId, newStatus, "Status update from POS");
194
+
195
+ // Or run through full workflow
196
+ // service.orderWorkflowExample(orderId);
197
+
198
+ } catch (Exception e) {
199
+ System.exit(1);
200
+ }
201
+ }
202
+ }
@@ -0,0 +1,142 @@
1
+ """
2
+ Grubtech Order Status Update - Python
3
+
4
+ This example demonstrates how to update order status in Grubtech.
5
+
6
+ Prerequisites:
7
+ - Python 3.8+
8
+ - requests library (pip install requests)
9
+ - Valid access token from authentication
10
+
11
+ Replace the following placeholders:
12
+ - {{AUTH_TOKEN}}: Access token from authentication step
13
+ - {{ORDER_ID}}: The Grubtech order ID to update
14
+ - {{NEW_STATUS}}: The new status value
15
+ """
16
+
17
+ import requests
18
+ import sys
19
+ from datetime import datetime
20
+ from enum import Enum
21
+ from typing import Dict, Any, Optional
22
+
23
+ AUTH_TOKEN = '{{AUTH_TOKEN}}'
24
+ BASE_URL = 'https://api.grubtech.io'
25
+
26
+
27
+ class OrderStatus(Enum):
28
+ """Valid order status values"""
29
+ ACCEPTED = 'accepted'
30
+ PREPARING = 'preparing'
31
+ READY = 'ready'
32
+ DELIVERED = 'delivered'
33
+ CANCELLED = 'cancelled'
34
+
35
+
36
+ def update_order_status(
37
+ order_id: str,
38
+ new_status: OrderStatus,
39
+ notes: Optional[str] = None
40
+ ) -> Dict[str, Any]:
41
+ """
42
+ Update order status in Grubtech
43
+
44
+ Args:
45
+ order_id: The Grubtech order ID
46
+ new_status: The new status value
47
+ notes: Optional notes about the status change
48
+
49
+ Returns:
50
+ Dict: Response from API
51
+
52
+ Raises:
53
+ Exception: If status update fails
54
+ """
55
+ try:
56
+ # Construct status update payload
57
+ payload = {
58
+ 'orderId': order_id,
59
+ 'status': new_status.value,
60
+ 'timestamp': datetime.utcnow().isoformat() + 'Z',
61
+ }
62
+
63
+ if notes:
64
+ payload['notes'] = notes
65
+
66
+ print(f'Updating order {order_id} to status: {new_status.value}')
67
+
68
+ # Make status update request
69
+ url = f'{BASE_URL}/v1/orders/{order_id}/status'
70
+ headers = {
71
+ 'Authorization': f'Bearer {AUTH_TOKEN}',
72
+ 'Content-Type': 'application/json',
73
+ }
74
+
75
+ response = requests.put(url, json=payload, headers=headers, timeout=10)
76
+
77
+ # Check for errors
78
+ if not response.ok:
79
+ raise Exception(
80
+ f'Status update failed: {response.status_code} - {response.text}'
81
+ )
82
+
83
+ # Parse response
84
+ data = response.json()
85
+
86
+ print(f'✅ Order status updated successfully!')
87
+ print(f'Order ID: {data["orderId"]}')
88
+ print(f'New Status: {data["status"]}')
89
+ print(f'Updated At: {data["updatedAt"]}')
90
+
91
+ return data
92
+
93
+ except requests.RequestException as e:
94
+ print(f'❌ Status update error: {e}', file=sys.stderr)
95
+ raise
96
+ except Exception as e:
97
+ print(f'❌ Unexpected error: {e}', file=sys.stderr)
98
+ raise
99
+
100
+
101
+ def order_workflow_example(order_id: str) -> None:
102
+ """
103
+ Example: Update order through typical workflow
104
+
105
+ Args:
106
+ order_id: The Grubtech order ID
107
+ """
108
+ try:
109
+ # Step 1: Accept the order
110
+ update_order_status(order_id, OrderStatus.ACCEPTED, 'Order confirmed')
111
+
112
+ # Step 2: Start preparing
113
+ update_order_status(order_id, OrderStatus.PREPARING, 'Chef started cooking')
114
+
115
+ # Step 3: Mark as ready
116
+ update_order_status(order_id, OrderStatus.READY, 'Order ready for pickup')
117
+
118
+ # Step 4: Mark as delivered
119
+ update_order_status(order_id, OrderStatus.DELIVERED, 'Order delivered to customer')
120
+
121
+ print('✅ Order workflow completed!')
122
+
123
+ except Exception as e:
124
+ print(f'❌ Workflow error: {e}', file=sys.stderr)
125
+
126
+ # If something goes wrong, cancel the order
127
+ update_order_status(order_id, OrderStatus.CANCELLED, 'Unable to fulfill order')
128
+
129
+
130
+ if __name__ == '__main__':
131
+ try:
132
+ order_id = '{{ORDER_ID}}'
133
+ new_status = OrderStatus.PREPARING # Change to {{NEW_STATUS}}
134
+
135
+ # Single status update
136
+ update_order_status(order_id, new_status, 'Status update from POS')
137
+
138
+ # Or run through full workflow
139
+ # order_workflow_example(order_id)
140
+
141
+ except Exception as e:
142
+ sys.exit(1)
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Grubtech Order Status Update - TypeScript
3
+ *
4
+ * This example demonstrates how to update order status in Grubtech.
5
+ *
6
+ * Prerequisites:
7
+ * - Node.js 18+ with fetch API
8
+ * - Valid access token from authentication
9
+ *
10
+ * Replace the following placeholders:
11
+ * - {{AUTH_TOKEN}}: Access token from authentication step
12
+ * - {{ORDER_ID}}: The Grubtech order ID to update
13
+ * - {{NEW_STATUS}}: The new status value
14
+ */
15
+
16
+ const AUTH_TOKEN = '{{AUTH_TOKEN}}';
17
+ const BASE_URL = 'https://api.grubtech.io';
18
+
19
+ enum OrderStatus {
20
+ ACCEPTED = 'accepted',
21
+ PREPARING = 'preparing',
22
+ READY = 'ready',
23
+ DELIVERED = 'delivered',
24
+ CANCELLED = 'cancelled',
25
+ }
26
+
27
+ interface StatusUpdatePayload {
28
+ orderId: string;
29
+ status: OrderStatus;
30
+ timestamp: string;
31
+ notes?: string;
32
+ }
33
+
34
+ interface StatusUpdateResponse {
35
+ success: boolean;
36
+ orderId: string;
37
+ status: string;
38
+ updatedAt: string;
39
+ message?: string;
40
+ }
41
+
42
+ /**
43
+ * Update order status in Grubtech
44
+ */
45
+ async function updateOrderStatus(
46
+ orderId: string,
47
+ newStatus: OrderStatus,
48
+ notes?: string
49
+ ): Promise<StatusUpdateResponse> {
50
+ try {
51
+ // Validate status value
52
+ if (!Object.values(OrderStatus).includes(newStatus)) {
53
+ throw new Error(`Invalid status: ${newStatus}`);
54
+ }
55
+
56
+ // Construct status update payload
57
+ const payload: StatusUpdatePayload = {
58
+ orderId,
59
+ status: newStatus,
60
+ timestamp: new Date().toISOString(),
61
+ notes,
62
+ };
63
+
64
+ console.log(`Updating order ${orderId} to status: ${newStatus}`);
65
+
66
+ // Make status update request
67
+ const response = await fetch(`${BASE_URL}/v1/orders/${orderId}/status`, {
68
+ method: 'PUT',
69
+ headers: {
70
+ 'Authorization': `Bearer ${AUTH_TOKEN}`,
71
+ 'Content-Type': 'application/json',
72
+ },
73
+ body: JSON.stringify(payload),
74
+ });
75
+
76
+ // Check for errors
77
+ if (!response.ok) {
78
+ const errorBody = await response.text();
79
+ throw new Error(
80
+ `Status update failed: ${response.status} - ${errorBody}`
81
+ );
82
+ }
83
+
84
+ // Parse response
85
+ const data: StatusUpdateResponse = await response.json();
86
+
87
+ console.log('✅ Order status updated successfully!');
88
+ console.log(`Order ID: ${data.orderId}`);
89
+ console.log(`New Status: ${data.status}`);
90
+ console.log(`Updated At: ${data.updatedAt}`);
91
+
92
+ return data;
93
+ } catch (error) {
94
+ console.error('❌ Status update error:', error);
95
+ throw error;
96
+ }
97
+ }
98
+
99
+ /**
100
+ * Example: Update order through typical workflow
101
+ */
102
+ async function orderWorkflowExample(orderId: string) {
103
+ try {
104
+ // Step 1: Accept the order
105
+ await updateOrderStatus(orderId, OrderStatus.ACCEPTED, 'Order confirmed');
106
+
107
+ // Step 2: Start preparing
108
+ await updateOrderStatus(orderId, OrderStatus.PREPARING, 'Chef started cooking');
109
+
110
+ // Step 3: Mark as ready
111
+ await updateOrderStatus(orderId, OrderStatus.READY, 'Order ready for pickup');
112
+
113
+ // Step 4: Mark as delivered (or picked up)
114
+ await updateOrderStatus(orderId, OrderStatus.DELIVERED, 'Order delivered to customer');
115
+
116
+ console.log('✅ Order workflow completed!');
117
+ } catch (error) {
118
+ console.error('❌ Workflow error:', error);
119
+
120
+ // If something goes wrong, cancel the order
121
+ await updateOrderStatus(orderId, OrderStatus.CANCELLED, 'Unable to fulfill order');
122
+ }
123
+ }
124
+
125
+ // Main execution
126
+ (async () => {
127
+ try {
128
+ const orderId = '{{ORDER_ID}}';
129
+ const newStatus = OrderStatus.PREPARING; // Change this to {{NEW_STATUS}}
130
+
131
+ // Single status update
132
+ await updateOrderStatus(orderId, newStatus, 'Status update from POS');
133
+
134
+ // Or run through full workflow
135
+ // await orderWorkflowExample(orderId);
136
+ } catch (error) {
137
+ process.exit(1);
138
+ }
139
+ })();