@johnlwin-test/create-repro 0.1.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.
- package/LICENSE +175 -0
- package/README.md +116 -0
- package/package.json +33 -0
- package/src/cli.js +308 -0
- package/src/operations.js +268 -0
- package/src/regions.js +235 -0
- package/src/sdks/java/generate.js +79 -0
- package/src/sdks/java/templates/LOG.md +0 -0
- package/src/sdks/java/templates/Main.java +24 -0
- package/src/sdks/java/templates/README.md +14 -0
- package/src/sdks/java/templates/pom.xml +61 -0
- package/src/sdks/java/utils/maven.js +24 -0
- package/src/sdks/javascript/environments/browser/generate.js +208 -0
- package/src/sdks/javascript/environments/browser/templates/index.html +27 -0
- package/src/sdks/javascript/environments/browser/templates/index.js +62 -0
- package/src/sdks/javascript/environments/node/generate.js +55 -0
- package/src/sdks/javascript/environments/node/templates/index.js +12 -0
- package/src/sdks/javascript/environments/react-native/generate.js +286 -0
- package/src/sdks/javascript/environments/react-native/templates/App.js +147 -0
- package/src/services.js +310 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Button, StyleSheet, View, Text, TextInput, ScrollView } from 'react-native';
|
|
3
|
+
|
|
4
|
+
// React Native polyfills required for AWS SDK for JavaScript
|
|
5
|
+
import 'react-native-get-random-values';
|
|
6
|
+
import 'react-native-url-polyfill/auto';
|
|
7
|
+
import 'web-streams-polyfill/polyfill';
|
|
8
|
+
|
|
9
|
+
import { {{serviceClient}}, {{operationCommand}} } from '{{service}}';
|
|
10
|
+
import { fromCognitoIdentityPool } from '@aws-sdk/credential-provider-cognito-identity';
|
|
11
|
+
import { CognitoIdentityClient } from '@aws-sdk/client-cognito-identity';
|
|
12
|
+
|
|
13
|
+
// Configuration - Update these values
|
|
14
|
+
const REGION = 'REGION'; // e.g., 'us-east-1'
|
|
15
|
+
const IDENTITY_POOL_ID = 'IDENTITY_POOL_ID'; // e.g., 'us-east-1:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
|
|
16
|
+
|
|
17
|
+
// Validate configuration
|
|
18
|
+
const isConfigured = REGION !== 'REGION' && IDENTITY_POOL_ID !== 'IDENTITY_POOL_ID';
|
|
19
|
+
|
|
20
|
+
const App = () => {
|
|
21
|
+
const [response, setResponse] = useState('');
|
|
22
|
+
const [loading, setLoading] = useState(false);
|
|
23
|
+
|
|
24
|
+
const makeAwsCall = async () => {
|
|
25
|
+
if (!isConfigured) {
|
|
26
|
+
setResponse(
|
|
27
|
+
'Configuration Error: Please update REGION and IDENTITY_POOL_ID in App.js\n\n' +
|
|
28
|
+
'See COGNITO_SETUP.md for detailed setup instructions.'
|
|
29
|
+
);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
setLoading(true);
|
|
34
|
+
setResponse('Making AWS SDK call...');
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
const client = new {{serviceClient}}({
|
|
38
|
+
region: REGION,
|
|
39
|
+
credentials: fromCognitoIdentityPool({
|
|
40
|
+
client: new CognitoIdentityClient({
|
|
41
|
+
region: REGION,
|
|
42
|
+
}),
|
|
43
|
+
identityPoolId: IDENTITY_POOL_ID,
|
|
44
|
+
}),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const input = {}; // Add your input parameters here
|
|
48
|
+
const command = new {{operationCommand}}(input);
|
|
49
|
+
const result = await client.send(command);
|
|
50
|
+
|
|
51
|
+
setResponse(JSON.stringify(result, null, 2));
|
|
52
|
+
} catch (err) {
|
|
53
|
+
console.error(err);
|
|
54
|
+
|
|
55
|
+
// Provide helpful error messages
|
|
56
|
+
let errorMessage = `Error: ${err.message || err}\n\n`;
|
|
57
|
+
|
|
58
|
+
if (err.name === 'NotAuthorizedException' || err.name === 'AccessDeniedException') {
|
|
59
|
+
errorMessage += 'This error usually means the IAM role attached to your Cognito Identity Pool ' +
|
|
60
|
+
'does not have sufficient permissions.\n\n' +
|
|
61
|
+
'See COGNITO_SETUP.md for instructions on adding the required IAM policy.';
|
|
62
|
+
} else if (err.name === 'InvalidIdentityPoolConfigurationException') {
|
|
63
|
+
errorMessage += 'This error usually means the IDENTITY_POOL_ID or REGION is incorrect.\n\n' +
|
|
64
|
+
'See COGNITO_SETUP.md for setup instructions.';
|
|
65
|
+
} else {
|
|
66
|
+
errorMessage += 'Check the console for more details.';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
setResponse(errorMessage);
|
|
70
|
+
} finally {
|
|
71
|
+
setLoading(false);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<ScrollView style={styles.container}>
|
|
77
|
+
<View style={styles.sectionContainer}>
|
|
78
|
+
<Text style={styles.sectionTitle}>AWS SDK for JavaScript v3</Text>
|
|
79
|
+
<Text style={styles.serviceInfo}>Service: {{service}}</Text>
|
|
80
|
+
<Text style={styles.serviceInfo}>Operation: {{operation}}</Text>
|
|
81
|
+
|
|
82
|
+
<View style={styles.buttonContainer}>
|
|
83
|
+
<Button
|
|
84
|
+
title={loading ? "Loading..." : "Click to make a call"}
|
|
85
|
+
onPress={makeAwsCall}
|
|
86
|
+
disabled={loading}
|
|
87
|
+
/>
|
|
88
|
+
</View>
|
|
89
|
+
|
|
90
|
+
<Text style={styles.responseLabel}>Response:</Text>
|
|
91
|
+
<TextInput
|
|
92
|
+
style={styles.sectionDescription}
|
|
93
|
+
multiline={true}
|
|
94
|
+
editable={false}
|
|
95
|
+
placeholder="Response will be populated here"
|
|
96
|
+
value={response}
|
|
97
|
+
/>
|
|
98
|
+
</View>
|
|
99
|
+
</ScrollView>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const styles = StyleSheet.create({
|
|
104
|
+
container: {
|
|
105
|
+
flex: 1,
|
|
106
|
+
backgroundColor: '#ffffff',
|
|
107
|
+
},
|
|
108
|
+
sectionContainer: {
|
|
109
|
+
flex: 1,
|
|
110
|
+
padding: 16,
|
|
111
|
+
paddingTop: 50,
|
|
112
|
+
},
|
|
113
|
+
sectionTitle: {
|
|
114
|
+
fontSize: 20,
|
|
115
|
+
textAlign: 'center',
|
|
116
|
+
fontWeight: '600',
|
|
117
|
+
color: '#000000',
|
|
118
|
+
marginBottom: 8,
|
|
119
|
+
},
|
|
120
|
+
serviceInfo: {
|
|
121
|
+
fontSize: 14,
|
|
122
|
+
textAlign: 'center',
|
|
123
|
+
color: '#666666',
|
|
124
|
+
marginBottom: 4,
|
|
125
|
+
},
|
|
126
|
+
buttonContainer: {
|
|
127
|
+
marginVertical: 16,
|
|
128
|
+
},
|
|
129
|
+
responseLabel: {
|
|
130
|
+
fontSize: 16,
|
|
131
|
+
fontWeight: '600',
|
|
132
|
+
color: '#000000',
|
|
133
|
+
marginBottom: 8,
|
|
134
|
+
},
|
|
135
|
+
sectionDescription: {
|
|
136
|
+
minHeight: 300,
|
|
137
|
+
fontSize: 12,
|
|
138
|
+
fontWeight: '400',
|
|
139
|
+
color: '#4c4c4c',
|
|
140
|
+
backgroundColor: '#f0f0f0',
|
|
141
|
+
padding: 12,
|
|
142
|
+
borderRadius: 4,
|
|
143
|
+
fontFamily: 'Courier',
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
export default App;
|
package/src/services.js
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
// Comprehensive list of AWS SDK v3 JavaScript client packages
|
|
2
|
+
// This list includes the most commonly used AWS services
|
|
3
|
+
// For a complete list, see: https://github.com/aws/aws-sdk-js-v3/tree/main/clients
|
|
4
|
+
|
|
5
|
+
export const AWS_SERVICES = [
|
|
6
|
+
"@aws-sdk/client-s3",
|
|
7
|
+
"@aws-sdk/client-dynamodb",
|
|
8
|
+
"@aws-sdk/client-ec2",
|
|
9
|
+
"@aws-sdk/client-lambda",
|
|
10
|
+
"@aws-sdk/client-iam",
|
|
11
|
+
"@aws-sdk/client-cloudformation",
|
|
12
|
+
"@aws-sdk/client-cloudwatch",
|
|
13
|
+
"@aws-sdk/client-cloudwatch-logs",
|
|
14
|
+
"@aws-sdk/client-sns",
|
|
15
|
+
"@aws-sdk/client-sqs",
|
|
16
|
+
"@aws-sdk/client-rds",
|
|
17
|
+
"@aws-sdk/client-ecs",
|
|
18
|
+
"@aws-sdk/client-eks",
|
|
19
|
+
"@aws-sdk/client-elasticache",
|
|
20
|
+
"@aws-sdk/client-elastic-load-balancing-v2",
|
|
21
|
+
"@aws-sdk/client-route-53",
|
|
22
|
+
"@aws-sdk/client-api-gateway",
|
|
23
|
+
"@aws-sdk/client-apigatewayv2",
|
|
24
|
+
"@aws-sdk/client-cognito-identity",
|
|
25
|
+
"@aws-sdk/client-cognito-identity-provider",
|
|
26
|
+
"@aws-sdk/client-secrets-manager",
|
|
27
|
+
"@aws-sdk/client-ssm",
|
|
28
|
+
"@aws-sdk/client-kms",
|
|
29
|
+
"@aws-sdk/client-cloudfront",
|
|
30
|
+
"@aws-sdk/client-eventbridge",
|
|
31
|
+
"@aws-sdk/client-step-functions",
|
|
32
|
+
"@aws-sdk/client-kinesis",
|
|
33
|
+
"@aws-sdk/client-firehose",
|
|
34
|
+
"@aws-sdk/client-athena",
|
|
35
|
+
"@aws-sdk/client-glue",
|
|
36
|
+
"@aws-sdk/client-redshift",
|
|
37
|
+
"@aws-sdk/client-sagemaker",
|
|
38
|
+
"@aws-sdk/client-bedrock",
|
|
39
|
+
"@aws-sdk/client-bedrock-runtime",
|
|
40
|
+
"@aws-sdk/client-sts",
|
|
41
|
+
"@aws-sdk/client-organizations",
|
|
42
|
+
"@aws-sdk/client-cloudtrail",
|
|
43
|
+
"@aws-sdk/client-config-service",
|
|
44
|
+
"@aws-sdk/client-guardduty",
|
|
45
|
+
"@aws-sdk/client-inspector2",
|
|
46
|
+
"@aws-sdk/client-securityhub",
|
|
47
|
+
"@aws-sdk/client-waf",
|
|
48
|
+
"@aws-sdk/client-wafv2",
|
|
49
|
+
"@aws-sdk/client-shield",
|
|
50
|
+
"@aws-sdk/client-acm",
|
|
51
|
+
"@aws-sdk/client-certificate-manager",
|
|
52
|
+
"@aws-sdk/client-elastic-beanstalk",
|
|
53
|
+
"@aws-sdk/client-amplify",
|
|
54
|
+
"@aws-sdk/client-appsync",
|
|
55
|
+
"@aws-sdk/client-batch",
|
|
56
|
+
"@aws-sdk/client-codecommit",
|
|
57
|
+
"@aws-sdk/client-codebuild",
|
|
58
|
+
"@aws-sdk/client-codedeploy",
|
|
59
|
+
"@aws-sdk/client-codepipeline",
|
|
60
|
+
"@aws-sdk/client-codeartifact",
|
|
61
|
+
"@aws-sdk/client-ecr",
|
|
62
|
+
"@aws-sdk/client-efs",
|
|
63
|
+
"@aws-sdk/client-fsx",
|
|
64
|
+
"@aws-sdk/client-backup",
|
|
65
|
+
"@aws-sdk/client-glacier",
|
|
66
|
+
"@aws-sdk/client-storage-gateway",
|
|
67
|
+
"@aws-sdk/client-transfer",
|
|
68
|
+
"@aws-sdk/client-datasync",
|
|
69
|
+
"@aws-sdk/client-dms",
|
|
70
|
+
"@aws-sdk/client-application-auto-scaling",
|
|
71
|
+
"@aws-sdk/client-auto-scaling",
|
|
72
|
+
"@aws-sdk/client-elastic-load-balancing",
|
|
73
|
+
"@aws-sdk/client-vpc-lattice",
|
|
74
|
+
"@aws-sdk/client-app-mesh",
|
|
75
|
+
"@aws-sdk/client-cloud-map",
|
|
76
|
+
"@aws-sdk/client-service-discovery",
|
|
77
|
+
"@aws-sdk/client-xray",
|
|
78
|
+
"@aws-sdk/client-cloudwatch-events",
|
|
79
|
+
"@aws-sdk/client-scheduler",
|
|
80
|
+
"@aws-sdk/client-pipes",
|
|
81
|
+
"@aws-sdk/client-mq",
|
|
82
|
+
"@aws-sdk/client-kafka",
|
|
83
|
+
"@aws-sdk/client-kinesis-analytics",
|
|
84
|
+
"@aws-sdk/client-kinesis-video",
|
|
85
|
+
"@aws-sdk/client-mediaconvert",
|
|
86
|
+
"@aws-sdk/client-medialive",
|
|
87
|
+
"@aws-sdk/client-mediapackage",
|
|
88
|
+
"@aws-sdk/client-mediastore",
|
|
89
|
+
"@aws-sdk/client-transcribe",
|
|
90
|
+
"@aws-sdk/client-translate",
|
|
91
|
+
"@aws-sdk/client-polly",
|
|
92
|
+
"@aws-sdk/client-rekognition",
|
|
93
|
+
"@aws-sdk/client-textract",
|
|
94
|
+
"@aws-sdk/client-comprehend",
|
|
95
|
+
"@aws-sdk/client-lex-runtime-service",
|
|
96
|
+
"@aws-sdk/client-lex-models-v2",
|
|
97
|
+
"@aws-sdk/client-personalize",
|
|
98
|
+
"@aws-sdk/client-forecast",
|
|
99
|
+
"@aws-sdk/client-lookout-for-vision",
|
|
100
|
+
"@aws-sdk/client-iot",
|
|
101
|
+
"@aws-sdk/client-iot-data-plane",
|
|
102
|
+
"@aws-sdk/client-iot-events",
|
|
103
|
+
"@aws-sdk/client-iot-analytics",
|
|
104
|
+
"@aws-sdk/client-greengrass",
|
|
105
|
+
"@aws-sdk/client-timestream-write",
|
|
106
|
+
"@aws-sdk/client-timestream-query",
|
|
107
|
+
"@aws-sdk/client-neptune",
|
|
108
|
+
"@aws-sdk/client-docdb",
|
|
109
|
+
"@aws-sdk/client-elasticache",
|
|
110
|
+
"@aws-sdk/client-memorydb",
|
|
111
|
+
"@aws-sdk/client-keyspaces",
|
|
112
|
+
"@aws-sdk/client-qldb",
|
|
113
|
+
"@aws-sdk/client-cloudsearch",
|
|
114
|
+
"@aws-sdk/client-elasticsearch-service",
|
|
115
|
+
"@aws-sdk/client-opensearch",
|
|
116
|
+
"@aws-sdk/client-emr",
|
|
117
|
+
"@aws-sdk/client-emr-serverless",
|
|
118
|
+
"@aws-sdk/client-mwaa",
|
|
119
|
+
"@aws-sdk/client-databrew",
|
|
120
|
+
"@aws-sdk/client-quicksight",
|
|
121
|
+
"@aws-sdk/client-cost-explorer",
|
|
122
|
+
"@aws-sdk/client-budgets",
|
|
123
|
+
"@aws-sdk/client-pricing",
|
|
124
|
+
"@aws-sdk/client-marketplace-catalog",
|
|
125
|
+
"@aws-sdk/client-license-manager",
|
|
126
|
+
"@aws-sdk/client-service-catalog",
|
|
127
|
+
"@aws-sdk/client-resource-groups",
|
|
128
|
+
"@aws-sdk/client-resource-groups-tagging-api",
|
|
129
|
+
"@aws-sdk/client-ram",
|
|
130
|
+
"@aws-sdk/client-workspaces",
|
|
131
|
+
"@aws-sdk/client-appstream",
|
|
132
|
+
"@aws-sdk/client-workdocs",
|
|
133
|
+
"@aws-sdk/client-chime",
|
|
134
|
+
"@aws-sdk/client-connect",
|
|
135
|
+
"@aws-sdk/client-pinpoint",
|
|
136
|
+
"@aws-sdk/client-ses",
|
|
137
|
+
"@aws-sdk/client-sesv2",
|
|
138
|
+
"@aws-sdk/client-device-farm",
|
|
139
|
+
"@aws-sdk/client-mobile",
|
|
140
|
+
"@aws-sdk/client-gamelift",
|
|
141
|
+
"@aws-sdk/client-robomaker",
|
|
142
|
+
"@aws-sdk/client-ground-station",
|
|
143
|
+
"@aws-sdk/client-braket",
|
|
144
|
+
"@aws-sdk/client-honeycode",
|
|
145
|
+
"@aws-sdk/client-location",
|
|
146
|
+
"@aws-sdk/client-nimble",
|
|
147
|
+
"@aws-sdk/client-proton",
|
|
148
|
+
"@aws-sdk/client-wisdom",
|
|
149
|
+
"@aws-sdk/client-voice-id",
|
|
150
|
+
"@aws-sdk/client-panorama",
|
|
151
|
+
"@aws-sdk/client-cloudcontrol",
|
|
152
|
+
"@aws-sdk/client-account",
|
|
153
|
+
"@aws-sdk/client-amp",
|
|
154
|
+
"@aws-sdk/client-grafana",
|
|
155
|
+
"@aws-sdk/client-prometheus",
|
|
156
|
+
"@aws-sdk/client-rum",
|
|
157
|
+
"@aws-sdk/client-evidently",
|
|
158
|
+
"@aws-sdk/client-fis",
|
|
159
|
+
"@aws-sdk/client-resiliencehub",
|
|
160
|
+
"@aws-sdk/client-migration-hub",
|
|
161
|
+
"@aws-sdk/client-application-discovery-service",
|
|
162
|
+
"@aws-sdk/client-mgn",
|
|
163
|
+
"@aws-sdk/client-sms",
|
|
164
|
+
"@aws-sdk/client-snow-device-management",
|
|
165
|
+
"@aws-sdk/client-snowball",
|
|
166
|
+
"@aws-sdk/client-direct-connect",
|
|
167
|
+
"@aws-sdk/client-global-accelerator",
|
|
168
|
+
"@aws-sdk/client-network-firewall",
|
|
169
|
+
"@aws-sdk/client-network-manager",
|
|
170
|
+
"@aws-sdk/client-private-networks",
|
|
171
|
+
"@aws-sdk/client-vpc",
|
|
172
|
+
"@aws-sdk/client-lightsail",
|
|
173
|
+
"@aws-sdk/client-outposts",
|
|
174
|
+
"@aws-sdk/client-compute-optimizer",
|
|
175
|
+
"@aws-sdk/client-wellarchitected",
|
|
176
|
+
"@aws-sdk/client-controltower",
|
|
177
|
+
"@aws-sdk/client-sso",
|
|
178
|
+
"@aws-sdk/client-sso-admin",
|
|
179
|
+
"@aws-sdk/client-identitystore",
|
|
180
|
+
"@aws-sdk/client-directory-service",
|
|
181
|
+
"@aws-sdk/client-access-analyzer",
|
|
182
|
+
"@aws-sdk/client-audit-manager",
|
|
183
|
+
"@aws-sdk/client-detective",
|
|
184
|
+
"@aws-sdk/client-macie2",
|
|
185
|
+
"@aws-sdk/client-fms",
|
|
186
|
+
"@aws-sdk/client-health",
|
|
187
|
+
"@aws-sdk/client-support",
|
|
188
|
+
"@aws-sdk/client-trustedadvisor",
|
|
189
|
+
"@aws-sdk/client-service-quotas",
|
|
190
|
+
"@aws-sdk/client-pi",
|
|
191
|
+
"@aws-sdk/client-application-insights",
|
|
192
|
+
"@aws-sdk/client-synthetics",
|
|
193
|
+
"@aws-sdk/client-osis",
|
|
194
|
+
"@aws-sdk/client-oam",
|
|
195
|
+
"@aws-sdk/client-internetmonitor",
|
|
196
|
+
"@aws-sdk/client-cloudwatch-network-monitor",
|
|
197
|
+
];
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Validates if a service package name is in the known list
|
|
201
|
+
* @param {string} service - The service package name (e.g., "@aws-sdk/client-s3")
|
|
202
|
+
* @returns {boolean} - True if valid, false otherwise
|
|
203
|
+
*/
|
|
204
|
+
export function isValidService(service) {
|
|
205
|
+
return AWS_SERVICES.includes(service);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Calculate Levenshtein distance between two strings
|
|
210
|
+
* @param {string} a - First string
|
|
211
|
+
* @param {string} b - Second string
|
|
212
|
+
* @returns {number} - Edit distance
|
|
213
|
+
*/
|
|
214
|
+
function levenshteinDistance(a, b) {
|
|
215
|
+
const matrix = [];
|
|
216
|
+
|
|
217
|
+
for (let i = 0; i <= b.length; i++) {
|
|
218
|
+
matrix[i] = [i];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
for (let j = 0; j <= a.length; j++) {
|
|
222
|
+
matrix[0][j] = j;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
for (let i = 1; i <= b.length; i++) {
|
|
226
|
+
for (let j = 1; j <= a.length; j++) {
|
|
227
|
+
if (b.charAt(i - 1) === a.charAt(j - 1)) {
|
|
228
|
+
matrix[i][j] = matrix[i - 1][j - 1];
|
|
229
|
+
} else {
|
|
230
|
+
matrix[i][j] = Math.min(
|
|
231
|
+
matrix[i - 1][j - 1] + 1, // substitution
|
|
232
|
+
matrix[i][j - 1] + 1, // insertion
|
|
233
|
+
matrix[i - 1][j] + 1 // deletion
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return matrix[b.length][a.length];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Finds similar service names based on typos
|
|
244
|
+
* @param {string} service - The service package name to check
|
|
245
|
+
* @param {number} maxDistance - Maximum edit distance (default: 2)
|
|
246
|
+
* @returns {string[]} - Array of similar service names
|
|
247
|
+
*/
|
|
248
|
+
export function findSimilarServices(service, maxDistance = 2) {
|
|
249
|
+
// Extract just the service name part for comparison
|
|
250
|
+
const inputServiceName = service.replace("@aws-sdk/client-", "");
|
|
251
|
+
|
|
252
|
+
return AWS_SERVICES.filter(validService => {
|
|
253
|
+
const validServiceName = validService.replace("@aws-sdk/client-", "");
|
|
254
|
+
const distance = levenshteinDistance(inputServiceName, validServiceName);
|
|
255
|
+
return distance > 0 && distance <= maxDistance;
|
|
256
|
+
}).slice(0, 5); // Limit to top 5 suggestions
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Provides helpful error message for invalid services
|
|
261
|
+
* @param {string} service - The invalid service name
|
|
262
|
+
* @returns {string} - Error message with suggestions
|
|
263
|
+
*/
|
|
264
|
+
export function getServiceErrorMessage(service) {
|
|
265
|
+
// Check if it's missing the @aws-sdk/client- prefix
|
|
266
|
+
if (!service.startsWith("@aws-sdk/client-")) {
|
|
267
|
+
const withPrefix = `@aws-sdk/client-${service}`;
|
|
268
|
+
if (isValidService(withPrefix)) {
|
|
269
|
+
return `Did you mean: ${withPrefix}?`;
|
|
270
|
+
}
|
|
271
|
+
return `Service must start with "@aws-sdk/client-". Did you mean: ${withPrefix}?`;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Find similar services
|
|
275
|
+
const similar = findSimilarServices(service);
|
|
276
|
+
|
|
277
|
+
if (similar.length > 0) {
|
|
278
|
+
const suggestions = similar.map(s => getServiceDisplayName(s)).join(", ");
|
|
279
|
+
return `Service not found. Did you mean: ${suggestions}?`;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return "Service not found. Use format: @aws-sdk/client-<service-name>";
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Gets service name suggestions based on partial input
|
|
287
|
+
* @param {string} input - Partial service name
|
|
288
|
+
* @returns {string[]} - Array of matching service names
|
|
289
|
+
*/
|
|
290
|
+
export function getServiceSuggestions(input) {
|
|
291
|
+
if (!input) return AWS_SERVICES;
|
|
292
|
+
|
|
293
|
+
const lowerInput = input.toLowerCase();
|
|
294
|
+
return AWS_SERVICES.filter(service =>
|
|
295
|
+
service.toLowerCase().includes(lowerInput)
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Extracts the service display name from package name
|
|
301
|
+
* @param {string} packageName - Full package name (e.g., "@aws-sdk/client-s3")
|
|
302
|
+
* @returns {string} - Display name (e.g., "S3")
|
|
303
|
+
*/
|
|
304
|
+
export function getServiceDisplayName(packageName) {
|
|
305
|
+
return packageName
|
|
306
|
+
.replace("@aws-sdk/client-", "")
|
|
307
|
+
.split("-")
|
|
308
|
+
.map(word => word.toUpperCase())
|
|
309
|
+
.join(" ");
|
|
310
|
+
}
|