@resistdesign/voltra 0.0.0-alpha.0 → 1.2.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 (287) hide show
  1. package/.releaserc +3 -0
  2. package/README.md +4 -51
  3. package/api/ORM/CriteriaUtils/CriteriaUtils.d.ts +7 -0
  4. package/api/ORM/CriteriaUtils/CriteriaUtils.js +140 -0
  5. package/api/ORM/CriteriaUtils/CriterionDriverResolutionTools.d.ts +4 -0
  6. package/api/ORM/CriteriaUtils/CriterionDriverResolutionTools.js +23 -0
  7. package/api/ORM/CriteriaUtils/index.d.ts +2 -0
  8. package/api/ORM/CriteriaUtils/index.js +18 -0
  9. package/api/ORM/DataContextService.d.ts +68 -0
  10. package/api/ORM/DataContextService.js +352 -0
  11. package/api/ORM/SearchCriteriaTypes.d.ts +83 -0
  12. package/api/ORM/SearchCriteriaTypes.js +47 -0
  13. package/api/ORM/ServiceTypes/DBServiceTypes.d.ts +30 -0
  14. package/api/ORM/ServiceTypes/FileServiceTypes.d.ts +25 -0
  15. package/api/ORM/ServiceTypes/index.d.ts +2 -0
  16. package/api/ORM/ServiceTypes/index.js +18 -0
  17. package/api/ORM/TypeStructureUtils.d.ts +17 -0
  18. package/api/ORM/TypeStructureUtils.js +120 -0
  19. package/api/ORM/drivers/db/DynamoDBServiceItem.d.ts +19 -0
  20. package/api/ORM/drivers/db/DynamoDBServiceItem.js +206 -0
  21. package/api/ORM/drivers/db/S3DBServiceItem.d.ts +17 -0
  22. package/api/ORM/drivers/db/S3DBServiceItem.js +118 -0
  23. package/api/ORM/drivers/db/index.d.ts +2 -0
  24. package/{src/api/ORM/drivers/common → api/ORM/drivers/db}/index.js +2 -2
  25. package/api/ORM/drivers/file/S3.d.ts +15 -0
  26. package/api/ORM/drivers/file/S3.js +97 -0
  27. package/api/ORM/drivers/file/index.d.ts +1 -0
  28. package/{src/common/TypeInfoORM → api/ORM/drivers/file}/index.js +1 -1
  29. package/api/ORM/drivers/index.d.ts +2 -0
  30. package/{src/common/ItemRelationships → api/ORM/drivers}/index.js +2 -1
  31. package/api/ORM/index.d.ts +6 -0
  32. package/api/ORM/index.js +32 -0
  33. package/{src/api → api}/Router/AWS.js +2 -8
  34. package/{src/api → api}/Router/CORS.d.ts +1 -1
  35. package/{src/api → api}/Router/CORS.js +10 -10
  36. package/{src/api → api}/Router/Types.d.ts +1 -1
  37. package/{src/api → api}/Router/index.js +18 -22
  38. package/api/index.d.ts +2 -0
  39. package/{src/api → api}/index.js +8 -19
  40. package/app/components/BaseForm.d.ts +9 -0
  41. package/app/components/BaseForm.js +37 -0
  42. package/app/components/FormGen/Application.d.ts +10 -0
  43. package/app/components/FormGen/Application.js +58 -0
  44. package/app/components/FormGen/Display.d.ts +13 -0
  45. package/app/components/FormGen/Display.js +69 -0
  46. package/app/components/FormGen/Editor.d.ts +12 -0
  47. package/app/components/FormGen/Editor.js +46 -0
  48. package/app/components/FormGen/Form.d.ts +5 -0
  49. package/app/components/FormGen/Form.js +25 -0
  50. package/app/components/FormGen/HelperTypes.d.ts +41 -0
  51. package/app/components/FormGen/HelperTypes.js +27 -0
  52. package/app/components/FormGen/IdUtils.d.ts +3 -0
  53. package/app/components/FormGen/IdUtils.js +22 -0
  54. package/app/components/FormGen/Input.d.ts +13 -0
  55. package/app/components/FormGen/Input.js +82 -0
  56. package/app/components/FormGen/Layout.d.ts +20 -0
  57. package/app/components/FormGen/Layout.js +107 -0
  58. package/app/components/FormGen/List.d.ts +12 -0
  59. package/app/components/FormGen/List.js +134 -0
  60. package/app/components/FormGen/Navigation.d.ts +27 -0
  61. package/app/components/FormGen/Navigation.js +82 -0
  62. package/app/components/FormGen/Storage/LocalJSON.d.ts +8 -0
  63. package/app/components/FormGen/Storage/LocalJSON.js +35 -0
  64. package/app/components/FormGen/Storage/index.d.ts +1 -0
  65. package/{src/common/Logging → app/components/FormGen/Storage}/index.js +1 -1
  66. package/app/components/FormGen/TypeStructureComponent.d.ts +20 -0
  67. package/app/components/FormGen/TypeStructureComponent.js +223 -0
  68. package/app/components/FormGen/ValueProcessing/HashMatrix.d.ts +50 -0
  69. package/app/components/FormGen/ValueProcessing/HashMatrix.js +268 -0
  70. package/app/components/FormGen/ValueProcessing/index.d.ts +1 -0
  71. package/{src/common/IdGeneration → app/components/FormGen/ValueProcessing}/index.js +1 -1
  72. package/app/components/FormGen/index.d.ts +13 -0
  73. package/app/components/FormGen/index.js +42 -0
  74. package/app/components/MaterialSymbol.d.ts +8 -0
  75. package/app/components/MaterialSymbol.js +22 -0
  76. package/app/components/Tabs.d.ts +9 -0
  77. package/app/components/Tabs.js +26 -0
  78. package/app/components/index.d.ts +4 -0
  79. package/{src/api/ORM → app/components}/index.js +12 -22
  80. package/app/index.d.ts +2 -0
  81. package/{src/app → app}/index.js +9 -18
  82. package/{src/app → app}/utils/ApplicationState.d.ts +1 -1
  83. package/{src/app → app}/utils/ApplicationState.js +3 -9
  84. package/{src/app → app}/utils/ApplicationStateLoader.js +13 -4
  85. package/{src/app → app}/utils/Controller.js +1 -4
  86. package/{src/app → app}/utils/Debug.d.ts +0 -3
  87. package/{src/app → app}/utils/Debug.js +1 -4
  88. package/{src/app → app}/utils/EasyLayout.d.ts +1 -1
  89. package/{src/app → app}/utils/EasyLayout.js +2 -5
  90. package/{src/app → app}/utils/Route.d.ts +1 -1
  91. package/{src/app → app}/utils/Route.js +4 -8
  92. package/{src/app → app}/utils/Service.js +14 -5
  93. package/{src/app → app}/utils/index.d.ts +0 -1
  94. package/{src/app → app}/utils/index.js +0 -1
  95. package/common/Routing.d.ts +20 -0
  96. package/{src/common → common}/Routing.js +10 -32
  97. package/common/TypeParsing/TypeParsing.d.ts +5 -0
  98. package/common/TypeParsing/TypeParsing.js +283 -0
  99. package/common/TypeParsing/TypeUtils.d.ts +86 -0
  100. package/common/TypeParsing/TypeUtils.js +281 -0
  101. package/common/TypeParsing/index.d.ts +2 -0
  102. package/{src/common/Testing → common/TypeParsing}/index.js +2 -2
  103. package/common/index.d.ts +2 -0
  104. package/common/index.js +28 -0
  105. package/{src/iac → iac}/SimpleCFT.d.ts +1 -21
  106. package/iac/SimpleCFT.js +67 -0
  107. package/{src/iac → iac}/index.js +7 -17
  108. package/iac/packs/abstract/user-management/UserPoolAliasTargetCustomResourceCode.d.ts +2 -0
  109. package/iac/packs/abstract/user-management/UserPoolAliasTargetCustomResourceCode.js +86 -0
  110. package/{src/iac/packs/auth → iac/packs/abstract}/user-management.js +88 -16
  111. package/{src/iac → iac}/packs/auth.js +1 -1
  112. package/{src/iac → iac}/packs/build/utils.d.ts +1 -1
  113. package/{src/iac → iac}/packs/build.d.ts +2 -7
  114. package/{src/iac → iac}/packs/cloud-function.d.ts +1 -2
  115. package/{src/iac → iac}/packs/cloud-function.js +1 -1
  116. package/iac/packs/database.d.ts +10 -0
  117. package/{src/iac → iac}/packs/database.js +1 -2
  118. package/iac/packs/dns.d.ts +11 -0
  119. package/iac/packs/dns.js +60 -0
  120. package/{src/iac → iac}/packs/gateway.d.ts +1 -2
  121. package/{src/iac → iac}/packs/gateway.js +8 -20
  122. package/{src/iac → iac}/types/CloudFormationResourceSpecification.d.ts +1 -1
  123. package/iac/types/CloudFormationResourceSpecification.js +196438 -0
  124. package/{src/iac → iac}/types/Renderers.js +1 -1
  125. package/{src/iac → iac}/types/Utils.js +2 -7
  126. package/{src/iac → iac}/types/generate.js +15 -5
  127. package/{src/iac → iac}/utils/index.d.ts +1 -4
  128. package/{src/iac → iac}/utils/index.js +10 -27
  129. package/{src/iac → iac}/utils/patch-utils.js +2 -8
  130. package/{src/index.d.ts → index.d.ts} +5 -5
  131. package/{src/index.js → index.js} +12 -22
  132. package/package.json +11 -69
  133. package/src/api/DataAccessControl.d.ts +0 -85
  134. package/src/api/DataAccessControl.js +0 -159
  135. package/src/api/ORM/DACUtils.d.ts +0 -60
  136. package/src/api/ORM/DACUtils.js +0 -197
  137. package/src/api/ORM/ListItemUtils.d.ts +0 -7
  138. package/src/api/ORM/ListItemUtils.js +0 -22
  139. package/src/api/ORM/ORMRouteMap.d.ts +0 -19
  140. package/src/api/ORM/ORMRouteMap.js +0 -82
  141. package/src/api/ORM/TypeInfoORMService.d.ts +0 -103
  142. package/src/api/ORM/TypeInfoORMService.js +0 -581
  143. package/src/api/ORM/drivers/DynamoDBDataItemDBDriver/ConfigTypes.d.ts +0 -63
  144. package/src/api/ORM/drivers/DynamoDBDataItemDBDriver.d.ts +0 -36
  145. package/src/api/ORM/drivers/DynamoDBDataItemDBDriver.js +0 -282
  146. package/src/api/ORM/drivers/S3FileItemDBDriver/ConfigTypes.d.ts +0 -90
  147. package/src/api/ORM/drivers/S3FileItemDBDriver/S3FileDriver.d.ts +0 -45
  148. package/src/api/ORM/drivers/S3FileItemDBDriver/S3FileDriver.js +0 -127
  149. package/src/api/ORM/drivers/S3FileItemDBDriver.d.ts +0 -44
  150. package/src/api/ORM/drivers/S3FileItemDBDriver.js +0 -182
  151. package/src/api/ORM/drivers/common/SupportedTypeInfoORMDBDrivers.d.ts +0 -12
  152. package/src/api/ORM/drivers/common/SupportedTypeInfoORMDBDrivers.js +0 -20
  153. package/src/api/ORM/drivers/common/Types.d.ts +0 -77
  154. package/src/api/ORM/drivers/common/Types.js +0 -14
  155. package/src/api/ORM/drivers/common/index.d.ts +0 -2
  156. package/src/api/ORM/drivers/index.d.ts +0 -3
  157. package/src/api/ORM/drivers/index.js +0 -19
  158. package/src/api/ORM/index.d.ts +0 -4
  159. package/src/api/index.d.ts +0 -3
  160. package/src/app/index.d.ts +0 -1
  161. package/src/app/utils/TypeInfoORMAPIUtils.d.ts +0 -20
  162. package/src/app/utils/TypeInfoORMAPIUtils.js +0 -62
  163. package/src/app/utils/TypeInfoORMClient.d.ts +0 -24
  164. package/src/app/utils/TypeInfoORMClient.js +0 -69
  165. package/src/common/CommandLine/collectRequiredEnvironmentVariables.d.ts +0 -1
  166. package/src/common/CommandLine/collectRequiredEnvironmentVariables.js +0 -16
  167. package/src/common/HelperTypes.d.ts +0 -3
  168. package/src/common/HelperTypes.js +0 -2
  169. package/src/common/IdGeneration/getSimpleId.d.ts +0 -4
  170. package/src/common/IdGeneration/getSimpleId.js +0 -16
  171. package/src/common/IdGeneration/index.d.ts +0 -1
  172. package/src/common/ItemRelationshipInfoTypes.d.ts +0 -46
  173. package/src/common/ItemRelationshipInfoTypes.js +0 -20
  174. package/src/common/ItemRelationships/ItemRelationshipValidation.d.ts +0 -10
  175. package/src/common/ItemRelationships/ItemRelationshipValidation.js +0 -43
  176. package/src/common/ItemRelationships/index.d.ts +0 -1
  177. package/src/common/Logging/Utils.d.ts +0 -10
  178. package/src/common/Logging/Utils.js +0 -33
  179. package/src/common/Logging/index.d.ts +0 -1
  180. package/src/common/Routing.d.ts +0 -25
  181. package/src/common/SearchTypes.d.ts +0 -98
  182. package/src/common/SearchTypes.js +0 -39
  183. package/src/common/SearchUtils.d.ts +0 -22
  184. package/src/common/SearchUtils.js +0 -134
  185. package/src/common/SearchValidation.d.ts +0 -17
  186. package/src/common/SearchValidation.js +0 -90
  187. package/src/common/Storyboarding/Types.d.ts +0 -25
  188. package/src/common/StringTransformers.d.ts +0 -17
  189. package/src/common/StringTransformers.js +0 -36
  190. package/src/common/Testing/CLI.d.ts +0 -2
  191. package/src/common/Testing/CLI.js +0 -56
  192. package/src/common/Testing/Types.d.ts +0 -117
  193. package/src/common/Testing/Types.js +0 -19
  194. package/src/common/Testing/Utils.d.ts +0 -48
  195. package/src/common/Testing/Utils.js +0 -334
  196. package/src/common/Testing/index.d.ts +0 -2
  197. package/src/common/TypeInfoDataItemUtils.d.ts +0 -10
  198. package/src/common/TypeInfoDataItemUtils.js +0 -55
  199. package/src/common/TypeInfoORM/Types.d.ts +0 -76
  200. package/src/common/TypeInfoORM/Types.js +0 -55
  201. package/src/common/TypeInfoORM/index.d.ts +0 -1
  202. package/src/common/TypeParsing/Constants.d.ts +0 -1
  203. package/src/common/TypeParsing/Constants.js +0 -4
  204. package/src/common/TypeParsing/ParsingUtils/Constants.d.ts +0 -5
  205. package/src/common/TypeParsing/ParsingUtils/Constants.js +0 -8
  206. package/src/common/TypeParsing/ParsingUtils/checkType.d.ts +0 -8
  207. package/src/common/TypeParsing/ParsingUtils/checkType.js +0 -46
  208. package/src/common/TypeParsing/ParsingUtils/checkUnionType.d.ts +0 -6
  209. package/src/common/TypeParsing/ParsingUtils/checkUnionType.js +0 -15
  210. package/src/common/TypeParsing/ParsingUtils/extractCommentTags.d.ts +0 -2
  211. package/src/common/TypeParsing/ParsingUtils/extractCommentTags.js +0 -105
  212. package/src/common/TypeParsing/ParsingUtils/extractLiteralValues.d.ts +0 -6
  213. package/src/common/TypeParsing/ParsingUtils/extractLiteralValues.js +0 -42
  214. package/src/common/TypeParsing/ParsingUtils/extractTypeDetails.d.ts +0 -8
  215. package/src/common/TypeParsing/ParsingUtils/extractTypeDetails.js +0 -14
  216. package/src/common/TypeParsing/ParsingUtils/getPrimaryFieldForTypeInfo.d.ts +0 -5
  217. package/src/common/TypeParsing/ParsingUtils/getPrimaryFieldForTypeInfo.js +0 -27
  218. package/src/common/TypeParsing/ParsingUtils/getTypeInfo.d.ts +0 -3
  219. package/src/common/TypeParsing/ParsingUtils/getTypeInfo.js +0 -27
  220. package/src/common/TypeParsing/ParsingUtils/getTypeInfoField.d.ts +0 -3
  221. package/src/common/TypeParsing/ParsingUtils/getTypeInfoField.js +0 -44
  222. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromAliasType.d.ts +0 -4
  223. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromAliasType.js +0 -28
  224. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromFieldFilter.d.ts +0 -4
  225. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromFieldFilter.js +0 -105
  226. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromTypeAlias.d.ts +0 -4
  227. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromTypeAlias.js +0 -20
  228. package/src/common/TypeParsing/ParsingUtils/getTypeKeyword.d.ts +0 -3
  229. package/src/common/TypeParsing/ParsingUtils/getTypeKeyword.js +0 -17
  230. package/src/common/TypeParsing/ParsingUtils/getUnionOrIntersectionTypeInfo.d.ts +0 -4
  231. package/src/common/TypeParsing/ParsingUtils/getUnionOrIntersectionTypeInfo.js +0 -49
  232. package/src/common/TypeParsing/ParsingUtils/getUnionOrLiteralStringValues.d.ts +0 -2
  233. package/src/common/TypeParsing/ParsingUtils/getUnionOrLiteralStringValues.js +0 -24
  234. package/src/common/TypeParsing/TypeInfo.d.ts +0 -142
  235. package/src/common/TypeParsing/TypeInfo.js +0 -13
  236. package/src/common/TypeParsing/TypeMapping.d.ts +0 -9
  237. package/src/common/TypeParsing/TypeMapping.js +0 -32
  238. package/src/common/TypeParsing/TypeParsing.d.ts +0 -5
  239. package/src/common/TypeParsing/TypeParsing.js +0 -39
  240. package/src/common/TypeParsing/Utils.d.ts +0 -21
  241. package/src/common/TypeParsing/Utils.js +0 -94
  242. package/src/common/TypeParsing/Validation.d.ts +0 -92
  243. package/src/common/TypeParsing/Validation.js +0 -340
  244. package/src/common/TypeParsing/index.d.ts +0 -5
  245. package/src/common/TypeParsing/index.js +0 -44
  246. package/src/common/index.d.ts +0 -11
  247. package/src/common/index.js +0 -47
  248. package/src/iac/SimpleCFT.js +0 -82
  249. package/src/iac/packs/database.d.ts +0 -29
  250. package/src/iac/packs/dns.d.ts +0 -13
  251. package/src/iac/packs/dns.js +0 -26
  252. package/src/iac/types/IaCTypes.d.ts +0 -234994
  253. package/src/iac/types/IaCTypes.js +0 -14
  254. package/src/iac/types/Types.js +0 -2
  255. /package/{src/api/ORM/drivers/DynamoDBDataItemDBDriver/ConfigTypes.js → api/ORM/ServiceTypes/DBServiceTypes.js} +0 -0
  256. /package/{src/api/ORM/drivers/S3FileItemDBDriver/ConfigTypes.js → api/ORM/ServiceTypes/FileServiceTypes.js} +0 -0
  257. /package/{src/api → api}/Router/AWS.d.ts +0 -0
  258. /package/{src/api → api}/Router/Auth.d.ts +0 -0
  259. /package/{src/api → api}/Router/Auth.js +0 -0
  260. /package/{src/api → api}/Router/Types.js +0 -0
  261. /package/{src/api → api}/Router/index.d.ts +0 -0
  262. /package/{src/app → app}/utils/ApplicationStateLoader.d.ts +0 -0
  263. /package/{src/app → app}/utils/Controller.d.ts +0 -0
  264. /package/{src/app → app}/utils/Service.d.ts +0 -0
  265. /package/{src/iac → iac}/index.d.ts +0 -0
  266. /package/{src/iac/packs/auth → iac/packs/abstract}/user-management.d.ts +0 -0
  267. /package/{src/iac → iac}/packs/auth.d.ts +0 -0
  268. /package/{src/iac → iac}/packs/build/utils.js +0 -0
  269. /package/{src/iac → iac}/packs/build.js +0 -0
  270. /package/{src/iac → iac}/packs/cdn.d.ts +0 -0
  271. /package/{src/iac → iac}/packs/cdn.js +0 -0
  272. /package/{src/iac → iac}/packs/file-storage.d.ts +0 -0
  273. /package/{src/iac → iac}/packs/file-storage.js +0 -0
  274. /package/{src/iac → iac}/packs/index.d.ts +0 -0
  275. /package/{src/iac → iac}/packs/index.js +0 -0
  276. /package/{src/iac → iac}/packs/repo.d.ts +0 -0
  277. /package/{src/iac → iac}/packs/repo.js +0 -0
  278. /package/{src/iac → iac}/packs/ssl-certificate.d.ts +0 -0
  279. /package/{src/iac → iac}/packs/ssl-certificate.js +0 -0
  280. /package/{src/iac → iac}/types/Constants.d.ts +0 -0
  281. /package/{src/iac → iac}/types/Constants.js +0 -0
  282. /package/{src/iac → iac}/types/Renderers.d.ts +0 -0
  283. /package/{src/iac → iac}/types/Types.d.ts +0 -0
  284. /package/{src/common/Storyboarding → iac/types}/Types.js +0 -0
  285. /package/{src/iac → iac}/types/Utils.d.ts +0 -0
  286. /package/{src/iac → iac}/types/generate.d.ts +0 -0
  287. /package/{src/iac → iac}/utils/patch-utils.d.ts +0 -0
