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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/README.md +75 -0
  2. package/SearchTypes-DjN6YQzE.d.ts +577 -0
  3. package/Types-C7XjUjoF.d.ts +240 -0
  4. package/Validation-CFP59oIP.d.ts +226 -0
  5. package/api/index.d.ts +6 -0
  6. package/api/index.js +7968 -0
  7. package/app/index.d.ts +5 -0
  8. package/app/index.js +810 -0
  9. package/common/Testing/CLI.js +432 -0
  10. package/common/index.d.ts +4 -0
  11. package/common/index.js +1760 -0
  12. package/iac/index.d.ts +2 -0
  13. package/iac/index.js +1661 -0
  14. package/iac/packs/index.d.ts +1 -0
  15. package/iac/packs/index.js +1620 -0
  16. package/index-BkFZlfit.d.ts +112 -0
  17. package/index-C3-iD9Mh.d.ts +690 -0
  18. package/index-DZ2BB4iX.d.ts +5357 -0
  19. package/{src/iac/types/IaCTypes.d.ts → index-DcvJOZ_c.d.ts} +1018 -23
  20. package/index-IokxSNxm.d.ts +745 -0
  21. package/index.d.ts +13 -0
  22. package/index.js +10973 -0
  23. package/package.json +40 -41
  24. package/src/api/DataAccessControl.d.ts +0 -85
  25. package/src/api/DataAccessControl.js +0 -159
  26. package/src/api/ORM/DACUtils.d.ts +0 -60
  27. package/src/api/ORM/DACUtils.js +0 -197
  28. package/src/api/ORM/ListItemUtils.d.ts +0 -7
  29. package/src/api/ORM/ListItemUtils.js +0 -22
  30. package/src/api/ORM/ORMRouteMap.d.ts +0 -19
  31. package/src/api/ORM/ORMRouteMap.js +0 -82
  32. package/src/api/ORM/TypeInfoORMService.d.ts +0 -103
  33. package/src/api/ORM/TypeInfoORMService.js +0 -581
  34. package/src/api/ORM/drivers/DynamoDBDataItemDBDriver/ConfigTypes.d.ts +0 -63
  35. package/src/api/ORM/drivers/DynamoDBDataItemDBDriver/ConfigTypes.js +0 -2
  36. package/src/api/ORM/drivers/DynamoDBDataItemDBDriver.d.ts +0 -36
  37. package/src/api/ORM/drivers/DynamoDBDataItemDBDriver.js +0 -282
  38. package/src/api/ORM/drivers/S3FileItemDBDriver/ConfigTypes.d.ts +0 -90
  39. package/src/api/ORM/drivers/S3FileItemDBDriver/ConfigTypes.js +0 -2
  40. package/src/api/ORM/drivers/S3FileItemDBDriver/S3FileDriver.d.ts +0 -45
  41. package/src/api/ORM/drivers/S3FileItemDBDriver/S3FileDriver.js +0 -127
  42. package/src/api/ORM/drivers/S3FileItemDBDriver.d.ts +0 -44
  43. package/src/api/ORM/drivers/S3FileItemDBDriver.js +0 -182
  44. package/src/api/ORM/drivers/common/SupportedTypeInfoORMDBDrivers.d.ts +0 -12
  45. package/src/api/ORM/drivers/common/SupportedTypeInfoORMDBDrivers.js +0 -20
  46. package/src/api/ORM/drivers/common/Types.d.ts +0 -77
  47. package/src/api/ORM/drivers/common/Types.js +0 -14
  48. package/src/api/ORM/drivers/common/index.d.ts +0 -2
  49. package/src/api/ORM/drivers/common/index.js +0 -18
  50. package/src/api/ORM/drivers/index.d.ts +0 -3
  51. package/src/api/ORM/drivers/index.js +0 -19
  52. package/src/api/ORM/index.d.ts +0 -4
  53. package/src/api/ORM/index.js +0 -43
  54. package/src/api/Router/AWS.d.ts +0 -26
  55. package/src/api/Router/AWS.js +0 -76
  56. package/src/api/Router/Auth.d.ts +0 -2
  57. package/src/api/Router/Auth.js +0 -9
  58. package/src/api/Router/CORS.d.ts +0 -6
  59. package/src/api/Router/CORS.js +0 -27
  60. package/src/api/Router/Types.d.ts +0 -71
  61. package/src/api/Router/Types.js +0 -2
  62. package/src/api/Router/index.d.ts +0 -18
  63. package/src/api/Router/index.js +0 -145
  64. package/src/api/index.d.ts +0 -3
  65. package/src/api/index.js +0 -39
  66. package/src/app/index.d.ts +0 -1
  67. package/src/app/index.js +0 -37
  68. package/src/app/utils/ApplicationState.d.ts +0 -52
  69. package/src/app/utils/ApplicationState.js +0 -86
  70. package/src/app/utils/ApplicationStateLoader.d.ts +0 -46
  71. package/src/app/utils/ApplicationStateLoader.js +0 -57
  72. package/src/app/utils/Controller.d.ts +0 -4
  73. package/src/app/utils/Controller.js +0 -47
  74. package/src/app/utils/Debug.d.ts +0 -4
  75. package/src/app/utils/Debug.js +0 -30
  76. package/src/app/utils/EasyLayout.d.ts +0 -49
  77. package/src/app/utils/EasyLayout.js +0 -122
  78. package/src/app/utils/Route.d.ts +0 -28
  79. package/src/app/utils/Route.js +0 -102
  80. package/src/app/utils/Service.d.ts +0 -12
  81. package/src/app/utils/Service.js +0 -34
  82. package/src/app/utils/TypeInfoORMAPIUtils.d.ts +0 -20
  83. package/src/app/utils/TypeInfoORMAPIUtils.js +0 -62
  84. package/src/app/utils/TypeInfoORMClient.d.ts +0 -24
  85. package/src/app/utils/TypeInfoORMClient.js +0 -69
  86. package/src/app/utils/index.d.ts +0 -8
  87. package/src/app/utils/index.js +0 -24
  88. package/src/common/CommandLine/collectRequiredEnvironmentVariables.d.ts +0 -1
  89. package/src/common/CommandLine/collectRequiredEnvironmentVariables.js +0 -16
  90. package/src/common/HelperTypes.d.ts +0 -3
  91. package/src/common/HelperTypes.js +0 -2
  92. package/src/common/IdGeneration/getSimpleId.d.ts +0 -4
  93. package/src/common/IdGeneration/getSimpleId.js +0 -16
  94. package/src/common/IdGeneration/index.d.ts +0 -1
  95. package/src/common/IdGeneration/index.js +0 -17
  96. package/src/common/ItemRelationshipInfoTypes.d.ts +0 -46
  97. package/src/common/ItemRelationshipInfoTypes.js +0 -20
  98. package/src/common/ItemRelationships/ItemRelationshipValidation.d.ts +0 -10
  99. package/src/common/ItemRelationships/ItemRelationshipValidation.js +0 -43
  100. package/src/common/ItemRelationships/index.d.ts +0 -1
  101. package/src/common/ItemRelationships/index.js +0 -17
  102. package/src/common/Logging/Utils.d.ts +0 -10
  103. package/src/common/Logging/Utils.js +0 -33
  104. package/src/common/Logging/index.d.ts +0 -1
  105. package/src/common/Logging/index.js +0 -17
  106. package/src/common/Routing.d.ts +0 -25
  107. package/src/common/Routing.js +0 -102
  108. package/src/common/SearchTypes.d.ts +0 -98
  109. package/src/common/SearchTypes.js +0 -39
  110. package/src/common/SearchUtils.d.ts +0 -22
  111. package/src/common/SearchUtils.js +0 -134
  112. package/src/common/SearchValidation.d.ts +0 -17
  113. package/src/common/SearchValidation.js +0 -90
  114. package/src/common/Storyboarding/Types.d.ts +0 -25
  115. package/src/common/Storyboarding/Types.js +0 -2
  116. package/src/common/StringTransformers.d.ts +0 -17
  117. package/src/common/StringTransformers.js +0 -36
  118. package/src/common/Testing/CLI.d.ts +0 -2
  119. package/src/common/Testing/CLI.js +0 -56
  120. package/src/common/Testing/Types.d.ts +0 -117
  121. package/src/common/Testing/Types.js +0 -19
  122. package/src/common/Testing/Utils.d.ts +0 -48
  123. package/src/common/Testing/Utils.js +0 -334
  124. package/src/common/Testing/index.d.ts +0 -2
  125. package/src/common/Testing/index.js +0 -18
  126. package/src/common/TypeInfoDataItemUtils.d.ts +0 -10
  127. package/src/common/TypeInfoDataItemUtils.js +0 -55
  128. package/src/common/TypeInfoORM/Types.d.ts +0 -76
  129. package/src/common/TypeInfoORM/Types.js +0 -55
  130. package/src/common/TypeInfoORM/index.d.ts +0 -1
  131. package/src/common/TypeInfoORM/index.js +0 -17
  132. package/src/common/TypeParsing/Constants.d.ts +0 -1
  133. package/src/common/TypeParsing/Constants.js +0 -4
  134. package/src/common/TypeParsing/ParsingUtils/Constants.d.ts +0 -5
  135. package/src/common/TypeParsing/ParsingUtils/Constants.js +0 -8
  136. package/src/common/TypeParsing/ParsingUtils/checkType.d.ts +0 -8
  137. package/src/common/TypeParsing/ParsingUtils/checkType.js +0 -46
  138. package/src/common/TypeParsing/ParsingUtils/checkUnionType.d.ts +0 -6
  139. package/src/common/TypeParsing/ParsingUtils/checkUnionType.js +0 -15
  140. package/src/common/TypeParsing/ParsingUtils/extractCommentTags.d.ts +0 -2
  141. package/src/common/TypeParsing/ParsingUtils/extractCommentTags.js +0 -105
  142. package/src/common/TypeParsing/ParsingUtils/extractLiteralValues.d.ts +0 -6
  143. package/src/common/TypeParsing/ParsingUtils/extractLiteralValues.js +0 -42
  144. package/src/common/TypeParsing/ParsingUtils/extractTypeDetails.d.ts +0 -8
  145. package/src/common/TypeParsing/ParsingUtils/extractTypeDetails.js +0 -14
  146. package/src/common/TypeParsing/ParsingUtils/getPrimaryFieldForTypeInfo.d.ts +0 -5
  147. package/src/common/TypeParsing/ParsingUtils/getPrimaryFieldForTypeInfo.js +0 -27
  148. package/src/common/TypeParsing/ParsingUtils/getTypeInfo.d.ts +0 -3
  149. package/src/common/TypeParsing/ParsingUtils/getTypeInfo.js +0 -27
  150. package/src/common/TypeParsing/ParsingUtils/getTypeInfoField.d.ts +0 -3
  151. package/src/common/TypeParsing/ParsingUtils/getTypeInfoField.js +0 -44
  152. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromAliasType.d.ts +0 -4
  153. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromAliasType.js +0 -28
  154. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromFieldFilter.d.ts +0 -4
  155. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromFieldFilter.js +0 -105
  156. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromTypeAlias.d.ts +0 -4
  157. package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromTypeAlias.js +0 -20
  158. package/src/common/TypeParsing/ParsingUtils/getTypeKeyword.d.ts +0 -3
  159. package/src/common/TypeParsing/ParsingUtils/getTypeKeyword.js +0 -17
  160. package/src/common/TypeParsing/ParsingUtils/getUnionOrIntersectionTypeInfo.d.ts +0 -4
  161. package/src/common/TypeParsing/ParsingUtils/getUnionOrIntersectionTypeInfo.js +0 -49
  162. package/src/common/TypeParsing/ParsingUtils/getUnionOrLiteralStringValues.d.ts +0 -2
  163. package/src/common/TypeParsing/ParsingUtils/getUnionOrLiteralStringValues.js +0 -24
  164. package/src/common/TypeParsing/TypeInfo.d.ts +0 -142
  165. package/src/common/TypeParsing/TypeInfo.js +0 -13
  166. package/src/common/TypeParsing/TypeMapping.d.ts +0 -9
  167. package/src/common/TypeParsing/TypeMapping.js +0 -32
  168. package/src/common/TypeParsing/TypeParsing.d.ts +0 -5
  169. package/src/common/TypeParsing/TypeParsing.js +0 -39
  170. package/src/common/TypeParsing/Utils.d.ts +0 -21
  171. package/src/common/TypeParsing/Utils.js +0 -94
  172. package/src/common/TypeParsing/Validation.d.ts +0 -92
  173. package/src/common/TypeParsing/Validation.js +0 -340
  174. package/src/common/TypeParsing/index.d.ts +0 -5
  175. package/src/common/TypeParsing/index.js +0 -44
  176. package/src/common/index.d.ts +0 -11
  177. package/src/common/index.js +0 -47
  178. package/src/iac/SimpleCFT.d.ts +0 -48
  179. package/src/iac/SimpleCFT.js +0 -82
  180. package/src/iac/index.d.ts +0 -9
  181. package/src/iac/index.js +0 -48
  182. package/src/iac/packs/auth/user-management.d.ts +0 -14
  183. package/src/iac/packs/auth/user-management.js +0 -302
  184. package/src/iac/packs/auth.d.ts +0 -19
  185. package/src/iac/packs/auth.js +0 -47
  186. package/src/iac/packs/build/utils.d.ts +0 -100
  187. package/src/iac/packs/build/utils.js +0 -23
  188. package/src/iac/packs/build.d.ts +0 -29
  189. package/src/iac/packs/build.js +0 -217
  190. package/src/iac/packs/cdn.d.ts +0 -12
  191. package/src/iac/packs/cdn.js +0 -126
  192. package/src/iac/packs/cloud-function.d.ts +0 -17
  193. package/src/iac/packs/cloud-function.js +0 -69
  194. package/src/iac/packs/database.d.ts +0 -29
  195. package/src/iac/packs/database.js +0 -27
  196. package/src/iac/packs/dns.d.ts +0 -13
  197. package/src/iac/packs/dns.js +0 -26
  198. package/src/iac/packs/file-storage.d.ts +0 -14
  199. package/src/iac/packs/file-storage.js +0 -71
  200. package/src/iac/packs/gateway.d.ts +0 -27
  201. package/src/iac/packs/gateway.js +0 -342
  202. package/src/iac/packs/index.d.ts +0 -11
  203. package/src/iac/packs/index.js +0 -27
  204. package/src/iac/packs/repo.d.ts +0 -10
  205. package/src/iac/packs/repo.js +0 -34
  206. package/src/iac/packs/ssl-certificate.d.ts +0 -10
  207. package/src/iac/packs/ssl-certificate.js +0 -36
  208. package/src/iac/types/CloudFormationResourceSpecification.d.ts +0 -2
  209. package/src/iac/types/Constants.d.ts +0 -9
  210. package/src/iac/types/Constants.js +0 -20
  211. package/src/iac/types/IaCTypes.js +0 -14
  212. package/src/iac/types/Renderers.d.ts +0 -12
  213. package/src/iac/types/Renderers.js +0 -112
  214. package/src/iac/types/Types.d.ts +0 -37
  215. package/src/iac/types/Types.js +0 -2
  216. package/src/iac/types/Utils.d.ts +0 -2
  217. package/src/iac/types/Utils.js +0 -60
  218. package/src/iac/types/generate.d.ts +0 -1
  219. package/src/iac/types/generate.js +0 -31
  220. package/src/iac/utils/index.d.ts +0 -36
  221. package/src/iac/utils/index.js +0 -105
  222. package/src/iac/utils/patch-utils.d.ts +0 -15
  223. package/src/iac/utils/patch-utils.js +0 -62
  224. package/src/index.d.ts +0 -178
  225. package/src/index.js +0 -214
