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

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 +391 -594
  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
@@ -1,441 +1,308 @@
1
+ import { createResourcePack, SimpleCFT } from '../../chunk-ATO2455Q.js';
2
+ import '../../chunk-I2KLQ2HA.js';
1
3
  import YAML from 'yaml';
2
4
 
3
- // src/iac/utils/patch-utils.ts
4
- var DEFAULT_MERGE_STRATEGY = "transpose";
5
- var getValuePathString = (valuePathArray = []) => valuePathArray.map((p) => encodeURIComponent(p)).join("/");
6
- var isConstructedFrom = (value, constructorReference) => value !== null && typeof value === "object" && "constructor" in value && value.constructor === constructorReference;
7
- var mergeValues = (valuePathArray = [], existingValue, newValue, mergeStrategyMap = {}) => {
8
- const valuePathString = getValuePathString(valuePathArray);
9
- const arrayIndexWildcardValuePathString = getValuePathString(
10
- valuePathArray.map((p) => typeof p === "number" ? "#" : p)
11
- );
12
- const {
13
- [valuePathString]: {
14
- strategy: specificKeyMergeStrategy = DEFAULT_MERGE_STRATEGY,
15
- data: specificKeyMergeStrategyData = void 0
16
- } = {},
17
- [arrayIndexWildcardValuePathString]: {
18
- strategy: arrayIndexWildcardMergeStrategy = DEFAULT_MERGE_STRATEGY,
19
- data: arrayIndexWildcardMergeStrategyData = void 0
20
- } = {}
21
- } = mergeStrategyMap;
22
- const mergeStrategy = valuePathString in mergeStrategyMap ? specificKeyMergeStrategy : arrayIndexWildcardMergeStrategy;
23
- const mergeStrategyData = valuePathString in mergeStrategyMap ? specificKeyMergeStrategyData : arrayIndexWildcardMergeStrategyData;
24
- let mergedValue = typeof newValue !== "undefined" ? newValue : existingValue;
25
- if (mergeStrategy !== "replace") {
26
- if (isConstructedFrom(existingValue, Array) && isConstructedFrom(newValue, Array)) {
27
- if (mergeStrategy === "accumulate") {
28
- mergedValue = [...existingValue, ...newValue];
29
- } else if (mergeStrategy === "accumulate-unique") {
30
- mergedValue = [
31
- ...existingValue,
32
- ...newValue.filter(
33
- (item) => existingValue.indexOf(item) === -1
34
- )
35
- ];
36
- } else if (mergeStrategy === "accumulate-unique-by") {
37
- const existingItemMap = {};
38
- const newItemMap = {};
39
- for (let i = 0; i < existingValue.length; i++) {
40
- const existingItem = existingValue[i];
41
- if (existingItem && typeof existingItem === "object") {
42
- const identifier = mergeStrategyData instanceof Function ? mergeStrategyData(existingItem) : existingItem[mergeStrategyData];
43
- existingItemMap[identifier] = existingItem;
44
- }
45
- }
46
- for (let j = 0; j < newValue.length; j++) {
47
- const newItem = newValue[j];
48
- if (newItem && typeof newItem === "object") {
49
- const identifier = mergeStrategyData instanceof Function ? mergeStrategyData(newItem) : newItem[mergeStrategyData];
50
- newItemMap[identifier] = newItem;
51
- }
52
- }
53
- mergedValue = Object.keys({
54
- ...existingItemMap,
55
- ...newItemMap
56
- }).map(
57
- (id, index) => mergeValues(
58
- [...valuePathArray, index],
59
- existingItemMap[id],
60
- newItemMap[id],
61
- mergeStrategyMap
62
- )
63
- );
64
- } else if (mergeStrategy === "transpose") {
65
- const fullLength = Math.max(existingValue.length, newValue.length);
66
- mergedValue = [...new Array(fullLength)].map(
67
- (_empty, index) => mergeValues(
68
- [...valuePathArray, index],
69
- existingValue[index],
70
- newValue[index],
71
- mergeStrategyMap
72
- )
73
- );
74
- }
75
- } else if (isConstructedFrom(existingValue, Object) && isConstructedFrom(newValue, Object)) {
76
- mergedValue = Object.keys({ ...existingValue, ...newValue }).reduce(
77
- (acc, k) => ({
78
- ...acc,
79
- [k]: mergeValues(
80
- [...valuePathArray, k],
81
- existingValue[k],
82
- newValue[k],
83
- mergeStrategyMap
84
- )
85
- }),
86
- {}
87
- );
88
- }
89
- }
90
- return mergedValue;
91
- };
92
-
93
- // src/iac/utils/index.ts
94
- var addParameter = (parameterInfo, template) => {
95
- const { ParameterId, Parameter, Label, Group } = parameterInfo;
96
- const {
97
- Parameters,
98
- Metadata: {
99
- "AWS::CloudFormation::Interface": {
100
- ParameterGroups = [],
101
- ParameterLabels = {}
102
- } = {}
103
- } = {}
104
- } = template;
105
- let NewParameterGroups = ParameterGroups;
106
- if (Group) {
107
- const GroupObject = ParameterGroups.filter(
108
- (g) => g.Label?.default === Group
109
- )[0];
110
- NewParameterGroups = GroupObject ? ParameterGroups.map(
111
- (g) => g.Label?.default === Group ? {
112
- ...g,
113
- Parameters: [...g.Parameters || [], ParameterId]
114
- } : g
115
- ) : [
116
- ...ParameterGroups,
117
- {
118
- Label: {
119
- default: Group
120
- },
121
- Parameters: [ParameterId]
122
- }
123
- ];
124
- }
125
- return {
126
- ...template,
127
- Parameters: {
128
- ...Parameters,
129
- [ParameterId]: Parameter
130
- },
131
- Metadata: {
132
- ...template.Metadata,
133
- "AWS::CloudFormation::Interface": {
134
- ...template?.Metadata?.["AWS::CloudFormation::Interface"],
135
- ParameterGroups: NewParameterGroups,
136
- ParameterLabels: {
137
- ...ParameterLabels,
138
- [ParameterId]: {
139
- default: Label
140
- }
141
- }
142
- }
143
- }
144
- };
145
- };
146
- var addParameters = (parameters, template) => parameters.reduce((acc, p) => addParameter(p, acc), template);
147
- var patchTemplate = (patch, template) => mergeValues([], template, patch, {
148
- [getValuePathString([
149
- // Parameter Groups
150
- "Metadata",
151
- "AWS::CloudFormation::Interface",
152
- "ParameterGroups"
153
- ])]: {
154
- strategy: "accumulate-unique-by",
155
- data: (pG) => pG?.Label?.default
156
- },
157
- [getValuePathString([
158
- // Parameter Group Parameter Ids
159
- "Metadata",
160
- "AWS::CloudFormation::Interface",
161
- "ParameterGroups",
162
- "#",
163
- "Parameters"
164
- ])]: {
165
- strategy: "accumulate-unique"
166
- }
5
+ // src/iac/packs/auth.ts
6
+ var resolveUserManagementIds = (baseId, ids) => ({
7
+ userPool: ids?.userPool || baseId,
8
+ userPoolClient: ids?.userPoolClient || `${baseId}Client`,
9
+ identityPool: ids?.identityPool || `${baseId}IdentityPool`,
10
+ authRole: ids?.authRole || `${baseId}AuthRole`,
11
+ unauthRole: ids?.unauthRole || `${baseId}UnauthRole`,
12
+ roleAttachment: ids?.roleAttachment || `${baseId}IdentityPoolRoles`,
13
+ domain: ids?.domain || `${baseId}Domain`,
14
+ domainRecord: ids?.domainRecord || `${baseId}DomainRecord`,
15
+ baseDomainRecord: ids?.baseDomainRecord || `${baseId}BaseDomainRecord`
167
16
  });
168
- var createResourcePack = (creator) => (params, template) => {
169
- const patch = creator(params);
170
- return patchTemplate(patch, template);
171
- };
172
-
173
- // src/iac/packs/auth/user-management.ts
174
- var addUserManagement = createResourcePack(
175
- ({
176
- id,
17
+ var addAuth = createResourcePack((config) => {
18
+ const {
19
+ userManagementId,
20
+ userManagementIds,
177
21
  authRoleName,
178
22
  unauthRoleName,
179
- domainName,
180
- hostedZoneId,
181
- sslCertificateArn,
182
- callbackUrls,
183
- logoutUrls,
184
- baseDomainRecordAliasTargetDNSName,
185
- apiGatewayRESTAPIId,
186
- apiStageName
187
- }) => {
188
- const apiRoleConfig = apiGatewayRESTAPIId && apiStageName ? {
189
- [`${id}IdentityPoolRoles`]: {
190
- Type: "AWS::Cognito::IdentityPoolRoleAttachment",
191
- Properties: {
192
- IdentityPoolId: {
193
- Ref: `${id}IdentityPool`
23
+ apiCloudFunctionGatewayId,
24
+ apiStageName,
25
+ adminGroupId,
26
+ userManagementAdminGroupName
27
+ } = config;
28
+ const resolvedIds = resolveUserManagementIds(
29
+ userManagementId,
30
+ userManagementIds
31
+ );
32
+ const isUserPoolDomainEnabled = config.enableUserPoolDomain !== false;
33
+ const supportedIdentityProviders = isUserPoolDomainEnabled && "supportedIdentityProviders" in config && config.supportedIdentityProviders && config.supportedIdentityProviders.length > 0 ? config.supportedIdentityProviders : ["COGNITO"];
34
+ const apiRoleConfig = {
35
+ [resolvedIds.roleAttachment]: {
36
+ Type: "AWS::Cognito::IdentityPoolRoleAttachment",
37
+ Properties: {
38
+ IdentityPoolId: {
39
+ Ref: resolvedIds.identityPool
40
+ },
41
+ Roles: {
42
+ authenticated: {
43
+ "Fn::GetAtt": [resolvedIds.authRole, "Arn"]
194
44
  },
195
- Roles: {
196
- authenticated: {
197
- "Fn::GetAtt": [`${id}AuthRole`, "Arn"]
198
- },
199
- unauthenticated: {
200
- "Fn::GetAtt": [`${id}UnauthRole`, "Arn"]
201
- }
45
+ unauthenticated: {
46
+ "Fn::GetAtt": [resolvedIds.unauthRole, "Arn"]
202
47
  }
203
48
  }
204
- },
205
- [`${id}AuthRole`]: {
206
- Type: "AWS::IAM::Role",
207
- Properties: {
208
- RoleName: authRoleName,
209
- Path: "/",
210
- AssumeRolePolicyDocument: {
211
- Version: "2012-10-17",
212
- Statement: [
213
- {
214
- Effect: "Allow",
215
- Principal: {
216
- Federated: "cognito-identity.amazonaws.com"
217
- },
218
- Action: ["sts:AssumeRoleWithWebIdentity"],
219
- Condition: {
220
- StringEquals: {
221
- "cognito-identity.amazonaws.com:aud": {
222
- Ref: `${id}IdentityPool`
223
- }
224
- },
225
- "ForAnyValue:StringLike": {
226
- "cognito-identity.amazonaws.com:amr": "authenticated"
227
- }
228
- }
229
- }
230
- ]
231
- },
232
- Policies: [
49
+ }
50
+ },
51
+ [resolvedIds.authRole]: {
52
+ Type: "AWS::IAM::Role",
53
+ Properties: {
54
+ RoleName: authRoleName,
55
+ Path: "/",
56
+ AssumeRolePolicyDocument: {
57
+ Version: "2012-10-17",
58
+ Statement: [
233
59
  {
234
- PolicyName: "CognitoAuthorizedPolicy",
235
- PolicyDocument: {
236
- Version: "2012-10-17",
237
- Statement: [
238
- {
239
- Effect: "Allow",
240
- Action: [
241
- "mobileanalytics:PutEvents",
242
- "cognito-sync:*",
243
- "cognito-identity:*"
244
- ],
245
- Resource: "*"
246
- },
247
- {
248
- Effect: "Allow",
249
- Action: ["execute-api:Invoke"],
250
- Resource: {
251
- "Fn::Sub": [
252
- "arn:aws:execute-api:${Region}:${AccountId}:${APIID}/${StageName}/${HTTPVerb}/api/*",
253
- {
254
- Region: {
255
- Ref: "AWS::Region"
256
- },
257
- AccountId: {
258
- Ref: "AWS::AccountId"
259
- },
260
- APIID: apiGatewayRESTAPIId,
261
- StageName: apiStageName,
262
- HTTPVerb: "*"
263
- }
264
- ]
265
- }
60
+ Effect: "Allow",
61
+ Principal: {
62
+ Federated: "cognito-identity.amazonaws.com"
63
+ },
64
+ Action: ["sts:AssumeRoleWithWebIdentity"],
65
+ Condition: {
66
+ StringEquals: {
67
+ "cognito-identity.amazonaws.com:aud": {
68
+ Ref: resolvedIds.identityPool
266
69
  }
267
- ]
70
+ },
71
+ "ForAnyValue:StringLike": {
72
+ "cognito-identity.amazonaws.com:amr": "authenticated"
73
+ }
268
74
  }
269
75
  }
270
76
  ]
271
- }
272
- },
273
- [`${id}UnauthRole`]: {
274
- Type: "AWS::IAM::Role",
275
- Properties: {
276
- RoleName: unauthRoleName,
277
- Path: "/",
278
- AssumeRolePolicyDocument: {
279
- Version: "2012-10-17",
280
- Statement: [
281
- {
282
- Effect: "Allow",
283
- Principal: {
284
- Federated: "cognito-identity.amazonaws.com"
77
+ },
78
+ Policies: [
79
+ {
80
+ PolicyName: "CognitoAuthorizedPolicy",
81
+ PolicyDocument: {
82
+ Version: "2012-10-17",
83
+ Statement: [
84
+ {
85
+ Effect: "Allow",
86
+ Action: [
87
+ "mobileanalytics:PutEvents",
88
+ "cognito-sync:*",
89
+ "cognito-identity:*"
90
+ ],
91
+ Resource: "*"
285
92
  },
286
- Action: ["sts:AssumeRoleWithWebIdentity"],
287
- Condition: {
288
- StringEquals: {
289
- "cognito-identity.amazonaws.com:aud": {
290
- Ref: `${id}IdentityPool`
291
- }
292
- },
293
- "ForAnyValue:StringLike": {
294
- "cognito-identity.amazonaws.com:amr": "unauthenticated"
93
+ {
94
+ Effect: "Allow",
95
+ Action: ["execute-api:Invoke"],
96
+ Resource: {
97
+ "Fn::Sub": [
98
+ "arn:aws:execute-api:${Region}:${AccountId}:${APIID}/${StageName}/${HTTPVerb}/api/*",
99
+ {
100
+ Region: {
101
+ Ref: "AWS::Region"
102
+ },
103
+ AccountId: {
104
+ Ref: "AWS::AccountId"
105
+ },
106
+ APIID: {
107
+ Ref: apiCloudFunctionGatewayId
108
+ },
109
+ StageName: apiStageName,
110
+ HTTPVerb: "*"
111
+ }
112
+ ]
295
113
  }
296
114
  }
297
- }
298
- ]
299
- },
300
- Policies: [
115
+ ]
116
+ }
117
+ }
118
+ ]
119
+ }
120
+ },
121
+ [resolvedIds.unauthRole]: {
122
+ Type: "AWS::IAM::Role",
123
+ Properties: {
124
+ RoleName: unauthRoleName,
125
+ Path: "/",
126
+ AssumeRolePolicyDocument: {
127
+ Version: "2012-10-17",
128
+ Statement: [
301
129
  {
302
- PolicyName: "CognitoUnauthorizedPolicy",
303
- PolicyDocument: {
304
- Version: "2012-10-17",
305
- Statement: [
306
- {
307
- Effect: "Allow",
308
- Action: [
309
- "mobileanalytics:PutEvents",
310
- "cognito-sync:*",
311
- "cognito-identity:*"
312
- ],
313
- Resource: "*"
130
+ Effect: "Allow",
131
+ Principal: {
132
+ Federated: "cognito-identity.amazonaws.com"
133
+ },
134
+ Action: ["sts:AssumeRoleWithWebIdentity"],
135
+ Condition: {
136
+ StringEquals: {
137
+ "cognito-identity.amazonaws.com:aud": {
138
+ Ref: resolvedIds.identityPool
314
139
  }
315
- ]
140
+ },
141
+ "ForAnyValue:StringLike": {
142
+ "cognito-identity.amazonaws.com:amr": "unauthenticated"
143
+ }
316
144
  }
317
145
  }
318
146
  ]
319
- }
320
- }
321
- } : {};
322
- return {
323
- Resources: {
324
- [id]: {
325
- Type: "AWS::Cognito::UserPool",
326
- Properties: {
327
- UserPoolName: {
328
- "Fn::Sub": [`\${AWS::StackName}${id}`, {}]
329
- },
330
- AccountRecoverySetting: {
331
- RecoveryMechanisms: [
147
+ },
148
+ Policies: [
149
+ {
150
+ PolicyName: "CognitoUnauthorizedPolicy",
151
+ PolicyDocument: {
152
+ Version: "2012-10-17",
153
+ Statement: [
332
154
  {
333
- Name: "verified_email",
334
- Priority: 1
155
+ Effect: "Allow",
156
+ Action: [
157
+ "mobileanalytics:PutEvents",
158
+ "cognito-sync:*",
159
+ "cognito-identity:*"
160
+ ],
161
+ Resource: "*"
335
162
  }
336
163
  ]
337
- },
338
- AdminCreateUserConfig: {
339
- AllowAdminCreateUserOnly: false,
340
- UnusedAccountValidityDays: 365
341
- },
342
- AutoVerifiedAttributes: ["email"],
343
- AliasAttributes: ["phone_number", "email", "preferred_username"],
344
- Schema: [
345
- {
346
- Name: "email",
347
- Required: true,
348
- Mutable: true
349
- },
350
- {
351
- Name: "given_name",
352
- Required: true,
353
- Mutable: true
354
- },
355
- {
356
- Name: "family_name",
357
- Required: true,
358
- Mutable: true
359
- },
360
- {
361
- Name: "phone_number",
362
- Required: true,
363
- Mutable: true
364
- }
365
- ],
366
- DeviceConfiguration: {
367
- ChallengeRequiredOnNewDevice: true,
368
- DeviceOnlyRememberedOnUserPrompt: false
369
- },
370
- UsernameConfiguration: {
371
- CaseSensitive: false
372
164
  }
373
165
  }
166
+ ]
167
+ }
168
+ }
169
+ };
170
+ const userPoolDomainConfig = config.enableUserPoolDomain === false ? {} : {
171
+ [resolvedIds.baseDomainRecord]: {
172
+ Type: "AWS::Route53::RecordSet",
173
+ DeletionPolicy: "Delete",
174
+ Properties: {
175
+ HostedZoneId: {
176
+ Ref: config.hostedZoneIdParameterName
374
177
  },
375
- [`${id}BaseDomainRecord`]: !!baseDomainRecordAliasTargetDNSName ? {
376
- Type: "AWS::Route53::RecordSet",
377
- DeletionPolicy: "Delete",
378
- Properties: {
379
- HostedZoneId: hostedZoneId,
380
- Type: "A",
381
- Name: domainName,
382
- AliasTarget: {
383
- HostedZoneId: "Z2FDTNDATAQYW2",
384
- DNSName: baseDomainRecordAliasTargetDNSName
385
- }
178
+ Type: "A",
179
+ Name: {
180
+ Ref: config.domainNameParameterName
181
+ },
182
+ AliasTarget: {
183
+ HostedZoneId: "Z2FDTNDATAQYW2",
184
+ DNSName: {
185
+ "Fn::GetAtt": [config.mainCDNCloudFrontId, "DomainName"]
386
186
  }
387
- } : void 0,
388
- [`${id}DomainRecord`]: {
389
- Type: "AWS::Route53::RecordSet",
390
- DeletionPolicy: "Delete",
391
- Properties: {
392
- HostedZoneId: hostedZoneId,
393
- Type: "A",
394
- Name: {
395
- "Fn::Sub": [
396
- "auth.${BaseDomainName}",
397
- {
398
- BaseDomainName: domainName
399
- }
400
- ]
401
- },
402
- AliasTarget: {
403
- HostedZoneId: "Z2FDTNDATAQYW2",
404
- DNSName: {
405
- "Fn::GetAtt": [`${id}Domain`, "CloudFrontDistribution"]
187
+ }
188
+ }
189
+ },
190
+ [resolvedIds.domainRecord]: {
191
+ Type: "AWS::Route53::RecordSet",
192
+ DeletionPolicy: "Delete",
193
+ Properties: {
194
+ HostedZoneId: {
195
+ Ref: config.hostedZoneIdParameterName
196
+ },
197
+ Type: "A",
198
+ Name: {
199
+ "Fn::Sub": [
200
+ "auth.${BaseDomainName}",
201
+ {
202
+ BaseDomainName: {
203
+ Ref: config.domainNameParameterName
406
204
  }
407
205
  }
206
+ ]
207
+ },
208
+ AliasTarget: {
209
+ HostedZoneId: "Z2FDTNDATAQYW2",
210
+ DNSName: {
211
+ "Fn::GetAtt": [resolvedIds.domain, "CloudFrontDistribution"]
408
212
  }
213
+ }
214
+ }
215
+ },
216
+ [resolvedIds.domain]: {
217
+ Type: "AWS::Cognito::UserPoolDomain",
218
+ DependsOn: resolvedIds.baseDomainRecord,
219
+ Properties: {
220
+ Domain: {
221
+ "Fn::Sub": [
222
+ "auth.${BaseDomainName}",
223
+ {
224
+ BaseDomainName: {
225
+ Ref: config.domainNameParameterName
226
+ }
227
+ }
228
+ ]
409
229
  },
410
- [`${id}Domain`]: {
411
- Type: "AWS::Cognito::UserPoolDomain",
412
- DependsOn: !!baseDomainRecordAliasTargetDNSName ? `${id}BaseDomainRecord` : void 0,
413
- Properties: {
414
- Domain: {
415
- "Fn::Sub": [
416
- "auth.${BaseDomainName}",
417
- {
418
- BaseDomainName: domainName
419
- }
420
- ]
230
+ UserPoolId: {
231
+ Ref: resolvedIds.userPool
232
+ },
233
+ CustomDomainConfig: {
234
+ CertificateArn: {
235
+ Ref: config.sslCertificateId
236
+ }
237
+ }
238
+ }
239
+ }
240
+ };
241
+ const callbackUrls = config.enableUserPoolDomain === false ? void 0 : config.callbackUrls;
242
+ const logoutUrls = config.enableUserPoolDomain === false ? void 0 : config.logoutUrls;
243
+ return new SimpleCFT().patch({
244
+ Resources: {
245
+ [resolvedIds.userPool]: {
246
+ Type: "AWS::Cognito::UserPool",
247
+ Properties: {
248
+ UserPoolName: {
249
+ "Fn::Sub": [`\${AWS::StackName}${userManagementId}`, {}]
250
+ },
251
+ AccountRecoverySetting: {
252
+ RecoveryMechanisms: [
253
+ {
254
+ Name: "verified_email",
255
+ Priority: 1
256
+ }
257
+ ]
258
+ },
259
+ AdminCreateUserConfig: {
260
+ AllowAdminCreateUserOnly: false,
261
+ UnusedAccountValidityDays: 365
262
+ },
263
+ AutoVerifiedAttributes: ["email"],
264
+ AliasAttributes: ["phone_number", "email", "preferred_username"],
265
+ Schema: [
266
+ {
267
+ Name: "email",
268
+ Required: true,
269
+ Mutable: true
421
270
  },
422
- UserPoolId: {
423
- Ref: id
271
+ {
272
+ Name: "given_name",
273
+ Required: true,
274
+ Mutable: true
275
+ },
276
+ {
277
+ Name: "family_name",
278
+ Required: true,
279
+ Mutable: true
424
280
  },
425
- CustomDomainConfig: {
426
- CertificateArn: sslCertificateArn
281
+ {
282
+ Name: "phone_number",
283
+ Required: true,
284
+ Mutable: true
427
285
  }
286
+ ],
287
+ DeviceConfiguration: {
288
+ ChallengeRequiredOnNewDevice: true,
289
+ DeviceOnlyRememberedOnUserPrompt: false
290
+ },
291
+ UsernameConfiguration: {
292
+ CaseSensitive: false
428
293
  }
429
- },
430
- [`${id}Client`]: {
431
- Type: "AWS::Cognito::UserPoolClient",
432
- Properties: {
433
- ClientName: {
434
- "Fn::Sub": [`\${AWS::StackName}${id}Client`, {}]
435
- },
436
- UserPoolId: {
437
- Ref: id
438
- },
294
+ }
295
+ },
296
+ [resolvedIds.userPoolClient]: {
297
+ Type: "AWS::Cognito::UserPoolClient",
298
+ Properties: {
299
+ ClientName: {
300
+ "Fn::Sub": [`\${AWS::StackName}${userManagementId}Client`, {}]
301
+ },
302
+ UserPoolId: {
303
+ Ref: resolvedIds.userPool
304
+ },
305
+ ...isUserPoolDomainEnabled ? {
439
306
  AllowedOAuthFlowsUserPoolClient: true,
440
307
  AllowedOAuthFlows: ["code", "implicit"],
441
308
  AllowedOAuthScopes: [
@@ -445,178 +312,54 @@ var addUserManagement = createResourcePack(
445
312
  "profile",
446
313
  "aws.cognito.signin.user.admin"
447
314
  ],
448
- CallbackURLs: callbackUrls,
449
- LogoutURLs: logoutUrls,
450
- EnableTokenRevocation: true,
451
- PreventUserExistenceErrors: "ENABLED",
452
- SupportedIdentityProviders: ["COGNITO"]
453
- }
454
- },
455
- [`${id}IdentityPool`]: {
456
- Type: "AWS::Cognito::IdentityPool",
457
- Properties: {
458
- IdentityPoolName: {
459
- "Fn::Sub": [`\${AWS::StackName}${id}IdentityPool`, {}]
460
- },
461
- AllowUnauthenticatedIdentities: false,
462
- CognitoIdentityProviders: [
463
- {
464
- ClientId: {
465
- Ref: `${id}Client`
466
- },
467
- ProviderName: {
468
- "Fn::GetAtt": [id, "ProviderName"]
469
- },
470
- ServerSideTokenCheck: true
471
- }
315
+ SupportedIdentityProviders: supportedIdentityProviders
316
+ } : {
317
+ AllowedOAuthFlowsUserPoolClient: false
318
+ },
319
+ EnableTokenRevocation: true,
320
+ PreventUserExistenceErrors: "ENABLED",
321
+ ...callbackUrls && callbackUrls.length > 0 ? { CallbackURLs: callbackUrls } : {},
322
+ ...logoutUrls && logoutUrls.length > 0 ? { LogoutURLs: logoutUrls } : {}
323
+ }
324
+ },
325
+ [resolvedIds.identityPool]: {
326
+ Type: "AWS::Cognito::IdentityPool",
327
+ Properties: {
328
+ IdentityPoolName: {
329
+ "Fn::Sub": [
330
+ `\${AWS::StackName}${userManagementId}IdentityPool`,
331
+ {}
472
332
  ]
473
- }
474
- },
475
- ...apiRoleConfig
476
- }
477
- };
478
- }
479
- );
480
- var SimpleCFT = class {
481
- /**
482
- * Create a SimpleCFT template wrapper.
483
- *
484
- * @param template - Initial CloudFormation template.
485
- */
486
- constructor(template = {
487
- AWSTemplateFormatVersion: "2010-09-09"
488
- }) {
489
- this.template = template;
490
- }
491
- /**
492
- * Apply a pack with configuration to the stack template.
493
- * @see {@link IaC} for an example.
494
- * */
495
- applyPack = (pack, params) => {
496
- this.template = pack(params, this.template);
497
- return this;
498
- };
499
- /**
500
- * Apply a patch to the stack template.
501
- *
502
- * @param patch - Template patch to merge.
503
- * */
504
- patch = (patch) => {
505
- this.template = patchTemplate(patch, this.template);
506
- return this;
507
- };
508
- /**
509
- * Add a stack parameter including its descriptive info and an optional parameter group.
510
- *
511
- * @param parameter - Parameter definition and metadata.
512
- * */
513
- addParameter = (parameter) => {
514
- this.template = addParameter(parameter, this.template);
515
- return this;
516
- };
517
- /**
518
- * Add a group of stack parameters including their descriptive info and an optional parameter group.
519
- *
520
- * @param group - Parameter group definition.
521
- * */
522
- addParameterGroup = ({ Label: Group, Parameters }) => {
523
- const parameterIds = Object.keys(Parameters);
524
- const parameterList = parameterIds.map((ParameterId) => {
525
- const { Label, ...Parameter } = Parameters[ParameterId];
526
- return {
527
- Group,
528
- ParameterId,
529
- Label,
530
- Parameter
531
- };
532
- });
533
- this.template = addParameters(parameterList, this.template);
534
- return this;
535
- };
536
- /**
537
- * Use a modification to dynamically apply various changes at once.
538
- *
539
- * @param modification - Modification callback to apply.
540
- * */
541
- modify = (modification) => {
542
- modification(this);
543
- return this;
544
- };
545
- /**
546
- * Convert the stack template to a string.
547
- *
548
- * @returns JSON string representation of the template.
549
- * */
550
- toString = () => JSON.stringify(this.template, null, 2);
551
- /**
552
- * Convert the stack template to a JSON object.
553
- *
554
- * @returns Template JSON object.
555
- * */
556
- toJSON = () => this.template;
557
- /**
558
- * Convert the stack template to a YAML string.
559
- *
560
- * @returns YAML string representation of the template.
561
- * */
562
- toYAML = () => YAML.stringify(this.template, {
563
- aliasDuplicateObjects: false
564
- });
565
- };
566
-
567
- // src/iac/packs/auth.ts
568
- var addAuth = createResourcePack(
569
- ({
570
- userManagementId,
571
- authRoleName,
572
- unauthRoleName,
573
- hostedZoneIdParameterName,
574
- domainNameParameterName,
575
- sslCertificateId,
576
- callbackUrls,
577
- logoutUrls,
578
- mainCDNCloudFrontId,
579
- apiCloudFunctionGatewayId,
580
- apiStageName,
581
- adminGroupId,
582
- userManagementAdminGroupName
583
- }) => new SimpleCFT().applyPack(addUserManagement, {
584
- id: userManagementId,
585
- authRoleName,
586
- unauthRoleName,
587
- domainName: {
588
- Ref: domainNameParameterName
589
- },
590
- hostedZoneId: {
591
- Ref: hostedZoneIdParameterName
592
- },
593
- sslCertificateArn: {
594
- Ref: sslCertificateId
595
- },
596
- callbackUrls,
597
- logoutUrls,
598
- baseDomainRecordAliasTargetDNSName: {
599
- "Fn::GetAtt": [mainCDNCloudFrontId, "DomainName"]
600
- },
601
- apiGatewayRESTAPIId: {
602
- Ref: apiCloudFunctionGatewayId
603
- },
604
- apiStageName
605
- }).patch({
606
- Resources: {
333
+ },
334
+ AllowUnauthenticatedIdentities: false,
335
+ CognitoIdentityProviders: [
336
+ {
337
+ ClientId: {
338
+ Ref: resolvedIds.userPoolClient
339
+ },
340
+ ProviderName: {
341
+ "Fn::GetAtt": [resolvedIds.userPool, "ProviderName"]
342
+ },
343
+ ServerSideTokenCheck: true
344
+ }
345
+ ]
346
+ }
347
+ },
348
+ ...userPoolDomainConfig,
349
+ ...apiRoleConfig,
607
350
  [adminGroupId]: {
608
351
  Type: "AWS::Cognito::UserPoolGroup",
609
352
  Properties: {
610
353
  GroupName: userManagementAdminGroupName,
611
354
  UserPoolId: {
612
- Ref: userManagementId
355
+ Ref: resolvedIds.userPool
613
356
  },
614
357
  Description: "Application admin group."
615
358
  }
616
359
  }
617
360
  }
618
- }).template
619
- );
361
+ }).template;
362
+ });
620
363
 
621
364
  // src/iac/packs/build.ts
622
365
  var DEFAULT_BUILD_PIPELINE_REPO_PROVIDER = "GitHub";
@@ -1035,7 +778,8 @@ var addCloudFunction = createResourcePack(
1035
778
  ]
1036
779
  }
1037
780
  }
1038
- ]
781
+ ],
782
+ memorySize = 128
1039
783
  }) => {
1040
784
  return {
1041
785
  Resources: {
@@ -1070,7 +814,8 @@ var addCloudFunction = createResourcePack(
1070
814
  Role: {
1071
815
  "Fn::GetAtt": [`${id}Role`, "Arn"]
1072
816
  },
1073
- Runtime: runtime
817
+ Runtime: runtime,
818
+ MemorySize: memorySize
1074
819
  }
1075
820
  }
1076
821
  }
@@ -1205,6 +950,31 @@ var addSecureFileStorage = createResourcePack(
1205
950
  );
1206
951
 
1207
952
  // src/iac/packs/gateway.ts
953
+ var canonicalizeHashableValue = (value) => {
954
+ if (Array.isArray(value)) {
955
+ return value.map((item) => canonicalizeHashableValue(item));
956
+ }
957
+ if (value && typeof value === "object") {
958
+ const output = {};
959
+ Object.keys(value).sort().forEach((key) => {
960
+ output[key] = canonicalizeHashableValue(
961
+ value[key]
962
+ );
963
+ });
964
+ return output;
965
+ }
966
+ return value;
967
+ };
968
+ var getDeterministicHash = (value) => {
969
+ const canonical = JSON.stringify(canonicalizeHashableValue(value));
970
+ let hash = 2166136261;
971
+ for (let i = 0; i < canonical.length; i += 1) {
972
+ hash ^= canonical.charCodeAt(i);
973
+ hash = Math.imul(hash, 16777619);
974
+ hash >>>= 0;
975
+ }
976
+ return hash.toString(16).toUpperCase().padStart(8, "0");
977
+ };
1208
978
  var DEFAULT_AUTH_TYPE = "COGNITO_USER_POOLS";
1209
979
  var addGateway = createResourcePack(
1210
980
  ({
@@ -1227,8 +997,29 @@ var addGateway = createResourcePack(
1227
997
  scopes: authScopes = ["phone", "email", "openid", "profile"],
1228
998
  type: authType = "COGNITO_USER_POOLS",
1229
999
  providerARNs,
1230
- identitySource = "method.request.header.authorization"
1000
+ identitySource = "method.request.header.Authorization"
1231
1001
  } = !!authorizer && typeof authorizer === "object" ? authorizer : {};
1002
+ const cloudFunctionIntegration = {
1003
+ Type: "AWS_PROXY",
1004
+ IntegrationHttpMethod: "POST",
1005
+ Uri: cloudFunctionUri
1006
+ };
1007
+ const gatewayResponseParameters = {
1008
+ "gatewayresponse.header.Access-Control-Allow-Origin": "method.request.header.origin",
1009
+ "gatewayresponse.header.Access-Control-Allow-Credentials": "'true'",
1010
+ "gatewayresponse.header.Access-Control-Allow-Headers": "'*'"
1011
+ };
1012
+ const cloudFunctionPermissionSourceArn = {
1013
+ "Fn::Sub": [
1014
+ "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*/*",
1015
+ {
1016
+ __Stage__: stageName,
1017
+ __ApiId__: {
1018
+ Ref: id
1019
+ }
1020
+ }
1021
+ ]
1022
+ };
1232
1023
  const authorizerId = `${id}CustomAuthorizer`;
1233
1024
  const authProps = !!authorizer ? {
1234
1025
  AuthorizationScopes: authScopes,
@@ -1239,7 +1030,33 @@ var addGateway = createResourcePack(
1239
1030
  } : {
1240
1031
  AuthorizationType: "NONE"
1241
1032
  };
1242
- const fullDeploymentId = `${id}GatewayRESTAPIDeployment${deploymentSuffix}`;
1033
+ const gatewayDeploymentFingerprint = {
1034
+ restApiEndpointTypes: ["EDGE"],
1035
+ proxyPathPart: "{proxy+}",
1036
+ anyMethod: {
1037
+ ...authProps,
1038
+ HttpMethod: "ANY",
1039
+ Integration: cloudFunctionIntegration
1040
+ },
1041
+ optionsMethod: {
1042
+ AuthorizationType: "NONE",
1043
+ HttpMethod: "OPTIONS",
1044
+ Integration: cloudFunctionIntegration
1045
+ },
1046
+ gatewayResponseDefault4XX: {
1047
+ ResponseParameters: gatewayResponseParameters,
1048
+ ResponseType: "DEFAULT_4XX"
1049
+ },
1050
+ stageName,
1051
+ cloudFunctionPermissionSourceArn,
1052
+ authorizer: !!authorizer ? {
1053
+ IdentitySource: identitySource,
1054
+ ProviderARNs: providerARNs,
1055
+ Type: "COGNITO_USER_POOLS"
1056
+ } : null
1057
+ };
1058
+ const deploymentHash = getDeterministicHash(gatewayDeploymentFingerprint);
1059
+ const fullDeploymentId = `${id}GatewayRESTAPIDeployment${deploymentHash}${deploymentSuffix}`;
1243
1060
  return new SimpleCFT().patch({
1244
1061
  Resources: {
1245
1062
  // REST API
@@ -1280,9 +1097,7 @@ var addGateway = createResourcePack(
1280
1097
  Ref: id
1281
1098
  },
1282
1099
  Integration: {
1283
- Type: "AWS_PROXY",
1284
- IntegrationHttpMethod: "POST",
1285
- Uri: cloudFunctionUri
1100
+ ...cloudFunctionIntegration
1286
1101
  }
1287
1102
  }
1288
1103
  },
@@ -1299,9 +1114,7 @@ var addGateway = createResourcePack(
1299
1114
  Ref: id
1300
1115
  },
1301
1116
  Integration: {
1302
- Type: "AWS_PROXY",
1303
- IntegrationHttpMethod: "POST",
1304
- Uri: cloudFunctionUri
1117
+ ...cloudFunctionIntegration
1305
1118
  }
1306
1119
  }
1307
1120
  }
@@ -1322,9 +1135,7 @@ var addGateway = createResourcePack(
1322
1135
  Ref: id
1323
1136
  },
1324
1137
  Integration: {
1325
- Type: "AWS_PROXY",
1326
- IntegrationHttpMethod: "POST",
1327
- Uri: cloudFunctionUri
1138
+ ...cloudFunctionIntegration
1328
1139
  }
1329
1140
  }
1330
1141
  },
@@ -1341,21 +1152,15 @@ var addGateway = createResourcePack(
1341
1152
  Ref: id
1342
1153
  },
1343
1154
  Integration: {
1344
- Type: "AWS_PROXY",
1345
- IntegrationHttpMethod: "POST",
1346
- Uri: cloudFunctionUri
1155
+ ...cloudFunctionIntegration
1347
1156
  }
1348
1157
  }
1349
1158
  },
1350
1159
  [`${id}GatewayResponseDefault4XX`]: {
1351
1160
  Type: "AWS::ApiGateway::GatewayResponse",
1352
1161
  Properties: {
1353
- ResponseParameters: {
1354
- // Not authorized, so just allow the current origin by mapping it into the header.
1355
- "gatewayresponse.header.Access-Control-Allow-Origin": "method.request.header.origin",
1356
- "gatewayresponse.header.Access-Control-Allow-Credentials": "'true'",
1357
- "gatewayresponse.header.Access-Control-Allow-Headers": "'*'"
1358
- },
1162
+ // Not authorized, so just allow the current origin by mapping it into the header.
1163
+ ResponseParameters: gatewayResponseParameters,
1359
1164
  ResponseType: "DEFAULT_4XX",
1360
1165
  RestApiId: {
1361
1166
  Ref: id
@@ -1511,15 +1316,7 @@ var addGateway = createResourcePack(
1511
1316
  "Fn::GetAtt": [cloudFunctionId, "Arn"]
1512
1317
  },
1513
1318
  SourceArn: {
1514
- "Fn::Sub": [
1515
- "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*/*",
1516
- {
1517
- __Stage__: stageName,
1518
- __ApiId__: {
1519
- Ref: id
1520
- }
1521
- }
1522
- ]
1319
+ ...cloudFunctionPermissionSourceArn
1523
1320
  }
1524
1321
  }
1525
1322
  }