Skip to content

Commit b309fca

Browse files
chore: wip
1 parent 350892e commit b309fca

5 files changed

Lines changed: 53 additions & 105 deletions

File tree

bun.lock

Lines changed: 18 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/src/intrinsic-functions.ts

Lines changed: 32 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2,106 +2,68 @@
22
* CloudFormation Intrinsic Functions Helpers
33
*/
44

5-
export const Fn = {
6-
/**
7-
* Ref - Returns the value of the specified parameter or resource
8-
*/
9-
Ref: (logicalName: string): { Ref: string } => ({ Ref: logicalName }),
5+
export interface IntrinsicFunctions {
6+
Ref: (logicalName: string) => { Ref: string }
7+
GetAtt: (logicalName: string, attributeName: string) => { 'Fn::GetAtt': [string, string] }
8+
Sub: (template: string, variables?: Record<string, any>) => { 'Fn::Sub': string | [string, Record<string, any>] }
9+
Join: (delimiter: string, values: any[]) => { 'Fn::Join': [string, any[]] }
10+
Select: (index: number | string, list: any[]) => { 'Fn::Select': [number | string, any[]] }
11+
Split: (delimiter: string, source: string) => { 'Fn::Split': [string, string] }
12+
GetAZs: (region?: string) => { 'Fn::GetAZs': string }
13+
ImportValue: (name: string) => { 'Fn::ImportValue': string }
14+
If: (condition: string, trueValue: any, falseValue: any) => { 'Fn::If': [string, any, any] }
15+
Equals: (value1: any, value2: any) => { 'Fn::Equals': [any, any] }
16+
And: (...conditions: any[]) => { 'Fn::And': any[] }
17+
Or: (...conditions: any[]) => { 'Fn::Or': any[] }
18+
Not: (condition: any) => { 'Fn::Not': [any] }
19+
Base64: (input: string) => { 'Fn::Base64': string }
20+
}
1021

11-
/**
12-
* GetAtt - Returns the value of an attribute from a resource
13-
*/
14-
GetAtt: (logicalName: string, attributeName: string): { 'Fn::GetAtt': [string, string] } => ({
22+
export const Fn: IntrinsicFunctions = {
23+
Ref: (logicalName: string) => ({ Ref: logicalName }),
24+
GetAtt: (logicalName: string, attributeName: string) => ({
1525
'Fn::GetAtt': [logicalName, attributeName] as [string, string],
1626
}),
17-
18-
/**
19-
* Sub - Substitutes variables in an input string with values
20-
*/
21-
Sub: (template: string, variables?: Record<string, any>): { 'Fn::Sub': string | [string, Record<string, any>] } => {
27+
Sub: (template: string, variables?: Record<string, any>) => {
2228
if (variables) {
2329
return { 'Fn::Sub': [template, variables] as [string, Record<string, any>] }
2430
}
2531
return { 'Fn::Sub': template }
2632
},
27-
28-
/**
29-
* Join - Appends a set of values into a single value, separated by delimiter
30-
*/
31-
Join: (delimiter: string, values: any[]): { 'Fn::Join': [string, any[]] } => ({
33+
Join: (delimiter: string, values: any[]) => ({
3234
'Fn::Join': [delimiter, values] as [string, any[]],
3335
}),
34-
35-
/**
36-
* Select - Returns a single object from a list of objects by index
37-
*/
38-
Select: (index: number | string, list: any[]): { 'Fn::Select': [number | string, any[]] } => ({
36+
Select: (index: number | string, list: any[]) => ({
3937
'Fn::Select': [index, list] as [number | string, any[]],
4038
}),
41-
42-
/**
43-
* Split - Splits a string into a list of string values
44-
*/
45-
Split: (delimiter: string, source: string): { 'Fn::Split': [string, string] } => ({
39+
Split: (delimiter: string, source: string) => ({
4640
'Fn::Split': [delimiter, source] as [string, string],
4741
}),
48-
49-
/**
50-
* GetAZs - Returns an array of Availability Zones for a region
51-
*/
52-
GetAZs: (region: string = ''): { 'Fn::GetAZs': string } => ({
42+
GetAZs: (region: string = '') => ({
5343
'Fn::GetAZs': region,
5444
}),
55-
56-
/**
57-
* ImportValue - Returns the value of an output exported by another stack
58-
*/
59-
ImportValue: (name: string): { 'Fn::ImportValue': string } => ({
45+
ImportValue: (name: string) => ({
6046
'Fn::ImportValue': name,
6147
}),
62-
63-
/**
64-
* If - Returns one value if condition is true, another if false
65-
*/
66-
If: (condition: string, trueValue: any, falseValue: any): { 'Fn::If': [string, any, any] } => ({
48+
If: (condition: string, trueValue: any, falseValue: any) => ({
6749
'Fn::If': [condition, trueValue, falseValue] as [string, any, any],
6850
}),
69-
70-
/**
71-
* Equals - Compares if two values are equal
72-
*/
73-
Equals: (value1: any, value2: any): { 'Fn::Equals': [any, any] } => ({
51+
Equals: (value1: any, value2: any) => ({
7452
'Fn::Equals': [value1, value2] as [any, any],
7553
}),
76-
77-
/**
78-
* And - Returns true if all conditions are true
79-
*/
80-
And: (...conditions: any[]): { 'Fn::And': any[] } => ({
54+
And: (...conditions: any[]) => ({
8155
'Fn::And': conditions,
8256
}),
83-
84-
/**
85-
* Or - Returns true if any condition is true
86-
*/
87-
Or: (...conditions: any[]): { 'Fn::Or': any[] } => ({
57+
Or: (...conditions: any[]) => ({
8858
'Fn::Or': conditions,
8959
}),
90-
91-
/**
92-
* Not - Returns true if condition is false
93-
*/
94-
Not: (condition: any): { 'Fn::Not': [any] } => ({
60+
Not: (condition: any) => ({
9561
'Fn::Not': [condition] as [any],
9662
}),
97-
98-
/**
99-
* Base64 - Returns the Base64 representation of the input string
100-
*/
101-
Base64: (input: string): { 'Fn::Base64': string } => ({
63+
Base64: (input: string) => ({
10264
'Fn::Base64': input,
10365
}),
104-
} as const
66+
}
10567

10668
/**
10769
* Pseudo Parameters - AWS CloudFormation provides several built-in parameters

packages/core/tsconfig.tsbuildinfo

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

packages/ts-cloud/src/aws/dynamodb.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export class DynamoDBClient {
8484
throw new Error(`DynamoDB request failed: ${response.status} ${text}`)
8585
}
8686

87-
return response.json()
87+
return response.json() as Promise<T>
8888
}
8989

9090
return this.client.request({

packages/types/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export interface EnvironmentConfig {
9898
* Network/VPC configuration
9999
*/
100100
export interface NetworkConfig {
101+
cidr?: string
101102
vpc?: VpcConfig
102103
subnets?: {
103104
public?: number

0 commit comments

Comments
 (0)