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

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 (225) hide show
  1. package/README.md +75 -0
  2. package/SearchTypes-DjN6YQzE.d.ts +577 -0
  3. package/Types-C7XjUjoF.d.ts +240 -0
  4. package/Validation-CFP59oIP.d.ts +226 -0
  5. package/api/index.d.ts +6 -0
  6. package/api/index.js +7968 -0
  7. package/app/index.d.ts +5 -0
  8. package/app/index.js +810 -0
  9. package/common/Testing/CLI.js +432 -0
  10. package/common/index.d.ts +4 -0
  11. package/common/index.js +1760 -0
  12. package/iac/index.d.ts +2 -0
  13. package/iac/index.js +1661 -0
  14. package/iac/packs/index.d.ts +1 -0
  15. package/iac/packs/index.js +1620 -0
  16. package/index-BkFZlfit.d.ts +112 -0
  17. package/index-C3-iD9Mh.d.ts +690 -0
  18. package/index-DZ2BB4iX.d.ts +5357 -0
  19. package/{src/iac/types/IaCTypes.d.ts → index-DcvJOZ_c.d.ts} +1018 -23
  20. package/index-IokxSNxm.d.ts +745 -0
  21. package/index.d.ts +13 -0
  22. package/index.js +10973 -0
  23. package/package.json +40 -41
  24. package/src/api/DataAccessControl.d.ts +0 -85
  25. package/src/api/DataAccessControl.js +0 -159
  26. package/src/api/ORM/DACUtils.d.ts +0 -60
  27. package/src/api/ORM/DACUtils.js +0 -197
  28. package/src/api/ORM/ListItemUtils.d.ts +0 -7
  29. package/src/api/ORM/ListItemUtils.js +0 -22
  30. package/src/api/ORM/ORMRouteMap.d.ts +0 -19
  31. package/src/api/ORM/ORMRouteMap.js +0 -82
  32. package/src/api/ORM/TypeInfoORMService.d.ts +0 -103
  33. package/src/api/ORM/TypeInfoORMService.js +0 -581
  34. package/src/api/ORM/drivers/DynamoDBDataItemDBDriver/ConfigTypes.d.ts +0 -63
  35. package/src/api/ORM/drivers/DynamoDBDataItemDBDriver/ConfigTypes.js +0 -2
  36. package/src/api/ORM/drivers/DynamoDBDataItemDBDriver.d.ts +0 -36
  37. package/src/api/ORM/drivers/DynamoDBDataItemDBDriver.js +0 -282
  38. package/src/api/ORM/drivers/S3FileItemDBDriver/ConfigTypes.d.ts +0 -90
  39. package/src/api/ORM/drivers/S3FileItemDBDriver/ConfigTypes.js +0 -2
  40. package/src/api/ORM/drivers/S3FileItemDBDriver/S3FileDriver.d.ts +0 -45
  41. package/src/api/ORM/drivers/S3FileItemDBDriver/S3FileDriver.js +0 -127
  42. package/src/api/ORM/drivers/S3FileItemDBDriver.d.ts +0 -44
  43. package/src/api/ORM/drivers/S3FileItemDBDriver.js +0 -182
  44. package/src/api/ORM/drivers/common/SupportedTypeInfoORMDBDrivers.d.ts +0 -12
  45. package/src/api/ORM/drivers/common/SupportedTypeInfoORMDBDrivers.js +0 -20
  46. package/src/api/ORM/drivers/common/Types.d.ts +0 -77
  47. package/src/api/ORM/drivers/common/Types.js +0 -14
  48. package/src/api/ORM/drivers/common/index.d.ts +0 -2
  49. package/src/api/ORM/drivers/common/index.js +0 -18
  50. package/src/api/ORM/drivers/index.d.ts +0 -3
  51. package/src/api/ORM/drivers/index.js +0 -19
  52. package/src/api/ORM/index.d.ts +0 -4
  53. package/src/api/ORM/index.js +0 -43
  54. package/src/api/Router/AWS.d.ts +0 -26
  55. package/src/api/Router/AWS.js +0 -76
  56. package/src/api/Router/Auth.d.ts +0 -2
  57. package/src/api/Router/Auth.js +0 -9
  58. package/src/api/Router/CORS.d.ts +0 -6
  59. package/src/api/Router/CORS.js +0 -27
  60. package/src/api/Router/Types.d.ts +0 -71
  61. package/src/api/Router/Types.js +0 -2
  62. package/src/api/Router/index.d.ts +0 -18
  63. package/src/api/Router/index.js +0 -145
  64. package/src/api/index.d.ts +0 -3
  65. package/src/api/index.js +0 -39
  66. package/src/app/index.d.ts +0 -1
  67. package/src/app/index.js +0 -37
  68. package/src/app/utils/ApplicationState.d.ts +0 -52
  69. package/src/app/utils/ApplicationState.js +0 -86
  70. package/src/app/utils/ApplicationStateLoader.d.ts +0 -46
  71. package/src/app/utils/ApplicationStateLoader.js +0 -57
  72. package/src/app/utils/Controller.d.ts +0 -4
  73. package/src/app/utils/Controller.js +0 -47
  74. package/src/app/utils/Debug.d.ts +0 -4
  75. package/src/app/utils/Debug.js +0 -30
  76. package/src/app/utils/EasyLayout.d.ts +0 -49
  77. package/src/app/utils/EasyLayout.js +0 -122
  78. package/src/app/utils/Route.d.ts +0 -28
  79. package/src/app/utils/Route.js +0 -102
  80. package/src/app/utils/Service.d.ts +0 -12
  81. package/src/app/utils/Service.js +0 -34
  82. package/src/app/utils/TypeInfoORMAPIUtils.d.ts +0 -20
  83. package/src/app/utils/TypeInfoORMAPIUtils.js +0 -62
  84. package/src/app/utils/TypeInfoORMClient.d.ts +0 -24
  85. package/src/app/utils/TypeInfoORMClient.js +0 -69
  86. package/src/app/utils/index.d.ts +0 -8
  87. package/src/app/utils/index.js +0 -24
  88. package/src/common/CommandLine/collectRequiredEnvironmentVariables.d.ts +0 -1
  89. package/src/common/CommandLine/collectRequiredEnvironmentVariables.js +0 -16
  90. package/src/common/HelperTypes.d.ts +0 -3
  91. package/src/common/HelperTypes.js +0 -2
  92. package/src/common/IdGeneration/getSimpleId.d.ts +0 -4
  93. package/src/common/IdGeneration/getSimpleId.js +0 -16
  94. package/src/common/IdGeneration/index.d.ts +0 -1
  95. package/src/common/IdGeneration/index.js +0 -17
  96. package/src/common/ItemRelationshipInfoTypes.d.ts +0 -46
  97. package/src/common/ItemRelationshipInfoTypes.js +0 -20
  98. package/src/common/ItemRelationships/ItemRelationshipValidation.d.ts +0 -10
  99. package/src/common/ItemRelationships/ItemRelationshipValidation.js +0 -43
  100. package/src/common/ItemRelationships/index.d.ts +0 -1
  101. package/src/common/ItemRelationships/index.js +0 -17
  102. package/src/common/Logging/Utils.d.ts +0 -10
  103. package/src/common/Logging/Utils.js +0 -33
  104. package/src/common/Logging/index.d.ts +0 -1
  105. package/src/common/Logging/index.js +0 -17
  106. package/src/common/Routing.d.ts +0 -25
  107. package/src/common/Routing.js +0 -102
  108. package/src/common/SearchTypes.d.ts +0 -98
  109. package/src/common/SearchTypes.js +0 -39
  110. package/src/common/SearchUtils.d.ts +0 -22
  111. package/src/common/SearchUtils.js +0 -134
  112. package/src/common/SearchValidation.d.ts +0 -17
  113. package/src/common/SearchValidation.js +0 -90
  114. package/src/common/Storyboarding/Types.d.ts +0 -25
  115. package/src/common/Storyboarding/Types.js +0 -2
  116. package/src/common/StringTransformers.d.ts +0 -17
  117. package/src/common/StringTransformers.js +0 -36
  118. package/src/common/Testing/CLI.d.ts +0 -2
  119. package/src/common/Testing/CLI.js +0 -56
  120. package/src/common/Testing/Types.d.ts +0 -117
  121. package/src/common/Testing/Types.js +0 -19
  122. package/src/common/Testing/Utils.d.ts +0 -48
  123. package/src/common/Testing/Utils.js +0 -334
  124. package/src/common/Testing/index.d.ts +0 -2
  125. package/src/common/Testing/index.js +0 -18
  126. package/src/common/TypeInfoDataItemUtils.d.ts +0 -10
  127. package/src/common/TypeInfoDataItemUtils.js +0 -55
  128. package/src/common/TypeInfoORM/Types.d.ts +0 -76
  129. package/src/common/TypeInfoORM/Types.js +0 -55
  130. package/src/common/TypeInfoORM/index.d.ts +0 -1
  131. package/src/common/TypeInfoORM/index.js +0 -17
  132. package/src/common/TypeParsing/Constants.d.ts +0 -1
  133. package/src/common/TypeParsing/Constants.js +0 -4
  134. package/src/common/TypeParsing/ParsingUtils/Constants.d.ts +0 -5
  135. package/src/common/TypeParsing/ParsingUtils/Constants.js +0 -8
  136. package/src/common/TypeParsing/ParsingUtils/checkType.d.ts +0 -8
  137. package/src/common/TypeParsing/ParsingUtils/checkType.js +0 -46
  138. package/src/common/TypeParsing/ParsingUtils/checkUnionType.d.ts +0 -6
  139. package/src/common/TypeParsing/ParsingUtils/checkUnionType.js +0 -15
  140. package/src/common/TypeParsing/ParsingUtils/extractCommentTags.d.ts +0 -2
  141. package/src/common/TypeParsing/ParsingUtils/extractCommentTags.js +0 -105
  142. package/src/common/TypeParsing/ParsingUtils/extractLiteralValues.d.ts +0 -6
  143. package/src/common/TypeParsing/ParsingUtils/extractLiteralValues.js +0 -42
  144. package/src/common/TypeParsing/ParsingUtils/extractTypeDetails.d.ts +0 -8
  145. package/src/common/TypeParsing/ParsingUtils/extractTypeDetails.js +0 -14
  146. package/src/common/TypeParsing/ParsingUtils/getPrimaryFieldForTypeInfo.d.ts +0 -5
  147. package/src/common/TypeParsing/ParsingUtils/getPrimaryFieldForTypeInfo.js +0 -27
  148. package/src/common/TypeParsing/ParsingUtils/getTypeInfo.d.ts +0 -3
  149. package/src/common/TypeParsing/ParsingUtils/getTypeInfo.js +0 -27
  150. package/src/common/TypeParsing/ParsingUtils/getTypeInfoField.d.ts +0 -3
  151. package/src/common/TypeParsing/ParsingUtils/getTypeInfoField.js +0 -44
  152. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromAliasType.d.ts +0 -4
  153. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromAliasType.js +0 -28
  154. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromFieldFilter.d.ts +0 -4
  155. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromFieldFilter.js +0 -105
  156. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromTypeAlias.d.ts +0 -4
  157. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromTypeAlias.js +0 -20
  158. package/src/common/TypeParsing/ParsingUtils/getTypeKeyword.d.ts +0 -3
  159. package/src/common/TypeParsing/ParsingUtils/getTypeKeyword.js +0 -17
  160. package/src/common/TypeParsing/ParsingUtils/getUnionOrIntersectionTypeInfo.d.ts +0 -4
  161. package/src/common/TypeParsing/ParsingUtils/getUnionOrIntersectionTypeInfo.js +0 -49
  162. package/src/common/TypeParsing/ParsingUtils/getUnionOrLiteralStringValues.d.ts +0 -2
  163. package/src/common/TypeParsing/ParsingUtils/getUnionOrLiteralStringValues.js +0 -24
  164. package/src/common/TypeParsing/TypeInfo.d.ts +0 -142
  165. package/src/common/TypeParsing/TypeInfo.js +0 -13
  166. package/src/common/TypeParsing/TypeMapping.d.ts +0 -9
  167. package/src/common/TypeParsing/TypeMapping.js +0 -32
  168. package/src/common/TypeParsing/TypeParsing.d.ts +0 -5
  169. package/src/common/TypeParsing/TypeParsing.js +0 -39
  170. package/src/common/TypeParsing/Utils.d.ts +0 -21
  171. package/src/common/TypeParsing/Utils.js +0 -94
  172. package/src/common/TypeParsing/Validation.d.ts +0 -92
  173. package/src/common/TypeParsing/Validation.js +0 -340
  174. package/src/common/TypeParsing/index.d.ts +0 -5
  175. package/src/common/TypeParsing/index.js +0 -44
  176. package/src/common/index.d.ts +0 -11
  177. package/src/common/index.js +0 -47
  178. package/src/iac/SimpleCFT.d.ts +0 -48
  179. package/src/iac/SimpleCFT.js +0 -82
  180. package/src/iac/index.d.ts +0 -9
  181. package/src/iac/index.js +0 -48
  182. package/src/iac/packs/auth/user-management.d.ts +0 -14
  183. package/src/iac/packs/auth/user-management.js +0 -302
  184. package/src/iac/packs/auth.d.ts +0 -19
  185. package/src/iac/packs/auth.js +0 -47
  186. package/src/iac/packs/build/utils.d.ts +0 -100
  187. package/src/iac/packs/build/utils.js +0 -23
  188. package/src/iac/packs/build.d.ts +0 -29
  189. package/src/iac/packs/build.js +0 -217
  190. package/src/iac/packs/cdn.d.ts +0 -12
  191. package/src/iac/packs/cdn.js +0 -126
  192. package/src/iac/packs/cloud-function.d.ts +0 -17
  193. package/src/iac/packs/cloud-function.js +0 -69
  194. package/src/iac/packs/database.d.ts +0 -29
  195. package/src/iac/packs/database.js +0 -27
  196. package/src/iac/packs/dns.d.ts +0 -13
  197. package/src/iac/packs/dns.js +0 -26
  198. package/src/iac/packs/file-storage.d.ts +0 -14
  199. package/src/iac/packs/file-storage.js +0 -71
  200. package/src/iac/packs/gateway.d.ts +0 -27
  201. package/src/iac/packs/gateway.js +0 -342
  202. package/src/iac/packs/index.d.ts +0 -11
  203. package/src/iac/packs/index.js +0 -27
  204. package/src/iac/packs/repo.d.ts +0 -10
  205. package/src/iac/packs/repo.js +0 -34
  206. package/src/iac/packs/ssl-certificate.d.ts +0 -10
  207. package/src/iac/packs/ssl-certificate.js +0 -36
  208. package/src/iac/types/CloudFormationResourceSpecification.d.ts +0 -2
  209. package/src/iac/types/Constants.d.ts +0 -9
  210. package/src/iac/types/Constants.js +0 -20
  211. package/src/iac/types/IaCTypes.js +0 -14
  212. package/src/iac/types/Renderers.d.ts +0 -12
  213. package/src/iac/types/Renderers.js +0 -112
  214. package/src/iac/types/Types.d.ts +0 -37
  215. package/src/iac/types/Types.js +0 -2
  216. package/src/iac/types/Utils.d.ts +0 -2
  217. package/src/iac/types/Utils.js +0 -60
  218. package/src/iac/types/generate.d.ts +0 -1
  219. package/src/iac/types/generate.js +0 -31
  220. package/src/iac/utils/index.d.ts +0 -36
  221. package/src/iac/utils/index.js +0 -105
  222. package/src/iac/utils/patch-utils.d.ts +0 -15
  223. package/src/iac/utils/patch-utils.js +0 -62
  224. package/src/index.d.ts +0 -178
  225. package/src/index.js +0 -214
