@resistdesign/voltra 3.0.0-alpha.4 → 3.0.0-alpha.40

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 (219) hide show
  1. package/README.md +379 -14
  2. package/api/DBX/DBXAsserts.d.ts +95 -0
  3. package/api/DBX/DBXRequest.d.ts +5 -0
  4. package/api/DBX/DBXRuntime.d.ts +5 -0
  5. package/api/DBX/DBXScenarioConfig.d.ts +9 -0
  6. package/api/DBX/DBXSeed.d.ts +124 -0
  7. package/api/DBX/DBXTypes.d.ts +176 -0
  8. package/api/DBX/index.d.ts +8 -0
  9. package/api/DataAccessControl.d.ts +220 -0
  10. package/api/Indexing/API.d.ts +224 -0
  11. package/api/Indexing/Cursor.d.ts +101 -0
  12. package/api/Indexing/Handler/Config.d.ts +39 -0
  13. package/api/Indexing/Handler.d.ts +166 -0
  14. package/api/Indexing/Trace.d.ts +54 -0
  15. package/api/Indexing/Types.d.ts +204 -0
  16. package/api/Indexing/ddb/AwsSdkV3Adapter.d.ts +8 -0
  17. package/api/Indexing/ddb/Types.d.ts +209 -0
  18. package/api/Indexing/docId.d.ts +27 -0
  19. package/api/Indexing/exact/ExactDdb.d.ts +58 -0
  20. package/api/Indexing/exact/ExactIndex.d.ts +90 -0
  21. package/api/Indexing/exact/ExactS3.d.ts +41 -0
  22. package/api/Indexing/fieldQualification.d.ts +12 -0
  23. package/api/Indexing/fulltext/FullTextDdbBackend.d.ts +212 -0
  24. package/api/Indexing/fulltext/FullTextMemoryBackend.d.ts +93 -0
  25. package/api/Indexing/fulltext/Schema.d.ts +164 -0
  26. package/api/Indexing/hashUniversal.d.ts +13 -0
  27. package/api/Indexing/index.d.ts +45 -0
  28. package/api/Indexing/lossy/LossyDdb.d.ts +43 -0
  29. package/api/Indexing/lossy/LossyIndex.d.ts +72 -0
  30. package/api/Indexing/lossy/LossyS3.d.ts +40 -0
  31. package/api/Indexing/rel/Cursor.d.ts +25 -0
  32. package/api/Indexing/rel/Handlers.d.ts +144 -0
  33. package/api/Indexing/rel/RelationalDdb.d.ts +169 -0
  34. package/api/Indexing/rel/RelationalInMemoryBackend.d.ts +38 -0
  35. package/api/Indexing/rel/Types.d.ts +69 -0
  36. package/api/Indexing/structured/Cursor.d.ts +26 -0
  37. package/api/Indexing/structured/Handlers.d.ts +128 -0
  38. package/api/Indexing/structured/SearchStructured.d.ts +44 -0
  39. package/api/Indexing/structured/StructuredDdb.d.ts +184 -0
  40. package/api/Indexing/structured/StructuredDdbBackend.d.ts +112 -0
  41. package/api/Indexing/structured/StructuredInMemoryBackend.d.ts +40 -0
  42. package/api/Indexing/structured/StructuredInMemoryIndex.d.ts +61 -0
  43. package/api/Indexing/structured/StructuredStringLike.d.ts +54 -0
  44. package/api/Indexing/structured/StructuredWriter.d.ts +74 -0
  45. package/api/Indexing/structured/Types.d.ts +126 -0
  46. package/api/Indexing/structured/index.d.ts +9 -0
  47. package/api/Indexing/tokenize.d.ts +31 -0
  48. package/api/ORM/DACUtils.d.ts +270 -0
  49. package/api/ORM/ListItemUtils.d.ts +40 -0
  50. package/api/ORM/ORMRouteMap.d.ts +55 -0
  51. package/api/ORM/TypeInfoORMService.d.ts +740 -0
  52. package/api/ORM/drivers/DynamoDBDataItemDBDriver/ConfigTypes.d.ts +229 -0
  53. package/api/ORM/drivers/DynamoDBDataItemDBDriver.d.ts +89 -0
  54. package/api/ORM/drivers/InMemoryDataItemDBDriver/ConfigTypes.d.ts +4 -0
  55. package/api/ORM/drivers/InMemoryDataItemDBDriver.d.ts +55 -0
  56. package/api/ORM/drivers/InMemoryFileItemDBDriver/ConfigTypes.d.ts +13 -0
  57. package/api/ORM/drivers/InMemoryFileItemDBDriver.d.ts +98 -0
  58. package/api/ORM/drivers/InMemoryItemRelationshipDBDriver.d.ts +16 -0
  59. package/api/ORM/drivers/IndexingRelationshipDriver.d.ts +123 -0
  60. package/api/ORM/drivers/S3FileItemDBDriver/ConfigTypes.d.ts +322 -0
  61. package/api/ORM/drivers/S3FileItemDBDriver/S3FileDriver.d.ts +118 -0
  62. package/api/ORM/drivers/S3FileItemDBDriver.d.ts +71 -0
  63. package/api/ORM/drivers/common/SupportedTypeInfoORMDBDrivers.d.ts +36 -0
  64. package/api/ORM/drivers/common/Types.d.ts +197 -0
  65. package/api/ORM/drivers/common/index.d.ts +2 -0
  66. package/api/ORM/drivers/index.d.ts +8 -0
  67. package/api/ORM/index.d.ts +9 -0
  68. package/api/ORM/indexing/criteriaToStructuredWhere.d.ts +22 -0
  69. package/api/Router/AWS.d.ts +80 -0
  70. package/api/Router/Auth.d.ts +14 -0
  71. package/api/Router/CORS.d.ts +66 -0
  72. package/api/Router/Types.d.ts +138 -0
  73. package/api/Router/index.d.ts +89 -0
  74. package/api/index.d.ts +72 -6
  75. package/api/index.js +3291 -1954
  76. package/app/forms/Engine.d.ts +23 -0
  77. package/app/forms/UI.d.ts +83 -0
  78. package/app/forms/core/createAutoField.d.ts +43 -0
  79. package/app/forms/core/createFormRenderer.d.ts +25 -0
  80. package/app/forms/core/getFieldKind.d.ts +14 -0
  81. package/app/forms/core/index.d.ts +11 -0
  82. package/app/forms/core/mergeSuites.d.ts +23 -0
  83. package/app/forms/core/resolveSuite.d.ts +15 -0
  84. package/app/forms/core/types.d.ts +180 -0
  85. package/app/forms/index.d.ts +9 -0
  86. package/app/forms/types.d.ts +137 -0
  87. package/app/helpers/styled.d.ts +3 -0
  88. package/app/index.d.ts +102 -5
  89. package/app/index.js +98 -327
  90. package/app/utils/ApplicationState.d.ts +167 -0
  91. package/app/utils/ApplicationStateLoader.d.ts +86 -0
  92. package/app/utils/Controller.d.ts +10 -0
  93. package/app/utils/Debug.d.ts +14 -0
  94. package/app/utils/EasyLayout.d.ts +89 -0
  95. package/app/utils/History.d.ts +165 -0
  96. package/app/utils/Route.d.ts +173 -0
  97. package/app/utils/RouteHistory.d.ts +27 -0
  98. package/app/utils/Service.d.ts +45 -0
  99. package/app/utils/TypeInfoORMAPIUtils.d.ts +94 -0
  100. package/app/utils/TypeInfoORMClient.d.ts +103 -0
  101. package/app/utils/UniversalRouteAdapter.d.ts +73 -0
  102. package/app/utils/easy-layout/computeAreaBounds.d.ts +5 -0
  103. package/app/utils/easy-layout/computeTracks.d.ts +16 -0
  104. package/app/utils/easy-layout/index.d.ts +5 -0
  105. package/app/utils/easy-layout/parseTemplate.d.ts +12 -0
  106. package/app/utils/easy-layout/types.d.ts +52 -0
  107. package/app/utils/easy-layout/validateAreas.d.ts +5 -0
  108. package/app/utils/index.d.ts +24 -0
  109. package/build/TypeMapping.d.ts +17 -0
  110. package/build/TypeParsing.d.ts +10 -0
  111. package/build/index.d.ts +15 -0
  112. package/build/index.js +569 -0
  113. package/chunk-2MOLWZMQ.js +71 -0
  114. package/chunk-7AMEFPPP.js +78 -0
  115. package/chunk-ATO2455Q.js +258 -0
  116. package/chunk-DT6WWJUI.js +1185 -0
  117. package/chunk-I2KLQ2HA.js +19 -0
  118. package/chunk-TJFTWPXQ.js +39 -0
  119. package/chunk-WNFRDIBW.js +121 -0
  120. package/chunk-YCTVEW2I.js +546 -0
  121. package/common/CommandLine/collectRequiredEnvironmentVariables.d.ts +9 -0
  122. package/common/CommandLine/index.d.ts +6 -0
  123. package/common/HelperTypes.d.ts +9 -0
  124. package/common/IdGeneration/getSimpleId.d.ts +8 -0
  125. package/common/IdGeneration/index.d.ts +1 -0
  126. package/common/ItemRelationshipInfoTypes.d.ts +64 -0
  127. package/common/ItemRelationships/ItemRelationshipValidation.d.ts +21 -0
  128. package/common/ItemRelationships/index.d.ts +2 -0
  129. package/common/Logging/Utils.d.ts +10 -0
  130. package/common/Logging/index.d.ts +1 -0
  131. package/common/Routing.d.ts +81 -0
  132. package/common/SearchTypes.d.ts +227 -0
  133. package/common/SearchUtils.d.ts +55 -0
  134. package/common/SearchValidation.d.ts +27 -0
  135. package/common/StringTransformers.d.ts +28 -0
  136. package/common/Testing/CLI.d.ts +6 -0
  137. package/common/Testing/Types.d.ts +216 -0
  138. package/common/Testing/Utils.d.ts +112 -0
  139. package/common/Testing/index.d.ts +8 -0
  140. package/common/TypeInfoDataItemUtils.d.ts +39 -0
  141. package/{Types-C7XjUjoF.d.ts → common/TypeInfoORM/Types.d.ts} +117 -15
  142. package/common/TypeInfoORM/index.d.ts +3 -0
  143. package/common/TypeParsing/Constants.d.ts +4 -0
  144. package/common/TypeParsing/ParsingUtils/Constants.d.ts +8 -0
  145. package/common/TypeParsing/ParsingUtils/checkType.d.ts +14 -0
  146. package/common/TypeParsing/ParsingUtils/checkUnionType.d.ts +12 -0
  147. package/common/TypeParsing/ParsingUtils/extractCommentTags.d.ts +8 -0
  148. package/common/TypeParsing/ParsingUtils/extractLiteralValues.d.ts +12 -0
  149. package/common/TypeParsing/ParsingUtils/extractTypeDetails.d.ts +14 -0
  150. package/common/TypeParsing/ParsingUtils/getPrimaryFieldForTypeInfo.d.ts +18 -0
  151. package/common/TypeParsing/ParsingUtils/getTypeInfo.d.ts +9 -0
  152. package/common/TypeParsing/ParsingUtils/getTypeInfoField.d.ts +9 -0
  153. package/common/TypeParsing/ParsingUtils/getTypeInfoFromAliasType.d.ts +11 -0
  154. package/common/TypeParsing/ParsingUtils/getTypeInfoFromFieldFilter.d.ts +12 -0
  155. package/common/TypeParsing/ParsingUtils/getTypeInfoFromTypeAlias.d.ts +11 -0
  156. package/common/TypeParsing/ParsingUtils/getTypeKeyword.d.ts +9 -0
  157. package/common/TypeParsing/ParsingUtils/getUnionOrIntersectionTypeInfo.d.ts +11 -0
  158. package/common/TypeParsing/ParsingUtils/getUnionOrLiteralStringValues.d.ts +8 -0
  159. package/common/TypeParsing/TypeInfo.d.ts +222 -0
  160. package/common/TypeParsing/Utils.d.ts +47 -0
  161. package/common/TypeParsing/Validation.d.ts +327 -0
  162. package/common/TypeParsing/index.d.ts +8 -0
  163. package/common/index.d.ts +40 -4
  164. package/common/index.js +25 -1737
  165. package/{index-BkFZlfit.d.ts → iac/SimpleCFT.d.ts} +5 -25
  166. package/iac/index.d.ts +40 -2
  167. package/iac/index.js +2 -1661
  168. package/iac/packs/auth.d.ts +131 -0
  169. package/iac/packs/build/utils.d.ts +289 -0
  170. package/iac/packs/build.d.ts +92 -0
  171. package/iac/packs/cdn.d.ts +33 -0
  172. package/iac/packs/cloud-function.d.ts +67 -0
  173. package/iac/packs/database.d.ts +32 -0
  174. package/iac/packs/dns.d.ts +34 -0
  175. package/iac/packs/file-storage.d.ts +46 -0
  176. package/iac/packs/gateway.d.ts +82 -0
  177. package/iac/packs/index.d.ts +60 -1
  178. package/iac/packs/index.js +311 -566
  179. package/iac/packs/repo.d.ts +28 -0
  180. package/iac/packs/ssl-certificate.d.ts +28 -0
  181. package/iac/types/Constants.d.ts +24 -0
  182. package/{index-DcvJOZ_c.d.ts → iac/types/IaCTypes.d.ts} +23 -1018
  183. package/iac/types/Renderers.d.ts +96 -0
  184. package/iac/types/Types.d.ts +131 -0
  185. package/iac/types/Utils.d.ts +9 -0
  186. package/iac/types/generate.d.ts +1 -0
  187. package/iac/utils/index.d.ts +87 -0
  188. package/iac/utils/patch-utils.d.ts +66 -0
  189. package/iac-packs/index.d.ts +6 -0
  190. package/native/forms/UI.d.ts +73 -0
  191. package/native/forms/createNativeFormRenderer.d.ts +21 -0
  192. package/native/forms/index.d.ts +25 -0
  193. package/native/forms/primitives/index.d.ts +38 -0
  194. package/native/forms/suite.d.ts +15 -0
  195. package/native/index.d.ts +19 -0
  196. package/native/index.js +748 -0
  197. package/native/testing/react-native.d.ts +46 -0
  198. package/native/utils/EasyLayout.d.ts +88 -0
  199. package/native/utils/History.d.ts +102 -0
  200. package/native/utils/Route.d.ts +80 -0
  201. package/native/utils/index.d.ts +20 -0
  202. package/package.json +54 -21
  203. package/web/forms/UI.d.ts +74 -0
  204. package/web/forms/createWebFormRenderer.d.ts +21 -0
  205. package/web/forms/index.d.ts +9 -0
  206. package/web/forms/primitives/index.d.ts +21 -0
  207. package/web/forms/suite.d.ts +15 -0
  208. package/web/index.d.ts +15 -0
  209. package/web/index.js +668 -0
  210. package/web/utils/EasyLayout.d.ts +47 -0
  211. package/web/utils/Route.d.ts +16 -0
  212. package/web/utils/index.d.ts +7 -0
  213. package/SearchTypes-DjN6YQzE.d.ts +0 -577
  214. package/Validation-CFP59oIP.d.ts +0 -226
  215. package/index-C3-iD9Mh.d.ts +0 -690
  216. package/index-DZ2BB4iX.d.ts +0 -5357
  217. package/index-IokxSNxm.d.ts +0 -745
  218. package/index.d.ts +0 -13
  219. package/index.js +0 -10973