@@ -1,145 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.handleCloudFunctionEvent = exports.addRouteMapToRouteMap = exports.addRoutesToRouteMap = exports.addRouteToRouteMap = void 0;
18
- const Auth_1 = require("./Auth");
19
- const CORS_1 = require("./CORS");
20
- const Routing_1 = require("../../common/Routing");
21
- const Utils_1 = require("../../common/Logging/Utils");
22
- __exportStar(require("./AWS"), exports);
23
- /**
24
- * A utility function to add a route to a route map by path.
25
- * */
26
- const addRouteToRouteMap = (routeMap, route, basePath = "") => {
27
- const { path: routePath } = route;
28
- const path = (0, Routing_1.mergeStringPaths)(basePath, routePath);
29
- return {
30
- ...routeMap,
31
- [path]: route,
32
- };
33
- };
34
- exports.addRouteToRouteMap = addRouteToRouteMap;
35
- /**
36
- * Add multiple routes to a {@link RouteMap} by path.
37
- * */
38
- const addRoutesToRouteMap = (routeMap, routes, basePath = "") => {
39
- let newRouteMap = {
40
- ...routeMap,
41
- };
42
- for (const route of routes) {
43
- newRouteMap = (0, exports.addRouteToRouteMap)(newRouteMap, route, basePath);
44
- }
45
- return newRouteMap;
46
- };
47
- exports.addRoutesToRouteMap = addRoutesToRouteMap;
48
- /**
49
- * Apply one {@link RouteMap} to another.
50
- * */
51
- const addRouteMapToRouteMap = (routeMap, routeMapToAdd, basePath = "") => {
52
- const newRouteMap = {
53
- ...routeMap,
54
- };
55
- for (const k in routeMapToAdd) {
56
- const path = (0, Routing_1.mergeStringPaths)(basePath, k);
57
- newRouteMap[path] = routeMapToAdd[k];
58
- }
59
- return newRouteMap;
60
- };
61
- exports.addRouteMapToRouteMap = addRouteMapToRouteMap;
62
- /**
63
- * A Cloud Function event router.
64
- * */
65
- const handleCloudFunctionEvent = async (event, eventTransformer, routeMap, allowedOrigins, errorShouldBeExposedToClient, debug = false) => {
66
- let transformedEvent = undefined;
67
- try {
68
- transformedEvent = eventTransformer(event);
69
- }
70
- catch (error) {
71
- // Ignore.
72
- }
73
- if (transformedEvent) {
74
- const { authInfo, headers: { origin: originItems = [] } = {}, path = "",
75
- // IMPORTANT: Respond automatically to all OPTIONS requests.
76
- method,
77
- // IMPORTANT: Should be an array of arguments.
78
- body = [], } = transformedEvent;
79
- const providedOrigin = originItems[0];
80
- const normalizedOrigin = typeof providedOrigin === "string" ? providedOrigin : "";
81
- const normalizedBody = Array.isArray(body) ? body : [body];
82
- const normalizedPath = (0, Routing_1.getPathString)((0, Routing_1.getPathArray)(`${path}`));
83
- const route = routeMap[normalizedPath];
84
- const responseHeaders = (0, CORS_1.getHeadersWithCORS)(normalizedOrigin, allowedOrigins);
85
- if (method === "OPTIONS") {
86
- return {
87
- statusCode: 200,
88
- headers: responseHeaders,
89
- body: "OK",
90
- };
91
- }
92
- else {
93
- if (route) {
94
- const { authConfig = {}, handlerFactory, handler } = route;
95
- const requestIsAuthorized = (0, Auth_1.getRouteIsAuthorized)(authInfo, authConfig);
96
- if (requestIsAuthorized) {
97
- const handlerInstance = handler
98
- ? handler
99
- : handlerFactory(transformedEvent);
100
- try {
101
- const result = await (0, Utils_1.logFunctionCall)(normalizedPath, normalizedBody, handlerInstance, debug);
102
- return {
103
- statusCode: 200,
104
- headers: responseHeaders,
105
- body: JSON.stringify(result),
106
- };
107
- }
108
- catch (error) {
109
- return {
110
- statusCode: 500,
111
- headers: responseHeaders,
112
- body: JSON.stringify({
113
- status: "Internal Server Error",
114
- message: error?.message,
115
- error: errorShouldBeExposedToClient
116
- ? errorShouldBeExposedToClient(error)
117
- ? error
118
- : undefined
119
- : undefined,
120
- }, null, 2),
121
- };
122
- }
123
- }
124
- else {
125
- return {
126
- statusCode: 401,
127
- headers: responseHeaders,
128
- body: "Unauthorized",
129
- };
130
- }
131
- }
132
- return {
133
- statusCode: 404,
134
- headers: responseHeaders,
135
- body: "Not Found",
136
- };
137
- }
138
- }
139
- return {
140
- statusCode: 500,
141
- headers: {},
142
- body: "Internal Server Error",
143
- };
144
- };
145
- exports.handleCloudFunctionEvent = handleCloudFunctionEvent;
@@ -1,3 +0,0 @@
1
- export * as ORM from "./ORM";
2
- export * as Routing from "./Router";
3
- export * as DAC from "./DataAccessControl";
package/src/api/index.js DELETED
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.DAC = exports.Routing = exports.ORM = void 0;
37
- exports.ORM = __importStar(require("./ORM"));
38
- exports.Routing = __importStar(require("./Router"));
39
- exports.DAC = __importStar(require("./DataAccessControl"));
@@ -1 +0,0 @@
1
- export * as Utils from "./utils";
package/src/app/index.js DELETED
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.Utils = void 0;
37
- exports.Utils = __importStar(require("./utils"));
@@ -1,52 +0,0 @@
1
- import { FC, PropsWithChildren } from "react";
2
- /**
3
- * An object, nested or not, used as the identifier or identifier path for a state value.
4
- * */
5
- export interface ApplicationStateIdentifier extends Record<string, ApplicationStateIdentifier | {}> {
6
- }
7
- export type ApplicationStateValue = any;
8
- export type ApplicationStateModificationState = Map<ApplicationStateIdentifier, boolean>;
9
- export type ApplicationState = Map<ApplicationStateIdentifier, ApplicationStateValue>;
10
- export type ApplicationStateIdentifierSubStateType<SpecificType> = SpecificType extends undefined ? ApplicationStateIdentifier : SpecificType extends ApplicationStateIdentifier ? SpecificType : never;
11
- export declare const getApplicationStateIdentifier: <SubStateIdStructure extends ApplicationStateIdentifier>(subStateIdMap?: SubStateIdStructure) => ApplicationStateIdentifierSubStateType<SubStateIdStructure>;
12
- export declare const getApplicationStateModified: (identifier: ApplicationStateIdentifier, modificationState: ApplicationStateModificationState) => boolean;
13
- export declare const getApplicationStateValue: (identifier: ApplicationStateIdentifier, applicationState: ApplicationState) => ApplicationStateValue;
14
- export declare const setApplicationStateModified: (identifier: ApplicationStateIdentifier, value: boolean, modificationState: ApplicationState) => ApplicationStateModificationState;
15
- export declare const setApplicationStateValue: (identifier: ApplicationStateIdentifier, value: ApplicationStateValue, applicationState: ApplicationState) => ApplicationState;
16
- export declare const getApplicationStateValueStructure: <ReturnStructureType extends Record<string, any>>(idStructure: Record<keyof ReturnStructureType, ApplicationStateIdentifier>, applicationState: ApplicationState) => ReturnStructureType;
17
- export type ApplicationStateContextType = {
18
- modified: ApplicationStateModificationState;
19
- value: ApplicationState;
20
- onChange: (newValue: ApplicationState) => void;
21
- setModified: (newValue: ApplicationStateModificationState) => void;
22
- };
23
- export declare const ApplicationStateContext: import("react").Context<ApplicationStateContextType>;
24
- /**
25
- * Used to access and update application state values.
26
- * */
27
- export type ApplicationStateValueController = {
28
- modified: boolean;
29
- value: ApplicationStateValue;
30
- onChange: (value: ApplicationStateValue) => void;
31
- setModified: (value: boolean) => void;
32
- };
33
- /**
34
- * Get and set an application state value by identifier.
35
- * */
36
- export declare const useApplicationStateValue: (identifier: ApplicationStateIdentifier) => ApplicationStateValueController;
37
- /**
38
- * A mapped structure of application state value controllers.
39
- * */
40
- export type ApplicationStateValueStructureController<StructureType extends Record<string, any>> = {
41
- valueStructure: StructureType;
42
- onChangeStructure: Record<keyof StructureType, (newValue: any) => void>;
43
- };
44
- /**
45
- * Use an object that is a collection of application state value controllers.
46
- * */
47
- export declare const useApplicationStateValueStructure: <StructureType extends Record<string, any>>(idStructure: Record<keyof StructureType, ApplicationStateIdentifier>) => ApplicationStateValueStructureController<StructureType>;
48
- export type ApplicationStateProviderProps = PropsWithChildren<{}>;
49
- /**
50
- * Provide a context container for application state.
51
- * */
52
- export declare const ApplicationStateProvider: FC<ApplicationStateProviderProps>;
@@ -1,86 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApplicationStateProvider = exports.useApplicationStateValueStructure = exports.useApplicationStateValue = exports.ApplicationStateContext = exports.getApplicationStateValueStructure = exports.setApplicationStateValue = exports.setApplicationStateModified = exports.getApplicationStateValue = exports.getApplicationStateModified = exports.getApplicationStateIdentifier = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- const getApplicationStateIdentifier = (subStateIdMap) => (subStateIdMap ? subStateIdMap : {});
7
- exports.getApplicationStateIdentifier = getApplicationStateIdentifier;
8
- const getApplicationStateModified = (identifier, modificationState) => !!modificationState.get(identifier);
9
- exports.getApplicationStateModified = getApplicationStateModified;
10
- const getApplicationStateValue = (identifier, applicationState) => applicationState.get(identifier);
11
- exports.getApplicationStateValue = getApplicationStateValue;
12
- const setApplicationStateModified = (identifier, value, modificationState) => new Map(modificationState).set(identifier, value);
13
- exports.setApplicationStateModified = setApplicationStateModified;
14
- const setApplicationStateValue = (identifier, value, applicationState) => new Map(applicationState).set(identifier, value);
15
- exports.setApplicationStateValue = setApplicationStateValue;
16
- const getApplicationStateValueStructure = (idStructure, applicationState) => Object.keys(idStructure).reduce((acc, k) => ({
17
- ...acc,
18
- [k]: (0, exports.getApplicationStateValue)(idStructure[k], applicationState),
19
- }), {});
20
- exports.getApplicationStateValueStructure = getApplicationStateValueStructure;
21
- exports.ApplicationStateContext = (0, react_1.createContext)({
22
- modified: new Map(),
23
- value: new Map(),
24
- onChange: () => { },
25
- setModified: () => { },
26
- });
27
- const { Provider } = exports.ApplicationStateContext;
28
- /**
29
- * Get and set an application state value by identifier.
30
- * */
31
- const useApplicationStateValue = (identifier) => {
32
- const { modified: modificationState, value: applicationState, onChange: setApplicationState, setModified: setModificationState, } = (0, react_1.useContext)(exports.ApplicationStateContext);
33
- const appStateRef = (0, react_1.useRef)(applicationState);
34
- appStateRef.current = applicationState;
35
- const modified = (0, react_1.useMemo)(() => (0, exports.getApplicationStateModified)(identifier, modificationState), [identifier, modificationState]);
36
- const value = (0, react_1.useMemo)(() => (0, exports.getApplicationStateValue)(identifier, applicationState), [identifier, applicationState]);
37
- const setModified = (0, react_1.useCallback)((isModified) => {
38
- setModificationState((0, exports.setApplicationStateModified)(identifier, isModified, modificationState));
39
- }, [identifier, setModificationState]);
40
- const onChange = (0, react_1.useCallback)((newValue) => {
41
- setApplicationState((0, exports.setApplicationStateValue)(identifier, newValue, appStateRef.current));
42
- setModified(true);
43
- }, [identifier, setApplicationState]);
44
- const controller = (0, react_1.useMemo)(() => ({
45
- modified,
46
- value,
47
- onChange,
48
- setModified,
49
- }), [modified, onChange, setModified, value]);
50
- return controller;
51
- };
52
- exports.useApplicationStateValue = useApplicationStateValue;
53
- /**
54
- * Use an object that is a collection of application state value controllers.
55
- * */
56
- const useApplicationStateValueStructure = (idStructure) => {
57
- const { value: applicationState, onChange: setApplicationState } = (0, react_1.useContext)(exports.ApplicationStateContext);
58
- const valueStructure = (0, react_1.useMemo)(() => (0, exports.getApplicationStateValueStructure)(idStructure, applicationState), [applicationState, idStructure]);
59
- const onChangeStructure = (0, react_1.useMemo)(() => Object.keys(idStructure).reduce((acc, k) => ({
60
- ...acc,
61
- [k]: (newValue) => {
62
- setApplicationState((0, exports.setApplicationStateValue)(idStructure[k], newValue, applicationState));
63
- },
64
- }), {}), [applicationState, idStructure, setApplicationState]);
65
- const controller = (0, react_1.useMemo)(() => ({
66
- valueStructure,
67
- onChangeStructure,
68
- }), [onChangeStructure, valueStructure]);
69
- return controller;
70
- };
71
- exports.useApplicationStateValueStructure = useApplicationStateValueStructure;
72
- /**
73
- * Provide a context container for application state.
74
- * */
75
- const ApplicationStateProvider = ({ children, }) => {
76
- const [modified, setModified] = (0, react_1.useState)(new Map());
77
- const [value, setValue] = (0, react_1.useState)(new Map());
78
- const controller = (0, react_1.useMemo)(() => ({
79
- modified,
80
- value,
81
- onChange: setValue,
82
- setModified,
83
- }), [modified, value]);
84
- return (0, jsx_runtime_1.jsx)(Provider, { value: controller, children: children });
85
- };
86
- exports.ApplicationStateProvider = ApplicationStateProvider;
@@ -1,46 +0,0 @@
1
- import { ApplicationStateIdentifier } from "./ApplicationState";
2
- import { ServiceConfig } from "./Service";
3
- /**
4
- * Access and track the loading of an application state value.
5
- * */
6
- export type ApplicationStateLoader = {
7
- loading: boolean;
8
- latestError: any;
9
- invalidate: () => void;
10
- makeRemoteProcedureCall: (...args: any[]) => Promise<void>;
11
- };
12
- /**
13
- * The service, path and arguments to use for a remote procedure call.
14
- * */
15
- export type RemoteProcedureCall = {
16
- serviceConfig: ServiceConfig;
17
- path: string;
18
- args?: any[];
19
- };
20
- /**
21
- * The configuration for an application state loader.
22
- * */
23
- export type ApplicationStateLoaderConfig = {
24
- identifier: ApplicationStateIdentifier;
25
- remoteProcedureCall: RemoteProcedureCall;
26
- /**
27
- * Clear the application state value on error.
28
- *
29
- * @default false
30
- * */
31
- resetOnError?: boolean;
32
- /**
33
- * Called each time the application state value has been loaded.
34
- * */
35
- onLoadComplete?: (success: boolean) => void;
36
- /**
37
- * Prevent automatic loading of the application state value and call the `RemoteProcedureCall` manually with `makeRemoteProcedureCall` on the `ApplicationStateLoader`.
38
- *
39
- * @default false
40
- * */
41
- manual?: boolean;
42
- };
43
- /**
44
- * Load, track and access an application state value.
45
- * */
46
- export declare const useApplicationStateLoader: (config: ApplicationStateLoaderConfig) => ApplicationStateLoader;
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useApplicationStateLoader = void 0;
4
- const ApplicationState_1 = require("./ApplicationState");
5
- const Service_1 = require("./Service");
6
- const react_1 = require("react");
7
- /**
8
- * Load, track and access an application state value.
9
- * */
10
- const useApplicationStateLoader = (config) => {
11
- const { identifier, remoteProcedureCall, resetOnError = false, onLoadComplete, manual = false, } = config;
12
- const { args = [] } = remoteProcedureCall;
13
- const argsRef = (0, react_1.useRef)(args);
14
- argsRef.current = args;
15
- const [cacheValidity, setCacheValidity] = (0, react_1.useState)({});
16
- const [loading, setLoading] = (0, react_1.useState)(false);
17
- const [latestError, setLatestError] = (0, react_1.useState)();
18
- const { onChange, setModified } = (0, ApplicationState_1.useApplicationStateValue)(identifier);
19
- const invalidate = (0, react_1.useCallback)(() => {
20
- setCacheValidity({});
21
- }, []);
22
- const makeRemoteProcedureCall = (0, react_1.useCallback)(async (...directArgs) => {
23
- let success;
24
- setLoading(true);
25
- setLatestError(undefined);
26
- try {
27
- const { serviceConfig, path } = remoteProcedureCall;
28
- const result = await (0, Service_1.sendServiceRequest)(serviceConfig, path, directArgs);
29
- success = true;
30
- onChange(result);
31
- setModified(false);
32
- }
33
- catch (error) {
34
- success = false;
35
- setLatestError(error);
36
- if (resetOnError) {
37
- onChange(undefined);
38
- setModified(false);
39
- }
40
- }
41
- setLoading(false);
42
- onLoadComplete?.(success);
43
- }, [remoteProcedureCall, onChange, setModified, resetOnError, onLoadComplete]);
44
- const appStateLoader = (0, react_1.useMemo)(() => ({
45
- loading,
46
- latestError,
47
- invalidate,
48
- makeRemoteProcedureCall,
49
- }), [loading, latestError, invalidate, makeRemoteProcedureCall]);
50
- (0, react_1.useEffect)(() => {
51
- if (!manual && argsRef.current) {
52
- makeRemoteProcedureCall(...argsRef.current);
53
- }
54
- }, [cacheValidity, manual, makeRemoteProcedureCall]);
55
- return appStateLoader;
56
- };
57
- exports.useApplicationStateLoader = useApplicationStateLoader;
@@ -1,4 +0,0 @@
1
- /**
2
- * Safely access and update a value in a parent object by its key.
3
- * */
4
- export declare const useController: (parentValue: any, key: string | number, onParentValueChange: (value: any) => void, isArrayIndex?: boolean) => any[];
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useController = void 0;
4
- const react_1 = require("react");
5
- const getKeyValueWithoutError = (obj, key) => {
6
- try {
7
- return obj[key];
8
- }
9
- catch (e) {
10
- return undefined;
11
- }
12
- };
13
- /**
14
- * Safely access and update a value in a parent object by its key.
15
- * */
16
- const useController = (parentValue, key, onParentValueChange, isArrayIndex = false) => {
17
- const [value, setValue] = (0, react_1.useState)(getKeyValueWithoutError(parentValue, key));
18
- const onChange = (0, react_1.useCallback)((value) => {
19
- try {
20
- setValue(value);
21
- if (isArrayIndex) {
22
- const newArray = [...parentValue];
23
- newArray[key] = value;
24
- onParentValueChange(newArray);
25
- }
26
- else {
27
- onParentValueChange({
28
- ...parentValue,
29
- [key]: value,
30
- });
31
- }
32
- }
33
- catch (e) {
34
- // Ignore.
35
- }
36
- }, [parentValue, key, onParentValueChange, isArrayIndex]);
37
- (0, react_1.useEffect)(() => {
38
- try {
39
- setValue(getKeyValueWithoutError(parentValue, key));
40
- }
41
- catch (e) {
42
- setValue(undefined);
43
- }
44
- }, [parentValue, key]);
45
- return [value, onChange];
46
- };
47
- exports.useController = useController;
@@ -1,4 +0,0 @@
1
- /**
2
- * Examines the changes in the dependencies of a hook.
3
- * */
4
- export declare const useDebugDependencies: (dependencies: any[]) => void;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useDebugDependencies = void 0;
4
- const react_1 = require("react");
5
- /**
6
- * Examines the changes in the dependencies of a hook.
7
- * */
8
- const useDebugDependencies = (dependencies) => {
9
- const firstRender = (0, react_1.useRef)(true);
10
- const prevDeps = (0, react_1.useRef)(dependencies);
11
- (0, react_1.useEffect)(() => {
12
- if (firstRender.current) {
13
- firstRender.current = false;
14
- return;
15
- }
16
- const changedDeps = dependencies
17
- .map((dep, i) => {
18
- if (dep !== prevDeps.current[i]) {
19
- return i;
20
- }
21
- return null;
22
- })
23
- .filter((dep) => dep !== null);
24
- if (changedDeps.length > 0) {
25
- console.log("Changed dependencies:", changedDeps);
26
- }
27
- prevDeps.current = dependencies;
28
- }, dependencies);
29
- };
30
- exports.useDebugDependencies = useDebugDependencies;
@@ -1,49 +0,0 @@
1
- import { FC, PropsWithChildren } from "react";
2
- /**
3
- * FC With Children
4
- * */
5
- export type FCWithChildren = FC<PropsWithChildren>;
6
- /**
7
- * Component Map
8
- * */
9
- export type ComponentMap = Record<string, FCWithChildren>;
10
- /**
11
- * Layout Components
12
- * */
13
- export type LayoutComponents = {
14
- layout: FCWithChildren;
15
- areas: ComponentMap;
16
- };
17
- /**
18
- * Quickly express advanced, extensible grid layouts with styled-components.
19
- *
20
- * @example
21
- * ```tsx
22
- * const {
23
- * layout: Container,
24
- * areas: {
25
- * Header,
26
- * Side,
27
- * Main,
28
- * Footer,
29
- * },
30
- * } = getEasyLayout(styled.div)`
31
- * header header header, 1fr
32
- * side main main, 5fr
33
- * footer footer footer, 1fr
34
- * \\ 1fr 1fr 1fr
35
- * `;
36
- *
37
- * const App = () => {
38
- * return (
39
- * <Container>
40
- * <Header>Header Content</Header>
41
- * <Side>Side Content</Side>
42
- * <Main>Main Content</Main>
43
- * <Footer>Footer Content</Footer>
44
- * </Container>
45
- * );
46
- * };
47
- * ```
48
- * */
49
- export declare const getEasyLayout: (extendFrom?: FCWithChildren, areasExtendFrom?: FCWithChildren) => ((layoutTemplate: TemplateStringsArray, ...expressions: any[]) => LayoutComponents);