@ohos-ports/layer0-prefetch 4.20.0-beta.0 → 4.20.0-beta.1

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 (281) hide show
  1. package/node_modules/@layer0/core/README.md +50 -0
  2. package/node_modules/@layer0/core/build.d.ts +5 -0
  3. package/node_modules/@layer0/core/build.js +17 -0
  4. package/node_modules/@layer0/core/cache/Cache.d.ts +56 -0
  5. package/node_modules/@layer0/core/cache/Cache.js +138 -0
  6. package/node_modules/@layer0/core/cache/CacheKey.d.ts +52 -0
  7. package/node_modules/@layer0/core/cache/CacheKey.js +95 -0
  8. package/node_modules/@layer0/core/config.d.ts +53 -0
  9. package/node_modules/@layer0/core/config.js +113 -0
  10. package/node_modules/@layer0/core/constants.d.ts +214 -0
  11. package/node_modules/@layer0/core/constants.js +216 -0
  12. package/node_modules/@layer0/core/context.d.ts +38 -0
  13. package/node_modules/@layer0/core/context.js +98 -0
  14. package/node_modules/@layer0/core/default-app/all/layer0.config.js +60 -0
  15. package/node_modules/@layer0/core/default-app/js/routes.js +27 -0
  16. package/node_modules/@layer0/core/default-app/ts/routes.ts +27 -0
  17. package/node_modules/@layer0/core/deploy/DeploymentBuilder.d.ts +177 -0
  18. package/node_modules/@layer0/core/deploy/DeploymentBuilder.js +543 -0
  19. package/node_modules/@layer0/core/deploy/bundle-esbuild.d.ts +11 -0
  20. package/node_modules/@layer0/core/deploy/bundle-esbuild.js +67 -0
  21. package/node_modules/@layer0/core/deploy/bundle-ncc.d.ts +8 -0
  22. package/node_modules/@layer0/core/deploy/bundle-ncc.js +30 -0
  23. package/node_modules/@layer0/core/deploy/bundle-nft.d.ts +7 -0
  24. package/node_modules/@layer0/core/deploy/bundle-nft.js +41 -0
  25. package/node_modules/@layer0/core/deploy/bundle-webpack.d.ts +11 -0
  26. package/node_modules/@layer0/core/deploy/bundle-webpack.js +127 -0
  27. package/node_modules/@layer0/core/deploy/index.d.ts +19 -0
  28. package/node_modules/@layer0/core/deploy/index.js +6 -0
  29. package/node_modules/@layer0/core/deploy/listSources.d.ts +11 -0
  30. package/node_modules/@layer0/core/deploy/listSources.js +18 -0
  31. package/node_modules/@layer0/core/deploy/paths.d.ts +27 -0
  32. package/node_modules/@layer0/core/deploy/paths.js +33 -0
  33. package/node_modules/@layer0/core/deploy/resolveInPackage.d.ts +7 -0
  34. package/node_modules/@layer0/core/deploy/resolveInPackage.js +21 -0
  35. package/node_modules/@layer0/core/deploy/routeToFiles.d.ts +14 -0
  36. package/node_modules/@layer0/core/deploy/routeToFiles.js +24 -0
  37. package/node_modules/@layer0/core/dev/DevServerOptions.d.ts +33 -0
  38. package/node_modules/@layer0/core/dev/DevServerOptions.js +2 -0
  39. package/node_modules/@layer0/core/dev/createDevServer.d.ts +8 -0
  40. package/node_modules/@layer0/core/dev/createDevServer.js +114 -0
  41. package/node_modules/@layer0/core/dev/index.d.ts +3 -0
  42. package/node_modules/@layer0/core/dev/index.js +6 -0
  43. package/node_modules/@layer0/core/dev/runLocalApp.d.ts +8 -0
  44. package/node_modules/@layer0/core/dev/runLocalApp.js +73 -0
  45. package/node_modules/@layer0/core/dev/serverlessCompatibilityMiddleware.d.ts +11 -0
  46. package/node_modules/@layer0/core/dev/serverlessCompatibilityMiddleware.js +30 -0
  47. package/node_modules/@layer0/core/edge/EdgeErrorPageResponseWriter.d.ts +12 -0
  48. package/node_modules/@layer0/core/edge/EdgeErrorPageResponseWriter.js +22 -0
  49. package/node_modules/@layer0/core/edge/EdgeResponseWriter.d.ts +122 -0
  50. package/node_modules/@layer0/core/edge/EdgeResponseWriter.js +451 -0
  51. package/node_modules/@layer0/core/edge/createEdgeConfig.d.ts +16 -0
  52. package/node_modules/@layer0/core/edge/createEdgeConfig.js +284 -0
  53. package/node_modules/@layer0/core/environment.d.ts +24 -0
  54. package/node_modules/@layer0/core/environment.js +42 -0
  55. package/node_modules/@layer0/core/errors/BackendFetchError.d.ts +11 -0
  56. package/node_modules/@layer0/core/errors/BackendFetchError.js +17 -0
  57. package/node_modules/@layer0/core/errors/FrameworkBuildError.d.ts +7 -0
  58. package/node_modules/@layer0/core/errors/FrameworkBuildError.js +26 -0
  59. package/node_modules/@layer0/core/index.d.ts +3 -0
  60. package/node_modules/@layer0/core/index.js +9 -0
  61. package/node_modules/@layer0/core/init/addToPackageJson.d.ts +7 -0
  62. package/node_modules/@layer0/core/init/addToPackageJson.js +22 -0
  63. package/node_modules/@layer0/core/init/index.d.ts +2 -0
  64. package/node_modules/@layer0/core/init/index.js +6 -0
  65. package/node_modules/@layer0/core/init/init.d.ts +5 -0
  66. package/node_modules/@layer0/core/init/init.js +17 -0
  67. package/node_modules/@layer0/core/lambda/JSBackend.d.ts +30 -0
  68. package/node_modules/@layer0/core/lambda/JSBackend.js +51 -0
  69. package/node_modules/@layer0/core/lambda/RequestListenerJSBackend.d.ts +8 -0
  70. package/node_modules/@layer0/core/lambda/RequestListenerJSBackend.js +19 -0
  71. package/node_modules/@layer0/core/lambda/adaptResponseEncodingToDownstream.d.ts +17 -0
  72. package/node_modules/@layer0/core/lambda/adaptResponseEncodingToDownstream.js +132 -0
  73. package/node_modules/@layer0/core/lambda/consoleWrapper.d.ts +16 -0
  74. package/node_modules/@layer0/core/lambda/consoleWrapper.js +127 -0
  75. package/node_modules/@layer0/core/lambda/getBodyLoggingData.d.ts +10 -0
  76. package/node_modules/@layer0/core/lambda/getBodyLoggingData.js +108 -0
  77. package/node_modules/@layer0/core/lambda/handler.d.ts +1 -0
  78. package/node_modules/@layer0/core/lambda/handler.js +91 -0
  79. package/node_modules/@layer0/core/lambda/handler.js.map +7 -0
  80. package/node_modules/@layer0/core/lambda/innerHandler.d.ts +7 -0
  81. package/node_modules/@layer0/core/lambda/innerHandler.js +181 -0
  82. package/node_modules/@layer0/core/lambda/lambdaInstance.d.ts +29 -0
  83. package/node_modules/@layer0/core/lambda/lambdaInstance.js +71 -0
  84. package/node_modules/@layer0/core/lambda/reqResMapper.d.ts +24 -0
  85. package/node_modules/@layer0/core/lambda/reqResMapper.js +286 -0
  86. package/node_modules/@layer0/core/lambda/stdStreamsWrapper.d.ts +31 -0
  87. package/node_modules/@layer0/core/lambda/stdStreamsWrapper.js +196 -0
  88. package/node_modules/@layer0/core/lambda/toJSBackend.d.ts +10 -0
  89. package/node_modules/@layer0/core/lambda/toJSBackend.js +23 -0
  90. package/node_modules/@layer0/core/node_modules/esbuild/LICENSE.md +21 -0
  91. package/node_modules/@layer0/core/node_modules/esbuild/README.md +3 -0
  92. package/node_modules/@layer0/core/node_modules/esbuild/bin/esbuild +223 -0
  93. package/node_modules/@layer0/core/node_modules/esbuild/install.js +301 -0
  94. package/node_modules/@layer0/core/node_modules/esbuild/lib/main.d.ts +716 -0
  95. package/node_modules/@layer0/core/node_modules/esbuild/lib/main.js +2532 -0
  96. package/node_modules/@layer0/core/node_modules/esbuild/node_modules/@ohos-ports/esbuild-openharmony-arm64/README.md +3 -0
  97. package/node_modules/@layer0/core/node_modules/esbuild/node_modules/@ohos-ports/esbuild-openharmony-arm64/bin/esbuild +0 -0
  98. package/node_modules/@layer0/core/node_modules/esbuild/node_modules/@ohos-ports/esbuild-openharmony-arm64/esbuild.wasm +0 -0
  99. package/node_modules/@layer0/core/node_modules/esbuild/node_modules/@ohos-ports/esbuild-openharmony-arm64/package.json +28 -0
  100. package/node_modules/@layer0/core/node_modules/esbuild/node_modules/@ohos-ports/esbuild-openharmony-arm64/wasm_exec.js +575 -0
  101. package/node_modules/@layer0/core/node_modules/esbuild/node_modules/@ohos-ports/esbuild-openharmony-arm64/wasm_exec_node.js +40 -0
  102. package/node_modules/@layer0/core/node_modules/esbuild/package.json +78 -0
  103. package/node_modules/@layer0/core/package.json +132 -0
  104. package/node_modules/@layer0/core/parser/parseRouter.d.ts +13 -0
  105. package/node_modules/@layer0/core/parser/parseRouter.js +77 -0
  106. package/node_modules/@layer0/core/plugins/PluginBase.d.ts +18 -0
  107. package/node_modules/@layer0/core/plugins/PluginBase.js +19 -0
  108. package/node_modules/@layer0/core/router/Backend.d.ts +69 -0
  109. package/node_modules/@layer0/core/router/Backend.js +176 -0
  110. package/node_modules/@layer0/core/router/BackendOptions.d.ts +11 -0
  111. package/node_modules/@layer0/core/router/BackendOptions.js +2 -0
  112. package/node_modules/@layer0/core/router/BaseResponseWriter.d.ts +65 -0
  113. package/node_modules/@layer0/core/router/BaseResponseWriter.js +81 -0
  114. package/node_modules/@layer0/core/router/BehindEdgeResponseWriterProxy.d.ts +4 -0
  115. package/node_modules/@layer0/core/router/BehindEdgeResponseWriterProxy.js +89 -0
  116. package/node_modules/@layer0/core/router/CacheManifest.d.ts +80 -0
  117. package/node_modules/@layer0/core/router/CacheManifest.js +83 -0
  118. package/node_modules/@layer0/core/router/CacheOptions.d.ts +171 -0
  119. package/node_modules/@layer0/core/router/CacheOptions.js +2 -0
  120. package/node_modules/@layer0/core/router/CustomCacheKey.d.ts +140 -0
  121. package/node_modules/@layer0/core/router/CustomCacheKey.js +272 -0
  122. package/node_modules/@layer0/core/router/GroupConfig.d.ts +7 -0
  123. package/node_modules/@layer0/core/router/GroupConfig.js +20 -0
  124. package/node_modules/@layer0/core/router/Groups.d.ts +7 -0
  125. package/node_modules/@layer0/core/router/Groups.js +21 -0
  126. package/node_modules/@layer0/core/router/Headers.d.ts +3 -0
  127. package/node_modules/@layer0/core/router/Headers.js +2 -0
  128. package/node_modules/@layer0/core/router/PathMatcher.d.ts +51 -0
  129. package/node_modules/@layer0/core/router/PathMatcher.js +73 -0
  130. package/node_modules/@layer0/core/router/Preload.d.ts +16 -0
  131. package/node_modules/@layer0/core/router/Preload.js +2 -0
  132. package/node_modules/@layer0/core/router/PreloadRequests.d.ts +23 -0
  133. package/node_modules/@layer0/core/router/PreloadRequests.js +66 -0
  134. package/node_modules/@layer0/core/router/Request.d.ts +74 -0
  135. package/node_modules/@layer0/core/router/Request.js +2 -0
  136. package/node_modules/@layer0/core/router/RequestContext.d.ts +12 -0
  137. package/node_modules/@layer0/core/router/RequestContext.js +11 -0
  138. package/node_modules/@layer0/core/router/Response.d.ts +55 -0
  139. package/node_modules/@layer0/core/router/Response.js +2 -0
  140. package/node_modules/@layer0/core/router/ResponseWriter.d.ts +1011 -0
  141. package/node_modules/@layer0/core/router/ResponseWriter.js +1341 -0
  142. package/node_modules/@layer0/core/router/Route.d.ts +124 -0
  143. package/node_modules/@layer0/core/router/Route.js +280 -0
  144. package/node_modules/@layer0/core/router/RouteCriteria.d.ts +68 -0
  145. package/node_modules/@layer0/core/router/RouteCriteria.js +2 -0
  146. package/node_modules/@layer0/core/router/RouteGroup.d.ts +157 -0
  147. package/node_modules/@layer0/core/router/RouteGroup.js +223 -0
  148. package/node_modules/@layer0/core/router/RouteGroupList.d.ts +45 -0
  149. package/node_modules/@layer0/core/router/RouteGroupList.js +73 -0
  150. package/node_modules/@layer0/core/router/Router.d.ts +439 -0
  151. package/node_modules/@layer0/core/router/Router.js +907 -0
  152. package/node_modules/@layer0/core/router/addBuiltInRoutes.d.ts +2 -0
  153. package/node_modules/@layer0/core/router/addBuiltInRoutes.js +58 -0
  154. package/node_modules/@layer0/core/router/addPreloadHeaders.d.ts +7 -0
  155. package/node_modules/@layer0/core/router/addPreloadHeaders.js +57 -0
  156. package/node_modules/@layer0/core/router/cacheManifestFromRouter.d.ts +6 -0
  157. package/node_modules/@layer0/core/router/cacheManifestFromRouter.js +85 -0
  158. package/node_modules/@layer0/core/router/createCustomCacheKey.d.ts +27 -0
  159. package/node_modules/@layer0/core/router/createCustomCacheKey.js +35 -0
  160. package/node_modules/@layer0/core/router/deriveSurrogateKeysFromJson.d.ts +36 -0
  161. package/node_modules/@layer0/core/router/deriveSurrogateKeysFromJson.js +70 -0
  162. package/node_modules/@layer0/core/router/index.d.ts +11 -0
  163. package/node_modules/@layer0/core/router/index.js +17 -0
  164. package/node_modules/@layer0/core/router/interpolateParams.d.ts +21 -0
  165. package/node_modules/@layer0/core/router/interpolateParams.js +150 -0
  166. package/node_modules/@layer0/core/router/loadRouter.d.ts +13 -0
  167. package/node_modules/@layer0/core/router/loadRouter.js +29 -0
  168. package/node_modules/@layer0/core/router/mergeQueryString.d.ts +1 -0
  169. package/node_modules/@layer0/core/router/mergeQueryString.js +23 -0
  170. package/node_modules/@layer0/core/router/normalizeCriteria.d.ts +6 -0
  171. package/node_modules/@layer0/core/router/normalizeCriteria.js +20 -0
  172. package/node_modules/@layer0/core/router/stream.d.ts +12 -0
  173. package/node_modules/@layer0/core/router/stream.js +30 -0
  174. package/node_modules/@layer0/core/router/universalRouteUtils.d.ts +55 -0
  175. package/node_modules/@layer0/core/router/universalRouteUtils.js +114 -0
  176. package/node_modules/@layer0/core/router/validateWriter.d.ts +41 -0
  177. package/node_modules/@layer0/core/router/validateWriter.js +120 -0
  178. package/node_modules/@layer0/core/serverless.yml +30 -0
  179. package/node_modules/@layer0/core/source.d.ts +9 -0
  180. package/node_modules/@layer0/core/source.js +17 -0
  181. package/node_modules/@layer0/core/test-utils/MockRequest.d.ts +15 -0
  182. package/node_modules/@layer0/core/test-utils/MockRequest.js +36 -0
  183. package/node_modules/@layer0/core/test-utils/MockResponse.d.ts +7 -0
  184. package/node_modules/@layer0/core/test-utils/MockResponse.js +24 -0
  185. package/node_modules/@layer0/core/test-utils/expect-extend.d.ts +1 -0
  186. package/node_modules/@layer0/core/test-utils/expect-extend.js +11 -0
  187. package/node_modules/@layer0/core/test-utils/index.d.ts +4 -0
  188. package/node_modules/@layer0/core/test-utils/index.js +11 -0
  189. package/node_modules/@layer0/core/test-utils/matchers/toBeCachedByTheBrowser.d.ts +19 -0
  190. package/node_modules/@layer0/core/test-utils/matchers/toBeCachedByTheBrowser.js +45 -0
  191. package/node_modules/@layer0/core/test-utils/matchers/toBeCachedByTheEdge.d.ts +19 -0
  192. package/node_modules/@layer0/core/test-utils/matchers/toBeCachedByTheEdge.js +38 -0
  193. package/node_modules/@layer0/core/test-utils/matchers/toBeCachedByTheServiceWorker.d.ts +19 -0
  194. package/node_modules/@layer0/core/test-utils/matchers/toBeCachedByTheServiceWorker.js +45 -0
  195. package/node_modules/@layer0/core/test-utils/matchers/toBeServedStale.d.ts +20 -0
  196. package/node_modules/@layer0/core/test-utils/matchers/toBeServedStale.js +50 -0
  197. package/node_modules/@layer0/core/test-utils/matchers/toHaveBody.d.ts +18 -0
  198. package/node_modules/@layer0/core/test-utils/matchers/toHaveBody.js +40 -0
  199. package/node_modules/@layer0/core/test-utils/matchers/toHaveHeader.d.ts +19 -0
  200. package/node_modules/@layer0/core/test-utils/matchers/toHaveHeader.js +43 -0
  201. package/node_modules/@layer0/core/test-utils/matchers.d.ts +6 -0
  202. package/node_modules/@layer0/core/test-utils/matchers.js +18 -0
  203. package/node_modules/@layer0/core/test-utils/utils/createRouteMock.d.ts +21 -0
  204. package/node_modules/@layer0/core/test-utils/utils/createRouteMock.js +27 -0
  205. package/node_modules/@layer0/core/test-utils/utils/getBackend.d.ts +13 -0
  206. package/node_modules/@layer0/core/test-utils/utils/getBackend.js +30 -0
  207. package/node_modules/@layer0/core/test-utils/utils/getMessage.d.ts +1 -0
  208. package/node_modules/@layer0/core/test-utils/utils/getMessage.js +16 -0
  209. package/node_modules/@layer0/core/test-utils/utils/runRoute.d.ts +10 -0
  210. package/node_modules/@layer0/core/test-utils/utils/runRoute.js +39 -0
  211. package/node_modules/@layer0/core/timing.d.ts +115 -0
  212. package/node_modules/@layer0/core/timing.js +200 -0
  213. package/node_modules/@layer0/core/transform/index.d.ts +1 -0
  214. package/node_modules/@layer0/core/transform/index.js +4 -0
  215. package/node_modules/@layer0/core/transform/transformMethod.d.ts +40 -0
  216. package/node_modules/@layer0/core/transform/transformMethod.js +58 -0
  217. package/node_modules/@layer0/core/types.d.ts +102 -0
  218. package/node_modules/@layer0/core/types.js +30 -0
  219. package/node_modules/@layer0/core/utils/Tasks.d.ts +32 -0
  220. package/node_modules/@layer0/core/utils/Tasks.js +80 -0
  221. package/node_modules/@layer0/core/utils/Validator.d.ts +18 -0
  222. package/node_modules/@layer0/core/utils/Validator.js +178 -0
  223. package/node_modules/@layer0/core/utils/bindParamsToPath.d.ts +15 -0
  224. package/node_modules/@layer0/core/utils/bindParamsToPath.js +49 -0
  225. package/node_modules/@layer0/core/utils/convertParamsToBackReferences.d.ts +16 -0
  226. package/node_modules/@layer0/core/utils/convertParamsToBackReferences.js +45 -0
  227. package/node_modules/@layer0/core/utils/convertStringMatcherToRegex.d.ts +7 -0
  228. package/node_modules/@layer0/core/utils/convertStringMatcherToRegex.js +26 -0
  229. package/node_modules/@layer0/core/utils/decode.d.ts +9 -0
  230. package/node_modules/@layer0/core/utils/decode.js +44 -0
  231. package/node_modules/@layer0/core/utils/esImport.d.ts +1 -0
  232. package/node_modules/@layer0/core/utils/esImport.js +9 -0
  233. package/node_modules/@layer0/core/utils/fs.d.ts +1 -0
  234. package/node_modules/@layer0/core/utils/fs.js +7 -0
  235. package/node_modules/@layer0/core/utils/get.d.ts +6 -0
  236. package/node_modules/@layer0/core/utils/get.js +19 -0
  237. package/node_modules/@layer0/core/utils/getPackageVersion.d.ts +7 -0
  238. package/node_modules/@layer0/core/utils/getPackageVersion.js +19 -0
  239. package/node_modules/@layer0/core/utils/has.d.ts +6 -0
  240. package/node_modules/@layer0/core/utils/has.js +15 -0
  241. package/node_modules/@layer0/core/utils/identity.d.ts +7 -0
  242. package/node_modules/@layer0/core/utils/identity.js +12 -0
  243. package/node_modules/@layer0/core/utils/index.d.ts +1 -0
  244. package/node_modules/@layer0/core/utils/index.js +4 -0
  245. package/node_modules/@layer0/core/utils/isEmpty.d.ts +6 -0
  246. package/node_modules/@layer0/core/utils/isEmpty.js +20 -0
  247. package/node_modules/@layer0/core/utils/isString.d.ts +1 -0
  248. package/node_modules/@layer0/core/utils/isString.js +6 -0
  249. package/node_modules/@layer0/core/utils/logo.d.ts +5 -0
  250. package/node_modules/@layer0/core/utils/logo.js +27 -0
  251. package/node_modules/@layer0/core/utils/mapValues.d.ts +7 -0
  252. package/node_modules/@layer0/core/utils/mapValues.js +16 -0
  253. package/node_modules/@layer0/core/utils/minBy.d.ts +8 -0
  254. package/node_modules/@layer0/core/utils/minBy.js +41 -0
  255. package/node_modules/@layer0/core/utils/nonWebpackRequire.d.ts +11 -0
  256. package/node_modules/@layer0/core/utils/nonWebpackRequire.js +28 -0
  257. package/node_modules/@layer0/core/utils/packageUtils.d.ts +12 -0
  258. package/node_modules/@layer0/core/utils/packageUtils.js +22 -0
  259. package/node_modules/@layer0/core/utils/ports.d.ts +5 -0
  260. package/node_modules/@layer0/core/utils/ports.js +7 -0
  261. package/node_modules/@layer0/core/utils/readBody.d.ts +7 -0
  262. package/node_modules/@layer0/core/utils/readBody.js +15 -0
  263. package/node_modules/@layer0/core/utils/readRawBody.d.ts +9 -0
  264. package/node_modules/@layer0/core/utils/readRawBody.js +21 -0
  265. package/node_modules/@layer0/core/utils/regExpEscape.d.ts +12 -0
  266. package/node_modules/@layer0/core/utils/regExpEscape.js +20 -0
  267. package/node_modules/@layer0/core/utils/requireInternal.d.ts +7 -0
  268. package/node_modules/@layer0/core/utils/requireInternal.js +24 -0
  269. package/node_modules/@layer0/core/utils/set.d.ts +10 -0
  270. package/node_modules/@layer0/core/utils/set.js +21 -0
  271. package/node_modules/@layer0/core/utils/toEdgeRegex.d.ts +11 -0
  272. package/node_modules/@layer0/core/utils/toEdgeRegex.js +23 -0
  273. package/node_modules/@layer0/core/utils/toHttpMethodMatchRegex.d.ts +12 -0
  274. package/node_modules/@layer0/core/utils/toHttpMethodMatchRegex.js +17 -0
  275. package/node_modules/@layer0/core/utils/toLower.d.ts +1 -0
  276. package/node_modules/@layer0/core/utils/toLower.js +9 -0
  277. package/node_modules/@layer0/core/utils/validateBackends.d.ts +5 -0
  278. package/node_modules/@layer0/core/utils/validateBackends.js +30 -0
  279. package/node_modules/@layer0/core/utils/watch.d.ts +10 -0
  280. package/node_modules/@layer0/core/utils/watch.js +17 -0
  281. package/package.json +47 -3
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const os_1 = require("os");
7
+ const constants_1 = require("../constants");
8
+ const environment_1 = require("../environment");
9
+ const nonWebpackRequire_1 = __importDefault(require("./nonWebpackRequire"));
10
+ // config.backends[x] domainOrIp schema
11
+ const domainOrIpSchema = {
12
+ $id: '/domainOrIpSchema',
13
+ type: 'string',
14
+ };
15
+ // config.backends[x] object schema
16
+ const backendObjectSchema = {
17
+ $id: '/backendObjectSchema',
18
+ type: 'object',
19
+ properties: {
20
+ domainOrIp: {
21
+ $ref: domainOrIpSchema.$id,
22
+ },
23
+ port: {
24
+ type: 'number',
25
+ // We allow all ports but we will always use HTTPS protocol no matter the port.
26
+ minimum: 1,
27
+ maximum: 65535,
28
+ },
29
+ hostHeader: {
30
+ type: 'string',
31
+ },
32
+ disableCheckCert: {
33
+ type: 'boolean',
34
+ },
35
+ firstByteTimeout: {
36
+ type: 'number',
37
+ },
38
+ basePath: {
39
+ type: 'string',
40
+ },
41
+ },
42
+ additionalProperties: false,
43
+ required: ['domainOrIp'],
44
+ };
45
+ // config.backends schema
46
+ const backendSchema = {
47
+ $id: '/backendSchema',
48
+ type: 'object',
49
+ patternProperties: {
50
+ '^.*$': {
51
+ oneOf: [{ $ref: domainOrIpSchema.$id }, { $ref: backendObjectSchema.$id }],
52
+ },
53
+ },
54
+ };
55
+ // layer0.config.js schema
56
+ const layer0FileConfigurationSchema = {
57
+ $id: '/layer0FileConfigurationSchema',
58
+ type: 'object',
59
+ properties: {
60
+ name: { type: 'string' },
61
+ team: { type: 'string' },
62
+ prerenderConcurrency: { type: 'number' },
63
+ production: { type: 'boolean' },
64
+ routes: { type: 'string' },
65
+ server: {
66
+ type: 'object',
67
+ required: ['path'],
68
+ properties: { path: { type: 'string' }, export: { type: 'string' } },
69
+ },
70
+ includeFiles: {
71
+ type: 'object',
72
+ },
73
+ sources: {
74
+ type: 'array',
75
+ items: {
76
+ type: 'string',
77
+ },
78
+ },
79
+ backends: {
80
+ $ref: backendSchema.$id,
81
+ },
82
+ includeNodeModules: { type: 'boolean' },
83
+ connector: {
84
+ type: 'string',
85
+ },
86
+ },
87
+ additionalProperties: false,
88
+ required: [],
89
+ };
90
+ /**
91
+ * An object used to validate an layer0 config.
92
+ *
93
+ * Example:
94
+ * ```js
95
+ * Validator.validateLayer0FileConfiguration(config)
96
+ * ```
97
+ */
98
+ class Validator {
99
+ /**
100
+ * Validates `layer0.config.js`. If the config is validated, it is returned; otherwise,
101
+ * an error is thrown.
102
+ * @param config Loaded layer0 configuration
103
+ * @returns The validated config
104
+ */
105
+ static validateLayer0FileConfiguration(config) {
106
+ if (environment_1.isCloud())
107
+ return config;
108
+ // Ajv is really big, so we don't bother validating in the cloud - I've we've gotten this far, let 'er rip, baby!
109
+ const Ajv = nonWebpackRequire_1.default('ajv');
110
+ if (config.connector) {
111
+ try {
112
+ const configSchema = require(`${config.connector}/configSchema`);
113
+ // If a configuration schema exists for the connector, merge into the default schema
114
+ Object.assign(layer0FileConfigurationSchema.properties, configSchema);
115
+ }
116
+ catch {
117
+ // No config schema for connector, nothing to do here
118
+ }
119
+ }
120
+ const ajv = new Ajv({
121
+ allErrors: true,
122
+ schemas: [
123
+ layer0FileConfigurationSchema,
124
+ backendSchema,
125
+ backendObjectSchema,
126
+ domainOrIpSchema,
127
+ ],
128
+ });
129
+ let errors = [];
130
+ // the type cast on the following line is needed to get coverage to 100%. In theory getSchema can return undefined, but it won't since we are creating the schema ourselves.
131
+ const layer0SchemaValidator = ajv.getSchema(layer0FileConfigurationSchema.$id);
132
+ if (config.backends && config.backends.moov != null) {
133
+ // Don't allow providing moov backend in layer0.config.js
134
+ errors.push({
135
+ message: 'is a reserved backend name',
136
+ // eslint-disable-next-line quotes
137
+ dataPath: ".backends['moov']",
138
+ });
139
+ }
140
+ // Don't allow providing static backend in layer0.config.js
141
+ if (config.backends && config.backends[constants_1.BACKENDS.static]) {
142
+ errors.push({
143
+ message: 'is a reserved backend name',
144
+ // eslint-disable-next-line quotes
145
+ dataPath: `.backends.${constants_1.BACKENDS.static}`,
146
+ });
147
+ }
148
+ // Don't allow providing js backend in layer0.config.js
149
+ if (config.backends && config.backends[constants_1.BACKENDS.js]) {
150
+ errors.push({
151
+ message: 'is a reserved backend name',
152
+ // eslint-disable-next-line quotes
153
+ dataPath: `.backends.${constants_1.BACKENDS.js}`,
154
+ });
155
+ }
156
+ // Run schema validation
157
+ if (!layer0SchemaValidator(config) && layer0SchemaValidator.errors) {
158
+ errors = [...errors, ...layer0SchemaValidator.errors];
159
+ }
160
+ // If errors length is not 0 throw error
161
+ if (errors.length) {
162
+ const errorsString = errors
163
+ .map((err, i) => {
164
+ let eString = `${i + 1}) config${err.dataPath}: ${err.message}`;
165
+ // @ts-ignore
166
+ if (err.keyword === 'additionalProperties') {
167
+ // @ts-ignore
168
+ eString += ` '${err.params.additionalProperty}'`;
169
+ }
170
+ return eString;
171
+ })
172
+ .join(os_1.EOL);
173
+ throw new Error(`Layer0 configuration validation failed with errors: ${os_1.EOL}${errorsString}`);
174
+ }
175
+ return config;
176
+ }
177
+ }
178
+ exports.default = Validator;
@@ -0,0 +1,15 @@
1
+ declare const _default: (path: string, params: any) => string;
2
+ /**
3
+ * Binds params to path.
4
+ *
5
+ * Example:
6
+ * ```js
7
+ * bindParamsToPath('/:foo/:bar*', { foo: 'p1', bar: 'p2/p3' })
8
+ * ```
9
+ * Output: `/p1/p2/p3`
10
+ *
11
+ * @param path The path, with param substitutions in braces `{}`.
12
+ * @param params An object with keys matching the params in braces.
13
+ * @returns A string with the params substituted with their values.
14
+ */
15
+ export default _default;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Binds params to path.
5
+ *
6
+ * Example:
7
+ * ```js
8
+ * bindParamsToPath('/:foo/:bar*', { foo: 'p1', bar: 'p2/p3' })
9
+ * ```
10
+ * Output: `/p1/p2/p3`
11
+ *
12
+ * @param path The path, with param substitutions in braces `{}`.
13
+ * @param params An object with keys matching the params in braces.
14
+ * @returns A string with the params substituted with their values.
15
+ */
16
+ exports.default = (path, params) => {
17
+ let p = path;
18
+ // We allow edge interpolation params which begin with `${` but we no longer
19
+ // allow old path options that only begin with `{`.
20
+ if (/(^|[^$]){/.test(path)) {
21
+ throw new Error(`{variable} syntax in the path option is no longer supported, use :variable instead (${path})`);
22
+ }
23
+ for (let paramName in params) {
24
+ let value = params[paramName];
25
+ if (Array.isArray(value)) {
26
+ value = value.join('/');
27
+ }
28
+ // Here we decide *not* to use path-to-regexp `compile()` function
29
+ // as bindParamsToPath is used by other string which are not paths.
30
+ // For example it is used to interpolate setHeader values, which can be a CORS header like
31
+ // 'https://www.domain.com/:path'. The ':' behind https is not a valid path-to-regexp expression.
32
+ // p = p.replace(new RegExp(`:${paramName}(\\?|\\*|\\(.*\\)[?*]?)?`, 'g'), value)
33
+ p = p.replace(new RegExp(`:${paramName}(\\([^)]*\\))?[?*+]?`, 'g'), value === undefined ? '' : value);
34
+ }
35
+ // For optional matchers (:path* and :path?), path may not be defined in params
36
+ // after matching a route but should still be replaced by a blank value
37
+ //
38
+ // ex: pathToRegexp.match('/public/:param?')('/').params returns {}
39
+ // so bindParamsToPath('/public/:param?', {}) should return '/public/'
40
+ //
41
+ p = p.replace(/:\w+(\*|\+|\?)?/, '');
42
+ // We un-escape '?' character that needed to be escape from path-to-regexp expression
43
+ // to *not* be considered as optional parameter matcher
44
+ p = p.replace('\\?', '?');
45
+ p = p
46
+ .replace(/\/+/g, '/') // finally dedupe /'s that result from missing optional parameters
47
+ .replace(/^([^:]+:)\//gi, '$1//'); // but don't replace http://domain with http:/domain
48
+ return p;
49
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Replaces named parameters in the specified path with back references so
3
+ * that the edge can create a path using the matched params with a regex replace in VCL.
4
+ *
5
+ * **Note** this method can return a replacement that, when applied, can result in duplicated '/' characters,
6
+ * which must be collapsed. For example, if the route pattern is /:locale?/products and the url is '/products',
7
+ * where the optional parameter is not provided, url.replace(pattern, replacement) will result in '//products'
8
+ *
9
+ * @param matcher A route-parser route
10
+ * @param path The request path
11
+ * @returns A path with params replaced by back references
12
+ */
13
+ export default function convertParamsToBackReferences(source: any | null | undefined, dest: string): string;
14
+ export declare function getBackReferences(path?: string): {
15
+ [key: string]: string;
16
+ };
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const bindParamsToPath_1 = __importDefault(require("./bindParamsToPath"));
7
+ const path_to_regexp_1 = require("path-to-regexp");
8
+ /**
9
+ * Replaces named parameters in the specified path with back references so
10
+ * that the edge can create a path using the matched params with a regex replace in VCL.
11
+ *
12
+ * **Note** this method can return a replacement that, when applied, can result in duplicated '/' characters,
13
+ * which must be collapsed. For example, if the route pattern is /:locale?/products and the url is '/products',
14
+ * where the optional parameter is not provided, url.replace(pattern, replacement) will result in '//products'
15
+ *
16
+ * @param matcher A route-parser route
17
+ * @param path The request path
18
+ * @returns A path with params replaced by back references
19
+ */
20
+ function convertParamsToBackReferences(source, dest) {
21
+ if (source == null)
22
+ return dest;
23
+ const sourceTokens = getBackReferences(source);
24
+ return bindParamsToPath_1.default(dest, sourceTokens);
25
+ }
26
+ exports.default = convertParamsToBackReferences;
27
+ function getBackReferences(path) {
28
+ if (!path)
29
+ return {};
30
+ // In case path is an absolute path
31
+ const absolutePathMatch = path.match(/https?:\/\/[^/]+(.*)/);
32
+ if (absolutePathMatch) {
33
+ path = `/${absolutePathMatch[1]}`;
34
+ }
35
+ // Back reference counting starts from 1
36
+ let backReferenceCounter = 1;
37
+ const references = {};
38
+ path_to_regexp_1.parse(path).forEach(token => {
39
+ if (typeof token !== 'string') {
40
+ references[token.name] = `\\${backReferenceCounter++}`;
41
+ }
42
+ });
43
+ return references;
44
+ }
45
+ exports.getBackReferences = getBackReferences;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Returns either null or regex even if input is string matcher.
3
+ *
4
+ * @param potentialRegex
5
+ * @private
6
+ */
7
+ export default function convertStringMatcherToRegex(potentialRegex: string | RegExp | null): RegExp;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const toEdgeRegex_1 = __importDefault(require("./toEdgeRegex"));
7
+ /**
8
+ * Returns either null or regex even if input is string matcher.
9
+ *
10
+ * @param potentialRegex
11
+ * @private
12
+ */
13
+ function convertStringMatcherToRegex(potentialRegex) {
14
+ let regex;
15
+ if (potentialRegex === null) {
16
+ regex = null;
17
+ }
18
+ else if (typeof potentialRegex === 'string') {
19
+ regex = toEdgeRegex_1.default(new RegExp(`^${potentialRegex}$`, 'i'));
20
+ }
21
+ else {
22
+ regex = toEdgeRegex_1.default(potentialRegex);
23
+ }
24
+ return regex;
25
+ }
26
+ exports.default = convertStringMatcherToRegex;
@@ -0,0 +1,9 @@
1
+ import Response from '../router/Response';
2
+ /**
3
+ * If needed decodes the body in place from the response content-encoding.
4
+ * Removes the content-encoding header and updates the content-length as the
5
+ * decoded body has no encoding and will have a different length.
6
+ * @param response
7
+ * @returns True if decoding happened or wasn't needed, false otherwise
8
+ */
9
+ export default function decode(response: Response): Boolean;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const zlib_1 = require("zlib");
4
+ const constants_1 = require("../constants");
5
+ /**
6
+ * If needed decodes the body in place from the response content-encoding.
7
+ * Removes the content-encoding header and updates the content-length as the
8
+ * decoded body has no encoding and will have a different length.
9
+ * @param response
10
+ * @returns True if decoding happened or wasn't needed, false otherwise
11
+ */
12
+ function decode(response) {
13
+ var _a;
14
+ const contentEncoding = (_a = response.getHeader(constants_1.HTTP_HEADERS.contentEncoding)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
15
+ // When there is no encoding, then there is nothing to decode.
16
+ if (!contentEncoding) {
17
+ return true;
18
+ }
19
+ switch (contentEncoding) {
20
+ case constants_1.GZIP_ENCODING: {
21
+ if (!Buffer.isBuffer(response.body)) {
22
+ return false;
23
+ }
24
+ response.body = zlib_1.gunzipSync(response.body);
25
+ response.removeHeader(constants_1.HTTP_HEADERS.contentEncoding);
26
+ response.setHeader(constants_1.HTTP_HEADERS.contentLength, Buffer.byteLength(response.body));
27
+ return true;
28
+ }
29
+ case constants_1.BROTLI_ENCODING: {
30
+ if (!Buffer.isBuffer(response.body)) {
31
+ return false;
32
+ }
33
+ response.body = zlib_1.brotliDecompressSync(response.body);
34
+ response.removeHeader(constants_1.HTTP_HEADERS.contentEncoding);
35
+ response.setHeader(constants_1.HTTP_HEADERS.contentLength, Buffer.byteLength(response.body));
36
+ return true;
37
+ }
38
+ default: {
39
+ // We cannot decode the body for unsupported encodings.
40
+ return false;
41
+ }
42
+ }
43
+ }
44
+ exports.default = decode;
@@ -0,0 +1 @@
1
+ export default function esImport(path: string): Promise<any>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* istanbul ignore file */
4
+ // Workaround for importing ES module within CJS module
5
+ // https://github.com/microsoft/TypeScript/issues/43329#issuecomment-1008361973
6
+ async function esImport(path) {
7
+ return Function(`return import("${path}")`)();
8
+ }
9
+ exports.default = esImport;
@@ -0,0 +1 @@
1
+ export { readFileSync, writeFileSync, existsSync } from 'fs';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* istanbul ignore file */
4
+ var fs_1 = require("fs");
5
+ exports.readFileSync = fs_1.readFileSync;
6
+ exports.writeFileSync = fs_1.writeFileSync;
7
+ exports.existsSync = fs_1.existsSync;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * `get` function instead of importing lodash.
3
+ *
4
+ * Note that this function is not entirely equivalent to lodash's but it uses far less space in the bundle.
5
+ */
6
+ export default function get(object: any, path: string): any;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * `get` function instead of importing lodash.
5
+ *
6
+ * Note that this function is not entirely equivalent to lodash's but it uses far less space in the bundle.
7
+ */
8
+ function get(object, path) {
9
+ let value = object;
10
+ const components = path.split('.');
11
+ for (let component of components) {
12
+ if (typeof value === 'undefined') {
13
+ return undefined;
14
+ }
15
+ value = value[component];
16
+ }
17
+ return value;
18
+ }
19
+ exports.default = get;
@@ -0,0 +1,7 @@
1
+ import SemVer from 'semver/classes/semver';
2
+ /**
3
+ * Returns the semver version of the specified package. Returns null if the package cannot be found or does not have a main export
4
+ * @param packageName
5
+ * @returns
6
+ */
7
+ export default function getPackageVersion(packageName: string): SemVer | null;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const parse_1 = __importDefault(require("semver/functions/parse"));
7
+ const resolve_package_path_1 = __importDefault(require("resolve-package-path"));
8
+ /**
9
+ * Returns the semver version of the specified package. Returns null if the package cannot be found or does not have a main export
10
+ * @param packageName
11
+ * @returns
12
+ */
13
+ function getPackageVersion(packageName) {
14
+ // This will return the path to the main module, which will not necessarily be in the root
15
+ // directory of the package. Next.js is one such example.
16
+ const packagePath = resolve_package_path_1.default(packageName, process.cwd());
17
+ return packagePath ? parse_1.default(eval('require')(packagePath).version) : null;
18
+ }
19
+ exports.default = getPackageVersion;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * `has` function instead of importing lodash.
3
+ *
4
+ * Note that this function is not entirely equivalent to lodash's but it uses far less space in the bundle.
5
+ */
6
+ export default function has(object: any, path: string): any;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const get_1 = __importDefault(require("./get"));
7
+ /**
8
+ * `has` function instead of importing lodash.
9
+ *
10
+ * Note that this function is not entirely equivalent to lodash's but it uses far less space in the bundle.
11
+ */
12
+ function has(object, path) {
13
+ return !!get_1.default(object, path);
14
+ }
15
+ exports.default = has;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Identity function instead of importing lodash.
3
+ *
4
+ * @param x Any object
5
+ * @returns The same object
6
+ */
7
+ export default function identity(x: any): any;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Identity function instead of importing lodash.
5
+ *
6
+ * @param x Any object
7
+ * @returns The same object
8
+ */
9
+ function identity(x) {
10
+ return x;
11
+ }
12
+ exports.default = identity;
@@ -0,0 +1 @@
1
+ export { default as nonWebpackRequire } from './nonWebpackRequire';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var nonWebpackRequire_1 = require("./nonWebpackRequire");
4
+ exports.nonWebpackRequire = nonWebpackRequire_1.default;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * `isEmpty` function instead of importing lodash.
3
+ *
4
+ * Note that this function is not entirely equivalent to lodash's but it uses far less space in the bundle.
5
+ */
6
+ export default function isEmpty(value: any): boolean;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * `isEmpty` function instead of importing lodash.
5
+ *
6
+ * Note that this function is not entirely equivalent to lodash's but it uses far less space in the bundle.
7
+ */
8
+ function isEmpty(value) {
9
+ if (!value) {
10
+ return true;
11
+ }
12
+ if (typeof value.length === 'number') {
13
+ return !value.length;
14
+ }
15
+ if (typeof value === 'object' && Object.keys(value).length) {
16
+ return false;
17
+ }
18
+ return true;
19
+ }
20
+ exports.default = isEmpty;
@@ -0,0 +1 @@
1
+ export default function isString(x: any): boolean;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function isString(x) {
4
+ return typeof x === 'string';
5
+ }
6
+ exports.default = isString;
@@ -0,0 +1,5 @@
1
+ declare let logo: string;
2
+ export declare const infoLogLabel: string;
3
+ export declare const warnLogLabel: string;
4
+ export declare const errorLogLabel: string;
5
+ export default logo;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const nonWebpackRequire_1 = __importDefault(require("./nonWebpackRequire"));
7
+ let logo;
8
+ let label;
9
+ let info = 'info', warn = 'warn', error = 'error';
10
+ try {
11
+ // We don't bundle chalk in the user lambda because it is a large module that is not required
12
+ // during runtime. Thus if it cannot be required we default to plain ASCII logo definitions.
13
+ const chalk = nonWebpackRequire_1.default('chalk');
14
+ const c1 = chalk.hex('D355A7');
15
+ label = chalk.grey(`Layer0`);
16
+ logo = chalk.bold(`Layer${c1('0')}`);
17
+ info = chalk.cyan(info);
18
+ warn = chalk.yellow(warn);
19
+ error = chalk.red(error);
20
+ }
21
+ catch (e) {
22
+ logo = label = 'Layer0';
23
+ }
24
+ exports.infoLogLabel = `${label} ${info} -`;
25
+ exports.warnLogLabel = `${label} ${warn} -`;
26
+ exports.errorLogLabel = `${label} ${error} -`;
27
+ exports.default = logo;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Lightweight port of lodash.mapValues
3
+ * https://lodash.com/docs/4.17.15#mapValues
4
+ * @param obj
5
+ * @param callback
6
+ */
7
+ export default function mapValues(obj: any, callback: (value: any, key: string) => any): any;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Lightweight port of lodash.mapValues
5
+ * https://lodash.com/docs/4.17.15#mapValues
6
+ * @param obj
7
+ * @param callback
8
+ */
9
+ function mapValues(obj, callback) {
10
+ const result = {};
11
+ for (let [key, value] of Object.entries(obj)) {
12
+ result[key] = callback(value, key);
13
+ }
14
+ return result;
15
+ }
16
+ exports.default = mapValues;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * `minBy` function instead of importing lodash.
3
+ *
4
+ * Note that this function is not entirely equivalent to lodash's but it uses far less space in the bundle.
5
+ *
6
+ * @param collection Array of items of type T
7
+ */
8
+ export default function minBy<T>(collection: T[] | null | undefined, iteratee: (t: T) => any): T | undefined;