@aws-mdaa/dataops-job-l3-construct 1.5.0 → 1.6.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.
Files changed (90) hide show
  1. package/.jsii +38 -28
  2. package/README.md +5 -0
  3. package/lib/dataops-job-l3-construct.d.ts +8 -1
  4. package/lib/dataops-job-l3-construct.js +40 -13
  5. package/node_modules/@aws-mdaa/config/README.md +3 -0
  6. package/node_modules/@aws-mdaa/config/lib/blueprint-value-transformer.d.ts +20 -0
  7. package/node_modules/@aws-mdaa/config/lib/blueprint-value-transformer.js +70 -0
  8. package/node_modules/@aws-mdaa/config/lib/blueprint-value-transformer.ts +88 -0
  9. package/node_modules/@aws-mdaa/config/lib/config.d.ts +87 -0
  10. package/node_modules/@aws-mdaa/config/lib/config.js +7 -0
  11. package/node_modules/@aws-mdaa/config/lib/config.ts +92 -0
  12. package/node_modules/@aws-mdaa/config/lib/index.d.ts +11 -0
  13. package/node_modules/@aws-mdaa/config/lib/index.js +28 -0
  14. package/node_modules/@aws-mdaa/config/lib/index.ts +12 -0
  15. package/node_modules/@aws-mdaa/config/lib/param-transformer.d.ts +49 -0
  16. package/node_modules/@aws-mdaa/config/lib/param-transformer.js +160 -0
  17. package/node_modules/@aws-mdaa/config/lib/param-transformer.ts +159 -0
  18. package/node_modules/@aws-mdaa/config/lib/path-value-transformer.d.ts +10 -0
  19. package/node_modules/@aws-mdaa/config/lib/path-value-transformer.js +30 -0
  20. package/node_modules/@aws-mdaa/config/lib/path-value-transformer.ts +27 -0
  21. package/node_modules/@aws-mdaa/config/lib/ref-value-transformer.d.ts +44 -0
  22. package/node_modules/@aws-mdaa/config/lib/ref-value-transformer.js +243 -0
  23. package/node_modules/@aws-mdaa/config/lib/ref-value-transformer.ts +302 -0
  24. package/node_modules/@aws-mdaa/config/lib/ssm-ref-transformer.d.ts +8 -0
  25. package/node_modules/@aws-mdaa/config/lib/ssm-ref-transformer.js +22 -0
  26. package/node_modules/@aws-mdaa/config/lib/ssm-ref-transformer.ts +21 -0
  27. package/node_modules/@aws-mdaa/config/lib/transformer.d.ts +35 -0
  28. package/node_modules/@aws-mdaa/config/lib/transformer.js +66 -0
  29. package/node_modules/@aws-mdaa/config/lib/transformer.ts +74 -0
  30. package/node_modules/@aws-mdaa/config/package.json +42 -0
  31. package/node_modules/@aws-mdaa/config/test/blueprint-value-transformer.test.js +224 -0
  32. package/node_modules/@aws-mdaa/config/test/blueprint-value-transformer.test.ts +259 -0
  33. package/node_modules/@aws-mdaa/config/test/config-nt.test.d.ts +5 -0
  34. package/node_modules/@aws-mdaa/config/test/config-nt.test.js +129 -0
  35. package/node_modules/@aws-mdaa/config/test/config-nt.test.ts +163 -0
  36. package/node_modules/@aws-mdaa/config/test/config.test.d.ts +5 -0
  37. package/node_modules/@aws-mdaa/config/test/config.test.js +409 -0
  38. package/node_modules/@aws-mdaa/config/test/config.test.ts +517 -0
  39. package/node_modules/@aws-mdaa/config/test/param-transformer.test.d.ts +5 -0
  40. package/node_modules/@aws-mdaa/config/test/param-transformer.test.js +216 -0
  41. package/node_modules/@aws-mdaa/config/test/param-transformer.test.ts +234 -0
  42. package/node_modules/@aws-mdaa/config/test/path-value-transformer.test.d.ts +5 -0
  43. package/node_modules/@aws-mdaa/config/test/path-value-transformer.test.js +59 -0
  44. package/node_modules/@aws-mdaa/config/test/path-value-transformer.test.ts +68 -0
  45. package/node_modules/@aws-mdaa/config/test/ref-value-transformer.test.d.ts +5 -0
  46. package/node_modules/@aws-mdaa/config/test/ref-value-transformer.test.js +254 -0
  47. package/node_modules/@aws-mdaa/config/test/ref-value-transformer.test.ts +304 -0
  48. package/node_modules/@aws-mdaa/config/test/ssm-ref-transformer.test.d.ts +5 -0
  49. package/node_modules/@aws-mdaa/config/test/ssm-ref-transformer.test.js +66 -0
  50. package/node_modules/@aws-mdaa/config/test/ssm-ref-transformer.test.ts +79 -0
  51. package/node_modules/@aws-mdaa/config/tsconfig.tsbuildinfo +1 -0
  52. package/node_modules/lodash/README.md +2 -2
  53. package/node_modules/lodash/_baseOrderBy.js +1 -1
  54. package/node_modules/lodash/_baseUnset.js +7 -20
  55. package/node_modules/lodash/_setCacheHas.js +1 -1
  56. package/node_modules/lodash/compact.js +1 -1
  57. package/node_modules/lodash/core.js +3 -3
  58. package/node_modules/lodash/core.min.js +26 -25
  59. package/node_modules/lodash/fromPairs.js +3 -1
  60. package/node_modules/lodash/lodash.js +38 -27
  61. package/node_modules/lodash/lodash.min.js +125 -129
  62. package/node_modules/lodash/package.json +4 -2
  63. package/node_modules/lodash/random.js +9 -0
  64. package/node_modules/lodash/template.js +16 -4
  65. package/node_modules/lodash/templateSettings.js +4 -0
  66. package/package.json +27 -32
  67. package/node_modules/@aws-mdaa/s3-bucketpolicy-helper/README.md +0 -185
  68. package/node_modules/@aws-mdaa/s3-bucketpolicy-helper/lib/index.d.ts +0 -57
  69. package/node_modules/@aws-mdaa/s3-bucketpolicy-helper/lib/index.js +0 -198
  70. package/node_modules/@aws-mdaa/s3-bucketpolicy-helper/lib/index.ts +0 -241
  71. package/node_modules/@aws-mdaa/s3-bucketpolicy-helper/package.json +0 -44
  72. package/node_modules/@aws-mdaa/s3-bucketpolicy-helper/test/bucketpolicy-helper.test.js +0 -200
  73. package/node_modules/@aws-mdaa/s3-bucketpolicy-helper/test/bucketpolicy-helper.test.ts +0 -215
  74. package/node_modules/@aws-mdaa/s3-bucketpolicy-helper/tsconfig.tsbuildinfo +0 -1
  75. package/node_modules/@aws-mdaa/s3-inventory-helper/.npmignore +0 -34
  76. package/node_modules/@aws-mdaa/s3-inventory-helper/README.md +0 -3
  77. package/node_modules/@aws-mdaa/s3-inventory-helper/jest.config.js +0 -5
  78. package/node_modules/@aws-mdaa/s3-inventory-helper/lib/index.d.ts +0 -48
  79. package/node_modules/@aws-mdaa/s3-inventory-helper/lib/index.js +0 -213
  80. package/node_modules/@aws-mdaa/s3-inventory-helper/lib/index.ts +0 -241
  81. package/node_modules/@aws-mdaa/s3-inventory-helper/package.json +0 -44
  82. package/node_modules/@aws-mdaa/s3-inventory-helper/test/TODO +0 -0
  83. package/node_modules/@aws-mdaa/s3-inventory-helper/tsconfig.json +0 -40
  84. package/node_modules/@aws-mdaa/s3-inventory-helper/tsconfig.tsbuildinfo +0 -1
  85. package/node_modules/@aws-mdaa/s3-inventory-helper/typedoc.json +0 -7
  86. /package/node_modules/@aws-mdaa/{s3-bucketpolicy-helper → config}/.npmignore +0 -0
  87. /package/node_modules/@aws-mdaa/{s3-bucketpolicy-helper → config}/jest.config.js +0 -0
  88. /package/node_modules/@aws-mdaa/{s3-bucketpolicy-helper/test/bucketpolicy-helper.test.d.ts → config/test/blueprint-value-transformer.test.d.ts} +0 -0
  89. /package/node_modules/@aws-mdaa/{s3-bucketpolicy-helper → config}/tsconfig.json +0 -0
  90. /package/node_modules/@aws-mdaa/{s3-bucketpolicy-helper → config}/typedoc.json +0 -0
