forked from aws/aws-toolkit-vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschemaCodeLangs.ts
More file actions
77 lines (66 loc) · 2.2 KB
/
schemaCodeLangs.ts
File metadata and controls
77 lines (66 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
import { Runtime } from '@aws-sdk/client-lambda'
import { Set as ImmutableSet } from 'immutable'
import { goRuntimes } from '../../lambda/models/samLambdaRuntime'
export const JAVA = 'Java 8+' // eslint-disable-line @typescript-eslint/naming-convention
export const PYTHON = 'Python 3.6+' // eslint-disable-line @typescript-eslint/naming-convention
export const TYPESCRIPT = 'Typescript 3+' // eslint-disable-line @typescript-eslint/naming-convention
export const GO = 'Go 1+' // eslint-disable-line @typescript-eslint/naming-convention
export type SchemaCodeLangs = 'Java 8+' | 'Python 3.6+' | 'Typescript 3+' | 'Go 1+'
export const schemaCodeLangs: ImmutableSet<SchemaCodeLangs> = ImmutableSet([JAVA, PYTHON, TYPESCRIPT, GO])
const javaDetail = {
apiValue: 'Java8',
extension: '.java',
}
const pythonDetail = {
apiValue: 'Python36',
extension: '.py',
}
const typescriptDetail = {
apiValue: 'TypeScript3',
extension: '.ts',
}
const goDetail = {
apiValue: 'Go1',
extension: '.go',
}
export function getLanguageDetails(language: SchemaCodeLangs): {
apiValue: string
extension: string
} {
switch (language) {
case JAVA:
return javaDetail
case PYTHON:
return pythonDetail
case TYPESCRIPT:
return typescriptDetail
case GO:
return goDetail
default:
throw new Error(`Language ${language} is not supported as Schema Code Language`)
}
}
export function supportsEventBridgeTemplates(runtime: Runtime): boolean {
return [
'python3.7',
'python3.8',
'python3.9',
'python3.10',
'python3.11',
'python3.12',
'python3.13',
'python3.14',
'go1.x',
].includes(runtime)
}
export function getApiValueForSchemasDownload(runtime: Runtime): string {
if (supportsEventBridgeTemplates(runtime)) {
// Python36 really means python3.x for schema downloading
return goRuntimes.has(runtime) ? 'Go1' : 'Python36'
}
throw new Error(`Runtime ${runtime} is not supported by eventBridge application`)
}