@openstax/ts-utils 1.33.1 → 1.34.0

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 (504) hide show
  1. package/.cfnlintrc +2 -0
  2. package/.github/CODEOWNERS +1 -0
  3. package/.github/workflows/ci.yml +36 -0
  4. package/.github/workflows/lint.yml +55 -0
  5. package/.nvmrc +1 -0
  6. package/.syncignore +4 -0
  7. package/.syncpackrc +18 -0
  8. package/CONTRIBUTING.md +96 -0
  9. package/LICENSE +661 -0
  10. package/Procfile +1 -0
  11. package/README.md +62 -90
  12. package/app.json +23 -0
  13. package/cspell.json +32 -0
  14. package/deploy/constants.env +21 -0
  15. package/deploy/deploy.bash +157 -0
  16. package/deploy/deployment-alt-region.cfn.yml +70 -0
  17. package/deploy/deployment.cfn.yml +650 -0
  18. package/deploy/destroy-deployment.bash +23 -0
  19. package/deploy/shared.cfn.yml +94 -0
  20. package/docs/lambda-build.md +35 -0
  21. package/package.json +12 -228
  22. package/packages/frontend/README.md +46 -0
  23. package/packages/frontend/package.json +101 -0
  24. package/packages/frontend/public/favicon.ico +0 -0
  25. package/packages/frontend/public/index.html +107 -0
  26. package/packages/frontend/public/maintenance.html +59 -0
  27. package/packages/frontend/public/manifest.json +15 -0
  28. package/packages/frontend/public/robots.txt +3 -0
  29. package/packages/frontend/script/make-certificate.bash +49 -0
  30. package/packages/frontend/script/server/cli.js +11 -0
  31. package/packages/frontend/script/server/index.js +47 -0
  32. package/packages/frontend/script/start.bash +22 -0
  33. package/packages/frontend/script/trust-localhost.bash +7 -0
  34. package/packages/frontend/src/auth/authProvider.ts +10 -0
  35. package/packages/frontend/src/auth/useAuth.ts +33 -0
  36. package/packages/frontend/src/components/Pagination.tsx +26 -0
  37. package/packages/frontend/src/configProvider/index.ts +53 -0
  38. package/packages/frontend/src/configProvider/use.ts +41 -0
  39. package/packages/frontend/src/core/context/services.spec.tsx +39 -0
  40. package/packages/frontend/src/core/context/services.tsx +16 -0
  41. package/packages/frontend/src/core/index.spec.ts +7 -0
  42. package/packages/frontend/src/core/index.ts +20 -0
  43. package/packages/frontend/src/core/services.tsx +14 -0
  44. package/packages/frontend/src/core/types.ts +3 -0
  45. package/packages/frontend/src/example/api.ts +28 -0
  46. package/packages/frontend/src/example/components/Layout.tsx +23 -0
  47. package/packages/frontend/src/example/screens/Home.spec.tsx +68 -0
  48. package/packages/frontend/src/example/screens/Home.tsx +78 -0
  49. package/packages/frontend/src/example/screens/ThingList.spec.tsx +60 -0
  50. package/packages/frontend/src/example/screens/ThingList.tsx +75 -0
  51. package/packages/frontend/src/example/screens/ThingView.spec.tsx +71 -0
  52. package/packages/frontend/src/example/screens/ThingView.tsx +47 -0
  53. package/packages/frontend/src/example/screens/index.ts +9 -0
  54. package/packages/frontend/src/index.css +159 -0
  55. package/packages/frontend/src/index.tsx +67 -0
  56. package/packages/frontend/src/react-app-env.d.ts +1 -0
  57. package/packages/frontend/src/routing/components/RouteLink.spec.tsx +55 -0
  58. package/packages/frontend/src/routing/components/RouteLink.tsx +35 -0
  59. package/packages/frontend/src/routing/middleware.ts +6 -0
  60. package/packages/frontend/src/routing/useQuery.ts +14 -0
  61. package/packages/frontend/src/setupProxy.js +19 -0
  62. package/packages/frontend/src/setupTests.ts +9 -0
  63. package/packages/frontend/src/tests/testServices.tsx +23 -0
  64. package/packages/frontend/tsconfig.json +27 -0
  65. package/packages/lambda/.eslintrc.js +64 -0
  66. package/packages/lambda/jest-global-setup.js +3 -0
  67. package/packages/lambda/jest-setup-after-env.js +1 -0
  68. package/packages/lambda/jest.config.js +31 -0
  69. package/packages/lambda/jest.resolver.js +17 -0
  70. package/packages/lambda/package.json +68 -0
  71. package/packages/lambda/script/build.bash +19 -0
  72. package/packages/lambda/script/bundle-functions.bash +10 -0
  73. package/packages/lambda/script/lambdaLocalProxy.js +16 -0
  74. package/packages/lambda/script/lambdaLocalProxy.spec.ts +147 -0
  75. package/packages/lambda/script/utils/getRouteData.ts +7 -0
  76. package/packages/lambda/script/utils/routeDataLoader.js +8 -0
  77. package/packages/lambda/script/utils/routeDataLoader.spec.ts +8 -0
  78. package/packages/lambda/src/functions/serviceApi/core/index.ts +7 -0
  79. package/packages/lambda/src/functions/serviceApi/core/request.spec.ts +38 -0
  80. package/packages/lambda/src/functions/serviceApi/core/request.ts +42 -0
  81. package/packages/lambda/src/functions/serviceApi/core/routes.spec.ts +7 -0
  82. package/packages/lambda/src/functions/serviceApi/core/routes.ts +10 -0
  83. package/packages/lambda/src/functions/serviceApi/core/services.ts +9 -0
  84. package/packages/lambda/src/functions/serviceApi/core/types.ts +13 -0
  85. package/packages/lambda/src/functions/serviceApi/entry/lambda/https-xray.ts +4 -0
  86. package/packages/lambda/src/functions/serviceApi/entry/lambda/index.spec.ts +48 -0
  87. package/packages/lambda/src/functions/serviceApi/entry/lambda/index.ts +58 -0
  88. package/packages/lambda/src/functions/serviceApi/entry/lambda/services.ts +36 -0
  89. package/packages/lambda/src/functions/serviceApi/entry/local.ts +71 -0
  90. package/packages/lambda/src/functions/serviceApi/versions/v0/example/documentSearchMiddleware.spec.ts +16 -0
  91. package/packages/lambda/src/functions/serviceApi/versions/v0/example/documentSearchMiddleware.ts +41 -0
  92. package/packages/lambda/src/functions/serviceApi/versions/v0/example/documentStoreMiddleware.spec.ts +78 -0
  93. package/packages/lambda/src/functions/serviceApi/versions/v0/example/documentStoreMiddleware.ts +70 -0
  94. package/packages/lambda/src/functions/serviceApi/versions/v0/example/routes.spec.ts +306 -0
  95. package/packages/lambda/src/functions/serviceApi/versions/v0/example/routes.ts +176 -0
  96. package/packages/lambda/src/functions/serviceApi/versions/v0/index.spec.ts +263 -0
  97. package/packages/lambda/src/functions/serviceApi/versions/v0/index.ts +134 -0
  98. package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/authMiddleware.spec.ts +23 -0
  99. package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/authMiddleware.ts +32 -0
  100. package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/configMiddleware.spec.ts +10 -0
  101. package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/configMiddleware.ts +7 -0
  102. package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/frontendFileServerMiddleware.spec.ts +13 -0
  103. package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/frontendFileServerMiddleware.ts +23 -0
  104. package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/paginationMiddleware.spec.ts +9 -0
  105. package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/paginationMiddleware.ts +9 -0
  106. package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/searchMiddleware.spec.ts +12 -0
  107. package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/searchMiddleware.ts +21 -0
  108. package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/userRoleValidatorMiddleware.spec.ts +21 -0
  109. package/packages/lambda/src/functions/serviceApi/versions/v0/middleware/userRoleValidatorMiddleware.ts +18 -0
  110. package/packages/lambda/tsconfig.json +30 -0
  111. package/packages/lambda/webpack.config.js +97 -0
  112. package/packages/utils/.eslintrc.js +64 -0
  113. package/packages/utils/README.md +118 -0
  114. package/packages/utils/jest-global-setup.js +3 -0
  115. package/packages/utils/jest.config.js +25 -0
  116. package/packages/utils/jest.resolver.js +17 -0
  117. package/packages/utils/package.json +238 -0
  118. package/packages/utils/src/assertions/index.spec.ts +126 -0
  119. package/{dist/esm/assertions/index.js → packages/utils/src/assertions/index.ts} +64 -49
  120. package/packages/utils/src/aws/ssmService.ts +7 -0
  121. package/packages/utils/src/config/awsParameterConfig.ts +24 -0
  122. package/packages/utils/src/config/envConfig.ts +58 -0
  123. package/packages/utils/src/config/index.spec.ts +165 -0
  124. package/{dist/esm/config/index.d.ts → packages/utils/src/config/index.ts} +29 -13
  125. package/packages/utils/src/config/lambdaParameterConfig.ts +49 -0
  126. package/{dist/esm/config/replaceConfig.js → packages/utils/src/config/replaceConfig.ts} +16 -6
  127. package/packages/utils/src/config/resolveConfigValue.ts +10 -0
  128. package/packages/utils/src/errors/index.spec.ts +35 -0
  129. package/{dist/esm/errors/index.js → packages/utils/src/errors/index.ts} +57 -41
  130. package/packages/utils/src/fetch/fetchStatusRetry.spec.ts +197 -0
  131. package/packages/utils/src/fetch/fetchStatusRetry.ts +33 -0
  132. package/packages/utils/src/fetch/index.spec.ts +34 -0
  133. package/packages/utils/src/fetch/index.ts +87 -0
  134. package/packages/utils/src/guards/index.spec.ts +58 -0
  135. package/{dist/esm/guards/index.d.ts → packages/utils/src/guards/index.ts} +10 -7
  136. package/packages/utils/src/index.spec.ts +471 -0
  137. package/packages/utils/src/middleware/apiErrorHandler.spec.ts +65 -0
  138. package/packages/utils/src/middleware/apiErrorHandler.ts +67 -0
  139. package/packages/utils/src/middleware/apiSlowResponseMiddleware.spec.ts +184 -0
  140. package/packages/utils/src/middleware/apiSlowResponseMiddleware.ts +71 -0
  141. package/packages/utils/src/middleware/index.spec.ts +99 -0
  142. package/{dist/cjs/middleware/index.d.ts → packages/utils/src/middleware/index.ts} +53 -5
  143. package/packages/utils/src/middleware/lambdaCorsResponseMiddleware.spec.ts +103 -0
  144. package/packages/utils/src/middleware/lambdaCorsResponseMiddleware.ts +52 -0
  145. package/packages/utils/src/middleware/throwNotFoundMiddleware.spec.ts +20 -0
  146. package/packages/utils/src/middleware/throwNotFoundMiddleware.ts +11 -0
  147. package/packages/utils/src/misc/hashValue.ts +18 -0
  148. package/packages/utils/src/misc/helpers.ts +259 -0
  149. package/packages/utils/src/misc/merge.ts +48 -0
  150. package/{dist/esm/misc/partitionSequence.js → packages/utils/src/misc/partitionSequence.ts} +23 -15
  151. package/packages/utils/src/pagination/index.spec.ts +150 -0
  152. package/packages/utils/src/pagination/index.ts +117 -0
  153. package/{dist/esm/routing/helpers.js → packages/utils/src/routing/helpers.ts} +42 -30
  154. package/packages/utils/src/routing/index.spec.ts +553 -0
  155. package/packages/utils/src/routing/index.ts +424 -0
  156. package/packages/utils/src/routing/validators/zod.spec.ts +16 -0
  157. package/packages/utils/src/routing/validators/zod.ts +14 -0
  158. package/packages/utils/src/services/accountsGateway/README.md +3 -0
  159. package/packages/utils/src/services/accountsGateway/index.spec.ts +518 -0
  160. package/packages/utils/src/services/accountsGateway/index.ts +251 -0
  161. package/packages/utils/src/services/apiGateway/README.md +93 -0
  162. package/packages/utils/src/services/apiGateway/index.spec.ts +254 -0
  163. package/packages/utils/src/services/apiGateway/index.ts +189 -0
  164. package/packages/utils/src/services/authProvider/README.md +21 -0
  165. package/packages/utils/src/services/authProvider/browser.spec.ts +391 -0
  166. package/packages/utils/src/services/authProvider/browser.ts +209 -0
  167. package/packages/utils/src/services/authProvider/decryption.spec.ts +337 -0
  168. package/packages/utils/src/services/authProvider/decryption.ts +98 -0
  169. package/packages/utils/src/services/authProvider/index.ts +93 -0
  170. package/packages/utils/src/services/authProvider/stub.spec.ts +29 -0
  171. package/packages/utils/src/services/authProvider/subrequest.spec.ts +105 -0
  172. package/packages/utils/src/services/authProvider/subrequest.ts +68 -0
  173. package/packages/utils/src/services/authProvider/utils/decryptAndVerify.spec.ts +128 -0
  174. package/packages/utils/src/services/authProvider/utils/decryptAndVerify.ts +106 -0
  175. package/packages/utils/src/services/authProvider/utils/embeddedAuthProvider.spec.ts +26 -0
  176. package/packages/utils/src/services/authProvider/utils/embeddedAuthProvider.ts +57 -0
  177. package/packages/utils/src/services/authProvider/utils/userRoleValidator.spec.ts +135 -0
  178. package/packages/utils/src/services/authProvider/utils/userRoleValidator.ts +49 -0
  179. package/packages/utils/src/services/authProvider/utils/userSubrequest.spec.ts +26 -0
  180. package/packages/utils/src/services/authProvider/utils/userSubrequest.ts +10 -0
  181. package/packages/utils/src/services/documentStore/dynamoEncoding.ts +57 -0
  182. package/packages/utils/src/services/documentStore/fileSystemAssert.spec.ts +43 -0
  183. package/packages/utils/src/services/documentStore/fileSystemAssert.ts +10 -0
  184. package/{dist/cjs/services/documentStore/index.d.ts → packages/utils/src/services/documentStore/index.ts} +8 -8
  185. package/packages/utils/src/services/documentStore/unversioned/README.md +13 -0
  186. package/packages/utils/src/services/documentStore/unversioned/dynamodb.spec.ts +859 -0
  187. package/packages/utils/src/services/documentStore/unversioned/dynamodb.ts +243 -0
  188. package/packages/utils/src/services/documentStore/unversioned/file-system.spec.ts +629 -0
  189. package/packages/utils/src/services/documentStore/unversioned/file-system.ts +194 -0
  190. package/{dist/cjs/services/documentStore/unversioned/index.d.ts → packages/utils/src/services/documentStore/unversioned/index.ts} +2 -0
  191. package/packages/utils/src/services/documentStore/versioned/README.md +13 -0
  192. package/packages/utils/src/services/documentStore/versioned/dynamodb.spec.ts +376 -0
  193. package/packages/utils/src/services/documentStore/versioned/dynamodb.ts +167 -0
  194. package/packages/utils/src/services/documentStore/versioned/file-system.spec.ts +262 -0
  195. package/packages/utils/src/services/documentStore/versioned/file-system.ts +90 -0
  196. package/packages/utils/src/services/documentStore/versioned/index.ts +25 -0
  197. package/packages/utils/src/services/exercisesGateway/README.md +5 -0
  198. package/packages/utils/src/services/exercisesGateway/index.spec.ts +326 -0
  199. package/packages/utils/src/services/exercisesGateway/index.ts +163 -0
  200. package/packages/utils/src/services/fileServer/index.spec.ts +88 -0
  201. package/packages/utils/src/services/fileServer/index.ts +43 -0
  202. package/packages/utils/src/services/fileServer/localFileServer.spec.ts +182 -0
  203. package/packages/utils/src/services/fileServer/localFileServer.ts +159 -0
  204. package/packages/utils/src/services/fileServer/s3FileServer.spec.ts +266 -0
  205. package/packages/utils/src/services/fileServer/s3FileServer.ts +155 -0
  206. package/packages/utils/src/services/launchParams/index.spec.ts +366 -0
  207. package/packages/utils/src/services/launchParams/signer.ts +73 -0
  208. package/packages/utils/src/services/launchParams/verifier.ts +120 -0
  209. package/packages/utils/src/services/logger/console.spec.ts +29 -0
  210. package/{dist/esm/services/logger/console.js → packages/utils/src/services/logger/console.ts} +5 -2
  211. package/packages/utils/src/services/logger/index.spec.ts +65 -0
  212. package/{dist/esm/services/logger/index.d.ts → packages/utils/src/services/logger/index.ts} +23 -9
  213. package/packages/utils/src/services/lrsGateway/README.md +5 -0
  214. package/packages/utils/src/services/lrsGateway/addStatementDefaultFields.ts +22 -0
  215. package/packages/utils/src/services/lrsGateway/attempt-utils.spec.ts +847 -0
  216. package/packages/utils/src/services/lrsGateway/attempt-utils.ts +358 -0
  217. package/packages/utils/src/services/lrsGateway/file-system.spec.ts +363 -0
  218. package/packages/utils/src/services/lrsGateway/file-system.ts +165 -0
  219. package/packages/utils/src/services/lrsGateway/index.spec.ts +194 -0
  220. package/packages/utils/src/services/lrsGateway/index.ts +257 -0
  221. package/packages/utils/src/services/lrsGateway/xapiUtils.spec.ts +887 -0
  222. package/packages/utils/src/services/lrsGateway/xapiUtils.ts +262 -0
  223. package/packages/utils/src/services/postgresConnection/index.spec.ts +170 -0
  224. package/packages/utils/src/services/postgresConnection/index.ts +84 -0
  225. package/packages/utils/src/services/searchProvider/README.md +3 -0
  226. package/packages/utils/src/services/searchProvider/index.ts +59 -0
  227. package/packages/utils/src/services/searchProvider/memorySearchTheBadWay.spec.ts +526 -0
  228. package/packages/utils/src/services/searchProvider/memorySearchTheBadWay.ts +223 -0
  229. package/packages/utils/src/services/searchProvider/openSearch.spec.ts +926 -0
  230. package/packages/utils/src/services/searchProvider/openSearch.ts +195 -0
  231. package/{dist/esm/types.d.ts → packages/utils/src/types.ts} +34 -6
  232. package/packages/utils/tsconfig.json +31 -0
  233. package/packages/utils/tsconfig.without-specs.cjs.json +7 -0
  234. package/packages/utils/tsconfig.without-specs.esm.json +7 -0
  235. package/packages/utils/tsconfig.without-specs.json +6 -0
  236. package/scripts/build.bash +24 -0
  237. package/scripts/ci.bash +10 -0
  238. package/scripts/start.bash +29 -0
  239. package/dist/cjs/assertions/index.d.ts +0 -89
  240. package/dist/cjs/assertions/index.js +0 -157
  241. package/dist/cjs/aws/ssmService.d.ts +0 -5
  242. package/dist/cjs/aws/ssmService.js +0 -9
  243. package/dist/cjs/config/awsParameterConfig.d.ts +0 -10
  244. package/dist/cjs/config/awsParameterConfig.js +0 -26
  245. package/dist/cjs/config/envConfig.d.ts +0 -24
  246. package/dist/cjs/config/envConfig.js +0 -57
  247. package/dist/cjs/config/index.d.ts +0 -48
  248. package/dist/cjs/config/index.js +0 -35
  249. package/dist/cjs/config/lambdaParameterConfig.d.ts +0 -12
  250. package/dist/cjs/config/lambdaParameterConfig.js +0 -45
  251. package/dist/cjs/config/replaceConfig.d.ts +0 -14
  252. package/dist/cjs/config/replaceConfig.js +0 -22
  253. package/dist/cjs/config/resolveConfigValue.d.ts +0 -5
  254. package/dist/cjs/config/resolveConfigValue.js +0 -12
  255. package/dist/cjs/errors/index.d.ts +0 -88
  256. package/dist/cjs/errors/index.js +0 -123
  257. package/dist/cjs/fetch/fetchStatusRetry.d.ts +0 -8
  258. package/dist/cjs/fetch/fetchStatusRetry.js +0 -27
  259. package/dist/cjs/fetch/index.d.ts +0 -64
  260. package/dist/cjs/fetch/index.js +0 -55
  261. package/dist/cjs/guards/index.d.ts +0 -38
  262. package/dist/cjs/guards/index.js +0 -44
  263. package/dist/cjs/index.js +0 -20
  264. package/dist/cjs/middleware/apiErrorHandler.d.ts +0 -24
  265. package/dist/cjs/middleware/apiErrorHandler.js +0 -42
  266. package/dist/cjs/middleware/apiSlowResponseMiddleware.d.ts +0 -23
  267. package/dist/cjs/middleware/apiSlowResponseMiddleware.js +0 -54
  268. package/dist/cjs/middleware/index.js +0 -48
  269. package/dist/cjs/middleware/lambdaCorsResponseMiddleware.d.ts +0 -20
  270. package/dist/cjs/middleware/lambdaCorsResponseMiddleware.js +0 -44
  271. package/dist/cjs/middleware/throwNotFoundMiddleware.d.ts +0 -4
  272. package/dist/cjs/middleware/throwNotFoundMiddleware.js +0 -14
  273. package/dist/cjs/misc/hashValue.d.ts +0 -10
  274. package/dist/cjs/misc/hashValue.js +0 -17
  275. package/dist/cjs/misc/helpers.d.ts +0 -124
  276. package/dist/cjs/misc/helpers.js +0 -214
  277. package/dist/cjs/misc/merge.d.ts +0 -21
  278. package/dist/cjs/misc/merge.js +0 -45
  279. package/dist/cjs/misc/partitionSequence.d.ts +0 -35
  280. package/dist/cjs/misc/partitionSequence.js +0 -55
  281. package/dist/cjs/pagination/index.d.ts +0 -91
  282. package/dist/cjs/pagination/index.js +0 -83
  283. package/dist/cjs/routing/helpers.d.ts +0 -57
  284. package/dist/cjs/routing/helpers.js +0 -90
  285. package/dist/cjs/routing/index.d.ts +0 -290
  286. package/dist/cjs/routing/index.js +0 -295
  287. package/dist/cjs/routing/validators/zod.d.ts +0 -4
  288. package/dist/cjs/routing/validators/zod.js +0 -14
  289. package/dist/cjs/services/accountsGateway/index.d.ts +0 -92
  290. package/dist/cjs/services/accountsGateway/index.js +0 -138
  291. package/dist/cjs/services/apiGateway/index.d.ts +0 -68
  292. package/dist/cjs/services/apiGateway/index.js +0 -118
  293. package/dist/cjs/services/authProvider/browser.d.ts +0 -40
  294. package/dist/cjs/services/authProvider/browser.js +0 -155
  295. package/dist/cjs/services/authProvider/decryption.d.ts +0 -19
  296. package/dist/cjs/services/authProvider/decryption.js +0 -73
  297. package/dist/cjs/services/authProvider/index.d.ts +0 -63
  298. package/dist/cjs/services/authProvider/index.js +0 -34
  299. package/dist/cjs/services/authProvider/subrequest.d.ts +0 -13
  300. package/dist/cjs/services/authProvider/subrequest.js +0 -49
  301. package/dist/cjs/services/authProvider/utils/decryptAndVerify.d.ts +0 -28
  302. package/dist/cjs/services/authProvider/utils/decryptAndVerify.js +0 -91
  303. package/dist/cjs/services/authProvider/utils/embeddedAuthProvider.d.ts +0 -26
  304. package/dist/cjs/services/authProvider/utils/embeddedAuthProvider.js +0 -47
  305. package/dist/cjs/services/authProvider/utils/userRoleValidator.d.ts +0 -13
  306. package/dist/cjs/services/authProvider/utils/userRoleValidator.js +0 -37
  307. package/dist/cjs/services/authProvider/utils/userSubrequest.d.ts +0 -3
  308. package/dist/cjs/services/authProvider/utils/userSubrequest.js +0 -13
  309. package/dist/cjs/services/documentStore/dynamoEncoding.d.ts +0 -10
  310. package/dist/cjs/services/documentStore/dynamoEncoding.js +0 -52
  311. package/dist/cjs/services/documentStore/fileSystemAssert.d.ts +0 -1
  312. package/dist/cjs/services/documentStore/fileSystemAssert.js +0 -14
  313. package/dist/cjs/services/documentStore/index.js +0 -2
  314. package/dist/cjs/services/documentStore/unversioned/dynamodb.d.ts +0 -31
  315. package/dist/cjs/services/documentStore/unversioned/dynamodb.js +0 -233
  316. package/dist/cjs/services/documentStore/unversioned/file-system.d.ts +0 -32
  317. package/dist/cjs/services/documentStore/unversioned/file-system.js +0 -214
  318. package/dist/cjs/services/documentStore/unversioned/index.js +0 -2
  319. package/dist/cjs/services/documentStore/versioned/dynamodb.d.ts +0 -25
  320. package/dist/cjs/services/documentStore/versioned/dynamodb.js +0 -143
  321. package/dist/cjs/services/documentStore/versioned/file-system.d.ts +0 -25
  322. package/dist/cjs/services/documentStore/versioned/file-system.js +0 -73
  323. package/dist/cjs/services/documentStore/versioned/index.d.ts +0 -17
  324. package/dist/cjs/services/documentStore/versioned/index.js +0 -2
  325. package/dist/cjs/services/exercisesGateway/index.d.ts +0 -67
  326. package/dist/cjs/services/exercisesGateway/index.js +0 -107
  327. package/dist/cjs/services/fileServer/index.d.ts +0 -30
  328. package/dist/cjs/services/fileServer/index.js +0 -19
  329. package/dist/cjs/services/fileServer/localFileServer.d.ts +0 -13
  330. package/dist/cjs/services/fileServer/localFileServer.js +0 -132
  331. package/dist/cjs/services/fileServer/s3FileServer.d.ts +0 -14
  332. package/dist/cjs/services/fileServer/s3FileServer.js +0 -132
  333. package/dist/cjs/services/launchParams/index.js +0 -7
  334. package/dist/cjs/services/launchParams/signer.d.ts +0 -23
  335. package/dist/cjs/services/launchParams/signer.js +0 -58
  336. package/dist/cjs/services/launchParams/verifier.d.ts +0 -21
  337. package/dist/cjs/services/launchParams/verifier.js +0 -129
  338. package/dist/cjs/services/logger/console.d.ts +0 -4
  339. package/dist/cjs/services/logger/console.js +0 -12
  340. package/dist/cjs/services/logger/index.d.ts +0 -39
  341. package/dist/cjs/services/logger/index.js +0 -31
  342. package/dist/cjs/services/lrsGateway/addStatementDefaultFields.d.ts +0 -5
  343. package/dist/cjs/services/lrsGateway/addStatementDefaultFields.js +0 -21
  344. package/dist/cjs/services/lrsGateway/attempt-utils.d.ts +0 -70
  345. package/dist/cjs/services/lrsGateway/attempt-utils.js +0 -258
  346. package/dist/cjs/services/lrsGateway/file-system.d.ts +0 -15
  347. package/dist/cjs/services/lrsGateway/file-system.js +0 -150
  348. package/dist/cjs/services/lrsGateway/index.d.ts +0 -122
  349. package/dist/cjs/services/lrsGateway/index.js +0 -148
  350. package/dist/cjs/services/lrsGateway/xapiUtils.d.ts +0 -68
  351. package/dist/cjs/services/lrsGateway/xapiUtils.js +0 -109
  352. package/dist/cjs/services/postgresConnection/index.d.ts +0 -28
  353. package/dist/cjs/services/postgresConnection/index.js +0 -65
  354. package/dist/cjs/services/searchProvider/index.d.ts +0 -67
  355. package/dist/cjs/services/searchProvider/index.js +0 -2
  356. package/dist/cjs/services/searchProvider/memorySearchTheBadWay.d.ts +0 -20
  357. package/dist/cjs/services/searchProvider/memorySearchTheBadWay.js +0 -191
  358. package/dist/cjs/services/searchProvider/openSearch.d.ts +0 -28
  359. package/dist/cjs/services/searchProvider/openSearch.js +0 -154
  360. package/dist/cjs/tsconfig.without-specs.cjs.tsbuildinfo +0 -1
  361. package/dist/cjs/types.d.ts +0 -31
  362. package/dist/cjs/types.js +0 -2
  363. package/dist/esm/assertions/index.d.ts +0 -89
  364. package/dist/esm/aws/ssmService.d.ts +0 -5
  365. package/dist/esm/aws/ssmService.js +0 -6
  366. package/dist/esm/config/awsParameterConfig.d.ts +0 -10
  367. package/dist/esm/config/awsParameterConfig.js +0 -22
  368. package/dist/esm/config/envConfig.d.ts +0 -24
  369. package/dist/esm/config/envConfig.js +0 -53
  370. package/dist/esm/config/index.js +0 -17
  371. package/dist/esm/config/lambdaParameterConfig.d.ts +0 -12
  372. package/dist/esm/config/lambdaParameterConfig.js +0 -38
  373. package/dist/esm/config/replaceConfig.d.ts +0 -14
  374. package/dist/esm/config/resolveConfigValue.d.ts +0 -5
  375. package/dist/esm/config/resolveConfigValue.js +0 -8
  376. package/dist/esm/errors/index.d.ts +0 -88
  377. package/dist/esm/fetch/fetchStatusRetry.d.ts +0 -8
  378. package/dist/esm/fetch/fetchStatusRetry.js +0 -23
  379. package/dist/esm/fetch/index.d.ts +0 -64
  380. package/dist/esm/fetch/index.js +0 -46
  381. package/dist/esm/guards/index.js +0 -36
  382. package/dist/esm/index.d.ts +0 -4
  383. package/dist/esm/index.js +0 -4
  384. package/dist/esm/middleware/apiErrorHandler.d.ts +0 -24
  385. package/dist/esm/middleware/apiErrorHandler.js +0 -38
  386. package/dist/esm/middleware/apiSlowResponseMiddleware.d.ts +0 -23
  387. package/dist/esm/middleware/apiSlowResponseMiddleware.js +0 -50
  388. package/dist/esm/middleware/index.d.ts +0 -47
  389. package/dist/esm/middleware/index.js +0 -44
  390. package/dist/esm/middleware/lambdaCorsResponseMiddleware.d.ts +0 -20
  391. package/dist/esm/middleware/lambdaCorsResponseMiddleware.js +0 -40
  392. package/dist/esm/middleware/throwNotFoundMiddleware.d.ts +0 -4
  393. package/dist/esm/middleware/throwNotFoundMiddleware.js +0 -10
  394. package/dist/esm/misc/hashValue.d.ts +0 -10
  395. package/dist/esm/misc/hashValue.js +0 -13
  396. package/dist/esm/misc/helpers.d.ts +0 -124
  397. package/dist/esm/misc/helpers.js +0 -199
  398. package/dist/esm/misc/merge.d.ts +0 -21
  399. package/dist/esm/misc/merge.js +0 -40
  400. package/dist/esm/misc/partitionSequence.d.ts +0 -35
  401. package/dist/esm/pagination/index.d.ts +0 -91
  402. package/dist/esm/pagination/index.js +0 -77
  403. package/dist/esm/routing/helpers.d.ts +0 -57
  404. package/dist/esm/routing/index.d.ts +0 -290
  405. package/dist/esm/routing/index.js +0 -246
  406. package/dist/esm/routing/validators/zod.d.ts +0 -4
  407. package/dist/esm/routing/validators/zod.js +0 -10
  408. package/dist/esm/services/accountsGateway/index.d.ts +0 -92
  409. package/dist/esm/services/accountsGateway/index.js +0 -131
  410. package/dist/esm/services/apiGateway/index.d.ts +0 -68
  411. package/dist/esm/services/apiGateway/index.js +0 -77
  412. package/dist/esm/services/authProvider/browser.d.ts +0 -40
  413. package/dist/esm/services/authProvider/browser.js +0 -151
  414. package/dist/esm/services/authProvider/decryption.d.ts +0 -19
  415. package/dist/esm/services/authProvider/decryption.js +0 -69
  416. package/dist/esm/services/authProvider/index.d.ts +0 -63
  417. package/dist/esm/services/authProvider/index.js +0 -26
  418. package/dist/esm/services/authProvider/subrequest.d.ts +0 -13
  419. package/dist/esm/services/authProvider/subrequest.js +0 -45
  420. package/dist/esm/services/authProvider/utils/decryptAndVerify.d.ts +0 -28
  421. package/dist/esm/services/authProvider/utils/decryptAndVerify.js +0 -85
  422. package/dist/esm/services/authProvider/utils/embeddedAuthProvider.d.ts +0 -26
  423. package/dist/esm/services/authProvider/utils/embeddedAuthProvider.js +0 -40
  424. package/dist/esm/services/authProvider/utils/userRoleValidator.d.ts +0 -13
  425. package/dist/esm/services/authProvider/utils/userRoleValidator.js +0 -33
  426. package/dist/esm/services/authProvider/utils/userSubrequest.d.ts +0 -3
  427. package/dist/esm/services/authProvider/utils/userSubrequest.js +0 -6
  428. package/dist/esm/services/documentStore/dynamoEncoding.d.ts +0 -10
  429. package/dist/esm/services/documentStore/dynamoEncoding.js +0 -45
  430. package/dist/esm/services/documentStore/fileSystemAssert.d.ts +0 -1
  431. package/dist/esm/services/documentStore/fileSystemAssert.js +0 -10
  432. package/dist/esm/services/documentStore/index.d.ts +0 -14
  433. package/dist/esm/services/documentStore/index.js +0 -1
  434. package/dist/esm/services/documentStore/unversioned/dynamodb.d.ts +0 -31
  435. package/dist/esm/services/documentStore/unversioned/dynamodb.js +0 -226
  436. package/dist/esm/services/documentStore/unversioned/file-system.d.ts +0 -32
  437. package/dist/esm/services/documentStore/unversioned/file-system.js +0 -174
  438. package/dist/esm/services/documentStore/unversioned/index.d.ts +0 -2
  439. package/dist/esm/services/documentStore/unversioned/index.js +0 -1
  440. package/dist/esm/services/documentStore/versioned/dynamodb.d.ts +0 -25
  441. package/dist/esm/services/documentStore/versioned/dynamodb.js +0 -139
  442. package/dist/esm/services/documentStore/versioned/file-system.d.ts +0 -25
  443. package/dist/esm/services/documentStore/versioned/file-system.js +0 -69
  444. package/dist/esm/services/documentStore/versioned/index.d.ts +0 -17
  445. package/dist/esm/services/documentStore/versioned/index.js +0 -1
  446. package/dist/esm/services/exercisesGateway/index.d.ts +0 -67
  447. package/dist/esm/services/exercisesGateway/index.js +0 -70
  448. package/dist/esm/services/fileServer/index.d.ts +0 -30
  449. package/dist/esm/services/fileServer/index.js +0 -13
  450. package/dist/esm/services/fileServer/localFileServer.d.ts +0 -13
  451. package/dist/esm/services/fileServer/localFileServer.js +0 -125
  452. package/dist/esm/services/fileServer/s3FileServer.d.ts +0 -14
  453. package/dist/esm/services/fileServer/s3FileServer.js +0 -125
  454. package/dist/esm/services/launchParams/index.d.ts +0 -2
  455. package/dist/esm/services/launchParams/index.js +0 -2
  456. package/dist/esm/services/launchParams/signer.d.ts +0 -23
  457. package/dist/esm/services/launchParams/signer.js +0 -51
  458. package/dist/esm/services/launchParams/verifier.d.ts +0 -21
  459. package/dist/esm/services/launchParams/verifier.js +0 -92
  460. package/dist/esm/services/logger/console.d.ts +0 -4
  461. package/dist/esm/services/logger/index.js +0 -27
  462. package/dist/esm/services/lrsGateway/addStatementDefaultFields.d.ts +0 -5
  463. package/dist/esm/services/lrsGateway/addStatementDefaultFields.js +0 -14
  464. package/dist/esm/services/lrsGateway/attempt-utils.d.ts +0 -70
  465. package/dist/esm/services/lrsGateway/attempt-utils.js +0 -236
  466. package/dist/esm/services/lrsGateway/file-system.d.ts +0 -15
  467. package/dist/esm/services/lrsGateway/file-system.js +0 -110
  468. package/dist/esm/services/lrsGateway/index.d.ts +0 -122
  469. package/dist/esm/services/lrsGateway/index.js +0 -111
  470. package/dist/esm/services/lrsGateway/xapiUtils.d.ts +0 -68
  471. package/dist/esm/services/lrsGateway/xapiUtils.js +0 -99
  472. package/dist/esm/services/postgresConnection/index.d.ts +0 -28
  473. package/dist/esm/services/postgresConnection/index.js +0 -58
  474. package/dist/esm/services/searchProvider/index.d.ts +0 -67
  475. package/dist/esm/services/searchProvider/index.js +0 -1
  476. package/dist/esm/services/searchProvider/memorySearchTheBadWay.d.ts +0 -20
  477. package/dist/esm/services/searchProvider/memorySearchTheBadWay.js +0 -187
  478. package/dist/esm/services/searchProvider/openSearch.d.ts +0 -28
  479. package/dist/esm/services/searchProvider/openSearch.js +0 -150
  480. package/dist/esm/tsconfig.without-specs.esm.tsbuildinfo +0 -1
  481. package/dist/esm/types.js +0 -1
  482. package/script/bin/.init-params-script.bash.swp +0 -0
  483. /package/{script → packages/utils/script}/bin/copy-from-template.bash +0 -0
  484. /package/{script → packages/utils/script}/bin/delete-stack.bash +0 -0
  485. /package/{script → packages/utils/script}/bin/deploy.bash +0 -0
  486. /package/{script → packages/utils/script}/bin/destroy-deployment.bash +0 -0
  487. /package/{script → packages/utils/script}/bin/empty-bucket.bash +0 -0
  488. /package/{script → packages/utils/script}/bin/get-arg.bash +0 -0
  489. /package/{script → packages/utils/script}/bin/get-deployed-environments.bash +0 -0
  490. /package/{script → packages/utils/script}/bin/get-env-param.bash +0 -0
  491. /package/{script → packages/utils/script}/bin/get-kwarg.bash +0 -0
  492. /package/{script → packages/utils/script}/bin/get-stack-param.bash +0 -0
  493. /package/{script → packages/utils/script}/bin/has-flag.bash +0 -0
  494. /package/{script → packages/utils/script}/bin/init-constants-script.bash +0 -0
  495. /package/{script → packages/utils/script}/bin/init-params-script.bash +0 -0
  496. /package/{script → packages/utils/script}/bin/stack-exists.bash +0 -0
  497. /package/{script → packages/utils/script}/bin/update-utils.bash +0 -0
  498. /package/{script → packages/utils/script}/bin/upload-pager-duty-endpoints.bash +0 -0
  499. /package/{script → packages/utils/script}/bin/upload-params.bash +0 -0
  500. /package/{script → packages/utils/script}/bin/which.bash +0 -0
  501. /package/{script → packages/utils/script}/bin-entry.bash +0 -0
  502. /package/{script → packages/utils/script}/build.bash +0 -0
  503. /package/{dist/cjs/index.d.ts → packages/utils/src/index.ts} +0 -0
  504. /package/{dist/cjs/services/launchParams/index.d.ts → packages/utils/src/services/launchParams/index.ts} +0 -0
