@resistdesign/voltra 0.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/README.md +86 -0
  2. package/package.json +103 -0
  3. package/src/api/DataAccessControl.d.ts +85 -0
  4. package/src/api/DataAccessControl.js +159 -0
  5. package/src/api/ORM/DACUtils.d.ts +60 -0
  6. package/src/api/ORM/DACUtils.js +197 -0
  7. package/src/api/ORM/ListItemUtils.d.ts +7 -0
  8. package/src/api/ORM/ListItemUtils.js +22 -0
  9. package/src/api/ORM/ORMRouteMap.d.ts +19 -0
  10. package/src/api/ORM/ORMRouteMap.js +82 -0
  11. package/src/api/ORM/TypeInfoORMService.d.ts +103 -0
  12. package/src/api/ORM/TypeInfoORMService.js +581 -0
  13. package/src/api/ORM/drivers/DynamoDBDataItemDBDriver/ConfigTypes.d.ts +63 -0
  14. package/src/api/ORM/drivers/DynamoDBDataItemDBDriver/ConfigTypes.js +2 -0
  15. package/src/api/ORM/drivers/DynamoDBDataItemDBDriver.d.ts +36 -0
  16. package/src/api/ORM/drivers/DynamoDBDataItemDBDriver.js +282 -0
  17. package/src/api/ORM/drivers/S3FileItemDBDriver/ConfigTypes.d.ts +90 -0
  18. package/src/api/ORM/drivers/S3FileItemDBDriver/ConfigTypes.js +2 -0
  19. package/src/api/ORM/drivers/S3FileItemDBDriver/S3FileDriver.d.ts +45 -0
  20. package/src/api/ORM/drivers/S3FileItemDBDriver/S3FileDriver.js +127 -0
  21. package/src/api/ORM/drivers/S3FileItemDBDriver.d.ts +44 -0
  22. package/src/api/ORM/drivers/S3FileItemDBDriver.js +182 -0
  23. package/src/api/ORM/drivers/common/SupportedTypeInfoORMDBDrivers.d.ts +12 -0
  24. package/src/api/ORM/drivers/common/SupportedTypeInfoORMDBDrivers.js +20 -0
  25. package/src/api/ORM/drivers/common/Types.d.ts +77 -0
  26. package/src/api/ORM/drivers/common/Types.js +14 -0
  27. package/src/api/ORM/drivers/common/index.d.ts +2 -0
  28. package/src/api/ORM/drivers/common/index.js +18 -0
  29. package/src/api/ORM/drivers/index.d.ts +3 -0
  30. package/src/api/ORM/drivers/index.js +19 -0
  31. package/src/api/ORM/index.d.ts +4 -0
  32. package/src/api/ORM/index.js +43 -0
  33. package/src/api/Router/AWS.d.ts +26 -0
  34. package/src/api/Router/AWS.js +76 -0
  35. package/src/api/Router/Auth.d.ts +2 -0
  36. package/src/api/Router/Auth.js +9 -0
  37. package/src/api/Router/CORS.d.ts +6 -0
  38. package/src/api/Router/CORS.js +27 -0
  39. package/src/api/Router/Types.d.ts +71 -0
  40. package/src/api/Router/Types.js +2 -0
  41. package/src/api/Router/index.d.ts +18 -0
  42. package/src/api/Router/index.js +145 -0
  43. package/src/api/index.d.ts +3 -0
  44. package/src/api/index.js +39 -0
  45. package/src/app/index.d.ts +1 -0
  46. package/src/app/index.js +37 -0
  47. package/src/app/utils/ApplicationState.d.ts +52 -0
  48. package/src/app/utils/ApplicationState.js +86 -0
  49. package/src/app/utils/ApplicationStateLoader.d.ts +46 -0
  50. package/src/app/utils/ApplicationStateLoader.js +57 -0
  51. package/src/app/utils/Controller.d.ts +4 -0
  52. package/src/app/utils/Controller.js +47 -0
  53. package/src/app/utils/Debug.d.ts +4 -0
  54. package/src/app/utils/Debug.js +30 -0
  55. package/src/app/utils/EasyLayout.d.ts +49 -0
  56. package/src/app/utils/EasyLayout.js +122 -0
  57. package/src/app/utils/Route.d.ts +28 -0
  58. package/src/app/utils/Route.js +102 -0
  59. package/src/app/utils/Service.d.ts +12 -0
  60. package/src/app/utils/Service.js +34 -0
  61. package/src/app/utils/TypeInfoORMAPIUtils.d.ts +20 -0
  62. package/src/app/utils/TypeInfoORMAPIUtils.js +62 -0
  63. package/src/app/utils/TypeInfoORMClient.d.ts +24 -0
  64. package/src/app/utils/TypeInfoORMClient.js +69 -0
  65. package/src/app/utils/index.d.ts +8 -0
  66. package/src/app/utils/index.js +24 -0
  67. package/src/common/CommandLine/collectRequiredEnvironmentVariables.d.ts +1 -0
  68. package/src/common/CommandLine/collectRequiredEnvironmentVariables.js +16 -0
  69. package/src/common/HelperTypes.d.ts +3 -0
  70. package/src/common/HelperTypes.js +2 -0
  71. package/src/common/IdGeneration/getSimpleId.d.ts +4 -0
  72. package/src/common/IdGeneration/getSimpleId.js +16 -0
  73. package/src/common/IdGeneration/index.d.ts +1 -0
  74. package/src/common/IdGeneration/index.js +17 -0
  75. package/src/common/ItemRelationshipInfoTypes.d.ts +46 -0
  76. package/src/common/ItemRelationshipInfoTypes.js +20 -0
  77. package/src/common/ItemRelationships/ItemRelationshipValidation.d.ts +10 -0
  78. package/src/common/ItemRelationships/ItemRelationshipValidation.js +43 -0
  79. package/src/common/ItemRelationships/index.d.ts +1 -0
  80. package/src/common/ItemRelationships/index.js +17 -0
  81. package/src/common/Logging/Utils.d.ts +10 -0
  82. package/src/common/Logging/Utils.js +33 -0
  83. package/src/common/Logging/index.d.ts +1 -0
  84. package/src/common/Logging/index.js +17 -0
  85. package/src/common/Routing.d.ts +25 -0
  86. package/src/common/Routing.js +102 -0
  87. package/src/common/SearchTypes.d.ts +98 -0
  88. package/src/common/SearchTypes.js +39 -0
  89. package/src/common/SearchUtils.d.ts +22 -0
  90. package/src/common/SearchUtils.js +134 -0
  91. package/src/common/SearchValidation.d.ts +17 -0
  92. package/src/common/SearchValidation.js +90 -0
  93. package/src/common/Storyboarding/Types.d.ts +25 -0
  94. package/src/common/Storyboarding/Types.js +2 -0
  95. package/src/common/StringTransformers.d.ts +17 -0
  96. package/src/common/StringTransformers.js +36 -0
  97. package/src/common/Testing/CLI.d.ts +2 -0
  98. package/src/common/Testing/CLI.js +56 -0
  99. package/src/common/Testing/Types.d.ts +117 -0
  100. package/src/common/Testing/Types.js +19 -0
  101. package/src/common/Testing/Utils.d.ts +48 -0
  102. package/src/common/Testing/Utils.js +334 -0
  103. package/src/common/Testing/index.d.ts +2 -0
  104. package/src/common/Testing/index.js +18 -0
  105. package/src/common/TypeInfoDataItemUtils.d.ts +10 -0
  106. package/src/common/TypeInfoDataItemUtils.js +55 -0
  107. package/src/common/TypeInfoORM/Types.d.ts +76 -0
  108. package/src/common/TypeInfoORM/Types.js +55 -0
  109. package/src/common/TypeInfoORM/index.d.ts +1 -0
  110. package/src/common/TypeInfoORM/index.js +17 -0
  111. package/src/common/TypeParsing/Constants.d.ts +1 -0
  112. package/src/common/TypeParsing/Constants.js +4 -0
  113. package/src/common/TypeParsing/ParsingUtils/Constants.d.ts +5 -0
  114. package/src/common/TypeParsing/ParsingUtils/Constants.js +8 -0
  115. package/src/common/TypeParsing/ParsingUtils/checkType.d.ts +8 -0
  116. package/src/common/TypeParsing/ParsingUtils/checkType.js +46 -0
  117. package/src/common/TypeParsing/ParsingUtils/checkUnionType.d.ts +6 -0
  118. package/src/common/TypeParsing/ParsingUtils/checkUnionType.js +15 -0
  119. package/src/common/TypeParsing/ParsingUtils/extractCommentTags.d.ts +2 -0
  120. package/src/common/TypeParsing/ParsingUtils/extractCommentTags.js +105 -0
  121. package/src/common/TypeParsing/ParsingUtils/extractLiteralValues.d.ts +6 -0
  122. package/src/common/TypeParsing/ParsingUtils/extractLiteralValues.js +42 -0
  123. package/src/common/TypeParsing/ParsingUtils/extractTypeDetails.d.ts +8 -0
  124. package/src/common/TypeParsing/ParsingUtils/extractTypeDetails.js +14 -0
  125. package/src/common/TypeParsing/ParsingUtils/getPrimaryFieldForTypeInfo.d.ts +5 -0
  126. package/src/common/TypeParsing/ParsingUtils/getPrimaryFieldForTypeInfo.js +27 -0
  127. package/src/common/TypeParsing/ParsingUtils/getTypeInfo.d.ts +3 -0
  128. package/src/common/TypeParsing/ParsingUtils/getTypeInfo.js +27 -0
  129. package/src/common/TypeParsing/ParsingUtils/getTypeInfoField.d.ts +3 -0
  130. package/src/common/TypeParsing/ParsingUtils/getTypeInfoField.js +44 -0
  131. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromAliasType.d.ts +4 -0
  132. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromAliasType.js +28 -0
  133. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromFieldFilter.d.ts +4 -0
  134. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromFieldFilter.js +105 -0
  135. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromTypeAlias.d.ts +4 -0
  136. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromTypeAlias.js +20 -0
  137. package/src/common/TypeParsing/ParsingUtils/getTypeKeyword.d.ts +3 -0
  138. package/src/common/TypeParsing/ParsingUtils/getTypeKeyword.js +17 -0
  139. package/src/common/TypeParsing/ParsingUtils/getUnionOrIntersectionTypeInfo.d.ts +4 -0
  140. package/src/common/TypeParsing/ParsingUtils/getUnionOrIntersectionTypeInfo.js +49 -0
  141. package/src/common/TypeParsing/ParsingUtils/getUnionOrLiteralStringValues.d.ts +2 -0
  142. package/src/common/TypeParsing/ParsingUtils/getUnionOrLiteralStringValues.js +24 -0
  143. package/src/common/TypeParsing/TypeInfo.d.ts +142 -0
  144. package/src/common/TypeParsing/TypeInfo.js +13 -0
  145. package/src/common/TypeParsing/TypeMapping.d.ts +9 -0
  146. package/src/common/TypeParsing/TypeMapping.js +32 -0
  147. package/src/common/TypeParsing/TypeParsing.d.ts +5 -0
  148. package/src/common/TypeParsing/TypeParsing.js +39 -0
  149. package/src/common/TypeParsing/Utils.d.ts +21 -0
  150. package/src/common/TypeParsing/Utils.js +94 -0
  151. package/src/common/TypeParsing/Validation.d.ts +92 -0
  152. package/src/common/TypeParsing/Validation.js +340 -0
  153. package/src/common/TypeParsing/index.d.ts +5 -0
  154. package/src/common/TypeParsing/index.js +44 -0
  155. package/src/common/index.d.ts +11 -0
  156. package/src/common/index.js +47 -0
  157. package/src/iac/SimpleCFT.d.ts +48 -0
  158. package/src/iac/SimpleCFT.js +82 -0
  159. package/src/iac/index.d.ts +9 -0
  160. package/src/iac/index.js +48 -0
  161. package/src/iac/packs/auth/user-management.d.ts +14 -0
  162. package/src/iac/packs/auth/user-management.js +302 -0
  163. package/src/iac/packs/auth.d.ts +19 -0
  164. package/src/iac/packs/auth.js +47 -0
  165. package/src/iac/packs/build/utils.d.ts +100 -0
  166. package/src/iac/packs/build/utils.js +23 -0
  167. package/src/iac/packs/build.d.ts +29 -0
  168. package/src/iac/packs/build.js +217 -0
  169. package/src/iac/packs/cdn.d.ts +12 -0
  170. package/src/iac/packs/cdn.js +113 -0
  171. package/src/iac/packs/cloud-function.d.ts +17 -0
  172. package/src/iac/packs/cloud-function.js +69 -0
  173. package/src/iac/packs/database.d.ts +29 -0
  174. package/src/iac/packs/database.js +27 -0
  175. package/src/iac/packs/dns.d.ts +13 -0
  176. package/src/iac/packs/dns.js +26 -0
  177. package/src/iac/packs/file-storage.d.ts +14 -0
  178. package/src/iac/packs/file-storage.js +71 -0
  179. package/src/iac/packs/gateway.d.ts +27 -0
  180. package/src/iac/packs/gateway.js +342 -0
  181. package/src/iac/packs/index.d.ts +11 -0
  182. package/src/iac/packs/index.js +27 -0
  183. package/src/iac/packs/repo.d.ts +10 -0
  184. package/src/iac/packs/repo.js +34 -0
  185. package/src/iac/packs/ssl-certificate.d.ts +10 -0
  186. package/src/iac/packs/ssl-certificate.js +36 -0
  187. package/src/iac/types/CloudFormationResourceSpecification.d.ts +2 -0
  188. package/src/iac/types/Constants.d.ts +9 -0
  189. package/src/iac/types/Constants.js +20 -0
  190. package/src/iac/types/IaCTypes.d.ts +234994 -0
  191. package/src/iac/types/IaCTypes.js +14 -0
  192. package/src/iac/types/Renderers.d.ts +12 -0
  193. package/src/iac/types/Renderers.js +112 -0
  194. package/src/iac/types/Types.d.ts +37 -0
  195. package/src/iac/types/Types.js +2 -0
  196. package/src/iac/types/Utils.d.ts +2 -0
  197. package/src/iac/types/Utils.js +60 -0
  198. package/src/iac/types/generate.d.ts +1 -0
  199. package/src/iac/types/generate.js +31 -0
  200. package/src/iac/utils/index.d.ts +36 -0
  201. package/src/iac/utils/index.js +105 -0
  202. package/src/iac/utils/patch-utils.d.ts +15 -0
  203. package/src/iac/utils/patch-utils.js +62 -0
  204. package/src/index.d.ts +178 -0
  205. package/src/index.js +214 -0
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CloudFormationPseudoParameters = void 0;
4
+ var CloudFormationPseudoParameters;
5
+ (function (CloudFormationPseudoParameters) {
6
+ CloudFormationPseudoParameters["AWS::AccountId"] = "AWS::AccountId";
7
+ CloudFormationPseudoParameters["AWS::NotificationARNs"] = "AWS::NotificationARNs";
8
+ CloudFormationPseudoParameters["AWS::NoValue"] = "AWS::NoValue";
9
+ CloudFormationPseudoParameters["AWS::Partition"] = "AWS::Partition";
10
+ CloudFormationPseudoParameters["AWS::Region"] = "AWS::Region";
11
+ CloudFormationPseudoParameters["AWS::StackId"] = "AWS::StackId";
12
+ CloudFormationPseudoParameters["AWS::StackName"] = "AWS::StackName";
13
+ CloudFormationPseudoParameters["AWS::URLSuffix"] = "AWS::URLSuffix";
14
+ })(CloudFormationPseudoParameters || (exports.CloudFormationPseudoParameters = CloudFormationPseudoParameters = {}));
@@ -0,0 +1,12 @@
1
+ import { AttributeType, IDocumentable, NamespaceStructure, PropertyDescriptor, PropertyType, ResourceType } from './Types';
2
+ export declare const renderPrimitiveType: (primitiveType: string) => string;
3
+ export declare const renderPropertyType: (path: string[], { PrimitiveType, Type, PrimitiveItemType, ItemType }: AttributeType) => string;
4
+ export declare const renderPropertyName: (propertyName: string, descriptor: PropertyDescriptor | AttributeType) => string;
5
+ export declare const renderCommentBlock: ({ UpdateType, DuplicatesAllowed, Documentation }: IDocumentable) => string;
6
+ export declare const renderProperty: (path: string[], propertyName: string, propertyDescriptor: PropertyDescriptor | AttributeType) => string;
7
+ export declare const renderTypeWithFullBody: (commentBlock: string, typeName: string, fullBody: string) => string;
8
+ export declare const renderTypePropertiesBody: (path: string[], properties: Record<string, PropertyDescriptor | AttributeType>) => string;
9
+ export declare const renderTypeWithProperties: (path: string[], typeName: string, properties: Record<string, AttributeType>, commentBlock?: string) => string;
10
+ export declare const renderTypeFromPropertyType: (path: string[], typeName: string, propertyType: PropertyType) => string;
11
+ export declare const renderTypeFromResourceType: (path: string[], typeName: string, resourceType: ResourceType) => string;
12
+ export declare const renderNamespaceStructure: ({ path, includes, propertyTypes, resourceTypes, namespaces }: NamespaceStructure, namespaceName?: string) => string;
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderNamespaceStructure = exports.renderTypeFromResourceType = exports.renderTypeFromPropertyType = exports.renderTypeWithProperties = exports.renderTypePropertiesBody = exports.renderTypeWithFullBody = exports.renderProperty = exports.renderCommentBlock = exports.renderPropertyName = exports.renderPropertyType = exports.renderPrimitiveType = void 0;
4
+ const Constants_1 = require("./Constants");
5
+ const renderPrimitiveType = (primitiveType) => primitiveType in Constants_1.PRIMITIVE_TYPE_MAP ? `CloudFormationPrimitiveValue<${Constants_1.PRIMITIVE_TYPE_MAP[primitiveType]}>` : primitiveType;
6
+ exports.renderPrimitiveType = renderPrimitiveType;
7
+ const renderPropertyType = (path, { PrimitiveType, Type, PrimitiveItemType, ItemType }) => {
8
+ if (PrimitiveType) {
9
+ return (0, exports.renderPrimitiveType)(PrimitiveType);
10
+ }
11
+ else if (Type && Constants_1.CONTAINER_TYPES.indexOf(Type) !== -1) {
12
+ const resolvedItemType = PrimitiveItemType
13
+ ? (0, exports.renderPrimitiveType)(PrimitiveItemType)
14
+ : ItemType === Constants_1.TAG_TYPE
15
+ ? Constants_1.TAG_TYPE
16
+ : [...path, ItemType].join(Constants_1.NAMESPACE_DELIMITERS.OUTPUT);
17
+ return Type === 'List' ? `${resolvedItemType}[]` : `Record<string, ${resolvedItemType}>`;
18
+ }
19
+ else if (Type === Constants_1.TAG_TYPE) {
20
+ return Constants_1.TAG_TYPE;
21
+ }
22
+ else if (Type) {
23
+ return [...path, Type].join(Constants_1.NAMESPACE_DELIMITERS.OUTPUT);
24
+ }
25
+ else {
26
+ return Constants_1.NEVER_TYPE;
27
+ }
28
+ };
29
+ exports.renderPropertyType = renderPropertyType;
30
+ const renderPropertyName = (propertyName, descriptor) => {
31
+ const cleanPropertyName = propertyName && propertyName.indexOf('.') !== -1 ? `'${propertyName}'` : propertyName;
32
+ if ('Required' in descriptor) {
33
+ const { Required } = descriptor;
34
+ return `${cleanPropertyName}${Required ? '' : '?'}`;
35
+ }
36
+ else {
37
+ return cleanPropertyName;
38
+ }
39
+ };
40
+ exports.renderPropertyName = renderPropertyName;
41
+ const renderCommentBlock = ({ UpdateType, DuplicatesAllowed = false, Documentation }) => UpdateType || DuplicatesAllowed || Documentation
42
+ ? `/**${UpdateType
43
+ ? `
44
+ * Update Type: ${UpdateType}`
45
+ : ''}${DuplicatesAllowed
46
+ ? `
47
+ * Duplicates Allowed: Yes`
48
+ : ''}${Documentation
49
+ ? `
50
+ * @see ${Documentation}`
51
+ : ''}
52
+ * */
53
+ `
54
+ : '';
55
+ exports.renderCommentBlock = renderCommentBlock;
56
+ const renderProperty = (path, propertyName, propertyDescriptor) => `${(0, exports.renderCommentBlock)(propertyDescriptor)}${(0, exports.renderPropertyName)(propertyName, propertyDescriptor)}: ${(0, exports.renderPropertyType)(path, propertyDescriptor)};`;
57
+ exports.renderProperty = renderProperty;
58
+ const renderTypeWithFullBody = (commentBlock, typeName, fullBody) => `${commentBlock}export type ${typeName} = ${fullBody};`;
59
+ exports.renderTypeWithFullBody = renderTypeWithFullBody;
60
+ const renderTypePropertiesBody = (path, properties) => {
61
+ const propertyKeys = Object.keys(properties);
62
+ return `{
63
+ ${propertyKeys.map((pK) => (0, exports.renderProperty)(path, pK, properties[pK])).join('\n')}
64
+ }`;
65
+ };
66
+ exports.renderTypePropertiesBody = renderTypePropertiesBody;
67
+ const renderTypeWithProperties = (path, typeName, properties, commentBlock = '') => {
68
+ return (0, exports.renderTypeWithFullBody)(commentBlock, typeName, (0, exports.renderTypePropertiesBody)(path, properties));
69
+ };
70
+ exports.renderTypeWithProperties = renderTypeWithProperties;
71
+ const renderTypeFromPropertyType = (path, typeName, propertyType) => {
72
+ const { Properties } = propertyType;
73
+ const commentBlock = (0, exports.renderCommentBlock)(propertyType);
74
+ if (Properties) {
75
+ return (0, exports.renderTypeWithProperties)(path, typeName, Properties, commentBlock);
76
+ }
77
+ else {
78
+ return `${commentBlock}export type ${typeName} = ${(0, exports.renderPropertyType)(path, propertyType)}`;
79
+ }
80
+ };
81
+ exports.renderTypeFromPropertyType = renderTypeFromPropertyType;
82
+ const renderTypeFromResourceType = (path, typeName, resourceType) => {
83
+ const { Type, Properties, Attributes } = resourceType;
84
+ const commentBlock = (0, exports.renderCommentBlock)(resourceType);
85
+ const subPath = [...path, typeName];
86
+ return (0, exports.renderTypeWithFullBody)(commentBlock, typeName, `CloudFormationResource<'${Type}', ${Attributes ? (0, exports.renderTypePropertiesBody)(subPath, Attributes) : Constants_1.NEVER_TYPE}, ${Properties ? (0, exports.renderTypePropertiesBody)(subPath, Properties) : Constants_1.NEVER_TYPE}>`);
87
+ };
88
+ exports.renderTypeFromResourceType = renderTypeFromResourceType;
89
+ const renderNamespaceStructure = ({ path = [], includes = [], propertyTypes = {}, resourceTypes = {}, namespaces = {} }, namespaceName) => {
90
+ const namespaceBody = `${includes?.join('\n')}
91
+
92
+ ${Object.keys(propertyTypes)
93
+ .map((pT) => (0, exports.renderTypeFromPropertyType)(path, pT, propertyTypes[pT]))
94
+ .join('\n')}
95
+
96
+ ${Object.keys(resourceTypes)
97
+ .map((rT) => (0, exports.renderTypeFromResourceType)(path, rT, resourceTypes[rT]))
98
+ .join('\n')}
99
+
100
+ ${Object.keys(namespaces)
101
+ .map((ns) => (0, exports.renderNamespaceStructure)(namespaces[ns], ns))
102
+ .join('\n')}`;
103
+ if (namespaceName) {
104
+ return `export namespace ${namespaceName} {
105
+ ${namespaceBody}
106
+ }`;
107
+ }
108
+ else {
109
+ return namespaceBody;
110
+ }
111
+ };
112
+ exports.renderNamespaceStructure = renderNamespaceStructure;
@@ -0,0 +1,37 @@
1
+ export interface IDocumentable {
2
+ UpdateType?: string;
3
+ DuplicatesAllowed?: boolean;
4
+ Documentation?: string;
5
+ }
6
+ export type AttributeType = {
7
+ PrimitiveType?: string;
8
+ Type?: string;
9
+ ItemType?: string;
10
+ PrimitiveItemType?: string;
11
+ DuplicatesAllowed?: boolean;
12
+ };
13
+ export type PropertyDescriptor = IDocumentable & AttributeType & {
14
+ Required?: boolean;
15
+ };
16
+ export type PropertyType = PropertyDescriptor & {
17
+ Properties?: Record<string, PropertyDescriptor>;
18
+ };
19
+ export type ResourceType = {
20
+ Type?: string;
21
+ Documentation?: string;
22
+ AdditionalProperties?: boolean;
23
+ Properties?: Record<string, PropertyDescriptor>;
24
+ Attributes?: Record<string, AttributeType>;
25
+ };
26
+ export type CloudFormationResourceSpecification = {
27
+ PropertyTypes: Record<string, PropertyType>;
28
+ ResourceTypes: Record<string, ResourceType>;
29
+ ResourceSpecificationVersion: `${number}.${number}.${number}`;
30
+ };
31
+ export type NamespaceStructure = {
32
+ path: string[];
33
+ includes?: string[];
34
+ propertyTypes?: Record<string, PropertyType>;
35
+ resourceTypes?: Record<string, ResourceType>;
36
+ namespaces?: Record<string, NamespaceStructure>;
37
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import { CloudFormationResourceSpecification, NamespaceStructure } from './Types';
2
+ export declare const getNamespaceStructure: (specification: CloudFormationResourceSpecification, baseStructure: NamespaceStructure) => NamespaceStructure;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNamespaceStructure = void 0;
4
+ const Constants_1 = require("./Constants");
5
+ const getNamespaceStructure = (specification, baseStructure) => {
6
+ const newStructure = {
7
+ ...baseStructure,
8
+ };
9
+ const { PropertyTypes, ResourceTypes } = specification;
10
+ const propertyTypesKeys = Object.keys(PropertyTypes);
11
+ const resourceTypesKeys = Object.keys(ResourceTypes);
12
+ const resourceTypeOptions = [];
13
+ for (const pTK of propertyTypesKeys) {
14
+ const fullPropertyTypeNameParts = pTK
15
+ .replace(Constants_1.NAMESPACE_DELIMITERS.INPUT_REGEX, () => Constants_1.NAMESPACE_DELIMITERS.OUTPUT)
16
+ .split(Constants_1.NAMESPACE_DELIMITERS.OUTPUT);
17
+ const propType = PropertyTypes[pTK];
18
+ const currentPath = [];
19
+ let targetNamespace = newStructure;
20
+ for (let i = 0; i < fullPropertyTypeNameParts.length; i++) {
21
+ const part = fullPropertyTypeNameParts[i];
22
+ currentPath.push(part);
23
+ if (i === fullPropertyTypeNameParts.length - 1) {
24
+ targetNamespace.propertyTypes = targetNamespace.propertyTypes || {};
25
+ targetNamespace.propertyTypes[part] = propType;
26
+ }
27
+ else {
28
+ targetNamespace.namespaces = targetNamespace.namespaces || {};
29
+ targetNamespace.namespaces[part] = targetNamespace.namespaces[part] || { path: [...currentPath] };
30
+ targetNamespace = targetNamespace.namespaces[part];
31
+ }
32
+ }
33
+ }
34
+ for (const rTK of resourceTypesKeys) {
35
+ const fullResourceTypeNameParts = rTK.split(Constants_1.NAMESPACE_DELIMITERS.INPUT);
36
+ const resType = ResourceTypes[rTK];
37
+ const currentPath = [];
38
+ let targetNamespace = newStructure;
39
+ for (let i = 0; i < fullResourceTypeNameParts.length; i++) {
40
+ const part = fullResourceTypeNameParts[i];
41
+ currentPath.push(part);
42
+ if (i === fullResourceTypeNameParts.length - 1) {
43
+ targetNamespace.resourceTypes = targetNamespace.resourceTypes || {};
44
+ targetNamespace.resourceTypes[part] = {
45
+ ...resType,
46
+ Type: rTK,
47
+ };
48
+ resourceTypeOptions.push(currentPath.join(Constants_1.NAMESPACE_DELIMITERS.OUTPUT));
49
+ }
50
+ else {
51
+ targetNamespace.namespaces = targetNamespace.namespaces || {};
52
+ targetNamespace.namespaces[part] = targetNamespace.namespaces[part] || { path: [...currentPath] };
53
+ targetNamespace = targetNamespace.namespaces[part];
54
+ }
55
+ }
56
+ }
57
+ newStructure.includes = [`export type AllResourceTypes = ${resourceTypeOptions.join(' | ')};`, ...(newStructure.includes || [])];
58
+ return newStructure;
59
+ };
60
+ exports.getNamespaceStructure = getNamespaceStructure;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const path_1 = __importDefault(require("path"));
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const prettier_1 = require("prettier");
9
+ const CloudFormationResourceSpecification_1 = require("./CloudFormationResourceSpecification");
10
+ const Utils_1 = require("./Utils");
11
+ const Renderers_1 = require("./Renderers");
12
+ const STANDARD_INCLUDES = fs_1.default.readFileSync(path_1.default.join(__dirname, "StandardIncludes.d.ts.tmpl"), { encoding: "utf8" })
13
+ // IMPORTANT: Remove the first line which is a placeholder for the `AllResourceTypes` type.
14
+ .replace(/.*/, "")
15
+ .trimStart();
16
+ const BASE_NAMESPACE_STRUCTURE = {
17
+ path: [],
18
+ includes: [STANDARD_INCLUDES],
19
+ propertyTypes: {},
20
+ resourceTypes: {},
21
+ namespaces: {},
22
+ };
23
+ const NamespaceStructure = (0, Utils_1.getNamespaceStructure)(CloudFormationResourceSpecification_1.CloudFormationResourceSpecificationData, BASE_NAMESPACE_STRUCTURE);
24
+ const generate = async () => {
25
+ const TypesContentString = await (0, prettier_1.format)((0, Renderers_1.renderNamespaceStructure)(NamespaceStructure), {
26
+ parser: "typescript",
27
+ });
28
+ fs_1.default.mkdirSync(path_1.default.join(__dirname, "..", "dist"), { recursive: true });
29
+ fs_1.default.writeFileSync(path_1.default.join(__dirname, "..", "dist", "IaCTypes.ts"), TypesContentString, { encoding: "utf8" });
30
+ };
31
+ generate();
@@ -0,0 +1,36 @@
1
+ import { CloudFormationParameter, CloudFormationTemplate } from "../types/IaCTypes";
2
+ export * from "./patch-utils";
3
+ export type ParameterInfo = {
4
+ ParameterId: string;
5
+ Parameter: CloudFormationParameter;
6
+ Label: string;
7
+ Group?: string;
8
+ };
9
+ /**
10
+ * Add a stack parameter including its descriptive info and an optional parameter group.
11
+ * */
12
+ export declare const addParameter: (parameterInfo: ParameterInfo, template: CloudFormationTemplate) => CloudFormationTemplate;
13
+ /**
14
+ * Add multiple stack parameters with info and groups.
15
+ * */
16
+ export declare const addParameters: (parameters: ParameterInfo[], template: CloudFormationTemplate) => CloudFormationTemplate;
17
+ /**
18
+ * A function used to apply a pack to a stack template.
19
+ * */
20
+ export type ResourcePackApplier<ParamsType> = (params: ParamsType, template: CloudFormationTemplate) => CloudFormationTemplate;
21
+ /**
22
+ * Apply a patch to a stack template.
23
+ * */
24
+ export declare const patchTemplate: (patch: Partial<CloudFormationTemplate>, template: CloudFormationTemplate) => CloudFormationTemplate;
25
+ /**
26
+ * Create a custom resource pack that can use configuration input to patch a stack with convenient resources, parameters, etc.
27
+ * */
28
+ export declare const createResourcePack: <ParamsType>(creator: (params: ParamsType) => Partial<CloudFormationTemplate>) => ResourcePackApplier<ParamsType>;
29
+ export type ParameterGroup = {
30
+ Label: string;
31
+ Parameters: {
32
+ [parameterId: string]: {
33
+ Label: string;
34
+ } & CloudFormationParameter;
35
+ };
36
+ };
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.createResourcePack = exports.patchTemplate = exports.addParameters = exports.addParameter = void 0;
18
+ const patch_utils_1 = require("./patch-utils");
19
+ __exportStar(require("./patch-utils"), exports);
20
+ /**
21
+ * Add a stack parameter including its descriptive info and an optional parameter group.
22
+ * */
23
+ const addParameter = (parameterInfo, template) => {
24
+ const { ParameterId, Parameter, Label, Group } = parameterInfo;
25
+ const { Parameters, Metadata: { "AWS::CloudFormation::Interface": { ParameterGroups = [], ParameterLabels = {}, } = {}, } = {}, } = template;
26
+ let NewParameterGroups = ParameterGroups;
27
+ if (Group) {
28
+ const GroupObject = ParameterGroups.filter((g) => g.Label?.default === Group)[0];
29
+ NewParameterGroups = GroupObject
30
+ ? ParameterGroups.map((g) => g.Label?.default === Group
31
+ ? {
32
+ ...g,
33
+ Parameters: [...(g.Parameters || []), ParameterId],
34
+ }
35
+ : g)
36
+ : [
37
+ ...ParameterGroups,
38
+ {
39
+ Label: {
40
+ default: Group,
41
+ },
42
+ Parameters: [ParameterId],
43
+ },
44
+ ];
45
+ }
46
+ return {
47
+ ...template,
48
+ Parameters: {
49
+ ...Parameters,
50
+ [ParameterId]: Parameter,
51
+ },
52
+ Metadata: {
53
+ ...template.Metadata,
54
+ "AWS::CloudFormation::Interface": {
55
+ ...template?.Metadata?.["AWS::CloudFormation::Interface"],
56
+ ParameterGroups: NewParameterGroups,
57
+ ParameterLabels: {
58
+ ...ParameterLabels,
59
+ [ParameterId]: {
60
+ default: Label,
61
+ },
62
+ },
63
+ },
64
+ },
65
+ };
66
+ };
67
+ exports.addParameter = addParameter;
68
+ /**
69
+ * Add multiple stack parameters with info and groups.
70
+ * */
71
+ const addParameters = (parameters, template) => parameters.reduce((acc, p) => (0, exports.addParameter)(p, acc), template);
72
+ exports.addParameters = addParameters;
73
+ /**
74
+ * Apply a patch to a stack template.
75
+ * */
76
+ const patchTemplate = (patch, template) => (0, patch_utils_1.mergeValues)([], template, patch, {
77
+ [(0, patch_utils_1.getValuePathString)([
78
+ // Parameter Groups
79
+ "Metadata",
80
+ "AWS::CloudFormation::Interface",
81
+ "ParameterGroups",
82
+ ])]: {
83
+ strategy: "accumulate-unique-by",
84
+ data: (pG) => pG?.Label?.default,
85
+ },
86
+ [(0, patch_utils_1.getValuePathString)([
87
+ // Parameter Group Parameter Ids
88
+ "Metadata",
89
+ "AWS::CloudFormation::Interface",
90
+ "ParameterGroups",
91
+ "#",
92
+ "Parameters",
93
+ ])]: {
94
+ strategy: "accumulate-unique",
95
+ },
96
+ });
97
+ exports.patchTemplate = patchTemplate;
98
+ /**
99
+ * Create a custom resource pack that can use configuration input to patch a stack with convenient resources, parameters, etc.
100
+ * */
101
+ const createResourcePack = (creator) => (params, template) => {
102
+ const patch = creator(params);
103
+ return (0, exports.patchTemplate)(patch, template);
104
+ };
105
+ exports.createResourcePack = createResourcePack;
@@ -0,0 +1,15 @@
1
+ export type MergeStrategy = 'transpose' | 'accumulate' | 'accumulate-unique' | 'accumulate-unique-by' | 'replace';
2
+ export type MergeStrategyDescriptor = {
3
+ strategy: MergeStrategy;
4
+ } | {
5
+ strategy: 'accumulate-unique-by';
6
+ data: string | ((value: any) => string);
7
+ };
8
+ export type ValuePathString = string;
9
+ export type ValuePathArray = (string | number)[];
10
+ export type MergeStrategyMap = Record<ValuePathString, MergeStrategyDescriptor>;
11
+ export declare const DEFAULT_MERGE_STRATEGY: MergeStrategy;
12
+ export declare const getValuePathString: (valuePathArray?: ValuePathArray) => string;
13
+ export declare const getValuePathArray: (valuePathString?: ValuePathString) => string[];
14
+ export declare const isConstructedFrom: (value: any, constructorReference: Function) => boolean;
15
+ export declare const mergeValues: (valuePathArray: ValuePathArray | undefined, existingValue: any, newValue: any, mergeStrategyMap?: MergeStrategyMap) => any;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeValues = exports.isConstructedFrom = exports.getValuePathArray = exports.getValuePathString = exports.DEFAULT_MERGE_STRATEGY = void 0;
4
+ exports.DEFAULT_MERGE_STRATEGY = 'transpose';
5
+ const getValuePathString = (valuePathArray = []) => valuePathArray.map((p) => encodeURIComponent(p)).join('/');
6
+ exports.getValuePathString = getValuePathString;
7
+ const getValuePathArray = (valuePathString = '') => valuePathString.split('/').map((p) => decodeURIComponent(p));
8
+ exports.getValuePathArray = getValuePathArray;
9
+ const isConstructedFrom = (value, constructorReference) => value !== null && typeof value === 'object' && 'constructor' in value && value.constructor === constructorReference;
10
+ exports.isConstructedFrom = isConstructedFrom;
11
+ const mergeValues = (valuePathArray = [], existingValue, newValue, mergeStrategyMap = {}) => {
12
+ const valuePathString = (0, exports.getValuePathString)(valuePathArray);
13
+ const arrayIndexWildcardValuePathString = (0, exports.getValuePathString)(valuePathArray.map((p) => (typeof p === 'number' ? '#' : p)));
14
+ const { [valuePathString]: { strategy: specificKeyMergeStrategy = exports.DEFAULT_MERGE_STRATEGY, data: specificKeyMergeStrategyData = undefined } = {}, [arrayIndexWildcardValuePathString]: { strategy: arrayIndexWildcardMergeStrategy = exports.DEFAULT_MERGE_STRATEGY, data: arrayIndexWildcardMergeStrategyData = undefined, } = {}, } = mergeStrategyMap;
15
+ const mergeStrategy = valuePathString in mergeStrategyMap ? specificKeyMergeStrategy : arrayIndexWildcardMergeStrategy;
16
+ const mergeStrategyData = valuePathString in mergeStrategyMap ? specificKeyMergeStrategyData : arrayIndexWildcardMergeStrategyData;
17
+ let mergedValue = typeof newValue !== 'undefined' ? newValue : existingValue;
18
+ if (mergeStrategy !== 'replace') {
19
+ if ((0, exports.isConstructedFrom)(existingValue, Array) && (0, exports.isConstructedFrom)(newValue, Array)) {
20
+ if (mergeStrategy === 'accumulate') {
21
+ mergedValue = [...existingValue, ...newValue];
22
+ }
23
+ else if (mergeStrategy === 'accumulate-unique') {
24
+ mergedValue = [...existingValue, ...newValue.filter((item) => existingValue.indexOf(item) === -1)];
25
+ }
26
+ else if (mergeStrategy === 'accumulate-unique-by') {
27
+ const existingItemMap = {};
28
+ const newItemMap = {};
29
+ for (let i = 0; i < existingValue.length; i++) {
30
+ const existingItem = existingValue[i];
31
+ if (existingItem && typeof existingItem === 'object') {
32
+ const identifier = mergeStrategyData instanceof Function ? mergeStrategyData(existingItem) : existingItem[mergeStrategyData];
33
+ existingItemMap[identifier] = existingItem;
34
+ }
35
+ }
36
+ for (let j = 0; j < newValue.length; j++) {
37
+ const newItem = newValue[j];
38
+ if (newItem && typeof newItem === 'object') {
39
+ const identifier = mergeStrategyData instanceof Function ? mergeStrategyData(newItem) : newItem[mergeStrategyData];
40
+ newItemMap[identifier] = newItem;
41
+ }
42
+ }
43
+ mergedValue = Object.keys({
44
+ ...existingItemMap,
45
+ ...newItemMap,
46
+ }).map((id, index) => (0, exports.mergeValues)([...valuePathArray, index], existingItemMap[id], newItemMap[id], mergeStrategyMap));
47
+ }
48
+ else if (mergeStrategy === 'transpose') {
49
+ const fullLength = Math.max(existingValue.length, newValue.length);
50
+ mergedValue = [...new Array(fullLength)].map((_empty, index) => (0, exports.mergeValues)([...valuePathArray, index], existingValue[index], newValue[index], mergeStrategyMap));
51
+ }
52
+ }
53
+ else if ((0, exports.isConstructedFrom)(existingValue, Object) && (0, exports.isConstructedFrom)(newValue, Object)) {
54
+ mergedValue = Object.keys({ ...existingValue, ...newValue }).reduce((acc, k) => ({
55
+ ...acc,
56
+ [k]: (0, exports.mergeValues)([...valuePathArray, k], existingValue[k], newValue[k], mergeStrategyMap),
57
+ }), {});
58
+ }
59
+ }
60
+ return mergedValue;
61
+ };
62
+ exports.mergeValues = mergeValues;