@@ -87,7 +87,7 @@ const renderTypeFromResourceType = (path, typeName, resourceType) => {
87
87
  };
88
88
  exports.renderTypeFromResourceType = renderTypeFromResourceType;
89
89
  const renderNamespaceStructure = ({ path = [], includes = [], propertyTypes = {}, resourceTypes = {}, namespaces = {} }, namespaceName) => {
90
- const namespaceBody = `${includes?.join('\n')}
90
+ const namespaceBody = `${includes === null || includes === void 0 ? void 0 : includes.join('\n')}
91
91
 
92
92
  ${Object.keys(propertyTypes)
93
93
  .map((pT) => (0, exports.renderTypeFromPropertyType)(path, pT, propertyTypes[pT]))
@@ -3,9 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNamespaceStructure = void 0;
4
4
  const Constants_1 = require("./Constants");
5
5
  const getNamespaceStructure = (specification, baseStructure) => {
6
- const newStructure = {
7
- ...baseStructure,
8
- };
6
+ const newStructure = Object.assign({}, baseStructure);
9
7
  const { PropertyTypes, ResourceTypes } = specification;
10
8
  const propertyTypesKeys = Object.keys(PropertyTypes);
11
9
  const resourceTypesKeys = Object.keys(ResourceTypes);
@@ -41,10 +39,7 @@ const getNamespaceStructure = (specification, baseStructure) => {
41
39
  currentPath.push(part);
42
40
  if (i === fullResourceTypeNameParts.length - 1) {
43
41
  targetNamespace.resourceTypes = targetNamespace.resourceTypes || {};
44
- targetNamespace.resourceTypes[part] = {
45
- ...resType,
46
- Type: rTK,
47
- };
42
+ targetNamespace.resourceTypes[part] = Object.assign(Object.assign({}, resType), { Type: rTK });
48
43
  resourceTypeOptions.push(currentPath.join(Constants_1.NAMESPACE_DELIMITERS.OUTPUT));
49
44
  }
50
45
  else {
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
13
  };
@@ -9,7 +18,7 @@ const prettier_1 = require("prettier");
9
18
  const CloudFormationResourceSpecification_1 = require("./CloudFormationResourceSpecification");
10
19
  const Utils_1 = require("./Utils");
11
20
  const Renderers_1 = require("./Renderers");
12
- const STANDARD_INCLUDES = fs_1.default.readFileSync(path_1.default.join(__dirname, "StandardIncludes.d.ts.tmpl"), { encoding: "utf8" })
21
+ const STANDARD_INCLUDES = fs_1.default.readFileSync(path_1.default.join(__dirname, "StandardIncludes.d.ts"), { encoding: "utf8" })
13
22
  // IMPORTANT: Remove the first line which is a placeholder for the `AllResourceTypes` type.
14
23
  .replace(/.*/, "")
15
24
  .trimStart();
@@ -21,11 +30,12 @@ const BASE_NAMESPACE_STRUCTURE = {
21
30
  namespaces: {},
22
31
  };
23
32
  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), {
33
+ const generate = () => __awaiter(void 0, void 0, void 0, function* () {
34
+ const TypesContentString = yield (0, prettier_1.format)((0, Renderers_1.renderNamespaceStructure)(NamespaceStructure), {
26
35
  parser: "typescript",
27
36
  });
37
+ // TODO: Types should be broken up into separate files.
28
38
  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
- };
39
+ fs_1.default.writeFileSync(path_1.default.join(__dirname, "..", "dist", "index.d.ts"), TypesContentString, { encoding: "utf8" });
40
+ });
31
41
  generate();
@@ -1,4 +1,4 @@
1
- import { CloudFormationParameter, CloudFormationTemplate } from "../types/IaCTypes";
1
+ import { CloudFormationParameter, CloudFormationTemplate } from "../types/StandardIncludes";
2
2
  export * from "./patch-utils";
3
3
  export type ParameterInfo = {
4
4
  ParameterId: string;
@@ -14,9 +14,6 @@ export declare const addParameter: (parameterInfo: ParameterInfo, template: Clou
14
14
  * Add multiple stack parameters with info and groups.
15
15
  * */
16
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
17
  export type ResourcePackApplier<ParamsType> = (params: ParamsType, template: CloudFormationTemplate) => CloudFormationTemplate;
21
18
  /**
22
19
  * Apply a patch to a stack template.
@@ -21,18 +21,18 @@ __exportStar(require("./patch-utils"), exports);
21
21
  * Add a stack parameter including its descriptive info and an optional parameter group.
22
22
  * */
23
23
  const addParameter = (parameterInfo, template) => {
24
+ var _a;
24
25
  const { ParameterId, Parameter, Label, Group } = parameterInfo;
25
26
  const { Parameters, Metadata: { "AWS::CloudFormation::Interface": { ParameterGroups = [], ParameterLabels = {}, } = {}, } = {}, } = template;
26
27
  let NewParameterGroups = ParameterGroups;
27
28
  if (Group) {
28
- const GroupObject = ParameterGroups.filter((g) => g.Label?.default === Group)[0];
29
+ const GroupObject = ParameterGroups.filter((g) => { var _a; return ((_a = g.Label) === null || _a === void 0 ? void 0 : _a.default) === Group; })[0];
29
30
  NewParameterGroups = GroupObject
30
- ? ParameterGroups.map((g) => g.Label?.default === Group
31
- ? {
32
- ...g,
33
- Parameters: [...(g.Parameters || []), ParameterId],
34
- }
35
- : g)
31
+ ? ParameterGroups.map((g) => {
32
+ var _a;
33
+ return ((_a = g.Label) === null || _a === void 0 ? void 0 : _a.default) === Group
34
+ ? Object.assign(Object.assign({}, g), { Parameters: [...(g.Parameters || []), ParameterId] }) : g;
35
+ })
36
36
  : [
37
37
  ...ParameterGroups,
38
38
  {
@@ -43,26 +43,9 @@ const addParameter = (parameterInfo, template) => {
43
43
  },
44
44
  ];
45
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]: {
46
+ return Object.assign(Object.assign({}, template), { Parameters: Object.assign(Object.assign({}, Parameters), { [ParameterId]: Parameter }), Metadata: Object.assign(Object.assign({}, template.Metadata), { "AWS::CloudFormation::Interface": Object.assign(Object.assign({}, (_a = template === null || template === void 0 ? void 0 : template.Metadata) === null || _a === void 0 ? void 0 : _a["AWS::CloudFormation::Interface"]), { ParameterGroups: NewParameterGroups, ParameterLabels: Object.assign(Object.assign({}, ParameterLabels), { [ParameterId]: {
60
47
  default: Label,
61
- },
62
- },
63
- },
64
- },
65
- };
48
+ } }) }) }) });
66
49
  };
67
50
  exports.addParameter = addParameter;
68
51
  /**
@@ -81,7 +64,7 @@ const patchTemplate = (patch, template) => (0, patch_utils_1.mergeValues)([], te
81
64
  "ParameterGroups",
82
65
  ])]: {
83
66
  strategy: "accumulate-unique-by",
84
- data: (pG) => pG?.Label?.default,
67
+ data: (pG) => { var _a; return (_a = pG === null || pG === void 0 ? void 0 : pG.Label) === null || _a === void 0 ? void 0 : _a.default; },
85
68
  },
86
69
  [(0, patch_utils_1.getValuePathString)([
87
70
  // Parameter Group Parameter Ids
@@ -40,10 +40,7 @@ const mergeValues = (valuePathArray = [], existingValue, newValue, mergeStrategy
40
40
  newItemMap[identifier] = newItem;
41
41
  }
42
42
  }
43
- mergedValue = Object.keys({
44
- ...existingItemMap,
45
- ...newItemMap,
46
- }).map((id, index) => (0, exports.mergeValues)([...valuePathArray, index], existingItemMap[id], newItemMap[id], mergeStrategyMap));
43
+ mergedValue = Object.keys(Object.assign(Object.assign({}, existingItemMap), newItemMap)).map((id, index) => (0, exports.mergeValues)([...valuePathArray, index], existingItemMap[id], newItemMap[id], mergeStrategyMap));
47
44
  }
48
45
  else if (mergeStrategy === 'transpose') {
49
46
  const fullLength = Math.max(existingValue.length, newValue.length);
@@ -51,10 +48,7 @@ const mergeValues = (valuePathArray = [], existingValue, newValue, mergeStrategy
51
48
  }
52
49
  }
53
50
  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
- }), {});
51
+ mergedValue = Object.keys(Object.assign(Object.assign({}, existingValue), newValue)).reduce((acc, k) => (Object.assign(Object.assign({}, acc), { [k]: (0, exports.mergeValues)([...valuePathArray, k], existingValue[k], newValue[k], mergeStrategyMap) })), {});
58
52
  }
59
53
  }
60
54
  return mergedValue;
@@ -31,7 +31,7 @@ export * as API from "./api";
31
31
  *
32
32
  * @usage `import * from "@resistdesign/voltra/app";`
33
33
  *
34
- * @see {@link getEasyLayout}, {@link TypeInfoApplication} and {@link useApplicationStateLoader} for some great starting points.
34
+ * @see {@link getEasyLayout}, {@link TypeStructureComponent} and {@link useApplicationStateLoader} for some great starting points.
35
35
  *
36
36
  * @example
37
37
  * ```tsx
@@ -159,10 +159,10 @@ export * as App from "./app";
159
159
  * .applyPack(
160
160
  * addDNS,
161
161
  * {
162
- * hostedZoneIdParameterName: "<YOUR_INFO_HERE>",
163
- * domainNameParameterName: "<YOUR_INFO_HERE>",
164
- * localUIDevelopmentDomainName: "<YOUR_INFO_HERE>",
165
- * localUIDevelopmentIPAddress: "<YOUR_INFO_HERE>",
162
+ * hostedZoneIdParameterName: "<YOUR_INFO_HERE>"
163
+ * domainNameParameterName: "<YOUR_INFO_HERE>"
164
+ * localUIDevelopmentDomainName: "<YOUR_INFO_HERE>"
165
+ * localUIDevelopmentIPAddress: "<YOUR_INFO_HERE>"
166
166
  * }
167
167
  * );
168
168
  *
@@ -15,23 +15,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
35
25
  Object.defineProperty(exports, "__esModule", { value: true });
36
26
  exports.Common = exports.IaC = exports.App = exports.API = void 0;
37
27
  /**
@@ -67,7 +57,7 @@ exports.API = __importStar(require("./api"));
67
57
  *
68
58
  * @usage `import * from "@resistdesign/voltra/app";`
69
59
  *
70
- * @see {@link getEasyLayout}, {@link TypeInfoApplication} and {@link useApplicationStateLoader} for some great starting points.
60
+ * @see {@link getEasyLayout}, {@link TypeStructureComponent} and {@link useApplicationStateLoader} for some great starting points.
71
61
  *
72
62
  * @example
73
63
  * ```tsx
@@ -195,10 +185,10 @@ exports.App = __importStar(require("./app"));
195
185
  * .applyPack(
196
186
  * addDNS,
197
187
  * {
198
- * hostedZoneIdParameterName: "<YOUR_INFO_HERE>",
199
- * domainNameParameterName: "<YOUR_INFO_HERE>",
200
- * localUIDevelopmentDomainName: "<YOUR_INFO_HERE>",
201
- * localUIDevelopmentIPAddress: "<YOUR_INFO_HERE>",
188
+ * hostedZoneIdParameterName: "<YOUR_INFO_HERE>"
189
+ * domainNameParameterName: "<YOUR_INFO_HERE>"
190
+ * localUIDevelopmentDomainName: "<YOUR_INFO_HERE>"
191
+ * localUIDevelopmentIPAddress: "<YOUR_INFO_HERE>"
202
192
  * }
203
193
  * );
204
194
  *
package/package.json CHANGED
@@ -1,103 +1,45 @@
1
1
  {
2
2
  "name": "@resistdesign/voltra",
3
- "version": "0.0.0-alpha.0",
3
+ "version": "1.2.0",
4
4
  "description": "With our powers combined!",
5
5
  "homepage": "https://voltra.app",
6
6
  "repository": "git@github.com:resistdesign/voltra.git",
7
7
  "author": "Resist Design",
8
- "license": "MIT",
9
- "bin": {
10
- "vest": "src/common/Testing/CLI.ts"
11
- },
12
- "files": [
13
- "src/**/*",
14
- "README.md",
15
- "package.json",
16
- "!src/iac/types/CloudFormationResourceSpecification.js"
17
- ],
8
+ "license": "UNLICENSED",
9
+ "main": "index.js",
10
+ "types": "index.d.ts",
18
11
  "scripts": {
19
12
  "build": "tsc && yarn prep-dist",
20
- "test": "ts-node src/common/Testing/CLI.ts ./src/**/*.spec.json",
21
- "test:gen": "ts-node src/common/Testing/CLI.ts --generate ./src/**/*.spec.json",
22
- "doc": "typedoc",
13
+ "test": "tsc --noEmit",
14
+ "doc": "typedoc && cp CNAME docs/ && cp -r ./images docs/ && cp ./favicon/assets/* docs/",
23
15
  "doc:dev": "typedoc --watch",
24
- "doc-to-site": "cp -r ./docs site-dist/app/",
25
- "prep-dist": "cp package.json dist/ && cp README.md dist/ && cp .npmignore dist/",
26
- "site:build:app": "parcel build site/app/index.html --dist-dir site-dist --target app && yarn finalize-site",
27
- "site:build:api": "parcel build site/api/index.ts --target api --dist-dir site-dist --no-source-maps --no-optimize --no-scope-hoist",
28
- "site:build:iac": "ts-node ./site/iac/index.ts",
29
- "start": "parcel site/app/index.html --host docs-local.demo.voltra.app --dist-dir site-dist/app --https",
30
- "finalize-site": "yarn doc && yarn doc-to-site && cp CNAME site-dist/app/ && cp -r ./images site-dist/app/",
31
- "iac:types:gen": "ts-node ./src/iac/types/generate.ts"
16
+ "prep-dist": "cp package.json dist/ && cp README.md dist/ && cp .releaserc dist/"
32
17
  },
33
18
  "dependencies": {
34
19
  "@aws-sdk/client-dynamodb": "^3.490.0",
35
20
  "@aws-sdk/client-s3": "^3.490.0",
36
21
  "@aws-sdk/s3-request-presigner": "^3.490.0",
37
22
  "@aws-sdk/util-dynamodb": "^3.490.0",
38
- "@picocss/pico": "^2.1.1",
39
23
  "ace-builds": "^1.32.3",
40
- "fast-glob": "^3.3.3",
41
- "picocolors": "^1.1.1",
24
+ "material-symbols": "^0.14.6",
42
25
  "react": "^18.2.0",
43
26
  "react-ace": "^10.1.0",
44
- "react-dom": "^18.3.1",
45
27
  "styled-components": "^6.1.8",
46
- "ts-node": "^10.9.2",
47
28
  "typescript": "^5.3.3",
48
- "uuid": "^11.0.3",
49
29
  "yaml": "^2.3.4"
50
30
  },
51
31
  "devDependencies": {
52
- "@parcel/packager-raw-url": "2.13.3",
53
- "@parcel/packager-ts": "2.13.3",
54
- "@parcel/transformer-inline-string": "2.13.3",
55
32
  "@parcel/transformer-typescript-types": "2.11.0",
56
- "@parcel/transformer-webmanifest": "2.13.3",
57
33
  "@types/cfn-response": "^1.0.8",
58
34
  "@types/node": "^20.11.6",
59
- "@types/react-dom": "^18.3.0",
60
35
  "@types/styled-components": "^5.1.34",
61
36
  "aws-lambda": "^1.0.7",
62
37
  "aws-sdk": "^2.1545.0",
63
- "buffer": "^5.5.0||^6.0.0",
64
38
  "cfn-response": "^1.0.1",
65
- "parcel": "^2.13.3",
66
- "prettier": "^3.6.2",
67
- "process": "^0.11.10",
68
- "svgo": "^3",
69
- "ts-morph": "^24.0.0",
39
+ "prettier": "^3.1.1",
40
+ "semantic-release": "^23.0.0",
41
+ "ts-node": "^10.9.2",
70
42
  "typedoc": "^0.25.8",
71
43
  "typedoc-material-theme": "^1.0.2"
72
- },
73
- "targets": {
74
- "app": {
75
- "context": "browser",
76
- "engines": {
77
- "browsers": [
78
- "last 2 version",
79
- "not dead",
80
- "> 0.2%"
81
- ]
82
- },
83
- "includeNodeModules": true,
84
- "outputFormat": "commonjs",
85
- "isLibrary": false,
86
- "scopeHoist": false
87
- },
88
- "api": {
89
- "context": "node",
90
- "engines": {
91
- "node": ">=20"
92
- },
93
- "outputFormat": "commonjs",
94
- "includeNodeModules": true,
95
- "isLibrary": false,
96
- "scopeHoist": false
97
- }
98
- },
99
- "@parcel/transformer-js": {
100
- "inlineFS": true,
101
- "inlineEnvironment": true
102
44
  }
103
45
  }
