@resistdesign/voltra 3.0.0-alpha.2 → 3.0.0-alpha.21

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