@resistdesign/voltra 3.0.0-alpha.5 → 3.0.0-alpha.50

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 (222) hide show
  1. package/README.md +392 -14
  2. package/api/DBX/DBXAsserts.d.ts +95 -0
  3. package/api/DBX/DBXRequest.d.ts +5 -0
  4. package/api/DBX/DBXRuntime.d.ts +5 -0
  5. package/api/DBX/DBXScenarioConfig.d.ts +9 -0
  6. package/api/DBX/DBXSeed.d.ts +124 -0
  7. package/api/DBX/DBXTypes.d.ts +176 -0
  8. package/api/DBX/index.d.ts +8 -0
  9. package/api/DataAccessControl.d.ts +220 -0
  10. package/api/Indexing/API.d.ts +224 -0
  11. package/api/Indexing/Cursor.d.ts +101 -0
  12. package/api/Indexing/Handler/Config.d.ts +39 -0
  13. package/api/Indexing/Handler.d.ts +166 -0
  14. package/api/Indexing/Trace.d.ts +54 -0
  15. package/api/Indexing/Types.d.ts +204 -0
  16. package/api/Indexing/ddb/AwsSdkV3Adapter.d.ts +8 -0
  17. package/api/Indexing/ddb/Types.d.ts +209 -0
  18. package/api/Indexing/docId.d.ts +27 -0
  19. package/api/Indexing/exact/ExactDdb.d.ts +58 -0
  20. package/api/Indexing/exact/ExactIndex.d.ts +90 -0
  21. package/api/Indexing/exact/ExactS3.d.ts +41 -0
  22. package/api/Indexing/fieldQualification.d.ts +12 -0
  23. package/api/Indexing/fulltext/FullTextDdbBackend.d.ts +212 -0
  24. package/api/Indexing/fulltext/FullTextMemoryBackend.d.ts +93 -0
  25. package/api/Indexing/fulltext/Schema.d.ts +164 -0
  26. package/api/Indexing/hashUniversal.d.ts +13 -0
  27. package/api/Indexing/index.d.ts +45 -0
  28. package/api/Indexing/lossy/LossyDdb.d.ts +43 -0
  29. package/api/Indexing/lossy/LossyIndex.d.ts +72 -0
  30. package/api/Indexing/lossy/LossyS3.d.ts +40 -0
  31. package/api/Indexing/rel/Cursor.d.ts +25 -0
  32. package/api/Indexing/rel/Handlers.d.ts +144 -0
  33. package/api/Indexing/rel/RelationalDdb.d.ts +169 -0
  34. package/api/Indexing/rel/RelationalInMemoryBackend.d.ts +38 -0
  35. package/api/Indexing/rel/Types.d.ts +69 -0
  36. package/api/Indexing/structured/Cursor.d.ts +26 -0
  37. package/api/Indexing/structured/Handlers.d.ts +128 -0
  38. package/api/Indexing/structured/SearchStructured.d.ts +44 -0
  39. package/api/Indexing/structured/StructuredDdb.d.ts +184 -0
  40. package/api/Indexing/structured/StructuredDdbBackend.d.ts +112 -0
  41. package/api/Indexing/structured/StructuredInMemoryBackend.d.ts +40 -0
  42. package/api/Indexing/structured/StructuredInMemoryIndex.d.ts +61 -0
  43. package/api/Indexing/structured/StructuredStringLike.d.ts +54 -0
  44. package/api/Indexing/structured/StructuredWriter.d.ts +74 -0
  45. package/api/Indexing/structured/Types.d.ts +126 -0
  46. package/api/Indexing/structured/index.d.ts +9 -0
  47. package/api/Indexing/tokenize.d.ts +31 -0
  48. package/api/ORM/DACUtils.d.ts +270 -0
  49. package/api/ORM/ListItemUtils.d.ts +40 -0
  50. package/api/ORM/ORMRouteMap.d.ts +70 -0
  51. package/api/ORM/TypeInfoORMService.d.ts +879 -0
  52. package/api/ORM/drivers/DynamoDBDataItemDBDriver/ConfigTypes.d.ts +229 -0
  53. package/api/ORM/drivers/DynamoDBDataItemDBDriver.d.ts +90 -0
  54. package/api/ORM/drivers/InMemoryDataItemDBDriver/ConfigTypes.d.ts +4 -0
  55. package/api/ORM/drivers/InMemoryDataItemDBDriver.d.ts +56 -0
  56. package/api/ORM/drivers/InMemoryFileItemDBDriver/ConfigTypes.d.ts +13 -0
  57. package/api/ORM/drivers/InMemoryFileItemDBDriver.d.ts +98 -0
  58. package/api/ORM/drivers/InMemoryItemRelationshipDBDriver.d.ts +16 -0
  59. package/api/ORM/drivers/IndexingRelationshipDriver.d.ts +123 -0
  60. package/api/ORM/drivers/S3FileItemDBDriver/ConfigTypes.d.ts +322 -0
  61. package/api/ORM/drivers/S3FileItemDBDriver/S3FileDriver.d.ts +118 -0
  62. package/api/ORM/drivers/S3FileItemDBDriver.d.ts +71 -0
  63. package/api/ORM/drivers/common/SupportedTypeInfoORMDBDrivers.d.ts +36 -0
  64. package/api/ORM/drivers/common/Types.d.ts +202 -0
  65. package/api/ORM/drivers/common/index.d.ts +2 -0
  66. package/api/ORM/drivers/index.d.ts +8 -0
  67. package/api/ORM/getTypeInfoORMIndexingConfigFromTypeInfoMap.d.ts +31 -0
  68. package/api/ORM/index.d.ts +10 -0
  69. package/api/ORM/indexing/criteriaToStructuredWhere.d.ts +22 -0
  70. package/api/Router/AWS.d.ts +80 -0
  71. package/api/Router/Auth.d.ts +14 -0
  72. package/api/Router/CORS.d.ts +66 -0
  73. package/api/Router/Types.d.ts +138 -0
  74. package/api/Router/index.d.ts +89 -0
  75. package/api/index.d.ts +72 -6
  76. package/api/index.js +3551 -1946
  77. package/app/forms/Engine.d.ts +23 -0
  78. package/app/forms/UI.d.ts +83 -0
  79. package/app/forms/core/createAutoField.d.ts +43 -0
  80. package/app/forms/core/createFormRenderer.d.ts +25 -0
  81. package/app/forms/core/getFieldKind.d.ts +14 -0
  82. package/app/forms/core/index.d.ts +11 -0
  83. package/app/forms/core/mergeSuites.d.ts +23 -0
  84. package/app/forms/core/resolveSuite.d.ts +15 -0
  85. package/app/forms/core/types.d.ts +180 -0
  86. package/app/forms/index.d.ts +9 -0
  87. package/app/forms/types.d.ts +137 -0
  88. package/app/helpers/styled.d.ts +3 -0
  89. package/app/index.d.ts +116 -5
  90. package/app/index.js +120 -382
  91. package/app/utils/ApplicationState.d.ts +161 -0
  92. package/app/utils/ApplicationStateLoader.d.ts +91 -0
  93. package/app/utils/Controller.d.ts +10 -0
  94. package/app/utils/Debug.d.ts +14 -0
  95. package/app/utils/EasyLayout.d.ts +89 -0
  96. package/app/utils/History.d.ts +165 -0
  97. package/app/utils/Route.d.ts +207 -0
  98. package/app/utils/RouteHistory.d.ts +27 -0
  99. package/app/utils/Service.d.ts +45 -0
  100. package/app/utils/TypeInfoORMAPIUtils.d.ts +94 -0
  101. package/app/utils/TypeInfoORMClient.d.ts +104 -0
  102. package/app/utils/UniversalRouteAdapter.d.ts +73 -0
  103. package/app/utils/easy-layout/computeAreaBounds.d.ts +5 -0
  104. package/app/utils/easy-layout/computeTracks.d.ts +16 -0
  105. package/app/utils/easy-layout/index.d.ts +5 -0
  106. package/app/utils/easy-layout/parseTemplate.d.ts +12 -0
  107. package/app/utils/easy-layout/types.d.ts +52 -0
  108. package/app/utils/easy-layout/validateAreas.d.ts +5 -0
  109. package/app/utils/index.d.ts +24 -0
  110. package/build/TypeMapping.d.ts +17 -0
  111. package/build/TypeParsing.d.ts +10 -0
  112. package/build/index.d.ts +15 -0
  113. package/build/index.js +569 -0
  114. package/chunk-2JDOM6PB.js +138 -0
  115. package/chunk-3HVYVX3S.js +546 -0
  116. package/chunk-ATO2455Q.js +258 -0
  117. package/chunk-BSHQIRBV.js +71 -0
  118. package/chunk-I2KLQ2HA.js +19 -0
  119. package/chunk-K4R2PFNG.js +1258 -0
  120. package/chunk-TJFTWPXQ.js +39 -0
  121. package/chunk-XHOMAXLR.js +84 -0
  122. package/common/CommandLine/collectRequiredEnvironmentVariables.d.ts +9 -0
  123. package/common/CommandLine/index.d.ts +6 -0
  124. package/common/HelperTypes.d.ts +9 -0
  125. package/common/IdGeneration/getSimpleId.d.ts +8 -0
  126. package/common/IdGeneration/index.d.ts +1 -0
  127. package/common/ItemRelationshipInfoTypes.d.ts +64 -0
  128. package/common/ItemRelationships/ItemRelationshipValidation.d.ts +21 -0
  129. package/common/ItemRelationships/index.d.ts +2 -0
  130. package/common/Logging/Utils.d.ts +10 -0
  131. package/common/Logging/index.d.ts +1 -0
  132. package/common/Routing.d.ts +81 -0
  133. package/common/SearchTypes.d.ts +227 -0
  134. package/common/SearchUtils.d.ts +55 -0
  135. package/common/SearchValidation.d.ts +27 -0
  136. package/common/StringTransformers.d.ts +28 -0
  137. package/common/Testing/CLI.d.ts +6 -0
  138. package/common/Testing/Types.d.ts +216 -0
  139. package/common/Testing/Utils.d.ts +112 -0
  140. package/common/Testing/index.d.ts +8 -0
  141. package/common/TypeInfoDataItemUtils.d.ts +39 -0
  142. package/{Types-C7XjUjoF.d.ts → common/TypeInfoORM/Types.d.ts} +150 -20
  143. package/common/TypeInfoORM/index.d.ts +3 -0
  144. package/common/TypeParsing/Constants.d.ts +4 -0
  145. package/common/TypeParsing/ParsingUtils/Constants.d.ts +8 -0
  146. package/common/TypeParsing/ParsingUtils/checkType.d.ts +14 -0
  147. package/common/TypeParsing/ParsingUtils/checkUnionType.d.ts +12 -0
  148. package/common/TypeParsing/ParsingUtils/extractCommentTags.d.ts +8 -0
  149. package/common/TypeParsing/ParsingUtils/extractLiteralValues.d.ts +12 -0
  150. package/common/TypeParsing/ParsingUtils/extractTypeDetails.d.ts +14 -0
  151. package/common/TypeParsing/ParsingUtils/getPrimaryFieldForTypeInfo.d.ts +18 -0
  152. package/common/TypeParsing/ParsingUtils/getTypeInfo.d.ts +9 -0
  153. package/common/TypeParsing/ParsingUtils/getTypeInfoField.d.ts +9 -0
  154. package/common/TypeParsing/ParsingUtils/getTypeInfoFromAliasType.d.ts +11 -0
  155. package/common/TypeParsing/ParsingUtils/getTypeInfoFromFieldFilter.d.ts +12 -0
  156. package/common/TypeParsing/ParsingUtils/getTypeInfoFromTypeAlias.d.ts +11 -0
  157. package/common/TypeParsing/ParsingUtils/getTypeKeyword.d.ts +9 -0
  158. package/common/TypeParsing/ParsingUtils/getUnionOrIntersectionTypeInfo.d.ts +11 -0
  159. package/common/TypeParsing/ParsingUtils/getUnionOrLiteralStringValues.d.ts +8 -0
  160. package/common/TypeParsing/TypeInfo.d.ts +235 -0
  161. package/common/TypeParsing/Utils.d.ts +47 -0
  162. package/common/TypeParsing/Validation.d.ts +327 -0
  163. package/common/TypeParsing/index.d.ts +8 -0
  164. package/common/index.d.ts +47 -4
  165. package/common/index.js +25 -1737
  166. package/{index-BkFZlfit.d.ts → iac/SimpleCFT.d.ts} +5 -25
  167. package/iac/index.d.ts +40 -2
  168. package/iac/index.js +2 -1661
  169. package/iac/packs/auth.d.ts +131 -0
  170. package/iac/packs/build/utils.d.ts +289 -0
  171. package/iac/packs/build.d.ts +92 -0
  172. package/iac/packs/cdn.d.ts +33 -0
  173. package/iac/packs/cloud-function.d.ts +67 -0
  174. package/iac/packs/database.d.ts +32 -0
  175. package/iac/packs/dns.d.ts +34 -0
  176. package/iac/packs/file-storage.d.ts +46 -0
  177. package/iac/packs/gateway.d.ts +82 -0
  178. package/iac/packs/index.d.ts +60 -1
  179. package/iac/packs/index.js +391 -594
  180. package/iac/packs/repo.d.ts +28 -0
  181. package/iac/packs/ssl-certificate.d.ts +28 -0
  182. package/iac/types/Constants.d.ts +24 -0
  183. package/{index-DcvJOZ_c.d.ts → iac/types/IaCTypes.d.ts} +23 -1018
  184. package/iac/types/Renderers.d.ts +96 -0
  185. package/iac/types/Types.d.ts +131 -0
  186. package/iac/types/Utils.d.ts +9 -0
  187. package/iac/types/generate.d.ts +1 -0
  188. package/iac/utils/index.d.ts +87 -0
  189. package/iac/utils/patch-utils.d.ts +66 -0
  190. package/iac-packs/index.d.ts +6 -0
  191. package/native/forms/UI.d.ts +73 -0
  192. package/native/forms/createNativeFormRenderer.d.ts +21 -0
  193. package/native/forms/index.d.ts +25 -0
  194. package/native/forms/primitives/index.d.ts +38 -0
  195. package/native/forms/suite.d.ts +15 -0
  196. package/native/index.d.ts +19 -0
  197. package/native/index.js +792 -0
  198. package/native/testing/react-native.d.ts +46 -0
  199. package/native/utils/EasyLayout.d.ts +88 -0
  200. package/native/utils/History.d.ts +124 -0
  201. package/native/utils/NavButton.d.ts +25 -0
  202. package/native/utils/Route.d.ts +41 -0
  203. package/native/utils/index.d.ts +25 -0
  204. package/package.json +54 -21
  205. package/web/forms/UI.d.ts +74 -0
  206. package/web/forms/createWebFormRenderer.d.ts +21 -0
  207. package/web/forms/index.d.ts +9 -0
  208. package/web/forms/primitives/index.d.ts +21 -0
  209. package/web/forms/suite.d.ts +15 -0
  210. package/web/index.d.ts +15 -0
  211. package/web/index.js +701 -0
  212. package/web/utils/EasyLayout.d.ts +47 -0
  213. package/web/utils/NavLink.d.ts +24 -0
  214. package/web/utils/Route.d.ts +16 -0
  215. package/web/utils/index.d.ts +8 -0
  216. package/SearchTypes-DjN6YQzE.d.ts +0 -577
  217. package/Validation-CFP59oIP.d.ts +0 -226
  218. package/index-C3-iD9Mh.d.ts +0 -690
  219. package/index-CK5Qwvfb.d.ts +0 -5378
  220. package/index-IokxSNxm.d.ts +0 -745
  221. package/index.d.ts +0 -13
  222. package/index.js +0 -11005