@@ -0,0 +1,517 @@
1
+ /*!
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import { App, Stack } from 'aws-cdk-lib';
7
+ // nosemgrep
8
+ import * as path from 'path';
9
+ import {
10
+ MdaaConfigRefValueTransformer,
11
+ MdaaConfigSSMValueTransformer,
12
+ MdaaConfigTransformer,
13
+ ConfigConfigPathValueTransformer,
14
+ MdaaServiceCatalogProductConfig,
15
+ IMdaaConfigValueTransformer,
16
+ MdaaConfigParamRefValueTransformer,
17
+ MdaaConfigRefValueTransformerProps,
18
+ MdaaConfigParamRefValueTransformerProps,
19
+ ConfigurationElement,
20
+ } from '../lib';
21
+ import * as console from 'console';
22
+ import { MdaaDefaultResourceNaming, MdaaResourceNamingConfig } from '@aws-mdaa/naming';
23
+
24
+ class TestKeyTransformer implements IMdaaConfigValueTransformer {
25
+ public transformValue(value: string, contextPath?: string | undefined): string {
26
+ console.log(`Transforming ${contextPath}:${value} -> "transformedValue"`);
27
+ return 'transformedKey';
28
+ }
29
+ }
30
+
31
+ class TestValueTransformer implements IMdaaConfigValueTransformer {
32
+ public transformValue(value: string, contextPath?: string | undefined): string {
33
+ console.log(`Transforming ${contextPath}:${value} -> "transformedValue"`);
34
+ return 'transformedValue';
35
+ }
36
+ }
37
+ describe('Test MdaaConfigKeyTransformer', () => {
38
+ describe('Test transformConfigObject', () => {
39
+ const testConfigObj = {
40
+ testString: 'testing',
41
+ };
42
+ const transformedConfig = new MdaaConfigTransformer(
43
+ new TestValueTransformer(),
44
+ new TestKeyTransformer(),
45
+ ).transformConfig(testConfigObj);
46
+
47
+ test('String Transformation', () => {
48
+ expect(transformedConfig['transformedKey']).toBe('transformedValue');
49
+ });
50
+ });
51
+ });
52
+ describe('Test MdaaConfigValueTransformer', () => {
53
+ describe('Test transformConfigObject', () => {
54
+ const testConfigObj = {
55
+ testString: 'testing',
56
+ testNumber: 123,
57
+ testObj: {
58
+ testObjString: 'testing',
59
+ },
60
+ testArray: ['testing1', 'testing2'],
61
+ };
62
+ const transformedConfig = new MdaaConfigTransformer(new TestValueTransformer()).transformConfig(testConfigObj);
63
+
64
+ test('String Transformation', () => {
65
+ expect(transformedConfig['testString']).toBe('transformedValue');
66
+ });
67
+ test('Number Transformation', () => {
68
+ expect(transformedConfig['testNumber']).toBe(123);
69
+ });
70
+ test('Child Object String Transformation', () => {
71
+ expect((transformedConfig['testObj'] as ConfigurationElement)['testObjString']).toBe('transformedValue');
72
+ });
73
+ test('Child Array String Transformation', () => {
74
+ expect((transformedConfig['testArray'] as unknown[])[0]).toBe('transformedValue');
75
+ expect((transformedConfig['testArray'] as unknown[])[1]).toBe('transformedValue');
76
+ });
77
+ });
78
+
79
+ describe('Test transformConfigArray', () => {
80
+ const testArray = [
81
+ 'testing1',
82
+ 'testing2',
83
+ {
84
+ testingobj: 'testingobjvalue',
85
+ },
86
+ ['testingchild1', 'testingchild2'],
87
+ 123,
88
+ ];
89
+ const transformedConfig = new MdaaConfigTransformer(new TestValueTransformer()).transformConfigArray(
90
+ '/',
91
+ testArray,
92
+ );
93
+ describe('Array String Transformation', () => {
94
+ test('Array String values', () => {
95
+ expect(transformedConfig[0]).toBe('transformedValue');
96
+ expect(transformedConfig[1]).toBe('transformedValue');
97
+ });
98
+ test('Array child object values', () => {
99
+ expect((transformedConfig[2] as ConfigurationElement)['testingobj']).toBe('transformedValue');
100
+ });
101
+ test('Array child array values', () => {
102
+ expect((transformedConfig[3] as ConfigurationElement)[0]).toBe('transformedValue');
103
+ expect((transformedConfig[3] as ConfigurationElement)[1]).toBe('transformedValue');
104
+ });
105
+ test('Array number values', () => {
106
+ expect(transformedConfig[4]).toBe(123);
107
+ });
108
+ });
109
+ });
110
+ });
111
+ describe('Test MdaaConfigRefValueTransformer', () => {
112
+ // Helper function that mimics CLI encoding (copied from packages/cli/lib/utils.ts)
113
+ // This documents the encoding contract that the decoder must handle
114
+ function encodeContextValue(contextValue: unknown): string {
115
+ let encodedContextValue: string;
116
+ if (contextValue instanceof Array) {
117
+ encodedContextValue = `"list:${JSON.stringify(contextValue)}"`;
118
+ } else if (contextValue instanceof Object) {
119
+ encodedContextValue = `"obj:${JSON.stringify(contextValue)}"`;
120
+ } else if (typeof contextValue === 'string') {
121
+ encodedContextValue = contextValue;
122
+ } else if (typeof contextValue === 'boolean') {
123
+ encodedContextValue = contextValue ? 'true' : 'false';
124
+ } else {
125
+ throw Error(`Don't know how to handle type ${contextValue}`);
126
+ }
127
+ return encodedContextValue;
128
+ }
129
+
130
+ const testContextObj = {
131
+ testingkey: 'testingobjval',
132
+ };
133
+ const testContextList = ['val1', 'val2', 'val3'];
134
+ const context = {
135
+ org: 'testorg',
136
+ domain: 'testdomain',
137
+ env: 'testenv',
138
+ module_name: 'testmodule',
139
+ test_context_obj: encodeContextValue(testContextObj),
140
+ test_context_name: 'test_context_value',
141
+ test_context_list: encodeContextValue(testContextList),
142
+ };
143
+ const testApp = new App({ context: context });
144
+ const testStack = new Stack(testApp, 'testStack');
145
+ const namingProps: MdaaResourceNamingConfig = {
146
+ cdkNode: new App().node,
147
+ org: 'test-org',
148
+ env: 'test-env',
149
+ domain: 'test-domain',
150
+ moduleName: 'test-module',
151
+ };
152
+
153
+ const naming = new MdaaDefaultResourceNaming(namingProps);
154
+
155
+ const transformerProps: MdaaConfigRefValueTransformerProps = {
156
+ naming: naming,
157
+ org: 'testorg',
158
+ domain: 'testdomain',
159
+ env: 'testenv',
160
+ module_name: 'testmodule',
161
+ scope: testStack,
162
+ };
163
+
164
+ const serviceCatalogConfig: MdaaServiceCatalogProductConfig = {
165
+ portfolio_arn: 'dummy-portfolio-arn',
166
+ portfolio_bucket_name: 'test-bucket',
167
+ owner: 'owner',
168
+ name: 'test product name',
169
+ launch_role_name: 'dummy-launch-role',
170
+ parameters: {
171
+ number_param: {
172
+ props: {
173
+ type: 'Number',
174
+ description: 'Sample number parameter',
175
+ default: 10,
176
+ },
177
+ },
178
+ string_param: {
179
+ props: {
180
+ type: 'String',
181
+ description: 'Sample string parameter',
182
+ default: 'default_string',
183
+ },
184
+ },
185
+ list_param: {
186
+ props: {
187
+ type: 'CommaDelimitedList',
188
+ description: 'Sample list parameter',
189
+ default: 'sample,list,of,strings',
190
+ },
191
+ },
192
+ },
193
+ };
194
+ test('Nested', () => {
195
+ const transformedValue = new MdaaConfigRefValueTransformer(transformerProps).transformValue(
196
+ 'testing{{resolve:ssm:/{{org}}/{{domain}}/{{env}}/{{module_name}}}}testing',
197
+ );
198
+ expect(transformedValue).toMatch(/testing\${Token\[TOKEN.\d+]}testing/);
199
+ });
200
+ test('MultiRef', () => {
201
+ const transformedValue = new MdaaConfigRefValueTransformer(transformerProps).transformValue(
202
+ 'multi-{{org}}-{{domain}}-{{env}}',
203
+ );
204
+ expect(transformedValue).toBe('multi-testorg-testdomain-testenv');
205
+ });
206
+ test('No Ref', () => {
207
+ const transformedValue = new MdaaConfigRefValueTransformer(transformerProps).transformValue('noref');
208
+ expect(transformedValue).toBe('noref');
209
+ });
210
+
211
+ test('Env Var', () => {
212
+ process.env['TEST_VAR'] = 'testval';
213
+ const transformedValue = new MdaaConfigRefValueTransformer(transformerProps).transformValue('{{env_var:TEST_VAR}}');
214
+ expect(transformedValue).toBe('testval');
215
+ });
216
+
217
+ test('MissingContext', () => {
218
+ expect(() => new MdaaConfigRefValueTransformer(transformerProps).transformValue('{{context:missing}}')).toThrow();
219
+ });
220
+
221
+ test('Context Obj - Naked Reference', () => {
222
+ const transformedValue = new MdaaConfigRefValueTransformer(transformerProps).transformValue(
223
+ '{{context:test_context_obj}}',
224
+ );
225
+ // Naked reference should return the actual object
226
+ expect(transformedValue).toEqual(testContextObj);
227
+ });
228
+
229
+ test('Context Obj - Embedded Reference Should Error', () => {
230
+ // Embedding an object in a string should throw an error
231
+ expect(() => {
232
+ new MdaaConfigRefValueTransformer(transformerProps).transformValue('prefix-{{context:test_context_obj}}');
233
+ }).toThrow(/Cannot embed array or object context value in string/);
234
+ });
235
+
236
+ test('Context List - Naked Reference', () => {
237
+ const transformedValue = new MdaaConfigRefValueTransformer(transformerProps).transformValue(
238
+ '{{context:test_context_list}}',
239
+ );
240
+ // Naked reference should return the actual array
241
+ expect(transformedValue).toEqual(testContextList);
242
+ });
243
+
244
+ test('Context List - Embedded Reference Should Error', () => {
245
+ // Embedding an array in a string should throw an error
246
+ expect(() => {
247
+ new MdaaConfigRefValueTransformer(transformerProps).transformValue('prefix-{{context:test_context_list}}');
248
+ }).toThrow(/Cannot embed array or object context value in string/);
249
+ });
250
+
251
+ test('Resolve ssm ref', () => {
252
+ const transformedValue = new MdaaConfigRefValueTransformer(transformerProps).transformValue(
253
+ 'testing{{resolve:ssm:/test/param/path}}testing',
254
+ );
255
+ expect(transformedValue).toMatch(/testing\${Token\[TOKEN.\d+]}testing/);
256
+ });
257
+ test('Resolve ssm non ref', () => {
258
+ const transformedValue = new MdaaConfigRefValueTransformer(transformerProps).transformValue(
259
+ 'testing{{resolve:nonssm}}testing',
260
+ );
261
+ expect(transformedValue).toBe('testing{{resolve:nonssm}}testing');
262
+ });
263
+ test('Context', () => {
264
+ const transformedValue = new MdaaConfigRefValueTransformer(transformerProps).transformValue(
265
+ 'testing{{context:test_context_name}}testing',
266
+ );
267
+ expect(transformedValue).toBe('testingtest_context_valuetesting');
268
+ });
269
+ test('ContextOrg', () => {
270
+ const transformedValue = new MdaaConfigRefValueTransformer(transformerProps).transformValue(
271
+ 'testing{{context:org}}testing',
272
+ );
273
+ expect(transformedValue).toBe('testingtestorgtesting');
274
+ });
275
+ test('OrgRef', () => {
276
+ const transformedValue = new MdaaConfigRefValueTransformer(transformerProps).transformValue('{{org}}');
277
+ expect(transformedValue).toBe('testorg');
278
+ });
279
+
280
+ const paramTransformerProps: MdaaConfigParamRefValueTransformerProps = {
281
+ ...transformerProps,
282
+ paramProps: Object.fromEntries(
283
+ Object.entries(serviceCatalogConfig.parameters || {}).map(([paramName, props]) => {
284
+ return [paramName, props.props];
285
+ }),
286
+ ),
287
+ };
288
+ test('Param', () => {
289
+ const transformedValue = new MdaaConfigParamRefValueTransformer(paramTransformerProps).transformValue(
290
+ '{{param:paramname}}',
291
+ );
292
+ expect(transformedValue).toMatch(/\${Token\[TOKEN.\d+]}/);
293
+ });
294
+
295
+ test('ParamNotInServiceCatalogConfig', () => {
296
+ const transformedValue = new MdaaConfigParamRefValueTransformer(paramTransformerProps).transformValue(
297
+ '{{param:parameter_not_in_sc_config}}',
298
+ );
299
+ expect(transformedValue).toMatch(/\${Token\[TOKEN.\d+]}/);
300
+ });
301
+ test('StringParamInServiceCatalogConfig', () => {
302
+ const transformedValue = new MdaaConfigParamRefValueTransformer(paramTransformerProps).transformValue(
303
+ '{{param:string_param}}',
304
+ );
305
+ expect(transformedValue).toMatch(/\${Token\[TOKEN.\d+]}/);
306
+ });
307
+
308
+ test('NumberParamInServiceCatalogConfig', () => {
309
+ const transformedValue = new MdaaConfigParamRefValueTransformer(paramTransformerProps).transformValue(
310
+ '{{param:number_param}}',
311
+ );
312
+ expect(typeof transformedValue).toBe('number');
313
+ });
314
+ test('ListParamInServiceCatalogConfig', () => {
315
+ const transformedValue = new MdaaConfigParamRefValueTransformer(paramTransformerProps).transformValue(
316
+ '{{param:list_param}}',
317
+ );
318
+ expect(transformedValue).toMatch(/#{Token\[TOKEN.\d+]}/);
319
+ });
320
+ test('StringParamAnnotation', () => {
321
+ const transformedValue = new MdaaConfigParamRefValueTransformer(paramTransformerProps).transformValue(
322
+ '{{param:string:string_param}}',
323
+ );
324
+ expect(transformedValue).toMatch(/\${Token\[TOKEN.\d+]}/);
325
+ });
326
+ test('NumberParamAnnotation', () => {
327
+ const transformedValue = new MdaaConfigParamRefValueTransformer(paramTransformerProps).transformValue(
328
+ '{{param:number:number_param}}',
329
+ );
330
+ expect(typeof transformedValue).toBe('number');
331
+ });
332
+ test('ListParamAnnotation', () => {
333
+ const transformedValue = new MdaaConfigParamRefValueTransformer(paramTransformerProps).transformValue(
334
+ '{{param:list:list_param}}',
335
+ );
336
+ expect(transformedValue).toMatch(/#{Token\[TOKEN.\d+]}/);
337
+ });
338
+ test('PrefixedNumberParam', () => {
339
+ const transformedValue = new MdaaConfigParamRefValueTransformer(paramTransformerProps).transformValue(
340
+ 'testing{{param:number:number_param}}',
341
+ );
342
+ expect(transformedValue).toMatch(/^testing-\d+(\.\d+)?(e\+\d+)?$/);
343
+ });
344
+ test('PrefixedListParam', () => {
345
+ const transformedValue = new MdaaConfigParamRefValueTransformer(paramTransformerProps).transformValue(
346
+ 'testing{{param:list:list_param}}',
347
+ );
348
+ expect(transformedValue).toMatch(/testing#{Token\[TOKEN.\d+]}/);
349
+ });
350
+ test('NestedResolutionWithinNumberParam', () => {
351
+ const transformedValue = new MdaaConfigParamRefValueTransformer(paramTransformerProps).transformValue(
352
+ '{{param:number:{{org}}_param}}',
353
+ );
354
+ expect(typeof transformedValue).toBe('number');
355
+ });
356
+
357
+ test('Partition', () => {
358
+ const transformedValue = new MdaaConfigRefValueTransformer(transformerProps).transformValue('{{partition}}');
359
+ expect(transformedValue).toMatch(/\${Token\[AWS.Partition.\d+]}/);
360
+ });
361
+ test('Region', () => {
362
+ const transformedValue = new MdaaConfigRefValueTransformer(transformerProps).transformValue('{{region}}');
363
+ expect(transformedValue).toMatch(/\${Token\[AWS.Region.\d+]}/);
364
+ });
365
+
366
+ test('Account', () => {
367
+ const transformedValue = new MdaaConfigRefValueTransformer(transformerProps).transformValue('{{account}}');
368
+ expect(transformedValue).toMatch(/\${Token\[AWS.AccountId.\d+]}/);
369
+ });
370
+ test('Module Name', () => {
371
+ const transformedValue = new MdaaConfigRefValueTransformer(transformerProps).transformValue('{{module_name}}');
372
+ expect(transformedValue).toBe('testmodule');
373
+ });
374
+
375
+ // Additional test cases for better coverage
376
+
377
+ test('Naked SSM Reference', () => {
378
+ const transformedValue = new MdaaConfigRefValueTransformer(transformerProps).transformValue(
379
+ '{{resolve:ssm:/test/param/path}}',
380
+ );
381
+ expect(transformedValue).toMatch(/\${Token\[TOKEN.\d+]}/);
382
+ });
383
+
384
+ test('Naked Env Var', () => {
385
+ process.env['NAKED_TEST_VAR'] = 'naked_testval';
386
+ const transformedValue = new MdaaConfigRefValueTransformer(transformerProps).transformValue(
387
+ '{{env_var:NAKED_TEST_VAR}}',
388
+ );
389
+ expect(transformedValue).toBe('naked_testval');
390
+ });
391
+
392
+ test('Missing Env Var - Embedded', () => {
393
+ delete process.env['MISSING_VAR'];
394
+ const transformedValue = new MdaaConfigRefValueTransformer(transformerProps).transformValue(
395
+ 'prefix-{{env_var:MISSING_VAR}}-suffix',
396
+ );
397
+ // Should leave the reference as-is when env var is undefined
398
+ expect(transformedValue).toBe('prefix-{{env_var:MISSING_VAR}}-suffix');
399
+ });
400
+
401
+ test('Missing Env Var - Naked Reference', () => {
402
+ delete process.env['MISSING_VAR_NAKED'];
403
+ const transformedValue = new MdaaConfigRefValueTransformer(transformerProps).transformValue(
404
+ '{{env_var:MISSING_VAR_NAKED}}',
405
+ );
406
+ // Should return the original string for naked reference with undefined env var
407
+ expect(transformedValue).toBe('{{env_var:MISSING_VAR_NAKED}}');
408
+ });
409
+
410
+ test('Nested Context Array in SSM Path Should Error', () => {
411
+ expect(() => {
412
+ new MdaaConfigRefValueTransformer(transformerProps).transformValue(
413
+ '{{resolve:ssm:/{{context:test_context_list}}/path}}',
414
+ );
415
+ }).toThrow(/Cannot embed array or object context value in string/);
416
+ });
417
+
418
+ test('Nested Context Object in String Should Error', () => {
419
+ expect(() => {
420
+ new MdaaConfigRefValueTransformer(transformerProps).transformValue(
421
+ 'prefix-{{resolve:ssm:/{{context:test_context_obj}}/path}}',
422
+ );
423
+ }).toThrow(/Cannot embed array or object context value in string/);
424
+ });
425
+
426
+ test('Boolean Context Value', () => {
427
+ const contextWithBool = {
428
+ ...context,
429
+ bool_value: 'true', // Encoded as string
430
+ };
431
+ const appWithBool = new App({ context: contextWithBool });
432
+ const stackWithBool = new Stack(appWithBool, 'testStackBool');
433
+ const propsWithBool = { ...transformerProps, scope: stackWithBool };
434
+
435
+ const transformedValue = new MdaaConfigRefValueTransformer(propsWithBool).transformValue('{{context:bool_value}}');
436
+ expect(transformedValue).toBe('true');
437
+ });
438
+
439
+ test('Nested Object Context', () => {
440
+ const nestedObj = {
441
+ outer: {
442
+ inner: 'value',
443
+ },
444
+ };
445
+ const contextWithNested = {
446
+ ...context,
447
+ nested_obj: encodeContextValue(nestedObj),
448
+ };
449
+ const appWithNested = new App({ context: contextWithNested });
450
+ const stackWithNested = new Stack(appWithNested, 'testStackNested');
451
+ const propsWithNested = { ...transformerProps, scope: stackWithNested };
452
+
453
+ const transformedValue = new MdaaConfigRefValueTransformer(propsWithNested).transformValue(
454
+ '{{context:nested_obj}}',
455
+ );
456
+ expect(transformedValue).toEqual(nestedObj);
457
+ });
458
+
459
+ test('Array with Mixed Types Context', () => {
460
+ const mixedArray = ['string', 123, true, { key: 'value' }];
461
+ const contextWithMixed = {
462
+ ...context,
463
+ mixed_array: encodeContextValue(mixedArray),
464
+ };
465
+ const appWithMixed = new App({ context: contextWithMixed });
466
+ const stackWithMixed = new Stack(appWithMixed, 'testStackMixed');
467
+ const propsWithMixed = { ...transformerProps, scope: stackWithMixed };
468
+
469
+ const transformedValue = new MdaaConfigRefValueTransformer(propsWithMixed).transformValue(
470
+ '{{context:mixed_array}}',
471
+ );
472
+ expect(transformedValue).toEqual(mixedArray);
473
+ });
474
+ });
475
+
476
+ describe('Test MdaaConfigSSMValueTransformer', () => {
477
+ test('Non ssm:', () => {
478
+ const transformedValue = new MdaaConfigSSMValueTransformer().transformValue('testvalue', 'testPath');
479
+ expect(transformedValue).toBe('testvalue');
480
+ });
481
+ test('Naked ssm:', () => {
482
+ const transformedValue = new MdaaConfigSSMValueTransformer().transformValue('ssm:testSSMParamPath', 'testPath');
483
+ expect(transformedValue).toBe('{{resolve:ssm:testSSMParamPath}}');
484
+ });
485
+ test('Ignored SSM: Action', () => {
486
+ const transformedValue = new MdaaConfigSSMValueTransformer().transformValue(
487
+ 'ssm:GetParameter',
488
+ 'policyDocument/Statement/Action',
489
+ );
490
+ expect(transformedValue).toBe('ssm:GetParameter');
491
+ });
492
+ });
493
+ describe('Test ConfigConfigPathValueTransformer', () => {
494
+ test('Non relative', () => {
495
+ const transformedValue = new ConfigConfigPathValueTransformer('testBaseDir').transformValue('testNonRelative');
496
+ expect(transformedValue).toBe('testNonRelative');
497
+ });
498
+ test('Relative', () => {
499
+ const transformedValue = new ConfigConfigPathValueTransformer('testBaseDir').transformValue('./relative');
500
+ expect(transformedValue).toBe(path.resolve('./relative'.replace(/^\./, 'testBaseDir')));
501
+ });
502
+
503
+ test('Parent Relative', () => {
504
+ const transformedValue = new ConfigConfigPathValueTransformer('testBaseDir').transformValue('../relative-parent');
505
+ expect(transformedValue).toBe(path.resolve('./relative-parent'));
506
+ });
507
+
508
+ test('Parent Sub folder Relative', () => {
509
+ const transformedValue = new ConfigConfigPathValueTransformer('testBaseDir').transformValue('../app/code');
510
+ expect(transformedValue).toBe(path.resolve('./app/code'));
511
+ });
512
+
513
+ test('Grandparent folder Relative', () => {
514
+ const transformedValue = new ConfigConfigPathValueTransformer('testBaseDir').transformValue('../../mdaa-naming');
515
+ expect(transformedValue).toBe(path.resolve('../mdaa-naming'));
516
+ });
517
+ });
@@ -0,0 +1,5 @@
1
+ /*!
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ export {};