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

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/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';
@@ -1,173 +1,7 @@
1
+ import { createResourcePack, SimpleCFT } from '../../chunk-ATO2455Q.js';
2
+ import '../../chunk-I2KLQ2HA.js';
1
3
  import YAML from 'yaml';
2
4
 
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 isConstructedFrom = (value, constructorReference) => value !== null && typeof value === "object" && "constructor" in value && value.constructor === constructorReference;
7
- var mergeValues = (valuePathArray = [], existingValue, newValue, mergeStrategyMap = {}) => {
8
- const valuePathString = getValuePathString(valuePathArray);
9
- const arrayIndexWildcardValuePathString = getValuePathString(
10
- valuePathArray.map((p) => typeof p === "number" ? "#" : p)
11
- );
12
- const {
13
- [valuePathString]: {
14
- strategy: specificKeyMergeStrategy = DEFAULT_MERGE_STRATEGY,
15
- data: specificKeyMergeStrategyData = void 0
16
- } = {},
17
- [arrayIndexWildcardValuePathString]: {
18
- strategy: arrayIndexWildcardMergeStrategy = DEFAULT_MERGE_STRATEGY,
19
- data: arrayIndexWildcardMergeStrategyData = void 0
20
- } = {}
21
- } = mergeStrategyMap;
22
- const mergeStrategy = valuePathString in mergeStrategyMap ? specificKeyMergeStrategy : arrayIndexWildcardMergeStrategy;
23
- const mergeStrategyData = valuePathString in mergeStrategyMap ? specificKeyMergeStrategyData : arrayIndexWildcardMergeStrategyData;
24
- let mergedValue = typeof newValue !== "undefined" ? newValue : existingValue;
25
- if (mergeStrategy !== "replace") {
26
- if (isConstructedFrom(existingValue, Array) && isConstructedFrom(newValue, Array)) {
27
- if (mergeStrategy === "accumulate") {
28
- mergedValue = [...existingValue, ...newValue];
29
- } else if (mergeStrategy === "accumulate-unique") {
30
- mergedValue = [
31
- ...existingValue,
32
- ...newValue.filter((item) => existingValue.indexOf(item) === -1)
33
- ];
34
- } else if (mergeStrategy === "accumulate-unique-by") {
35
- const existingItemMap = {};
36
- const newItemMap = {};
37
- for (let i = 0; i < existingValue.length; i++) {
38
- const existingItem = existingValue[i];
39
- if (existingItem && typeof existingItem === "object") {
40
- const identifier = mergeStrategyData instanceof Function ? mergeStrategyData(existingItem) : existingItem[mergeStrategyData];
41
- existingItemMap[identifier] = existingItem;
42
- }
43
- }
44
- for (let j = 0; j < newValue.length; j++) {
45
- const newItem = newValue[j];
46
- if (newItem && typeof newItem === "object") {
47
- const identifier = mergeStrategyData instanceof Function ? mergeStrategyData(newItem) : newItem[mergeStrategyData];
48
- newItemMap[identifier] = newItem;
49
- }
50
- }
51
- mergedValue = Object.keys({
52
- ...existingItemMap,
53
- ...newItemMap
54
- }).map(
55
- (id, index) => mergeValues(
56
- [...valuePathArray, index],
57
- existingItemMap[id],
58
- newItemMap[id],
59
- mergeStrategyMap
60
- )
61
- );
62
- } else if (mergeStrategy === "transpose") {
63
- const fullLength = Math.max(existingValue.length, newValue.length);
64
- mergedValue = [...new Array(fullLength)].map(
65
- (_empty, index) => mergeValues(
66
- [...valuePathArray, index],
67
- existingValue[index],
68
- newValue[index],
69
- mergeStrategyMap
70
- )
71
- );
72
- }
73
- } else if (isConstructedFrom(existingValue, Object) && isConstructedFrom(newValue, Object)) {
74
- mergedValue = Object.keys({ ...existingValue, ...newValue }).reduce(
75
- (acc, k) => ({
76
- ...acc,
77
- [k]: mergeValues(
78
- [...valuePathArray, k],
79
- existingValue[k],
80
- newValue[k],
81
- mergeStrategyMap
82
- )
83
- }),
84
- {}
85
- );
86
- }
87
- }
88
- return mergedValue;
89
- };
90
-
91
- // src/iac/utils/index.ts
92
- var addParameter = (parameterInfo, template) => {
93
- const { ParameterId, Parameter, Label, Group } = parameterInfo;
94
- const {
95
- Parameters,
96
- Metadata: {
97
- "AWS::CloudFormation::Interface": {
98
- ParameterGroups = [],
99
- ParameterLabels = {}
100
- } = {}
101
- } = {}
102
- } = template;
103
- let NewParameterGroups = ParameterGroups;
104
- if (Group) {
105
- const GroupObject = ParameterGroups.filter(
106
- (g) => g.Label?.default === Group
107
- )[0];
108
- NewParameterGroups = GroupObject ? ParameterGroups.map(
109
- (g) => g.Label?.default === Group ? {
110
- ...g,
111
- Parameters: [...g.Parameters || [], ParameterId]
112
- } : g
113
- ) : [
114
- ...ParameterGroups,
115
- {
116
- Label: {
117
- default: Group
118
- },
119
- Parameters: [ParameterId]
120
- }
121
- ];
122
- }
123
- return {
124
- ...template,
125
- Parameters: {
126
- ...Parameters,
127
- [ParameterId]: Parameter
128
- },
129
- Metadata: {
130
- ...template.Metadata,
131
- "AWS::CloudFormation::Interface": {
132
- ...template?.Metadata?.["AWS::CloudFormation::Interface"],
133
- ParameterGroups: NewParameterGroups,
134
- ParameterLabels: {
135
- ...ParameterLabels,
136
- [ParameterId]: {
137
- default: Label
138
- }
139
- }
140
- }
141
- }
142
- };
143
- };
144
- var addParameters = (parameters, template) => parameters.reduce((acc, p) => addParameter(p, acc), template);
145
- var patchTemplate = (patch, template) => mergeValues([], template, patch, {
146
- [getValuePathString([
147
- // Parameter Groups
148
- "Metadata",
149
- "AWS::CloudFormation::Interface",
150
- "ParameterGroups"
151
- ])]: {
152
- strategy: "accumulate-unique-by",
153
- data: (pG) => pG?.Label?.default
154
- },
155
- [getValuePathString([
156
- // Parameter Group Parameter Ids
157
- "Metadata",
158
- "AWS::CloudFormation::Interface",
159
- "ParameterGroups",
160
- "#",
161
- "Parameters"
162
- ])]: {
163
- strategy: "accumulate-unique"
164
- }
165
- });
166
- var createResourcePack = (creator) => (params, template) => {
167
- const patch = creator(params);
168
- return patchTemplate(patch, template);
169
- };
170
-
171
5
  // src/iac/packs/auth/user-management.ts
