@lafken/common 0.10.1 → 0.10.2
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/lib/types/resource.types.d.ts +252 -0
- package/package.json +1 -1
|
@@ -3,6 +3,248 @@ import type { ApiRestScopedNames, AuthScopedNames, BucketScopedNames, DynamoTabl
|
|
|
3
3
|
export interface ClassResource {
|
|
4
4
|
new (...args: any[]): {};
|
|
5
5
|
}
|
|
6
|
+
export interface TerraformToken {
|
|
7
|
+
/**
|
|
8
|
+
* Converts a Terraform token string into a list of strings.
|
|
9
|
+
*
|
|
10
|
+
* @param value - The Terraform token string to convert.
|
|
11
|
+
*/
|
|
12
|
+
asList: (value: string) => string[];
|
|
13
|
+
/**
|
|
14
|
+
* Converts a Terraform token string into a number.
|
|
15
|
+
*
|
|
16
|
+
* @param value - The Terraform token string to convert.
|
|
17
|
+
*/
|
|
18
|
+
asNumber: (value: string) => number;
|
|
19
|
+
/**
|
|
20
|
+
* Converts a Terraform token into a string representation.
|
|
21
|
+
*
|
|
22
|
+
* @param value - The Terraform token to convert.
|
|
23
|
+
*/
|
|
24
|
+
asString: (value: string) => string;
|
|
25
|
+
/**
|
|
26
|
+
* Checks whether a value is an unresolved Terraform token.
|
|
27
|
+
*
|
|
28
|
+
* @param value - The value to check.
|
|
29
|
+
*/
|
|
30
|
+
isUnresolved: (value: unknown) => boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface TerraformFn {
|
|
33
|
+
/** Returns the absolute value of the given number. */
|
|
34
|
+
abs(num: number): number;
|
|
35
|
+
/** Converts a filesystem path to an absolute path. */
|
|
36
|
+
abspath(path: string): string;
|
|
37
|
+
/** Decodes a Base64-encoded string. */
|
|
38
|
+
base64decode(str: string): string;
|
|
39
|
+
/** Encodes a string to Base64. */
|
|
40
|
+
base64encode(str: string): string;
|
|
41
|
+
/** Compresses a string with gzip and encodes the result in Base64. */
|
|
42
|
+
base64gzip(str: string): string;
|
|
43
|
+
/** Computes the SHA256 hash of a string and encodes it in Base64. */
|
|
44
|
+
base64sha256(str: string): string;
|
|
45
|
+
/** Computes the SHA512 hash of a string and encodes it in Base64. */
|
|
46
|
+
base64sha512(str: string): string;
|
|
47
|
+
/** Removes all except the last portion from a filesystem path. */
|
|
48
|
+
basename(path: string): string;
|
|
49
|
+
/** @internal Computes a bcrypt hash of the given string. */
|
|
50
|
+
_bcrypt(str: string, cost: number[]): string;
|
|
51
|
+
/** Returns the closest whole number greater than or equal to the given value. */
|
|
52
|
+
ceil(num: number): number;
|
|
53
|
+
/** Removes trailing newline characters from a string. */
|
|
54
|
+
chomp(str: string): string;
|
|
55
|
+
/** Splits a list into fixed-size chunks, returning a list of lists. */
|
|
56
|
+
chunklist(list: any[], size: number): string[];
|
|
57
|
+
/** Calculates a full host IP address within a given CIDR prefix. */
|
|
58
|
+
cidrhost(prefix: string, hostnum: number): string;
|
|
59
|
+
/** Converts an IPv4 CIDR notation prefix into a subnet mask address. */
|
|
60
|
+
cidrnetmask(prefix: string): string;
|
|
61
|
+
/** Calculates a subnet address within a given IP network prefix. */
|
|
62
|
+
cidrsubnet(prefix: string, newbits: number, netnum: number): string;
|
|
63
|
+
/** Calculates a sequence of consecutive IP address ranges within a CIDR prefix. */
|
|
64
|
+
cidrsubnets(prefix: string, newbits: number[]): string[];
|
|
65
|
+
/** Returns the first non-null, non-empty value from the arguments. */
|
|
66
|
+
coalesce(vals: any[]): any;
|
|
67
|
+
/** Returns the first non-empty list from the arguments. */
|
|
68
|
+
coalescelist(vals: any[]): any;
|
|
69
|
+
/** Removes empty string elements from a list. */
|
|
70
|
+
compact(list: string[]): string[];
|
|
71
|
+
/** Combines two or more lists into a single list. */
|
|
72
|
+
concat(seqs: any[]): any;
|
|
73
|
+
/** Returns `true` if a list or set contains the given value. */
|
|
74
|
+
contains(list: any, value: any): any;
|
|
75
|
+
/** Decodes a CSV-formatted string into a list of maps. */
|
|
76
|
+
csvdecode(str: string): any;
|
|
77
|
+
/** Removes the last portion from a filesystem path. */
|
|
78
|
+
dirname(path: string): string;
|
|
79
|
+
/** Returns a new list with duplicate elements removed. */
|
|
80
|
+
distinct(list: any[]): string[];
|
|
81
|
+
/** Retrieves a single element from a list by index (wraps around). */
|
|
82
|
+
element(list: any, index: number): any;
|
|
83
|
+
/** Reads the contents of a file at the given path as a string. */
|
|
84
|
+
file(path: string): string;
|
|
85
|
+
/** Reads a file and returns its contents as a Base64-encoded string. */
|
|
86
|
+
filebase64(path: string): string;
|
|
87
|
+
/** Computes the Base64-encoded SHA256 hash of a file's contents. */
|
|
88
|
+
filebase64sha256(path: string): string;
|
|
89
|
+
/** Computes the Base64-encoded SHA512 hash of a file's contents. */
|
|
90
|
+
filebase64sha512(path: string): string;
|
|
91
|
+
/** Computes the MD5 hash of a file's contents. */
|
|
92
|
+
filemd5(path: string): string;
|
|
93
|
+
/** Enumerates file names matching a glob pattern under a path. */
|
|
94
|
+
fileset(path: string, pattern: string): string[];
|
|
95
|
+
/** Computes the SHA1 hash of a file's contents. */
|
|
96
|
+
filesha1(path: string): string;
|
|
97
|
+
/** Computes the SHA256 hash of a file's contents. */
|
|
98
|
+
filesha256(path: string): string;
|
|
99
|
+
/** Computes the SHA512 hash of a file's contents. */
|
|
100
|
+
filesha512(path: string): string;
|
|
101
|
+
/** Flattens nested lists into a single flat list. */
|
|
102
|
+
flatten(list: any): any;
|
|
103
|
+
/** Returns the closest whole number less than or equal to the given value. */
|
|
104
|
+
floor(num: number): number;
|
|
105
|
+
/** Produces a formatted string using a `printf`-style format specifier. */
|
|
106
|
+
format(format: string, args: any[]): any;
|
|
107
|
+
/** Converts a timestamp into a different time format. */
|
|
108
|
+
formatdate(format: string, time: string): string;
|
|
109
|
+
/** Produces a list of formatted strings from a format specifier and arguments. */
|
|
110
|
+
formatlist(format: string, args: any[]): any;
|
|
111
|
+
/** Adds spaces to the beginning of all but the first line of a multi-line string. */
|
|
112
|
+
indent(spaces: number, str: string): string;
|
|
113
|
+
/** Finds the element index for a given value in a list. */
|
|
114
|
+
index(list: any, value: any): any;
|
|
115
|
+
/** @internal Joins multiple lists of strings with a separator. */
|
|
116
|
+
_join(separator: string, lists: string[][]): string;
|
|
117
|
+
/** Decodes a JSON string into a value. */
|
|
118
|
+
jsondecode(str: string): any;
|
|
119
|
+
/** Encodes a value as a JSON string. */
|
|
120
|
+
jsonencode(val: any): string;
|
|
121
|
+
/** Returns a list of keys from a map. */
|
|
122
|
+
keys(inputMap: any): any;
|
|
123
|
+
/** Returns the length of a list, map, or string. */
|
|
124
|
+
lengthOf(value: any): number;
|
|
125
|
+
/** Returns the logarithm of a number in the given base. */
|
|
126
|
+
log(num: number, base: number): number;
|
|
127
|
+
/** @internal Retrieves a value from a map by key, with a default fallback. */
|
|
128
|
+
_lookup(inputMap: any, key: string, defaultValue: any[]): any;
|
|
129
|
+
/** Converts all cased letters in a string to lowercase. */
|
|
130
|
+
lower(str: string): string;
|
|
131
|
+
/** Constructs a new list by matching indexes between values, keys, and a search set. */
|
|
132
|
+
matchkeys(values: any[], keys: any[], searchset: any[]): string[];
|
|
133
|
+
/** Returns the greatest number from the given set. */
|
|
134
|
+
max(numbers: number[]): number;
|
|
135
|
+
/** Computes the MD5 hash of a string in hexadecimal. */
|
|
136
|
+
md5(str: string): string;
|
|
137
|
+
/** Merges multiple maps or objects into a single map. */
|
|
138
|
+
merge(maps: any[]): any;
|
|
139
|
+
/** Returns the smallest number from the given set. */
|
|
140
|
+
min(numbers: number[]): number;
|
|
141
|
+
/** Removes the sensitive marking from a value. */
|
|
142
|
+
nonsensitive(value: any): any;
|
|
143
|
+
/** Returns the single element from a zero-or-one element collection, or `null`. */
|
|
144
|
+
one(list: any): any;
|
|
145
|
+
/** Parses a string as an integer in the specified base (2–62). */
|
|
146
|
+
parseint(number: any, base: number): any;
|
|
147
|
+
/** Expands a `~` prefix in a filesystem path to the user's home directory. */
|
|
148
|
+
pathexpand(path: string): string;
|
|
149
|
+
/** Returns a UTC timestamp string fixed to the time of the plan. */
|
|
150
|
+
plantimestamp(): string;
|
|
151
|
+
/** Raises a number to the power of another number. */
|
|
152
|
+
pow(num: number, power: number): number;
|
|
153
|
+
/** @internal Generates a list of numbers using start, limit, and step values. */
|
|
154
|
+
_range(params: number[]): string[];
|
|
155
|
+
/** Applies a regular expression to a string and returns matching substrings. */
|
|
156
|
+
regex(pattern: string, str: string): any;
|
|
157
|
+
/** Applies a regular expression to a string and returns all matches. */
|
|
158
|
+
regexall(pattern: string, str: string): string[];
|
|
159
|
+
/** Replaces all occurrences of a substring within a string. */
|
|
160
|
+
replace(str: string, substr: string, replace: string): string;
|
|
161
|
+
/** Returns a sequence with all elements in reverse order. */
|
|
162
|
+
reverse(list: any): any;
|
|
163
|
+
/** Decrypts an RSA-encrypted ciphertext and returns the cleartext. */
|
|
164
|
+
rsadecrypt(ciphertext: string, privatekey: string): string;
|
|
165
|
+
/** Marks a value as sensitive so Terraform suppresses it in output. */
|
|
166
|
+
sensitive(value: any): any;
|
|
167
|
+
/** Returns the intersection of multiple sets. */
|
|
168
|
+
setintersection(first_set: any[], other_sets: any[][]): string[];
|
|
169
|
+
/** Computes the Cartesian product of multiple sets. */
|
|
170
|
+
setproduct(sets: any[]): any;
|
|
171
|
+
/** Returns elements from the first set not present in the second set. */
|
|
172
|
+
setsubtract(a: any[], b: any[]): string[];
|
|
173
|
+
/** Returns the union of multiple sets. */
|
|
174
|
+
setunion(first_set: any[], other_sets: any[][]): string[];
|
|
175
|
+
/** Computes the SHA1 hash of a string in hexadecimal. */
|
|
176
|
+
sha1(str: string): string;
|
|
177
|
+
/** Computes the SHA256 hash of a string in hexadecimal. */
|
|
178
|
+
sha256(str: string): string;
|
|
179
|
+
/** Computes the SHA512 hash of a string in hexadecimal. */
|
|
180
|
+
sha512(str: string): string;
|
|
181
|
+
/** Returns -1, 0, or 1 representing the sign of a number. */
|
|
182
|
+
signum(num: number): number;
|
|
183
|
+
/** Extracts consecutive elements from a list between start and end indexes. */
|
|
184
|
+
slice(list: any, start_index: number, end_index: number): any;
|
|
185
|
+
/** Sorts a list of strings lexicographically. */
|
|
186
|
+
sort(list: string[]): string[];
|
|
187
|
+
/** Splits a string into a list by a separator. */
|
|
188
|
+
split(separator: string, str: string): string[];
|
|
189
|
+
/** Reverses the characters in a string (Unicode-aware). */
|
|
190
|
+
strrev(str: string): string;
|
|
191
|
+
/** Extracts a substring by offset and maximum length. */
|
|
192
|
+
substr(str: string, offset: number, length: number): string;
|
|
193
|
+
/** Returns the sum of all numbers in a list. */
|
|
194
|
+
sum(list: any): any;
|
|
195
|
+
/** Reads a file and renders its content as a template with the given variables. */
|
|
196
|
+
templatefile(path: string, vars: any): any;
|
|
197
|
+
/** Decodes a Base64 string using the specified character encoding. */
|
|
198
|
+
textdecodebase64(source: string, encoding: string): string;
|
|
199
|
+
/** Encodes a string using the specified character encoding and returns it in Base64. */
|
|
200
|
+
textencodebase64(str: string, encoding: string): string;
|
|
201
|
+
/** Adds a duration to a timestamp and returns the new timestamp. */
|
|
202
|
+
timeadd(timestamp: string, duration: string): string;
|
|
203
|
+
/** Compares two timestamps and returns -1, 0, or 1. */
|
|
204
|
+
timecmp(timestamp_a: string, timestamp_b: string): number;
|
|
205
|
+
/** Returns the current UTC timestamp in RFC 3339 format. */
|
|
206
|
+
timestamp(): string;
|
|
207
|
+
/** Converts the first letter of each word to uppercase. */
|
|
208
|
+
title(str: string): string;
|
|
209
|
+
/** Converts a value to a Terraform list type. */
|
|
210
|
+
tolist(v: any): string[];
|
|
211
|
+
/** Converts a value to a Terraform map type. */
|
|
212
|
+
tomap(v: any): any;
|
|
213
|
+
/** Converts a value to a number type. */
|
|
214
|
+
tonumber(v: any): number;
|
|
215
|
+
/** Converts a value to a Terraform set type (removes duplicates). */
|
|
216
|
+
toset(v: any): string[];
|
|
217
|
+
/** Converts a value to a string type. */
|
|
218
|
+
tostring(v: any): string;
|
|
219
|
+
/** Swaps the keys and values of a map of lists of strings. */
|
|
220
|
+
transpose(values: any): any;
|
|
221
|
+
/** Removes the specified characters from the start and end of a string. */
|
|
222
|
+
trim(str: string, cutset: string): string;
|
|
223
|
+
/** Removes the specified prefix from the start of a string. */
|
|
224
|
+
trimprefix(str: string, prefix: string): string;
|
|
225
|
+
/** Removes leading and trailing whitespace from a string. */
|
|
226
|
+
trimspace(str: string): string;
|
|
227
|
+
/** Removes the specified suffix from the end of a string. */
|
|
228
|
+
trimsuffix(str: string, suffix: string): string;
|
|
229
|
+
/** Evaluates expressions in order and returns the first one that doesn't error. */
|
|
230
|
+
try(expressions: any[]): any;
|
|
231
|
+
/** Converts all cased letters in a string to uppercase. */
|
|
232
|
+
upper(str: string): string;
|
|
233
|
+
/** Applies URL encoding to a string. */
|
|
234
|
+
urlencode(str: string): string;
|
|
235
|
+
/** Generates a unique identifier string (UUID v4). */
|
|
236
|
+
uuid(): string;
|
|
237
|
+
/** Generates a name-based UUID v5 from a namespace and name. */
|
|
238
|
+
uuidv5(namespace: string, name: string): string;
|
|
239
|
+
/** Returns a list of values from a map. */
|
|
240
|
+
values(mapping: any): any;
|
|
241
|
+
/** Parses a YAML string and returns its value. */
|
|
242
|
+
yamldecode(src: string): any;
|
|
243
|
+
/** Encodes a value as a YAML string. */
|
|
244
|
+
yamlencode(value: any): string;
|
|
245
|
+
/** Constructs a map from a list of keys and a corresponding list of values. */
|
|
246
|
+
zipmap(keys: string[], values: any): any;
|
|
247
|
+
}
|
|
6
248
|
export interface GetResourceProps {
|
|
7
249
|
/**
|
|
8
250
|
* Retrieves an attribute value from a resource created by Lafken.
|
|
@@ -49,4 +291,14 @@ export interface GetResourceProps {
|
|
|
49
291
|
* getSSMValue('/my-app/secret', true)
|
|
50
292
|
*/
|
|
51
293
|
getSSMValue: (value: string, secure?: boolean) => string;
|
|
294
|
+
/**
|
|
295
|
+
* Provides access to Terraform built-in functions for string manipulation,
|
|
296
|
+
* encoding, list operations, and conditional expressions.
|
|
297
|
+
*/
|
|
298
|
+
fn: TerraformFn;
|
|
299
|
+
/**
|
|
300
|
+
* Provides access to Terraform token utilities for converting and inspecting
|
|
301
|
+
* unresolved token values.
|
|
302
|
+
*/
|
|
303
|
+
token: TerraformToken;
|
|
52
304
|
}
|
package/package.json
CHANGED