@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,155 @@
1
+ /**
2
+ * @description Grubtech API Authentication - Java (Spring Boot)
3
+ * @author Grubtech Integration Team
4
+ * @version 1.0.0
5
+ *
6
+ * This example demonstrates how to authenticate with the Grubtech API
7
+ * using an API key to obtain an access token.
8
+ *
9
+ * Prerequisites:
10
+ * - Java 17+
11
+ * - Spring Boot 3.x
12
+ * - Spring WebFlux (for WebClient)
13
+ *
14
+ * Dependencies (Maven):
15
+ * <dependency>
16
+ * <groupId>org.springframework.boot</groupId>
17
+ * <artifactId>spring-boot-starter-webflux</artifactId>
18
+ * </dependency>
19
+ *
20
+ * Replace the following placeholders:
21
+ * - {{API_KEY}}: Your Grubtech API key
22
+ * - {{PARTNER_ID}}: Your partner identifier
23
+ */
24
+
25
+ package com.example.grubtech;
26
+
27
+ import org.springframework.http.HttpHeaders;
28
+ import org.springframework.http.MediaType;
29
+ import org.springframework.web.reactive.function.client.WebClient;
30
+ import reactor.core.publisher.Mono;
31
+
32
+ import java.util.HashMap;
33
+ import java.util.Map;
34
+
35
+ public class GrubtechAuthentication {
36
+
37
+ private static final String API_KEY = "{{API_KEY}}";
38
+ private static final String PARTNER_ID = "{{PARTNER_ID}}";
39
+ private static final String BASE_URL = "https://api.grubtech.io";
40
+
41
+ private final WebClient webClient;
42
+
43
+ public GrubtechAuthentication() {
44
+ this.webClient = WebClient.builder()
45
+ .baseUrl(BASE_URL)
46
+ .build();
47
+ }
48
+
49
+ /**
50
+ * Authenticate with Grubtech API and obtain access token
51
+ *
52
+ * @return Access token for API requests
53
+ * @throws RuntimeException if authentication fails
54
+ */
55
+ public String authenticate() {
56
+ try {
57
+ // Construct authentication request body
58
+ Map<String, String> requestBody = new HashMap<>();
59
+ requestBody.put("partnerId", PARTNER_ID);
60
+ requestBody.put("grantType", "api_key");
61
+
62
+ // Make authentication request
63
+ AuthResponse response = webClient.post()
64
+ .uri("/v1/auth/token")
65
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
66
+ .header("x-api-key", API_KEY)
67
+ .bodyValue(requestBody)
68
+ .retrieve()
69
+ .onStatus(
70
+ status -> !status.is2xxSuccessful(),
71
+ clientResponse -> clientResponse.bodyToMono(String.class)
72
+ .flatMap(errorBody -> Mono.error(
73
+ new RuntimeException(
74
+ "Authentication failed: " +
75
+ clientResponse.statusCode() +
76
+ " - " + errorBody
77
+ )
78
+ ))
79
+ )
80
+ .bodyToMono(AuthResponse.class)
81
+ .block();
82
+
83
+ if (response == null || response.getToken() == null) {
84
+ throw new RuntimeException("No token received from authentication");
85
+ }
86
+
87
+ System.out.println("Authentication successful!");
88
+ System.out.println("Token expires in: " + response.getExpiresIn() + " seconds");
89
+
90
+ return response.getToken();
91
+
92
+ } catch (Exception e) {
93
+ System.err.println("Authentication error: " + e.getMessage());
94
+ throw e;
95
+ }
96
+ }
97
+
98
+ /**
99
+ * Example: Use token in subsequent API requests
100
+ *
101
+ * @param token Access token from authenticate()
102
+ * @return API response
103
+ */
104
+ public Map<String, Object> exampleApiCall(String token) {
105
+ return webClient.get()
106
+ .uri("/v1/menus")
107
+ .header(HttpHeaders.AUTHORIZATION, "Bearer " + token)
108
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
109
+ .retrieve()
110
+ .onStatus(
111
+ status -> !status.is2xxSuccessful(),
112
+ clientResponse -> Mono.error(
113
+ new RuntimeException("API call failed: " + clientResponse.statusCode())
114
+ )
115
+ )
116
+ .bodyToMono(Map.class)
117
+ .block();
118
+ }
119
+
120
+ /**
121
+ * Response model for authentication endpoint
122
+ */
123
+ public static class AuthResponse {
124
+ private String token;
125
+ private int expiresIn;
126
+ private String tokenType;
127
+
128
+ // Getters and setters
129
+ public String getToken() { return token; }
130
+ public void setToken(String token) { this.token = token; }
131
+
132
+ public int getExpiresIn() { return expiresIn; }
133
+ public void setExpiresIn(int expiresIn) { this.expiresIn = expiresIn; }
134
+
135
+ public String getTokenType() { return tokenType; }
136
+ public void setTokenType(String tokenType) { this.tokenType = tokenType; }
137
+ }
138
+
139
+ // Main method for testing
140
+ public static void main(String[] args) {
141
+ try {
142
+ GrubtechAuthentication auth = new GrubtechAuthentication();
143
+
144
+ // Authenticate and get token
145
+ String token = auth.authenticate();
146
+
147
+ // Use token for API calls
148
+ Map<String, Object> menus = auth.exampleApiCall(token);
149
+ System.out.println("Menus: " + menus);
150
+
151
+ } catch (Exception e) {
152
+ System.exit(1);
153
+ }
154
+ }
155
+ }
@@ -0,0 +1,111 @@
1
+ """
2
+ @description Grubtech API Authentication - Python
3
+ @author Grubtech Integration Team
4
+ @version 1.0.0
5
+
6
+ This example demonstrates how to authenticate with the Grubtech API
7
+ using an API key to obtain an access token.
8
+
9
+ Prerequisites:
10
+ - Python 3.8+
11
+ - requests library (pip install requests)
12
+ - Valid Grubtech API key
13
+
14
+ Replace the following placeholders:
15
+ - {{API_KEY}}: Your Grubtech API key
16
+ - {{PARTNER_ID}}: Your partner identifier
17
+ """
18
+
19
+ import requests
20
+ import sys
21
+ from typing import Dict, Any
22
+
23
+ API_KEY = '{{API_KEY}}'
24
+ PARTNER_ID = '{{PARTNER_ID}}'
25
+ BASE_URL = 'https://api.grubtech.io'
26
+
27
+
28
+ def authenticate() -> str:
29
+ """
30
+ Authenticate with Grubtech API and obtain access token
31
+
32
+ Returns:
33
+ str: Access token for API requests
34
+
35
+ Raises:
36
+ Exception: If authentication fails
37
+ """
38
+ try:
39
+ # Construct authentication request
40
+ url = f'{BASE_URL}/v1/auth/token'
41
+ headers = {
42
+ 'Content-Type': 'application/json',
43
+ 'x-api-key': API_KEY,
44
+ }
45
+ payload = {
46
+ 'partnerId': PARTNER_ID,
47
+ 'grantType': 'api_key',
48
+ }
49
+
50
+ # Make authentication request
51
+ response = requests.post(url, json=payload, headers=headers, timeout=10)
52
+
53
+ # Check for errors
54
+ if not response.ok:
55
+ raise Exception(
56
+ f'Authentication failed: {response.status_code} - {response.text}'
57
+ )
58
+
59
+ # Extract token from response
60
+ data: Dict[str, Any] = response.json()
61
+ token = data['token']
62
+ expires_in = data.get('expiresIn', 'unknown')
63
+
64
+ print(f'Authentication successful!')
65
+ print(f'Token expires in: {expires_in} seconds')
66
+
67
+ return token
68
+
69
+ except requests.RequestException as e:
70
+ print(f'Authentication error: {e}', file=sys.stderr)
71
+ raise
72
+ except Exception as e:
73
+ print(f'Unexpected error: {e}', file=sys.stderr)
74
+ raise
75
+
76
+
77
+ def example_api_call(token: str) -> Dict[str, Any]:
78
+ """
79
+ Example: Use token in subsequent API requests
80
+
81
+ Args:
82
+ token: Access token from authenticate()
83
+
84
+ Returns:
85
+ API response data
86
+ """
87
+ url = f'{BASE_URL}/v1/menus'
88
+ headers = {
89
+ 'Authorization': f'Bearer {token}',
90
+ 'Content-Type': 'application/json',
91
+ }
92
+
93
+ response = requests.get(url, headers=headers, timeout=10)
94
+
95
+ if not response.ok:
96
+ raise Exception(f'API call failed: {response.status_code}')
97
+
98
+ return response.json()
99
+
100
+
101
+ if __name__ == '__main__':
102
+ try:
103
+ # Authenticate and get token
104
+ access_token = authenticate()
105
+
106
+ # Use token for API calls
107
+ menus = example_api_call(access_token)
108
+ print(f'Menus: {menus}')
109
+
110
+ except Exception as e:
111
+ sys.exit(1)
@@ -0,0 +1,98 @@
1
+ /**
2
+ * @description Grubtech API Authentication - TypeScript
3
+ * @author Grubtech Integration Team
4
+ * @version 1.0.0
5
+ *
6
+ * This example demonstrates how to authenticate with the Grubtech API
7
+ * using an API key to obtain an access token.
8
+ *
9
+ * Prerequisites:
10
+ * - Node.js 18+ with fetch API support
11
+ * - Valid Grubtech API key
12
+ *
13
+ * Replace the following placeholders:
14
+ * - {{API_KEY}}: Your Grubtech API key
15
+ * - {{PARTNER_ID}}: Your partner identifier
16
+ */
17
+
18
+ const API_KEY = '{{API_KEY}}';
19
+ const PARTNER_ID = '{{PARTNER_ID}}';
20
+ const BASE_URL = 'https://api.grubtech.io';
21
+
22
+ interface AuthResponse {
23
+ token: string;
24
+ expiresIn: number;
25
+ tokenType: string;
26
+ }
27
+
28
+ /**
29
+ * Authenticate with Grubtech API and obtain access token
30
+ */
31
+ async function authenticate(): Promise<string> {
32
+ try {
33
+ // Construct authentication request
34
+ const response = await fetch(`${BASE_URL}/v1/auth/token`, {
35
+ method: 'POST',
36
+ headers: {
37
+ 'Content-Type': 'application/json',
38
+ 'x-api-key': API_KEY,
39
+ },
40
+ body: JSON.stringify({
41
+ partnerId: PARTNER_ID,
42
+ grantType: 'api_key',
43
+ }),
44
+ });
45
+
46
+ // Check for errors
47
+ if (!response.ok) {
48
+ const errorBody = await response.text();
49
+ throw new Error(
50
+ `Authentication failed: ${response.status} - ${errorBody}`
51
+ );
52
+ }
53
+
54
+ // Extract token from response
55
+ const data: AuthResponse = await response.json();
56
+ const token = data.token;
57
+
58
+ console.log('Authentication successful!');
59
+ console.log(`Token expires in: ${data.expiresIn} seconds`);
60
+
61
+ return token;
62
+ } catch (error) {
63
+ console.error('Authentication error:', error);
64
+ throw error;
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Example: Use token in subsequent API requests
70
+ */
71
+ async function exampleApiCall(token: string) {
72
+ const response = await fetch(`${BASE_URL}/v1/menus`, {
73
+ method: 'GET',
74
+ headers: {
75
+ 'Authorization': `Bearer ${token}`,
76
+ 'Content-Type': 'application/json',
77
+ },
78
+ });
79
+
80
+ if (!response.ok) {
81
+ throw new Error(`API call failed: ${response.status}`);
82
+ }
83
+
84
+ return response.json();
85
+ }
86
+
87
+ // Main execution
88
+ (async () => {
89
+ try {
90
+ const token = await authenticate();
91
+
92
+ // Use token for API calls
93
+ const menus = await exampleApiCall(token);
94
+ console.log('Menus:', menus);
95
+ } catch (error) {
96
+ process.exit(1);
97
+ }
98
+ })();
@@ -0,0 +1,145 @@
1
+ #!/bin/bash
2
+
3
+ # Grubtech Menu Sync - cURL
4
+ #
5
+ # This example demonstrates how to push menu data to Grubtech API.
6
+ #
7
+ # Prerequisites:
8
+ # - curl command-line tool
9
+ # - jq (for JSON parsing, optional)
10
+ # - Valid access token from authentication
11
+ #
12
+ # Replace the following placeholders:
13
+ # - {{AUTH_TOKEN}}: Access token from authentication step
14
+ # - {{MENU_DATA}}: Your menu data in the required format
15
+
16
+ AUTH_TOKEN="{{AUTH_TOKEN}}"
17
+ BASE_URL="https://api.grubtech.io"
18
+
19
+ # Example menu data (replace with your actual menu)
20
+ MENU_DATA='{
21
+ "name": "Restaurant Menu",
22
+ "description": "Main menu with categories and items",
23
+ "categories": [
24
+ {
25
+ "id": "cat-1",
26
+ "name": "Appetizers",
27
+ "description": "Start your meal right",
28
+ "sortOrder": 1,
29
+ "items": [
30
+ {
31
+ "id": "item-1",
32
+ "name": "Spring Rolls",
33
+ "description": "Crispy vegetable spring rolls",
34
+ "price": 8.99,
35
+ "available": true,
36
+ "modifiers": [
37
+ {
38
+ "id": "mod-1",
39
+ "name": "Extra Sauce",
40
+ "price": 1.50,
41
+ "available": true
42
+ }
43
+ ]
44
+ }
45
+ ]
46
+ },
47
+ {
48
+ "id": "cat-2",
49
+ "name": "Main Courses",
50
+ "description": "Delicious entrees",
51
+ "sortOrder": 2,
52
+ "items": [
53
+ {
54
+ "id": "item-2",
55
+ "name": "Grilled Chicken",
56
+ "description": "Tender chicken with herbs",
57
+ "price": 15.99,
58
+ "available": true,
59
+ "modifiers": []
60
+ }
61
+ ]
62
+ }
63
+ ]
64
+ }'
65
+
66
+ # Push menu data to Grubtech API
67
+ create_menu() {
68
+ echo "Creating menu in Grubtech..."
69
+
70
+ # Make menu creation request
71
+ RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
72
+ "${BASE_URL}/v1/menus" \
73
+ -H "Authorization: Bearer ${AUTH_TOKEN}" \
74
+ -H "Content-Type: application/json" \
75
+ -d "${MENU_DATA}")
76
+
77
+ # Extract HTTP status code and body
78
+ HTTP_CODE=$(echo "$RESPONSE" | tail -n 1)
79
+ BODY=$(echo "$RESPONSE" | sed '$d')
80
+
81
+ # Check for errors
82
+ if [ "$HTTP_CODE" -ne 200 ] && [ "$HTTP_CODE" -ne 201 ]; then
83
+ echo "❌ Menu creation failed: HTTP $HTTP_CODE"
84
+ echo "Response: $BODY"
85
+ return 1
86
+ fi
87
+
88
+ # Extract menu ID from response
89
+ if command -v jq &> /dev/null; then
90
+ MENU_ID=$(echo "$BODY" | jq -r '.menuId')
91
+ STATUS=$(echo "$BODY" | jq -r '.status')
92
+
93
+ echo "✅ Menu created successfully!"
94
+ echo "Menu ID: ${MENU_ID}"
95
+ echo "Status: ${STATUS}"
96
+ else
97
+ # Fallback: manual parsing
98
+ MENU_ID=$(echo "$BODY" | grep -o '"menuId":"[^"]*' | cut -d'"' -f4)
99
+ echo "✅ Menu created successfully!"
100
+ echo "Menu ID: ${MENU_ID}"
101
+ echo "Note: Install jq for better JSON parsing"
102
+ fi
103
+
104
+ echo "$MENU_ID"
105
+ }
106
+
107
+ # Update existing menu
108
+ update_menu() {
109
+ local MENU_ID=$1
110
+
111
+ echo "Updating menu ${MENU_ID}..."
112
+
113
+ curl -s -X PUT \
114
+ "${BASE_URL}/v1/menus/${MENU_ID}" \
115
+ -H "Authorization: Bearer ${AUTH_TOKEN}" \
116
+ -H "Content-Type: application/json" \
117
+ -d "${MENU_DATA}"
118
+
119
+ if [ $? -eq 0 ]; then
120
+ echo "✅ Menu updated successfully!"
121
+ else
122
+ echo "❌ Menu update failed"
123
+ return 1
124
+ fi
125
+ }
126
+
127
+ # Main execution
128
+ main() {
129
+ # Create menu
130
+ MENU_ID=$(create_menu)
131
+
132
+ if [ -z "$MENU_ID" ]; then
133
+ echo "Failed to create menu"
134
+ exit 1
135
+ fi
136
+
137
+ echo ""
138
+ echo "Menu created with ID: ${MENU_ID}"
139
+
140
+ # Optionally update the menu
141
+ # update_menu "$MENU_ID"
142
+ }
143
+
144
+ # Run main function
145
+ main