@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,334 +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.executeTestingCommand = exports.runTestsForFile = exports.generateTestsForFile = exports.runTest = exports.mergeTestResults = exports.getResolvedTestConfig = exports.getTestConfig = exports.getTestFunction = exports.getSetupInstance = exports.getResolvedConditions = exports.compare = exports.OPERATIONS = void 0;
7
- const Types_1 = require("./Types");
8
- const fs_1 = require("fs");
9
- const path_1 = __importDefault(require("path"));
10
- const stringifyOutput = (value) => JSON.stringify(value, function (_key, value) {
11
- return typeof value === "function" ? "[Function]" : value;
12
- }, 2);
13
- /**
14
- * A map of comparison functions for each `TestComparisonOperation`.
15
- * */
16
- exports.OPERATIONS = {
17
- [Types_1.TestComparisonOperation.EQUALS]: (a, b) => a === b,
18
- [Types_1.TestComparisonOperation.NOT_EQUALS]: (a, b) => a !== b,
19
- [Types_1.TestComparisonOperation.IN]: (a, b) => Array.isArray(b) && b.includes(a),
20
- [Types_1.TestComparisonOperation.BETWEEN]: (a, b) => {
21
- if (Array.isArray(b) &&
22
- b.length === 2 &&
23
- typeof b[0] === "number" &&
24
- typeof b[1] === "number") {
25
- return typeof a === "number" && a >= b[0] && a <= b[1];
26
- }
27
- throw new Error("BETWEEN requires an array of two numbers as expectation.");
28
- },
29
- [Types_1.TestComparisonOperation.CONTAINS]: (a, b) => typeof a === "string" && typeof b === "string" && a.includes(b),
30
- [Types_1.TestComparisonOperation.REGEX]: (a, b) => {
31
- if (typeof b === "object" && b !== null && "pattern" in b) {
32
- const { pattern, flags } = b;
33
- try {
34
- const regex = new RegExp(pattern, flags);
35
- return typeof a === "string" && regex.test(a);
36
- }
37
- catch (err) {
38
- throw new Error(`Invalid REGEX: ${err.message}`);
39
- }
40
- }
41
- throw new Error("REGEX requires an expectation with 'pattern' and optional 'flags'.");
42
- },
43
- [Types_1.TestComparisonOperation.EXT_REGEX]: (a, b) => {
44
- if (typeof b === "object" && b !== null && "pattern" in b) {
45
- const { pattern, flags } = b;
46
- const buildRegexFromPattern = (pattern, flags = "") => {
47
- if (!Array.isArray(pattern)) {
48
- throw new Error("EXT_REGEX pattern must be an array of objects.");
49
- }
50
- const regexBody = pattern
51
- .map(({ value, escaped }) => {
52
- if (typeof value !== "string") {
53
- throw new Error("Each pattern element must have a string 'value'.");
54
- }
55
- return escaped
56
- ? value.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")
57
- : value;
58
- })
59
- .join("");
60
- return new RegExp(regexBody, flags);
61
- };
62
- try {
63
- const regex = buildRegexFromPattern(pattern, flags);
64
- return typeof a === "string" && regex.test(a);
65
- }
66
- catch (err) {
67
- throw new Error(`Invalid EXT_REGEX: ${err.message}`);
68
- }
69
- }
70
- throw new Error("EXT_REGEX requires an expectation with 'pattern' as an array of PatternElement and optional 'flags'.");
71
- },
72
- [Types_1.TestComparisonOperation.DEEP_EQUALS]: (a, b) => {
73
- if (typeof a === "object" &&
74
- typeof b === "object" &&
75
- a !== null &&
76
- b !== null) {
77
- return JSON.stringify(a) === JSON.stringify(b);
78
- }
79
- return false;
80
- },
81
- [Types_1.TestComparisonOperation.ARRAY_CONTAINS]: (a, b) => {
82
- if (Array.isArray(a)) {
83
- return a.includes(b);
84
- }
85
- throw new Error("ARRAY_CONTAINS requires an array as the first argument.");
86
- },
87
- [Types_1.TestComparisonOperation.ARRAY_EQUALS]: (a, b) => {
88
- if (Array.isArray(a) && Array.isArray(b)) {
89
- return JSON.stringify(a) === JSON.stringify(b);
90
- }
91
- throw new Error("ARRAY_EQUALS requires two arrays as arguments.");
92
- },
93
- };
94
- /**
95
- * Compare a result with an expectation using a specified `TestComparisonOperation`.
96
- * */
97
- const compare = (result, expectation, operation = Types_1.TestComparisonOperation.EQUALS) => {
98
- const op = exports.OPERATIONS[operation];
99
- if (!op) {
100
- throw new Error(`Unsupported operation: ${operation}`);
101
- }
102
- return op(result, expectation);
103
- };
104
- exports.compare = compare;
105
- /**
106
- * Get the target module for testing from a file being tested.
107
- * */
108
- const getResolvedConditions = (testFilePath, targetTestIndex, targetTestExport, conditions, isSetup = false) => {
109
- if (Array.isArray(conditions)) {
110
- return conditions;
111
- }
112
- else if (typeof conditions === "object" && conditions !== null) {
113
- const { file, export: targetConditionExport } = conditions;
114
- const modulePath = path_1.default.resolve(path_1.default.dirname(testFilePath), file);
115
- const targetModule = require(modulePath);
116
- const conditionArray = targetModule[targetConditionExport];
117
- if (Array.isArray(conditionArray)) {
118
- return conditionArray;
119
- }
120
- }
121
- throw new Error(`Invalid conditions for TEST${isSetup ? " SETUP" : ""} ${targetTestIndex + 1} (${targetTestExport}) in ${testFilePath}`);
122
- };
123
- exports.getResolvedConditions = getResolvedConditions;
124
- /**
125
- * Get the target base instance from a module, for a given test setup.
126
- * */
127
- const getSetupInstance = async (testFilePath, targetTestIndex, targetTestExport, test, module) => {
128
- const { setup } = test;
129
- if (!setup)
130
- return module;
131
- const { conditions: baseConditions, export: targetSetupExport } = setup;
132
- const setupFunction = module[targetSetupExport];
133
- const conditions = (0, exports.getResolvedConditions)(testFilePath, targetTestIndex, targetTestExport, baseConditions, true);
134
- if (typeof setupFunction !== "function") {
135
- throw new Error(`Setup export "${setup.export}" is not a function.`);
136
- }
137
- return setup.instantiate
138
- ? new setupFunction(...conditions)
139
- : await setupFunction(...conditions);
140
- };
141
- exports.getSetupInstance = getSetupInstance;
142
- const getTestFunction = async (testFilePath, file, targetTestIndex, test, targetModule) => {
143
- const { export: targetExport } = test;
144
- if (!targetExport) {
145
- throw new Error(`Invalid test export (${targetExport}) for TEST ${targetTestIndex + 1} in ${testFilePath}`);
146
- }
147
- const instance = await (0, exports.getSetupInstance)(testFilePath, targetTestIndex, targetExport, test, targetModule);
148
- const testFunction = instance[targetExport];
149
- if (typeof testFunction !== "function") {
150
- throw new Error(`Export "${targetExport}" from "${file}", declared in TEST ${targetTestIndex + 1}, is not a function.`);
151
- }
152
- return testFunction;
153
- };
154
- exports.getTestFunction = getTestFunction;
155
- /**
156
- * Get the test configuration from a test file.
157
- * */
158
- const getTestConfig = async (testFilePath) => {
159
- const testConfig = JSON.parse(await fs_1.promises.readFile(testFilePath, "utf8"));
160
- return testConfig;
161
- };
162
- exports.getTestConfig = getTestConfig;
163
- /**
164
- * Get the target module for testing from a file being tested.
165
- * */
166
- const getResolvedTestConfig = async (testFilePath) => {
167
- const { file, tests } = await (0, exports.getTestConfig)(testFilePath);
168
- if (!file) {
169
- throw new Error(`Invalid test configuration in ${testFilePath}`);
170
- }
171
- const modulePath = path_1.default.resolve(path_1.default.dirname(testFilePath), file);
172
- const targetModule = require(modulePath);
173
- return {
174
- file,
175
- targetModule,
176
- tests,
177
- };
178
- };
179
- exports.getResolvedTestConfig = getResolvedTestConfig;
180
- /**
181
- * Merge multiple test results into a single result.
182
- * */
183
- const mergeTestResults = (...results) => results.reduce(({ messages: accMessages = [], generated: accGenerated = [], passes: accPasses = [], failures: accFailures = [], errors: accErrors = [], }, { messages = [], generated = [], passes = [], failures = [], errors = [], }) => ({
184
- messages: [...accMessages, ...messages],
185
- generated: [...accGenerated, ...generated],
186
- passes: [...accPasses, ...passes],
187
- failures: [...accFailures, ...failures],
188
- errors: [...accErrors, ...errors],
189
- }), { messages: [], passes: [], failures: [], errors: [] });
190
- exports.mergeTestResults = mergeTestResults;
191
- /**
192
- * Run a test using a test function and a test condition.
193
- * */
194
- const runTest = async (testFilePath, testFunction, test, index, targetExport, report) => {
195
- const { conditions: baseConditions, expectation, operation, expectUndefined, } = test;
196
- const conditions = (0, exports.getResolvedConditions)(testFilePath, index, targetExport, baseConditions);
197
- try {
198
- const result = await testFunction(...conditions);
199
- const passed = expectUndefined || (0, exports.compare)(result, expectation, operation);
200
- if (passed) {
201
- report({
202
- passes: [`Test ${index + 1} (${targetExport})`],
203
- });
204
- }
205
- else {
206
- report({
207
- failures: [
208
- `Test ${index + 1} (${targetExport}):
209
-
210
- Result:
211
-
212
- ${stringifyOutput(result)}`,
213
- ],
214
- });
215
- }
216
- }
217
- catch (err) {
218
- report({
219
- errors: [
220
- `Test ${index + 1} (${targetExport}):
221
-
222
- Error:
223
-
224
- ${err.message}`,
225
- ],
226
- });
227
- }
228
- };
229
- exports.runTest = runTest;
230
- /**
231
- * Generate tests for a file by running the tests, capturing the current result and storing it as the new expectation.
232
- * */
233
- const generateTestsForFile = async (testFilePath, report) => {
234
- try {
235
- const { file, targetModule, tests } = await (0, exports.getResolvedTestConfig)(testFilePath);
236
- report({
237
- messages: [`Generating expectations for tests in ${testFilePath}`],
238
- });
239
- const generatedTests = [];
240
- let hasNewExpectations = false;
241
- for (let i = 0; i < tests.length; i++) {
242
- const test = tests[i];
243
- const { export: targetExport, conditions: baseConditions, expectation, operation, expectUndefined, } = test;
244
- const conditions = (0, exports.getResolvedConditions)(testFilePath, i, targetExport, baseConditions);
245
- if (expectation !== undefined || expectUndefined) {
246
- // IMPORTANT: Skip if expectation already exists
247
- generatedTests.push(test);
248
- }
249
- else {
250
- const testFunction = await (0, exports.getTestFunction)(testFilePath, file, i, test, targetModule);
251
- const result = await testFunction(...conditions);
252
- report({
253
- generated: [
254
- `Expectation for TEST ${i + 1} (${targetExport}):
255
-
256
- ${stringifyOutput(result)}`,
257
- ],
258
- });
259
- generatedTests.push({
260
- ...test,
261
- expectation: result,
262
- operation: operation || Types_1.TestComparisonOperation.EQUALS,
263
- });
264
- hasNewExpectations = true;
265
- }
266
- }
267
- if (hasNewExpectations) {
268
- const updatedTestConfig = { file, tests: generatedTests };
269
- await fs_1.promises.writeFile(testFilePath, JSON.stringify(updatedTestConfig, null, 2));
270
- report({ messages: [`Updated test file saved to ${testFilePath}`] });
271
- }
272
- else {
273
- report({
274
- messages: [`No new expectations were generated for ${testFilePath}`],
275
- });
276
- }
277
- }
278
- catch (err) {
279
- report({
280
- errors: [`Error processing test file ${testFilePath}:\n\n${err.message}`],
281
- });
282
- }
283
- };
284
- exports.generateTestsForFile = generateTestsForFile;
285
- /**
286
- * Run the tests for a given test file.
287
- *
288
- * The test file content is expected to be a JSON in the structure of a `TestConfig`.
289
- * */
290
- const runTestsForFile = async (testFilePath, report) => {
291
- try {
292
- const { file, targetModule, tests } = await (0, exports.getResolvedTestConfig)(testFilePath);
293
- report({
294
- messages: [`Running tests from ${testFilePath}`],
295
- });
296
- for (const [index, test] of tests.entries()) {
297
- const { export: targetExport } = test;
298
- const testFunction = await (0, exports.getTestFunction)(testFilePath, file, index, test, targetModule);
299
- await (0, exports.runTest)(testFilePath, testFunction, test, index, targetExport, report);
300
- }
301
- }
302
- catch (err) {
303
- report({
304
- errors: [`Error processing test file ${testFilePath}: ${err.message}`],
305
- });
306
- }
307
- };
308
- exports.runTestsForFile = runTestsForFile;
309
- /**
310
- * Run or generate all of the tests in the specified `testPath` glob.
311
- * */
312
- const executeTestingCommand = async (testFiles, generateMode = false, report) => {
313
- const completeMessage = generateMode
314
- ? "Test generation complete."
315
- : "Testing complete.";
316
- try {
317
- for (const testFile of testFiles) {
318
- const resolvedTestFile = path_1.default.resolve(testFile);
319
- if (generateMode) {
320
- await (0, exports.generateTestsForFile)(resolvedTestFile, report);
321
- }
322
- else {
323
- await (0, exports.runTestsForFile)(resolvedTestFile, report);
324
- }
325
- }
326
- report({
327
- messages: [completeMessage],
328
- });
329
- }
330
- catch (err) {
331
- report({ errors: [`Error running tests:\n\n${err.message}`] });
332
- }
333
- };
334
- exports.executeTestingCommand = executeTestingCommand;
@@ -1,2 +0,0 @@
1
- export * from "./Types";
2
- export * from "./Utils";
@@ -1,18 +0,0 @@
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
- __exportStar(require("./Types"), exports);
18
- __exportStar(require("./Utils"), exports);
@@ -1,10 +0,0 @@
1
- import { LiteralValue, TypeInfoField } from "./TypeParsing/TypeInfo";
2
- export type FieldValueType = LiteralValue | LiteralValue[];
3
- export type DefaultValueInfo = {
4
- hasDefaultValue: true;
5
- defaultValue: FieldValueType;
6
- } | {
7
- hasDefaultValue: false;
8
- defaultValue: undefined;
9
- };
10
- export declare const getDefaultValueInfo: (typeInfoField: TypeInfoField) => DefaultValueInfo;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDefaultValueInfo = void 0;
4
- const FIELD_VALUE_CONVERTER_MAP = {
5
- string: (value) => `${value}`,
6
- number: (value) => {
7
- let num = 0;
8
- try {
9
- num = parseFloat(value);
10
- }
11
- catch (error) {
12
- // Ignore.
13
- }
14
- return isNaN(num) ? 0 : num;
15
- },
16
- boolean: (value) => !!value && value === "true",
17
- };
18
- const ARRAY_CONVERTER = (value, subConverter) => {
19
- let arr = [];
20
- try {
21
- const interimArr = JSON.parse(value);
22
- if (Array.isArray(interimArr)) {
23
- arr = interimArr.map((x) => subConverter(`${x}`));
24
- }
25
- }
26
- catch (error) {
27
- // Ignore.
28
- }
29
- return arr;
30
- };
31
- const getDefaultValueInfo = (typeInfoField) => {
32
- const { type, array = false, typeReference, tags: { constraints = {} } = {}, } = typeInfoField;
33
- let info = {
34
- hasDefaultValue: false,
35
- defaultValue: undefined,
36
- };
37
- if (!typeReference && constraints && "defaultValue" in constraints) {
38
- const { defaultValue } = constraints;
39
- const fieldType = type;
40
- const converter = typeof fieldType === "string" && fieldType in FIELD_VALUE_CONVERTER_MAP
41
- ? FIELD_VALUE_CONVERTER_MAP[fieldType]
42
- : undefined;
43
- const cleanDefaultValue = converter && typeof defaultValue === "string"
44
- ? array
45
- ? ARRAY_CONVERTER(defaultValue, converter)
46
- : converter(defaultValue)
47
- : defaultValue;
48
- info = {
49
- hasDefaultValue: true,
50
- defaultValue: cleanDefaultValue,
51
- };
52
- }
53
- return info;
54
- };
55
- exports.getDefaultValueInfo = getDefaultValueInfo;
@@ -1,76 +0,0 @@
1
- import { ListItemsConfig, ListItemsResults, ListRelationshipsConfig } from "../SearchTypes";
2
- import { BaseItemRelationshipInfo, ItemRelationshipInfo } from "../ItemRelationshipInfoTypes";
3
- import { TypeInfoDataItem, TypeOperation } from "../TypeParsing/TypeInfo";
4
- /**
5
- * The DAC Resource name for item relationships.
6
- * */
7
- export declare const ITEM_RELATIONSHIP_DAC_RESOURCE_NAME = "TYPE_INFO_ORM_ITEM_RELATIONSHIP";
8
- /**
9
- * A set of possible operations for a {@link ItemRelationshipInfo}.
10
- * */
11
- export declare enum RelationshipOperation {
12
- GET = "GET",
13
- SET = "SET",
14
- UNSET = "UNSET"
15
- }
16
- /**
17
- * A set groups of possible operations for a type, field value or relationship.
18
- * */
19
- export declare enum OperationGroup {
20
- ALL_OPERATIONS = "ALL_OPERATIONS",
21
- ALL_ITEM_OPERATIONS = "ALL_ITEM_OPERATIONS",
22
- ALL_RELATIONSHIP_OPERATIONS = "ALL_RELATIONSHIP_OPERATIONS"
23
- }
24
- /**
25
- * A set of possible ORM operations.
26
- * */
27
- export type ORMOperation = TypeOperation | RelationshipOperation | OperationGroup;
28
- /**
29
- * Error types for a TypeInfoORM service.
30
- * */
31
- export declare enum TypeInfoORMServiceError {
32
- NO_DRIVERS_SUPPLIED = "NO_DRIVERS_SUPPLIED",
33
- NO_RELATIONSHIP_DRIVERS_SUPPLIED = "NO_RELATIONSHIP_DRIVERS_SUPPLIED",
34
- NO_PRIMARY_FIELD_VALUE_SUPPLIED = "NO_PRIMARY_FIELD_VALUE_SUPPLIED",
35
- INVALID_DRIVER = "INVALID_DRIVER",
36
- INVALID_RELATIONSHIP_DRIVER = "INVALID_RELATIONSHIP_DRIVER",
37
- INVALID_TYPE_INFO = "INVALID_TYPE_INFO",
38
- TYPE_INFO_MISSING_PRIMARY_FIELD = "TYPE_INFO_MISSING_PRIMARY_FIELD",
39
- INVALID_RELATIONSHIP = "INVALID_RELATIONSHIP",
40
- INVALID_OPERATION = "INVALID_OPERATION"
41
- }
42
- /**
43
- * A collection of kebab-case route paths for a TypeInfoORM API.
44
- * */
45
- export declare enum TypeInfoORMAPIRoutePaths {
46
- CREATE = "create",
47
- READ = "read",
48
- UPDATE = "update",
49
- DELETE = "delete",
50
- LIST = "list",
51
- CREATE_RELATIONSHIP = "create-relationship",
52
- DELETE_RELATIONSHIP = "delete-relationship",
53
- LIST_RELATIONSHIPS = "list-relationships",
54
- LIST_RELATED_ITEMS = "list-related-items"
55
- }
56
- /**
57
- * The results of a delete relationship operation.
58
- */
59
- export type DeleteRelationshipResults = {
60
- success: boolean;
61
- remainingItemsExist: boolean;
62
- };
63
- /**
64
- * The API type for TypeInfoORM providers to implement.
65
- * */
66
- export type TypeInfoORMAPI = {
67
- createRelationship: (relationshipItem: BaseItemRelationshipInfo) => Promise<boolean>;
68
- deleteRelationship: (relationshipItem: BaseItemRelationshipInfo) => Promise<DeleteRelationshipResults>;
69
- listRelationships: (config: ListRelationshipsConfig) => Promise<ListItemsResults<ItemRelationshipInfo>>;
70
- listRelatedItems: (config: ListRelationshipsConfig, selectedFields?: (keyof TypeInfoDataItem)[]) => Promise<ListItemsResults<Partial<TypeInfoDataItem>>>;
71
- create: (typeName: string, item: TypeInfoDataItem) => Promise<any>;
72
- read: (typeName: string, primaryFieldValue: any, selectedFields?: (keyof TypeInfoDataItem)[]) => Promise<Partial<TypeInfoDataItem>>;
73
- update: (typeName: string, item: TypeInfoDataItem) => Promise<boolean>;
74
- delete: (typeName: string, primaryFieldValue: any) => Promise<boolean>;
75
- list: (typeName: string, config: ListItemsConfig, selectedFields?: (keyof TypeInfoDataItem)[]) => Promise<ListItemsResults<Partial<TypeInfoDataItem>>>;
76
- };
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TypeInfoORMAPIRoutePaths = exports.TypeInfoORMServiceError = exports.OperationGroup = exports.RelationshipOperation = exports.ITEM_RELATIONSHIP_DAC_RESOURCE_NAME = void 0;
4
- /**
5
- * The DAC Resource name for item relationships.
6
- * */
7
- exports.ITEM_RELATIONSHIP_DAC_RESOURCE_NAME = "TYPE_INFO_ORM_ITEM_RELATIONSHIP";
8
- /**
9
- * A set of possible operations for a {@link ItemRelationshipInfo}.
10
- * */
11
- var RelationshipOperation;
12
- (function (RelationshipOperation) {
13
- RelationshipOperation["GET"] = "GET";
14
- RelationshipOperation["SET"] = "SET";
15
- RelationshipOperation["UNSET"] = "UNSET";
16
- })(RelationshipOperation || (exports.RelationshipOperation = RelationshipOperation = {}));
17
- /**
18
- * A set groups of possible operations for a type, field value or relationship.
19
- * */
20
- var OperationGroup;
21
- (function (OperationGroup) {
22
- OperationGroup["ALL_OPERATIONS"] = "ALL_OPERATIONS";
23
- OperationGroup["ALL_ITEM_OPERATIONS"] = "ALL_ITEM_OPERATIONS";
24
- OperationGroup["ALL_RELATIONSHIP_OPERATIONS"] = "ALL_RELATIONSHIP_OPERATIONS";
25
- })(OperationGroup || (exports.OperationGroup = OperationGroup = {}));
26
- /**
27
- * Error types for a TypeInfoORM service.
28
- * */
29
- var TypeInfoORMServiceError;
30
- (function (TypeInfoORMServiceError) {
31
- TypeInfoORMServiceError["NO_DRIVERS_SUPPLIED"] = "NO_DRIVERS_SUPPLIED";
32
- TypeInfoORMServiceError["NO_RELATIONSHIP_DRIVERS_SUPPLIED"] = "NO_RELATIONSHIP_DRIVERS_SUPPLIED";
33
- TypeInfoORMServiceError["NO_PRIMARY_FIELD_VALUE_SUPPLIED"] = "NO_PRIMARY_FIELD_VALUE_SUPPLIED";
34
- TypeInfoORMServiceError["INVALID_DRIVER"] = "INVALID_DRIVER";
35
- TypeInfoORMServiceError["INVALID_RELATIONSHIP_DRIVER"] = "INVALID_RELATIONSHIP_DRIVER";
36
- TypeInfoORMServiceError["INVALID_TYPE_INFO"] = "INVALID_TYPE_INFO";
37
- TypeInfoORMServiceError["TYPE_INFO_MISSING_PRIMARY_FIELD"] = "TYPE_INFO_MISSING_PRIMARY_FIELD";
38
- TypeInfoORMServiceError["INVALID_RELATIONSHIP"] = "INVALID_RELATIONSHIP";
39
- TypeInfoORMServiceError["INVALID_OPERATION"] = "INVALID_OPERATION";
40
- })(TypeInfoORMServiceError || (exports.TypeInfoORMServiceError = TypeInfoORMServiceError = {}));
41
- /**
42
- * A collection of kebab-case route paths for a TypeInfoORM API.
43
- * */
44
- var TypeInfoORMAPIRoutePaths;
45
- (function (TypeInfoORMAPIRoutePaths) {
46
- TypeInfoORMAPIRoutePaths["CREATE"] = "create";
47
- TypeInfoORMAPIRoutePaths["READ"] = "read";
48
- TypeInfoORMAPIRoutePaths["UPDATE"] = "update";
49
- TypeInfoORMAPIRoutePaths["DELETE"] = "delete";
50
- TypeInfoORMAPIRoutePaths["LIST"] = "list";
51
- TypeInfoORMAPIRoutePaths["CREATE_RELATIONSHIP"] = "create-relationship";
52
- TypeInfoORMAPIRoutePaths["DELETE_RELATIONSHIP"] = "delete-relationship";
53
- TypeInfoORMAPIRoutePaths["LIST_RELATIONSHIPS"] = "list-relationships";
54
- TypeInfoORMAPIRoutePaths["LIST_RELATED_ITEMS"] = "list-related-items";
55
- })(TypeInfoORMAPIRoutePaths || (exports.TypeInfoORMAPIRoutePaths = TypeInfoORMAPIRoutePaths = {}));
@@ -1 +0,0 @@
1
- export * from "./Types";
@@ -1,17 +0,0 @@
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
- __exportStar(require("./Types"), exports);
@@ -1 +0,0 @@
1
- export declare const BUILTIN_TYPE_NAMES: string[];
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BUILTIN_TYPE_NAMES = void 0;
4
- exports.BUILTIN_TYPE_NAMES = ['string', 'number', 'boolean', 'null', 'object', 'array', 'any', 'unknown', 'never'];
@@ -1,5 +0,0 @@
1
- export declare const FIELD_FILTERS: {
2
- OMIT: string;
3
- PICK: string;
4
- EXCLUDE: string;
5
- };
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FIELD_FILTERS = void 0;
4
- exports.FIELD_FILTERS = {
5
- OMIT: 'Omit',
6
- PICK: 'Pick',
7
- EXCLUDE: 'Exclude',
8
- };
@@ -1,8 +0,0 @@
1
- import { TypeNode } from "typescript";
2
- import { LiteralValue, TypeKeyword } from "../TypeInfo";
3
- export declare const checkType: (node: TypeNode) => {
4
- typeReference?: string | undefined;
5
- isArray?: boolean;
6
- typeKeyword?: TypeKeyword;
7
- options?: LiteralValue[] | undefined;
8
- };
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkType = void 0;
4
- const typescript_1 = require("typescript");
5
- const checkUnionType_1 = require("./checkUnionType");
6
- const getTypeKeyword_1 = require("./getTypeKeyword");
7
- const checkType = (node) => {
8
- let typeReference;
9
- let isArray = false;
10
- let typeKeyword;
11
- let options;
12
- if (node.kind === typescript_1.SyntaxKind.TypeReference) {
13
- typeReference = node.typeName.getText();
14
- typeKeyword = "string";
15
- }
16
- else if (node.kind === typescript_1.SyntaxKind.ArrayType) {
17
- isArray = true;
18
- const elementType = node.elementType;
19
- const { typeReference: elementReference, isArray: elementIsArray, typeKeyword: elementKeyword, options: elementOptions, } = (0, exports.checkType)(elementType);
20
- typeReference = elementReference;
21
- isArray = !!elementIsArray;
22
- typeKeyword = elementKeyword || "string";
23
- options = elementOptions;
24
- }
25
- else if (node.kind === typescript_1.SyntaxKind.UnionType) {
26
- const { types: unionTypes } = node;
27
- const { options: unionOptions, typeKeyword: unionTypeKeyword } = (0, checkUnionType_1.checkUnionType)(node);
28
- options = unionOptions;
29
- typeKeyword = unionTypeKeyword;
30
- if (!options) {
31
- typeKeyword = (0, getTypeKeyword_1.getTypeKeyword)(unionTypes[0]);
32
- }
33
- }
34
- else if (node.kind === typescript_1.SyntaxKind.ParenthesizedType) {
35
- const { typeReference: parenthesizedReference, isArray: parenthesizedIsArray, typeKeyword: parenthesizedKeyword, options: parenthesizedOptions, } = (0, exports.checkType)(node.type);
36
- typeReference = parenthesizedReference;
37
- isArray = !!parenthesizedIsArray;
38
- typeKeyword = parenthesizedKeyword || "string";
39
- options = parenthesizedOptions;
40
- }
41
- else {
42
- typeKeyword = (0, getTypeKeyword_1.getTypeKeyword)(node);
43
- }
44
- return { typeReference, isArray, typeKeyword, options };
45
- };
46
- exports.checkType = checkType;
@@ -1,6 +0,0 @@
1
- import { UnionTypeNode } from "typescript";
2
- import { LiteralValue, TypeKeyword } from "../TypeInfo";
3
- export declare const checkUnionType: (unionType: UnionTypeNode) => {
4
- options: LiteralValue[] | undefined;
5
- typeKeyword: TypeKeyword;
6
- };