@resistdesign/voltra 3.0.0-alpha.27 → 3.0.0-alpha.29

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/common/index.js CHANGED
@@ -1,3 +1,9 @@
1
+ export { DENIED_TYPE_OPERATIONS, ERROR_MESSAGE_CONSTANTS, INVALID_CUSTOM_TYPE, PRIMITIVE_ERROR_MESSAGE_CONSTANTS, RelationshipValidationType, TYPE_KEYWORD_VALIDATORS, getValidityValue, hasValue, validateArrayOfTypeInfoFieldValues, validateCustomType, validateKeywordType, validateTypeInfoFieldOperationAllowed, validateTypeInfoFieldValue, validateTypeInfoValue, validateTypeOperationAllowed, validateValueMatchesPattern } from '../chunk-LGM75I6P.js';
2
+ export { TypeInfoORMServiceError } from '../chunk-HVY7POTD.js';
3
+ export { TypeOperation } from '../chunk-IWRHGGGH.js';
4
+ import '../chunk-GYWRAW3Y.js';
5
+ import '../chunk-I2KLQ2HA.js';
6
+
1
7
  // src/common/CommandLine/collectRequiredEnvironmentVariables.ts
2
8
  var collectRequiredEnvironmentVariables = (varNames) => {
3
9
  const result = {};
@@ -27,387 +33,4 @@ ${missingEnvVars.map((vN) => `- ${vN}`).join(`
27
33
  return result;
28
34
  };
29
35
 
30
- // src/common/TypeParsing/TypeInfo.ts
31
- var TypeOperation = /* @__PURE__ */ ((TypeOperation2) => {
32
- TypeOperation2["CREATE"] = "CREATE";
33
- TypeOperation2["READ"] = "READ";
34
- TypeOperation2["UPDATE"] = "UPDATE";
35
- TypeOperation2["DELETE"] = "DELETE";
36
- return TypeOperation2;
37
- })(TypeOperation || {});
38
-
39
- // src/common/TypeInfoORM/Types.ts
40
- var TypeInfoORMServiceError = /* @__PURE__ */ ((TypeInfoORMServiceError2) => {
41
- TypeInfoORMServiceError2["NO_DRIVERS_SUPPLIED"] = "NO_DRIVERS_SUPPLIED";
42
- TypeInfoORMServiceError2["NO_RELATIONSHIP_DRIVERS_SUPPLIED"] = "NO_RELATIONSHIP_DRIVERS_SUPPLIED";
43
- TypeInfoORMServiceError2["NO_PRIMARY_FIELD_VALUE_SUPPLIED"] = "NO_PRIMARY_FIELD_VALUE_SUPPLIED";
44
- TypeInfoORMServiceError2["INVALID_DRIVER"] = "INVALID_DRIVER";
45
- TypeInfoORMServiceError2["INVALID_RELATIONSHIP_DRIVER"] = "INVALID_RELATIONSHIP_DRIVER";
46
- TypeInfoORMServiceError2["INVALID_TYPE_INFO"] = "INVALID_TYPE_INFO";
47
- TypeInfoORMServiceError2["TYPE_INFO_MISSING_PRIMARY_FIELD"] = "TYPE_INFO_MISSING_PRIMARY_FIELD";
48
- TypeInfoORMServiceError2["INVALID_RELATIONSHIP"] = "INVALID_RELATIONSHIP";
49
- TypeInfoORMServiceError2["INVALID_OPERATION"] = "INVALID_OPERATION";
50
- TypeInfoORMServiceError2["MISSING_ACCESSING_ROLE"] = "MISSING_ACCESSING_ROLE";
51
- TypeInfoORMServiceError2["INDEXING_UNSUPPORTED_CRITERIA"] = "INDEXING_UNSUPPORTED_CRITERIA";
52
- TypeInfoORMServiceError2["INDEXING_UNSUPPORTED_COMBINATION"] = "INDEXING_UNSUPPORTED_COMBINATION";
53
- TypeInfoORMServiceError2["INDEXING_MISSING_INDEX_FIELD"] = "INDEXING_MISSING_INDEX_FIELD";
54
- TypeInfoORMServiceError2["INDEXING_MISSING_BACKEND"] = "INDEXING_MISSING_BACKEND";
55
- TypeInfoORMServiceError2["INDEXING_REQUIRES_CRITERIA"] = "INDEXING_REQUIRES_CRITERIA";
56
- return TypeInfoORMServiceError2;
57
- })(TypeInfoORMServiceError || {});
58
-
59
- // src/common/Routing.ts
60
- var PATH_DELIMITER = "/";
61
- var getPathString = (parts = [], delimiter = PATH_DELIMITER, filterEmptyInput = false, useJson = true, uriEncodeParts = false) => parts.filter(filterEmptyInput ? (p) => p ?? false : () => true).map(useJson ? (p) => JSON.stringify(p) : (x) => x).map(uriEncodeParts ? encodeURIComponent : (x) => x).join(delimiter);
62
-
63
- // src/common/TypeParsing/Validation.ts
64
- var RelationshipValidationType = /* @__PURE__ */ ((RelationshipValidationType2) => {
65
- RelationshipValidationType2["INCLUDE"] = "INCLUDE";
66
- RelationshipValidationType2["EXCLUDE"] = "EXCLUDE";
67
- RelationshipValidationType2["STRICT_EXCLUDE"] = "STRICT_EXCLUDE";
68
- return RelationshipValidationType2;
69
- })(RelationshipValidationType || {});
70
- var INVALID_CUSTOM_TYPE = "INVALID_CUSTOM_TYPE";
71
- var PRIMITIVE_ERROR_MESSAGE_CONSTANTS = {
72
- string: "NOT_A_STRING",
73
- number: "NOT_A_NUMBER",
74
- boolean: "NOT_A_BOOLEAN"
75
- };
76
- var ERROR_MESSAGE_CONSTANTS = {
77
- MISSING: "MISSING",
78
- INVALID_OPTION: "INVALID_OPTION",
79
- INVALID_FIELD: "INVALID_FIELD",
80
- RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED: "RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED",
81
- INVALID_TYPE: "INVALID_TYPE",
82
- NO_UNION_TYPE_MATCHED: "NO_UNION_TYPE_MATCHED",
83
- TYPE_DOES_NOT_EXIST: "TYPE_DOES_NOT_EXIST",
84
- INVALID_PATTERN: "INVALID_PATTERN",
85
- VALUE_DOES_NOT_MATCH_PATTERN: "VALUE_DOES_NOT_MATCH_PATTERN"
86
- };
87
- var DENIED_TYPE_OPERATIONS = {
88
- CREATE: "DENIED_TYPE_OPERATION_CREATE",
89
- READ: "DENIED_TYPE_OPERATION_READ",
90
- UPDATE: "DENIED_TYPE_OPERATION_UPDATE",
91
- DELETE: "DENIED_TYPE_OPERATION_DELETE"
92
- };
93
- var validateValueMatchesPattern = (typeName, value, pattern) => {
94
- const results = {
95
- typeName,
96
- valid: true,
97
- error: "",
98
- errorMap: {}
99
- };
100
- const valueSupplied = typeof value !== "undefined";
101
- const patternSupplied = typeof pattern === "string" && pattern.trim() !== "";
102
- if (!valueSupplied || !patternSupplied) {
103
- try {
104
- const regex = new RegExp(pattern);
105
- const testResult = typeof value === "string" && regex.test(value);
106
- if (!testResult) {
107
- results.valid = false;
108
- results.error = ERROR_MESSAGE_CONSTANTS.VALUE_DOES_NOT_MATCH_PATTERN;
109
- }
110
- } catch (e) {
111
- results.valid = false;
112
- results.error = ERROR_MESSAGE_CONSTANTS.INVALID_PATTERN;
113
- }
114
- }
115
- return results;
116
- };
117
- var getValidityValue = (existing, pending) => !existing ? false : pending;
118
- var TYPE_KEYWORD_VALIDATORS = {
119
- string: (value) => typeof value === "string",
120
- number: (value) => typeof value === "number",
121
- boolean: (value) => typeof value === "boolean"
122
- };
123
- var hasValue = (value) => value ?? false;
124
- var validateKeywordType = (value, type) => {
125
- const validator = TYPE_KEYWORD_VALIDATORS[type];
126
- let valid = true;
127
- if (validator) {
128
- valid = validator(value);
129
- }
130
- return valid;
131
- };
132
- var validateCustomType = (value, customType, customValidators) => {
133
- let valid = true;
134
- if (customValidators && customType) {
135
- const validator = customValidators[customType];
136
- if (validator) {
137
- try {
138
- valid = validator(value);
139
- } catch (e) {
140
- valid = false;
141
- }
142
- }
143
- }
144
- return valid;
145
- };
146
- var validateTypeInfoFieldValue = (value, typeInfoField, typeInfoMap, ignoreArray = false, strict = false, customValidators, typeOperation, relationshipValidationType = "STRICT_EXCLUDE" /* STRICT_EXCLUDE */, itemIsPartial) => {
147
- const {
148
- type,
149
- typeReference,
150
- array,
151
- optional,
152
- possibleValues,
153
- tags: { customType, constraints: { pattern = void 0 } = {} } = {}
154
- } = typeInfoField;
155
- const results = {
156
- typeName: typeReference ?? type,
157
- valid: true,
158
- error: "",
159
- errorMap: {}
160
- };
161
- const requiredValueAllowed = !typeReference || relationshipValidationType === "INCLUDE" /* INCLUDE */;
162
- const valueIsUndefined = typeof value === "undefined";
163
- const valueIsNull = value === null;
164
- const canSkipValidation = itemIsPartial && (valueIsUndefined || valueIsNull) || optional && valueIsUndefined;
165
- if (canSkipValidation) {
166
- results.valid = true;
167
- } else if (requiredValueAllowed && !itemIsPartial && !optional && !hasValue(value)) {
168
- results.valid = false;
169
- results.error = ERROR_MESSAGE_CONSTANTS.MISSING;
170
- } else if (array && !ignoreArray) {
171
- const {
172
- valid: validArray,
173
- error: arrayError,
174
- errorMap: arrayErrorMap
175
- } = validateArrayOfTypeInfoFieldValues(
176
- value,
177
- typeInfoField,
178
- typeInfoMap,
179
- strict,
180
- customValidators,
181
- typeOperation,
182
- relationshipValidationType,
183
- itemIsPartial
184
- );
185
- results.valid = getValidityValue(results.valid, validArray);
186
- results.error = arrayError;
187
- results.errorMap = arrayErrorMap;
188
- } else {
189
- if (typeReference) {
190
- if (relationshipValidationType === "INCLUDE" /* INCLUDE */) {
191
- const {
192
- valid: validTypeInfo,
193
- error: typeInfoError,
194
- errorMap: typeInfoErrorMap
195
- } = validateTypeInfoValue(
196
- value,
197
- typeReference,
198
- typeInfoMap,
199
- strict,
200
- customValidators,
201
- typeOperation,
202
- relationshipValidationType,
203
- itemIsPartial
204
- );
205
- results.valid = getValidityValue(results.valid, validTypeInfo);
206
- results.error = typeInfoError;
207
- results.errorMap = typeInfoErrorMap;
208
- } else if (relationshipValidationType === "STRICT_EXCLUDE" /* STRICT_EXCLUDE */) {
209
- const valueSupplied = typeof value !== "undefined";
210
- if (valueSupplied) {
211
- results.valid = false;
212
- results.error = ERROR_MESSAGE_CONSTANTS.RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED;
213
- }
214
- } else if (relationshipValidationType === "EXCLUDE" /* EXCLUDE */) {
215
- results.valid = getValidityValue(results.valid, true);
216
- }
217
- } else if (possibleValues && !possibleValues.includes(value)) {
218
- results.valid = false;
219
- results.error = ERROR_MESSAGE_CONSTANTS.INVALID_OPTION;
220
- } else {
221
- const pendingValid = validateKeywordType(value, type);
222
- const customValid = validateCustomType(
223
- value,
224
- customType,
225
- customValidators
226
- );
227
- results.valid = getValidityValue(results.valid, pendingValid);
228
- results.valid = getValidityValue(results.valid, customValid);
229
- if (type === "string" && typeof pattern === "string") {
230
- const { valid: patternValid, error: patternError } = validateValueMatchesPattern(value, pattern);
231
- results.valid = getValidityValue(results.valid, patternValid);
232
- results.error = patternError;
233
- }
234
- if (!customValid) {
235
- results.error = INVALID_CUSTOM_TYPE;
236
- } else if (!results.valid) {
237
- results.error = results.error ? results.error : PRIMITIVE_ERROR_MESSAGE_CONSTANTS[type];
238
- }
239
- }
240
- }
241
- return results;
242
- };
243
- var validateArrayOfTypeInfoFieldValues = (values = [], typeInfoField, typeInfoMap, strict = false, customValidators, typeOperation, relationshipValidationType, itemIsPartial) => {
244
- const { type, typeReference } = typeInfoField;
245
- const results = {
246
- typeName: typeReference ?? type,
247
- valid: true,
248
- error: "",
249
- errorMap: {}
250
- };
251
- for (let i = 0; i < values.length; i++) {
252
- const v = values[i];
253
- const {
254
- valid: indexValid,
255
- error: indexError = "",
256
- errorMap: indexErrorMap
257
- } = validateTypeInfoFieldValue(
258
- v,
259
- typeInfoField,
260
- typeInfoMap,
261
- true,
262
- strict,
263
- customValidators,
264
- typeOperation,
265
- relationshipValidationType,
266
- itemIsPartial
267
- );
268
- results.valid = getValidityValue(results.valid, indexValid);
269
- results.errorMap[getPathString([i])] = [indexError];
270
- for (const er in indexErrorMap) {
271
- results.errorMap[getPathString([i, er])] = indexErrorMap[er];
272
- }
273
- }
274
- return results;
275
- };
276
- var validateTypeInfoFieldOperationAllowed = (fieldName, fieldOperation, typeInfoField) => {
277
- const results = {
278
- typeName: null,
279
- valid: true,
280
- error: "",
281
- errorMap: {}
282
- };
283
- if (fieldOperation && typeInfoField) {
284
- const {
285
- type,
286
- typeReference,
287
- tags = {}
288
- } = typeInfoField || {};
289
- const { deniedOperations: { [fieldOperation]: denied = false } = {} } = tags;
290
- results.typeName = typeReference ?? type;
291
- results.valid = !denied;
292
- if (!results.valid) {
293
- results.error = DENIED_TYPE_OPERATIONS[fieldOperation];
294
- results.errorMap[fieldName] = [results.error];
295
- }
296
- }
297
- return results;
298
- };
299
- var validateTypeOperationAllowed = (typeName, valueFields, typeOperation, typeInfo) => {
300
- const results = {
301
- typeName,
302
- valid: true,
303
- error: "",
304
- errorMap: {}
305
- };
306
- const { fields = {}, tags = {} } = typeInfo;
307
- const { deniedOperations: { [typeOperation]: denied = false } = {} } = tags;
308
- if (denied) {
309
- results.valid = false;
310
- results.error = DENIED_TYPE_OPERATIONS[typeOperation];
311
- } else {
312
- for (const vF of valueFields) {
313
- const vFieldInfo = fields[vF];
314
- const { valid: vFValid, error: vFError } = validateTypeInfoFieldOperationAllowed(vF, typeOperation, vFieldInfo);
315
- results.valid = getValidityValue(results.valid, vFValid);
316
- if (!vFValid) {
317
- results.errorMap[vF] = [vFError];
318
- }
319
- }
320
- }
321
- return results;
322
- };
323
- var validateTypeInfoValue = (value, typeInfoFullName, typeInfoMap, strict = false, customValidators, typeOperation, relationshipValidationType, itemIsPartial) => {
324
- const typeInfo = typeInfoMap[typeInfoFullName];
325
- const results = {
326
- typeName: typeInfoFullName,
327
- valid: !!typeInfo,
328
- error: !!typeInfo ? "" : ERROR_MESSAGE_CONSTANTS.TYPE_DOES_NOT_EXIST,
329
- errorMap: {}
330
- };
331
- if (typeInfo) {
332
- const { primaryField, fields, unionFieldSets } = typeInfo;
333
- if (typeOperation) {
334
- const valueFields = typeof value === "object" ? Object.keys(value ?? {}) : [];
335
- const {
336
- valid: operationValid,
337
- error: operationError,
338
- errorMap: operationErrorMap
339
- } = validateTypeOperationAllowed(
340
- typeInfoFullName,
341
- valueFields,
342
- typeOperation,
343
- typeInfo
344
- );
345
- results.valid = getValidityValue(results.valid, operationValid);
346
- results.error = operationError;
347
- for (const oE in operationErrorMap) {
348
- const existingError = results.errorMap[oE] ?? [];
349
- results.errorMap[oE] = existingError ? [...existingError, ...operationErrorMap[oE]] : operationErrorMap[oE];
350
- }
351
- if (!operationValid && operationError) {
352
- results.error = operationError;
353
- }
354
- }
355
- if (unionFieldSets) {
356
- const valueFields = Object.keys(value || {});
357
- let valid = false;
358
- for (const uFS of unionFieldSets) {
359
- valid = valueFields.every((vF) => uFS.includes(vF));
360
- if (valid) {
361
- break;
362
- }
363
- }
364
- if (!valid) {
365
- results.valid = false;
366
- results.error = ERROR_MESSAGE_CONSTANTS.NO_UNION_TYPE_MATCHED;
367
- }
368
- } else if (strict) {
369
- const knownFields = Object.keys(fields || {});
370
- const valueFields = Object.keys(value || {});
371
- for (const vF of valueFields) {
372
- if (!knownFields.includes(vF)) {
373
- results.valid = false;
374
- results.errorMap[vF] = [ERROR_MESSAGE_CONSTANTS.INVALID_FIELD];
375
- }
376
- }
377
- }
378
- if (fields) {
379
- for (const key in fields) {
380
- if (typeOperation !== "CREATE" /* CREATE */ || typeof primaryField !== "string" || key !== primaryField) {
381
- const typeInfoField = fields[key];
382
- const fieldValue = value[key];
383
- const {
384
- valid: fieldValid,
385
- error: fieldError,
386
- errorMap: fieldErrorMap
387
- } = validateTypeInfoFieldValue(
388
- fieldValue,
389
- typeInfoField,
390
- typeInfoMap,
391
- false,
392
- strict,
393
- customValidators,
394
- typeOperation,
395
- relationshipValidationType,
396
- itemIsPartial
397
- );
398
- results.valid = getValidityValue(results.valid, fieldValid);
399
- results.errorMap[key] = [fieldError];
400
- for (const fE in fieldErrorMap) {
401
- results.errorMap[getPathString([key, fE])] = fieldErrorMap[fE];
402
- }
403
- }
404
- }
405
- }
406
- if (!results.valid && !results.error) {
407
- results.error = ERROR_MESSAGE_CONSTANTS.INVALID_TYPE;
408
- }
409
- }
410
- return results;
411
- };
412
-
413
- export { DENIED_TYPE_OPERATIONS, ERROR_MESSAGE_CONSTANTS, INVALID_CUSTOM_TYPE, PRIMITIVE_ERROR_MESSAGE_CONSTANTS, RelationshipValidationType, TYPE_KEYWORD_VALIDATORS, TypeInfoORMServiceError, TypeOperation, collectRequiredEnvironmentVariables, getValidityValue, hasValue, validateArrayOfTypeInfoFieldValues, validateCustomType, validateKeywordType, validateTypeInfoFieldOperationAllowed, validateTypeInfoFieldValue, validateTypeInfoValue, validateTypeOperationAllowed, validateValueMatchesPattern };
36
+ export { collectRequiredEnvironmentVariables };
package/iac/index.js CHANGED
@@ -1,258 +1,2 @@
1
- import YAML from 'yaml';
2
-
3
- // src/iac/utils/patch-utils.ts
4
- var DEFAULT_MERGE_STRATEGY = "transpose";
5
- var getValuePathString = (valuePathArray = []) => valuePathArray.map((p) => encodeURIComponent(p)).join("/");
6
- var getValuePathArray = (valuePathString = "") => valuePathString.split("/").map((p) => decodeURIComponent(p));
7
- var isConstructedFrom = (value, constructorReference) => value !== null && typeof value === "object" && "constructor" in value && value.constructor === constructorReference;
8
- var mergeValues = (valuePathArray = [], existingValue, newValue, mergeStrategyMap = {}) => {
9
- const valuePathString = getValuePathString(valuePathArray);
10
- const arrayIndexWildcardValuePathString = getValuePathString(
11
- valuePathArray.map((p) => typeof p === "number" ? "#" : p)
12
- );
13
- const {
14
- [valuePathString]: {
15
- strategy: specificKeyMergeStrategy = DEFAULT_MERGE_STRATEGY,
16
- data: specificKeyMergeStrategyData = void 0
17
- } = {},
18
- [arrayIndexWildcardValuePathString]: {
19
- strategy: arrayIndexWildcardMergeStrategy = DEFAULT_MERGE_STRATEGY,
20
- data: arrayIndexWildcardMergeStrategyData = void 0
21
- } = {}
22
- } = mergeStrategyMap;
23
- const mergeStrategy = valuePathString in mergeStrategyMap ? specificKeyMergeStrategy : arrayIndexWildcardMergeStrategy;
24
- const mergeStrategyData = valuePathString in mergeStrategyMap ? specificKeyMergeStrategyData : arrayIndexWildcardMergeStrategyData;
25
- let mergedValue = typeof newValue !== "undefined" ? newValue : existingValue;
26
- if (mergeStrategy !== "replace") {
27
- if (isConstructedFrom(existingValue, Array) && isConstructedFrom(newValue, Array)) {
28
- if (mergeStrategy === "accumulate") {
29
- mergedValue = [...existingValue, ...newValue];
30
- } else if (mergeStrategy === "accumulate-unique") {
31
- mergedValue = [
32
- ...existingValue,
33
- ...newValue.filter((item) => existingValue.indexOf(item) === -1)
34
- ];
35
- } else if (mergeStrategy === "accumulate-unique-by") {
36
- const existingItemMap = {};
37
- const newItemMap = {};
38
- for (let i = 0; i < existingValue.length; i++) {
39
- const existingItem = existingValue[i];
40
- if (existingItem && typeof existingItem === "object") {
41
- const identifier = mergeStrategyData instanceof Function ? mergeStrategyData(existingItem) : existingItem[mergeStrategyData];
42
- existingItemMap[identifier] = existingItem;
43
- }
44
- }
45
- for (let j = 0; j < newValue.length; j++) {
46
- const newItem = newValue[j];
47
- if (newItem && typeof newItem === "object") {
48
- const identifier = mergeStrategyData instanceof Function ? mergeStrategyData(newItem) : newItem[mergeStrategyData];
49
- newItemMap[identifier] = newItem;
50
- }
51
- }
52
- mergedValue = Object.keys({
53
- ...existingItemMap,
54
- ...newItemMap
55
- }).map(
56
- (id, index) => mergeValues(
57
- [...valuePathArray, index],
58
- existingItemMap[id],
59
- newItemMap[id],
60
- mergeStrategyMap
61
- )
62
- );
63
- } else if (mergeStrategy === "transpose") {
64
- const fullLength = Math.max(existingValue.length, newValue.length);
65
- mergedValue = [...new Array(fullLength)].map(
66
- (_empty, index) => mergeValues(
67
- [...valuePathArray, index],
68
- existingValue[index],
69
- newValue[index],
70
- mergeStrategyMap
71
- )
72
- );
73
- }
74
- } else if (isConstructedFrom(existingValue, Object) && isConstructedFrom(newValue, Object)) {
75
- mergedValue = Object.keys({ ...existingValue, ...newValue }).reduce(
76
- (acc, k) => ({
77
- ...acc,
78
- [k]: mergeValues(
79
- [...valuePathArray, k],
80
- existingValue[k],
81
- newValue[k],
82
- mergeStrategyMap
83
- )
84
- }),
85
- {}
86
- );
87
- }
88
- }
89
- return mergedValue;
90
- };
91
-
92
- // src/iac/utils/index.ts
93
- var addParameter = (parameterInfo, template) => {
94
- const { ParameterId, Parameter, Label, Group } = parameterInfo;
95
- const {
96
- Parameters,
97
- Metadata: {
98
- "AWS::CloudFormation::Interface": {
99
- ParameterGroups = [],
100
- ParameterLabels = {}
101
- } = {}
102
- } = {}
103
- } = template;
104
- let NewParameterGroups = ParameterGroups;
105
- if (Group) {
106
- const GroupObject = ParameterGroups.filter(
107
- (g) => g.Label?.default === Group
108
- )[0];
109
- NewParameterGroups = GroupObject ? ParameterGroups.map(
110
- (g) => g.Label?.default === Group ? {
111
- ...g,
112
- Parameters: [...g.Parameters || [], ParameterId]
113
- } : g
114
- ) : [
115
- ...ParameterGroups,
116
- {
117
- Label: {
118
- default: Group
119
- },
120
- Parameters: [ParameterId]
121
- }
122
- ];
123
- }
124
- return {
125
- ...template,
126
- Parameters: {
127
- ...Parameters,
128
- [ParameterId]: Parameter
129
- },
130
- Metadata: {
131
- ...template.Metadata,
132
- "AWS::CloudFormation::Interface": {
133
- ...template?.Metadata?.["AWS::CloudFormation::Interface"],
134
- ParameterGroups: NewParameterGroups,
135
- ParameterLabels: {
136
- ...ParameterLabels,
137
- [ParameterId]: {
138
- default: Label
139
- }
140
- }
141
- }
142
- }
143
- };
144
- };
145
- var addParameters = (parameters, template) => parameters.reduce((acc, p) => addParameter(p, acc), template);
146
- var patchTemplate = (patch, template) => mergeValues([], template, patch, {
147
- [getValuePathString([
148
- // Parameter Groups
149
- "Metadata",
150
- "AWS::CloudFormation::Interface",
151
- "ParameterGroups"
152
- ])]: {
153
- strategy: "accumulate-unique-by",
154
- data: (pG) => pG?.Label?.default
155
- },
156
- [getValuePathString([
157
- // Parameter Group Parameter Ids
158
- "Metadata",
159
- "AWS::CloudFormation::Interface",
160
- "ParameterGroups",
161
- "#",
162
- "Parameters"
163
- ])]: {
164
- strategy: "accumulate-unique"
165
- }
166
- });
167
- var createResourcePack = (creator) => (params, template) => {
168
- const patch = creator(params);
169
- return patchTemplate(patch, template);
170
- };
171
- var SimpleCFT = class {
172
- /**
173
- * Create a SimpleCFT template wrapper.
174
- *
175
- * @param template - Initial CloudFormation template.
176
- */
177
- constructor(template = {
178
- AWSTemplateFormatVersion: "2010-09-09"
179
- }) {
180
- this.template = template;
181
- }
182
- /**
183
- * Apply a pack with configuration to the stack template.
184
- * @see `@resistdesign/voltra/iac` and `@resistdesign/voltra/iac/packs` for examples.
185
- * */
186
- applyPack = (pack, params) => {
187
- this.template = pack(params, this.template);
188
- return this;
189
- };
190
- /**
191
- * Apply a patch to the stack template.
192
- *
193
- * @param patch - Template patch to merge.
194
- * */
195
- patch = (patch) => {
196
- this.template = patchTemplate(patch, this.template);
197
- return this;
198
- };
199
- /**
200
- * Add a stack parameter including its descriptive info and an optional parameter group.
201
- *
202
- * @param parameter - Parameter definition and metadata.
203
- * */
204
- addParameter = (parameter) => {
205
- this.template = addParameter(parameter, this.template);
206
- return this;
207
- };
208
- /**
209
- * Add a group of stack parameters including their descriptive info and an optional parameter group.
210
- *
211
- * @param group - Parameter group definition.
212
- * */
213
- addParameterGroup = ({ Label: Group, Parameters }) => {
214
- const parameterIds = Object.keys(Parameters);
215
- const parameterList = parameterIds.map((ParameterId) => {
216
- const { Label, ...Parameter } = Parameters[ParameterId];
217
- return {
218
- Group,
219
- ParameterId,
220
- Label,
221
- Parameter
222
- };
223
- });
224
- this.template = addParameters(parameterList, this.template);
225
- return this;
226
- };
227
- /**
228
- * Use a modification to dynamically apply various changes at once.
229
- *
230
- * @param modification - Modification callback to apply.
231
- * */
232
- modify = (modification) => {
233
- modification(this);
234
- return this;
235
- };
236
- /**
237
- * Convert the stack template to a string.
238
- *
239
- * @returns JSON string representation of the template.
240
- * */
241
- toString = () => JSON.stringify(this.template, null, 2);
242
- /**
243
- * Convert the stack template to a JSON object.
244
- *
245
- * @returns Template JSON object.
246
- * */
247
- toJSON = () => this.template;
248
- /**
249
- * Convert the stack template to a YAML string.
250
- *
251
- * @returns YAML string representation of the template.
252
- * */
253
- toYAML = () => YAML.stringify(this.template, {
254
- aliasDuplicateObjects: false
255
- });
256
- };
257
-
258
- export { DEFAULT_MERGE_STRATEGY, SimpleCFT, addParameter, addParameters, createResourcePack, getValuePathArray, getValuePathString, isConstructedFrom, mergeValues, patchTemplate };
1
+ export { DEFAULT_MERGE_STRATEGY, SimpleCFT, addParameter, addParameters, createResourcePack, getValuePathArray, getValuePathString, isConstructedFrom, mergeValues, patchTemplate } from '../chunk-ATO2455Q.js';
2
+ import '../chunk-I2KLQ2HA.js';