@bleedingdev/modern-js-plugin-bff 3.5.0-ultramodern.4 → 3.5.0-ultramodern.41

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 (317) hide show
  1. package/dist/cjs/cli/compress.js +52 -0
  2. package/dist/cjs/cli/generator.js +149 -0
  3. package/dist/cjs/cli/prefix.js +50 -0
  4. package/dist/cjs/cli/watch.js +51 -0
  5. package/dist/cjs/cli.js +11 -130
  6. package/dist/cjs/runtime/data-platform/batch/queue.js +284 -0
  7. package/dist/cjs/runtime/data-platform/batch/request.js +98 -0
  8. package/dist/cjs/runtime/data-platform/batch/response.js +64 -0
  9. package/dist/cjs/runtime/data-platform/batch/telemetry.js +67 -0
  10. package/dist/cjs/runtime/data-platform/batch/url.js +69 -0
  11. package/dist/cjs/runtime/data-platform/batch-transport.js +59 -0
  12. package/dist/cjs/runtime/data-platform/codec.js +155 -0
  13. package/dist/cjs/runtime/data-platform/index.js +30 -633
  14. package/dist/cjs/runtime/data-platform/invalidation.js +61 -0
  15. package/dist/cjs/runtime/data-platform/trace.js +73 -0
  16. package/dist/cjs/runtime/data-platform/types.js +48 -0
  17. package/dist/cjs/runtime/data-platform/validation.js +178 -0
  18. package/dist/cjs/runtime/effect/adapter/constants.js +44 -0
  19. package/dist/cjs/runtime/effect/adapter/cross-project-policy.js +61 -0
  20. package/dist/cjs/runtime/effect/adapter/entry.js +77 -0
  21. package/dist/cjs/runtime/effect/adapter/error-response.js +79 -0
  22. package/dist/cjs/runtime/effect/adapter/handler.js +53 -0
  23. package/dist/cjs/runtime/effect/adapter.js +20 -154
  24. package/dist/cjs/runtime/effect/backend-federation/entry.js +99 -0
  25. package/dist/cjs/runtime/effect/backend-federation/load.js +57 -0
  26. package/dist/cjs/runtime/effect/backend-federation/plugin.js +53 -0
  27. package/dist/cjs/runtime/effect/backend-federation/remotes.js +50 -0
  28. package/dist/cjs/runtime/effect/backend-federation/runtime.js +64 -0
  29. package/dist/cjs/runtime/effect/backend-federation/types.js +18 -0
  30. package/dist/cjs/runtime/effect/backend-federation/utils.js +48 -0
  31. package/dist/cjs/runtime/effect/backend-federation-manifest/errors.js +83 -0
  32. package/dist/cjs/runtime/effect/backend-federation-manifest/index.js +55 -0
  33. package/dist/cjs/runtime/effect/backend-federation-manifest/load.js +74 -0
  34. package/dist/cjs/runtime/effect/backend-federation-manifest/metadata.js +101 -0
  35. package/dist/cjs/runtime/effect/backend-federation-manifest/reference.js +117 -0
  36. package/dist/cjs/runtime/effect/backend-federation-manifest/remote.js +68 -0
  37. package/dist/cjs/runtime/effect/backend-federation-manifest/types.js +18 -0
  38. package/dist/cjs/runtime/effect/backend-federation-manifest/validation.js +108 -0
  39. package/dist/cjs/runtime/effect/backend-federation-manifest.js +62 -0
  40. package/dist/cjs/runtime/effect/backend-federation.js +61 -0
  41. package/dist/cjs/runtime/effect/dispatch.js +101 -0
  42. package/dist/cjs/runtime/effect/edge.js +58 -69
  43. package/dist/cjs/runtime/effect/endpoint-contracts.js +7 -21
  44. package/dist/cjs/runtime/effect/entry-shape.js +84 -0
  45. package/dist/cjs/runtime/effect/handler/batch-handler.js +161 -0
  46. package/dist/cjs/runtime/effect/handler/batch.js +195 -0
  47. package/dist/cjs/runtime/effect/handler/definition.js +101 -0
  48. package/dist/cjs/runtime/effect/handler/envelope.js +104 -0
  49. package/dist/cjs/runtime/effect/handler/http.js +96 -0
  50. package/dist/cjs/runtime/effect/handler/openapi.js +57 -0
  51. package/dist/cjs/runtime/effect/handler/routing.js +100 -0
  52. package/dist/cjs/runtime/effect/handler/rpc.js +63 -0
  53. package/dist/cjs/runtime/effect/handler/types.js +43 -0
  54. package/dist/cjs/runtime/effect/handler.js +37 -529
  55. package/dist/cjs/runtime/effect/index.js +91 -15
  56. package/dist/cjs/runtime/effect/module.js +23 -80
  57. package/dist/cjs/runtime/effect/rpcSerialization.js +54 -0
  58. package/dist/cjs/runtime/effect-client/batch.js +73 -0
  59. package/dist/cjs/runtime/effect-client/envelope.js +145 -0
  60. package/dist/cjs/runtime/effect-client/guards.js +44 -0
  61. package/dist/cjs/runtime/effect-client/index.js +6 -16
  62. package/dist/cjs/runtime/effect-client/request-context.js +64 -0
  63. package/dist/cjs/runtime/effect-client/request.js +66 -0
  64. package/dist/cjs/runtime/effect-client/runtime.js +12 -178
  65. package/dist/cjs/runtime/effect-client/types.js +18 -0
  66. package/dist/cjs/runtime/safe-failure.js +2 -1
  67. package/dist/cjs/utils/client-generator/files.js +152 -0
  68. package/dist/cjs/utils/client-generator/generate.js +138 -0
  69. package/dist/cjs/utils/client-generator/index.js +83 -0
  70. package/dist/cjs/utils/client-generator/package-json.js +132 -0
  71. package/dist/cjs/utils/client-generator/write-package.js +125 -0
  72. package/dist/cjs/utils/clientGenerator.js +26 -303
  73. package/dist/cjs/utils/effect-client-generator/generator.js +64 -0
  74. package/dist/cjs/utils/effect-client-generator/index.js +51 -0
  75. package/dist/cjs/utils/effect-client-generator/paths.js +73 -0
  76. package/dist/cjs/utils/effect-client-generator/rendering.js +231 -0
  77. package/dist/cjs/utils/effect-client-generator/runtime.js +84 -0
  78. package/dist/cjs/utils/effect-client-generator/types.js +18 -0
  79. package/dist/cjs/utils/effectClientGenerator.js +5 -262
  80. package/dist/esm/cli/compress.mjs +14 -0
  81. package/dist/esm/cli/generator.mjs +98 -0
  82. package/dist/esm/cli/prefix.mjs +9 -0
  83. package/dist/esm/cli/watch.mjs +13 -0
  84. package/dist/esm/cli.mjs +7 -121
  85. package/dist/esm/runtime/data-platform/batch/queue.mjs +246 -0
  86. package/dist/esm/runtime/data-platform/batch/request.mjs +45 -0
  87. package/dist/esm/runtime/data-platform/batch/response.mjs +23 -0
  88. package/dist/esm/runtime/data-platform/batch/telemetry.mjs +23 -0
  89. package/dist/esm/runtime/data-platform/batch/url.mjs +25 -0
  90. package/dist/esm/runtime/data-platform/batch-transport.mjs +12 -0
  91. package/dist/esm/runtime/data-platform/codec.mjs +90 -0
  92. package/dist/esm/runtime/data-platform/index.mjs +6 -610
  93. package/dist/esm/runtime/data-platform/invalidation.mjs +20 -0
  94. package/dist/esm/runtime/data-platform/trace.mjs +29 -0
  95. package/dist/esm/runtime/data-platform/types.mjs +4 -0
  96. package/dist/esm/runtime/data-platform/validation.mjs +128 -0
  97. package/dist/esm/runtime/effect/adapter/constants.mjs +6 -0
  98. package/dist/esm/runtime/effect/adapter/cross-project-policy.mjs +23 -0
  99. package/dist/esm/runtime/effect/adapter/entry.mjs +29 -0
  100. package/dist/esm/runtime/effect/adapter/error-response.mjs +41 -0
  101. package/dist/esm/runtime/effect/adapter/handler.mjs +15 -0
  102. package/dist/esm/runtime/effect/adapter.mjs +21 -145
  103. package/dist/esm/runtime/effect/backend-federation/entry.mjs +61 -0
  104. package/dist/esm/runtime/effect/backend-federation/load.mjs +19 -0
  105. package/dist/esm/runtime/effect/backend-federation/plugin.mjs +15 -0
  106. package/dist/esm/runtime/effect/backend-federation/remotes.mjs +12 -0
  107. package/dist/esm/runtime/effect/backend-federation/runtime.mjs +26 -0
  108. package/dist/esm/runtime/effect/backend-federation/types.mjs +0 -0
  109. package/dist/esm/runtime/effect/backend-federation/utils.mjs +7 -0
  110. package/dist/esm/runtime/effect/backend-federation-manifest/errors.mjs +32 -0
  111. package/dist/esm/runtime/effect/backend-federation-manifest/index.mjs +4 -0
  112. package/dist/esm/runtime/effect/backend-federation-manifest/load.mjs +36 -0
  113. package/dist/esm/runtime/effect/backend-federation-manifest/metadata.mjs +42 -0
  114. package/dist/esm/runtime/effect/backend-federation-manifest/reference.mjs +76 -0
  115. package/dist/esm/runtime/effect/backend-federation-manifest/remote.mjs +30 -0
  116. package/dist/esm/runtime/effect/backend-federation-manifest/types.mjs +0 -0
  117. package/dist/esm/runtime/effect/backend-federation-manifest/validation.mjs +64 -0
  118. package/dist/esm/runtime/effect/backend-federation-manifest.mjs +1 -0
  119. package/dist/esm/runtime/effect/backend-federation.mjs +4 -0
  120. package/dist/esm/runtime/effect/dispatch.mjs +63 -0
  121. package/dist/esm/runtime/effect/edge.mjs +17 -63
  122. package/dist/esm/runtime/effect/endpoint-contracts.mjs +8 -13
  123. package/dist/esm/runtime/effect/entry-shape.mjs +36 -0
  124. package/dist/esm/runtime/effect/handler/batch-handler.mjs +123 -0
  125. package/dist/esm/runtime/effect/handler/batch.mjs +124 -0
  126. package/dist/esm/runtime/effect/handler/definition.mjs +60 -0
  127. package/dist/esm/runtime/effect/handler/envelope.mjs +63 -0
  128. package/dist/esm/runtime/effect/handler/http.mjs +58 -0
  129. package/dist/esm/runtime/effect/handler/openapi.mjs +19 -0
  130. package/dist/esm/runtime/effect/handler/routing.mjs +50 -0
  131. package/dist/esm/runtime/effect/handler/rpc.mjs +22 -0
  132. package/dist/esm/runtime/effect/handler/types.mjs +5 -0
  133. package/dist/esm/runtime/effect/handler.mjs +11 -506
  134. package/dist/esm/runtime/effect/index.mjs +5 -2
  135. package/dist/esm/runtime/effect/module.mjs +25 -82
  136. package/dist/esm/runtime/effect/rpcSerialization.mjs +16 -0
  137. package/dist/esm/runtime/effect-client/batch.mjs +35 -0
  138. package/dist/esm/runtime/effect-client/envelope.mjs +104 -0
  139. package/dist/esm/runtime/effect-client/guards.mjs +3 -0
  140. package/dist/esm/runtime/effect-client/index.mjs +27 -37
  141. package/dist/esm/runtime/effect-client/request-context.mjs +23 -0
  142. package/dist/esm/runtime/effect-client/request.mjs +28 -0
  143. package/dist/esm/runtime/effect-client/runtime.mjs +12 -178
  144. package/dist/esm/runtime/effect-client/types.mjs +0 -0
  145. package/dist/esm/runtime/safe-failure.mjs +2 -1
  146. package/dist/esm/utils/client-generator/files.mjs +68 -0
  147. package/dist/esm/utils/client-generator/generate.mjs +88 -0
  148. package/dist/esm/utils/client-generator/index.mjs +4 -0
  149. package/dist/esm/utils/client-generator/package-json.mjs +78 -0
  150. package/dist/esm/utils/client-generator/write-package.mjs +74 -0
  151. package/dist/esm/utils/clientGenerator.mjs +2 -293
  152. package/dist/esm/utils/effect-client-generator/generator.mjs +23 -0
  153. package/dist/esm/utils/effect-client-generator/index.mjs +3 -0
  154. package/dist/esm/utils/effect-client-generator/paths.mjs +25 -0
  155. package/dist/esm/utils/effect-client-generator/rendering.mjs +180 -0
  156. package/dist/esm/utils/effect-client-generator/runtime.mjs +33 -0
  157. package/dist/esm/utils/effect-client-generator/types.mjs +0 -0
  158. package/dist/esm/utils/effectClientGenerator.mjs +1 -249
  159. package/dist/esm-node/cli/compress.mjs +15 -0
  160. package/dist/esm-node/cli/generator.mjs +99 -0
  161. package/dist/esm-node/cli/prefix.mjs +10 -0
  162. package/dist/esm-node/cli/watch.mjs +14 -0
  163. package/dist/esm-node/cli.mjs +7 -121
  164. package/dist/esm-node/runtime/data-platform/batch/queue.mjs +247 -0
  165. package/dist/esm-node/runtime/data-platform/batch/request.mjs +46 -0
  166. package/dist/esm-node/runtime/data-platform/batch/response.mjs +24 -0
  167. package/dist/esm-node/runtime/data-platform/batch/telemetry.mjs +24 -0
  168. package/dist/esm-node/runtime/data-platform/batch/url.mjs +26 -0
  169. package/dist/esm-node/runtime/data-platform/batch-transport.mjs +13 -0
  170. package/dist/esm-node/runtime/data-platform/codec.mjs +91 -0
  171. package/dist/esm-node/runtime/data-platform/index.mjs +6 -610
  172. package/dist/esm-node/runtime/data-platform/invalidation.mjs +21 -0
  173. package/dist/esm-node/runtime/data-platform/trace.mjs +30 -0
  174. package/dist/esm-node/runtime/data-platform/types.mjs +5 -0
  175. package/dist/esm-node/runtime/data-platform/validation.mjs +129 -0
  176. package/dist/esm-node/runtime/effect/adapter/constants.mjs +7 -0
  177. package/dist/esm-node/runtime/effect/adapter/cross-project-policy.mjs +24 -0
  178. package/dist/esm-node/runtime/effect/adapter/entry.mjs +30 -0
  179. package/dist/esm-node/runtime/effect/adapter/error-response.mjs +42 -0
  180. package/dist/esm-node/runtime/effect/adapter/handler.mjs +16 -0
  181. package/dist/esm-node/runtime/effect/adapter.mjs +21 -145
  182. package/dist/esm-node/runtime/effect/backend-federation/entry.mjs +62 -0
  183. package/dist/esm-node/runtime/effect/backend-federation/load.mjs +20 -0
  184. package/dist/esm-node/runtime/effect/backend-federation/plugin.mjs +16 -0
  185. package/dist/esm-node/runtime/effect/backend-federation/remotes.mjs +13 -0
  186. package/dist/esm-node/runtime/effect/backend-federation/runtime.mjs +27 -0
  187. package/dist/esm-node/runtime/effect/backend-federation/types.mjs +1 -0
  188. package/dist/esm-node/runtime/effect/backend-federation/utils.mjs +8 -0
  189. package/dist/esm-node/runtime/effect/backend-federation-manifest/errors.mjs +33 -0
  190. package/dist/esm-node/runtime/effect/backend-federation-manifest/index.mjs +5 -0
  191. package/dist/esm-node/runtime/effect/backend-federation-manifest/load.mjs +37 -0
  192. package/dist/esm-node/runtime/effect/backend-federation-manifest/metadata.mjs +43 -0
  193. package/dist/esm-node/runtime/effect/backend-federation-manifest/reference.mjs +77 -0
  194. package/dist/esm-node/runtime/effect/backend-federation-manifest/remote.mjs +31 -0
  195. package/dist/esm-node/runtime/effect/backend-federation-manifest/types.mjs +1 -0
  196. package/dist/esm-node/runtime/effect/backend-federation-manifest/validation.mjs +65 -0
  197. package/dist/esm-node/runtime/effect/backend-federation-manifest.mjs +2 -0
  198. package/dist/esm-node/runtime/effect/backend-federation.mjs +5 -0
  199. package/dist/esm-node/runtime/effect/dispatch.mjs +64 -0
  200. package/dist/esm-node/runtime/effect/edge.mjs +17 -63
  201. package/dist/esm-node/runtime/effect/endpoint-contracts.mjs +8 -13
  202. package/dist/esm-node/runtime/effect/entry-shape.mjs +37 -0
  203. package/dist/esm-node/runtime/effect/handler/batch-handler.mjs +124 -0
  204. package/dist/esm-node/runtime/effect/handler/batch.mjs +125 -0
  205. package/dist/esm-node/runtime/effect/handler/definition.mjs +61 -0
  206. package/dist/esm-node/runtime/effect/handler/envelope.mjs +64 -0
  207. package/dist/esm-node/runtime/effect/handler/http.mjs +59 -0
  208. package/dist/esm-node/runtime/effect/handler/openapi.mjs +20 -0
  209. package/dist/esm-node/runtime/effect/handler/routing.mjs +51 -0
  210. package/dist/esm-node/runtime/effect/handler/rpc.mjs +23 -0
  211. package/dist/esm-node/runtime/effect/handler/types.mjs +6 -0
  212. package/dist/esm-node/runtime/effect/handler.mjs +11 -506
  213. package/dist/esm-node/runtime/effect/index.mjs +5 -2
  214. package/dist/esm-node/runtime/effect/module.mjs +25 -82
  215. package/dist/esm-node/runtime/effect/rpcSerialization.mjs +17 -0
  216. package/dist/esm-node/runtime/effect-client/batch.mjs +36 -0
  217. package/dist/esm-node/runtime/effect-client/envelope.mjs +105 -0
  218. package/dist/esm-node/runtime/effect-client/guards.mjs +4 -0
  219. package/dist/esm-node/runtime/effect-client/index.mjs +27 -37
  220. package/dist/esm-node/runtime/effect-client/request-context.mjs +24 -0
  221. package/dist/esm-node/runtime/effect-client/request.mjs +29 -0
  222. package/dist/esm-node/runtime/effect-client/runtime.mjs +12 -178
  223. package/dist/esm-node/runtime/effect-client/types.mjs +1 -0
  224. package/dist/esm-node/runtime/safe-failure.mjs +2 -1
  225. package/dist/esm-node/utils/client-generator/files.mjs +69 -0
  226. package/dist/esm-node/utils/client-generator/generate.mjs +89 -0
  227. package/dist/esm-node/utils/client-generator/index.mjs +5 -0
  228. package/dist/esm-node/utils/client-generator/package-json.mjs +79 -0
  229. package/dist/esm-node/utils/client-generator/write-package.mjs +75 -0
  230. package/dist/esm-node/utils/clientGenerator.mjs +2 -293
  231. package/dist/esm-node/utils/effect-client-generator/generator.mjs +24 -0
  232. package/dist/esm-node/utils/effect-client-generator/index.mjs +4 -0
  233. package/dist/esm-node/utils/effect-client-generator/paths.mjs +26 -0
  234. package/dist/esm-node/utils/effect-client-generator/rendering.mjs +181 -0
  235. package/dist/esm-node/utils/effect-client-generator/runtime.mjs +35 -0
  236. package/dist/esm-node/utils/effect-client-generator/types.mjs +1 -0
  237. package/dist/esm-node/utils/effectClientGenerator.mjs +2 -251
  238. package/dist/types/cli/compress.d.ts +2 -0
  239. package/dist/types/cli/generator.d.ts +7 -0
  240. package/dist/types/cli/prefix.d.ts +2 -0
  241. package/dist/types/cli/watch.d.ts +1 -0
  242. package/dist/types/cli.d.ts +0 -1
  243. package/dist/types/runtime/data-platform/batch/queue.d.ts +8 -0
  244. package/dist/types/runtime/data-platform/batch/request.d.ts +13 -0
  245. package/dist/types/runtime/data-platform/batch/response.d.ts +3 -0
  246. package/dist/types/runtime/data-platform/batch/telemetry.d.ts +4 -0
  247. package/dist/types/runtime/data-platform/batch/url.d.ts +4 -0
  248. package/dist/types/runtime/data-platform/batch-transport.d.ts +3 -0
  249. package/dist/types/runtime/data-platform/codec.d.ts +17 -0
  250. package/dist/types/runtime/data-platform/index.d.ts +7 -191
  251. package/dist/types/runtime/data-platform/invalidation.d.ts +8 -0
  252. package/dist/types/runtime/data-platform/trace.d.ts +4 -0
  253. package/dist/types/runtime/data-platform/types.d.ts +146 -0
  254. package/dist/types/runtime/data-platform/validation.d.ts +29 -0
  255. package/dist/types/runtime/effect/adapter/constants.d.ts +1 -0
  256. package/dist/types/runtime/effect/adapter/cross-project-policy.d.ts +4 -0
  257. package/dist/types/runtime/effect/adapter/entry.d.ts +2 -0
  258. package/dist/types/runtime/effect/adapter/error-response.d.ts +2 -0
  259. package/dist/types/runtime/effect/adapter/handler.d.ts +7 -0
  260. package/dist/types/runtime/effect/adapter.d.ts +4 -13
  261. package/dist/types/runtime/effect/backend-federation/entry.d.ts +2 -0
  262. package/dist/types/runtime/effect/backend-federation/load.d.ts +2 -0
  263. package/dist/types/runtime/effect/backend-federation/plugin.d.ts +3 -0
  264. package/dist/types/runtime/effect/backend-federation/remotes.d.ts +2 -0
  265. package/dist/types/runtime/effect/backend-federation/runtime.d.ts +3 -0
  266. package/dist/types/runtime/effect/backend-federation/types.d.ts +58 -0
  267. package/dist/types/runtime/effect/backend-federation/utils.d.ts +2 -0
  268. package/dist/types/runtime/effect/backend-federation-manifest/errors.d.ts +11 -0
  269. package/dist/types/runtime/effect/backend-federation-manifest/index.d.ts +6 -0
  270. package/dist/types/runtime/effect/backend-federation-manifest/load.d.ts +3 -0
  271. package/dist/types/runtime/effect/backend-federation-manifest/metadata.d.ts +18 -0
  272. package/dist/types/runtime/effect/backend-federation-manifest/reference.d.ts +3 -0
  273. package/dist/types/runtime/effect/backend-federation-manifest/remote.d.ts +3 -0
  274. package/dist/types/runtime/effect/backend-federation-manifest/types.d.ts +51 -0
  275. package/dist/types/runtime/effect/backend-federation-manifest/validation.d.ts +5 -0
  276. package/dist/types/runtime/effect/backend-federation-manifest.d.ts +1 -0
  277. package/dist/types/runtime/effect/backend-federation.d.ts +6 -0
  278. package/dist/types/runtime/effect/dispatch.d.ts +13 -0
  279. package/dist/types/runtime/effect/edge.d.ts +8 -8
  280. package/dist/types/runtime/effect/endpoint-contracts.d.ts +5 -7
  281. package/dist/types/runtime/effect/entry-shape.d.ts +31 -0
  282. package/dist/types/runtime/effect/handler/batch-handler.d.ts +11 -0
  283. package/dist/types/runtime/effect/handler/batch.d.ts +17 -0
  284. package/dist/types/runtime/effect/handler/definition.d.ts +17 -0
  285. package/dist/types/runtime/effect/handler/envelope.d.ts +13 -0
  286. package/dist/types/runtime/effect/handler/http.d.ts +14 -0
  287. package/dist/types/runtime/effect/handler/openapi.d.ts +4 -0
  288. package/dist/types/runtime/effect/handler/routing.d.ts +5 -0
  289. package/dist/types/runtime/effect/handler/rpc.d.ts +7 -0
  290. package/dist/types/runtime/effect/handler/types.d.ts +148 -0
  291. package/dist/types/runtime/effect/handler.d.ts +4 -190
  292. package/dist/types/runtime/effect/index.d.ts +3 -0
  293. package/dist/types/runtime/effect/module.d.ts +3 -2
  294. package/dist/types/runtime/effect/rpcSerialization.d.ts +3 -0
  295. package/dist/types/runtime/effect-client/batch.d.ts +2 -0
  296. package/dist/types/runtime/effect-client/envelope.d.ts +15 -0
  297. package/dist/types/runtime/effect-client/guards.d.ts +2 -0
  298. package/dist/types/runtime/effect-client/index.d.ts +1 -1
  299. package/dist/types/runtime/effect-client/request-context.d.ts +3 -0
  300. package/dist/types/runtime/effect-client/request.d.ts +1 -0
  301. package/dist/types/runtime/effect-client/runtime.d.ts +2 -68
  302. package/dist/types/runtime/effect-client/types.d.ts +68 -0
  303. package/dist/types/utils/client-generator/files.d.ts +28 -0
  304. package/dist/types/utils/client-generator/generate.d.ts +26 -0
  305. package/dist/types/utils/client-generator/index.d.ts +7 -0
  306. package/dist/types/utils/client-generator/package-json.d.ts +16 -0
  307. package/dist/types/utils/client-generator/write-package.d.ts +6 -0
  308. package/dist/types/utils/clientGenerator.d.ts +2 -37
  309. package/dist/types/utils/crossProjectServerPolicy.d.ts +3 -2
  310. package/dist/types/utils/effect-client-generator/generator.d.ts +10 -0
  311. package/dist/types/utils/effect-client-generator/index.d.ts +4 -0
  312. package/dist/types/utils/effect-client-generator/paths.d.ts +5 -0
  313. package/dist/types/utils/effect-client-generator/rendering.d.ts +4 -0
  314. package/dist/types/utils/effect-client-generator/runtime.d.ts +8 -0
  315. package/dist/types/utils/effect-client-generator/types.d.ts +26 -0
  316. package/dist/types/utils/effectClientGenerator.d.ts +2 -41
  317. package/package.json +35 -29
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, getters, values)=>{
14
+ var define = (defs, kind)=>{
15
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
+ enumerable: true,
17
+ [kind]: defs[key]
18
+ });
19
+ };
20
+ define(getters, "get");
21
+ define(values, "value");
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
+ })();
27
+ (()=>{
28
+ __webpack_require__.r = (exports1)=>{
29
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
30
+ value: 'Module'
31
+ });
32
+ Object.defineProperty(exports1, '__esModule', {
33
+ value: true
34
+ });
35
+ };
36
+ })();
37
+ var __webpack_exports__ = {};
38
+ __webpack_require__.r(__webpack_exports__);
39
+ __webpack_require__.d(__webpack_exports__, {
40
+ renderEffectClientCode: ()=>renderEffectClientCode,
41
+ renderEffectClientDeclaration: ()=>renderEffectClientDeclaration
42
+ });
43
+ const bff_core_namespaceObject = require("@modern-js/bff-core");
44
+ const utils_namespaceObject = require("@modern-js/utils");
45
+ const external_path_namespaceObject = require("path");
46
+ var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
47
+ const endpoint_contracts_js_namespaceObject = require("../../runtime/effect/endpoint-contracts.js");
48
+ const DEFAULT_REQUEST_CREATOR = '@modern-js/plugin-bff/client';
49
+ const EFFECT_CLIENT_RUNTIME_IMPORT = '@modern-js/plugin-bff/effect-client-runtime';
50
+ function isAbsoluteUrl(value) {
51
+ try {
52
+ new URL(value);
53
+ return true;
54
+ } catch {
55
+ return false;
56
+ }
57
+ }
58
+ function resolveBatchEndpoint(prefix, endpoint) {
59
+ const value = endpoint || '/_data/batch';
60
+ if (isAbsoluteUrl(value)) return value;
61
+ const normalizedPrefix = (0, endpoint_contracts_js_namespaceObject.normalizeEffectPrefix)(prefix);
62
+ const normalizedEndpoint = (0, endpoint_contracts_js_namespaceObject.ensureLeadingSlash)(value);
63
+ if (!normalizedPrefix) return normalizedEndpoint;
64
+ if (normalizedEndpoint === normalizedPrefix || normalizedEndpoint.startsWith(`${normalizedPrefix}/`)) return normalizedEndpoint;
65
+ return `${normalizedPrefix}${'/' === normalizedEndpoint ? '' : normalizedEndpoint}`;
66
+ }
67
+ function getPackageInfo(appDir) {
68
+ try {
69
+ const packageJsonPath = external_path_default().resolve(appDir, './package.json');
70
+ const packageJson = utils_namespaceObject.fs.readJSONSync(packageJsonPath);
71
+ return {
72
+ name: packageJson.name,
73
+ version: packageJson.version
74
+ };
75
+ } catch {
76
+ return {};
77
+ }
78
+ }
79
+ function renderEffectClientCode(endpoints, options) {
80
+ const requestCreator = options.requestCreator || DEFAULT_REQUEST_CREATOR;
81
+ const httpMethodDecider = options.httpMethodDecider || 'functionName';
82
+ const packageInfo = getPackageInfo(options.appDir);
83
+ const packageName = packageInfo.name;
84
+ const dataPlatformAppNamespace = packageName || 'unknown-app';
85
+ const requestId = 'bundle' === options.target ? packageName || process.env.npm_package_name : void 0;
86
+ const normalizedRequestId = requestId || 'default';
87
+ const operationVersion = (0, bff_core_namespaceObject.deriveOperationVersion)(packageInfo.version);
88
+ const batchConfig = options.dataPlatformBatch;
89
+ const batchEndpoint = resolveBatchEndpoint(options.prefix, batchConfig?.endpoint);
90
+ const manifest = {
91
+ endpoints: endpoints.map((endpoint)=>({
92
+ apiId: endpoint.apiId,
93
+ group: endpoint.groupName,
94
+ endpoint: endpoint.endpointName,
95
+ method: endpoint.method,
96
+ routePath: endpoint.routePath,
97
+ schemaHash: (0, endpoint_contracts_js_namespaceObject.createEffectEndpointContractHash)(endpoint, normalizedRequestId),
98
+ operationVersion
99
+ }))
100
+ };
101
+ const config = {
102
+ appNamespace: dataPlatformAppNamespace,
103
+ ...requestId ? {
104
+ requestId
105
+ } : {},
106
+ port: options.port,
107
+ useEnvPort: 'server' === options.target,
108
+ defaultOrigin: `http://localhost:${String(options.port)}`,
109
+ httpMethodDecider,
110
+ batch: {
111
+ enabled: batchConfig?.enabled ?? true,
112
+ endpoint: batchEndpoint,
113
+ flushIntervalMs: batchConfig?.flushIntervalMs ?? 8,
114
+ maxBatchSize: batchConfig?.maxBatchSize ?? 16,
115
+ maxBatchBytes: batchConfig?.maxBatchBytes ?? 65536,
116
+ requestTimeoutMs: batchConfig?.requestTimeoutMs ?? 10000,
117
+ allowedMethods: batchConfig?.allowedMethods && batchConfig.allowedMethods.length > 0 ? batchConfig.allowedMethods : [
118
+ 'GET'
119
+ ]
120
+ }
121
+ };
122
+ return `import * as __requestRuntime from ${JSON.stringify(requestCreator)};
123
+ import { createGeneratedEffectClient } from ${JSON.stringify(EFFECT_CLIENT_RUNTIME_IMPORT)};
124
+
125
+ const __manifest = ${JSON.stringify(manifest, null, 2)};
126
+
127
+ const __config = ${JSON.stringify(config, null, 2)};
128
+
129
+ const __generated = createGeneratedEffectClient(__manifest, __config, __requestRuntime);
130
+
131
+ const client = __generated.client;
132
+ const operationManifest = __generated.operationManifest;
133
+ const createEffectRequestContext = __generated.createEffectRequestContext;
134
+ const apiModule = {
135
+ client,
136
+ operationManifest,
137
+ createEffectRequestContext,
138
+ };
139
+
140
+ export { client, createEffectRequestContext, operationManifest };
141
+ export default apiModule;
142
+ `;
143
+ }
144
+ function renderClientShape(endpoints, valueType) {
145
+ if (0 === endpoints.length) return `Record<string, Record<string, ${valueType}>>`;
146
+ const groups = new Map();
147
+ for (const endpoint of endpoints){
148
+ const group = groups.get(endpoint.groupName) || [];
149
+ group.push(endpoint.endpointName);
150
+ groups.set(endpoint.groupName, group);
151
+ }
152
+ const groupEntries = [
153
+ ...groups.entries()
154
+ ].map(([groupName, names])=>{
155
+ const endpointEntries = names.map((name)=>` ${JSON.stringify(name)}: ${valueType};`).join('\n');
156
+ return ` ${JSON.stringify(groupName)}: {\n${endpointEntries}\n };`;
157
+ });
158
+ return `{\n${groupEntries.join('\n')}\n}`;
159
+ }
160
+ function renderEffectClientDeclaration(endpoints = []) {
161
+ return `export type EffectClientOperation = (
162
+ request?: unknown,
163
+ ) => Promise<unknown>;
164
+ export type EffectClientGroup = Record<string, EffectClientOperation>;
165
+ export type EffectClient = Record<string, EffectClientGroup>;
166
+ export type EffectOperationDescriptor = {
167
+ appNamespace: string;
168
+ apiId: string;
169
+ group: string;
170
+ endpoint: string;
171
+ operationId: string;
172
+ routePath: string;
173
+ method: string;
174
+ operationVersion: number;
175
+ schemaHash: string;
176
+ version: number;
177
+ };
178
+ export type EffectOperationManifest = Record<
179
+ string,
180
+ Record<string, EffectOperationDescriptor>
181
+ >;
182
+ export type EffectOperationContext = {
183
+ requestId?: string;
184
+ operationId?: string;
185
+ routePath?: string;
186
+ method?: string;
187
+ schemaHash?: string;
188
+ operationVersion?: number;
189
+ locale?: string;
190
+ traceparent?: string;
191
+ traceId?: string;
192
+ spanId?: string;
193
+ source?: string;
194
+ scope?: Record<string, unknown>;
195
+ sessionClaims?: Record<string, unknown>;
196
+ attributes?: Record<string, unknown>;
197
+ };
198
+ export type EffectRequestContext = {
199
+ headers?: Record<string, string>;
200
+ locale?: string;
201
+ operationContext?: EffectOperationContext;
202
+ traceparent?: string;
203
+ traceId?: string;
204
+ spanId?: string;
205
+ };
206
+ export type GeneratedEffectClient = ${renderClientShape(endpoints, 'EffectClientOperation')};
207
+ export type GeneratedEffectOperationManifest = ${renderClientShape(endpoints, "EffectOperationDescriptor")};
208
+
209
+ export declare const client: GeneratedEffectClient;
210
+ export declare const createEffectRequestContext: (
211
+ requestContext: Record<string, unknown>,
212
+ ) => EffectRequestContext;
213
+ export declare const operationManifest: GeneratedEffectOperationManifest;
214
+ declare const apiModule: {
215
+ client: GeneratedEffectClient;
216
+ createEffectRequestContext: typeof createEffectRequestContext;
217
+ operationManifest: GeneratedEffectOperationManifest;
218
+ };
219
+
220
+ export default apiModule;
221
+ `;
222
+ }
223
+ exports.renderEffectClientCode = __webpack_exports__.renderEffectClientCode;
224
+ exports.renderEffectClientDeclaration = __webpack_exports__.renderEffectClientDeclaration;
225
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
226
+ "renderEffectClientCode",
227
+ "renderEffectClientDeclaration"
228
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
229
+ Object.defineProperty(exports, '__esModule', {
230
+ value: true
231
+ });
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, getters, values)=>{
14
+ var define = (defs, kind)=>{
15
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
+ enumerable: true,
17
+ [kind]: defs[key]
18
+ });
19
+ };
20
+ define(getters, "get");
21
+ define(values, "value");
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
+ })();
27
+ (()=>{
28
+ __webpack_require__.r = (exports1)=>{
29
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
30
+ value: 'Module'
31
+ });
32
+ Object.defineProperty(exports1, '__esModule', {
33
+ value: true
34
+ });
35
+ };
36
+ })();
37
+ var __webpack_exports__ = {};
38
+ __webpack_require__.r(__webpack_exports__);
39
+ __webpack_require__.d(__webpack_exports__, {
40
+ getHttpApiRuntime: ()=>getHttpApiRuntime,
41
+ loadEffectApi: ()=>loadEffectApi
42
+ });
43
+ const utils_namespaceObject = require("@modern-js/utils");
44
+ const external_path_namespaceObject = require("path");
45
+ var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
46
+ const endpoint_contracts_js_namespaceObject = require("../../runtime/effect/endpoint-contracts.js");
47
+ let httpApiRuntimePromise;
48
+ function isRecord(value) {
49
+ return 'object' == typeof value && null !== value;
50
+ }
51
+ async function getHttpApiRuntime() {
52
+ if (!httpApiRuntimePromise) httpApiRuntimePromise = (async ()=>{
53
+ let mod;
54
+ try {
55
+ mod = await (0, utils_namespaceObject.compatibleRequire)('effect/unstable/httpapi', false);
56
+ } catch (error) {
57
+ const message = error instanceof Error ? error.message : String(error);
58
+ if (!message.includes("Cannot find module 'effect/unstable/httpapi'")) throw error;
59
+ const effectPackageJson = require.resolve('effect/package.json');
60
+ const effectHttpApiRuntimePath = external_path_default().join(external_path_default().dirname(effectPackageJson), 'dist', 'unstable', 'httpapi', 'index.js');
61
+ mod = await (0, utils_namespaceObject.compatibleRequire)(effectHttpApiRuntimePath, false);
62
+ }
63
+ if (isRecord(mod) && isRecord(mod.HttpApi)) {
64
+ const maybeHttpApi = mod.HttpApi;
65
+ if ('function' == typeof maybeHttpApi.isHttpApi && 'function' == typeof maybeHttpApi.reflect) return maybeHttpApi;
66
+ }
67
+ throw new Error('[BFF][Effect] Unable to resolve HttpApi runtime from effect/unstable/httpapi.');
68
+ })();
69
+ return httpApiRuntimePromise;
70
+ }
71
+ async function loadEffectApi(resourcePath) {
72
+ const httpApiRuntime = await getHttpApiRuntime();
73
+ const mod = await (0, utils_namespaceObject.compatibleRequire)(resourcePath, false);
74
+ return (0, endpoint_contracts_js_namespaceObject.extractHttpApiFromModule)(mod, httpApiRuntime.isHttpApi);
75
+ }
76
+ exports.getHttpApiRuntime = __webpack_exports__.getHttpApiRuntime;
77
+ exports.loadEffectApi = __webpack_exports__.loadEffectApi;
78
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
79
+ "getHttpApiRuntime",
80
+ "loadEffectApi"
81
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
82
+ Object.defineProperty(exports, '__esModule', {
83
+ value: true
84
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.r = (exports1)=>{
5
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
+ value: 'Module'
7
+ });
8
+ Object.defineProperty(exports1, '__esModule', {
9
+ value: true
10
+ });
11
+ };
12
+ })();
13
+ var __webpack_exports__ = {};
14
+ __webpack_require__.r(__webpack_exports__);
15
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
16
+ Object.defineProperty(exports, '__esModule', {
17
+ value: true
18
+ });
@@ -1,14 +1,5 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
3
  (()=>{
13
4
  __webpack_require__.d = (exports1, getters, values)=>{
14
5
  var define = (defs, kind)=>{
@@ -37,260 +28,12 @@ var __webpack_require__ = {};
37
28
  var __webpack_exports__ = {};
38
29
  __webpack_require__.r(__webpack_exports__);
39
30
  __webpack_require__.d(__webpack_exports__, {
40
- generateEffectClient: ()=>generateEffectClient,
41
- generateEffectClientCode: ()=>generateEffectClientCode,
42
- renderEffectClientDeclaration: ()=>renderEffectClientDeclaration,
43
- resolveEffectEntryFile: ()=>resolveEffectEntryFile
31
+ generateEffectClient: ()=>index_js_namespaceObject.generateEffectClient,
32
+ generateEffectClientCode: ()=>index_js_namespaceObject.generateEffectClientCode,
33
+ renderEffectClientDeclaration: ()=>index_js_namespaceObject.renderEffectClientDeclaration,
34
+ resolveEffectEntryFile: ()=>index_js_namespaceObject.resolveEffectEntryFile
44
35
  });
45
- const bff_core_namespaceObject = require("@modern-js/bff-core");
46
- const utils_namespaceObject = require("@modern-js/utils");
47
- const external_path_namespaceObject = require("path");
48
- var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
49
- const endpoint_contracts_js_namespaceObject = require("../runtime/effect/endpoint-contracts.js");
50
- const JS_OR_TS_EXTS = [
51
- '.js',
52
- '.jsx',
53
- '.ts',
54
- '.tsx',
55
- '.mjs',
56
- '.mts',
57
- '.cjs',
58
- '.cts'
59
- ];
60
- const DEFAULT_REQUEST_CREATOR = '@modern-js/plugin-bff/client';
61
- const EFFECT_CLIENT_RUNTIME_IMPORT = '@modern-js/plugin-bff/effect-client-runtime';
62
- let httpApiRuntimePromise;
63
- function isRecord(value) {
64
- return 'object' == typeof value && null !== value;
65
- }
66
- function isAbsoluteUrl(value) {
67
- try {
68
- new URL(value);
69
- return true;
70
- } catch {
71
- return false;
72
- }
73
- }
74
- function resolveBatchEndpoint(prefix, endpoint) {
75
- const value = endpoint || '/_data/batch';
76
- if (isAbsoluteUrl(value)) return value;
77
- const normalizedPrefix = (0, endpoint_contracts_js_namespaceObject.normalizeEffectPrefix)(prefix);
78
- const normalizedEndpoint = (0, endpoint_contracts_js_namespaceObject.ensureLeadingSlash)(value);
79
- if (!normalizedPrefix) return normalizedEndpoint;
80
- if (normalizedEndpoint === normalizedPrefix || normalizedEndpoint.startsWith(`${normalizedPrefix}/`)) return normalizedEndpoint;
81
- return `${normalizedPrefix}${'/' === normalizedEndpoint ? '' : normalizedEndpoint}`;
82
- }
83
- function getPackageInfo(appDir) {
84
- try {
85
- const packageJsonPath = external_path_default().resolve(appDir, './package.json');
86
- const packageJson = utils_namespaceObject.fs.readJSONSync(packageJsonPath);
87
- return {
88
- name: packageJson.name,
89
- version: packageJson.version
90
- };
91
- } catch {
92
- return {};
93
- }
94
- }
95
- async function getHttpApiRuntime() {
96
- if (!httpApiRuntimePromise) httpApiRuntimePromise = (async ()=>{
97
- let mod;
98
- try {
99
- mod = await (0, utils_namespaceObject.compatibleRequire)('effect/unstable/httpapi', false);
100
- } catch (error) {
101
- const message = error instanceof Error ? error.message : String(error);
102
- if (!message.includes("Cannot find module 'effect/unstable/httpapi'")) throw error;
103
- const effectPackageJson = require.resolve('effect/package.json');
104
- const effectHttpApiRuntimePath = external_path_default().join(external_path_default().dirname(effectPackageJson), 'dist', 'unstable', 'httpapi', 'index.js');
105
- mod = await (0, utils_namespaceObject.compatibleRequire)(effectHttpApiRuntimePath, false);
106
- }
107
- if (isRecord(mod) && isRecord(mod.HttpApi)) {
108
- const maybeHttpApi = mod.HttpApi;
109
- if ('function' == typeof maybeHttpApi.isHttpApi && 'function' == typeof maybeHttpApi.reflect) return maybeHttpApi;
110
- }
111
- throw new Error('[BFF][Effect] Unable to resolve HttpApi runtime from effect/unstable/httpapi.');
112
- })();
113
- return httpApiRuntimePromise;
114
- }
115
- async function loadEffectApi(resourcePath) {
116
- const httpApiRuntime = await getHttpApiRuntime();
117
- const mod = await (0, utils_namespaceObject.compatibleRequire)(resourcePath, false);
118
- return (0, endpoint_contracts_js_namespaceObject.extractHttpApiFromModule)(mod, httpApiRuntime.isHttpApi);
119
- }
120
- function renderEffectClientCode(endpoints, options) {
121
- const requestCreator = options.requestCreator || DEFAULT_REQUEST_CREATOR;
122
- const httpMethodDecider = options.httpMethodDecider || 'functionName';
123
- const packageInfo = getPackageInfo(options.appDir);
124
- const packageName = packageInfo.name;
125
- const dataPlatformAppNamespace = packageName || 'unknown-app';
126
- const requestId = 'bundle' === options.target ? packageName || process.env.npm_package_name : void 0;
127
- const normalizedRequestId = requestId || 'default';
128
- const operationVersion = (0, bff_core_namespaceObject.deriveOperationVersion)(packageInfo.version);
129
- const batchConfig = options.dataPlatformBatch;
130
- const batchEndpoint = resolveBatchEndpoint(options.prefix, batchConfig?.endpoint);
131
- const manifest = {
132
- endpoints: endpoints.map((endpoint)=>({
133
- apiId: endpoint.apiId,
134
- group: endpoint.groupName,
135
- endpoint: endpoint.endpointName,
136
- method: endpoint.method,
137
- routePath: endpoint.routePath,
138
- schemaHash: (0, endpoint_contracts_js_namespaceObject.createEffectEndpointContractHash)(endpoint, normalizedRequestId),
139
- operationVersion
140
- }))
141
- };
142
- const config = {
143
- appNamespace: dataPlatformAppNamespace,
144
- ...requestId ? {
145
- requestId
146
- } : {},
147
- port: options.port,
148
- useEnvPort: 'server' === options.target,
149
- defaultOrigin: `http://localhost:${String(options.port)}`,
150
- httpMethodDecider,
151
- batch: {
152
- enabled: batchConfig?.enabled ?? true,
153
- endpoint: batchEndpoint,
154
- flushIntervalMs: batchConfig?.flushIntervalMs ?? 8,
155
- maxBatchSize: batchConfig?.maxBatchSize ?? 16,
156
- maxBatchBytes: batchConfig?.maxBatchBytes ?? 65536,
157
- requestTimeoutMs: batchConfig?.requestTimeoutMs ?? 10000,
158
- allowedMethods: batchConfig?.allowedMethods && batchConfig.allowedMethods.length > 0 ? batchConfig.allowedMethods : [
159
- 'GET'
160
- ]
161
- }
162
- };
163
- return `import * as __requestRuntime from ${JSON.stringify(requestCreator)};
164
- import { createGeneratedEffectClient } from ${JSON.stringify(EFFECT_CLIENT_RUNTIME_IMPORT)};
165
-
166
- const __manifest = ${JSON.stringify(manifest, null, 2)};
167
-
168
- const __config = ${JSON.stringify(config, null, 2)};
169
-
170
- const __generated = createGeneratedEffectClient(__manifest, __config, __requestRuntime);
171
-
172
- const client = __generated.client;
173
- const operationManifest = __generated.operationManifest;
174
- const createEffectRequestContext = __generated.createEffectRequestContext;
175
- const apiModule = {
176
- client,
177
- operationManifest,
178
- createEffectRequestContext,
179
- };
180
-
181
- export { client, createEffectRequestContext, operationManifest };
182
- export default apiModule;
183
- `;
184
- }
185
- function renderClientShape(endpoints, valueType) {
186
- if (0 === endpoints.length) return `Record<string, Record<string, ${valueType}>>`;
187
- const groups = new Map();
188
- for (const endpoint of endpoints){
189
- const group = groups.get(endpoint.groupName) || [];
190
- group.push(endpoint.endpointName);
191
- groups.set(endpoint.groupName, group);
192
- }
193
- const groupEntries = [
194
- ...groups.entries()
195
- ].map(([groupName, names])=>{
196
- const endpointEntries = names.map((name)=>` ${JSON.stringify(name)}: ${valueType};`).join('\n');
197
- return ` ${JSON.stringify(groupName)}: {\n${endpointEntries}\n };`;
198
- });
199
- return `{\n${groupEntries.join('\n')}\n}`;
200
- }
201
- function renderEffectClientDeclaration(endpoints = []) {
202
- return `export type EffectClientOperation = (
203
- request?: unknown,
204
- ) => Promise<unknown>;
205
- export type EffectClientGroup = Record<string, EffectClientOperation>;
206
- export type EffectClient = Record<string, EffectClientGroup>;
207
- export type EffectOperationDescriptor = {
208
- appNamespace: string;
209
- apiId: string;
210
- group: string;
211
- endpoint: string;
212
- operationId: string;
213
- routePath: string;
214
- method: string;
215
- operationVersion: number;
216
- schemaHash: string;
217
- version: number;
218
- };
219
- export type EffectOperationManifest = Record<
220
- string,
221
- Record<string, EffectOperationDescriptor>
222
- >;
223
- export type EffectOperationContext = {
224
- requestId?: string;
225
- operationId?: string;
226
- routePath?: string;
227
- method?: string;
228
- schemaHash?: string;
229
- operationVersion?: number;
230
- locale?: string;
231
- traceparent?: string;
232
- traceId?: string;
233
- spanId?: string;
234
- source?: string;
235
- scope?: Record<string, unknown>;
236
- sessionClaims?: Record<string, unknown>;
237
- attributes?: Record<string, unknown>;
238
- };
239
- export type EffectRequestContext = {
240
- headers?: Record<string, string>;
241
- locale?: string;
242
- operationContext?: EffectOperationContext;
243
- traceparent?: string;
244
- traceId?: string;
245
- spanId?: string;
246
- };
247
- export type GeneratedEffectClient = ${renderClientShape(endpoints, 'EffectClientOperation')};
248
- export type GeneratedEffectOperationManifest = ${renderClientShape(endpoints, "EffectOperationDescriptor")};
249
-
250
- export declare const client: GeneratedEffectClient;
251
- export declare const createEffectRequestContext: (
252
- requestContext: Record<string, unknown>,
253
- ) => EffectRequestContext;
254
- export declare const operationManifest: GeneratedEffectOperationManifest;
255
- declare const apiModule: {
256
- client: GeneratedEffectClient;
257
- createEffectRequestContext: typeof createEffectRequestContext;
258
- operationManifest: GeneratedEffectOperationManifest;
259
- };
260
-
261
- export default apiModule;
262
- `;
263
- }
264
- async function generateEffectClient(options) {
265
- const api = await loadEffectApi(options.resourcePath);
266
- if (!api) {
267
- utils_namespaceObject.logger.warn(`[BFF][Effect] Failed to generate client for ${options.resourcePath}: unable to resolve exported HttpApi.`);
268
- return null;
269
- }
270
- const httpApiRuntime = await getHttpApiRuntime();
271
- const endpoints = (0, endpoint_contracts_js_namespaceObject.collectEffectEndpoints)(httpApiRuntime.reflect, api, options.prefix);
272
- return {
273
- code: renderEffectClientCode(endpoints, options),
274
- declaration: renderEffectClientDeclaration(endpoints),
275
- endpoints
276
- };
277
- }
278
- async function generateEffectClientCode(options) {
279
- const artifacts = await generateEffectClient(options);
280
- return artifacts ? artifacts.code : null;
281
- }
282
- function resolveEffectEntryFile(options) {
283
- const { appDir, apiDir, effectEntry } = options;
284
- const resolveEntry = (entryWithoutExt)=>{
285
- if (external_path_default().extname(entryWithoutExt)) return utils_namespaceObject.fs.existsSync(entryWithoutExt) ? entryWithoutExt : void 0;
286
- return (0, utils_namespaceObject.findExists)(JS_OR_TS_EXTS.map((ext)=>`${entryWithoutExt}${ext}`));
287
- };
288
- if (effectEntry) {
289
- const entryWithoutExt = external_path_default().isAbsolute(effectEntry) ? effectEntry : external_path_default().resolve(appDir, effectEntry);
290
- return resolveEntry(entryWithoutExt);
291
- }
292
- return resolveEntry(external_path_default().resolve(apiDir, 'index'));
293
- }
36
+ const index_js_namespaceObject = require("./effect-client-generator/index.js");
294
37
  exports.generateEffectClient = __webpack_exports__.generateEffectClient;
295
38
  exports.generateEffectClientCode = __webpack_exports__.generateEffectClientCode;
296
39
  exports.renderEffectClientDeclaration = __webpack_exports__.renderEffectClientDeclaration;
@@ -0,0 +1,14 @@
1
+ import { normalizePrefixList } from "./prefix.mjs";
2
+ const createCompressConfig = (devServer, prefix)=>{
3
+ if (!devServer || 'object' != typeof devServer || Array.isArray(devServer)) return;
4
+ const { compress } = devServer;
5
+ if (void 0 === compress || true === compress) {
6
+ const prefixes = normalizePrefixList(prefix);
7
+ return {
8
+ filter: (req)=>!prefixes.some((item)=>req.url?.includes(item))
9
+ };
10
+ }
11
+ if (false === compress) return false;
12
+ return compress;
13
+ };
14
+ export { createCompressConfig };