@@ -1,85 +0,0 @@
1
- import { LiteralValue } from "../common/TypeParsing/TypeInfo";
2
- /**
3
- * The possible types of a data access control (DAC) constraint.
4
- * */
5
- export declare enum DACConstraintType {
6
- ALLOW = "ALLOW",
7
- DENY = "DENY"
8
- }
9
- /**
10
- * A data access control (DAC) constraint.
11
- * */
12
- export type DACConstraint = {
13
- type: DACConstraintType;
14
- resourcePath: LiteralValue[];
15
- pathIsPrefix?: boolean;
16
- };
17
- /**
18
- * The primary properties for a data access control (DAC) role.
19
- * */
20
- export type BaseDACRole = {
21
- childRoleIds?: string[];
22
- constraints: DACConstraint[];
23
- };
24
- /**
25
- * A data access control (DAC) role which has been stored and can be accessed by an `id`.
26
- * */
27
- export type DACRole = {
28
- id: string;
29
- } & BaseDACRole;
30
- /**
31
- * The result of a data access control (DAC) check.
32
- * */
33
- export type DACAccessResult = {
34
- allowed: boolean;
35
- denied: boolean;
36
- };
37
- /**
38
- * The result of a data access control (DAC) check for a data item.
39
- * */
40
- export type DACDataItemResourceAccessResultMap = DACAccessResult & {
41
- fieldsResources?: Record<string, DACAccessResult>;
42
- };
43
- /**
44
- * The result of matching a DAC path to a resource path.
45
- * */
46
- export type DACPathMatchResults = {
47
- prefixMatch: boolean;
48
- exactMatch: boolean;
49
- };
50
- /**
51
- * The prototype of a DAC wildcard signifier.
52
- * */
53
- export declare const WILDCARD_SIGNIFIER_PROTOTYPE: Record<string, string>;
54
- /**
55
- * Check if a given DAC path part value is a DAC wildcard signifier.
56
- * */
57
- export declare const getValueIsWildcardSignifier: (value: any) => boolean;
58
- /**
59
- * Check if a given DAC path matches a given resource path.
60
- *
61
- * Includes checking if the DAC path is a prefix of the
62
- * resource path and if the DAC path is an exact match of
63
- * the resource path.
64
- *
65
- * The DAC path can include wildcard signifier objects at
66
- * various indices in order to facilitate dynamic matches
67
- * and grouping by common resource aspects.
68
- * */
69
- export declare const getDACPathsMatch: (dacPath: LiteralValue[], resourcePath: LiteralValue[]) => DACPathMatchResults;
70
- /**
71
- * Get the flattened constraints of a DAC role.
72
- * */
73
- export declare const getFlattenedDACConstraints: (role: DACRole, getDACRoleById: (id: string) => DACRole,
74
- /**
75
- * SECURITY: Don't use this if you want realtime role resolution.
76
- * */
77
- dacRoleCache?: Record<string, DACRole>) => DACConstraint[];
78
- /**
79
- * Get the access to a given resource for a given DAC role.
80
- * */
81
- export declare const getResourceAccessByDACRole: (fullResourcePath: LiteralValue[], role: DACRole, getDACRoleById: (id: string) => DACRole, dacRoleCache?: Record<string, DACRole>) => DACAccessResult;
82
- /**
83
- * Merge multiple DAC access results.
84
- * */
85
- export declare const mergeDACAccessResults: (...results: DACAccessResult[]) => DACAccessResult;
@@ -1,159 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeDACAccessResults = exports.getResourceAccessByDACRole = exports.getFlattenedDACConstraints = exports.getDACPathsMatch = exports.getValueIsWildcardSignifier = exports.WILDCARD_SIGNIFIER_PROTOTYPE = exports.DACConstraintType = void 0;
4
- /**
5
- * The possible types of a data access control (DAC) constraint.
6
- * */
7
- var DACConstraintType;
8
- (function (DACConstraintType) {
9
- DACConstraintType["ALLOW"] = "ALLOW";
10
- DACConstraintType["DENY"] = "DENY";
11
- })(DACConstraintType || (exports.DACConstraintType = DACConstraintType = {}));
12
- /**
13
- * The prototype of a DAC wildcard signifier.
14
- * */
15
- exports.WILDCARD_SIGNIFIER_PROTOTYPE = {
16
- WILD_CARD: "*",
17
- };
18
- /**
19
- * Check if a given DAC path part value is a DAC wildcard signifier.
20
- * */
21
- const getValueIsWildcardSignifier = (value) => {
22
- if (typeof value === "object" && value !== null) {
23
- return Object.keys(exports.WILDCARD_SIGNIFIER_PROTOTYPE).every((key) => value[key] === exports.WILDCARD_SIGNIFIER_PROTOTYPE[key]);
24
- }
25
- return false;
26
- };
27
- exports.getValueIsWildcardSignifier = getValueIsWildcardSignifier;
28
- /**
29
- * Check if a given DAC path matches a given resource path.
30
- *
31
- * Includes checking if the DAC path is a prefix of the
32
- * resource path and if the DAC path is an exact match of
33
- * the resource path.
34
- *
35
- * The DAC path can include wildcard signifier objects at
36
- * various indices in order to facilitate dynamic matches
37
- * and grouping by common resource aspects.
38
- * */
39
- const getDACPathsMatch = (dacPath, resourcePath) => {
40
- const results = {
41
- prefixMatch: false,
42
- exactMatch: false,
43
- };
44
- let allDACPartsMatch = true;
45
- for (let i = 0; i < dacPath.length; i++) {
46
- const part = dacPath[i];
47
- const resourcePart = resourcePath[i];
48
- if (!(0, exports.getValueIsWildcardSignifier)(part) && part !== resourcePart) {
49
- allDACPartsMatch = false;
50
- break;
51
- }
52
- }
53
- if (allDACPartsMatch) {
54
- results.prefixMatch = true;
55
- }
56
- if (dacPath.length !== resourcePath.length) {
57
- const lastDACPart = dacPath[dacPath.length - 1];
58
- const lastDACPartIsWildcard = (0, exports.getValueIsWildcardSignifier)(lastDACPart);
59
- results.exactMatch = results.prefixMatch && lastDACPartIsWildcard;
60
- }
61
- else if (results.prefixMatch) {
62
- results.exactMatch = true;
63
- }
64
- return results;
65
- };
66
- exports.getDACPathsMatch = getDACPathsMatch;
67
- /**
68
- * Get the flattened constraints of a DAC role.
69
- * */
70
- const getFlattenedDACConstraints = (role, getDACRoleById,
71
- /**
72
- * SECURITY: Don't use this if you want realtime role resolution.
73
- * */
74
- dacRoleCache) => {
75
- const { childRoleIds = [], constraints = [] } = role;
76
- let flattenedConstraints = [...constraints];
77
- for (const cRI of childRoleIds) {
78
- let childRole;
79
- if (dacRoleCache && dacRoleCache[cRI]) {
80
- childRole = dacRoleCache[cRI];
81
- }
82
- else {
83
- childRole = getDACRoleById(cRI);
84
- if (dacRoleCache) {
85
- dacRoleCache[cRI] = childRole;
86
- }
87
- }
88
- flattenedConstraints = [
89
- ...flattenedConstraints,
90
- ...(0, exports.getFlattenedDACConstraints)(childRole, getDACRoleById, dacRoleCache),
91
- ];
92
- }
93
- return flattenedConstraints;
94
- };
95
- exports.getFlattenedDACConstraints = getFlattenedDACConstraints;
96
- /**
97
- * Get the access to a given resource for a given DAC role.
98
- * */
99
- const getResourceAccessByDACRole = (fullResourcePath, role, getDACRoleById, dacRoleCache) => {
100
- const flattenedConstraints = (0, exports.getFlattenedDACConstraints)(role, getDACRoleById, dacRoleCache);
101
- let allowed = false, denied = false, lastAllowedPath = [], lastDeniedPath = [];
102
- for (const constraint of flattenedConstraints) {
103
- const { type, resourcePath: dacPath, pathIsPrefix } = constraint;
104
- const { prefixMatch: dacPathIsPrefixOfResourcePath, exactMatch: dacPathIsExactMatch, } = (0, exports.getDACPathsMatch)(dacPath, fullResourcePath);
105
- if (pathIsPrefix) {
106
- if (dacPathIsPrefixOfResourcePath) {
107
- if (type === DACConstraintType.ALLOW) {
108
- allowed = true;
109
- lastAllowedPath = dacPath;
110
- // IMPORTANT: Calculate specificity.
111
- if (lastAllowedPath.length > lastDeniedPath.length) {
112
- denied = false;
113
- }
114
- }
115
- else {
116
- denied = true;
117
- lastDeniedPath = dacPath;
118
- // IMPORTANT: Calculate specificity.
119
- if (lastDeniedPath.length > lastAllowedPath.length) {
120
- allowed = false;
121
- }
122
- }
123
- }
124
- }
125
- else {
126
- if (dacPathIsExactMatch) {
127
- lastAllowedPath = dacPath;
128
- lastDeniedPath = dacPath;
129
- if (type === DACConstraintType.ALLOW) {
130
- allowed = true;
131
- }
132
- else {
133
- denied = true;
134
- }
135
- }
136
- }
137
- }
138
- return { allowed, denied };
139
- };
140
- exports.getResourceAccessByDACRole = getResourceAccessByDACRole;
141
- /**
142
- * Merge multiple DAC access results.
143
- * */
144
- const mergeDACAccessResults = (...results) => {
145
- let newResult = {
146
- allowed: false,
147
- denied: false,
148
- };
149
- for (const r of results) {
150
- const { allowed: rAllowed, denied: rDenied } = r;
151
- const { allowed: nAllowed, denied: nDenied } = newResult;
152
- newResult = {
153
- allowed: rAllowed || nAllowed,
154
- denied: rDenied || nDenied,
155
- };
156
- }
157
- return newResult;
158
- };
159
- exports.mergeDACAccessResults = mergeDACAccessResults;