@@ -1,282 +0,0 @@
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
- exports.DynamoDBSupportedDataItemDBDriverEntry = exports.DynamoDBDataItemDBDriver = void 0;
7
- const common_1 = require("./common");
8
- const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
9
- const util_dynamodb_1 = require("@aws-sdk/util-dynamodb");
10
- const uuid_1 = require("uuid");
11
- const SearchTypes_1 = require("../../../common/SearchTypes");
12
- const SearchUtils_1 = require("../../../common/SearchUtils");
13
- const fs_1 = __importDefault(require("fs"));
14
- const path_1 = __importDefault(require("path"));
15
- const TypeParsing_1 = require("../../../common/TypeParsing");
16
- const DynamoDBOperatorMappings = {
17
- [SearchTypes_1.ComparisonOperators.EQUALS]: (fieldName) => `#${fieldName} = :${fieldName}`,
18
- [SearchTypes_1.ComparisonOperators.NOT_EQUALS]: (fieldName) => `#${fieldName} <> :${fieldName}`,
19
- [SearchTypes_1.ComparisonOperators.GREATER_THAN]: (fieldName) => `#${fieldName} > :${fieldName}`,
20
- [SearchTypes_1.ComparisonOperators.GREATER_THAN_OR_EQUAL]: (fieldName) => `#${fieldName} >= :${fieldName}`,
21
- [SearchTypes_1.ComparisonOperators.LESS_THAN]: (fieldName) => `#${fieldName} < :${fieldName}`,
22
- [SearchTypes_1.ComparisonOperators.LESS_THAN_OR_EQUAL]: (fieldName) => `#${fieldName} <= :${fieldName}`,
23
- [SearchTypes_1.ComparisonOperators.IN]: (fieldName) => `#${fieldName} IN (:${fieldName})`,
24
- [SearchTypes_1.ComparisonOperators.LIKE]: (fieldName) => `contains(#${fieldName}, :${fieldName})`,
25
- [SearchTypes_1.ComparisonOperators.EXISTS]: (fieldName) => `attribute_exists(#${fieldName})`,
26
- [SearchTypes_1.ComparisonOperators.NOT_EXISTS]: (fieldName) => `attribute_not_exists(#${fieldName})`,
27
- [SearchTypes_1.ComparisonOperators.IS_EMPTY]: (fieldName) => `size(#${fieldName}) = 0`,
28
- [SearchTypes_1.ComparisonOperators.IS_NOT_EMPTY]: (fieldName) => `size(#${fieldName}) > 0`,
29
- [SearchTypes_1.ComparisonOperators.BETWEEN]: (fieldName) => `#${fieldName} BETWEEN :${fieldName}_start AND :${fieldName}_end`,
30
- [SearchTypes_1.ComparisonOperators.CONTAINS]: (fieldName) => `contains(#${fieldName}, :${fieldName})`,
31
- [SearchTypes_1.ComparisonOperators.STARTS_WITH]: (fieldName) => `begins_with(#${fieldName}, :${fieldName})`,
32
- };
33
- const DynamoDBLogicalOperatorMappings = {
34
- [SearchTypes_1.LogicalOperators.AND]: "AND",
35
- [SearchTypes_1.LogicalOperators.OR]: "OR",
36
- };
37
- const createFilterExpression = (fieldCriteria, logicalOperator) => {
38
- let output = {};
39
- if (fieldCriteria && fieldCriteria.length > 0) {
40
- const expressions = [];
41
- const attributeNames = {};
42
- const attributeValues = {};
43
- for (const criterion of fieldCriteria) {
44
- const { fieldName, operator, value } = criterion;
45
- const createExpression = DynamoDBOperatorMappings[operator];
46
- if (!createExpression) {
47
- throw {
48
- message: common_1.DATA_ITEM_DB_DRIVER_ERRORS.SEARCH_COMPARISON_OPERATOR_NOT_SUPPORTED,
49
- operator,
50
- fieldName,
51
- };
52
- }
53
- expressions.push(createExpression(fieldName));
54
- attributeNames[`#${fieldName}`] = fieldName;
55
- attributeValues[`:${fieldName}`] = value;
56
- }
57
- output = {
58
- FilterExpression: expressions.join(` ${DynamoDBLogicalOperatorMappings[logicalOperator]} `),
59
- ExpressionAttributeNames: attributeNames,
60
- ExpressionAttributeValues: (0, util_dynamodb_1.marshall)(attributeValues),
61
- };
62
- }
63
- return output;
64
- };
65
- const buildUpdateExpression = (updatedItem, uniquelyIdentifyingFieldName) => {
66
- const updateExpressionParts = [];
67
- const attributeNames = {};
68
- const attributeValues = {};
69
- for (const f in updatedItem) {
70
- const value = updatedItem[f];
71
- // IMPORTANT: DO NOT use the `uniquelyIdentifyingFieldName`.
72
- if (f !== uniquelyIdentifyingFieldName && typeof value !== "undefined") {
73
- const placeholderName = `#${f}`;
74
- const placeholderValue = `:${f}`;
75
- updateExpressionParts.push(`${placeholderName} = ${placeholderValue}`);
76
- attributeNames[placeholderName] = f;
77
- attributeValues[placeholderValue] = (0, util_dynamodb_1.marshall)(value);
78
- }
79
- }
80
- return {
81
- UpdateExpression: `SET ${updateExpressionParts.join(", ")}`,
82
- ExpressionAttributeNames: attributeNames,
83
- ExpressionAttributeValues: attributeValues,
84
- };
85
- };
86
- const buildSelectedFieldParams = (selectedFields) => {
87
- const selectedFieldParams = typeof (selectedFields ?? false) && Array.isArray(selectedFields)
88
- ? {
89
- ExpressionAttributeNames: selectedFields.reduce((acc, field) => {
90
- const fieldAsString = String(field);
91
- acc[`#${fieldAsString}`] = fieldAsString;
92
- return acc;
93
- }, {}),
94
- ProjectionExpression: selectedFields
95
- .map((field) => `#${String(field)}`)
96
- .join(", "),
97
- }
98
- : {};
99
- return selectedFieldParams;
100
- };
101
- /**
102
- * A {@link DataItemDBDriver} that uses DynamoDB as its database.
103
- * */
104
- class DynamoDBDataItemDBDriver {
105
- config;
106
- dynamoDBClient;
107
- constructor(config) {
108
- this.config = config;
109
- const { dbSpecificConfig } = config;
110
- this.dynamoDBClient = new client_dynamodb_1.DynamoDBClient(dbSpecificConfig);
111
- }
112
- /**
113
- * Create an item in the database.
114
- */
115
- createItem = async (newItem) => {
116
- const { tableName, uniquelyIdentifyingFieldName, generateUniqueIdentifier = () => (0, uuid_1.v4)(), } = this.config;
117
- const newItemId = generateUniqueIdentifier(newItem);
118
- const cleanNewItemWithId = {
119
- ...newItem,
120
- [uniquelyIdentifyingFieldName]: newItemId,
121
- };
122
- const command = new client_dynamodb_1.PutItemCommand({
123
- TableName: tableName,
124
- Item: (0, util_dynamodb_1.marshall)(cleanNewItemWithId),
125
- });
126
- await this.dynamoDBClient.send(command);
127
- return newItemId;
128
- };
129
- /**
130
- * Read an item from the database.
131
- */
132
- readItem = async (uniqueIdentifier, selectedFields) => {
133
- const { tableName, uniquelyIdentifyingFieldName } = this.config;
134
- const selectedFieldParams = buildSelectedFieldParams(selectedFields);
135
- const command = new client_dynamodb_1.GetItemCommand({
136
- TableName: tableName,
137
- Key: (0, util_dynamodb_1.marshall)({
138
- [uniquelyIdentifyingFieldName]: uniqueIdentifier,
139
- }),
140
- ...selectedFieldParams,
141
- });
142
- const { Item } = await this.dynamoDBClient.send(command);
143
- if (typeof Item === "undefined") {
144
- throw new Error(common_1.DATA_ITEM_DB_DRIVER_ERRORS.ITEM_NOT_FOUND);
145
- }
146
- else {
147
- const cleanItem = (0, util_dynamodb_1.unmarshall)(Item);
148
- return cleanItem;
149
- }
150
- };
151
- /**
152
- * Update an item in the database.
153
- */
154
- updateItem = async (uniqueIdentifier, updatedItem) => {
155
- const { tableName, uniquelyIdentifyingFieldName } = this.config;
156
- const { [uniquelyIdentifyingFieldName]: _unusedUniqueIdentifier, ...cleanUpdatedItem } = updatedItem;
157
- if (typeof uniqueIdentifier !== "undefined") {
158
- const command = new client_dynamodb_1.UpdateItemCommand({
159
- TableName: tableName,
160
- Key: (0, util_dynamodb_1.marshall)({
161
- [uniquelyIdentifyingFieldName]: uniqueIdentifier,
162
- }),
163
- ReturnValues: "ALL_NEW",
164
- ...buildUpdateExpression(cleanUpdatedItem, uniquelyIdentifyingFieldName),
165
- });
166
- const { Attributes } = await this.dynamoDBClient.send(command);
167
- return !!Attributes;
168
- }
169
- else {
170
- throw {
171
- message: common_1.DATA_ITEM_DB_DRIVER_ERRORS.MISSING_UNIQUE_IDENTIFIER,
172
- uniquelyIdentifyingFieldName,
173
- };
174
- }
175
- };
176
- /**
177
- * Delete an item from the database.
178
- */
179
- deleteItem = async (uniqueIdentifier) => {
180
- const { tableName, uniquelyIdentifyingFieldName } = this.config;
181
- const command = new client_dynamodb_1.DeleteItemCommand({
182
- TableName: tableName,
183
- Key: (0, util_dynamodb_1.marshall)({
184
- [uniquelyIdentifyingFieldName]: uniqueIdentifier,
185
- }),
186
- ReturnValues: "ALL_OLD",
187
- });
188
- const { Attributes } = await this.dynamoDBClient.send(command);
189
- return !!Attributes;
190
- };
191
- /**
192
- * List items from the database.
193
- */
194
- listItems = async (config, selectedFields) => {
195
- const { tableName } = this.config;
196
- const { itemsPerPage = 10, cursor, sortFields, criteria: { logicalOperator = SearchTypes_1.LogicalOperators.AND, fieldCriteria = [], } = {}, } = config;
197
- const { ProjectionExpression, ExpressionAttributeNames: selectFieldParamsAttributeNames, } = buildSelectedFieldParams(selectedFields);
198
- const { FilterExpression, ExpressionAttributeNames, ExpressionAttributeValues, } = createFilterExpression(fieldCriteria, logicalOperator);
199
- // IMPORTANT: DynamoDB is VERY particular about whether to include
200
- // properties, AT ALL, based on expressions being used.
201
- const params = {
202
- TableName: tableName,
203
- Select: selectedFields && selectedFields.length > 0
204
- ? "SPECIFIC_ATTRIBUTES"
205
- : "ALL_ATTRIBUTES",
206
- ...(ProjectionExpression
207
- ? {
208
- ProjectionExpression: ProjectionExpression,
209
- }
210
- : {}),
211
- ...(FilterExpression
212
- ? {
213
- FilterExpression,
214
- }
215
- : {}),
216
- ...(FilterExpression
217
- ? {
218
- ExpressionAttributeNames: {
219
- ...selectFieldParamsAttributeNames,
220
- ...ExpressionAttributeNames,
221
- },
222
- }
223
- : ProjectionExpression
224
- ? {
225
- ExpressionAttributeNames: {
226
- ...selectFieldParamsAttributeNames,
227
- },
228
- }
229
- : {}),
230
- ...(FilterExpression
231
- ? {
232
- ExpressionAttributeValues,
233
- }
234
- : {}),
235
- };
236
- let structuredCursor = undefined;
237
- if (typeof cursor === "string") {
238
- try {
239
- structuredCursor = (0, util_dynamodb_1.marshall)(JSON.parse(cursor));
240
- }
241
- catch (error) {
242
- throw {
243
- message: common_1.DATA_ITEM_DB_DRIVER_ERRORS.INVALID_CURSOR,
244
- cursor,
245
- };
246
- }
247
- }
248
- const command = new client_dynamodb_1.ScanCommand({
249
- ...params,
250
- ExclusiveStartKey: structuredCursor,
251
- Limit: itemsPerPage,
252
- });
253
- const { Items = [], LastEvaluatedKey } = await this.dynamoDBClient.send(command);
254
- const unmarshalledItems = Items.map((item) => (0, util_dynamodb_1.unmarshall)(item));
255
- // Sort the items.
256
- const sortedItems = (0, SearchUtils_1.getSortedItems)(sortFields, unmarshalledItems);
257
- return {
258
- items: sortedItems,
259
- cursor: LastEvaluatedKey
260
- ? JSON.stringify((0, util_dynamodb_1.unmarshall)(LastEvaluatedKey))
261
- : undefined,
262
- };
263
- };
264
- }
265
- exports.DynamoDBDataItemDBDriver = DynamoDBDataItemDBDriver;
266
- /**
267
- * The supported DB driver entry for the DynamoDB {@link DataItemDBDriver}.
268
- * */
269
- exports.DynamoDBSupportedDataItemDBDriverEntry = {
270
- factory: (config) => {
271
- return new DynamoDBDataItemDBDriver(config);
272
- },
273
- getDBSpecificConfigTypeInfo: () => {
274
- const configTypesPath = path_1.default.join(__dirname, "DynamoDBDataItemDBDriver", "ConfigTypes.ts");
275
- const configTypesTS = fs_1.default.readFileSync(configTypesPath, "utf8");
276
- const typeInfoMap = (0, TypeParsing_1.getTypeInfoMapFromTypeScript)(configTypesTS);
277
- return {
278
- entryTypeName: "DynamoDBSpecificConfig",
279
- typeInfoMap,
280
- };
281
- },
282
- };
@@ -1,90 +0,0 @@
1
- export type Trace = (...content: any[]) => void;
2
- export type Logger = {
3
- trace?: string | Trace;
4
- debug: Trace;
5
- info: Trace;
6
- warn: Trace;
7
- error: Trace;
8
- };
9
- export type Endpoint = {
10
- protocol: string;
11
- hostname: string;
12
- port?: string;
13
- path: string;
14
- query?: string;
15
- };
16
- export type Properties = {
17
- authSchemes?: string;
18
- };
19
- export type RetryStrategy = {
20
- mode?: string;
21
- retry: any;
22
- };
23
- export type Credentials = {
24
- accessKeyId: string;
25
- secretAccessKey: string;
26
- sessionToken?: string;
27
- credentialScope?: string;
28
- expiration?: string;
29
- };
30
- export type Signer = {
31
- sign: any;
32
- };
33
- export type AbridgedS3ClientConfig = {
34
- requestHandler?: string;
35
- apiVersion?: string;
36
- sha256?: string;
37
- urlParser?: string;
38
- bodyLengthChecker?: string;
39
- streamCollector?: string;
40
- base64Decoder?: string;
41
- base64Encoder?: string;
42
- utf8Decoder?: string;
43
- utf8Encoder?: string;
44
- runtime?: string;
45
- disableHostPrefix?: string | false | true;
46
- serviceId?: string;
47
- useDualstackEndpoint?: string | false | true;
48
- useFipsEndpoint?: string | false | true;
49
- region?: string;
50
- credentialDefaultProvider?: string;
51
- signingEscapePath?: string | false | true;
52
- useArnRegion?: string | false | true;
53
- defaultUserAgentProvider?: string;
54
- streamHasher?: string;
55
- md5?: string;
56
- sha1?: string;
57
- getAwsChunkedEncodingStream?: string;
58
- maxAttempts?: string;
59
- retryMode?: string;
60
- logger?: string | Logger;
61
- extensions?: string;
62
- eventStreamSerdeProvider?: string;
63
- /**
64
- * @allowCustomSelection
65
- * */
66
- defaultsMode?: "standard" | "in-region" | "cross-region" | "mobile" | "auto" | "legacy";
67
- sdkStreamMixin?: string;
68
- endpoint?: string | Endpoint;
69
- endpointProvider?: string;
70
- tls?: string | false | true;
71
- retryStrategy?: string | RetryStrategy;
72
- credentials?: string | Credentials;
73
- signer?: string | Signer;
74
- systemClockOffset?: string;
75
- signingRegion?: string;
76
- signerConstructor?: string;
77
- forcePathStyle?: string | false | true;
78
- useAccelerateEndpoint?: string | false | true;
79
- disableMultiregionAccessPoints?: string | false | true;
80
- followRegionRedirects?: string | false | true;
81
- s3ExpressIdentityProvider?: string;
82
- customUserAgent?: string;
83
- useGlobalEndpoint?: string | false | true;
84
- disableS3ExpressSessionAuth?: string | false | true;
85
- };
86
- export type S3SpecificConfig = {
87
- s3Config?: AbridgedS3ClientConfig;
88
- bucketName: string;
89
- urlExpirationInSeconds?: number;
90
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,45 +0,0 @@
1
- import { S3, S3ClientConfig } from "@aws-sdk/client-s3";
2
- import { BaseFile, BaseFileLocationInfo, CloudFileServiceDriver } from "../common/Types";
3
- export declare const S3_FILE_DRIVER_ERRORS: {
4
- INVALID_PATH: string;
5
- };
6
- export declare const getFullFileKey: ({ file, baseDirectory, }: {
7
- file: BaseFileLocationInfo;
8
- baseDirectory?: string;
9
- }) => string;
10
- export declare const getBaseFileLocationInfo: (path: string) => BaseFileLocationInfo;
11
- /**
12
- * The configuration for an {@link S3FileDriver}.
13
- * */
14
- export type S3FileDriverConfig = {
15
- s3Config?: S3ClientConfig;
16
- bucketName: string;
17
- urlExpirationInSeconds?: number;
18
- };
19
- /**
20
- * Use S3 as a {@link CloudFileServiceDriver} for {@link BaseFile}s.
21
- */
22
- export declare class S3FileDriver implements CloudFileServiceDriver {
23
- protected config: S3FileDriverConfig;
24
- protected s3: S3;
25
- constructor(config: S3FileDriverConfig);
26
- /**
27
- * Get a signed URL for uploading a file.
28
- */
29
- getFileUploadUrl: (file: BaseFileLocationInfo, baseDirectory?: string) => Promise<string>;
30
- /**
31
- * Get a signed URL for downloading a file.
32
- */
33
- getFileDownloadUrl: (file: BaseFileLocationInfo, baseDirectory?: string) => Promise<string>;
34
- /**
35
- * Delete a file.
36
- */
37
- deleteFile: (file: BaseFileLocationInfo, baseDirectory?: string) => Promise<void>;
38
- /**
39
- * List the files and directories in a directory.
40
- */
41
- listFiles: (path?: string, baseDirectory?: string, maxNumberOfFiles?: number, cursor?: string) => Promise<{
42
- files: BaseFile[];
43
- cursor: string | undefined;
44
- }>;
45
- }
@@ -1,127 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.S3FileDriver = exports.getBaseFileLocationInfo = exports.getFullFileKey = exports.S3_FILE_DRIVER_ERRORS = void 0;
4
- const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
5
- const client_s3_1 = require("@aws-sdk/client-s3");
6
- const Routing_1 = require("../../../../common/Routing");
7
- exports.S3_FILE_DRIVER_ERRORS = {
8
- INVALID_PATH: "INVALID_PATH",
9
- };
10
- const getFullFileKey = ({ file, baseDirectory, }) => {
11
- const { directory, name } = file;
12
- const fullFileKey = `${baseDirectory ? `${baseDirectory}/` : ""}${directory ? `${directory}/` : ""}${name}`;
13
- const pathArray = (0, Routing_1.getPathArray)(fullFileKey, "/", false);
14
- if (pathArray.includes("..") ||
15
- pathArray.includes(".") ||
16
- pathArray.includes("")) {
17
- throw {
18
- message: exports.S3_FILE_DRIVER_ERRORS.INVALID_PATH,
19
- file,
20
- baseDirectory,
21
- };
22
- }
23
- else {
24
- return fullFileKey;
25
- }
26
- };
27
- exports.getFullFileKey = getFullFileKey;
28
- const getBaseFileLocationInfo = (path) => {
29
- const [name, ...directoryParts] = path.split("/").reverse();
30
- return {
31
- directory: directoryParts.reverse().join("/"),
32
- name,
33
- };
34
- };
35
- exports.getBaseFileLocationInfo = getBaseFileLocationInfo;
36
- /**
37
- * Use S3 as a {@link CloudFileServiceDriver} for {@link BaseFile}s.
38
- */
39
- class S3FileDriver {
40
- config;
41
- s3;
42
- constructor(config) {
43
- this.config = config;
44
- const { s3Config = {} } = config;
45
- this.s3 = new client_s3_1.S3(s3Config);
46
- }
47
- /**
48
- * Get a signed URL for uploading a file.
49
- */
50
- getFileUploadUrl = async (file, baseDirectory) => {
51
- const { bucketName, urlExpirationInSeconds } = this.config;
52
- const params = {
53
- Bucket: bucketName,
54
- Key: (0, exports.getFullFileKey)({ file, baseDirectory }),
55
- };
56
- return await (0, s3_request_presigner_1.getSignedUrl)(this.s3, new client_s3_1.PutObjectCommand(params), {
57
- expiresIn: urlExpirationInSeconds,
58
- });
59
- };
60
- /**
61
- * Get a signed URL for downloading a file.
62
- */
63
- getFileDownloadUrl = async (file, baseDirectory) => {
64
- const { bucketName, urlExpirationInSeconds } = this.config;
65
- const params = {
66
- Bucket: bucketName,
67
- Key: (0, exports.getFullFileKey)({ file, baseDirectory }),
68
- };
69
- return await (0, s3_request_presigner_1.getSignedUrl)(this.s3, new client_s3_1.GetObjectCommand(params), {
70
- expiresIn: urlExpirationInSeconds,
71
- });
72
- };
73
- /**
74
- * Delete a file.
75
- */
76
- deleteFile = async (file, baseDirectory) => {
77
- const { bucketName } = this.config;
78
- await this.s3.send(new client_s3_1.DeleteObjectCommand({
79
- Bucket: bucketName,
80
- Key: (0, exports.getFullFileKey)({ file, baseDirectory }),
81
- }));
82
- };
83
- /**
84
- * List the files and directories in a directory.
85
- */
86
- listFiles = async (path, baseDirectory, maxNumberOfFiles = 1, cursor) => {
87
- const { bucketName } = this.config;
88
- const files = [];
89
- let allContents = [], continuationToken = cursor, listAttempted = false;
90
- while ((!listAttempted || continuationToken) &&
91
- files.length < maxNumberOfFiles) {
92
- listAttempted = true;
93
- const listObjectsV2CommandOutput = await this.s3.send(new client_s3_1.ListObjectsV2Command({
94
- Bucket: bucketName,
95
- Prefix: `${baseDirectory || ""}${path || ""}`,
96
- ContinuationToken: continuationToken,
97
- MaxKeys: maxNumberOfFiles === Infinity
98
- ? undefined
99
- : maxNumberOfFiles - allContents.length,
100
- }));
101
- const { Contents = [], NextContinuationToken, } = listObjectsV2CommandOutput;
102
- allContents = [...allContents, ...Contents];
103
- continuationToken = NextContinuationToken;
104
- }
105
- for (const file of allContents) {
106
- if (file.Key) {
107
- const { ContentType = "", ContentLength = 0, LastModified, Metadata: {} = {}, } = await this.s3.send(new client_s3_1.HeadObjectCommand({
108
- Bucket: bucketName,
109
- Key: file.Key,
110
- }));
111
- files.push({
112
- updatedOn: LastModified?.getTime() || 0,
113
- mimeType: ContentType,
114
- sizeInBytes: ContentLength,
115
- directory: path,
116
- name: file.Key.split("/").pop() || "",
117
- isDirectory: ContentType === "application/x-directory",
118
- });
119
- }
120
- }
121
- return {
122
- files,
123
- cursor: continuationToken,
124
- };
125
- };
126
- }
127
- exports.S3FileDriver = S3FileDriver;
@@ -1,44 +0,0 @@
1
- import { S3 } from "@aws-sdk/client-s3";
2
- import { BaseFile, CloudFileServiceDriver, DataItemDBDriver, DataItemDBDriverConfig, SupportedDataItemDBDriverEntry } from "./common/Types";
3
- import { S3SpecificConfig } from "./S3FileItemDBDriver/ConfigTypes";
4
- import { ListItemsConfig } from "../../../common/SearchTypes";
5
- export type BaseFileItem = {
6
- id: string;
7
- } & BaseFile;
8
- /**
9
- * Use S3 as a {@link DataItemDBDriver} for {@link BaseFileItem}s.
10
- * */
11
- export declare class S3FileItemDBDriver implements DataItemDBDriver<BaseFileItem, "id"> {
12
- protected config: DataItemDBDriverConfig<BaseFileItem, "id">;
13
- protected specificConfig: S3SpecificConfig;
14
- protected s3: S3;
15
- protected s3FileDriver: CloudFileServiceDriver;
16
- constructor(config: DataItemDBDriverConfig<BaseFileItem, "id">);
17
- /**
18
- * Create a new @{@link BaseFileItem}.
19
- * */
20
- createItem: (item: Partial<Omit<BaseFileItem, "id">>) => Promise<string>;
21
- /**
22
- * Read a @{@link BaseFileItem} by its id.
23
- * */
24
- readItem: (id: string, selectFields?: (keyof BaseFileItem)[]) => Promise<BaseFileItem>;
25
- /**
26
- * Update a @{@link BaseFileItem}.
27
- * */
28
- updateItem: (uniqueIdentifier: BaseFileItem["id"], item: Partial<BaseFileItem>) => Promise<boolean>;
29
- /**
30
- * Delete a @{@link BaseFileItem} by its id.
31
- */
32
- deleteItem: (id: string) => Promise<boolean>;
33
- /**
34
- * List @{@link BaseFileItem}s by a given criteria.
35
- */
36
- listItems: (config: ListItemsConfig, selectFields?: (keyof BaseFileItem)[]) => Promise<{
37
- items: Partial<BaseFileItem>[];
38
- cursor: string | undefined;
39
- }>;
40
- }
41
- /**
42
- * The supported DB driver entry for the S3 File {@link DataItemDBDriver}.
43
- * */
44
- export declare const S3SupportedFileItemDBDriverEntry: SupportedDataItemDBDriverEntry;