@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
@@ -0,0 +1,1760 @@
1
+ import { SyntaxKind, isLiteralTypeNode, isStringLiteral, isNumericLiteral, createSourceFile, ScriptTarget } from 'typescript';
2
+ import { promises } from 'fs';
3
+ import Path from 'path';
4
+ import { pathToFileURL } from 'url';
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+
12
+ // src/common/TypeParsing/index.ts
13
+ var TypeParsing_exports = {};
14
+ __export(TypeParsing_exports, {
15
+ Constants: () => Constants_exports,
16
+ TypeInfo: () => TypeInfo_exports,
17
+ TypeMapping: () => TypeMapping_exports,
18
+ Validation: () => Validation_exports,
19
+ getTypeInfoMapFromTypeScript: () => getTypeInfoMapFromTypeScript
20
+ });
21
+
22
+ // src/common/TypeParsing/TypeMapping.ts
23
+ var TypeMapping_exports = {};
24
+ __export(TypeMapping_exports, {
25
+ convertASTToMap: () => convertASTToMap
26
+ });
27
+ var convertASTToMap = (node, map = {}, parentName) => {
28
+ node.forEachChild((child) => {
29
+ const { kind: childKind } = child;
30
+ if (childKind === SyntaxKind.ModuleDeclaration) {
31
+ const moduleNode = child;
32
+ const { name: moduleName } = moduleNode;
33
+ const textModuleName = moduleName.getText();
34
+ const fullModuleName = parentName ? `${parentName}.${textModuleName}` : textModuleName;
35
+ convertASTToMap(moduleNode, map, fullModuleName);
36
+ }
37
+ if (childKind === SyntaxKind.ModuleBlock) {
38
+ convertASTToMap(child, map, parentName);
39
+ }
40
+ if (childKind === SyntaxKind.TypeAliasDeclaration) {
41
+ const typeAliasDec = child;
42
+ const {
43
+ name: { text: typeName }
44
+ } = typeAliasDec;
45
+ const fullTypeName = parentName ? `${parentName}.${typeName}` : typeName;
46
+ map[fullTypeName] = typeAliasDec;
47
+ }
48
+ });
49
+ return map;
50
+ };
51
+
52
+ // src/common/Routing.ts
53
+ var Routing_exports = {};
54
+ __export(Routing_exports, {
55
+ PATH_DELIMITER: () => PATH_DELIMITER,
56
+ getParamsAndTestPath: () => getParamsAndTestPath,
57
+ getPathArray: () => getPathArray,
58
+ getPathString: () => getPathString,
59
+ getPotentialJSONValue: () => getPotentialJSONValue,
60
+ mergeStringPaths: () => mergeStringPaths,
61
+ resolvePath: () => resolvePath
62
+ });
63
+ var PATH_DELIMITER = "/";
64
+ var getPotentialJSONValue = (value) => {
65
+ try {
66
+ return JSON.parse(value);
67
+ } catch (error) {
68
+ return value;
69
+ }
70
+ };
71
+ var getPathArray = (path, delimiter = PATH_DELIMITER, filterEmptyOutput = false, filterEmptyInput = true, useJson = true, uriDecodeParts = true) => path.split(delimiter).filter(filterEmptyInput ? (p) => p !== "" : () => true).map(uriDecodeParts ? decodeURIComponent : (x) => x).map(useJson ? getPotentialJSONValue : (p) => p).filter(filterEmptyOutput ? (p) => p ?? false : () => true);
72
+ var getPathString = (parts = [], delimiter = PATH_DELIMITER, filterEmptyInput = false, useJson = true, uriEncodeParts = false) => parts.filter(filterEmptyInput ? (p) => p ?? false : () => true).map(useJson ? (p) => JSON.stringify(p) : (x) => x).map(uriEncodeParts ? encodeURIComponent : (x) => x).join(delimiter);
73
+ var mergeStringPaths = (path1, path2, delimiter = PATH_DELIMITER, filterEmptyOutput = false, filterEmptyInput = true, useJson = true, uriEncodeParts = false) => getPathString(
74
+ [
75
+ ...getPathArray(
76
+ path1,
77
+ delimiter,
78
+ filterEmptyOutput,
79
+ filterEmptyInput,
80
+ useJson,
81
+ uriEncodeParts
82
+ ),
83
+ ...getPathArray(
84
+ path2,
85
+ delimiter,
86
+ filterEmptyOutput,
87
+ filterEmptyInput,
88
+ useJson,
89
+ uriEncodeParts
90
+ )
91
+ ],
92
+ delimiter,
93
+ filterEmptyInput,
94
+ useJson,
95
+ uriEncodeParts
96
+ );
97
+ var resolvePath = (currentPath, newPath) => {
98
+ const newSegments = getPathArray(newPath, PATH_DELIMITER, true);
99
+ let currentSegments = getPathArray(currentPath, PATH_DELIMITER, true);
100
+ if (newPath.startsWith("/")) {
101
+ currentSegments = [];
102
+ }
103
+ newSegments.forEach((segment) => {
104
+ if (segment === "..") {
105
+ if (currentSegments.length > 0) {
106
+ currentSegments.pop();
107
+ }
108
+ } else if (segment !== ".") {
109
+ currentSegments.push(segment);
110
+ }
111
+ });
112
+ return "/" + currentSegments.join("/");
113
+ };
114
+ var getParamsAndTestPath = (path, testPath, exact = false) => {
115
+ const pathList = getPathArray(path);
116
+ const testPathList = getPathArray(testPath);
117
+ if (exact && pathList.length !== testPathList.length) {
118
+ return false;
119
+ } else {
120
+ let params = {};
121
+ if (pathList.length >= testPathList.length) {
122
+ for (let i = 0; i < testPathList.length; i++) {
123
+ const testPathPart = testPathList[i];
124
+ const pathPart = pathList[i];
125
+ if (testPathPart.startsWith(":")) {
126
+ const paramName = testPathPart.slice(1);
127
+ params[paramName] = pathPart;
128
+ } else if (pathPart !== testPathPart) {
129
+ return false;
130
+ }
131
+ }
132
+ } else {
133
+ return false;
134
+ }
135
+ return params;
136
+ }
137
+ };
138
+
139
+ // src/common/TypeParsing/ParsingUtils/extractCommentTags.ts
140
+ var TAG_NAME_PATH_DELIMITER = ".";
141
+ var getFlatTagValue = (tagValue) => {
142
+ if (typeof tagValue === "undefined") {
143
+ return "";
144
+ } else if (Array.isArray(tagValue)) {
145
+ const valueNodeArray = tagValue;
146
+ const valueList = [];
147
+ for (let i = 0; i < valueNodeArray.length; i++) {
148
+ const { text } = valueNodeArray[i];
149
+ valueList.push(getFlatTagValue(text));
150
+ }
151
+ return valueList.join(" ");
152
+ } else {
153
+ return `${tagValue}`;
154
+ }
155
+ };
156
+ var getTagNameAndValue = (tag) => {
157
+ let name = tag.tagName.text, value = getFlatTagValue(tag.comment);
158
+ if (value.startsWith(TAG_NAME_PATH_DELIMITER)) {
159
+ const extendedTagNameEndIndex = value.indexOf(" ");
160
+ const hasActualValue = extendedTagNameEndIndex !== -1;
161
+ name += hasActualValue ? value.slice(0, extendedTagNameEndIndex) : value;
162
+ value = hasActualValue ? value.slice(extendedTagNameEndIndex + 1) : "";
163
+ }
164
+ if (value === "") {
165
+ value = "true";
166
+ }
167
+ return {
168
+ name,
169
+ value
170
+ };
171
+ };
172
+ var getObjectWithValueAppliedToPath = (path = [], value, baseObject) => {
173
+ let baseParentObject = void 0, currentParent = void 0;
174
+ if (path.length === 0) {
175
+ baseParentObject = value;
176
+ } else {
177
+ for (let i = 0; i < path.length; i++) {
178
+ const pathPart = path[i];
179
+ const cleanPathPart = typeof pathPart === "number" ? pathPart : `${typeof pathPart !== "undefined" ? pathPart : ""}`;
180
+ const isNum = typeof cleanPathPart === "number";
181
+ let newCurrentParent = void 0;
182
+ if (i === 0) {
183
+ if (!baseObject) {
184
+ baseParentObject = isNum ? [] : {};
185
+ } else {
186
+ baseParentObject = isNum ? [...Array.isArray(baseObject) ? baseObject : []] : {
187
+ ...typeof baseObject === "object" ? baseObject : {}
188
+ };
189
+ }
190
+ currentParent = baseParentObject;
191
+ }
192
+ if (i < path.length - 1) {
193
+ const existingNewCurrentParent = currentParent[cleanPathPart];
194
+ newCurrentParent = isNum ? [
195
+ ...Array.isArray(existingNewCurrentParent) ? existingNewCurrentParent : []
196
+ ] : {
197
+ ...typeof existingNewCurrentParent === "object" ? existingNewCurrentParent : {}
198
+ };
199
+ currentParent[cleanPathPart] = newCurrentParent;
200
+ currentParent = newCurrentParent;
201
+ } else {
202
+ currentParent[cleanPathPart] = value;
203
+ }
204
+ }
205
+ }
206
+ return baseParentObject;
207
+ };
208
+ var extractCommentTags = (node) => {
209
+ const jsDocComments = node["jsDoc"];
210
+ let commentTags = {};
211
+ if (jsDocComments) {
212
+ jsDocComments.forEach((jsDoc) => {
213
+ const tags = jsDoc.tags;
214
+ if (tags) {
215
+ tags.forEach((tag) => {
216
+ const { name: tagName, value: tagValue } = getTagNameAndValue(tag);
217
+ const potentialJSONValue = getPotentialJSONValue(tagValue);
218
+ commentTags = getObjectWithValueAppliedToPath(
219
+ getPathArray(tagName, TAG_NAME_PATH_DELIMITER),
220
+ potentialJSONValue,
221
+ commentTags
222
+ );
223
+ });
224
+ }
225
+ });
226
+ }
227
+ return commentTags;
228
+ };
229
+ var extractLiteralValues = (node) => {
230
+ const literalValues = [];
231
+ let detectedTypeKeyword;
232
+ for (const type of node.types) {
233
+ if (isLiteralTypeNode(type)) {
234
+ const literal = type.literal;
235
+ if (isStringLiteral(literal)) {
236
+ if (!detectedTypeKeyword) detectedTypeKeyword = "string";
237
+ if (detectedTypeKeyword === "string") {
238
+ literalValues.push(literal.text);
239
+ }
240
+ } else if (isNumericLiteral(literal)) {
241
+ if (!detectedTypeKeyword) detectedTypeKeyword = "number";
242
+ if (detectedTypeKeyword === "number") {
243
+ literalValues.push(Number(literal.text));
244
+ }
245
+ } else if (literal.kind === SyntaxKind.TrueKeyword || literal.kind === SyntaxKind.FalseKeyword) {
246
+ if (!detectedTypeKeyword) detectedTypeKeyword = "boolean";
247
+ if (detectedTypeKeyword === "boolean") {
248
+ literalValues.push(literal.kind === SyntaxKind.TrueKeyword);
249
+ }
250
+ } else if (literal.kind === SyntaxKind.NullKeyword) {
251
+ literalValues.push(null);
252
+ }
253
+ } else {
254
+ return void 0;
255
+ }
256
+ }
257
+ return literalValues.length ? { values: literalValues, type: detectedTypeKeyword } : void 0;
258
+ };
259
+
260
+ // src/common/TypeParsing/ParsingUtils/checkUnionType.ts
261
+ var checkUnionType = (unionType) => {
262
+ const extracted = extractLiteralValues(unionType);
263
+ let typeKeyword = "string";
264
+ let options;
265
+ if (extracted) {
266
+ options = extracted.values;
267
+ typeKeyword = extracted.type;
268
+ }
269
+ return { options: options || [], typeKeyword };
270
+ };
271
+ var getTypeKeyword = (node) => {
272
+ switch (node.kind) {
273
+ case SyntaxKind.StringKeyword:
274
+ return "string";
275
+ case SyntaxKind.NumberKeyword:
276
+ return "number";
277
+ case SyntaxKind.BooleanKeyword:
278
+ return "boolean";
279
+ default:
280
+ return "string";
281
+ }
282
+ };
283
+
284
+ // src/common/TypeParsing/ParsingUtils/checkType.ts
285
+ var checkType = (node) => {
286
+ let typeReference;
287
+ let isArray = false;
288
+ let typeKeyword;
289
+ let options;
290
+ if (node.kind === SyntaxKind.TypeReference) {
291
+ typeReference = node.typeName.getText();
292
+ typeKeyword = "string";
293
+ } else if (node.kind === SyntaxKind.ArrayType) {
294
+ isArray = true;
295
+ const elementType = node.elementType;
296
+ const {
297
+ typeReference: elementReference,
298
+ isArray: elementIsArray,
299
+ typeKeyword: elementKeyword,
300
+ options: elementOptions
301
+ } = checkType(elementType);
302
+ typeReference = elementReference;
303
+ isArray = !!elementIsArray;
304
+ typeKeyword = elementKeyword || "string";
305
+ options = elementOptions;
306
+ } else if (node.kind === SyntaxKind.UnionType) {
307
+ const { types: unionTypes } = node;
308
+ const { options: unionOptions, typeKeyword: unionTypeKeyword } = checkUnionType(node);
309
+ options = unionOptions;
310
+ typeKeyword = unionTypeKeyword;
311
+ if (!options) {
312
+ typeKeyword = getTypeKeyword(unionTypes[0]);
313
+ }
314
+ } else if (node.kind === SyntaxKind.ParenthesizedType) {
315
+ const {
316
+ typeReference: parenthesizedReference,
317
+ isArray: parenthesizedIsArray,
318
+ typeKeyword: parenthesizedKeyword,
319
+ options: parenthesizedOptions
320
+ } = checkType(node.type);
321
+ typeReference = parenthesizedReference;
322
+ isArray = !!parenthesizedIsArray;
323
+ typeKeyword = parenthesizedKeyword || "string";
324
+ options = parenthesizedOptions;
325
+ } else {
326
+ typeKeyword = getTypeKeyword(node);
327
+ }
328
+ return { typeReference, isArray, typeKeyword, options };
329
+ };
330
+
331
+ // src/common/TypeParsing/ParsingUtils/extractTypeDetails.ts
332
+ var extractTypeDetails = (type) => {
333
+ const { isArray, typeReference, options, typeKeyword } = checkType(type);
334
+ return {
335
+ type: typeKeyword || "string",
336
+ typeReference,
337
+ array: !!isArray,
338
+ options
339
+ };
340
+ };
341
+
342
+ // src/common/TypeParsing/ParsingUtils/getTypeInfoField.ts
343
+ var getTypeInfoField = (propertySignature) => {
344
+ const { type, modifiers } = propertySignature;
345
+ const {
346
+ array,
347
+ typeReference,
348
+ type: typeKeyword,
349
+ options
350
+ } = type ? extractTypeDetails(type) : {
351
+ array: false,
352
+ typeReference: void 0,
353
+ type: "string",
354
+ options: void 0
355
+ };
356
+ const readonly = modifiers ? modifiers.some((modifier) => modifier.kind === SyntaxKind.ReadonlyKeyword) : false;
357
+ const optional = !!propertySignature.questionToken;
358
+ let tags = extractCommentTags(propertySignature);
359
+ if (readonly) {
360
+ const {
361
+ deniedOperations,
362
+ deniedOperations: { CREATE, UPDATE, DELETE } = {}
363
+ } = tags || {};
364
+ tags = {
365
+ ...tags,
366
+ deniedOperations: {
367
+ ...deniedOperations,
368
+ create: CREATE ?? true,
369
+ update: UPDATE ?? true,
370
+ delete: DELETE ?? true
371
+ }
372
+ };
373
+ }
374
+ return {
375
+ type: typeKeyword,
376
+ array,
377
+ readonly,
378
+ optional,
379
+ typeReference,
380
+ possibleValues: options,
381
+ tags
382
+ };
383
+ };
384
+
385
+ // src/common/TypeParsing/ParsingUtils/getTypeInfo.ts
386
+ var getTypeInfo = (typeLiteral) => {
387
+ const { members } = typeLiteral;
388
+ const tags = extractCommentTags(typeLiteral);
389
+ let fields = {};
390
+ for (const m of members) {
391
+ const { name, kind } = m;
392
+ if (name && kind === SyntaxKind.PropertySignature) {
393
+ const fieldName = name.getText();
394
+ const field = getTypeInfoField(m);
395
+ fields = {
396
+ ...fields,
397
+ [fieldName]: field
398
+ };
399
+ }
400
+ }
401
+ return {
402
+ fields,
403
+ tags
404
+ };
405
+ };
406
+ var getUnionOrIntersectionTypeInfo = (unionType, typeMap) => {
407
+ const { kind, types } = unionType;
408
+ const isUnion = kind === SyntaxKind.UnionType;
409
+ let typeInfo;
410
+ for (const t of types) {
411
+ const { kind: kind2 } = t;
412
+ let nextTypeInfo;
413
+ if (kind2 === SyntaxKind.TypeReference) {
414
+ const { typeName } = t;
415
+ const refNode = typeMap[typeName.getText()];
416
+ if (refNode) {
417
+ nextTypeInfo = getTypeInfoFromTypeAlias(refNode, typeMap);
418
+ }
419
+ } else if (kind2 === SyntaxKind.TypeLiteral) {
420
+ nextTypeInfo = getTypeInfo(t);
421
+ }
422
+ if (nextTypeInfo) {
423
+ const {
424
+ fields: existingFields = {},
425
+ unionFieldSets: existingFieldSets = []
426
+ } = typeInfo || {};
427
+ const { fields: nextFields, unionFieldSets: nextUnionFieldSets = [] } = nextTypeInfo;
428
+ if (isUnion && nextFields) {
429
+ const newUnionFieldSet = Object.keys(nextFields);
430
+ typeInfo = {
431
+ ...typeInfo,
432
+ unionFieldSets: [
433
+ ...existingFieldSets,
434
+ ...nextUnionFieldSets,
435
+ newUnionFieldSet
436
+ ]
437
+ };
438
+ }
439
+ typeInfo = {
440
+ ...typeInfo,
441
+ fields: {
442
+ ...existingFields,
443
+ ...nextFields
444
+ }
445
+ };
446
+ }
447
+ }
448
+ return typeInfo;
449
+ };
450
+
451
+ // src/common/TypeParsing/ParsingUtils/Constants.ts
452
+ var FIELD_FILTERS = {
453
+ OMIT: "Omit",
454
+ PICK: "Pick",
455
+ EXCLUDE: "Exclude"
456
+ };
457
+ var getUnionOrLiteralStringValues = (node) => {
458
+ let values = [];
459
+ if (node) {
460
+ if (node.kind === SyntaxKind.LiteralType) {
461
+ const { literal } = node;
462
+ if (literal.kind === SyntaxKind.StringLiteral || literal.kind === SyntaxKind.NumericLiteral) {
463
+ const { text } = literal;
464
+ values = [text];
465
+ }
466
+ } else if (node.kind === SyntaxKind.UnionType) {
467
+ const { types } = node;
468
+ for (const type of types) {
469
+ values = [...values, ...getUnionOrLiteralStringValues(type)];
470
+ }
471
+ }
472
+ }
473
+ return values;
474
+ };
475
+
476
+ // src/common/TypeParsing/ParsingUtils/getTypeInfoFromFieldFilter.ts
477
+ var getTypeInfoFromPickOmitFieldFilters = (typeNameStr, typeRef, typeMap) => {
478
+ const picking = typeNameStr === FIELD_FILTERS.PICK;
479
+ const omitTypeKind = typeRef.typeArguments?.[0].kind;
480
+ let typeInfo;
481
+ if (omitTypeKind === SyntaxKind.TypeReference && typeRef.typeArguments && typeRef.typeArguments[0].kind === SyntaxKind.TypeReference) {
482
+ const omitType = typeRef.typeArguments[0];
483
+ const omitTypeFields = typeRef.typeArguments[1];
484
+ const omitTypeName = omitType.typeName.getText();
485
+ const refNode = typeMap[omitTypeName];
486
+ if (refNode) {
487
+ const {
488
+ fields: existingFields = {},
489
+ unionFieldSets: existingUnionFieldSets,
490
+ ...typeInfoOther
491
+ } = getTypeInfoFromTypeAlias(refNode, typeMap) || {};
492
+ const omitFieldNames = getUnionOrLiteralStringValues(omitTypeFields);
493
+ const cleanTypeInfoFields = Object.keys(
494
+ existingFields
495
+ ).reduce(
496
+ (acc, key) => {
497
+ if (acc && (picking && omitFieldNames.includes(key) || !picking && !omitFieldNames.includes(key)) && existingFields[key]) {
498
+ acc[key] = existingFields[key];
499
+ }
500
+ return acc;
501
+ },
502
+ {}
503
+ );
504
+ const cleanUnionFieldSets = existingUnionFieldSets ? existingUnionFieldSets.map(
505
+ (fieldSet) => fieldSet.filter(
506
+ (field) => picking ? omitFieldNames.includes(field) : !omitFieldNames.includes(field)
507
+ )
508
+ ) : void 0;
509
+ typeInfo = {
510
+ ...typeInfoOther,
511
+ fields: cleanTypeInfoFields,
512
+ unionFieldSets: cleanUnionFieldSets
513
+ };
514
+ }
515
+ }
516
+ return typeInfo;
517
+ };
518
+ var getTypeInfoFromExcludeFieldFilter = (typeNameStr, typeRef, typeMap) => {
519
+ const baseTypeKind = typeRef.typeArguments?.[0].kind;
520
+ const excludeTypeKind = typeRef.typeArguments?.[1].kind;
521
+ let typeInfo;
522
+ if (baseTypeKind === SyntaxKind.TypeReference && excludeTypeKind === SyntaxKind.TypeReference && typeRef.typeArguments) {
523
+ const baseType = typeRef.typeArguments[0];
524
+ const excludeType = typeRef.typeArguments[1];
525
+ const baseTypeName = baseType.typeName.getText();
526
+ const excludeTypeName = excludeType.typeName.getText();
527
+ const refNode = typeMap[baseTypeName];
528
+ const excludeNode = typeMap[excludeTypeName];
529
+ if (refNode && excludeNode) {
530
+ const baseTypeInfo = getTypeInfoFromTypeAlias(refNode, typeMap);
531
+ const excludeTypeInfo = getTypeInfoFromTypeAlias(excludeNode, typeMap);
532
+ if (baseTypeInfo && excludeTypeInfo) {
533
+ const {
534
+ fields: baseFields = {},
535
+ unionFieldSets: existingUnionFieldSets
536
+ } = baseTypeInfo;
537
+ const { fields: excludeFields = {} } = excludeTypeInfo;
538
+ const excludeFieldNames = Object.keys(excludeFields);
539
+ const cleanTypeInfoFields = Object.keys(
540
+ baseFields
541
+ ).reduce(
542
+ (acc, key) => {
543
+ if (acc && !excludeFieldNames.includes(key) && baseFields[key]) {
544
+ acc[key] = baseFields[key];
545
+ }
546
+ return acc;
547
+ },
548
+ {}
549
+ );
550
+ const cleanUnionFieldSets = existingUnionFieldSets ? existingUnionFieldSets.map(
551
+ (fieldSet) => fieldSet.filter((field) => !excludeFieldNames.includes(field))
552
+ ) : void 0;
553
+ typeInfo = {
554
+ ...baseTypeInfo,
555
+ fields: cleanTypeInfoFields,
556
+ unionFieldSets: cleanUnionFieldSets
557
+ };
558
+ }
559
+ }
560
+ }
561
+ return typeInfo;
562
+ };
563
+ var defaultFieldFilterProcessor = (typeNameStr, typeRef, typeMap) => {
564
+ const refNode = typeNameStr ? typeMap[typeNameStr] : void 0;
565
+ let typeInfo;
566
+ if (refNode) {
567
+ typeInfo = getTypeInfoFromTypeAlias(refNode, typeMap);
568
+ }
569
+ return typeInfo;
570
+ };
571
+ var FIELD_FILTER_PROCESSORS = {
572
+ [FIELD_FILTERS.PICK]: getTypeInfoFromPickOmitFieldFilters,
573
+ [FIELD_FILTERS.OMIT]: getTypeInfoFromPickOmitFieldFilters,
574
+ [FIELD_FILTERS.EXCLUDE]: getTypeInfoFromExcludeFieldFilter
575
+ };
576
+ var getTypeInfoFromFieldFilter = (typeNameStr, typeRef, typeMap) => {
577
+ const processor = typeNameStr ? FIELD_FILTER_PROCESSORS[typeNameStr] : void 0;
578
+ return processor ? processor(typeNameStr, typeRef, typeMap) : defaultFieldFilterProcessor(typeNameStr, typeRef, typeMap);
579
+ };
580
+
581
+ // src/common/TypeParsing/ParsingUtils/getTypeInfoFromAliasType.ts
582
+ var getTypeInfoFromTypeLiteral = (type) => getTypeInfo(type);
583
+ var getTypeInfoFromUnionOrIntersectionType = (type, typeMap) => getUnionOrIntersectionTypeInfo(type, typeMap);
584
+ var getTypeInfoFromTypeReference = (type, typeMap) => {
585
+ const typeRef = type;
586
+ const { typeName } = typeRef;
587
+ const typeNameStr = typeName.getText();
588
+ return getTypeInfoFromFieldFilter(typeNameStr, typeRef, typeMap);
589
+ };
590
+ var ALIAS_TYPE_PROCESSORS = {
591
+ [SyntaxKind.TypeLiteral]: getTypeInfoFromTypeLiteral,
592
+ [SyntaxKind.UnionType]: getTypeInfoFromUnionOrIntersectionType,
593
+ [SyntaxKind.IntersectionType]: getTypeInfoFromUnionOrIntersectionType,
594
+ [SyntaxKind.TypeReference]: getTypeInfoFromTypeReference
595
+ };
596
+ var getTypeInfoFromAliasType = (type, typeMap) => {
597
+ const { kind } = type;
598
+ const processor = ALIAS_TYPE_PROCESSORS[kind];
599
+ const typeInfo = processor ? processor(type, typeMap) : void 0;
600
+ return typeInfo;
601
+ };
602
+
603
+ // src/common/TypeParsing/ParsingUtils/getTypeInfoFromTypeAlias.ts
604
+ var getTypeInfoFromTypeAlias = (typeAliasDec, typeMap) => {
605
+ const { type } = typeAliasDec;
606
+ const tags = extractCommentTags(typeAliasDec);
607
+ const typeInfo = getTypeInfoFromAliasType(type, typeMap);
608
+ return typeInfo ? {
609
+ ...typeInfo,
610
+ tags: {
611
+ ...tags,
612
+ ...typeInfo.tags
613
+ }
614
+ } : void 0;
615
+ };
616
+
617
+ // src/common/TypeParsing/ParsingUtils/getPrimaryFieldForTypeInfo.ts
618
+ var getPrimaryFieldForTypeInfo = (typeInfo) => {
619
+ const { fields } = typeInfo;
620
+ let primaryField = void 0, primaryFieldReadDenied = false;
621
+ for (const fieldName in fields) {
622
+ const field = fields[fieldName];
623
+ const {
624
+ tags: {
625
+ primaryField: isPrimaryField = false,
626
+ deniedOperations: { READ: readDenied = false } = {}
627
+ } = {}
628
+ } = field;
629
+ if (isPrimaryField || !primaryField) {
630
+ primaryField = fieldName;
631
+ primaryFieldReadDenied = readDenied;
632
+ }
633
+ if (isPrimaryField) {
634
+ break;
635
+ }
636
+ }
637
+ if (primaryFieldReadDenied) {
638
+ throw new Error(
639
+ "READ_DENIED_PRIMARY_FIELD_NOT_SUPPORTED" /* READ_DENIED_PRIMARY_FIELD_NOT_SUPPORTED */
640
+ );
641
+ }
642
+ return primaryField;
643
+ };
644
+
645
+ // src/common/TypeParsing/TypeParsing.ts
646
+ var getTypeInfoMapFromTypeScript = (source) => {
647
+ const typeScriptNode = createSourceFile(
648
+ "x.ts",
649
+ source,
650
+ ScriptTarget.Latest,
651
+ true
652
+ );
653
+ const typeMap = convertASTToMap(typeScriptNode, {});
654
+ const typeInfoMap = {};
655
+ for (const key in typeMap) {
656
+ const typeAliasDec = typeMap[key];
657
+ const { modifiers } = typeAliasDec;
658
+ let outputTypeInfo = false;
659
+ if (modifiers) {
660
+ modifiers.forEach((modifier) => {
661
+ const { kind } = modifier;
662
+ if (kind === SyntaxKind.ExportKeyword) {
663
+ outputTypeInfo = true;
664
+ }
665
+ });
666
+ }
667
+ if (outputTypeInfo) {
668
+ const typeInfo = getTypeInfoFromTypeAlias(typeAliasDec, typeMap);
669
+ if (typeInfo) {
670
+ typeInfoMap[key] = {
671
+ ...typeInfo,
672
+ primaryField: getPrimaryFieldForTypeInfo(typeInfo)
673
+ };
674
+ }
675
+ }
676
+ }
677
+ return typeInfoMap;
678
+ };
679
+
680
+ // src/common/TypeParsing/Validation.ts
681
+ var Validation_exports = {};
682
+ __export(Validation_exports, {
683
+ DENIED_TYPE_OPERATIONS: () => DENIED_TYPE_OPERATIONS,
684
+ ERROR_MESSAGE_CONSTANTS: () => ERROR_MESSAGE_CONSTANTS,
685
+ INVALID_CUSTOM_TYPE: () => INVALID_CUSTOM_TYPE,
686
+ PRIMITIVE_ERROR_MESSAGE_CONSTANTS: () => PRIMITIVE_ERROR_MESSAGE_CONSTANTS,
687
+ RelationshipValidationType: () => RelationshipValidationType,
688
+ TYPE_KEYWORD_VALIDATORS: () => TYPE_KEYWORD_VALIDATORS,
689
+ getValidityValue: () => getValidityValue,
690
+ hasValue: () => hasValue,
691
+ validateArrayOfTypeInfoFieldValues: () => validateArrayOfTypeInfoFieldValues,
692
+ validateCustomType: () => validateCustomType,
693
+ validateKeywordType: () => validateKeywordType,
694
+ validateTypeInfoFieldOperationAllowed: () => validateTypeInfoFieldOperationAllowed,
695
+ validateTypeInfoFieldValue: () => validateTypeInfoFieldValue,
696
+ validateTypeInfoValue: () => validateTypeInfoValue,
697
+ validateTypeOperationAllowed: () => validateTypeOperationAllowed,
698
+ validateValueMatchesPattern: () => validateValueMatchesPattern
699
+ });
700
+
701
+ // src/common/TypeParsing/TypeInfo.ts
702
+ var TypeInfo_exports = {};
703
+ __export(TypeInfo_exports, {
704
+ TypeOperation: () => TypeOperation
705
+ });
706
+ var TypeOperation = /* @__PURE__ */ ((TypeOperation2) => {
707
+ TypeOperation2["CREATE"] = "CREATE";
708
+ TypeOperation2["READ"] = "READ";
709
+ TypeOperation2["UPDATE"] = "UPDATE";
710
+ TypeOperation2["DELETE"] = "DELETE";
711
+ return TypeOperation2;
712
+ })(TypeOperation || {});
713
+
714
+ // src/common/TypeParsing/Validation.ts
715
+ var RelationshipValidationType = /* @__PURE__ */ ((RelationshipValidationType2) => {
716
+ RelationshipValidationType2["INCLUDE"] = "INCLUDE";
717
+ RelationshipValidationType2["EXCLUDE"] = "EXCLUDE";
718
+ RelationshipValidationType2["STRICT_EXCLUDE"] = "STRICT_EXCLUDE";
719
+ return RelationshipValidationType2;
720
+ })(RelationshipValidationType || {});
721
+ var INVALID_CUSTOM_TYPE = "INVALID_CUSTOM_TYPE";
722
+ var PRIMITIVE_ERROR_MESSAGE_CONSTANTS = {
723
+ string: "NOT_A_STRING",
724
+ number: "NOT_A_NUMBER",
725
+ boolean: "NOT_A_BOOLEAN"
726
+ };
727
+ var ERROR_MESSAGE_CONSTANTS = {
728
+ MISSING: "MISSING",
729
+ INVALID_OPTION: "INVALID_OPTION",
730
+ INVALID_FIELD: "INVALID_FIELD",
731
+ RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED: "RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED",
732
+ INVALID_TYPE: "INVALID_TYPE",
733
+ NO_UNION_TYPE_MATCHED: "NO_UNION_TYPE_MATCHED",
734
+ TYPE_DOES_NOT_EXIST: "TYPE_DOES_NOT_EXIST",
735
+ INVALID_PATTERN: "INVALID_PATTERN",
736
+ VALUE_DOES_NOT_MATCH_PATTERN: "VALUE_DOES_NOT_MATCH_PATTERN"
737
+ };
738
+ var DENIED_TYPE_OPERATIONS = {
739
+ CREATE: "DENIED_TYPE_OPERATION_CREATE",
740
+ READ: "DENIED_TYPE_OPERATION_READ",
741
+ UPDATE: "DENIED_TYPE_OPERATION_UPDATE",
742
+ DELETE: "DENIED_TYPE_OPERATION_DELETE"
743
+ };
744
+ var validateValueMatchesPattern = (typeName, value, pattern) => {
745
+ const results = {
746
+ typeName,
747
+ valid: true,
748
+ error: "",
749
+ errorMap: {}
750
+ };
751
+ const valueSupplied = typeof value !== "undefined";
752
+ const patternSupplied = typeof pattern === "string" && pattern.trim() !== "";
753
+ if (!valueSupplied || !patternSupplied) {
754
+ try {
755
+ const regex = new RegExp(pattern);
756
+ const testResult = typeof value === "string" && regex.test(value);
757
+ if (!testResult) {
758
+ results.valid = false;
759
+ results.error = ERROR_MESSAGE_CONSTANTS.VALUE_DOES_NOT_MATCH_PATTERN;
760
+ }
761
+ } catch (e) {
762
+ results.valid = false;
763
+ results.error = ERROR_MESSAGE_CONSTANTS.INVALID_PATTERN;
764
+ }
765
+ }
766
+ return results;
767
+ };
768
+ var getValidityValue = (existing, pending) => !existing ? false : pending;
769
+ var TYPE_KEYWORD_VALIDATORS = {
770
+ string: (value) => typeof value === "string",
771
+ number: (value) => typeof value === "number",
772
+ boolean: (value) => typeof value === "boolean"
773
+ };
774
+ var hasValue = (value) => value ?? false;
775
+ var validateKeywordType = (value, type) => {
776
+ const validator = TYPE_KEYWORD_VALIDATORS[type];
777
+ let valid = true;
778
+ if (validator) {
779
+ valid = validator(value);
780
+ }
781
+ return valid;
782
+ };
783
+ var validateCustomType = (value, customType, customValidators) => {
784
+ let valid = true;
785
+ if (customValidators && customType) {
786
+ const validator = customValidators[customType];
787
+ if (validator) {
788
+ try {
789
+ valid = validator(value);
790
+ } catch (e) {
791
+ valid = false;
792
+ }
793
+ }
794
+ }
795
+ return valid;
796
+ };
797
+ var validateTypeInfoFieldValue = (value, typeInfoField, typeInfoMap, ignoreArray = false, strict = false, customValidators, typeOperation, relationshipValidationType = "STRICT_EXCLUDE" /* STRICT_EXCLUDE */, itemIsPartial) => {
798
+ const {
799
+ type,
800
+ typeReference,
801
+ array,
802
+ optional,
803
+ possibleValues,
804
+ tags: { customType, constraints: { pattern = void 0 } = {} } = {}
805
+ } = typeInfoField;
806
+ const results = {
807
+ typeName: typeReference ?? type,
808
+ valid: true,
809
+ error: "",
810
+ errorMap: {}
811
+ };
812
+ const requiredValueAllowed = !typeReference || relationshipValidationType === "INCLUDE" /* INCLUDE */;
813
+ if (requiredValueAllowed && !itemIsPartial && !optional && !hasValue(value)) {
814
+ results.valid = false;
815
+ results.error = ERROR_MESSAGE_CONSTANTS.MISSING;
816
+ } else if (array && !ignoreArray) {
817
+ const {
818
+ valid: validArray,
819
+ error: arrayError,
820
+ errorMap: arrayErrorMap
821
+ } = validateArrayOfTypeInfoFieldValues(
822
+ value,
823
+ typeInfoField,
824
+ typeInfoMap,
825
+ strict,
826
+ customValidators,
827
+ typeOperation,
828
+ relationshipValidationType,
829
+ itemIsPartial
830
+ );
831
+ results.valid = getValidityValue(results.valid, validArray);
832
+ results.error = arrayError;
833
+ results.errorMap = arrayErrorMap;
834
+ } else {
835
+ if (typeReference) {
836
+ if (relationshipValidationType === "INCLUDE" /* INCLUDE */) {
837
+ const {
838
+ valid: validTypeInfo,
839
+ error: typeInfoError,
840
+ errorMap: typeInfoErrorMap
841
+ } = validateTypeInfoValue(
842
+ value,
843
+ typeReference,
844
+ typeInfoMap,
845
+ strict,
846
+ customValidators,
847
+ typeOperation,
848
+ relationshipValidationType,
849
+ itemIsPartial
850
+ );
851
+ results.valid = getValidityValue(results.valid, validTypeInfo);
852
+ results.error = typeInfoError;
853
+ results.errorMap = typeInfoErrorMap;
854
+ } else if (relationshipValidationType === "STRICT_EXCLUDE" /* STRICT_EXCLUDE */) {
855
+ const valueSupplied = typeof value !== "undefined";
856
+ if (valueSupplied) {
857
+ results.valid = false;
858
+ results.error = ERROR_MESSAGE_CONSTANTS.RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED;
859
+ }
860
+ } else if (relationshipValidationType === "EXCLUDE" /* EXCLUDE */) {
861
+ results.valid = getValidityValue(results.valid, true);
862
+ }
863
+ } else if (possibleValues && !possibleValues.includes(value)) {
864
+ results.valid = false;
865
+ results.error = ERROR_MESSAGE_CONSTANTS.INVALID_OPTION;
866
+ } else {
867
+ const pendingValid = validateKeywordType(value, type);
868
+ const customValid = validateCustomType(
869
+ value,
870
+ customType,
871
+ customValidators
872
+ );
873
+ results.valid = getValidityValue(results.valid, pendingValid);
874
+ results.valid = getValidityValue(results.valid, customValid);
875
+ if (type === "string" && typeof pattern === "string") {
876
+ const { valid: patternValid, error: patternError } = validateValueMatchesPattern(value, pattern);
877
+ results.valid = getValidityValue(results.valid, patternValid);
878
+ results.error = patternError;
879
+ }
880
+ if (!customValid) {
881
+ results.error = INVALID_CUSTOM_TYPE;
882
+ } else if (!results.valid) {
883
+ results.error = results.error ? results.error : PRIMITIVE_ERROR_MESSAGE_CONSTANTS[type];
884
+ }
885
+ }
886
+ }
887
+ return results;
888
+ };
889
+ var validateArrayOfTypeInfoFieldValues = (values = [], typeInfoField, typeInfoMap, strict = false, customValidators, typeOperation, relationshipValidationType, itemIsPartial) => {
890
+ const { type, typeReference } = typeInfoField;
891
+ const results = {
892
+ typeName: typeReference ?? type,
893
+ valid: true,
894
+ error: "",
895
+ errorMap: {}
896
+ };
897
+ for (let i = 0; i < values.length; i++) {
898
+ const v = values[i];
899
+ const {
900
+ valid: indexValid,
901
+ error: indexError = "",
902
+ errorMap: indexErrorMap
903
+ } = validateTypeInfoFieldValue(
904
+ v,
905
+ typeInfoField,
906
+ typeInfoMap,
907
+ true,
908
+ strict,
909
+ customValidators,
910
+ typeOperation,
911
+ relationshipValidationType,
912
+ itemIsPartial
913
+ );
914
+ results.valid = getValidityValue(results.valid, indexValid);
915
+ results.errorMap[getPathString([i])] = [indexError];
916
+ for (const er in indexErrorMap) {
917
+ results.errorMap[getPathString([i, er])] = indexErrorMap[er];
918
+ }
919
+ }
920
+ return results;
921
+ };
922
+ var validateTypeInfoFieldOperationAllowed = (fieldName, fieldOperation, typeInfoField) => {
923
+ const results = {
924
+ typeName: null,
925
+ valid: true,
926
+ error: "",
927
+ errorMap: {}
928
+ };
929
+ if (fieldOperation && typeInfoField) {
930
+ const {
931
+ type,
932
+ typeReference,
933
+ tags = {}
934
+ } = typeInfoField || {};
935
+ const { deniedOperations: { [fieldOperation]: denied = false } = {} } = tags;
936
+ results.typeName = typeReference ?? type;
937
+ results.valid = !denied;
938
+ if (!results.valid) {
939
+ results.error = DENIED_TYPE_OPERATIONS[fieldOperation];
940
+ results.errorMap[fieldName] = [results.error];
941
+ }
942
+ }
943
+ return results;
944
+ };
945
+ var validateTypeOperationAllowed = (typeName, valueFields, typeOperation, typeInfo) => {
946
+ const results = {
947
+ typeName,
948
+ valid: true,
949
+ error: "",
950
+ errorMap: {}
951
+ };
952
+ const { fields = {}, tags = {} } = typeInfo;
953
+ const { deniedOperations: { [typeOperation]: denied = false } = {} } = tags;
954
+ if (denied) {
955
+ results.valid = false;
956
+ results.error = DENIED_TYPE_OPERATIONS[typeOperation];
957
+ } else {
958
+ for (const vF of valueFields) {
959
+ const vFieldInfo = fields[vF];
960
+ const { valid: vFValid, error: vFError } = validateTypeInfoFieldOperationAllowed(vF, typeOperation, vFieldInfo);
961
+ results.valid = getValidityValue(results.valid, vFValid);
962
+ if (!vFValid) {
963
+ results.errorMap[vF] = [vFError];
964
+ }
965
+ }
966
+ }
967
+ return results;
968
+ };
969
+ var validateTypeInfoValue = (value, typeInfoFullName, typeInfoMap, strict = false, customValidators, typeOperation, relationshipValidationType, itemIsPartial) => {
970
+ const typeInfo = typeInfoMap[typeInfoFullName];
971
+ const results = {
972
+ typeName: typeInfoFullName,
973
+ valid: !!typeInfo,
974
+ error: !!typeInfo ? "" : ERROR_MESSAGE_CONSTANTS.TYPE_DOES_NOT_EXIST,
975
+ errorMap: {}
976
+ };
977
+ if (typeInfo) {
978
+ const { primaryField, fields, unionFieldSets } = typeInfo;
979
+ if (typeOperation) {
980
+ const valueFields = typeof value === "object" ? Object.keys(value ?? {}) : [];
981
+ const {
982
+ valid: operationValid,
983
+ error: operationError,
984
+ errorMap: operationErrorMap
985
+ } = validateTypeOperationAllowed(
986
+ typeInfoFullName,
987
+ valueFields,
988
+ typeOperation,
989
+ typeInfo
990
+ );
991
+ results.valid = getValidityValue(results.valid, operationValid);
992
+ results.error = operationError;
993
+ for (const oE in operationErrorMap) {
994
+ const existingError = results.errorMap[oE] ?? [];
995
+ results.errorMap[oE] = existingError ? [...existingError, ...operationErrorMap[oE]] : operationErrorMap[oE];
996
+ }
997
+ if (!operationValid && operationError) {
998
+ results.error = operationError;
999
+ }
1000
+ }
1001
+ if (unionFieldSets) {
1002
+ const valueFields = Object.keys(value || {});
1003
+ let valid = false;
1004
+ for (const uFS of unionFieldSets) {
1005
+ valid = valueFields.every((vF) => uFS.includes(vF));
1006
+ if (valid) {
1007
+ break;
1008
+ }
1009
+ }
1010
+ if (!valid) {
1011
+ results.valid = false;
1012
+ results.error = ERROR_MESSAGE_CONSTANTS.NO_UNION_TYPE_MATCHED;
1013
+ }
1014
+ } else if (strict) {
1015
+ const knownFields = Object.keys(fields || {});
1016
+ const valueFields = Object.keys(value || {});
1017
+ for (const vF of valueFields) {
1018
+ if (!knownFields.includes(vF)) {
1019
+ results.valid = false;
1020
+ results.errorMap[vF] = [ERROR_MESSAGE_CONSTANTS.INVALID_FIELD];
1021
+ }
1022
+ }
1023
+ }
1024
+ if (fields) {
1025
+ for (const key in fields) {
1026
+ if (typeOperation !== "CREATE" /* CREATE */ || typeof primaryField !== "string" || key !== primaryField) {
1027
+ const typeInfoField = fields[key];
1028
+ const fieldValue = value[key];
1029
+ const {
1030
+ valid: fieldValid,
1031
+ error: fieldError,
1032
+ errorMap: fieldErrorMap
1033
+ } = validateTypeInfoFieldValue(
1034
+ fieldValue,
1035
+ typeInfoField,
1036
+ typeInfoMap,
1037
+ false,
1038
+ strict,
1039
+ customValidators,
1040
+ typeOperation,
1041
+ relationshipValidationType,
1042
+ itemIsPartial
1043
+ );
1044
+ results.valid = getValidityValue(results.valid, fieldValid);
1045
+ results.errorMap[key] = [fieldError];
1046
+ for (const fE in fieldErrorMap) {
1047
+ results.errorMap[getPathString([key, fE])] = fieldErrorMap[fE];
1048
+ }
1049
+ }
1050
+ }
1051
+ }
1052
+ if (!results.valid && !results.error) {
1053
+ results.error = ERROR_MESSAGE_CONSTANTS.INVALID_TYPE;
1054
+ }
1055
+ }
1056
+ return results;
1057
+ };
1058
+
1059
+ // src/common/TypeParsing/Constants.ts
1060
+ var Constants_exports = {};
1061
+ __export(Constants_exports, {
1062
+ BUILTIN_TYPE_NAMES: () => BUILTIN_TYPE_NAMES
1063
+ });
1064
+ var BUILTIN_TYPE_NAMES = [
1065
+ "string",
1066
+ "number",
1067
+ "boolean",
1068
+ "null",
1069
+ "object",
1070
+ "array",
1071
+ "any",
1072
+ "unknown",
1073
+ "never"
1074
+ ];
1075
+
1076
+ // src/common/IdGeneration/index.ts
1077
+ var IdGeneration_exports = {};
1078
+ __export(IdGeneration_exports, {
1079
+ getSimpleId: () => getSimpleId
1080
+ });
1081
+
1082
+ // src/common/IdGeneration/getSimpleId.ts
1083
+ var LAST_HAST_ID = 0;
1084
+ var getBase64EncodedString = (input) => Buffer.from(input).toString("base64");
1085
+ var getSimpleId = () => {
1086
+ const hashId = LAST_HAST_ID++;
1087
+ const base64Datetime = getBase64EncodedString(
1088
+ (/* @__PURE__ */ new Date()).toISOString()
1089
+ );
1090
+ const rand1 = Math.random().toString(36).substring(2, 15);
1091
+ const rand2 = Math.random().toString(36).substring(2, 15);
1092
+ return `${hashId}-${base64Datetime}-${rand1}-${rand2}`;
1093
+ };
1094
+
1095
+ // src/common/SearchTypes.ts
1096
+ var SearchTypes_exports = {};
1097
+ __export(SearchTypes_exports, {
1098
+ ComparisonOperators: () => ComparisonOperators,
1099
+ LogicalOperators: () => LogicalOperators
1100
+ });
1101
+ var LogicalOperators = /* @__PURE__ */ ((LogicalOperators2) => {
1102
+ LogicalOperators2["AND"] = "AND";
1103
+ LogicalOperators2["OR"] = "OR";
1104
+ return LogicalOperators2;
1105
+ })(LogicalOperators || {});
1106
+ var ComparisonOperators = /* @__PURE__ */ ((ComparisonOperators2) => {
1107
+ ComparisonOperators2["EQUALS"] = "EQUALS";
1108
+ ComparisonOperators2["NOT_EQUALS"] = "NOT_EQUALS";
1109
+ ComparisonOperators2["GREATER_THAN"] = "GREATER_THAN";
1110
+ ComparisonOperators2["GREATER_THAN_OR_EQUAL"] = "GREATER_THAN_OR_EQUAL";
1111
+ ComparisonOperators2["LESS_THAN"] = "LESS_THAN";
1112
+ ComparisonOperators2["LESS_THAN_OR_EQUAL"] = "LESS_THAN_OR_EQUAL";
1113
+ ComparisonOperators2["IN"] = "IN";
1114
+ ComparisonOperators2["NOT_IN"] = "NOT_IN";
1115
+ ComparisonOperators2["LIKE"] = "LIKE";
1116
+ ComparisonOperators2["NOT_LIKE"] = "NOT_LIKE";
1117
+ ComparisonOperators2["EXISTS"] = "EXISTS";
1118
+ ComparisonOperators2["NOT_EXISTS"] = "NOT_EXISTS";
1119
+ ComparisonOperators2["IS_NOT_EMPTY"] = "IS_NOT_EMPTY";
1120
+ ComparisonOperators2["IS_EMPTY"] = "IS_EMPTY";
1121
+ ComparisonOperators2["BETWEEN"] = "BETWEEN";
1122
+ ComparisonOperators2["NOT_BETWEEN"] = "NOT_BETWEEN";
1123
+ ComparisonOperators2["CONTAINS"] = "CONTAINS";
1124
+ ComparisonOperators2["NOT_CONTAINS"] = "NOT_CONTAINS";
1125
+ ComparisonOperators2["STARTS_WITH"] = "STARTS_WITH";
1126
+ ComparisonOperators2["ENDS_WITH"] = "ENDS_WITH";
1127
+ ComparisonOperators2["DOES_NOT_START_WITH"] = "DOES_NOT_START_WITH";
1128
+ ComparisonOperators2["DOES_NOT_END_WITH"] = "DOES_NOT_END_WITH";
1129
+ return ComparisonOperators2;
1130
+ })(ComparisonOperators || {});
1131
+
1132
+ // src/common/SearchUtils.ts
1133
+ var SearchUtils_exports = {};
1134
+ __export(SearchUtils_exports, {
1135
+ COMPARATORS: () => COMPARATORS,
1136
+ compare: () => compare,
1137
+ compareArray: () => compareArray,
1138
+ getFilterTypeInfoDataItemsBySearchCriteria: () => getFilterTypeInfoDataItemsBySearchCriteria,
1139
+ getSortedItems: () => getSortedItems
1140
+ });
1141
+ var COMPARATORS = {
1142
+ ["EQUALS" /* EQUALS */]: (criterionValue, criterionValueOptions, fieldValue) => fieldValue === criterionValue,
1143
+ ["NOT_EQUALS" /* NOT_EQUALS */]: (criterionValue, criterionValueOptions, fieldValue) => fieldValue !== criterionValue,
1144
+ ["GREATER_THAN" /* GREATER_THAN */]: (criterionValue, criterionValueOptions, fieldValue) => fieldValue > criterionValue,
1145
+ ["GREATER_THAN_OR_EQUAL" /* GREATER_THAN_OR_EQUAL */]: (criterionValue, criterionValueOptions, fieldValue) => fieldValue >= criterionValue,
1146
+ ["LESS_THAN" /* LESS_THAN */]: (criterionValue, criterionValueOptions, fieldValue) => fieldValue < criterionValue,
1147
+ ["LESS_THAN_OR_EQUAL" /* LESS_THAN_OR_EQUAL */]: (criterionValue, criterionValueOptions, fieldValue) => fieldValue <= criterionValue,
1148
+ ["IN" /* IN */]: (criterionValue, criterionValueOptions, fieldValue) => Array.isArray(criterionValueOptions) && criterionValueOptions.includes(fieldValue),
1149
+ ["NOT_IN" /* NOT_IN */]: (criterionValue, criterionValueOptions, fieldValue) => !Array.isArray(criterionValueOptions) || !criterionValueOptions.includes(fieldValue),
1150
+ ["LIKE" /* LIKE */]: (criterionValue, criterionValueOptions, fieldValue) => `${fieldValue}`.includes(`${criterionValue}`),
1151
+ ["NOT_LIKE" /* NOT_LIKE */]: (criterionValue, criterionValueOptions, fieldValue) => !`${fieldValue}`.includes(`${criterionValue}`),
1152
+ ["EXISTS" /* EXISTS */]: (criterionValue, criterionValueOptions, fieldValue) => fieldValue !== void 0 && fieldValue !== null,
1153
+ ["NOT_EXISTS" /* NOT_EXISTS */]: (criterionValue, criterionValueOptions, fieldValue) => fieldValue === void 0 || fieldValue === null,
1154
+ ["IS_NOT_EMPTY" /* IS_NOT_EMPTY */]: (criterionValue, criterionValueOptions, fieldValue) => fieldValue !== void 0 && fieldValue !== null && fieldValue !== "",
1155
+ ["IS_EMPTY" /* IS_EMPTY */]: (criterionValue, criterionValueOptions, fieldValue) => fieldValue === void 0 || fieldValue === null || fieldValue === "",
1156
+ ["BETWEEN" /* BETWEEN */]: (criterionValue, criterionValueOptions, fieldValue) => Array.isArray(criterionValueOptions) && fieldValue >= criterionValueOptions[0] && fieldValue <= criterionValueOptions[1],
1157
+ ["NOT_BETWEEN" /* NOT_BETWEEN */]: (criterionValue, criterionValueOptions, fieldValue) => !Array.isArray(criterionValueOptions) || fieldValue < criterionValueOptions[0] || fieldValue > criterionValueOptions[1],
1158
+ ["CONTAINS" /* CONTAINS */]: (criterionValue, criterionValueOptions, fieldValue) => Array.isArray(fieldValue) && fieldValue.includes(criterionValue),
1159
+ ["NOT_CONTAINS" /* NOT_CONTAINS */]: (criterionValue, criterionValueOptions, fieldValue) => !Array.isArray(fieldValue) || !fieldValue.includes(criterionValue),
1160
+ ["STARTS_WITH" /* STARTS_WITH */]: (criterionValue, criterionValueOptions, fieldValue) => `${fieldValue}`.startsWith(`${criterionValue}`),
1161
+ ["ENDS_WITH" /* ENDS_WITH */]: (criterionValue, criterionValueOptions, fieldValue) => `${fieldValue}`.endsWith(`${criterionValue}`),
1162
+ ["DOES_NOT_START_WITH" /* DOES_NOT_START_WITH */]: (criterionValue, criterionValueOptions, fieldValue) => !`${fieldValue}`.startsWith(`${criterionValue}`),
1163
+ ["DOES_NOT_END_WITH" /* DOES_NOT_END_WITH */]: (criterionValue, criterionValueOptions, fieldValue) => !`${fieldValue}`.endsWith(`${criterionValue}`)
1164
+ };
1165
+ var compare = (fieldCriterion, fieldValue) => {
1166
+ const {
1167
+ operator,
1168
+ value: criterionValue,
1169
+ valueOptions: criterionValueOptions
1170
+ } = fieldCriterion;
1171
+ const comparator = operator ? COMPARATORS[operator] : void 0;
1172
+ if (comparator) {
1173
+ return comparator(criterionValue, criterionValueOptions, fieldValue);
1174
+ } else {
1175
+ return false;
1176
+ }
1177
+ };
1178
+ var compareArray = (fieldCriterion, fieldValue) => {
1179
+ if (Array.isArray(fieldValue)) {
1180
+ const { operator } = fieldCriterion;
1181
+ const isArrayOperator = operator === "CONTAINS" /* CONTAINS */ || operator === "NOT_CONTAINS" /* NOT_CONTAINS */;
1182
+ return isArrayOperator ? compare(fieldCriterion, fieldValue) : fieldValue.some((value) => compare(fieldCriterion, value));
1183
+ } else {
1184
+ return false;
1185
+ }
1186
+ };
1187
+ var getFilterTypeInfoDataItemsBySearchCriteria = (searchCriteria, items, typeInfoName, typeInfoMap) => {
1188
+ const { fields = {} } = typeInfoMap?.[typeInfoName] || {};
1189
+ const { logicalOperator = "AND" /* AND */, fieldCriteria = [] } = searchCriteria;
1190
+ const filteredItems = [];
1191
+ for (const currentItem of items) {
1192
+ if (typeof currentItem === "object" && currentItem !== null) {
1193
+ let meetsCriteria = true;
1194
+ for (const fieldCriterion of fieldCriteria) {
1195
+ const { fieldName } = fieldCriterion;
1196
+ const { array: isArrayType, typeReference } = fields[fieldName] || {};
1197
+ const currentFieldValue = currentItem[fieldName];
1198
+ if (!typeReference) {
1199
+ const result = isArrayType ? compareArray(
1200
+ fieldCriterion,
1201
+ currentFieldValue
1202
+ ) : compare(fieldCriterion, currentFieldValue);
1203
+ if (logicalOperator === "AND" /* AND */) {
1204
+ meetsCriteria = result;
1205
+ if (!meetsCriteria) {
1206
+ break;
1207
+ }
1208
+ } else {
1209
+ meetsCriteria = meetsCriteria || result;
1210
+ if (meetsCriteria) {
1211
+ break;
1212
+ }
1213
+ }
1214
+ }
1215
+ }
1216
+ if (meetsCriteria) {
1217
+ filteredItems.push(currentItem);
1218
+ }
1219
+ }
1220
+ }
1221
+ return filteredItems;
1222
+ };
1223
+ var getSortedItems = (sortFields = [], items = []) => {
1224
+ let newItems = [...items];
1225
+ if (sortFields.length > 0) {
1226
+ for (const sortF of sortFields) {
1227
+ const { field, reverse } = sortF;
1228
+ newItems = newItems.sort((a, b) => {
1229
+ const aValue = a[field];
1230
+ const bValue = b[field];
1231
+ if (aValue < bValue) {
1232
+ return reverse ? 1 : -1;
1233
+ } else if (aValue > bValue) {
1234
+ return reverse ? -1 : 1;
1235
+ } else {
1236
+ return 0;
1237
+ }
1238
+ });
1239
+ }
1240
+ }
1241
+ return newItems;
1242
+ };
1243
+
1244
+ // src/common/StringTransformers.ts
1245
+ var StringTransformers_exports = {};
1246
+ __export(StringTransformers_exports, {
1247
+ CUSTOM_STRING_TRANSFORMERS: () => CUSTOM_STRING_TRANSFORMERS,
1248
+ STRING_TRANSFORMERS: () => STRING_TRANSFORMERS,
1249
+ transformValueToString: () => transformValueToString
1250
+ });
1251
+ var transformWhenStringExpected = (value) => (value ?? false) === false ? "" : `${value}`;
1252
+ var STRING_TRANSFORMERS = {
1253
+ string: transformWhenStringExpected,
1254
+ number: transformWhenStringExpected,
1255
+ boolean: (value) => value ? "true" : "false"
1256
+ };
1257
+ var CUSTOM_STRING_TRANSFORMERS = {
1258
+ date: (value) => value.toISOString(),
1259
+ time: (value) => value.toISOString(),
1260
+ datetime: (value) => value.toISOString(),
1261
+ duration: (value) => value.toString(),
1262
+ reference: (value) => value.toString(),
1263
+ unknown: (value) => value.toString()
1264
+ };
1265
+ var transformValueToString = (value, typeKeyword, customType) => {
1266
+ const transformer = customType ? CUSTOM_STRING_TRANSFORMERS[customType] : STRING_TRANSFORMERS[typeKeyword];
1267
+ return transformer ? transformer(value) : "";
1268
+ };
1269
+
1270
+ // src/common/ItemRelationshipInfoTypes.ts
1271
+ var ItemRelationshipInfoTypes_exports = {};
1272
+ __export(ItemRelationshipInfoTypes_exports, {
1273
+ ItemRelationshipInfoIdentifyingKeys: () => ItemRelationshipInfoIdentifyingKeys,
1274
+ ItemRelationshipInfoKeys: () => ItemRelationshipInfoKeys
1275
+ });
1276
+ var ItemRelationshipInfoKeys = /* @__PURE__ */ ((ItemRelationshipInfoKeys2) => {
1277
+ ItemRelationshipInfoKeys2["fromTypeName"] = "fromTypeName";
1278
+ ItemRelationshipInfoKeys2["fromTypeFieldName"] = "fromTypeFieldName";
1279
+ ItemRelationshipInfoKeys2["fromTypePrimaryFieldValue"] = "fromTypePrimaryFieldValue";
1280
+ ItemRelationshipInfoKeys2["toTypePrimaryFieldValue"] = "toTypePrimaryFieldValue";
1281
+ return ItemRelationshipInfoKeys2;
1282
+ })(ItemRelationshipInfoKeys || {});
1283
+ var ItemRelationshipInfoIdentifyingKeys = /* @__PURE__ */ ((ItemRelationshipInfoIdentifyingKeys2) => {
1284
+ ItemRelationshipInfoIdentifyingKeys2["id"] = "id";
1285
+ return ItemRelationshipInfoIdentifyingKeys2;
1286
+ })(ItemRelationshipInfoIdentifyingKeys || {});
1287
+
1288
+ // src/common/ItemRelationships/index.ts
1289
+ var ItemRelationships_exports = {};
1290
+ __export(ItemRelationships_exports, {
1291
+ TYPE_INFO_ORM_RELATIONSHIP_ERRORS: () => TYPE_INFO_ORM_RELATIONSHIP_ERRORS,
1292
+ validateRelationshipItem: () => validateRelationshipItem
1293
+ });
1294
+
1295
+ // src/common/ItemRelationships/ItemRelationshipValidation.ts
1296
+ var TYPE_INFO_ORM_RELATIONSHIP_ERRORS = {
1297
+ INVALID_RELATIONSHIP_ITEM: "INVALID_RELATIONSHIP_ITEM",
1298
+ INVALID_RELATIONSHIP_ITEM_FIELD: "INVALID_RELATIONSHIP_ITEM_FIELD"
1299
+ };
1300
+ var validateRelationshipItem = (relationshipItem, omitFields = []) => {
1301
+ const { fromTypeName } = relationshipItem;
1302
+ const results = {
1303
+ typeName: fromTypeName,
1304
+ valid: true,
1305
+ error: "",
1306
+ errorMap: {}
1307
+ };
1308
+ if (typeof relationshipItem === "object" && relationshipItem !== null) {
1309
+ const relKeyValues = Object.values(ItemRelationshipInfoKeys);
1310
+ for (const rKV of relKeyValues) {
1311
+ const universalRKV = rKV;
1312
+ const omitRKV = omitFields.includes(rKV);
1313
+ if (!omitRKV && (typeof relationshipItem[universalRKV] !== "string" || !relationshipItem[universalRKV])) {
1314
+ results.valid = false;
1315
+ results.error = TYPE_INFO_ORM_RELATIONSHIP_ERRORS.INVALID_RELATIONSHIP_ITEM;
1316
+ results.errorMap[rKV] = [
1317
+ TYPE_INFO_ORM_RELATIONSHIP_ERRORS.INVALID_RELATIONSHIP_ITEM_FIELD
1318
+ ];
1319
+ }
1320
+ }
1321
+ } else {
1322
+ results.valid = false;
1323
+ results.error = TYPE_INFO_ORM_RELATIONSHIP_ERRORS.INVALID_RELATIONSHIP_ITEM;
1324
+ }
1325
+ return results;
1326
+ };
1327
+
1328
+ // src/common/Testing/index.ts
1329
+ var Testing_exports = {};
1330
+ __export(Testing_exports, {
1331
+ OPERATIONS: () => OPERATIONS,
1332
+ TestComparisonOperation: () => TestComparisonOperation,
1333
+ compare: () => compare2,
1334
+ executeTestingCommand: () => executeTestingCommand,
1335
+ generateTestsForFile: () => generateTestsForFile,
1336
+ getResolvedConditions: () => getResolvedConditions,
1337
+ getResolvedTestConfig: () => getResolvedTestConfig,
1338
+ getSetupInstance: () => getSetupInstance,
1339
+ getTestConfig: () => getTestConfig,
1340
+ getTestFunction: () => getTestFunction,
1341
+ mergeTestResults: () => mergeTestResults,
1342
+ runTest: () => runTest,
1343
+ runTestsForFile: () => runTestsForFile
1344
+ });
1345
+
1346
+ // src/common/Testing/Types.ts
1347
+ var TestComparisonOperation = /* @__PURE__ */ ((TestComparisonOperation2) => {
1348
+ TestComparisonOperation2["EQUALS"] = "===";
1349
+ TestComparisonOperation2["NOT_EQUALS"] = "!==";
1350
+ TestComparisonOperation2["IN"] = "IN";
1351
+ TestComparisonOperation2["ARRAY_CONTAINS"] = "ARRAY_CONTAINS";
1352
+ TestComparisonOperation2["BETWEEN"] = "BETWEEN";
1353
+ TestComparisonOperation2["CONTAINS"] = "CONTAINS";
1354
+ TestComparisonOperation2["REGEX"] = "REGEX";
1355
+ TestComparisonOperation2["EXT_REGEX"] = "EXT_REGEX";
1356
+ TestComparisonOperation2["DEEP_EQUALS"] = "DEEP_EQUALS";
1357
+ TestComparisonOperation2["ARRAY_EQUALS"] = "ARRAY_EQUALS";
1358
+ return TestComparisonOperation2;
1359
+ })(TestComparisonOperation || {});
1360
+ var importModule = async (modulePath) => {
1361
+ const moduleUrl = pathToFileURL(modulePath);
1362
+ return import(moduleUrl.href);
1363
+ };
1364
+ var stringifyOutput = (value) => JSON.stringify(
1365
+ value,
1366
+ function(_key, value2) {
1367
+ return typeof value2 === "function" ? "[Function]" : value2;
1368
+ },
1369
+ 2
1370
+ );
1371
+ var OPERATIONS = {
1372
+ ["===" /* EQUALS */]: (a, b) => a === b,
1373
+ ["!==" /* NOT_EQUALS */]: (a, b) => a !== b,
1374
+ ["IN" /* IN */]: (a, b) => Array.isArray(b) && b.includes(a),
1375
+ ["BETWEEN" /* BETWEEN */]: (a, b) => {
1376
+ if (Array.isArray(b) && b.length === 2 && typeof b[0] === "number" && typeof b[1] === "number") {
1377
+ return typeof a === "number" && a >= b[0] && a <= b[1];
1378
+ }
1379
+ throw new Error("BETWEEN requires an array of two numbers as expectation.");
1380
+ },
1381
+ ["CONTAINS" /* CONTAINS */]: (a, b) => typeof a === "string" && typeof b === "string" && a.includes(b),
1382
+ ["REGEX" /* REGEX */]: (a, b) => {
1383
+ if (typeof b === "object" && b !== null && "pattern" in b) {
1384
+ const { pattern, flags } = b;
1385
+ try {
1386
+ const regex = new RegExp(pattern, flags);
1387
+ return typeof a === "string" && regex.test(a);
1388
+ } catch (err) {
1389
+ throw new Error(`Invalid REGEX: ${err.message}`);
1390
+ }
1391
+ }
1392
+ throw new Error(
1393
+ "REGEX requires an expectation with 'pattern' and optional 'flags'."
1394
+ );
1395
+ },
1396
+ ["EXT_REGEX" /* EXT_REGEX */]: (a, b) => {
1397
+ if (typeof b === "object" && b !== null && "pattern" in b) {
1398
+ const { pattern, flags } = b;
1399
+ const buildRegexFromPattern = (pattern2, flags2 = "") => {
1400
+ if (!Array.isArray(pattern2)) {
1401
+ throw new Error("EXT_REGEX pattern must be an array of objects.");
1402
+ }
1403
+ const regexBody = pattern2.map(({ value, escaped }) => {
1404
+ if (typeof value !== "string") {
1405
+ throw new Error(
1406
+ "Each pattern element must have a string 'value'."
1407
+ );
1408
+ }
1409
+ return escaped ? value.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&") : value;
1410
+ }).join("");
1411
+ return new RegExp(regexBody, flags2);
1412
+ };
1413
+ try {
1414
+ const regex = buildRegexFromPattern(pattern, flags);
1415
+ return typeof a === "string" && regex.test(a);
1416
+ } catch (err) {
1417
+ throw new Error(`Invalid EXT_REGEX: ${err.message}`);
1418
+ }
1419
+ }
1420
+ throw new Error(
1421
+ "EXT_REGEX requires an expectation with 'pattern' as an array of PatternElement and optional 'flags'."
1422
+ );
1423
+ },
1424
+ ["DEEP_EQUALS" /* DEEP_EQUALS */]: (a, b) => {
1425
+ if (typeof a === "object" && typeof b === "object" && a !== null && b !== null) {
1426
+ return JSON.stringify(a) === JSON.stringify(b);
1427
+ }
1428
+ return false;
1429
+ },
1430
+ ["ARRAY_CONTAINS" /* ARRAY_CONTAINS */]: (a, b) => {
1431
+ if (Array.isArray(a)) {
1432
+ return a.includes(b);
1433
+ }
1434
+ throw new Error("ARRAY_CONTAINS requires an array as the first argument.");
1435
+ },
1436
+ ["ARRAY_EQUALS" /* ARRAY_EQUALS */]: (a, b) => {
1437
+ if (Array.isArray(a) && Array.isArray(b)) {
1438
+ return JSON.stringify(a) === JSON.stringify(b);
1439
+ }
1440
+ throw new Error("ARRAY_EQUALS requires two arrays as arguments.");
1441
+ }
1442
+ };
1443
+ var compare2 = (result, expectation, operation = "===" /* EQUALS */) => {
1444
+ const op = OPERATIONS[operation];
1445
+ if (!op) {
1446
+ throw new Error(`Unsupported operation: ${operation}`);
1447
+ }
1448
+ return op(result, expectation);
1449
+ };
1450
+ var getResolvedConditions = async (testFilePath, targetTestIndex, targetTestExport, conditions, isSetup = false) => {
1451
+ if (Array.isArray(conditions)) {
1452
+ return conditions;
1453
+ } else if (typeof conditions === "object" && conditions !== null) {
1454
+ const { file, export: targetConditionExport } = conditions;
1455
+ const modulePath = Path.resolve(Path.dirname(testFilePath), file);
1456
+ const targetModule = await importModule(modulePath);
1457
+ const conditionArray = targetModule[targetConditionExport];
1458
+ if (Array.isArray(conditionArray)) {
1459
+ return conditionArray;
1460
+ }
1461
+ }
1462
+ throw new Error(
1463
+ `Invalid conditions for TEST${isSetup ? " SETUP" : ""} ${targetTestIndex + 1} (${targetTestExport}) in ${testFilePath}`
1464
+ );
1465
+ };
1466
+ var getSetupInstance = async (testFilePath, targetTestIndex, targetTestExport, test, module) => {
1467
+ const { setup } = test;
1468
+ if (!setup) return module;
1469
+ const { conditions: baseConditions, export: targetSetupExport } = setup;
1470
+ const setupFunction = module[targetSetupExport];
1471
+ const conditions = await getResolvedConditions(
1472
+ testFilePath,
1473
+ targetTestIndex,
1474
+ targetTestExport,
1475
+ baseConditions,
1476
+ true
1477
+ );
1478
+ if (typeof setupFunction !== "function") {
1479
+ throw new Error(`Setup export "${setup.export}" is not a function.`);
1480
+ }
1481
+ return setup.instantiate ? new setupFunction(...conditions) : await setupFunction(...conditions);
1482
+ };
1483
+ var getTestFunction = async (testFilePath, file, targetTestIndex, test, targetModule) => {
1484
+ const { export: targetExport } = test;
1485
+ if (!targetExport) {
1486
+ throw new Error(
1487
+ `Invalid test export (${targetExport}) for TEST ${targetTestIndex + 1} in ${testFilePath}`
1488
+ );
1489
+ }
1490
+ const instance = await getSetupInstance(
1491
+ testFilePath,
1492
+ targetTestIndex,
1493
+ targetExport,
1494
+ test,
1495
+ targetModule
1496
+ );
1497
+ const testFunction = instance[targetExport];
1498
+ if (typeof testFunction !== "function") {
1499
+ throw new Error(
1500
+ `Export "${targetExport}" from "${file}", declared in TEST ${targetTestIndex + 1}, is not a function.`
1501
+ );
1502
+ }
1503
+ return testFunction;
1504
+ };
1505
+ var getTestConfig = async (testFilePath) => {
1506
+ const testConfig = JSON.parse(
1507
+ await promises.readFile(testFilePath, "utf8")
1508
+ );
1509
+ return testConfig;
1510
+ };
1511
+ var getResolvedTestConfig = async (testFilePath) => {
1512
+ const { file, tests } = await getTestConfig(testFilePath);
1513
+ if (!file) {
1514
+ throw new Error(`Invalid test configuration in ${testFilePath}`);
1515
+ }
1516
+ const modulePath = Path.resolve(Path.dirname(testFilePath), file);
1517
+ const targetModule = await importModule(modulePath);
1518
+ return {
1519
+ file,
1520
+ targetModule,
1521
+ tests
1522
+ };
1523
+ };
1524
+ var mergeTestResults = (...results) => results.reduce(
1525
+ ({
1526
+ messages: accMessages = [],
1527
+ generated: accGenerated = [],
1528
+ passes: accPasses = [],
1529
+ failures: accFailures = [],
1530
+ errors: accErrors = []
1531
+ }, {
1532
+ messages = [],
1533
+ generated = [],
1534
+ passes = [],
1535
+ failures = [],
1536
+ errors = []
1537
+ }) => ({
1538
+ messages: [...accMessages, ...messages],
1539
+ generated: [...accGenerated, ...generated],
1540
+ passes: [...accPasses, ...passes],
1541
+ failures: [...accFailures, ...failures],
1542
+ errors: [...accErrors, ...errors]
1543
+ }),
1544
+ { messages: [], passes: [], failures: [], errors: [] }
1545
+ );
1546
+ var runTest = async (testFilePath, testFunction, test, index, targetExport, report) => {
1547
+ const {
1548
+ conditions: baseConditions,
1549
+ expectation,
1550
+ operation,
1551
+ expectUndefined
1552
+ } = test;
1553
+ const conditions = await getResolvedConditions(
1554
+ testFilePath,
1555
+ index,
1556
+ targetExport,
1557
+ baseConditions
1558
+ );
1559
+ try {
1560
+ const result = await testFunction(...conditions);
1561
+ const passed = expectUndefined || compare2(result, expectation, operation);
1562
+ if (passed) {
1563
+ report({
1564
+ passes: [`Test ${index + 1} (${targetExport})`]
1565
+ });
1566
+ } else {
1567
+ report({
1568
+ failures: [
1569
+ `Test ${index + 1} (${targetExport}):
1570
+
1571
+ Result:
1572
+
1573
+ ${stringifyOutput(result)}`
1574
+ ]
1575
+ });
1576
+ }
1577
+ } catch (err) {
1578
+ report({
1579
+ errors: [
1580
+ `Test ${index + 1} (${targetExport}):
1581
+
1582
+ Error:
1583
+
1584
+ ${err.message}`
1585
+ ]
1586
+ });
1587
+ }
1588
+ };
1589
+ var generateTestsForFile = async (testFilePath, report) => {
1590
+ try {
1591
+ const { file, targetModule, tests } = await getResolvedTestConfig(testFilePath);
1592
+ report({
1593
+ messages: [`Generating expectations for tests in ${testFilePath}`]
1594
+ });
1595
+ const generatedTests = [];
1596
+ let hasNewExpectations = false;
1597
+ for (let i = 0; i < tests.length; i++) {
1598
+ const test = tests[i];
1599
+ const {
1600
+ export: targetExport,
1601
+ conditions: baseConditions,
1602
+ expectation,
1603
+ operation,
1604
+ expectUndefined
1605
+ } = test;
1606
+ const conditions = await getResolvedConditions(
1607
+ testFilePath,
1608
+ i,
1609
+ targetExport,
1610
+ baseConditions
1611
+ );
1612
+ if (expectation !== void 0 || expectUndefined) {
1613
+ generatedTests.push(test);
1614
+ } else {
1615
+ const testFunction = await getTestFunction(
1616
+ testFilePath,
1617
+ file,
1618
+ i,
1619
+ test,
1620
+ targetModule
1621
+ );
1622
+ const result = await testFunction(...conditions);
1623
+ report({
1624
+ generated: [
1625
+ `Expectation for TEST ${i + 1} (${targetExport}):
1626
+
1627
+ ${stringifyOutput(result)}`
1628
+ ]
1629
+ });
1630
+ generatedTests.push({
1631
+ ...test,
1632
+ expectation: result,
1633
+ operation: operation || "===" /* EQUALS */
1634
+ });
1635
+ hasNewExpectations = true;
1636
+ }
1637
+ }
1638
+ if (hasNewExpectations) {
1639
+ const updatedTestConfig = { file, tests: generatedTests };
1640
+ await promises.writeFile(
1641
+ testFilePath,
1642
+ JSON.stringify(updatedTestConfig, null, 2)
1643
+ );
1644
+ report({ messages: [`Updated test file saved to ${testFilePath}`] });
1645
+ } else {
1646
+ report({
1647
+ messages: [`No new expectations were generated for ${testFilePath}`]
1648
+ });
1649
+ }
1650
+ } catch (err) {
1651
+ report({
1652
+ errors: [`Error processing test file ${testFilePath}:
1653
+
1654
+ ${err.message}`]
1655
+ });
1656
+ }
1657
+ };
1658
+ var runTestsForFile = async (testFilePath, report) => {
1659
+ try {
1660
+ const { file, targetModule, tests } = await getResolvedTestConfig(testFilePath);
1661
+ report({
1662
+ messages: [`Running tests from ${testFilePath}`]
1663
+ });
1664
+ for (const [index, test] of tests.entries()) {
1665
+ const { export: targetExport } = test;
1666
+ const testFunction = await getTestFunction(
1667
+ testFilePath,
1668
+ file,
1669
+ index,
1670
+ test,
1671
+ targetModule
1672
+ );
1673
+ await runTest(
1674
+ testFilePath,
1675
+ testFunction,
1676
+ test,
1677
+ index,
1678
+ targetExport,
1679
+ report
1680
+ );
1681
+ }
1682
+ } catch (err) {
1683
+ report({
1684
+ errors: [`Error processing test file ${testFilePath}: ${err.message}`]
1685
+ });
1686
+ }
1687
+ };
1688
+ var executeTestingCommand = async (testFiles, generateMode = false, report) => {
1689
+ const completeMessage = generateMode ? "Test generation complete." : "Testing complete.";
1690
+ try {
1691
+ for (const testFile of testFiles) {
1692
+ const resolvedTestFile = Path.resolve(testFile);
1693
+ if (generateMode) {
1694
+ await generateTestsForFile(resolvedTestFile, report);
1695
+ } else {
1696
+ await runTestsForFile(resolvedTestFile, report);
1697
+ }
1698
+ }
1699
+ report({
1700
+ messages: [completeMessage]
1701
+ });
1702
+ } catch (err) {
1703
+ report({ errors: [`Error running tests:
1704
+
1705
+ ${err.message}`] });
1706
+ }
1707
+ };
1708
+
1709
+ // src/common/Logging/index.ts
1710
+ var Logging_exports = {};
1711
+ __export(Logging_exports, {
1712
+ LOGGING_MESSAGES: () => LOGGING_MESSAGES,
1713
+ logFunctionCall: () => logFunctionCall
1714
+ });
1715
+
1716
+ // src/common/Logging/Utils.ts
1717
+ var LOGGING_MESSAGES = /* @__PURE__ */ ((LOGGING_MESSAGES2) => {
1718
+ LOGGING_MESSAGES2["LOGGING_FUNCTION_CALL"] = "LOGGING_FUNCTION_CALL";
1719
+ LOGGING_MESSAGES2["INPUT"] = "INPUT";
1720
+ LOGGING_MESSAGES2["OUTPUT"] = "OUTPUT";
1721
+ LOGGING_MESSAGES2["ERROR"] = "ERROR";
1722
+ return LOGGING_MESSAGES2;
1723
+ })(LOGGING_MESSAGES || {});
1724
+ var logFunctionCall = async (label, args, functionRef, enabled) => {
1725
+ if (enabled) {
1726
+ console.log(
1727
+ "LOGGING_FUNCTION_CALL" /* LOGGING_FUNCTION_CALL */,
1728
+ "INPUT" /* INPUT */,
1729
+ label,
1730
+ ":",
1731
+ JSON.stringify(args, null, 2)
1732
+ );
1733
+ }
1734
+ try {
1735
+ const result = await functionRef(...args);
1736
+ if (enabled) {
1737
+ console.log(
1738
+ "LOGGING_FUNCTION_CALL" /* LOGGING_FUNCTION_CALL */,
1739
+ "OUTPUT" /* OUTPUT */,
1740
+ label,
1741
+ ":",
1742
+ JSON.stringify(result, null, 2)
1743
+ );
1744
+ }
1745
+ return result;
1746
+ } catch (error) {
1747
+ if (enabled) {
1748
+ console.error(
1749
+ "LOGGING_FUNCTION_CALL" /* LOGGING_FUNCTION_CALL */,
1750
+ "ERROR" /* ERROR */,
1751
+ label,
1752
+ ":",
1753
+ error
1754
+ );
1755
+ }
1756
+ throw error;
1757
+ }
1758
+ };
1759
+
1760
+ export { IdGeneration_exports as IDGeneration, ItemRelationshipInfoTypes_exports as ItemRelationshipInfoTypes, ItemRelationships_exports as ItemRelationships, Logging_exports as Logging, Routing_exports as Routing, SearchTypes_exports as SearchTypes, SearchUtils_exports as SearchUtils, StringTransformers_exports as StringTransformers, Testing_exports as Testing, TypeParsing_exports as TypeParsing };