@@ -1,31 +0,0 @@
1
- /**
2
- * Returns the literal type `'yes'` if the first generic tuple array is a prefix of the second,
3
- * the `'no'` literal type otherwise. Can be used in conditional types, e.g.
4
- *
5
- * `type WillBeString = TupleExtends<[1,2], [1,2,3]> extends 'yes' ? string : number;`
6
- *
7
- * There may be a better way to do this; `T1 extends T2` doesn't work
8
- */
9
- export type TupleExtends<T1, T2> = T1 extends [infer T1Head, ...infer T1Tail] ? T2 extends [infer T2Head, ...infer T2Tail] ? T1Head extends T2Head ? TupleExtends<T1Tail, T2Tail> extends 'yes' ? 'yes' : 'no' : 'no' : T2 extends [] ? 'yes' : 'no' : T1 extends [] ? T2 extends [] ? 'yes' : 'no' : 'no';
10
- /**
11
- * unions each member of the tuple
12
- */
13
- export type TupleZip<T1, T2> = T1 extends [infer T1Head, ...infer T1Tail] ? T2 extends [infer T2Head, ...infer T2Tail] ? [T1Head & T2Head, ...TupleZip<T1Tail, T2Tail>] : T2 extends [] ? T1 : never : T1 extends [] ? T2 extends any[] ? T2 : never : never;
14
- /**
15
- * If `R` is `Promise<I>`, returns `I`, otherwise returns `R`
16
- * @deprecated use TypeScript builtin Awaited instead:
17
- * @see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-5.html#the-awaited-type-and-promise-improvements
18
- */
19
- export type UnwrapPromise<R> = R extends Promise<infer I> ? I : R;
20
- /**
21
- * turns `thing | thing2` into `thing & thing2`
22
- * @see https://stackoverflow.com/a/50375286/14809536
23
- */
24
- export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
25
- /**
26
- * make certain fields required
27
- * @see https://stackoverflow.com/a/69328045/14809536
28
- */
29
- export type WithRequired<T, K extends keyof T> = T & {
30
- [P in K]-?: T[P];
31
- };
package/dist/cjs/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,89 +0,0 @@
1
- export type AssertionFailed = string | Error | (() => never) | undefined;
2
- export declare const doThrow: (failed: AssertionFailed) => never;
3
- /**
4
- * Asserts that the given value is true.
5
- *
6
- * @param x The value to assert.
7
- * @param failed The error to throw if the assertion fails. It is STRONGLY encouraged
8
- * to provide some value for this for traceability. Passing an Error instead of a string
9
- * makes the stack trace more useful and allows you to handle assertion failures differently.
10
- * @example const definitelyTrue = assertTrue(randomThing, new Error('thing was not true'));
11
- * @returns the value that was asserted
12
- */
13
- export declare const assertTrue: <X>(x: X, failed?: AssertionFailed) => X & true;
14
- /**
15
- * Asserts that the given value is false.
16
- *
17
- * @param x The value to assert.
18
- * @param failed The error to throw if the assertion fails. It is STRONGLY encouraged
19
- * to provide some value for this for traceability. Passing an Error instead of a string
20
- * makes the stack trace more useful and allows you to handle assertion failures differently.
21
- * @example const definitelyFalse = assertFalse(randomThing, new Error('thing was not false'));
22
- * @returns the value that was asserted
23
- */
24
- export declare const assertFalse: <X>(x: X, failed?: AssertionFailed) => X & false;
25
- /**
26
- * Asserts that the given value is defined.
27
- *
28
- * @param x The value to assert.
29
- * @param failed The error to throw if the assertion fails. It is STRONGLY encouraged
30
- * to provide some value for this for traceability. Passing an Error instead of a string
31
- * makes the stack trace more useful and allows you to handle assertion failures differently.
32
- * @example const definitelyDefined = assertDefined(randomThing, new Error('thing was undefined'));
33
- * @returns the value that was asserted, with a type that excludes undefined
34
- */
35
- export declare const assertDefined: <X>(x: X, failed?: AssertionFailed) => Exclude<X, undefined>;
36
- /**
37
- * Asserts that the given value is a string.
38
- *
39
- * @param x The value to assert.
40
- * @param failed The error to throw if the assertion fails. It is STRONGLY encouraged
41
- * to provide some value for this for traceability. Passing an Error instead of a string
42
- * makes the stack trace more useful and allows you to handle assertion failures differently.
43
- * @example const definitelyAString = assertString(randomThing, new Error('thing is not a string'));
44
- * @returns the value that was asserted
45
- */
46
- export declare const assertString: <X>(x: X, failed?: AssertionFailed) => string;
47
- /**
48
- * Asserts that the given value is not `NaN`. Does not assert that the value is a number.
49
- *
50
- * @param thing The value to assert.
51
- * @param failed The error to throw if the assertion fails. It is STRONGLY encouraged
52
- * to provide some value for this for traceability. Passing an Error instead of a string
53
- * makes the stack trace more useful and allows you to handle assertion failures differently.
54
- * @example const definitelyNotNotANumber = assertNotNaN(randomThing, new Error('thing was NaN'));
55
- * @returns the value that was asserted
56
- */
57
- export declare const assertNotNaN: <T>(thing: T, failed?: AssertionFailed) => T;
58
- /**
59
- * @deprecated use assertNotNaN instead
60
- */
61
- export declare const notNaN: <T>(thing: T, failed?: AssertionFailed) => T;
62
- /**
63
- * Asserts that the first argument is an instance of the second.
64
- *
65
- * @param thing The value to assert.
66
- * @param constructable The class to check against.
67
- * @param failed The error to throw if the assertion fails. It is STRONGLY encouraged
68
- * to provide some value for this for traceability. Passing an Error instead of a string
69
- * makes the stack trace more useful and allows you to handle assertion failures differently.
70
- * @example const definitelySyntaxError = assertInstanceOf(error, SyntaxError, new Error('argument was not a SyntaxError'));
71
- * @returns the value that was asserted
72
- */
73
- export declare const assertInstanceOf: <T>(thing: any, constructable: Function & {
74
- new (...args: any[]): T;
75
- }, failed?: AssertionFailed) => T;
76
- /**
77
- * Asserts that the error in the first argument is an instance of the error given as the
78
- * second argument
79
- *
80
- * @param thing The value to assert.
81
- * @param constructable The error class to check against.
82
- * @example const definitelySyntaxError = assertInstanceOf(error, SyntaxError);
83
- * @returns the value that was asserted
84
- * @throws the original error if the check fails
85
- * @see assertInstanceOf
86
- */
87
- export declare const assertErrorInstanceOf: <T extends Error>(thing: unknown, constructable: Function & {
88
- new (...args: any[]): T;
89
- }) => T;
@@ -1,5 +0,0 @@
1
- import { SSM } from '@aws-sdk/client-ssm';
2
- /**
3
- * A memoized instance of the AWS SSM client.
4
- */
5
- export declare const ssmService: () => SSM;
@@ -1,6 +0,0 @@
1
- import { SSM } from '@aws-sdk/client-ssm';
2
- import { once } from '..';
3
- /**
4
- * A memoized instance of the AWS SSM client.
5
- */
6
- export const ssmService = once(() => new SSM({ apiVersion: '2012-08-10' }));
@@ -1,10 +0,0 @@
1
- import { ConfigValueProvider } from '.';
2
- /**
3
- * Returns a value from the AWS Parameter Store.
4
- *
5
- * @param parameterName the name of the parameter; can be a literal name (string) or can itself
6
- * be accessed via another parameter by giving a configuration value provider.
7
- * @example const someValue = resolveConfig(awsParameterConfig('some-parameter-name'));
8
- * @returns the configuration value provider for the value
9
- */
10
- export declare const awsParameterConfig: (parameterName: ConfigValueProvider<string>) => ConfigValueProvider<string>;
@@ -1,22 +0,0 @@
1
- import { GetParameterCommand } from '@aws-sdk/client-ssm';
2
- import { assertDefined } from '../assertions';
3
- import { ssmService } from '../aws/ssmService';
4
- import { resolveConfigValue } from './resolveConfigValue';
5
- /**
6
- * Returns a value from the AWS Parameter Store.
7
- *
8
- * @param parameterName the name of the parameter; can be a literal name (string) or can itself
9
- * be accessed via another parameter by giving a configuration value provider.
10
- * @example const someValue = resolveConfig(awsParameterConfig('some-parameter-name'));
11
- * @returns the configuration value provider for the value
12
- */
13
- export const awsParameterConfig = (parameterName) => {
14
- return async () => {
15
- const command = new GetParameterCommand({ Name: await resolveConfigValue(parameterName), WithDecryption: true });
16
- // send() throws ParameterNotFound if the parameter is missing,
17
- // so it's not clear what missing Parameter or Value mean
18
- const response = await ssmService().send(command);
19
- const parameter = assertDefined(response.Parameter, `aws GetParameter response missing Parameter key for ${parameterName}"`);
20
- return assertDefined(parameter.Value, `aws GetParameter response missing Parameter.Value key for ${parameterName}"`);
21
- };
22
- };
@@ -1,24 +0,0 @@
1
- import type { ConfigValueProvider } from '.';
2
- /**
3
- * A list of environment variables that were requested at build time. Used by webpack to
4
- * capture build-time environment variables values.
5
- */
6
- export declare const ENV_BUILD_CONFIGS: string[];
7
- /**
8
- * Returns an environment variable from the process environment. Depending on the `type` in the
9
- * call to get the variable, the variable's value may be what it was at build time, not at runtime.
10
- * The return value is not the variable value itself, but rather a provider that has to be called
11
- * to read the variable value (meaning, this is safe to call even if the variable doesn't exist,
12
- * because someone else later needs to call the provider to get the value -- that call may explode,
13
- * but this one won't).
14
- *
15
- * @param name The name of the environment variable to retrieve.
16
- * @param type The mode for accessing the variable. Defaults to `'build'`, i.e. getting the
17
- * variable as it was set at build time (webpack is connected here to make this possible). This
18
- * argument can also be `'runtime'` in which case the value at build time is ignored and the
19
- * variable is pulled live from `process.env`.
20
- * @param [defaultValue] The default value to use if the variable is not found.
21
- *
22
- * @example const config = { configValue: envConfig('environment_variable_name') };
23
- */
24
- export declare const envConfig: (name: string, type?: "build" | "runtime", defaultValue?: ConfigValueProvider<string>) => ConfigValueProvider<string>;
@@ -1,53 +0,0 @@
1
- import { resolveConfigValue } from './resolveConfigValue';
2
- /**
3
- * A list of environment variables that were requested at build time. Used by webpack to
4
- * capture build-time environment variables values.
5
- */
6
- export const ENV_BUILD_CONFIGS = [];
7
- /**
8
- * Returns an environment variable from the process environment. Depending on the `type` in the
9
- * call to get the variable, the variable's value may be what it was at build time, not at runtime.
10
- * The return value is not the variable value itself, but rather a provider that has to be called
11
- * to read the variable value (meaning, this is safe to call even if the variable doesn't exist,
12
- * because someone else later needs to call the provider to get the value -- that call may explode,
13
- * but this one won't).
14
- *
15
- * @param name The name of the environment variable to retrieve.
16
- * @param type The mode for accessing the variable. Defaults to `'build'`, i.e. getting the
17
- * variable as it was set at build time (webpack is connected here to make this possible). This
18
- * argument can also be `'runtime'` in which case the value at build time is ignored and the
19
- * variable is pulled live from `process.env`.
20
- * @param [defaultValue] The default value to use if the variable is not found.
21
- *
22
- * @example const config = { configValue: envConfig('environment_variable_name') };
23
- */
24
- export const envConfig = (name, type, defaultValue) => {
25
- // this doesn't use a default parameter value because of a:
26
- // "Regular parameters should not come after default parameters."
27
- // error that occurs when the defaultValue optional default of `undefined`
28
- // gets optimized out, causing a problem in cloudfront functions.
29
- type !== null && type !== void 0 ? type : (type = 'build');
30
- if (type === 'build') {
31
- ENV_BUILD_CONFIGS.push(name);
32
- }
33
- return () => {
34
- /*global __PROCESS_ENV*/
35
- // @ts-ignore - hack to get around the way webpack/define works
36
- // - https://github.com/webpack/webpack/issues/14800
37
- // - https://github.com/webpack/webpack/issues/5392
38
- // also, spread operator not supported in cloudfront functions
39
- const envs = Object.assign({}, process.env, typeof __PROCESS_ENV !== 'undefined' ? __PROCESS_ENV : {});
40
- const value = envs[name];
41
- if (value === undefined) {
42
- if (defaultValue === undefined) {
43
- throw new Error(`expected to find environment variable with name: ${name}`);
44
- }
45
- else {
46
- return resolveConfigValue(defaultValue);
47
- }
48
- }
49
- else {
50
- return value;
51
- }
52
- };
53
- };
@@ -1,17 +0,0 @@
1
- export * from './resolveConfigValue';
2
- /*
3
- * ===========
4
- * re-usable config providers
5
- * ===========
6
- * */
7
- /**
8
- * stub, mostly for testing. sometimes it helps please typescript to use this if you have
9
- * two configs you want to have the same type but one is a fixed string and one is a complicated provider
10
- *
11
- * @example const config = { configValue: stubConfig('just-a-string') };
12
- */
13
- export const stubConfig = (configValue) => configValue;
14
- export * from './envConfig';
15
- export * from './replaceConfig';
16
- export * from './awsParameterConfig';
17
- export * from './lambdaParameterConfig';
@@ -1,12 +0,0 @@
1
- import { ConfigValueProvider } from '.';
2
- /**
3
- * Returns a value from the AWS Parameter Store. Can only be used during in AWS Lambda, and
4
- * requires that the AWS Parameters and Secrets Lambda Extension Layer be included in the Lambda.
5
- * This extension has built-in caching for requested parameters.
6
- *
7
- * @param parameterName the name of the parameter; can be a literal name (string) or can itself
8
- * be accessed via another parameter by giving a configuration value provider.
9
- * @example const someValue = resolveConfig(lambdaParameterConfig('some-parameter-name'));
10
- * @returns the configuration value provider for the value
11
- */
12
- export declare const lambdaParameterConfig: (parameterName: ConfigValueProvider<string>) => ConfigValueProvider<string>;
@@ -1,38 +0,0 @@
1
- import fetch from 'node-fetch';
2
- import { assertDefined } from '../assertions';
3
- import { retryWithDelay } from '../misc/helpers';
4
- import { envConfig } from './envConfig';
5
- import { resolveConfigValue } from '.';
6
- const lambdaExtensionUrl = 'http://localhost:2773';
7
- let lambdaExtensionReadyPromise;
8
- /**
9
- * Returns a value from the AWS Parameter Store. Can only be used during in AWS Lambda, and
10
- * requires that the AWS Parameters and Secrets Lambda Extension Layer be included in the Lambda.
11
- * This extension has built-in caching for requested parameters.
12
- *
13
- * @param parameterName the name of the parameter; can be a literal name (string) or can itself
14
- * be accessed via another parameter by giving a configuration value provider.
15
- * @example const someValue = resolveConfig(lambdaParameterConfig('some-parameter-name'));
16
- * @returns the configuration value provider for the value
17
- */
18
- export const lambdaParameterConfig = (parameterName) => async () => {
19
- const token = await resolveConfigValue(envConfig('AWS_SESSION_TOKEN', 'runtime'));
20
- const name = await resolveConfigValue(parameterName);
21
- if (!lambdaExtensionReadyPromise) {
22
- // This request will return 400 Bad Request,
23
- // but we only care that it'll block until the extension is ready
24
- lambdaExtensionReadyPromise = retryWithDelay(() => fetch(lambdaExtensionUrl));
25
- }
26
- await lambdaExtensionReadyPromise;
27
- const resp = await retryWithDelay(() => fetch(
28
- // Port 2773 is the default port for the extension
29
- `${lambdaExtensionUrl}/systemsmanager/parameters/get?name=${name}&withDecryption=true`, { headers: { 'X-Aws-Parameters-Secrets-Token': token } }));
30
- if (resp.ok) {
31
- const response = await resp.json();
32
- const parameter = assertDefined(response.Parameter, `aws GetParameter response missing Parameter key for ${name}"`);
33
- return assertDefined(parameter.Value, `aws GetParameter response missing Parameter.Value key for ${name}"`);
34
- }
35
- else {
36
- throw new Error(`HTTP Error Response ${resp.status} ${resp.statusText} while fetching parameter ${name}`);
37
- }
38
- };
@@ -1,14 +0,0 @@
1
- import { ConfigValueProvider } from '.';
2
- /**
3
- * Substitutes configuration values into a provided string.
4
- * Performs a string substitution using configuration values
5
- * @param base The string into which substitutions will be made; contains tokens that are
6
- * referenced in the `replacements` argument.
7
- * @param replacements A map of tokens to configuration value providers. The providers are
8
- * resolved and the values are substituted into the `base` string, replacing the tokens.
9
- * @example replaceConfig('https://[host]', { '[host]': envConfig('HOST') })
10
- * @returns the string after substitution is complete
11
- */
12
- export declare const replaceConfig: (base: ConfigValueProvider<string>, replacements: {
13
- [token: string]: ConfigValueProvider<string>;
14
- }) => ConfigValueProvider<string>;
@@ -1,5 +0,0 @@
1
- import type { ConfigValue, ConfigValueProvider } from '.';
2
- /**
3
- * resolves a config value into a string, to be used inside of things that are provided configurations
4
- */
5
- export declare const resolveConfigValue: <V extends ConfigValue>(provider: ConfigValueProvider<V>) => Promise<V>;
@@ -1,8 +0,0 @@
1
- /**
2
- * resolves a config value into a string, to be used inside of things that are provided configurations
3
- */
4
- export const resolveConfigValue = async (provider) => {
5
- return typeof provider === 'function'
6
- ? await provider()
7
- : provider;
8
- };
@@ -1,88 +0,0 @@
1
- import type { JsonCompatibleStruct } from '../routing';
2
- /**
3
- * Returns true if the error is defined in this library
4
- */
5
- export declare const isAppError: (e: any) => e is Error & {
6
- constructor: {
7
- TYPE: string;
8
- };
9
- };
10
- /**
11
- * Invalid request error
12
- *
13
- * `InvalidRequestError.matches(error)` is a reliable way to check if an error is an
14
- * `InvalidRequestError`; `instanceof` checks may not work if code is split into multiple bundles
15
- */
16
- export declare class InvalidRequestError extends Error {
17
- static readonly TYPE = "InvalidRequestError";
18
- static matches: (e: any) => e is typeof InvalidRequestError;
19
- constructor(message?: string);
20
- }
21
- /**
22
- * Validation Error
23
- *
24
- * `ValidationError.matches(error)` is a reliable way to check if an error is an
25
- * `ValidationError`; `instanceof` checks may not work if code is split into multiple bundles
26
- */
27
- export declare class ValidationError extends Error {
28
- static readonly TYPE = "ValidationError";
29
- static matches: (e: any) => e is typeof ValidationError;
30
- private data;
31
- constructor(data: JsonCompatibleStruct);
32
- getData(): JsonCompatibleStruct;
33
- }
34
- /**
35
- * Unauthorized error
36
- *
37
- * `UnauthorizedError.matches(error)` is a reliable way to check if an error is an
38
- * `UnauthorizedError`; `instanceof` checks may not work if code is split into multiple bundles
39
- */
40
- export declare class UnauthorizedError extends Error {
41
- static readonly TYPE = "UnauthorizedError";
42
- static matches: (e: any) => e is typeof UnauthorizedError;
43
- constructor(message?: string);
44
- }
45
- /**
46
- * Forbidden error
47
- *
48
- * `ForbiddenError.matches(error)` is a reliable way to check if an error is a
49
- * `ForbiddenError`; `instanceof` checks may not work if code is split into multiple bundles
50
- */
51
- export declare class ForbiddenError extends Error {
52
- static readonly TYPE = "ForbiddenError";
53
- static matches: (e: any) => e is typeof ForbiddenError;
54
- constructor(message?: string);
55
- }
56
- /**
57
- * Not found error
58
- *
59
- * `NotFoundError.matches(error)` is a reliable way to check if an error is a
60
- * `NotFoundError`; `instanceof` checks may not work if code is split into multiple bundles
61
- */
62
- export declare class NotFoundError extends Error {
63
- static readonly TYPE = "NotFoundError";
64
- static matches: (e: any) => e is typeof NotFoundError;
65
- constructor(message?: string);
66
- }
67
- /**
68
- * Session expired error
69
- *
70
- * `SessionExpiredError.matches(error)` is a reliable way to check if an error is a
71
- * `SessionExpiredError`; `instanceof` checks may not work if code is split into multiple bundles
72
- */
73
- export declare class SessionExpiredError extends Error {
74
- static readonly TYPE = "SessionExpiredError";
75
- static matches: (e: any) => e is typeof SessionExpiredError;
76
- constructor(message?: string);
77
- }
78
- /**
79
- * Conflict error
80
- *
81
- * `ConflictError.matches(error)` is a reliable way to check if an error is a
82
- * `ConflictError`; `instanceof` checks may not work if code is split into multiple bundles
83
- */
84
- export declare class ConflictError extends Error {
85
- static readonly TYPE = "ConflictError";
86
- static matches: (e: any) => e is typeof ConflictError;
87
- constructor(message?: string);
88
- }
@@ -1,8 +0,0 @@
1
- import { RetryOptions } from '../misc/helpers';
2
- import { GenericFetch } from '.';
3
- interface Options extends RetryOptions {
4
- status?: number[];
5
- timeout?: number;
6
- }
7
- export declare const fetchStatusRetry: (base: GenericFetch, options: Options) => GenericFetch;
8
- export {};
@@ -1,23 +0,0 @@
1
- import { retryWithDelay } from '../misc/helpers';
2
- export const fetchStatusRetry = (base, options) => {
3
- return (...params) => retryWithDelay(() => {
4
- const fetchPromise = base(...params).then(r => {
5
- var _a;
6
- if ((_a = options.status) === null || _a === void 0 ? void 0 : _a.includes(r.status)) {
7
- return r.text().then(text => {
8
- throw new Error(`fetch failed ${params[0]} -- ${r.status}: ${text}`);
9
- });
10
- }
11
- return r;
12
- });
13
- if (options.timeout) {
14
- const timeoutPromise = new Promise((_, reject) => {
15
- setTimeout(() => {
16
- reject(new Error(`fetch timeout after ${options.timeout}ms: ${params[0]}`));
17
- }, options.timeout);
18
- });
19
- return Promise.race([fetchPromise, timeoutPromise]);
20
- }
21
- return fetchPromise;
22
- }, options);
23
- };
@@ -1,64 +0,0 @@
1
- import { METHOD } from '../routing';
2
- export declare enum FetchStateType {
3
- SUCCESS = "success",
4
- ERROR = "error",
5
- LOADING = "loading",
6
- IDLE = "idle"
7
- }
8
- export type FetchState<D, E> = FetchStateLoading<D> | FetchStateError<D, E> | FetchStateSuccess<D> | FetchStateIdle;
9
- type FetchStateLoading<D> = {
10
- type: FetchStateType.LOADING;
11
- data?: D;
12
- };
13
- type FetchStateError<D, E> = {
14
- type: FetchStateType.ERROR;
15
- data?: D;
16
- error: E;
17
- };
18
- type FetchStateSuccess<D> = {
19
- type: FetchStateType.SUCCESS;
20
- data: D;
21
- };
22
- type FetchStateIdle = {
23
- type: FetchStateType.IDLE;
24
- };
25
- export declare const fetchLoading: <D, E>(previous?: FetchState<D, E>) => FetchStateLoading<D>;
26
- export declare const fetchError: <D, E>(error: E, previous?: FetchState<D, E>) => FetchStateError<D, E>;
27
- export declare const fetchSuccess: <D>(data: D) => FetchStateSuccess<D>;
28
- export declare const fetchIdle: () => FetchStateIdle;
29
- export declare const stateHasData: <D, E>(state: {
30
- type: FetchStateType;
31
- data?: D;
32
- error?: E;
33
- }) => state is {
34
- type: FetchStateType;
35
- data: D;
36
- };
37
- export declare const stateHasError: <D, E>(state: {
38
- type: FetchStateType;
39
- data?: D;
40
- error?: E;
41
- }) => state is {
42
- type: FetchStateType;
43
- error: E;
44
- };
45
- export type FetchConfig = {
46
- credentials?: 'include' | 'omit' | 'same-origin';
47
- method?: METHOD;
48
- body?: string;
49
- headers?: {
50
- [key: string]: string;
51
- };
52
- };
53
- type Headers = {
54
- get: (name: string) => string | null;
55
- };
56
- export type Response = {
57
- status: number;
58
- headers: Headers;
59
- json: () => Promise<any>;
60
- text: () => Promise<string>;
61
- };
62
- export type GenericFetch<C extends FetchConfig = FetchConfig, R extends Response = Response> = (url: string, fetchConfig?: C) => Promise<R>;
63
- export type ConfigForFetch<F> = F extends GenericFetch<infer C, any> ? C : never;
64
- export {};
@@ -1,46 +0,0 @@
1
- /*
2
- * these are just helpers for formatting responses, they don't actually do any loading. especially in UI development they
3
- * help with continuity over loading, reloading, saving, and errors. this is pretty nice in typescript because you have to deal
4
- * with the possibility that the result state is in a loading or error state. if you avoid dealing with those states you need
5
- * to write very clear code to ignore them, which easily presents missing functionality like errors that are not being messaged
6
- * to the user.
7
- * */
8
- export var FetchStateType;
9
- (function (FetchStateType) {
10
- FetchStateType["SUCCESS"] = "success";
11
- FetchStateType["ERROR"] = "error";
12
- FetchStateType["LOADING"] = "loading";
13
- FetchStateType["IDLE"] = "idle";
14
- })(FetchStateType || (FetchStateType = {}));
15
- /*
16
- * keeps existing data but sets the new status
17
- *
18
- * const state = fetchLoading(previousState)
19
- * */
20
- export const fetchLoading = (previous) => ({ type: FetchStateType.LOADING, ...(previous && 'data' in previous ? { data: previous.data } : {}) });
21
- /*
22
- * keeps existing data but sets the new status and error value
23
- *
24
- * const state = fetchError(error, previousState)
25
- * */
26
- export const fetchError = (error, previous) => ({ ...previous, type: FetchStateType.ERROR, error });
27
- /*
28
- * formats data with success type
29
- *
30
- * const state = fetchSuccess(newData)
31
- * */
32
- export const fetchSuccess = (data) => ({ type: FetchStateType.SUCCESS, data });
33
- /*
34
- * formats data with idle type
35
- *
36
- * const state = fetchIdle(newData)
37
- * */
38
- export const fetchIdle = () => ({ type: FetchStateType.IDLE });
39
- /*
40
- * guard for checking if the state has result data, it might be true for any state type.
41
- * */
42
- export const stateHasData = (state) => 'data' in state;
43
- /*
44
- * guard for checking if the state has an error, it might be true for error or loading states.
45
- * */
46
- export const stateHasError = (state) => 'error' in state;
@@ -1,36 +0,0 @@
1
- /**
2
- * checks if a thing is defined. while often easy to do with a simple if statement, in certain
3
- * situations the guard is required and its nice to have one pre-defined. E.g. in the following
4
- * example, the result is `Array<string>`.
5
- *
6
- * `const result = (array as Array<string | undefined>).filter(isDefined);`
7
- */
8
- export const isDefined = (x) => x !== undefined;
9
- /**
10
- * checks if a thing is not null. while often easy to do with a simple if statement,
11
- * in certain situations the guard is required and its nice to have one pre-defined.
12
- * E.g. in the following example, the result is `Array<string>`.
13
- *
14
- * `const result = (array as Array<string | null>).filter(isNotNull);`
15
- */
16
- export const isNotNull = (x) => x !== null;
17
- /**
18
- * checks if a thing is a number. while often easy to do with a simple if statement, in certain
19
- * situations the guard is required and its nice to have one pre-defined. E.g. in the following
20
- * example, the result is `Array<number>`.
21
- *
22
- * `const result = (array as Array<number | undefined>).filter(isNumber);`
23
- */
24
- export const isNumber = (x) => typeof x === 'number';
25
- /**
26
- * a guard for plain old javascript objects that are not based on some other prototype,
27
- * for example making them safe to JSON stringify and stuff
28
- */
29
- export const isPlainObject = (thing) => thing instanceof Object && thing.__proto__.constructor.name === 'Object';
30
- /**
31
- * if the first thing is defined it uses it, otherwise it returns the second thing. this isn't
32
- * really a guard its just a way to provide a default value without creating a coverage branch.
33
- *
34
- * @example const valueWithDefault = ifDefined(thing, 'default value')
35
- */
36
- export const ifDefined = (x, d) => isDefined(x) ? x : d;
@@ -1,4 +0,0 @@
1
- export * from './misc/partitionSequence';
2
- export * from './misc/helpers';
3
- export * from './misc/merge';
4
- export * from './misc/hashValue';
package/dist/esm/index.js DELETED
@@ -1,4 +0,0 @@
1
- export * from './misc/partitionSequence';
2
- export * from './misc/helpers';
3
- export * from './misc/merge';
4
- export * from './misc/hashValue';