@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,196 @@
1
+ "use strict";
2
+ /*
3
+ * Wrap the stdout/stderr write function to get a JSON output with request metadata
4
+ * when we are running as a lambda
5
+ */
6
+ var __importStar = (this && this.__importStar) || function (mod) {
7
+ if (mod && mod.__esModule) return mod;
8
+ var result = {};
9
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
10
+ result["default"] = mod;
11
+ return result;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ const environment = require('../environment');
15
+ const consoleWrapper_1 = __importStar(require("./consoleWrapper"));
16
+ const layer0OriginalOutputs = {
17
+ stdoutWrite: process.stdout.write,
18
+ stderrWrite: process.stderr.write,
19
+ };
20
+ const PINO_ERROR_LEVEL = 50;
21
+ const PINO_INFO_LEVEL = 30;
22
+ let layer0EnabledCount = 0;
23
+ const JSON_LOG_IDENTIFIER = JSON.stringify(consoleWrapper_1.awsCloudWatchTag).replace('{', '').replace('}', '');
24
+ /**
25
+ * Check if this log is already wrapped into a json payload
26
+ * @param log
27
+ */
28
+ function isLayer0JsonLog(log) {
29
+ return log.indexOf(JSON_LOG_IDENTIFIER) >= 0;
30
+ }
31
+ // Connascence of values with LeDeployer UI: it depends on the values to correctly
32
+ // render the logged request data.
33
+ // Connascence of values with Log Streamr lambda: it depends on these values to
34
+ // correctly apply the filtering,
35
+ const DOWNSTREAM_REQUEST_INFO_LEVEL = 100;
36
+ const DOWNSTREAM_RESPONSE_INFO_LEVEL = 101;
37
+ const UPSTREAM_REQUEST_INFO_LEVEL = 102;
38
+ const UPSTREAM_RESPONSE_INFO_LEVEL = 103;
39
+ const UPSTREAM_RESPONSE_BODY_INFO_LEVEL = 104;
40
+ // Base JSON object for the ongoing request. In AWS lambda all
41
+ // requests are processed serially so we can keep this globally.
42
+ // If we have to make this work for local development, we will
43
+ // have to use "thread local storage".
44
+ let currentBaseJsonObject = {};
45
+ function deepRequestInspectionLogger(instance) {
46
+ // Logs the HTTP request information at the given level, provided that
47
+ // the HTTP request logging is globally enabled.
48
+ // This functionn never throws as it is just related to logging and we don't
49
+ // want a request to ever fail due to logging issues.
50
+ function logHttpRequestInfo(data, level) {
51
+ try {
52
+ // A global that is ultimately set through the UI in the environment version.
53
+ if (process.env.LAYER0_HTTP_REQUEST_LOGGING === '1') {
54
+ layer0OriginalOutputs.stdoutWrite.apply(process.stdout, [
55
+ JSON.stringify({
56
+ level,
57
+ time: Date.now(),
58
+ wi: instance.id,
59
+ ...currentBaseJsonObject,
60
+ data,
61
+ }),
62
+ ]);
63
+ layer0OriginalOutputs.stdoutWrite.apply(process.stdout, ['\n']);
64
+ }
65
+ }
66
+ catch (e) {
67
+ // istanbul ignore next
68
+ console.error(`Error while logging HTTP request info at level ${level}: ${e && e.message}`);
69
+ }
70
+ }
71
+ function logDownstreamRequestInfo(data) {
72
+ return logHttpRequestInfo(data, DOWNSTREAM_REQUEST_INFO_LEVEL);
73
+ }
74
+ function logDownstreamResponseInfo(data) {
75
+ return logHttpRequestInfo(data, DOWNSTREAM_RESPONSE_INFO_LEVEL);
76
+ }
77
+ function logUpstreamRequestInfo(data) {
78
+ return logHttpRequestInfo(data, UPSTREAM_REQUEST_INFO_LEVEL);
79
+ }
80
+ function logUpstreamResponseInfo(data) {
81
+ return logHttpRequestInfo(data, UPSTREAM_RESPONSE_INFO_LEVEL);
82
+ }
83
+ function logUpstreamResponseBodyInfo(data) {
84
+ return logHttpRequestInfo(data, UPSTREAM_RESPONSE_BODY_INFO_LEVEL);
85
+ }
86
+ return {
87
+ logDownstreamRequestInfo,
88
+ logDownstreamResponseInfo,
89
+ logUpstreamRequestInfo,
90
+ logUpstreamResponseInfo,
91
+ logUpstreamResponseBodyInfo,
92
+ };
93
+ }
94
+ exports.deepRequestInspectionLogger = deepRequestInspectionLogger;
95
+ /**
96
+ * Overrides the given stream #write method so that every chunk
97
+ * of text sent to that function is wrapped into a JSON object
98
+ * as a 'msg' attribute.
99
+ * The rest of the JSON object is defined by baseJsonObject
100
+ *
101
+ * @param stream Stream to override
102
+ * @param baseJsonObject JSON object into which we inject the stream message
103
+ */
104
+ function jsonifyWriteStream(stream, baseJsonObject) {
105
+ const originalWrite = stream.write;
106
+ // @ts-ignore
107
+ stream.write = function (chunk, ...otherArgs) {
108
+ // Converts Buffer or Uint8Array to string
109
+ let convertedChunk;
110
+ if (typeof chunk === 'object') {
111
+ convertedChunk = Buffer.from(chunk).toString();
112
+ }
113
+ else {
114
+ convertedChunk = chunk;
115
+ }
116
+ const dynamicObject = {
117
+ time: Date.now(),
118
+ };
119
+ // Let JSON pass through without wrapping it again.
120
+ if (chunk && !isLayer0JsonLog(convertedChunk)) {
121
+ chunk =
122
+ JSON.stringify({
123
+ ...baseJsonObject,
124
+ ...dynamicObject,
125
+ msg: convertedChunk,
126
+ }) + '\n';
127
+ }
128
+ // @ts-ignore
129
+ return originalWrite.apply(stream, [chunk, ...otherArgs]);
130
+ };
131
+ }
132
+ const stdStreamsWrapper = {
133
+ /**
134
+ * Wraps console.xxx methods AND standard streams into a JSON payload that will
135
+ * be sent back to the final user in the log streaming interface.
136
+ *
137
+ * Notes:
138
+ * - We have to wrap standard streams because some logging libraries (like 'consola')
139
+ * writes to those directly without going through console.xxx
140
+ * - We have to wrap console.xxx methods too, as they don't seem to be bound to
141
+ * standard streams in AWS Lambda Environment. That wrapper (using pino) streams
142
+ * to process.stdout, leading to the point below.
143
+ * - Both notes above would result in a double json encapsulation when logging via
144
+ * console.xxx methods. We prevent that in our standard stream wrapper by detecting
145
+ * a json string that coming from pino logger.
146
+ */
147
+ enable: ({ clientIp, requestId, wi, } = {}) => {
148
+ if (!environment.isCloud()) {
149
+ return;
150
+ }
151
+ if (layer0EnabledCount === 0) {
152
+ let basePayload = consoleWrapper_1.awsCloudWatchTag;
153
+ if (clientIp) {
154
+ basePayload = {
155
+ ...basePayload,
156
+ clientIp,
157
+ };
158
+ }
159
+ if (requestId) {
160
+ basePayload = {
161
+ ...basePayload,
162
+ requestId,
163
+ };
164
+ }
165
+ if (wi) {
166
+ basePayload = {
167
+ ...basePayload,
168
+ wi,
169
+ };
170
+ }
171
+ // Since lambda processes the requests serially, we can rely on a global.
172
+ currentBaseJsonObject = basePayload;
173
+ // Wrap standard streams as some
174
+ // As we don't have the same degree of "level" details as console methods, we
175
+ // assign INFO for stdout and ERROR for stderr
176
+ jsonifyWriteStream(process.stdout, { level: PINO_INFO_LEVEL, ...basePayload });
177
+ jsonifyWriteStream(process.stderr, { level: PINO_ERROR_LEVEL, ...basePayload });
178
+ // Wrap console.xxx methods
179
+ consoleWrapper_1.default.enable({ clientIp, requestId, wi });
180
+ }
181
+ layer0EnabledCount++;
182
+ },
183
+ disable: () => {
184
+ if (!environment.isCloud()) {
185
+ return;
186
+ }
187
+ layer0EnabledCount--;
188
+ if (layer0EnabledCount === 0) {
189
+ process.stdout.write = layer0OriginalOutputs.stdoutWrite;
190
+ process.stderr.write = layer0OriginalOutputs.stderrWrite;
191
+ currentBaseJsonObject = {};
192
+ consoleWrapper_1.default.disable();
193
+ }
194
+ },
195
+ };
196
+ exports.default = stdStreamsWrapper;
@@ -0,0 +1,10 @@
1
+ /// <reference types="node" />
2
+ import { RequestListener } from 'http';
3
+ import JSBackend from './JSBackend';
4
+ /**
5
+ * Normalizes the provided server as a JSBackend by returning it if it's already an instance of
6
+ * JSBackend, or wrapping it in RequestListenerJSBackend if it's a RequestListener
7
+ * @param server
8
+ * @param port
9
+ */
10
+ export default function toJSBackend(server: RequestListener | typeof JSBackend, port: number): JSBackend;
@@ -0,0 +1,23 @@
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 JSBackend_1 = __importDefault(require("./JSBackend"));
7
+ const RequestListenerJSBackend_1 = __importDefault(require("./RequestListenerJSBackend"));
8
+ /**
9
+ * Normalizes the provided server as a JSBackend by returning it if it's already an instance of
10
+ * JSBackend, or wrapping it in RequestListenerJSBackend if it's a RequestListener
11
+ * @param server
12
+ * @param port
13
+ */
14
+ function toJSBackend(server, port) {
15
+ if (JSBackend_1.default.isSubclass(server)) {
16
+ // @ts-ignore
17
+ return new server(port);
18
+ }
19
+ else {
20
+ return new RequestListenerJSBackend_1.default(port, server);
21
+ }
22
+ }
23
+ exports.default = toJSBackend;
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Evan Wallace
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ # esbuild
2
+
3
+ This is a JavaScript bundler and minifier. See https://github.com/evanw/esbuild and the [JavaScript API documentation](https://esbuild.github.io/api/) for details.
@@ -0,0 +1,223 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+
26
+ // lib/npm/node-platform.ts
27
+ var fs = require("fs");
28
+ var os = require("os");
29
+ var path = require("path");
30
+ var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH;
31
+ var isValidBinaryPath = (x) => !!x && x !== "/usr/bin/esbuild";
32
+ var packageDarwin_arm64 = "@esbuild/darwin-arm64";
33
+ var packageDarwin_x64 = "@esbuild/darwin-x64";
34
+ var knownWindowsPackages = {
35
+ "win32 arm64 LE": "@esbuild/win32-arm64",
36
+ "win32 ia32 LE": "@esbuild/win32-ia32",
37
+ "win32 x64 LE": "@esbuild/win32-x64"
38
+ };
39
+ var knownUnixlikePackages = {
40
+ "aix ppc64 BE": "@esbuild/aix-ppc64",
41
+ "android arm64 LE": "@esbuild/android-arm64",
42
+ "darwin arm64 LE": "@esbuild/darwin-arm64",
43
+ "darwin x64 LE": "@esbuild/darwin-x64",
44
+ "freebsd arm64 LE": "@esbuild/freebsd-arm64",
45
+ "freebsd x64 LE": "@esbuild/freebsd-x64",
46
+ "linux arm LE": "@esbuild/linux-arm",
47
+ "linux arm64 LE": "@esbuild/linux-arm64",
48
+ "linux ia32 LE": "@esbuild/linux-ia32",
49
+ "linux mips64el LE": "@esbuild/linux-mips64el",
50
+ "linux ppc64 LE": "@esbuild/linux-ppc64",
51
+ "linux riscv64 LE": "@esbuild/linux-riscv64",
52
+ "linux s390x BE": "@esbuild/linux-s390x",
53
+ "linux x64 LE": "@esbuild/linux-x64",
54
+ "linux loong64 LE": "@esbuild/linux-loong64",
55
+ "netbsd arm64 LE": "@esbuild/netbsd-arm64",
56
+ "netbsd x64 LE": "@esbuild/netbsd-x64",
57
+ "openbsd arm64 LE": "@esbuild/openbsd-arm64",
58
+ "openbsd x64 LE": "@esbuild/openbsd-x64",
59
+ "openharmony arm64 LE": "@ohos-ports/esbuild-openharmony-arm64",
60
+ "sunos x64 LE": "@esbuild/sunos-x64"
61
+ };
62
+ var knownWebAssemblyFallbackPackages = {
63
+ "android arm LE": "@esbuild/android-arm",
64
+ "android x64 LE": "@esbuild/android-x64"
65
+ };
66
+ function pkgAndSubpathForCurrentPlatform() {
67
+ let pkg;
68
+ let subpath;
69
+ let isWASM2 = false;
70
+ let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
71
+ if (platformKey in knownWindowsPackages) {
72
+ pkg = knownWindowsPackages[platformKey];
73
+ subpath = "esbuild.exe";
74
+ } else if (platformKey in knownUnixlikePackages) {
75
+ pkg = knownUnixlikePackages[platformKey];
76
+ subpath = "bin/esbuild";
77
+ } else if (platformKey in knownWebAssemblyFallbackPackages) {
78
+ pkg = knownWebAssemblyFallbackPackages[platformKey];
79
+ subpath = "bin/esbuild";
80
+ isWASM2 = true;
81
+ } else {
82
+ throw new Error(`Unsupported platform: ${platformKey}`);
83
+ }
84
+ return { pkg, subpath, isWASM: isWASM2 };
85
+ }
86
+ function pkgForSomeOtherPlatform() {
87
+ const libMainJS = __filename; // renamed port: resolve own package via __filename
88
+ const nodeModulesDirectory = path.dirname(path.dirname(path.dirname(libMainJS)));
89
+ if (path.basename(nodeModulesDirectory) === "node_modules") {
90
+ for (const unixKey in knownUnixlikePackages) {
91
+ try {
92
+ const pkg = knownUnixlikePackages[unixKey];
93
+ if (fs.existsSync(path.join(nodeModulesDirectory, pkg))) return pkg;
94
+ } catch {
95
+ }
96
+ }
97
+ for (const windowsKey in knownWindowsPackages) {
98
+ try {
99
+ const pkg = knownWindowsPackages[windowsKey];
100
+ if (fs.existsSync(path.join(nodeModulesDirectory, pkg))) return pkg;
101
+ } catch {
102
+ }
103
+ }
104
+ }
105
+ return null;
106
+ }
107
+ function downloadedBinPath(pkg, subpath) {
108
+ const esbuildLibDir = __dirname; // renamed port: own lib dir
109
+ return path.join(esbuildLibDir, `downloaded-${pkg.replace("/", "-")}-${path.basename(subpath)}`);
110
+ }
111
+ function generateBinPath() {
112
+ if (isValidBinaryPath(ESBUILD_BINARY_PATH)) {
113
+ if (!fs.existsSync(ESBUILD_BINARY_PATH)) {
114
+ console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${ESBUILD_BINARY_PATH}`);
115
+ } else {
116
+ return { binPath: ESBUILD_BINARY_PATH, isWASM: false };
117
+ }
118
+ }
119
+ const { pkg, subpath, isWASM: isWASM2 } = pkgAndSubpathForCurrentPlatform();
120
+ let binPath2;
121
+ try {
122
+ binPath2 = require.resolve(`${pkg}/${subpath}`);
123
+ } catch (e) {
124
+ binPath2 = downloadedBinPath(pkg, subpath);
125
+ if (!fs.existsSync(binPath2)) {
126
+ try {
127
+ require.resolve(pkg);
128
+ } catch {
129
+ const otherPkg = pkgForSomeOtherPlatform();
130
+ if (otherPkg) {
131
+ let suggestions = `
132
+ Specifically the "${otherPkg}" package is present but this platform
133
+ needs the "${pkg}" package instead. People often get into this
134
+ situation by installing esbuild on Windows or macOS and copying "node_modules"
135
+ into a Docker image that runs Linux, or by copying "node_modules" between
136
+ Windows and WSL environments.
137
+
138
+ If you are installing with npm, you can try not copying the "node_modules"
139
+ directory when you copy the files over, and running "npm ci" or "npm install"
140
+ on the destination platform after the copy. Or you could consider using yarn
141
+ instead of npm which has built-in support for installing a package on multiple
142
+ platforms simultaneously.
143
+
144
+ If you are installing with yarn, you can try listing both this platform and the
145
+ other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
146
+ feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
147
+ Keep in mind that this means multiple copies of esbuild will be present.
148
+ `;
149
+ if (pkg === packageDarwin_x64 && otherPkg === packageDarwin_arm64 || pkg === packageDarwin_arm64 && otherPkg === packageDarwin_x64) {
150
+ suggestions = `
151
+ Specifically the "${otherPkg}" package is present but this platform
152
+ needs the "${pkg}" package instead. People often get into this
153
+ situation by installing esbuild with npm running inside of Rosetta 2 and then
154
+ trying to use it with node running outside of Rosetta 2, or vice versa (Rosetta
155
+ 2 is Apple's on-the-fly x86_64-to-arm64 translation service).
156
+
157
+ If you are installing with npm, you can try ensuring that both npm and node are
158
+ not running under Rosetta 2 and then reinstalling esbuild. This likely involves
159
+ changing how you installed npm and/or node. For example, installing node with
160
+ the universal installer here should work: https://nodejs.org/en/download/. Or
161
+ you could consider using yarn instead of npm which has built-in support for
162
+ installing a package on multiple platforms simultaneously.
163
+
164
+ If you are installing with yarn, you can try listing both "arm64" and "x64"
165
+ in your ".yarnrc.yml" file using the "supportedArchitectures" feature:
166
+ https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
167
+ Keep in mind that this means multiple copies of esbuild will be present.
168
+ `;
169
+ }
170
+ throw new Error(`
171
+ You installed esbuild for another platform than the one you're currently using.
172
+ This won't work because esbuild is written with native code and needs to
173
+ install a platform-specific binary executable.
174
+ ${suggestions}
175
+ Another alternative is to use the "esbuild-wasm" package instead, which works
176
+ the same way on all platforms. But it comes with a heavy performance cost and
177
+ can sometimes be 10x slower than the "esbuild" package, so you may also not
178
+ want to do that.
179
+ `);
180
+ }
181
+ throw new Error(`The package "${pkg}" could not be found, and is needed by esbuild.
182
+
183
+ If you are installing esbuild with npm, make sure that you don't specify the
184
+ "--no-optional" or "--omit=optional" flags. The "optionalDependencies" feature
185
+ of "package.json" is used by esbuild to install the correct binary executable
186
+ for your current platform.`);
187
+ }
188
+ throw e;
189
+ }
190
+ }
191
+ if (/\.zip\//.test(binPath2)) {
192
+ let pnpapi;
193
+ try {
194
+ pnpapi = require("pnpapi");
195
+ } catch (e) {
196
+ }
197
+ if (pnpapi) {
198
+ const root = pnpapi.getPackageInformation(pnpapi.topLevel).packageLocation;
199
+ const binTargetPath = path.join(
200
+ root,
201
+ "node_modules",
202
+ ".cache",
203
+ "esbuild",
204
+ `pnpapi-${pkg.replace("/", "-")}-${"0.28.1"}-${path.basename(subpath)}`
205
+ );
206
+ if (!fs.existsSync(binTargetPath)) {
207
+ fs.mkdirSync(path.dirname(binTargetPath), { recursive: true });
208
+ fs.copyFileSync(binPath2, binTargetPath);
209
+ fs.chmodSync(binTargetPath, 493);
210
+ }
211
+ return { binPath: binTargetPath, isWASM: isWASM2 };
212
+ }
213
+ }
214
+ return { binPath: binPath2, isWASM: isWASM2 };
215
+ }
216
+
217
+ // lib/npm/node-shim.ts
218
+ var { binPath, isWASM } = generateBinPath();
219
+ if (isWASM) {
220
+ require("child_process").execFileSync("node", [binPath].concat(process.argv.slice(2)), { stdio: "inherit" });
221
+ } else {
222
+ require("child_process").execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" });
223
+ }