172
6
  var addUserManagement = createResourcePack(
173
7
  (config) => {
@@ -475,92 +309,6 @@ var addUserManagement = createResourcePack(
475
309
  };
476
310
  }
477
311
  );
478
- var SimpleCFT = class {
479
- /**
480
- * Create a SimpleCFT template wrapper.
481
- *
482
- * @param template - Initial CloudFormation template.
483
- */
484
- constructor(template = {
485
- AWSTemplateFormatVersion: "2010-09-09"
486
- }) {
487
- this.template = template;
488
- }
489
- /**
490
- * Apply a pack with configuration to the stack template.
491
- * @see `@resistdesign/voltra/iac` and `@resistdesign/voltra/iac/packs` for examples.
492
- * */
493
- applyPack = (pack, params) => {
494
- this.template = pack(params, this.template);
495
- return this;
496
- };
497
- /**
498
- * Apply a patch to the stack template.
499
- *
500
- * @param patch - Template patch to merge.
501
- * */
502
- patch = (patch) => {
503
- this.template = patchTemplate(patch, this.template);
504
- return this;
505
- };
506
- /**
507
- * Add a stack parameter including its descriptive info and an optional parameter group.
508
- *
509
- * @param parameter - Parameter definition and metadata.
510
- * */
511
- addParameter = (parameter) => {
512
- this.template = addParameter(parameter, this.template);
513
- return this;
514
- };
515
- /**
516
- * Add a group of stack parameters including their descriptive info and an optional parameter group.
517
- *
518
- * @param group - Parameter group definition.
519
- * */
520
- addParameterGroup = ({ Label: Group, Parameters }) => {
521
- const parameterIds = Object.keys(Parameters);
522
- const parameterList = parameterIds.map((ParameterId) => {
523
- const { Label, ...Parameter } = Parameters[ParameterId];
524
- return {
525
- Group,
526
- ParameterId,
527
- Label,
528
- Parameter
529
- };
530
- });
531
- this.template = addParameters(parameterList, this.template);
532
- return this;
533
- };
534
- /**
535
- * Use a modification to dynamically apply various changes at once.
536
- *
537
- * @param modification - Modification callback to apply.
538
- * */
539
- modify = (modification) => {
540
- modification(this);
541
- return this;
542
- };
543
- /**
544
- * Convert the stack template to a string.
545
- *
546
- * @returns JSON string representation of the template.
547
- * */
548
- toString = () => JSON.stringify(this.template, null, 2);
549
- /**
550
- * Convert the stack template to a JSON object.
551
- *
552
- * @returns Template JSON object.
553
- * */
554
- toJSON = () => this.template;
555
- /**
556
- * Convert the stack template to a YAML string.
557
- *
558
- * @returns YAML string representation of the template.
559
- * */
560
- toYAML = () => YAML.stringify(this.template, {
561
- aliasDuplicateObjects: false
562
- });
563
- };
564
312
 
565
313
  // src/iac/packs/auth.ts
566
314
  var addAuth = createResourcePack((config) => {
package/native/index.d.ts CHANGED
@@ -2,6 +2,10 @@
2
2
  * @packageDocumentation
3
3
  *
4
4
  * Native entrypoint exports.
5
+ *
6
+ * AGENT NOTE:
7
+ * In this native barrel, direct imports from `react-native` are expected and
8
+ * correct. Do not replace them with runtime import/require indirection hacks.
5
9
  */
6
10
  /**
7
11
  * @category native