@@ -0,0 +1,138 @@
1
+ // src/common/Routing.ts
2
+ var PATH_DELIMITER = "/";
3
+ var getPotentialJSONValue = (value) => {
4
+ try {
5
+ return JSON.parse(value);
6
+ } catch (error) {
7
+ return value;
8
+ }
9
+ };
10
+ 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);
11
+ 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);
12
+ var mergeStringPaths = (path1, path2, delimiter = PATH_DELIMITER, filterEmptyOutput = false, filterEmptyInput = true, useJson = true, uriEncodeParts = false) => getPathString(
13
+ [
14
+ ...getPathArray(
15
+ path1,
16
+ delimiter,
17
+ filterEmptyOutput,
18
+ filterEmptyInput,
19
+ useJson,
20
+ uriEncodeParts
21
+ ),
22
+ ...getPathArray(
23
+ path2,
24
+ delimiter,
25
+ filterEmptyOutput,
26
+ filterEmptyInput,
27
+ useJson,
28
+ uriEncodeParts
29
+ )
30
+ ],
31
+ delimiter,
32
+ filterEmptyInput,
33
+ useJson,
34
+ uriEncodeParts
35
+ );
36
+ var resolvePath = (currentPath, newPath) => {
37
+ const newSegments = getPathArray(newPath, PATH_DELIMITER, true);
38
+ let currentSegments = getPathArray(currentPath, PATH_DELIMITER, true);
39
+ if (newPath.startsWith("/")) {
40
+ currentSegments = [];
41
+ }
42
+ newSegments.forEach((segment) => {
43
+ if (segment === "..") {
44
+ if (currentSegments.length > 0) {
45
+ currentSegments.pop();
46
+ }
47
+ } else if (segment !== ".") {
48
+ currentSegments.push(segment);
49
+ }
50
+ });
51
+ return "/" + currentSegments.join("/");
52
+ };
53
+ var splitRoutePathParts = (rawPath) => {
54
+ let path = rawPath;
55
+ let hash = "";
56
+ let search = "";
57
+ const hashIndex = path.indexOf("#");
58
+ if (hashIndex >= 0) {
59
+ hash = path.slice(hashIndex);
60
+ path = path.slice(0, hashIndex);
61
+ }
62
+ const searchIndex = path.indexOf("?");
63
+ if (searchIndex >= 0) {
64
+ search = path.slice(searchIndex);
65
+ path = path.slice(0, searchIndex);
66
+ }
67
+ return {
68
+ path,
69
+ search,
70
+ hash
71
+ };
72
+ };
73
+ var resolveRouteAdapterPath = (currentPath, nextPath) => {
74
+ const rawNextPath = String(nextPath ?? "").trim();
75
+ if (rawNextPath === "") {
76
+ return "/";
77
+ }
78
+ const { path: rawCurrentBase } = splitRoutePathParts(
79
+ String(currentPath ?? "").trim()
80
+ );
81
+ const { path: rawRelativePath, search, hash } = splitRoutePathParts(rawNextPath);
82
+ const isAbsoluteTarget = rawRelativePath.startsWith(PATH_DELIMITER);
83
+ const currentSegments = getPathArray(
84
+ rawCurrentBase || PATH_DELIMITER,
85
+ PATH_DELIMITER,
86
+ true,
87
+ true,
88
+ false,
89
+ false
90
+ );
91
+ const outputSegments = isAbsoluteTarget ? [] : [...currentSegments];
92
+ const relativeSegments = getPathArray(
93
+ rawRelativePath,
94
+ PATH_DELIMITER,
95
+ true,
96
+ true,
97
+ false,
98
+ false
99
+ );
100
+ relativeSegments.forEach((segment) => {
101
+ if (segment === "." || segment === "") {
102
+ return;
103
+ }
104
+ if (segment === "..") {
105
+ outputSegments.pop();
106
+ return;
107
+ }
108
+ outputSegments.push(segment);
109
+ });
110
+ const resolvedPath = outputSegments.length > 0 ? `/${outputSegments.join(PATH_DELIMITER)}` : PATH_DELIMITER;
111
+ return `${resolvedPath}${search}${hash}`;
112
+ };
113
+ var getParamsAndTestPath = (path, testPath, exact = false) => {
114
+ const pathList = getPathArray(path);
115
+ const testPathList = getPathArray(testPath);
116
+ if (exact && pathList.length !== testPathList.length) {
117
+ return false;
118
+ } else {
119
+ let params = {};
120
+ if (pathList.length >= testPathList.length) {
121
+ for (let i = 0; i < testPathList.length; i++) {
122
+ const testPathPart = testPathList[i];
123
+ const pathPart = pathList[i];
124
+ if (testPathPart.startsWith(":")) {
125
+ const paramName = testPathPart.slice(1);
126
+ params[paramName] = pathPart;
127
+ } else if (pathPart !== testPathPart) {
128
+ return false;
129
+ }
130
+ }
131
+ } else {
132
+ return false;
133
+ }
134
+ return params;
135
+ }
136
+ };
137
+
138
+ export { PATH_DELIMITER, getParamsAndTestPath, getPathArray, getPathString, getPotentialJSONValue, mergeStringPaths, resolvePath, resolveRouteAdapterPath };
@@ -0,0 +1,546 @@
1
+ import { getPathString } from './chunk-2JDOM6PB.js';
2
+
3
+ // src/common/TypeParsing/TypeInfo.ts
4
+ var TypeOperation = /* @__PURE__ */ ((TypeOperation2) => {
5
+ TypeOperation2["CREATE"] = "CREATE";
6
+ TypeOperation2["READ"] = "READ";
7
+ TypeOperation2["UPDATE"] = "UPDATE";
8
+ TypeOperation2["DELETE"] = "DELETE";
9
+ return TypeOperation2;
10
+ })(TypeOperation || {});
11
+
12
+ // src/common/TypeParsing/Validation.ts
13
+ var RelationshipValidationType = /* @__PURE__ */ ((RelationshipValidationType2) => {
14
+ RelationshipValidationType2["INCLUDE"] = "INCLUDE";
15
+ RelationshipValidationType2["EXCLUDE"] = "EXCLUDE";
16
+ RelationshipValidationType2["STRICT_EXCLUDE"] = "STRICT_EXCLUDE";
17
+ return RelationshipValidationType2;
18
+ })(RelationshipValidationType || {});
19
+ var INVALID_CUSTOM_TYPE = "INVALID_CUSTOM_TYPE";
20
+ var PRIMITIVE_ERROR_MESSAGE_CONSTANTS = {
21
+ string: "NOT_A_STRING",
22
+ number: "NOT_A_NUMBER",
23
+ boolean: "NOT_A_BOOLEAN"
24
+ };
25
+ var DENIED_TYPE_OPERATIONS = {
26
+ CREATE: "DENIED_TYPE_OPERATION_CREATE",
27
+ READ: "DENIED_TYPE_OPERATION_READ",
28
+ UPDATE: "DENIED_TYPE_OPERATION_UPDATE",
29
+ DELETE: "DENIED_TYPE_OPERATION_DELETE"
30
+ };
31
+ var ERROR_MESSAGE_CONSTANTS = {
32
+ NONE: "NONE",
33
+ INVALID_CUSTOM_TYPE,
34
+ [PRIMITIVE_ERROR_MESSAGE_CONSTANTS.string]: PRIMITIVE_ERROR_MESSAGE_CONSTANTS.string,
35
+ [PRIMITIVE_ERROR_MESSAGE_CONSTANTS.number]: PRIMITIVE_ERROR_MESSAGE_CONSTANTS.number,
36
+ [PRIMITIVE_ERROR_MESSAGE_CONSTANTS.boolean]: PRIMITIVE_ERROR_MESSAGE_CONSTANTS.boolean,
37
+ [DENIED_TYPE_OPERATIONS.CREATE]: DENIED_TYPE_OPERATIONS.CREATE,
38
+ [DENIED_TYPE_OPERATIONS.READ]: DENIED_TYPE_OPERATIONS.READ,
39
+ [DENIED_TYPE_OPERATIONS.UPDATE]: DENIED_TYPE_OPERATIONS.UPDATE,
40
+ [DENIED_TYPE_OPERATIONS.DELETE]: DENIED_TYPE_OPERATIONS.DELETE,
41
+ MISSING_FIELD_VALUE: "MISSING_FIELD_VALUE",
42
+ INVALID_OPTION: "INVALID_OPTION",
43
+ INVALID_FIELD: "INVALID_FIELD",
44
+ RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED: "RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED",
45
+ INVALID_TYPE: "INVALID_TYPE",
46
+ NO_UNION_TYPE_MATCHED: "NO_UNION_TYPE_MATCHED",
47
+ TYPE_DOES_NOT_EXIST: "TYPE_DOES_NOT_EXIST",
48
+ INVALID_PATTERN: "INVALID_PATTERN",
49
+ VALUE_DOES_NOT_MATCH_PATTERN: "VALUE_DOES_NOT_MATCH_PATTERN",
50
+ VALUE_BELOW_MINIMUM: "VALUE_BELOW_MINIMUM",
51
+ VALUE_ABOVE_MAXIMUM: "VALUE_ABOVE_MAXIMUM"
52
+ };
53
+ var TYPE_KEYWORD_ERROR_MESSAGE_CONSTANTS = {
54
+ string: PRIMITIVE_ERROR_MESSAGE_CONSTANTS.string,
55
+ number: PRIMITIVE_ERROR_MESSAGE_CONSTANTS.number,
56
+ boolean: PRIMITIVE_ERROR_MESSAGE_CONSTANTS.boolean
57
+ };
58
+ var ARRAY_ITEM_ERROR_MAP_KEY = "__arrayItemErrors__";
59
+ var getErrorDescriptor = (code = ERROR_MESSAGE_CONSTANTS.NONE, values) => ({
60
+ code,
61
+ values
62
+ });
63
+ var getNoErrorDescriptor = () => getErrorDescriptor(ERROR_MESSAGE_CONSTANTS.NONE);
64
+ var isArrayErrorDescriptorCollection = (value) => typeof value === "object" && value !== null && "itemErrorMap" in value;
65
+ var getErrorDescriptors = (values = []) => values.filter(
66
+ (value) => !isArrayErrorDescriptorCollection(value)
67
+ );
68
+ var getArrayItemErrorMap = (values = []) => values.reduce((acc, value) => {
69
+ if (isArrayErrorDescriptorCollection(value)) {
70
+ for (const [indexKey, descriptors] of Object.entries(value.itemErrorMap)) {
71
+ const index = Number(indexKey);
72
+ if (!Number.isFinite(index)) {
73
+ continue;
74
+ }
75
+ acc[index] = [...acc[index] ?? [], ...descriptors];
76
+ }
77
+ }
78
+ return acc;
79
+ }, {});
80
+ var validateValueMatchesPattern = (typeName, value, pattern) => {
81
+ const results = {
82
+ typeName,
83
+ valid: true,
84
+ error: getNoErrorDescriptor(),
85
+ errorMap: {}
86
+ };
87
+ const valueSupplied = typeof value !== "undefined";
88
+ const patternSupplied = typeof pattern === "string" && pattern.trim() !== "";
89
+ if (valueSupplied && patternSupplied) {
90
+ try {
91
+ const regex = new RegExp(pattern);
92
+ const testResult = typeof value === "string" && regex.test(value);
93
+ if (!testResult) {
94
+ results.valid = false;
95
+ results.error = getErrorDescriptor(
96
+ ERROR_MESSAGE_CONSTANTS.VALUE_DOES_NOT_MATCH_PATTERN
97
+ );
98
+ }
99
+ } catch (e) {
100
+ results.valid = false;
101
+ results.error = getErrorDescriptor(
102
+ ERROR_MESSAGE_CONSTANTS.INVALID_PATTERN
103
+ );
104
+ }
105
+ }
106
+ return results;
107
+ };
108
+ var getValidityValue = (existing, pending) => !existing ? false : pending;
109
+ var TYPE_KEYWORD_VALIDATORS = {
110
+ string: (value) => typeof value === "string",
111
+ number: (value) => typeof value === "number",
112
+ boolean: (value) => typeof value === "boolean"
113
+ };
114
+ var hasValue = (value) => {
115
+ if (typeof value === "undefined" || value === null) {
116
+ return false;
117
+ }
118
+ if (typeof value === "string") {
119
+ return value.length > 0;
120
+ }
121
+ return true;
122
+ };
123
+ var validateKeywordType = (value, type) => {
124
+ const validator = TYPE_KEYWORD_VALIDATORS[type];
125
+ let valid = true;
126
+ if (validator) {
127
+ valid = validator(value);
128
+ }
129
+ return valid;
130
+ };
131
+ var validateCustomType = (value, customType, customValidators) => {
132
+ let valid = true;
133
+ if (customValidators && customType) {
134
+ const validator = customValidators[customType];
135
+ if (validator) {
136
+ try {
137
+ valid = validator(value);
138
+ } catch (e) {
139
+ valid = false;
140
+ }
141
+ }
142
+ }
143
+ return valid;
144
+ };
145
+ var validateTypeInfoFieldValue = (value, typeInfoField, typeInfoMap, ignoreArray = false, strict = false, customValidators, typeOperation, relationshipValidationType = "STRICT_EXCLUDE" /* STRICT_EXCLUDE */, itemIsPartial) => {
146
+ const {
147
+ type,
148
+ typeReference,
149
+ array,
150
+ optional,
151
+ possibleValues,
152
+ tags: {
153
+ customType,
154
+ validation: {
155
+ emptyArrayIsValid: emptyArrayIsValidOverride = void 0
156
+ } = {},
157
+ constraints: {
158
+ pattern = void 0,
159
+ min = void 0,
160
+ max = void 0
161
+ } = {}
162
+ } = {}
163
+ } = typeInfoField;
164
+ const results = {
165
+ typeName: typeReference ?? type,
166
+ valid: true,
167
+ error: getNoErrorDescriptor(),
168
+ errorMap: {}
169
+ };
170
+ const requiredValueAllowed = !typeReference || relationshipValidationType === "INCLUDE" /* INCLUDE */;
171
+ const valueIsUndefined = typeof value === "undefined";
172
+ const valueIsNull = value === null;
173
+ const canSkipValidation = itemIsPartial && (valueIsUndefined || valueIsNull) || optional && valueIsUndefined;
174
+ const emptyArrayIsValid = emptyArrayIsValidOverride ?? false;
175
+ if (canSkipValidation) {
176
+ results.valid = true;
177
+ } else if (requiredValueAllowed && !itemIsPartial && !optional && !hasValue(value)) {
178
+ results.valid = false;
179
+ results.error = getErrorDescriptor(ERROR_MESSAGE_CONSTANTS.MISSING_FIELD_VALUE);
180
+ } else if (array && !ignoreArray && !Array.isArray(value)) {
181
+ results.valid = false;
182
+ results.error = getErrorDescriptor(ERROR_MESSAGE_CONSTANTS.INVALID_TYPE);
183
+ } else if (array && !ignoreArray && !optional && Array.isArray(value) && value.length === 0 && !emptyArrayIsValid) {
184
+ results.valid = false;
185
+ results.error = getErrorDescriptor(ERROR_MESSAGE_CONSTANTS.MISSING_FIELD_VALUE);
186
+ } else if (array && !ignoreArray) {
187
+ const {
188
+ valid: validArray,
189
+ error: arrayError,
190
+ errorMap: arrayErrorMap
191
+ } = validateArrayOfTypeInfoFieldValues(
192
+ value,
193
+ typeInfoField,
194
+ typeInfoMap,
195
+ strict,
196
+ customValidators,
197
+ typeOperation,
198
+ relationshipValidationType,
199
+ itemIsPartial
200
+ );
201
+ results.valid = getValidityValue(results.valid, validArray);
202
+ results.error = arrayError;
203
+ results.errorMap = arrayErrorMap;
204
+ } else {
205
+ if (typeReference) {
206
+ if (relationshipValidationType === "INCLUDE" /* INCLUDE */) {
207
+ const {
208
+ valid: validTypeInfo,
209
+ error: typeInfoError,
210
+ errorMap: typeInfoErrorMap
211
+ } = validateTypeInfoValue(
212
+ value,
213
+ typeReference,
214
+ typeInfoMap,
215
+ strict,
216
+ customValidators,
217
+ typeOperation,
218
+ relationshipValidationType,
219
+ itemIsPartial
220
+ );
221
+ results.valid = getValidityValue(results.valid, validTypeInfo);
222
+ results.error = typeInfoError;
223
+ results.errorMap = typeInfoErrorMap;
224
+ } else if (relationshipValidationType === "STRICT_EXCLUDE" /* STRICT_EXCLUDE */) {
225
+ const valueSupplied = typeof value !== "undefined";
226
+ if (valueSupplied) {
227
+ results.valid = false;
228
+ results.error = getErrorDescriptor(
229
+ ERROR_MESSAGE_CONSTANTS.RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED
230
+ );
231
+ }
232
+ } else if (relationshipValidationType === "EXCLUDE" /* EXCLUDE */) {
233
+ results.valid = getValidityValue(results.valid, true);
234
+ }
235
+ } else if (possibleValues && !possibleValues.includes(value)) {
236
+ results.valid = false;
237
+ results.error = getErrorDescriptor(
238
+ ERROR_MESSAGE_CONSTANTS.INVALID_OPTION
239
+ );
240
+ } else {
241
+ const pendingValid = validateKeywordType(value, type);
242
+ const customValid = validateCustomType(
243
+ value,
244
+ customType,
245
+ customValidators
246
+ );
247
+ results.valid = getValidityValue(results.valid, pendingValid);
248
+ results.valid = getValidityValue(results.valid, customValid);
249
+ if (type === "string" && typeof pattern === "string") {
250
+ const { valid: patternValid, error: patternError } = validateValueMatchesPattern(typeReference ?? type, value, pattern);
251
+ results.valid = getValidityValue(results.valid, patternValid);
252
+ results.error = patternError;
253
+ }
254
+ if (type === "number" && typeof value === "number") {
255
+ if (typeof min === "number" && value < min) {
256
+ results.valid = false;
257
+ results.error = getErrorDescriptor(
258
+ ERROR_MESSAGE_CONSTANTS.VALUE_BELOW_MINIMUM,
259
+ [`${min}`]
260
+ );
261
+ } else if (typeof max === "number" && value > max) {
262
+ results.valid = false;
263
+ results.error = getErrorDescriptor(
264
+ ERROR_MESSAGE_CONSTANTS.VALUE_ABOVE_MAXIMUM,
265
+ [`${max}`]
266
+ );
267
+ }
268
+ }
269
+ if (!customValid) {
270
+ results.error = getErrorDescriptor(
271
+ ERROR_MESSAGE_CONSTANTS.INVALID_CUSTOM_TYPE
272
+ );
273
+ } else if (!results.valid) {
274
+ results.error = results.error.code !== ERROR_MESSAGE_CONSTANTS.NONE ? results.error : getErrorDescriptor(
275
+ TYPE_KEYWORD_ERROR_MESSAGE_CONSTANTS[type]
276
+ );
277
+ }
278
+ }
279
+ }
280
+ return results;
281
+ };
282
+ var validateArrayOfTypeInfoFieldValues = (values = [], typeInfoField, typeInfoMap, strict = false, customValidators, typeOperation, relationshipValidationType, itemIsPartial) => {
283
+ const { type, typeReference } = typeInfoField;
284
+ const results = {
285
+ typeName: typeReference ?? type,
286
+ valid: true,
287
+ error: getNoErrorDescriptor(),
288
+ errorMap: {}
289
+ };
290
+ const itemErrorMap = {};
291
+ for (let i = 0; i < values.length; i++) {
292
+ const v = values[i];
293
+ const {
294
+ valid: indexValid,
295
+ error: indexError = getNoErrorDescriptor(),
296
+ errorMap: indexErrorMap
297
+ } = validateTypeInfoFieldValue(
298
+ v,
299
+ typeInfoField,
300
+ typeInfoMap,
301
+ true,
302
+ strict,
303
+ customValidators,
304
+ typeOperation,
305
+ relationshipValidationType,
306
+ itemIsPartial
307
+ );
308
+ results.valid = getValidityValue(results.valid, indexValid);
309
+ const indexErrors = [
310
+ ...indexError.code !== ERROR_MESSAGE_CONSTANTS.NONE ? [indexError] : [],
311
+ ...getErrorDescriptors(indexErrorMap[ARRAY_ITEM_ERROR_MAP_KEY] ?? []),
312
+ ...Object.entries(indexErrorMap).filter(([key]) => key !== ARRAY_ITEM_ERROR_MAP_KEY).flatMap(([, entries]) => getErrorDescriptors(entries)).filter((descriptor) => descriptor.code !== ERROR_MESSAGE_CONSTANTS.NONE)
313
+ ];
314
+ if (indexErrors.length) {
315
+ itemErrorMap[i] = indexErrors;
316
+ if (results.error.code === ERROR_MESSAGE_CONSTANTS.NONE) {
317
+ results.error = indexErrors[0];
318
+ }
319
+ }
320
+ for (const [er, entries] of Object.entries(indexErrorMap)) {
321
+ if (er === ARRAY_ITEM_ERROR_MAP_KEY) {
322
+ continue;
323
+ }
324
+ results.errorMap[getPathString([i, er])] = entries;
325
+ }
326
+ }
327
+ results.errorMap[ARRAY_ITEM_ERROR_MAP_KEY] = [{ itemErrorMap }];
328
+ return results;
329
+ };
330
+ var validateTypeInfoFieldOperationAllowed = (fieldName, fieldOperation, typeInfoField) => {
331
+ const results = {
332
+ typeName: null,
333
+ valid: true,
334
+ error: getNoErrorDescriptor(),
335
+ errorMap: {}
336
+ };
337
+ if (fieldOperation && typeInfoField) {
338
+ const {
339
+ type,
340
+ typeReference,
341
+ tags = {}
342
+ } = typeInfoField || {};
343
+ const { deniedOperations: { [fieldOperation]: denied = false } = {} } = tags;
344
+ results.typeName = typeReference ?? type;
345
+ results.valid = !denied;
346
+ if (!results.valid) {
347
+ results.error = getErrorDescriptor(
348
+ DENIED_TYPE_OPERATIONS[fieldOperation]
349
+ );
350
+ results.errorMap[fieldName] = [results.error];
351
+ }
352
+ }
353
+ return results;
354
+ };
355
+ var validateTypeOperationAllowed = (typeName, valueFields, typeOperation, typeInfo) => {
356
+ const results = {
357
+ typeName,
358
+ valid: true,
359
+ error: getNoErrorDescriptor(),
360
+ errorMap: {}
361
+ };
362
+ const { fields = {}, tags = {} } = typeInfo;
363
+ const { deniedOperations: { [typeOperation]: denied = false } = {} } = tags;
364
+ if (denied) {
365
+ results.valid = false;
366
+ results.error = getErrorDescriptor(DENIED_TYPE_OPERATIONS[typeOperation]);
367
+ } else {
368
+ for (const vF of valueFields) {
369
+ const vFieldInfo = fields[vF];
370
+ const { valid: vFValid, error: vFError } = validateTypeInfoFieldOperationAllowed(vF, typeOperation, vFieldInfo);
371
+ results.valid = getValidityValue(results.valid, vFValid);
372
+ if (!vFValid) {
373
+ results.errorMap[vF] = [vFError];
374
+ }
375
+ }
376
+ }
377
+ return results;
378
+ };
379
+ var TYPE_INFO_DATA_ITEM_TYPE_NAME = "__TYPE_INFO_DATA_ITEM__";
380
+ var validateTypeInfoDataItem = (value = {}, typeInfo, customValidatorMap = {}, options) => {
381
+ const {
382
+ typeName = TYPE_INFO_DATA_ITEM_TYPE_NAME,
383
+ typeInfoMap = {},
384
+ strict = true,
385
+ customTypeValidators,
386
+ typeOperation = "CREATE" /* CREATE */,
387
+ relationshipValidationType = "STRICT_EXCLUDE" /* STRICT_EXCLUDE */,
388
+ itemIsPartial = typeOperation === "UPDATE" /* UPDATE */,
389
+ validateHidden = false,
390
+ validateReadonly = false
391
+ } = options ?? {};
392
+ const sourceFields = typeInfo.fields ?? {};
393
+ const normalizedFields = {};
394
+ for (const [fieldName, field] of Object.entries(sourceFields)) {
395
+ const validationTags = field.tags?.validation ?? {};
396
+ const shouldValidateHidden = validationTags.validateHidden ?? validateHidden;
397
+ const shouldValidateReadonly = validationTags.validateReadonly ?? validateReadonly;
398
+ const shouldSkipRequiredChecks = field.tags?.hidden && !shouldValidateHidden || field.readonly && !shouldValidateReadonly;
399
+ normalizedFields[fieldName] = shouldSkipRequiredChecks ? {
400
+ ...field,
401
+ optional: true
402
+ } : field;
403
+ }
404
+ const normalizedTypeInfo = {
405
+ ...typeInfo,
406
+ fields: normalizedFields
407
+ };
408
+ const results = validateTypeInfoValue(
409
+ value ?? {},
410
+ typeName,
411
+ { ...typeInfoMap, [typeName]: normalizedTypeInfo },
412
+ strict,
413
+ customTypeValidators,
414
+ typeOperation,
415
+ relationshipValidationType,
416
+ itemIsPartial
417
+ );
418
+ for (const [fieldName, validator] of Object.entries(customValidatorMap)) {
419
+ const field = normalizedFields[fieldName];
420
+ if (!field) {
421
+ continue;
422
+ }
423
+ let error = getNoErrorDescriptor();
424
+ try {
425
+ error = validator(value[fieldName], field);
426
+ } catch (e) {
427
+ error = getErrorDescriptor(ERROR_MESSAGE_CONSTANTS.INVALID_CUSTOM_TYPE);
428
+ }
429
+ if (error.code !== ERROR_MESSAGE_CONSTANTS.NONE) {
430
+ results.valid = false;
431
+ results.errorMap[fieldName] = [
432
+ ...results.errorMap[fieldName] ?? [],
433
+ error
434
+ ];
435
+ if (results.error.code === ERROR_MESSAGE_CONSTANTS.NONE) {
436
+ results.error = error;
437
+ }
438
+ }
439
+ }
440
+ return results;
441
+ };
442
+ var validateTypeInfoValue = (value, typeInfoFullName, typeInfoMap, strict = false, customValidators, typeOperation, relationshipValidationType, itemIsPartial) => {
443
+ const typeInfo = typeInfoMap[typeInfoFullName];
444
+ const results = {
445
+ typeName: typeInfoFullName,
446
+ valid: !!typeInfo,
447
+ error: !!typeInfo ? getNoErrorDescriptor() : getErrorDescriptor(ERROR_MESSAGE_CONSTANTS.TYPE_DOES_NOT_EXIST),
448
+ errorMap: {}
449
+ };
450
+ if (typeInfo) {
451
+ const { primaryField, fields, unionFieldSets } = typeInfo;
452
+ if (typeOperation) {
453
+ const valueFields = typeof value === "object" ? Object.keys(value ?? {}) : [];
454
+ const {
455
+ valid: operationValid,
456
+ error: operationError,
457
+ errorMap: operationErrorMap
458
+ } = validateTypeOperationAllowed(
459
+ typeInfoFullName,
460
+ valueFields,
461
+ typeOperation,
462
+ typeInfo
463
+ );
464
+ results.valid = getValidityValue(results.valid, operationValid);
465
+ results.error = operationError;
466
+ for (const oE in operationErrorMap) {
467
+ const existingError = results.errorMap[oE] ?? [];
468
+ results.errorMap[oE] = existingError ? [...existingError, ...operationErrorMap[oE]] : operationErrorMap[oE];
469
+ }
470
+ if (!operationValid && operationError.code !== ERROR_MESSAGE_CONSTANTS.NONE) {
471
+ results.error = operationError;
472
+ }
473
+ }
474
+ if (unionFieldSets) {
475
+ const valueFields = Object.keys(value || {});
476
+ let valid = false;
477
+ for (const uFS of unionFieldSets) {
478
+ valid = valueFields.every((vF) => uFS.includes(vF));
479
+ if (valid) {
480
+ break;
481
+ }
482
+ }
483
+ if (!valid) {
484
+ results.valid = false;
485
+ results.error = getErrorDescriptor(
486
+ ERROR_MESSAGE_CONSTANTS.NO_UNION_TYPE_MATCHED
487
+ );
488
+ }
489
+ } else if (strict) {
490
+ const knownFields = Object.keys(fields || {});
491
+ const valueFields = Object.keys(value || {});
492
+ for (const vF of valueFields) {
493
+ if (!knownFields.includes(vF)) {
494
+ results.valid = false;
495
+ results.errorMap[vF] = [
496
+ getErrorDescriptor(ERROR_MESSAGE_CONSTANTS.INVALID_FIELD)
497
+ ];
498
+ }
499
+ }
500
+ }
501
+ if (fields) {
502
+ for (const key in fields) {
503
+ if (typeOperation !== "CREATE" /* CREATE */ || typeof primaryField !== "string" || key !== primaryField) {
504
+ const typeInfoField = fields[key];
505
+ const fieldValue = value[key];
506
+ const {
507
+ valid: fieldValid,
508
+ error: fieldError,
509
+ errorMap: fieldErrorMap
510
+ } = validateTypeInfoFieldValue(
511
+ fieldValue,
512
+ typeInfoField,
513
+ typeInfoMap,
514
+ false,
515
+ strict,
516
+ customValidators,
517
+ typeOperation,
518
+ relationshipValidationType,
519
+ itemIsPartial
520
+ );
521
+ results.valid = getValidityValue(results.valid, fieldValid);
522
+ const fieldEntries = [fieldError];
523
+ const arrayItemErrorMap = getArrayItemErrorMap(
524
+ fieldErrorMap[ARRAY_ITEM_ERROR_MAP_KEY]
525
+ );
526
+ if (Object.keys(arrayItemErrorMap).length) {
527
+ fieldEntries.push({ itemErrorMap: arrayItemErrorMap });
528
+ }
529
+ results.errorMap[key] = fieldEntries;
530
+ for (const [fE, entries] of Object.entries(fieldErrorMap)) {
531
+ if (fE === ARRAY_ITEM_ERROR_MAP_KEY) {
532
+ continue;
533
+ }
534
+ results.errorMap[getPathString([key, fE])] = entries;
535
+ }
536
+ }
537
+ }
538
+ }
539
+ if (!results.valid && results.error.code === ERROR_MESSAGE_CONSTANTS.NONE) {
540
+ results.error = getErrorDescriptor(ERROR_MESSAGE_CONSTANTS.INVALID_TYPE);
541
+ }
542
+ }
543
+ return results;
544
+ };
545
+
546
+ export { DENIED_TYPE_OPERATIONS, ERROR_MESSAGE_CONSTANTS, INVALID_CUSTOM_TYPE, PRIMITIVE_ERROR_MESSAGE_CONSTANTS, RelationshipValidationType, TYPE_KEYWORD_ERROR_MESSAGE_CONSTANTS, TYPE_KEYWORD_VALIDATORS, TypeOperation, getArrayItemErrorMap, getErrorDescriptor, getErrorDescriptors, getNoErrorDescriptor, getValidityValue, hasValue, isArrayErrorDescriptorCollection, validateArrayOfTypeInfoFieldValues, validateCustomType, validateKeywordType, validateTypeInfoDataItem, validateTypeInfoFieldOperationAllowed, validateTypeInfoFieldValue, validateTypeInfoValue, validateTypeOperationAllowed, validateValueMatchesPattern };