package/iac/index.js CHANGED
@@ -1,1661 +1,2 @@
1
- import YAML from 'yaml';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __export = (target, all) => {
5
- for (var name in all)
6
- __defProp(target, name, { get: all[name], enumerable: true });
7
- };
8
-
9
- // src/iac/packs/index.ts
10
- var packs_exports = {};
11
- __export(packs_exports, {
12
- COMMAND_HELPERS: () => COMMAND_HELPERS,
13
- DEFAULT_AUTH_TYPE: () => DEFAULT_AUTH_TYPE,
14
- DEFAULT_BUILD_PIPELINE_REPO_PROVIDER: () => DEFAULT_BUILD_PIPELINE_REPO_PROVIDER,
15
- PLACEHOLDER_FUNCTION_CODE: () => PLACEHOLDER_FUNCTION_CODE,
16
- addAuth: () => addAuth,
17
- addBuildPipeline: () => addBuildPipeline,
18
- addCDN: () => addCDN,
19
- addCloudFunction: () => addCloudFunction,
20
- addDNS: () => addDNS,
21
- addDatabase: () => addDatabase,
22
- addGateway: () => addGateway,
23
- addRepo: () => addRepo,
24
- addSSLCertificate: () => addSSLCertificate,
25
- addSecureFileStorage: () => addSecureFileStorage,
26
- createBuildSpec: () => createBuildSpec
27
- });
28
-
29
- // src/iac/utils/index.ts
30
- var utils_exports = {};
31
- __export(utils_exports, {
32
- DEFAULT_MERGE_STRATEGY: () => DEFAULT_MERGE_STRATEGY,
33
- addParameter: () => addParameter,
34
- addParameters: () => addParameters,
35
- createResourcePack: () => createResourcePack,
36
- getValuePathArray: () => getValuePathArray,
37
- getValuePathString: () => getValuePathString,
38
- isConstructedFrom: () => isConstructedFrom,
39
- mergeValues: () => mergeValues,
40
- patchTemplate: () => patchTemplate
41
- });
42
-
43
- // src/iac/utils/patch-utils.ts
44
- var DEFAULT_MERGE_STRATEGY = "transpose";
45
- var getValuePathString = (valuePathArray = []) => valuePathArray.map((p) => encodeURIComponent(p)).join("/");
46
- var getValuePathArray = (valuePathString = "") => valuePathString.split("/").map((p) => decodeURIComponent(p));
47
- var isConstructedFrom = (value, constructorReference) => value !== null && typeof value === "object" && "constructor" in value && value.constructor === constructorReference;
48
- var mergeValues = (valuePathArray = [], existingValue, newValue, mergeStrategyMap = {}) => {
49
- const valuePathString = getValuePathString(valuePathArray);
50
- const arrayIndexWildcardValuePathString = getValuePathString(
51
- valuePathArray.map((p) => typeof p === "number" ? "#" : p)
52
- );
53
- const {
54
- [valuePathString]: {
55
- strategy: specificKeyMergeStrategy = DEFAULT_MERGE_STRATEGY,
56
- data: specificKeyMergeStrategyData = void 0
57
- } = {},
58
- [arrayIndexWildcardValuePathString]: {
59
- strategy: arrayIndexWildcardMergeStrategy = DEFAULT_MERGE_STRATEGY,
60
- data: arrayIndexWildcardMergeStrategyData = void 0
61
- } = {}
62
- } = mergeStrategyMap;
63
- const mergeStrategy = valuePathString in mergeStrategyMap ? specificKeyMergeStrategy : arrayIndexWildcardMergeStrategy;
64
- const mergeStrategyData = valuePathString in mergeStrategyMap ? specificKeyMergeStrategyData : arrayIndexWildcardMergeStrategyData;
65
- let mergedValue = typeof newValue !== "undefined" ? newValue : existingValue;
66
- if (mergeStrategy !== "replace") {
67
- if (isConstructedFrom(existingValue, Array) && isConstructedFrom(newValue, Array)) {
68
- if (mergeStrategy === "accumulate") {
69
- mergedValue = [...existingValue, ...newValue];
70
- } else if (mergeStrategy === "accumulate-unique") {
71
- mergedValue = [
72
- ...existingValue,
73
- ...newValue.filter(
74
- (item) => existingValue.indexOf(item) === -1
75
- )
76
- ];
77
- } else if (mergeStrategy === "accumulate-unique-by") {
78
- const existingItemMap = {};
79
- const newItemMap = {};
80
- for (let i = 0; i < existingValue.length; i++) {
81
- const existingItem = existingValue[i];
82
- if (existingItem && typeof existingItem === "object") {
83
- const identifier = mergeStrategyData instanceof Function ? mergeStrategyData(existingItem) : existingItem[mergeStrategyData];
84
- existingItemMap[identifier] = existingItem;
85
- }
86
- }
87
- for (let j = 0; j < newValue.length; j++) {
88
- const newItem = newValue[j];
89
- if (newItem && typeof newItem === "object") {
90
- const identifier = mergeStrategyData instanceof Function ? mergeStrategyData(newItem) : newItem[mergeStrategyData];
91
- newItemMap[identifier] = newItem;
92
- }
93
- }
94
- mergedValue = Object.keys({
95
- ...existingItemMap,
96
- ...newItemMap
97
- }).map(
98
- (id, index) => mergeValues(
99
- [...valuePathArray, index],
100
- existingItemMap[id],
101
- newItemMap[id],
102
- mergeStrategyMap
103
- )
104
- );
105
- } else if (mergeStrategy === "transpose") {
106
- const fullLength = Math.max(existingValue.length, newValue.length);
107
- mergedValue = [...new Array(fullLength)].map(
108
- (_empty, index) => mergeValues(
109
- [...valuePathArray, index],
110
- existingValue[index],
111
- newValue[index],
112
- mergeStrategyMap
113
- )
114
- );
115
- }
116
- } else if (isConstructedFrom(existingValue, Object) && isConstructedFrom(newValue, Object)) {
117
- mergedValue = Object.keys({ ...existingValue, ...newValue }).reduce(
118
- (acc, k) => ({
119
- ...acc,
120
- [k]: mergeValues(
121
- [...valuePathArray, k],
122
- existingValue[k],
123
- newValue[k],
124
- mergeStrategyMap
125
- )
126
- }),
127
- {}
128
- );
129
- }
130
- }
131
- return mergedValue;
132
- };
133
-
134
- // src/iac/utils/index.ts
135
- var addParameter = (parameterInfo, template) => {
136
- const { ParameterId, Parameter, Label, Group } = parameterInfo;
137
- const {
138
- Parameters,
139
- Metadata: {
140
- "AWS::CloudFormation::Interface": {
141
- ParameterGroups = [],
142
- ParameterLabels = {}
143
- } = {}
144
- } = {}
145
- } = template;
146
- let NewParameterGroups = ParameterGroups;
147
- if (Group) {
148
- const GroupObject = ParameterGroups.filter(
149
- (g) => g.Label?.default === Group
150
- )[0];
151
- NewParameterGroups = GroupObject ? ParameterGroups.map(
152
- (g) => g.Label?.default === Group ? {
153
- ...g,
154
- Parameters: [...g.Parameters || [], ParameterId]
155
- } : g
156
- ) : [
157
- ...ParameterGroups,
158
- {
159
- Label: {
160
- default: Group
161
- },
162
- Parameters: [ParameterId]
163
- }
164
- ];
165
- }
166
- return {
167
- ...template,
168
- Parameters: {
169
- ...Parameters,
170
- [ParameterId]: Parameter
171
- },
172
- Metadata: {
173
- ...template.Metadata,
174
- "AWS::CloudFormation::Interface": {
175
- ...template?.Metadata?.["AWS::CloudFormation::Interface"],
176
- ParameterGroups: NewParameterGroups,
177
- ParameterLabels: {
178
- ...ParameterLabels,
179
- [ParameterId]: {
180
- default: Label
181
- }
182
- }
183
- }
184
- }
185
- };
186
- };
187
- var addParameters = (parameters, template) => parameters.reduce((acc, p) => addParameter(p, acc), template);
188
- var patchTemplate = (patch, template) => mergeValues([], template, patch, {
189
- [getValuePathString([
190
- // Parameter Groups
191
- "Metadata",
192
- "AWS::CloudFormation::Interface",
193
- "ParameterGroups"
194
- ])]: {
195
- strategy: "accumulate-unique-by",
196
- data: (pG) => pG?.Label?.default
197
- },
198
- [getValuePathString([
199
- // Parameter Group Parameter Ids
200
- "Metadata",
201
- "AWS::CloudFormation::Interface",
202
- "ParameterGroups",
203
- "#",
204
- "Parameters"
205
- ])]: {
206
- strategy: "accumulate-unique"
207
- }
208
- });
209
- var createResourcePack = (creator) => (params, template) => {
210
- const patch = creator(params);
211
- return patchTemplate(patch, template);
212
- };
213
-
214
- // src/iac/packs/auth/user-management.ts
215
- var addUserManagement = createResourcePack(
216
- ({
217
- id,
218
- authRoleName,
219
- unauthRoleName,
220
- domainName,
221
- hostedZoneId,
222
- sslCertificateArn,
223
- callbackUrls,
224
- logoutUrls,
225
- baseDomainRecordAliasTargetDNSName,
226
- apiGatewayRESTAPIId,
227
- apiStageName
228
- }) => {
229
- const apiRoleConfig = apiGatewayRESTAPIId && apiStageName ? {
230
- [`${id}IdentityPoolRoles`]: {
231
- Type: "AWS::Cognito::IdentityPoolRoleAttachment",
232
- Properties: {
233
- IdentityPoolId: {
234
- Ref: `${id}IdentityPool`
235
- },
236
- Roles: {
237
- authenticated: {
238
- "Fn::GetAtt": [`${id}AuthRole`, "Arn"]
239
- },
240
- unauthenticated: {
241
- "Fn::GetAtt": [`${id}UnauthRole`, "Arn"]
242
- }
243
- }
244
- }
245
- },
246
- [`${id}AuthRole`]: {
247
- Type: "AWS::IAM::Role",
248
- Properties: {
249
- RoleName: authRoleName,
250
- Path: "/",
251
- AssumeRolePolicyDocument: {
252
- Version: "2012-10-17",
253
- Statement: [
254
- {
255
- Effect: "Allow",
256
- Principal: {
257
- Federated: "cognito-identity.amazonaws.com"
258
- },
259
- Action: ["sts:AssumeRoleWithWebIdentity"],
260
- Condition: {
261
- StringEquals: {
262
- "cognito-identity.amazonaws.com:aud": {
263
- Ref: `${id}IdentityPool`
264
- }
265
- },
266
- "ForAnyValue:StringLike": {
267
- "cognito-identity.amazonaws.com:amr": "authenticated"
268
- }
269
- }
270
- }
271
- ]
272
- },
273
- Policies: [
274
- {
275
- PolicyName: "CognitoAuthorizedPolicy",
276
- PolicyDocument: {
277
- Version: "2012-10-17",
278
- Statement: [
279
- {
280
- Effect: "Allow",
281
- Action: [
282
- "mobileanalytics:PutEvents",
283
- "cognito-sync:*",
284
- "cognito-identity:*"
285
- ],
286
- Resource: "*"
287
- },
288
- {
289
- Effect: "Allow",
290
- Action: ["execute-api:Invoke"],
291
- Resource: {
292
- "Fn::Sub": [
293
- "arn:aws:execute-api:${Region}:${AccountId}:${APIID}/${StageName}/${HTTPVerb}/api/*",
294
- {
295
- Region: {
296
- Ref: "AWS::Region"
297
- },
298
- AccountId: {
299
- Ref: "AWS::AccountId"
300
- },
301
- APIID: apiGatewayRESTAPIId,
302
- StageName: apiStageName,
303
- HTTPVerb: "*"
304
- }
305
- ]
306
- }
307
- }
308
- ]
309
- }
310
- }
311
- ]
312
- }
313
- },
314
- [`${id}UnauthRole`]: {
315
- Type: "AWS::IAM::Role",
316
- Properties: {
317
- RoleName: unauthRoleName,
318
- Path: "/",
319
- AssumeRolePolicyDocument: {
320
- Version: "2012-10-17",
321
- Statement: [
322
- {
323
- Effect: "Allow",
324
- Principal: {
325
- Federated: "cognito-identity.amazonaws.com"
326
- },
327
- Action: ["sts:AssumeRoleWithWebIdentity"],
328
- Condition: {
329
- StringEquals: {
330
- "cognito-identity.amazonaws.com:aud": {
331
- Ref: `${id}IdentityPool`
332
- }
333
- },
334
- "ForAnyValue:StringLike": {
335
- "cognito-identity.amazonaws.com:amr": "unauthenticated"
336
- }
337
- }
338
- }
339
- ]
340
- },
341
- Policies: [
342
- {
343
- PolicyName: "CognitoUnauthorizedPolicy",
344
- PolicyDocument: {
345
- Version: "2012-10-17",
346
- Statement: [
347
- {
348
- Effect: "Allow",
349
- Action: [
350
- "mobileanalytics:PutEvents",
351
- "cognito-sync:*",
352
- "cognito-identity:*"
353
- ],
354
- Resource: "*"
355
- }
356
- ]
357
- }
358
- }
359
- ]
360
- }
361
- }
362
- } : {};
363
- return {
364
- Resources: {
365
- [id]: {
366
- Type: "AWS::Cognito::UserPool",
367
- Properties: {
368
- UserPoolName: {
369
- "Fn::Sub": [`\${AWS::StackName}${id}`, {}]
370
- },
371
- AccountRecoverySetting: {
372
- RecoveryMechanisms: [
373
- {
374
- Name: "verified_email",
375
- Priority: 1
376
- }
377
- ]
378
- },
379
- AdminCreateUserConfig: {
380
- AllowAdminCreateUserOnly: false,
381
- UnusedAccountValidityDays: 365
382
- },
383
- AutoVerifiedAttributes: ["email"],
384
- AliasAttributes: ["phone_number", "email", "preferred_username"],
385
- Schema: [
386
- {
387
- Name: "email",
388
- Required: true,
389
- Mutable: true
390
- },
391
- {
392
- Name: "given_name",
393
- Required: true,
394
- Mutable: true
395
- },
396
- {
397
- Name: "family_name",
398
- Required: true,
399
- Mutable: true
400
- },
401
- {
402
- Name: "phone_number",
403
- Required: true,
404
- Mutable: true
405
- }
406
- ],
407
- DeviceConfiguration: {
408
- ChallengeRequiredOnNewDevice: true,
409
- DeviceOnlyRememberedOnUserPrompt: false
410
- },
411
- UsernameConfiguration: {
412
- CaseSensitive: false
413
- }
414
- }
415
- },
416
- [`${id}BaseDomainRecord`]: !!baseDomainRecordAliasTargetDNSName ? {
417
- Type: "AWS::Route53::RecordSet",
418
- DeletionPolicy: "Delete",
419
- Properties: {
420
- HostedZoneId: hostedZoneId,
421
- Type: "A",
422
- Name: domainName,
423
- AliasTarget: {
424
- HostedZoneId: "Z2FDTNDATAQYW2",
425
- DNSName: baseDomainRecordAliasTargetDNSName
426
- }
427
- }
428
- } : void 0,
429
- [`${id}DomainRecord`]: {
430
- Type: "AWS::Route53::RecordSet",
431
- DeletionPolicy: "Delete",
432
- Properties: {
433
- HostedZoneId: hostedZoneId,
434
- Type: "A",
435
- Name: {
436
- "Fn::Sub": [
437
- "auth.${BaseDomainName}",
438
- {
439
- BaseDomainName: domainName
440
- }
441
- ]
442
- },
443
- AliasTarget: {
444
- HostedZoneId: "Z2FDTNDATAQYW2",
445
- DNSName: {
446
- "Fn::GetAtt": [`${id}Domain`, "CloudFrontDistribution"]
447
- }
448
- }
449
- }
450
- },
451
- [`${id}Domain`]: {
452
- Type: "AWS::Cognito::UserPoolDomain",
453
- DependsOn: !!baseDomainRecordAliasTargetDNSName ? `${id}BaseDomainRecord` : void 0,
454
- Properties: {
455
- Domain: {
456
- "Fn::Sub": [
457
- "auth.${BaseDomainName}",
458
- {
459
- BaseDomainName: domainName
460
- }
461
- ]
462
- },
463
- UserPoolId: {
464
- Ref: id
465
- },
466
- CustomDomainConfig: {
467
- CertificateArn: sslCertificateArn
468
- }
469
- }
470
- },
471
- [`${id}Client`]: {
472
- Type: "AWS::Cognito::UserPoolClient",
473
- Properties: {
474
- ClientName: {
475
- "Fn::Sub": [`\${AWS::StackName}${id}Client`, {}]
476
- },
477
- UserPoolId: {
478
- Ref: id
479
- },
480
- AllowedOAuthFlowsUserPoolClient: true,
481
- AllowedOAuthFlows: ["code", "implicit"],
482
- AllowedOAuthScopes: [
483
- "openid",
484
- "email",
485
- "phone",
486
- "profile",
487
- "aws.cognito.signin.user.admin"
488
- ],
489
- CallbackURLs: callbackUrls,
490
- LogoutURLs: logoutUrls,
491
- EnableTokenRevocation: true,
492
- PreventUserExistenceErrors: "ENABLED",
493
- SupportedIdentityProviders: ["COGNITO"]
494
- }
495
- },
496
- [`${id}IdentityPool`]: {
497
- Type: "AWS::Cognito::IdentityPool",
498
- Properties: {
499
- IdentityPoolName: {
500
- "Fn::Sub": [`\${AWS::StackName}${id}IdentityPool`, {}]
501
- },
502
- AllowUnauthenticatedIdentities: false,
503
- CognitoIdentityProviders: [
504
- {
505
- ClientId: {
506
- Ref: `${id}Client`
507
- },
508
- ProviderName: {
509
- "Fn::GetAtt": [id, "ProviderName"]
510
- },
511
- ServerSideTokenCheck: true
512
- }
513
- ]
514
- }
515
- },
516
- ...apiRoleConfig
517
- }
518
- };
519
- }
520
- );
521
- var SimpleCFT = class {
522
- /**
523
- * Create a SimpleCFT template wrapper.
524
- *
525
- * @param template - Initial CloudFormation template.
526
- */
527
- constructor(template = {
528
- AWSTemplateFormatVersion: "2010-09-09"
529
- }) {
530
- this.template = template;
531
- }
532
- /**
533
- * Apply a pack with configuration to the stack template.
534
- * @see {@link IaC} for an example.
535
- * */
536
- applyPack = (pack, params) => {
537
- this.template = pack(params, this.template);
538
- return this;
539
- };
540
- /**
541
- * Apply a patch to the stack template.
542
- *
543
- * @param patch - Template patch to merge.
544
- * */
545
- patch = (patch) => {
546
- this.template = patchTemplate(patch, this.template);
547
- return this;
548
- };
549
- /**
550
- * Add a stack parameter including its descriptive info and an optional parameter group.
551
- *
552
- * @param parameter - Parameter definition and metadata.
553
- * */
554
- addParameter = (parameter) => {
555
- this.template = addParameter(parameter, this.template);
556
- return this;
557
- };
558
- /**
559
- * Add a group of stack parameters including their descriptive info and an optional parameter group.
560
- *
561
- * @param group - Parameter group definition.
562
- * */
563
- addParameterGroup = ({ Label: Group, Parameters }) => {
564
- const parameterIds = Object.keys(Parameters);
565
- const parameterList = parameterIds.map((ParameterId) => {
566
- const { Label, ...Parameter } = Parameters[ParameterId];
567
- return {
568
- Group,
569
- ParameterId,
570
- Label,
571
- Parameter
572
- };
573
- });
574
- this.template = addParameters(parameterList, this.template);
575
- return this;
576
- };
577
- /**
578
- * Use a modification to dynamically apply various changes at once.
579
- *
580
- * @param modification - Modification callback to apply.
581
- * */
582
- modify = (modification) => {
583
- modification(this);
584
- return this;
585
- };
586
- /**
587
- * Convert the stack template to a string.
588
- *
589
- * @returns JSON string representation of the template.
590
- * */
591
- toString = () => JSON.stringify(this.template, null, 2);
592
- /**
593
- * Convert the stack template to a JSON object.
594
- *
595
- * @returns Template JSON object.
596
- * */
597
- toJSON = () => this.template;
598
- /**
599
- * Convert the stack template to a YAML string.
600
- *
601
- * @returns YAML string representation of the template.
602
- * */
603
- toYAML = () => YAML.stringify(this.template, {
604
- aliasDuplicateObjects: false
605
- });
606
- };
607
-
608
- // src/iac/packs/auth.ts
609
- var addAuth = createResourcePack(
610
- ({
611
- userManagementId,
612
- authRoleName,
613
- unauthRoleName,
614
- hostedZoneIdParameterName,
615
- domainNameParameterName,
616
- sslCertificateId,
617
- callbackUrls,
618
- logoutUrls,
619
- mainCDNCloudFrontId,
620
- apiCloudFunctionGatewayId,
621
- apiStageName,
622
- adminGroupId,
623
- userManagementAdminGroupName
624
- }) => new SimpleCFT().applyPack(addUserManagement, {
625
- id: userManagementId,
626
- authRoleName,
627
- unauthRoleName,
628
- domainName: {
629
- Ref: domainNameParameterName
630
- },
631
- hostedZoneId: {
632
- Ref: hostedZoneIdParameterName
633
- },
634
- sslCertificateArn: {
635
- Ref: sslCertificateId
636
- },
637
- callbackUrls,
638
- logoutUrls,
639
- baseDomainRecordAliasTargetDNSName: {
640
- "Fn::GetAtt": [mainCDNCloudFrontId, "DomainName"]
641
- },
642
- apiGatewayRESTAPIId: {
643
- Ref: apiCloudFunctionGatewayId
644
- },
645
- apiStageName
646
- }).patch({
647
- Resources: {
648
- [adminGroupId]: {
649
- Type: "AWS::Cognito::UserPoolGroup",
650
- Properties: {
651
- GroupName: userManagementAdminGroupName,
652
- UserPoolId: {
653
- Ref: userManagementId
654
- },
655
- Description: "Application admin group."
656
- }
657
- }
658
- }
659
- }).template
660
- );
661
-
662
- // src/iac/packs/build.ts
663
- var DEFAULT_BUILD_PIPELINE_REPO_PROVIDER = "GitHub";
664
- var addBuildPipeline = createResourcePack(
665
- ({
666
- id,
667
- buildSpec,
668
- dependsOn,
669
- environmentVariables,
670
- timeoutInMinutes = 10,
671
- environmentType = "LINUX_CONTAINER",
672
- environmentComputeType = "BUILD_GENERAL1_SMALL",
673
- environmentImage = "aws/codebuild/nodejs:10.14.1",
674
- repoConfig: {
675
- provider = DEFAULT_BUILD_PIPELINE_REPO_PROVIDER,
676
- owner,
677
- repo,
678
- branch,
679
- oauthToken
680
- }
681
- }) => ({
682
- Resources: {
683
- [`${id}CodeBuildRole`]: {
684
- Type: "AWS::IAM::Role",
685
- Properties: {
686
- AssumeRolePolicyDocument: {
687
- Statement: [
688
- {
689
- Effect: "Allow",
690
- Principal: {
691
- Service: ["codebuild.amazonaws.com"]
692
- },
693
- Action: ["sts:AssumeRole"]
694
- }
695
- ]
696
- },
697
- Path: "/",
698
- Policies: [
699
- {
700
- PolicyName: "codebuild-service",
701
- PolicyDocument: {
702
- Statement: [
703
- {
704
- Effect: "Allow",
705
- Action: "*",
706
- Resource: "*"
707
- }
708
- ],
709
- Version: "2012-10-17"
710
- }
711
- }
712
- ]
713
- }
714
- },
715
- [`${id}CodePipelineRole`]: {
716
- Type: "AWS::IAM::Role",
717
- Properties: {
718
- AssumeRolePolicyDocument: {
719
- Statement: [
720
- {
721
- Effect: "Allow",
722
- Principal: {
723
- Service: ["codepipeline.amazonaws.com"]
724
- },
725
- Action: ["sts:AssumeRole"]
726
- }
727
- ]
728
- },
729
- Path: "/",
730
- Policies: [
731
- {
732
- PolicyName: "codepipeline-service",
733
- PolicyDocument: {
734
- Statement: [
735
- {
736
- Action: ["codebuild:*"],
737
- Resource: "*",
738
- Effect: "Allow"
739
- },
740
- {
741
- Action: [
742
- "s3:GetObject",
743
- "s3:GetObjectVersion",
744
- "s3:GetBucketVersioning"
745
- ],
746
- Resource: "*",
747
- Effect: "Allow"
748
- },
749
- {
750
- Action: ["s3:PutObject"],
751
- Resource: ["arn:aws:s3:::codepipeline*"],
752
- Effect: "Allow"
753
- },
754
- {
755
- Action: ["s3:*", "cloudformation:*", "iam:PassRole"],
756
- Resource: "*",
757
- Effect: "Allow"
758
- }
759
- ],
760
- Version: "2012-10-17"
761
- }
762
- }
763
- ]
764
- }
765
- },
766
- [`${id}PipelineBucket`]: {
767
- Type: "AWS::S3::Bucket",
768
- DeletionPolicy: "Delete",
769
- Properties: {
770
- BucketEncryption: {
771
- ServerSideEncryptionConfiguration: [
772
- {
773
- ServerSideEncryptionByDefault: {
774
- SSEAlgorithm: "AES256"
775
- }
776
- }
777
- ]
778
- },
779
- PublicAccessBlockConfiguration: {
780
- BlockPublicAcls: true,
781
- BlockPublicPolicy: true,
782
- IgnorePublicAcls: true,
783
- RestrictPublicBuckets: true
784
- }
785
- }
786
- },
787
- [`${id}CodeBuildAndDeploy`]: {
788
- Type: "AWS::CodeBuild::Project",
789
- DependsOn: dependsOn,
790
- Properties: {
791
- Name: {
792
- "Fn::Sub": `\${AWS::StackName}-${id}CodeBuildAndDeploy`
793
- },
794
- Description: "Deploy site to S3",
795
- ServiceRole: {
796
- "Fn::GetAtt": [`${id}CodeBuildRole`, "Arn"]
797
- },
798
- Artifacts: {
799
- Type: "CODEPIPELINE"
800
- },
801
- Environment: {
802
- Type: environmentType,
803
- ComputeType: environmentComputeType,
804
- Image: environmentImage,
805
- EnvironmentVariables: environmentVariables
806
- },
807
- Source: {
808
- Type: "CODEPIPELINE",
809
- BuildSpec: buildSpec
810
- },
811
- TimeoutInMinutes: timeoutInMinutes
812
- }
813
- },
814
- [`${id}Pipeline`]: {
815
- Type: "AWS::CodePipeline::Pipeline",
816
- DependsOn: `${id}CodeBuildAndDeploy`,
817
- Properties: {
818
- RoleArn: {
819
- "Fn::GetAtt": [`${id}CodePipelineRole`, "Arn"]
820
- },
821
- Stages: [
822
- {
823
- Name: "Acquire-Source",
824
- Actions: [
825
- {
826
- InputArtifacts: [],
827
- Name: "Source",
828
- ActionTypeId: {
829
- Category: "Source",
830
- Owner: "ThirdParty",
831
- Version: "1",
832
- Provider: provider
833
- },
834
- OutputArtifacts: [
835
- {
836
- Name: "SourceOutput"
837
- }
838
- ],
839
- Configuration: {
840
- Owner: owner,
841
- Repo: repo,
842
- Branch: branch,
843
- OAuthToken: oauthToken
844
- },
845
- RunOrder: 1
846
- }
847
- ]
848
- },
849
- {
850
- Name: "Build-And-Deploy",
851
- Actions: [
852
- {
853
- Name: "Artifact",
854
- ActionTypeId: {
855
- Category: "Build",
856
- Owner: "AWS",
857
- Version: "1",
858
- Provider: "CodeBuild"
859
- },
860
- InputArtifacts: [
861
- {
862
- Name: "SourceOutput"
863
- }
864
- ],
865
- OutputArtifacts: [
866
- {
867
- Name: "DeployOutput"
868
- }
869
- ],
870
- Configuration: {
871
- ProjectName: {
872
- Ref: `${id}CodeBuildAndDeploy`
873
- }
874
- },
875
- RunOrder: 1
876
- }
877
- ]
878
- }
879
- ],
880
- ArtifactStore: {
881
- Type: "S3",
882
- Location: {
883
- Ref: `${id}PipelineBucket`
884
- }
885
- }
886
- }
887
- }
888
- }
889
- })
890
- );
891
- var COMMAND_HELPERS = {
892
- updateFunction: ({
893
- cloudFunctionArn,
894
- codeZipFilePath
895
- }) => `aws lambda update-function-code --function-name "${cloudFunctionArn}" --zip-file "fileb://${codeZipFilePath}"`,
896
- copyDirectoryToS3: ({
897
- s3Domain,
898
- directoryPath
899
- }) => `aws s3 cp --recursive --acl public-read ${directoryPath} s3://${s3Domain}/`,
900
- cloudFrontInvalidation: ({
901
- cloudFrontDistributionId,
902
- pathsToInvalidate = ["/*"]
903
- }) => `aws cloudfront create-invalidation --distribution-id "${cloudFrontDistributionId}" --paths "${pathsToInvalidate.join('" "')}"`,
904
- addNPMTokenWithNPMRC: ({ npmToken }) => `echo '//registry.npmjs.org/:_authToken=${npmToken}' > .npmrc`
905
- };
906
- var createBuildSpec = ({ version = 0.2, phases }) => YAML.stringify(
907
- // TRICKY: Removed all keys with a value of `undefined`.
908
- JSON.parse(
909
- JSON.stringify({
910
- version,
911
- phases
912
- })
913
- )
914
- );
915
-
916
- // src/iac/packs/cdn.ts
917
- var addCDN = createResourcePack(
918
- ({
919
- id,
920
- hostedZoneId,
921
- domainName,
922
- certificateArn,
923
- fileStorageId
924
- }) => {
925
- const oacId = `${id}OriginAccessControl`;
926
- return {
927
- Resources: {
928
- [oacId]: {
929
- Type: "AWS::CloudFront::OriginAccessControl",
930
- Properties: {
931
- OriginAccessControlConfig: {
932
- Name: oacId,
933
- OriginAccessControlOriginType: "s3",
934
- SigningBehavior: "always",
935
- SigningProtocol: "sigv4"
936
- }
937
- }
938
- },
939
- [id]: {
940
- Type: "AWS::CloudFront::Distribution",
941
- DependsOn: fileStorageId,
942
- Properties: {
943
- DistributionConfig: {
944
- Aliases: [domainName],
945
- ViewerCertificate: {
946
- AcmCertificateArn: certificateArn,
947
- SslSupportMethod: "sni-only",
948
- MinimumProtocolVersion: "TLSv1.1_2016"
949
- },
950
- DefaultCacheBehavior: {
951
- ForwardedValues: {
952
- QueryString: false
953
- },
954
- TargetOriginId: {
955
- "Fn::Sub": [
956
- "S3-${S3BucketName}",
957
- {
958
- S3BucketName: domainName
959
- }
960
- ]
961
- },
962
- ViewerProtocolPolicy: "redirect-to-https"
963
- },
964
- DefaultRootObject: "index.html",
965
- Enabled: true,
966
- IPV6Enabled: false,
967
- HttpVersion: "http2",
968
- Origins: [
969
- {
970
- DomainName: {
971
- "Fn::Sub": [
972
- "${S3BucketName}.s3.amazonaws.com",
973
- {
974
- S3BucketName: domainName
975
- }
976
- ]
977
- },
978
- Id: {
979
- "Fn::Sub": [
980
- "S3-${S3BucketName}",
981
- {
982
- S3BucketName: domainName
983
- }
984
- ]
985
- },
986
- OriginAccessControlId: { Ref: oacId },
987
- S3OriginConfig: {
988
- OriginAccessIdentity: ""
989
- }
990
- }
991
- ],
992
- CustomErrorResponses: [
993
- {
994
- ErrorCachingMinTTL: 300,
995
- ErrorCode: 404,
996
- ResponseCode: 200,
997
- ResponsePagePath: "/index.html"
998
- },
999
- {
1000
- ErrorCachingMinTTL: 300,
1001
- ErrorCode: 403,
1002
- ResponseCode: 200,
1003
- ResponsePagePath: "/index.html"
1004
- }
1005
- ],
1006
- PriceClass: "PriceClass_All"
1007
- }
1008
- }
1009
- },
1010
- [`${id}Route53Record`]: {
1011
- Type: "AWS::Route53::RecordSet",
1012
- DependsOn: [id],
1013
- Properties: {
1014
- HostedZoneId: hostedZoneId,
1015
- Type: "A",
1016
- Name: {
1017
- "Fn::Sub": [
1018
- "${DomainName}.",
1019
- {
1020
- DomainName: domainName
1021
- }
1022
- ]
1023
- },
1024
- AliasTarget: {
1025
- HostedZoneId: "Z2FDTNDATAQYW2",
1026
- DNSName: {
1027
- "Fn::Sub": [
1028
- "${DomainName}.",
1029
- {
1030
- DomainName: {
1031
- "Fn::GetAtt": [id, "DomainName"]
1032
- }
1033
- }
1034
- ]
1035
- }
1036
- }
1037
- }
1038
- }
1039
- }
1040
- };
1041
- }
1042
- );
1043
-
1044
- // src/iac/packs/cloud-function.ts
1045
- var PLACEHOLDER_FUNCTION_CODE = {
1046
- ZipFile: `module.exports = {handler: async () => ({
1047
- statusCode: 200,
1048
- headers: {'Content-Type': 'application/json'},
1049
- body: '"You did it!"'
1050
- })};
1051
- `
1052
- };
1053
- var addCloudFunction = createResourcePack(
1054
- ({
1055
- id,
1056
- code = PLACEHOLDER_FUNCTION_CODE,
1057
- environment = {
1058
- Variables: {
1059
- NODE_ENV: "production"
1060
- }
1061
- },
1062
- handler = "index.handler",
1063
- runtime = "nodejs26.x",
1064
- timeout = 30,
1065
- policies = [
1066
- {
1067
- PolicyName: "lambda-parameter-store",
1068
- PolicyDocument: {
1069
- Version: "2012-10-17",
1070
- Statement: [
1071
- {
1072
- Effect: "Allow",
1073
- Action: ["*"],
1074
- Resource: "*"
1075
- }
1076
- ]
1077
- }
1078
- }
1079
- ]
1080
- }) => {
1081
- return {
1082
- Resources: {
1083
- [`${id}Role`]: {
1084
- Type: "AWS::IAM::Role",
1085
- Properties: {
1086
- ManagedPolicyArns: [
1087
- "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
1088
- ],
1089
- AssumeRolePolicyDocument: {
1090
- Version: "2012-10-17",
1091
- Statement: [
1092
- {
1093
- Action: ["sts:AssumeRole"],
1094
- Effect: "Allow",
1095
- Principal: {
1096
- Service: ["lambda.amazonaws.com"]
1097
- }
1098
- }
1099
- ]
1100
- },
1101
- Policies: policies
1102
- }
1103
- },
1104
- [id]: {
1105
- Type: "AWS::Lambda::Function",
1106
- Properties: {
1107
- Timeout: timeout,
1108
- Code: code,
1109
- Environment: environment,
1110
- Handler: handler,
1111
- Role: {
1112
- "Fn::GetAtt": [`${id}Role`, "Arn"]
1113
- },
1114
- Runtime: runtime
1115
- }
1116
- }
1117
- }
1118
- };
1119
- }
1120
- );
1121
-
1122
- // src/iac/packs/database.ts
1123
- var addDatabase = createResourcePack(
1124
- ({
1125
- tableId,
1126
- tableName,
1127
- keys,
1128
- attributes,
1129
- billingMode = "PAY_PER_REQUEST"
1130
- }) => new SimpleCFT().patch({
1131
- Resources: {
1132
- [tableId]: {
1133
- Type: "AWS::DynamoDB::Table",
1134
- Properties: {
1135
- TableName: tableName,
1136
- AttributeDefinitions: Object.keys(attributes).map(
1137
- (attributeName) => ({
1138
- AttributeName: attributeName,
1139
- AttributeType: attributes[attributeName]
1140
- })
1141
- ),
1142
- KeySchema: Object.keys(keys).map((keyName) => ({
1143
- AttributeName: keyName,
1144
- KeyType: keys[keyName]
1145
- })),
1146
- BillingMode: billingMode
1147
- }
1148
- }
1149
- }
1150
- }).template
1151
- );
1152
-
1153
- // src/iac/packs/dns.ts
1154
- var addDNS = createResourcePack(
1155
- ({
1156
- id,
1157
- hostedZoneId,
1158
- domainName,
1159
- resourceRecords,
1160
- recordType = "A"
1161
- }) => {
1162
- let cft = new SimpleCFT().patch({
1163
- Resources: {
1164
- [id]: {
1165
- Type: "AWS::Route53::RecordSet",
1166
- Properties: {
1167
- HostedZoneId: hostedZoneId,
1168
- Type: recordType,
1169
- Name: domainName,
1170
- ResourceRecords: resourceRecords,
1171
- TTL: "300"
1172
- }
1173
- }
1174
- }
1175
- });
1176
- return cft.template;
1177
- }
1178
- );
1179
-
1180
- // src/iac/packs/file-storage.ts
1181
- var addSecureFileStorage = createResourcePack(
1182
- ({
1183
- id,
1184
- bucketName,
1185
- shouldDelete = true,
1186
- blockPublicAccess = true,
1187
- cors = false,
1188
- accessControl = void 0,
1189
- allowACLs = false
1190
- }) => {
1191
- return {
1192
- Resources: {
1193
- [id]: {
1194
- Type: "AWS::S3::Bucket",
1195
- DeletionPolicy: shouldDelete ? "Delete" : "Retain",
1196
- Properties: {
1197
- BucketName: bucketName,
1198
- AccessControl: accessControl,
1199
- OwnershipControls: allowACLs ? {
1200
- Rules: [
1201
- {
1202
- ObjectOwnership: "ObjectWriter"
1203
- }
1204
- ]
1205
- } : void 0,
1206
- CorsConfiguration: typeof cors === "object" ? cors : cors === true ? {
1207
- CorsRules: [
1208
- {
1209
- AllowedHeaders: ["*"],
1210
- AllowedMethods: [
1211
- "GET",
1212
- "PUT",
1213
- "POST",
1214
- "DELETE",
1215
- "HEAD"
1216
- ],
1217
- AllowedOrigins: ["*"]
1218
- }
1219
- ]
1220
- } : void 0,
1221
- BucketEncryption: {
1222
- ServerSideEncryptionConfiguration: [
1223
- {
1224
- ServerSideEncryptionByDefault: {
1225
- SSEAlgorithm: "AES256"
1226
- }
1227
- }
1228
- ]
1229
- },
1230
- PublicAccessBlockConfiguration: blockPublicAccess ? {
1231
- BlockPublicAcls: true,
1232
- BlockPublicPolicy: true,
1233
- IgnorePublicAcls: true,
1234
- RestrictPublicBuckets: true
1235
- } : {
1236
- BlockPublicAcls: false,
1237
- BlockPublicPolicy: false,
1238
- IgnorePublicAcls: false,
1239
- RestrictPublicBuckets: false
1240
- }
1241
- }
1242
- }
1243
- }
1244
- };
1245
- }
1246
- );
1247
-
1248
- // src/iac/packs/gateway.ts
1249
- var DEFAULT_AUTH_TYPE = "COGNITO_USER_POOLS";
1250
- var addGateway = createResourcePack(
1251
- ({
1252
- id,
1253
- hostedZoneId,
1254
- domainName,
1255
- certificateArn,
1256
- cloudFunction: {
1257
- id: cloudFunctionId,
1258
- region: cloudFunctionRegion = "${AWS::Region}"
1259
- },
1260
- stageName = "production",
1261
- authorizer,
1262
- deploymentSuffix = ""
1263
- }) => {
1264
- const cloudFunctionUri = {
1265
- "Fn::Sub": `arn:aws:apigateway:${cloudFunctionRegion}:lambda:path/2015-03-31/functions/\${${cloudFunctionId}.Arn}/invocations`
1266
- };
1267
- const {
1268
- scopes: authScopes = ["phone", "email", "openid", "profile"],
1269
- type: authType = "COGNITO_USER_POOLS",
1270
- providerARNs,
1271
- identitySource = "method.request.header.authorization"
1272
- } = !!authorizer && typeof authorizer === "object" ? authorizer : {};
1273
- const authorizerId = `${id}CustomAuthorizer`;
1274
- const authProps = !!authorizer ? {
1275
- AuthorizationScopes: authScopes,
1276
- AuthorizationType: authType === DEFAULT_AUTH_TYPE ? DEFAULT_AUTH_TYPE : "CUSTOM",
1277
- AuthorizerId: {
1278
- Ref: authorizerId
1279
- }
1280
- } : {
1281
- AuthorizationType: "NONE"
1282
- };
1283
- const fullDeploymentId = `${id}GatewayRESTAPIDeployment${deploymentSuffix}`;
1284
- return new SimpleCFT().patch({
1285
- Resources: {
1286
- // REST API
1287
- [id]: {
1288
- Type: "AWS::ApiGateway::RestApi",
1289
- Properties: {
1290
- Name: {
1291
- "Fn::Sub": `\${AWS::StackName}-${id}GatewayRESTAPI`
1292
- },
1293
- EndpointConfiguration: {
1294
- Types: ["EDGE"]
1295
- }
1296
- }
1297
- },
1298
- [`${id}GatewayRESTAPIResource`]: {
1299
- Type: "AWS::ApiGateway::Resource",
1300
- DependsOn: id,
1301
- Properties: {
1302
- ParentId: {
1303
- "Fn::GetAtt": [id, "RootResourceId"]
1304
- },
1305
- PathPart: "{proxy+}",
1306
- RestApiId: {
1307
- Ref: id
1308
- }
1309
- }
1310
- },
1311
- [`${id}GatewayRESTAPIMethod`]: {
1312
- Type: "AWS::ApiGateway::Method",
1313
- DependsOn: `${id}GatewayRESTAPIResource`,
1314
- Properties: {
1315
- ...authProps,
1316
- HttpMethod: "ANY",
1317
- ResourceId: {
1318
- Ref: `${id}GatewayRESTAPIResource`
1319
- },
1320
- RestApiId: {
1321
- Ref: id
1322
- },
1323
- Integration: {
1324
- Type: "AWS_PROXY",
1325
- IntegrationHttpMethod: "POST",
1326
- Uri: cloudFunctionUri
1327
- }
1328
- }
1329
- },
1330
- [`${id}GatewayRESTAPIRootMethod`]: {
1331
- Type: "AWS::ApiGateway::Method",
1332
- DependsOn: `${id}GatewayRESTAPIResource`,
1333
- Properties: {
1334
- ...authProps,
1335
- HttpMethod: "ANY",
1336
- ResourceId: {
1337
- "Fn::GetAtt": [id, "RootResourceId"]
1338
- },
1339
- RestApiId: {
1340
- Ref: id
1341
- },
1342
- Integration: {
1343
- Type: "AWS_PROXY",
1344
- IntegrationHttpMethod: "POST",
1345
- Uri: cloudFunctionUri
1346
- }
1347
- }
1348
- }
1349
- }
1350
- }).patch({
1351
- Resources: {
1352
- // CORS
1353
- [`${id}GatewayRESTAPIOPTIONSMethod`]: {
1354
- Type: "AWS::ApiGateway::Method",
1355
- DependsOn: `${id}GatewayRESTAPIResource`,
1356
- Properties: {
1357
- AuthorizationType: "NONE",
1358
- HttpMethod: "OPTIONS",
1359
- ResourceId: {
1360
- Ref: `${id}GatewayRESTAPIResource`
1361
- },
1362
- RestApiId: {
1363
- Ref: id
1364
- },
1365
- Integration: {
1366
- Type: "AWS_PROXY",
1367
- IntegrationHttpMethod: "POST",
1368
- Uri: cloudFunctionUri
1369
- }
1370
- }
1371
- },
1372
- [`${id}GatewayRESTAPIRootOPTIONSMethod`]: {
1373
- Type: "AWS::ApiGateway::Method",
1374
- DependsOn: `${id}GatewayRESTAPIResource`,
1375
- Properties: {
1376
- AuthorizationType: "NONE",
1377
- HttpMethod: "OPTIONS",
1378
- ResourceId: {
1379
- "Fn::GetAtt": [id, "RootResourceId"]
1380
- },
1381
- RestApiId: {
1382
- Ref: id
1383
- },
1384
- Integration: {
1385
- Type: "AWS_PROXY",
1386
- IntegrationHttpMethod: "POST",
1387
- Uri: cloudFunctionUri
1388
- }
1389
- }
1390
- },
1391
- [`${id}GatewayResponseDefault4XX`]: {
1392
- Type: "AWS::ApiGateway::GatewayResponse",
1393
- Properties: {
1394
- ResponseParameters: {
1395
- // Not authorized, so just allow the current origin by mapping it into the header.
1396
- "gatewayresponse.header.Access-Control-Allow-Origin": "method.request.header.origin",
1397
- "gatewayresponse.header.Access-Control-Allow-Credentials": "'true'",
1398
- "gatewayresponse.header.Access-Control-Allow-Headers": "'*'"
1399
- },
1400
- ResponseType: "DEFAULT_4XX",
1401
- RestApiId: {
1402
- Ref: id
1403
- }
1404
- }
1405
- }
1406
- }
1407
- }).patch({
1408
- Resources: {
1409
- // SUPPORTING RESOURCES
1410
- [fullDeploymentId]: {
1411
- Type: "AWS::ApiGateway::Deployment",
1412
- DependsOn: [
1413
- `${id}GatewayRESTAPIResource`,
1414
- `${id}GatewayRESTAPIMethod`,
1415
- `${id}GatewayRESTAPIRootMethod`,
1416
- id,
1417
- cloudFunctionId
1418
- ],
1419
- Properties: {
1420
- RestApiId: {
1421
- Ref: id
1422
- }
1423
- }
1424
- },
1425
- [`${id}CloudWatch`]: {
1426
- Type: "AWS::Logs::LogGroup",
1427
- Properties: {
1428
- LogGroupName: {
1429
- "Fn::Sub": `\${AWS::StackName}-${id}GatewayLogs`
1430
- }
1431
- }
1432
- },
1433
- [`${id}CloudWatchRole`]: {
1434
- Type: "AWS::IAM::Role",
1435
- Properties: {
1436
- AssumeRolePolicyDocument: {
1437
- Version: "2012-10-17",
1438
- Statement: [
1439
- {
1440
- Effect: "Allow",
1441
- Principal: {
1442
- Service: ["apigateway.amazonaws.com"]
1443
- },
1444
- Action: "sts:AssumeRole"
1445
- }
1446
- ]
1447
- },
1448
- Path: "/",
1449
- ManagedPolicyArns: [
1450
- "arn:aws:iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs"
1451
- ]
1452
- }
1453
- },
1454
- [`${id}CloudWatchAccount`]: {
1455
- Type: "AWS::ApiGateway::Account",
1456
- Properties: {
1457
- CloudWatchRoleArn: {
1458
- "Fn::GetAtt": [`${id}CloudWatchRole`, "Arn"]
1459
- }
1460
- }
1461
- },
1462
- [`${id}GatewayRESTAPIEnvironment`]: {
1463
- Type: "AWS::ApiGateway::Stage",
1464
- DependsOn: [`${id}CloudWatchAccount`, fullDeploymentId],
1465
- Properties: {
1466
- AccessLogSetting: {
1467
- DestinationArn: {
1468
- "Fn::GetAtt": [`${id}CloudWatch`, "Arn"]
1469
- },
1470
- Format: '{"requestId":"$context.requestId","ip":"$context.identity.sourceIp","caller":"$context.identity.caller","user":"$context.identity.user","requestTime":"$context.requestTime","httpMethod":"$context.httpMethod","resourcePath":"$context.resourcePath","status":"$context.status","protocol":"$context.protocol","responseLength":"$context.responseLength","apiGatewayErrorMessage":"$context.error.message"}'
1471
- },
1472
- DeploymentId: {
1473
- Ref: fullDeploymentId
1474
- },
1475
- RestApiId: {
1476
- Ref: id
1477
- },
1478
- StageName: stageName
1479
- }
1480
- }
1481
- }
1482
- }).patch({
1483
- Resources: {
1484
- // DNS
1485
- [`${id}DomainName`]: {
1486
- Type: "AWS::ApiGateway::DomainName",
1487
- Properties: {
1488
- CertificateArn: certificateArn,
1489
- DomainName: domainName,
1490
- EndpointConfiguration: {
1491
- Types: ["EDGE"]
1492
- }
1493
- }
1494
- },
1495
- [`${id}DomainNameBasePathMapping`]: {
1496
- Type: "AWS::ApiGateway::BasePathMapping",
1497
- DependsOn: [
1498
- id,
1499
- `${id}GatewayRESTAPIEnvironment`,
1500
- `${id}DomainName`
1501
- ],
1502
- Properties: {
1503
- DomainName: domainName,
1504
- RestApiId: {
1505
- Ref: id
1506
- },
1507
- Stage: stageName
1508
- }
1509
- },
1510
- [`${id}Route53Record`]: {
1511
- Type: "AWS::Route53::RecordSet",
1512
- DependsOn: `${id}DomainName`,
1513
- Properties: {
1514
- HostedZoneId: hostedZoneId,
1515
- Type: "A",
1516
- Name: {
1517
- "Fn::Sub": [
1518
- "${DomainName}.",
1519
- {
1520
- DomainName: domainName
1521
- }
1522
- ]
1523
- },
1524
- AliasTarget: {
1525
- HostedZoneId: "Z2FDTNDATAQYW2",
1526
- DNSName: {
1527
- "Fn::Sub": [
1528
- "${DomainName}.",
1529
- {
1530
- DomainName: {
1531
- "Fn::GetAtt": [
1532
- `${id}DomainName`,
1533
- "DistributionDomainName"
1534
- ]
1535
- }
1536
- }
1537
- ]
1538
- }
1539
- }
1540
- }
1541
- }
1542
- }
1543
- }).patch({
1544
- Resources: {
1545
- // PERMISSIONS
1546
- [`${id}CloudFunctionANYResourcePermission`]: {
1547
- Type: "AWS::Lambda::Permission",
1548
- Properties: {
1549
- Action: "lambda:InvokeFunction",
1550
- Principal: "apigateway.amazonaws.com",
1551
- FunctionName: {
1552
- "Fn::GetAtt": [cloudFunctionId, "Arn"]
1553
- },
1554
- SourceArn: {
1555
- "Fn::Sub": [
1556
- "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*/*",
1557
- {
1558
- __Stage__: stageName,
1559
- __ApiId__: {
1560
- Ref: id
1561
- }
1562
- }
1563
- ]
1564
- }
1565
- }
1566
- }
1567
- }
1568
- }).patch(
1569
- !!authorizer ? {
1570
- Resources: {
1571
- // AUTHORIZER
1572
- [`${id}CustomAuthorizer`]: {
1573
- Type: "AWS::ApiGateway::Authorizer",
1574
- Properties: {
1575
- IdentitySource: identitySource,
1576
- Name: `${id}CustomAuthorizer`,
1577
- ProviderARNs: providerARNs,
1578
- RestApiId: {
1579
- Ref: id
1580
- },
1581
- Type: "COGNITO_USER_POOLS"
1582
- }
1583
- }
1584
- }
1585
- } : {}
1586
- ).template;
1587
- }
1588
- );
1589
-
1590
- // src/iac/packs/repo.ts
1591
- var addRepo = createResourcePack(
1592
- ({
1593
- repoOwnerParameterName,
1594
- repoNameParameterName,
1595
- repoBranchParameterName,
1596
- repoTokenParameterName
1597
- }) => new SimpleCFT().addParameterGroup({
1598
- Label: "Repository",
1599
- Parameters: {
1600
- [repoOwnerParameterName]: {
1601
- Label: "RepoOwner",
1602
- Type: "String",
1603
- Description: "The owner of the repository"
1604
- },
1605
- [repoNameParameterName]: {
1606
- Label: "RepoName",
1607
- Type: "String",
1608
- Description: "The name of the repository"
1609
- },
1610
- [repoBranchParameterName]: {
1611
- Label: "RepoBranch",
1612
- Type: "String",
1613
- Description: "The branch of the repository"
1614
- },
1615
- [repoTokenParameterName]: {
1616
- Label: "RepoToken",
1617
- Type: "String",
1618
- Description: "The token of the repository",
1619
- NoEcho: true
1620
- }
1621
- }
1622
- }).template
1623
- );
1624
-
1625
- // src/iac/packs/ssl-certificate.ts
1626
- var addSSLCertificate = createResourcePack(
1627
- ({
1628
- id,
1629
- domainName,
1630
- hostedZoneId,
1631
- includeWildCard = true
1632
- }) => ({
1633
- Resources: {
1634
- [id]: {
1635
- Type: "AWS::CertificateManager::Certificate",
1636
- Properties: {
1637
- DomainName: domainName,
1638
- ValidationMethod: "DNS",
1639
- DomainValidationOptions: [
1640
- {
1641
- DomainName: domainName,
1642
- HostedZoneId: hostedZoneId
1643
- }
1644
- ],
1645
- SubjectAlternativeNames: includeWildCard ? [
1646
- {
1647
- "Fn::Sub": [
1648
- "*.${BaseDomainName}",
1649
- {
1650
- BaseDomainName: domainName
1651
- }
1652
- ]
1653
- }
1654
- ] : void 0
1655
- }
1656
- }
1657
- }
1658
- })
1659
- );
1660
-
1661
- export { packs_exports as Packs, SimpleCFT, utils_exports as Utils };
1
+ export { DEFAULT_MERGE_STRATEGY, SimpleCFT, addParameter, addParameters, createResourcePack, getValuePathArray, getValuePathString, isConstructedFrom, mergeValues, patchTemplate } from '../chunk-ATO2455Q.js';
2
+ import '../chunk-I2KLQ2HA.js';