@bleedingdev/modern-js-plugin-bff 3.5.0-ultramodern.30 → 3.5.0-ultramodern.32

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 (292) 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 +287 -0
  7. package/dist/cjs/runtime/data-platform/batch/request.js +98 -0
  8. package/dist/cjs/runtime/data-platform/batch/response.js +67 -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 +12 -115
  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 +32 -257
  40. package/dist/cjs/runtime/effect/backend-federation.js +11 -139
  41. package/dist/cjs/runtime/effect/handler/batch-handler.js +161 -0
  42. package/dist/cjs/runtime/effect/handler/batch.js +195 -0
  43. package/dist/cjs/runtime/effect/handler/definition.js +101 -0
  44. package/dist/cjs/runtime/effect/handler/envelope.js +104 -0
  45. package/dist/cjs/runtime/effect/handler/http.js +96 -0
  46. package/dist/cjs/runtime/effect/handler/openapi.js +57 -0
  47. package/dist/cjs/runtime/effect/handler/routing.js +100 -0
  48. package/dist/cjs/runtime/effect/handler/rpc.js +63 -0
  49. package/dist/cjs/runtime/effect/handler/types.js +43 -0
  50. package/dist/cjs/runtime/effect/handler.js +35 -526
  51. package/dist/cjs/runtime/effect/rpcSerialization.js +54 -0
  52. package/dist/cjs/runtime/effect-client/batch.js +73 -0
  53. package/dist/cjs/runtime/effect-client/envelope.js +145 -0
  54. package/dist/cjs/runtime/effect-client/guards.js +44 -0
  55. package/dist/cjs/runtime/effect-client/index.js +6 -16
  56. package/dist/cjs/runtime/effect-client/request-context.js +64 -0
  57. package/dist/cjs/runtime/effect-client/request.js +66 -0
  58. package/dist/cjs/runtime/effect-client/runtime.js +12 -178
  59. package/dist/cjs/runtime/effect-client/types.js +18 -0
  60. package/dist/cjs/runtime/safe-failure.js +2 -1
  61. package/dist/cjs/utils/client-generator/files.js +152 -0
  62. package/dist/cjs/utils/client-generator/generate.js +138 -0
  63. package/dist/cjs/utils/client-generator/index.js +83 -0
  64. package/dist/cjs/utils/client-generator/package-json.js +132 -0
  65. package/dist/cjs/utils/client-generator/write-package.js +125 -0
  66. package/dist/cjs/utils/clientGenerator.js +26 -303
  67. package/dist/cjs/utils/effect-client-generator/generator.js +64 -0
  68. package/dist/cjs/utils/effect-client-generator/index.js +51 -0
  69. package/dist/cjs/utils/effect-client-generator/paths.js +73 -0
  70. package/dist/cjs/utils/effect-client-generator/rendering.js +231 -0
  71. package/dist/cjs/utils/effect-client-generator/runtime.js +84 -0
  72. package/dist/cjs/utils/effect-client-generator/types.js +18 -0
  73. package/dist/cjs/utils/effectClientGenerator.js +5 -262
  74. package/dist/esm/cli/compress.mjs +14 -0
  75. package/dist/esm/cli/generator.mjs +98 -0
  76. package/dist/esm/cli/prefix.mjs +9 -0
  77. package/dist/esm/cli/watch.mjs +13 -0
  78. package/dist/esm/cli.mjs +7 -121
  79. package/dist/esm/runtime/data-platform/batch/queue.mjs +246 -0
  80. package/dist/esm/runtime/data-platform/batch/request.mjs +45 -0
  81. package/dist/esm/runtime/data-platform/batch/response.mjs +23 -0
  82. package/dist/esm/runtime/data-platform/batch/telemetry.mjs +23 -0
  83. package/dist/esm/runtime/data-platform/batch/url.mjs +25 -0
  84. package/dist/esm/runtime/data-platform/batch-transport.mjs +12 -0
  85. package/dist/esm/runtime/data-platform/codec.mjs +90 -0
  86. package/dist/esm/runtime/data-platform/index.mjs +6 -610
  87. package/dist/esm/runtime/data-platform/invalidation.mjs +20 -0
  88. package/dist/esm/runtime/data-platform/trace.mjs +29 -0
  89. package/dist/esm/runtime/data-platform/types.mjs +4 -0
  90. package/dist/esm/runtime/data-platform/validation.mjs +128 -0
  91. package/dist/esm/runtime/effect/adapter/constants.mjs +6 -0
  92. package/dist/esm/runtime/effect/adapter/cross-project-policy.mjs +23 -0
  93. package/dist/esm/runtime/effect/adapter/entry.mjs +29 -0
  94. package/dist/esm/runtime/effect/adapter/error-response.mjs +41 -0
  95. package/dist/esm/runtime/effect/adapter/handler.mjs +15 -0
  96. package/dist/esm/runtime/effect/adapter.mjs +12 -105
  97. package/dist/esm/runtime/effect/backend-federation/entry.mjs +61 -0
  98. package/dist/esm/runtime/effect/backend-federation/load.mjs +19 -0
  99. package/dist/esm/runtime/effect/backend-federation/plugin.mjs +15 -0
  100. package/dist/esm/runtime/effect/backend-federation/remotes.mjs +12 -0
  101. package/dist/esm/runtime/effect/backend-federation/runtime.mjs +26 -0
  102. package/dist/esm/runtime/effect/backend-federation/types.mjs +0 -0
  103. package/dist/esm/runtime/effect/backend-federation/utils.mjs +7 -0
  104. package/dist/esm/runtime/effect/backend-federation-manifest/errors.mjs +32 -0
  105. package/dist/esm/runtime/effect/backend-federation-manifest/index.mjs +4 -0
  106. package/dist/esm/runtime/effect/backend-federation-manifest/load.mjs +36 -0
  107. package/dist/esm/runtime/effect/backend-federation-manifest/metadata.mjs +42 -0
  108. package/dist/esm/runtime/effect/backend-federation-manifest/reference.mjs +76 -0
  109. package/dist/esm/runtime/effect/backend-federation-manifest/remote.mjs +30 -0
  110. package/dist/esm/runtime/effect/backend-federation-manifest/types.mjs +0 -0
  111. package/dist/esm/runtime/effect/backend-federation-manifest/validation.mjs +64 -0
  112. package/dist/esm/runtime/effect/backend-federation-manifest.mjs +1 -237
  113. package/dist/esm/runtime/effect/backend-federation.mjs +4 -132
  114. package/dist/esm/runtime/effect/handler/batch-handler.mjs +123 -0
  115. package/dist/esm/runtime/effect/handler/batch.mjs +124 -0
  116. package/dist/esm/runtime/effect/handler/definition.mjs +60 -0
  117. package/dist/esm/runtime/effect/handler/envelope.mjs +63 -0
  118. package/dist/esm/runtime/effect/handler/http.mjs +58 -0
  119. package/dist/esm/runtime/effect/handler/openapi.mjs +19 -0
  120. package/dist/esm/runtime/effect/handler/routing.mjs +50 -0
  121. package/dist/esm/runtime/effect/handler/rpc.mjs +22 -0
  122. package/dist/esm/runtime/effect/handler/types.mjs +5 -0
  123. package/dist/esm/runtime/effect/handler.mjs +7 -499
  124. package/dist/esm/runtime/effect/rpcSerialization.mjs +16 -0
  125. package/dist/esm/runtime/effect-client/batch.mjs +35 -0
  126. package/dist/esm/runtime/effect-client/envelope.mjs +104 -0
  127. package/dist/esm/runtime/effect-client/guards.mjs +3 -0
  128. package/dist/esm/runtime/effect-client/index.mjs +5 -15
  129. package/dist/esm/runtime/effect-client/request-context.mjs +23 -0
  130. package/dist/esm/runtime/effect-client/request.mjs +28 -0
  131. package/dist/esm/runtime/effect-client/runtime.mjs +12 -178
  132. package/dist/esm/runtime/effect-client/types.mjs +0 -0
  133. package/dist/esm/runtime/safe-failure.mjs +2 -1
  134. package/dist/esm/utils/client-generator/files.mjs +68 -0
  135. package/dist/esm/utils/client-generator/generate.mjs +88 -0
  136. package/dist/esm/utils/client-generator/index.mjs +4 -0
  137. package/dist/esm/utils/client-generator/package-json.mjs +78 -0
  138. package/dist/esm/utils/client-generator/write-package.mjs +74 -0
  139. package/dist/esm/utils/clientGenerator.mjs +2 -293
  140. package/dist/esm/utils/effect-client-generator/generator.mjs +23 -0
  141. package/dist/esm/utils/effect-client-generator/index.mjs +3 -0
  142. package/dist/esm/utils/effect-client-generator/paths.mjs +25 -0
  143. package/dist/esm/utils/effect-client-generator/rendering.mjs +180 -0
  144. package/dist/esm/utils/effect-client-generator/runtime.mjs +33 -0
  145. package/dist/esm/utils/effect-client-generator/types.mjs +0 -0
  146. package/dist/esm/utils/effectClientGenerator.mjs +1 -249
  147. package/dist/esm-node/cli/compress.mjs +15 -0
  148. package/dist/esm-node/cli/generator.mjs +99 -0
  149. package/dist/esm-node/cli/prefix.mjs +10 -0
  150. package/dist/esm-node/cli/watch.mjs +14 -0
  151. package/dist/esm-node/cli.mjs +7 -121
  152. package/dist/esm-node/runtime/data-platform/batch/queue.mjs +247 -0
  153. package/dist/esm-node/runtime/data-platform/batch/request.mjs +46 -0
  154. package/dist/esm-node/runtime/data-platform/batch/response.mjs +24 -0
  155. package/dist/esm-node/runtime/data-platform/batch/telemetry.mjs +24 -0
  156. package/dist/esm-node/runtime/data-platform/batch/url.mjs +26 -0
  157. package/dist/esm-node/runtime/data-platform/batch-transport.mjs +13 -0
  158. package/dist/esm-node/runtime/data-platform/codec.mjs +91 -0
  159. package/dist/esm-node/runtime/data-platform/index.mjs +6 -610
  160. package/dist/esm-node/runtime/data-platform/invalidation.mjs +21 -0
  161. package/dist/esm-node/runtime/data-platform/trace.mjs +30 -0
  162. package/dist/esm-node/runtime/data-platform/types.mjs +5 -0
  163. package/dist/esm-node/runtime/data-platform/validation.mjs +129 -0
  164. package/dist/esm-node/runtime/effect/adapter/constants.mjs +7 -0
  165. package/dist/esm-node/runtime/effect/adapter/cross-project-policy.mjs +24 -0
  166. package/dist/esm-node/runtime/effect/adapter/entry.mjs +30 -0
  167. package/dist/esm-node/runtime/effect/adapter/error-response.mjs +42 -0
  168. package/dist/esm-node/runtime/effect/adapter/handler.mjs +16 -0
  169. package/dist/esm-node/runtime/effect/adapter.mjs +12 -105
  170. package/dist/esm-node/runtime/effect/backend-federation/entry.mjs +62 -0
  171. package/dist/esm-node/runtime/effect/backend-federation/load.mjs +20 -0
  172. package/dist/esm-node/runtime/effect/backend-federation/plugin.mjs +16 -0
  173. package/dist/esm-node/runtime/effect/backend-federation/remotes.mjs +13 -0
  174. package/dist/esm-node/runtime/effect/backend-federation/runtime.mjs +27 -0
  175. package/dist/esm-node/runtime/effect/backend-federation/types.mjs +1 -0
  176. package/dist/esm-node/runtime/effect/backend-federation/utils.mjs +8 -0
  177. package/dist/esm-node/runtime/effect/backend-federation-manifest/errors.mjs +33 -0
  178. package/dist/esm-node/runtime/effect/backend-federation-manifest/index.mjs +5 -0
  179. package/dist/esm-node/runtime/effect/backend-federation-manifest/load.mjs +37 -0
  180. package/dist/esm-node/runtime/effect/backend-federation-manifest/metadata.mjs +43 -0
  181. package/dist/esm-node/runtime/effect/backend-federation-manifest/reference.mjs +77 -0
  182. package/dist/esm-node/runtime/effect/backend-federation-manifest/remote.mjs +31 -0
  183. package/dist/esm-node/runtime/effect/backend-federation-manifest/types.mjs +1 -0
  184. package/dist/esm-node/runtime/effect/backend-federation-manifest/validation.mjs +65 -0
  185. package/dist/esm-node/runtime/effect/backend-federation-manifest.mjs +1 -237
  186. package/dist/esm-node/runtime/effect/backend-federation.mjs +4 -132
  187. package/dist/esm-node/runtime/effect/handler/batch-handler.mjs +124 -0
  188. package/dist/esm-node/runtime/effect/handler/batch.mjs +125 -0
  189. package/dist/esm-node/runtime/effect/handler/definition.mjs +61 -0
  190. package/dist/esm-node/runtime/effect/handler/envelope.mjs +64 -0
  191. package/dist/esm-node/runtime/effect/handler/http.mjs +59 -0
  192. package/dist/esm-node/runtime/effect/handler/openapi.mjs +20 -0
  193. package/dist/esm-node/runtime/effect/handler/routing.mjs +51 -0
  194. package/dist/esm-node/runtime/effect/handler/rpc.mjs +23 -0
  195. package/dist/esm-node/runtime/effect/handler/types.mjs +6 -0
  196. package/dist/esm-node/runtime/effect/handler.mjs +7 -499
  197. package/dist/esm-node/runtime/effect/rpcSerialization.mjs +17 -0
  198. package/dist/esm-node/runtime/effect-client/batch.mjs +36 -0
  199. package/dist/esm-node/runtime/effect-client/envelope.mjs +105 -0
  200. package/dist/esm-node/runtime/effect-client/guards.mjs +4 -0
  201. package/dist/esm-node/runtime/effect-client/index.mjs +5 -15
  202. package/dist/esm-node/runtime/effect-client/request-context.mjs +24 -0
  203. package/dist/esm-node/runtime/effect-client/request.mjs +29 -0
  204. package/dist/esm-node/runtime/effect-client/runtime.mjs +12 -178
  205. package/dist/esm-node/runtime/effect-client/types.mjs +1 -0
  206. package/dist/esm-node/runtime/safe-failure.mjs +2 -1
  207. package/dist/esm-node/utils/client-generator/files.mjs +69 -0
  208. package/dist/esm-node/utils/client-generator/generate.mjs +89 -0
  209. package/dist/esm-node/utils/client-generator/index.mjs +5 -0
  210. package/dist/esm-node/utils/client-generator/package-json.mjs +79 -0
  211. package/dist/esm-node/utils/client-generator/write-package.mjs +75 -0
  212. package/dist/esm-node/utils/clientGenerator.mjs +2 -293
  213. package/dist/esm-node/utils/effect-client-generator/generator.mjs +24 -0
  214. package/dist/esm-node/utils/effect-client-generator/index.mjs +4 -0
  215. package/dist/esm-node/utils/effect-client-generator/paths.mjs +26 -0
  216. package/dist/esm-node/utils/effect-client-generator/rendering.mjs +181 -0
  217. package/dist/esm-node/utils/effect-client-generator/runtime.mjs +35 -0
  218. package/dist/esm-node/utils/effect-client-generator/types.mjs +1 -0
  219. package/dist/esm-node/utils/effectClientGenerator.mjs +2 -251
  220. package/dist/types/cli/compress.d.ts +2 -0
  221. package/dist/types/cli/generator.d.ts +7 -0
  222. package/dist/types/cli/prefix.d.ts +2 -0
  223. package/dist/types/cli/watch.d.ts +1 -0
  224. package/dist/types/cli.d.ts +0 -1
  225. package/dist/types/runtime/data-platform/batch/queue.d.ts +25 -0
  226. package/dist/types/runtime/data-platform/batch/request.d.ts +13 -0
  227. package/dist/types/runtime/data-platform/batch/response.d.ts +4 -0
  228. package/dist/types/runtime/data-platform/batch/telemetry.d.ts +4 -0
  229. package/dist/types/runtime/data-platform/batch/url.d.ts +4 -0
  230. package/dist/types/runtime/data-platform/batch-transport.d.ts +3 -0
  231. package/dist/types/runtime/data-platform/codec.d.ts +17 -0
  232. package/dist/types/runtime/data-platform/index.d.ts +7 -191
  233. package/dist/types/runtime/data-platform/invalidation.d.ts +8 -0
  234. package/dist/types/runtime/data-platform/trace.d.ts +4 -0
  235. package/dist/types/runtime/data-platform/types.d.ts +146 -0
  236. package/dist/types/runtime/data-platform/validation.d.ts +29 -0
  237. package/dist/types/runtime/effect/adapter/constants.d.ts +1 -0
  238. package/dist/types/runtime/effect/adapter/cross-project-policy.d.ts +4 -0
  239. package/dist/types/runtime/effect/adapter/entry.d.ts +2 -0
  240. package/dist/types/runtime/effect/adapter/error-response.d.ts +2 -0
  241. package/dist/types/runtime/effect/adapter/handler.d.ts +4 -0
  242. package/dist/types/runtime/effect/adapter.d.ts +4 -13
  243. package/dist/types/runtime/effect/backend-federation/entry.d.ts +2 -0
  244. package/dist/types/runtime/effect/backend-federation/load.d.ts +2 -0
  245. package/dist/types/runtime/effect/backend-federation/plugin.d.ts +3 -0
  246. package/dist/types/runtime/effect/backend-federation/remotes.d.ts +2 -0
  247. package/dist/types/runtime/effect/backend-federation/runtime.d.ts +3 -0
  248. package/dist/types/runtime/effect/backend-federation/types.d.ts +58 -0
  249. package/dist/types/runtime/effect/backend-federation/utils.d.ts +2 -0
  250. package/dist/types/runtime/effect/backend-federation-manifest/errors.d.ts +11 -0
  251. package/dist/types/runtime/effect/backend-federation-manifest/index.d.ts +6 -0
  252. package/dist/types/runtime/effect/backend-federation-manifest/load.d.ts +3 -0
  253. package/dist/types/runtime/effect/backend-federation-manifest/metadata.d.ts +18 -0
  254. package/dist/types/runtime/effect/backend-federation-manifest/reference.d.ts +3 -0
  255. package/dist/types/runtime/effect/backend-federation-manifest/remote.d.ts +3 -0
  256. package/dist/types/runtime/effect/backend-federation-manifest/types.d.ts +51 -0
  257. package/dist/types/runtime/effect/backend-federation-manifest/validation.d.ts +5 -0
  258. package/dist/types/runtime/effect/backend-federation-manifest.d.ts +1 -60
  259. package/dist/types/runtime/effect/backend-federation.d.ts +6 -60
  260. package/dist/types/runtime/effect/handler/batch-handler.d.ts +11 -0
  261. package/dist/types/runtime/effect/handler/batch.d.ts +17 -0
  262. package/dist/types/runtime/effect/handler/definition.d.ts +17 -0
  263. package/dist/types/runtime/effect/handler/envelope.d.ts +13 -0
  264. package/dist/types/runtime/effect/handler/http.d.ts +14 -0
  265. package/dist/types/runtime/effect/handler/openapi.d.ts +4 -0
  266. package/dist/types/runtime/effect/handler/routing.d.ts +5 -0
  267. package/dist/types/runtime/effect/handler/rpc.d.ts +7 -0
  268. package/dist/types/runtime/effect/handler/types.d.ts +148 -0
  269. package/dist/types/runtime/effect/handler.d.ts +3 -173
  270. package/dist/types/runtime/effect/rpcSerialization.d.ts +3 -0
  271. package/dist/types/runtime/effect-client/batch.d.ts +2 -0
  272. package/dist/types/runtime/effect-client/envelope.d.ts +15 -0
  273. package/dist/types/runtime/effect-client/guards.d.ts +2 -0
  274. package/dist/types/runtime/effect-client/request-context.d.ts +3 -0
  275. package/dist/types/runtime/effect-client/request.d.ts +1 -0
  276. package/dist/types/runtime/effect-client/runtime.d.ts +2 -68
  277. package/dist/types/runtime/effect-client/types.d.ts +68 -0
  278. package/dist/types/utils/client-generator/files.d.ts +28 -0
  279. package/dist/types/utils/client-generator/generate.d.ts +26 -0
  280. package/dist/types/utils/client-generator/index.d.ts +7 -0
  281. package/dist/types/utils/client-generator/package-json.d.ts +16 -0
  282. package/dist/types/utils/client-generator/write-package.d.ts +6 -0
  283. package/dist/types/utils/clientGenerator.d.ts +2 -37
  284. package/dist/types/utils/crossProjectServerPolicy.d.ts +3 -2
  285. package/dist/types/utils/effect-client-generator/generator.d.ts +10 -0
  286. package/dist/types/utils/effect-client-generator/index.d.ts +4 -0
  287. package/dist/types/utils/effect-client-generator/paths.d.ts +5 -0
  288. package/dist/types/utils/effect-client-generator/rendering.d.ts +4 -0
  289. package/dist/types/utils/effect-client-generator/runtime.d.ts +8 -0
  290. package/dist/types/utils/effect-client-generator/types.d.ts +26 -0
  291. package/dist/types/utils/effectClientGenerator.d.ts +2 -41
  292. package/package.json +13 -13
@@ -1,507 +1,15 @@
1
1
  import "node:module";
2
- import * as __rspack_external_effect_Layer_16f7a8fc from "effect/Layer";
3
- import { HttpRouter, HttpServer, HttpServerResponse, HttpTraceContext } from "effect/unstable/http";
4
- import { HttpApiBuilder, OpenApi } from "effect/unstable/httpapi";
5
- import { RpcSerialization, RpcServer } from "effect/unstable/rpc";
6
- import { DEFAULT_DATA_BATCH_ENDPOINT, DEFAULT_DATA_BATCH_HEADER, DEFAULT_DATA_ENVELOPE_HEADER, decodeRequestEnvelopeHeader, validateRequestEnvelope, validateSelectionPlan } from "../data-platform/index.mjs";
7
- import { EFFECT_VALIDATOR_AWARE_FACTORY, isValidatorAwareHandlerFactory } from "./entry-shape.mjs";
8
2
  import * as __rspack_external_effect_Config_29be8a92 from "effect/Config";
9
3
  import * as __rspack_external_effect_Effect_194ac36c from "effect/Effect";
4
+ import * as __rspack_external_effect_Layer_16f7a8fc from "effect/Layer";
10
5
  import * as __rspack_external_effect_Option_4d691636 from "effect/Option";
11
6
  import * as __rspack_external_effect_Schema_f8472650 from "effect/Schema";
12
7
  export * from "effect/unstable/http";
13
8
  export * from "effect/unstable/httpapi";
14
9
  export * from "effect/unstable/rpc";
15
- import * as __rspack_external_effect_Context_f1289ca3 from "effect/Context";
16
- const emptyEffectServiceContext = __rspack_external_effect_Context_f1289ca3.empty();
17
- const isEffectServiceContext = (context)=>'object' == typeof context && null !== context && 'mapUnsafe' in context;
18
- const toEffectServiceContext = (context)=>isEffectServiceContext(context) ? context : emptyEffectServiceContext;
19
- function normalizeOpenApiPath(pathname) {
20
- if (!pathname.startsWith('/')) return `/${pathname}`;
21
- return pathname;
22
- }
23
- function getOpenApiOptions(openapi) {
24
- if (!openapi || 'object' != typeof openapi) return;
25
- if (!openapi.path) return;
26
- return {
27
- path: normalizeOpenApiPath(openapi.path)
28
- };
29
- }
30
- function normalizeRpcPath(pathname) {
31
- if (!pathname || '/' === pathname) return '/rpc';
32
- if (!pathname.startsWith('/')) return `/${pathname}`;
33
- return pathname;
34
- }
35
- function normalizeBatchPath(pathname) {
36
- if (!pathname || '/' === pathname) return DEFAULT_DATA_BATCH_ENDPOINT;
37
- if (!pathname.startsWith('/')) return `/${pathname}`;
38
- return pathname;
39
- }
40
- function isPlainObject(value) {
41
- return 'object' == typeof value && null !== value && !Array.isArray(value);
42
- }
43
- function toTextLength(value) {
44
- if ("u" > typeof TextEncoder) return new TextEncoder().encode(value).length;
45
- if ("u" > typeof Buffer) return Buffer.byteLength(value);
46
- return value.length;
47
- }
48
- function toHeaderRecord(headers) {
49
- const record = {};
50
- headers.forEach((value, key)=>{
51
- record[key] = value;
52
- });
53
- return record;
54
- }
55
- function normalizeItemMethod(method) {
56
- return (method || 'GET').toUpperCase();
57
- }
58
- function normalizeBatchAllowedMethods(allowedMethods) {
59
- const source = Array.isArray(allowedMethods) && allowedMethods.length > 0 ? allowedMethods : [
60
- 'GET'
61
- ];
62
- return new Set(source.map((method)=>method.toUpperCase()));
63
- }
64
- function isBatchRequestPayload(value) {
65
- return isPlainObject(value) && 1 === value.protocolVersion && 'string' == typeof value.batchId && 'number' == typeof value.sentAt && Array.isArray(value.items);
66
- }
67
- function createBatchValidationResponse(message, status = 400) {
68
- return new Response(JSON.stringify({
69
- message
70
- }), {
71
- status,
72
- headers: {
73
- 'content-type': 'application/json; charset=utf-8'
74
- }
75
- });
76
- }
77
- function createJsonValidationResponse(message, status = 400) {
78
- return new Response(JSON.stringify({
79
- message
80
- }), {
81
- status,
82
- headers: {
83
- 'content-type': 'application/json; charset=utf-8'
84
- }
85
- });
86
- }
87
- function cloneWithoutJsonBodyHeaders(request) {
88
- const headers = new Headers(request.headers);
89
- headers.delete('content-type');
90
- headers.delete('content-length');
91
- return new Request(request.url, {
92
- method: request.method,
93
- headers,
94
- signal: request.signal
95
- });
96
- }
97
- async function prepareJsonRequestBody(request) {
98
- const method = normalizeItemMethod(request.method);
99
- if ('GET' === method || 'HEAD' === method) return request;
100
- const contentType = (request.headers.get('content-type') || '').toLowerCase();
101
- if (!contentType.includes('application/json')) return request;
102
- if (null === request.body) return cloneWithoutJsonBodyHeaders(request);
103
- try {
104
- const bodyText = await request.clone().text();
105
- if ('' === bodyText) return cloneWithoutJsonBodyHeaders(request);
106
- JSON.parse(bodyText);
107
- } catch {
108
- return createJsonValidationResponse('Invalid JSON request body');
109
- }
110
- return request;
111
- }
112
- function toBatchItemError(id, status, message) {
113
- return {
114
- id,
115
- status,
116
- headers: {
117
- 'content-type': 'application/json; charset=utf-8'
118
- },
119
- body: JSON.stringify({
120
- message
121
- })
122
- };
123
- }
124
- function promiseWithTimeout(effect, timeoutMs) {
125
- if (timeoutMs <= 0) return effect;
126
- return new Promise((resolve, reject)=>{
127
- const timer = setTimeout(()=>{
128
- reject(new Error(`Batch item timeout after ${String(timeoutMs)}ms`));
129
- }, timeoutMs);
130
- effect.then((value)=>{
131
- clearTimeout(timer);
132
- resolve(value);
133
- }, (error)=>{
134
- clearTimeout(timer);
135
- reject(error);
136
- });
137
- });
138
- }
139
- async function mapWithConcurrency(items, concurrency, mapper) {
140
- if (0 === items.length) return [];
141
- const normalizedConcurrency = Math.max(1, concurrency);
142
- const output = new Array(items.length);
143
- let index = 0;
144
- const workers = Array.from({
145
- length: Math.min(normalizedConcurrency, items.length)
146
- }, async ()=>{
147
- while(true){
148
- const currentIndex = index;
149
- index += 1;
150
- if (currentIndex >= items.length) return;
151
- output[currentIndex] = await mapper(items[currentIndex], currentIndex);
152
- }
153
- });
154
- await Promise.all(workers);
155
- return output;
156
- }
157
- function getRequestPathname(request) {
158
- try {
159
- return new URL(request.url).pathname;
160
- } catch {
161
- return new URL(request.url, 'http://localhost').pathname;
162
- }
163
- }
164
- function normalizeMountPrefix(prefix) {
165
- if (!prefix || '/' === prefix) return '';
166
- return prefix.endsWith('/') ? prefix.slice(0, -1) : prefix;
167
- }
168
- function getMountedPrefixFromContext(request, context) {
169
- if (!isPlainObject(context) || 'string' != typeof context.path) return '';
170
- const contextPath = normalizeMountPrefix(context.path);
171
- const requestPath = normalizeMountPrefix(getRequestPathname(request));
172
- if (!contextPath || !requestPath || contextPath === requestPath || !contextPath.endsWith(requestPath)) return '';
173
- return normalizeMountPrefix(contextPath.slice(0, contextPath.length - requestPath.length));
174
- }
175
- function removeMountedPrefixFromBatchPath(pathWithQuery, prefix) {
176
- const normalizedPrefix = normalizeMountPrefix(prefix);
177
- if (!normalizedPrefix) return pathWithQuery;
178
- const [pathname, ...queryParts] = pathWithQuery.split('?');
179
- if (!pathname) return pathWithQuery;
180
- let nextPathname = pathname;
181
- if (pathname === normalizedPrefix) nextPathname = '/';
182
- else if (pathname.startsWith(`${normalizedPrefix}/`)) {
183
- const sliced = pathname.slice(normalizedPrefix.length);
184
- nextPathname = sliced.startsWith('/') ? sliced : `/${sliced}`;
185
- }
186
- if (0 === queryParts.length) return nextPathname;
187
- return `${nextPathname}?${queryParts.join('?')}`;
188
- }
189
- function getRequestOrigin(request) {
190
- try {
191
- return new URL(request.url).origin;
192
- } catch {
193
- return new URL(request.url, 'http://localhost').origin;
194
- }
195
- }
196
- function getExpectedEnvelopeOrigin(request) {
197
- const origin = request.headers.get('origin');
198
- if (origin && 'null' !== origin) return origin;
199
- return getRequestOrigin(request);
200
- }
201
- function isRpcRequest(request, rpcPath) {
202
- const pathname = getRequestPathname(request);
203
- return pathname === rpcPath || pathname.startsWith(`${rpcPath}/`);
204
- }
205
- function getRpcSerializationLayer(serialization) {
206
- switch(serialization){
207
- case 'ndjson':
208
- return RpcSerialization.layerNdjson;
209
- case 'jsonRpc':
210
- return RpcSerialization.layerJsonRpc();
211
- case 'ndJsonRpc':
212
- return RpcSerialization.layerNdJsonRpc();
213
- case 'msgPack':
214
- return RpcSerialization.layerMsgPack;
215
- default:
216
- return RpcSerialization.layerJsonRpc();
217
- }
218
- }
219
- function createRpcApiHandler(options) {
220
- const rpcPath = normalizeRpcPath(options.path);
221
- const rpcLayer = __rspack_external_effect_Layer_16f7a8fc.provide(RpcServer.layerHttp({
222
- group: options.group,
223
- path: rpcPath,
224
- protocol: 'http',
225
- disableTracing: options.disableTracing,
226
- spanPrefix: options.spanPrefix,
227
- spanAttributes: options.spanAttributes
228
- }), __rspack_external_effect_Layer_16f7a8fc.mergeAll(options.layer, getRpcSerializationLayer(options.serialization)));
229
- return HttpRouter.toWebHandler(rpcLayer);
230
- }
231
- function createOpenApiLayer(api, openapi) {
232
- const openApiOptions = getOpenApiOptions(openapi);
233
- if (!openApiOptions) return null;
234
- return HttpRouter.add('GET', openApiOptions.path, HttpServerResponse.jsonUnsafe(OpenApi.fromApi(api)));
235
- }
236
- function createInvalidEnvelopeResponse(message, errors) {
237
- return new Response(JSON.stringify({
238
- message,
239
- ...errors && errors.length > 0 ? {
240
- errors
241
- } : {}
242
- }), {
243
- status: 400,
244
- headers: {
245
- 'content-type': 'application/json; charset=utf-8'
246
- }
247
- });
248
- }
249
- function validateDataPlatformRequestEnvelope(request, options) {
250
- const isEnabled = options?.enabled ?? true;
251
- if (!isEnabled) return null;
252
- const envelopeHeader = options?.envelopeHeader || DEFAULT_DATA_ENVELOPE_HEADER;
253
- const encodedEnvelope = request.headers.get(envelopeHeader);
254
- if (!encodedEnvelope) {
255
- if (options?.requireEnvelope) return createInvalidEnvelopeResponse(`Missing required data envelope header: ${envelopeHeader}`);
256
- return null;
257
- }
258
- const envelope = decodeRequestEnvelopeHeader(encodedEnvelope);
259
- if (!envelope) return createInvalidEnvelopeResponse(`Invalid data envelope header format: ${envelopeHeader}`);
260
- const validation = validateRequestEnvelope(envelope, {
261
- expectedProtocolVersion: 1,
262
- expectedNamespace: options?.expectedNamespace,
263
- expectedOrigin: options?.validateOrigin === false ? void 0 : getExpectedEnvelopeOrigin(request),
264
- requireTraceContext: options?.requireTraceContext
265
- });
266
- if (!validation.ok) return createInvalidEnvelopeResponse('Invalid data envelope', validation.errors);
267
- if (envelope.selectionPlan) {
268
- const selectionValidation = validateSelectionPlan(envelope.selectionPlan, {
269
- maxDepth: options?.selection?.maxDepth,
270
- maxFields: options?.selection?.maxFields,
271
- allowedLeafPaths: options?.selection?.allowedLeafPaths
272
- });
273
- if (!selectionValidation.ok) return createInvalidEnvelopeResponse('Invalid data envelope selection plan', selectionValidation.errors);
274
- }
275
- return null;
276
- }
277
- function mergeDataPlatformOptions(base, override) {
278
- if (!base && !override) return;
279
- const baseSelection = base?.selection;
280
- const overrideSelection = override?.selection;
281
- const baseBatch = base?.batch;
282
- const overrideBatch = override?.batch;
283
- return {
284
- ...base,
285
- ...override,
286
- selection: baseSelection || overrideSelection ? {
287
- ...baseSelection,
288
- ...overrideSelection
289
- } : void 0,
290
- batch: baseBatch || overrideBatch ? {
291
- ...baseBatch,
292
- ...overrideBatch
293
- } : void 0
294
- };
295
- }
296
- function defineEffectBff(definition) {
297
- const createHandler = (options)=>{
298
- const rpcDefinition = definition.rpc;
299
- let mergedRpcOptions = rpcDefinition;
300
- if (rpcDefinition && options?.rpc) mergedRpcOptions = {
301
- ...rpcDefinition,
302
- ...options.rpc
303
- };
304
- return createHttpApiHandler({
305
- api: definition.api,
306
- layer: definition.layer,
307
- openapi: options?.openapi,
308
- rpc: mergedRpcOptions,
309
- dataPlatform: mergeDataPlatformOptions(definition.dataPlatform, options?.dataPlatform),
310
- validateRequest: options?.validateRequest
311
- });
312
- };
313
- Object.defineProperty(createHandler, EFFECT_VALIDATOR_AWARE_FACTORY, {
314
- value: true
315
- });
316
- const client = createLoaderMaterializedClientPlaceholder();
317
- return {
318
- ...definition,
319
- createHandler,
320
- client
321
- };
322
- }
323
- const LOADER_CLIENT_IGNORED_KEYS = new Set([
324
- 'then',
325
- 'catch',
326
- 'finally',
327
- 'toJSON',
328
- '$$typeof'
329
- ]);
330
- function createLoaderMaterializedClientPlaceholder() {
331
- const explain = (property)=>{
332
- throw new Error(`[BFF][Effect] client.${String(property)} is not available here: the typed client only exists when the API entry is imported through the "@api/index" transformed path (the BFF loader replaces it with generated client code). On the server, use HttpApiClient or call the Effect layer directly.`);
333
- };
334
- return new Proxy(Object.create(null), {
335
- get (_target, property) {
336
- if ('symbol' == typeof property || LOADER_CLIENT_IGNORED_KEYS.has(property)) return;
337
- return explain(property);
338
- }
339
- });
340
- }
341
- function defineEffectRpcBff(definition) {
342
- const createHandler = (options)=>createRpcApiHandler({
343
- ...definition,
344
- ...options
345
- });
346
- return {
347
- ...definition,
348
- createHandler
349
- };
350
- }
351
- function createHttpApiHandler(options) {
352
- const apiLayer = options.layer.pipe(__rspack_external_effect_Layer_16f7a8fc.provide(HttpServer.layerServices));
353
- const openApiLayer = createOpenApiLayer(options.api, options.openapi);
354
- const mergedLayer = openApiLayer ? __rspack_external_effect_Layer_16f7a8fc.mergeAll(apiLayer, openApiLayer) : apiLayer;
355
- const httpApiHandler = HttpRouter.toWebHandler(mergedLayer);
356
- const dataPlatformBatchOptions = options.dataPlatform?.batch;
357
- const batchEnabled = dataPlatformBatchOptions?.enabled !== false;
358
- const batchPath = normalizeBatchPath(dataPlatformBatchOptions?.endpoint);
359
- const batchMaxSize = Math.max(1, dataPlatformBatchOptions?.maxBatchSize ?? 16);
360
- const batchMaxBytes = Math.max(1024, dataPlatformBatchOptions?.maxBatchBytes ?? 65536);
361
- const batchConcurrency = Math.max(1, dataPlatformBatchOptions?.maxConcurrency ?? 4);
362
- const batchItemTimeoutMs = Math.max(0, dataPlatformBatchOptions?.requestTimeoutMs ?? 10000);
363
- const batchAllowedMethods = normalizeBatchAllowedMethods(dataPlatformBatchOptions?.allowedMethods);
364
- const envelopeHeader = options.dataPlatform?.envelopeHeader || DEFAULT_DATA_ENVELOPE_HEADER;
365
- const normalizedEnvelopeHeader = envelopeHeader.toLowerCase();
366
- const withDataPlatformValidation = async (request, context)=>{
367
- const policyDenial = options.validateRequest?.(request);
368
- if (policyDenial) return policyDenial;
369
- const preparedRequest = await prepareJsonRequestBody(request);
370
- if (preparedRequest instanceof Response) return preparedRequest;
371
- const validationError = validateDataPlatformRequestEnvelope(preparedRequest, options.dataPlatform);
372
- if (validationError) return validationError;
373
- return httpApiHandler.handler(preparedRequest, toEffectServiceContext(context));
374
- };
375
- const handleBatchRequest = async (request, context)=>{
376
- const mountedPrefix = getMountedPrefixFromContext(request, context);
377
- const method = normalizeItemMethod(request.method);
378
- if ('POST' !== method) return createBatchValidationResponse('Batch endpoint only supports POST requests', 405);
379
- const contentType = request.headers.get('content-type') || '';
380
- if (!contentType.includes('application/json')) return createBatchValidationResponse('Batch endpoint requires application/json content-type', 415);
381
- const payloadText = await request.text();
382
- if (toTextLength(payloadText) > batchMaxBytes) return createBatchValidationResponse(`Batch payload exceeds max size (${String(batchMaxBytes)} bytes)`, 413);
383
- let payload;
384
- try {
385
- payload = JSON.parse(payloadText);
386
- } catch {
387
- return createBatchValidationResponse('Invalid batch payload JSON');
388
- }
389
- if (!isBatchRequestPayload(payload)) return createBatchValidationResponse('Invalid batch payload shape');
390
- if (0 === payload.items.length) return createBatchValidationResponse('Batch payload items cannot be empty');
391
- if (payload.items.length > batchMaxSize) return createBatchValidationResponse(`Batch item count exceeds max size (${String(batchMaxSize)})`, 413);
392
- const responseItems = await mapWithConcurrency(payload.items, batchConcurrency, async (rawItem, index)=>{
393
- const fallbackId = `item_${String(index)}`;
394
- const itemId = isPlainObject(rawItem) && 'string' == typeof rawItem.id ? rawItem.id : fallbackId;
395
- if (!isPlainObject(rawItem)) return toBatchItemError(itemId, 400, 'Invalid batch item; expected object');
396
- if ('string' != typeof rawItem.path || 0 === rawItem.path.length) return toBatchItemError(itemId, 400, 'Invalid batch item path');
397
- if (!rawItem.path.startsWith('/')) return toBatchItemError(itemId, 400, 'Batch item path must start with "/"');
398
- const normalizedItemPath = removeMountedPrefixFromBatchPath(rawItem.path, mountedPrefix);
399
- const itemPathname = normalizedItemPath.split('?')[0] || normalizedItemPath;
400
- if (itemPathname === batchPath || itemPathname.startsWith(`${batchPath}/`)) return toBatchItemError(itemId, 400, 'Batch item path cannot target batch endpoint');
401
- const itemMethod = normalizeItemMethod('string' == typeof rawItem.method ? rawItem.method : void 0);
402
- if (!batchAllowedMethods.has(itemMethod)) return toBatchItemError(itemId, 405, `Batch item method ${itemMethod} is not allowed`);
403
- if (void 0 !== rawItem.body && null !== rawItem.body && 'string' != typeof rawItem.body) return toBatchItemError(itemId, 400, 'Batch item body must be a string when provided');
404
- if (('GET' === itemMethod || 'HEAD' === itemMethod) && 'string' == typeof rawItem.body) return toBatchItemError(itemId, 400, `${itemMethod} batch item cannot include body`);
405
- const normalizedHeaders = {};
406
- if (void 0 !== rawItem.headers) {
407
- if (!isPlainObject(rawItem.headers)) return toBatchItemError(itemId, 400, 'Batch item headers must be an object');
408
- for (const [key, value] of Object.entries(rawItem.headers)){
409
- if ('string' != typeof value) return toBatchItemError(itemId, 400, `Invalid header "${key}" for batch item`);
410
- normalizedHeaders[key.toLowerCase()] = value;
411
- }
412
- }
413
- if (!normalizedHeaders.traceparent) {
414
- const encodedEnvelope = normalizedHeaders[normalizedEnvelopeHeader];
415
- if ('string' == typeof encodedEnvelope) {
416
- const envelope = decodeRequestEnvelopeHeader(encodedEnvelope);
417
- if (envelope?.traceparent) normalizedHeaders.traceparent = envelope.traceparent;
418
- }
419
- }
420
- if (!normalizedHeaders.traceparent) {
421
- const requestTraceparent = request.headers.get('traceparent');
422
- if (requestTraceparent) normalizedHeaders.traceparent = requestTraceparent;
423
- }
424
- const targetUrl = new URL(normalizedItemPath, request.url);
425
- const requestHeaders = new Headers(normalizedHeaders);
426
- const body = 'GET' === itemMethod || 'HEAD' === itemMethod ? void 0 : rawItem.body;
427
- if (void 0 === body) requestHeaders.delete('content-type');
428
- const itemRequest = new Request(targetUrl.toString(), {
429
- method: itemMethod,
430
- headers: requestHeaders,
431
- body
432
- });
433
- try {
434
- const itemResponse = await promiseWithTimeout(withDataPlatformValidation(itemRequest, context), batchItemTimeoutMs);
435
- if (!(itemResponse instanceof Response)) return toBatchItemError(itemId, 500, 'Invalid response returned by batch item handler');
436
- const bodyText = await itemResponse.text();
437
- const responseItem = {
438
- id: itemId,
439
- status: itemResponse.status,
440
- headers: toHeaderRecord(itemResponse.headers),
441
- ...bodyText ? {
442
- body: bodyText
443
- } : {}
444
- };
445
- return responseItem;
446
- } catch (error) {
447
- if (error instanceof Response) {
448
- const bodyText = await error.text();
449
- return {
450
- id: itemId,
451
- status: error.status,
452
- headers: toHeaderRecord(error.headers),
453
- ...bodyText ? {
454
- body: bodyText
455
- } : {}
456
- };
457
- }
458
- const message = error instanceof Error ? error.message : String(error);
459
- return toBatchItemError(itemId, 500, message);
460
- }
461
- });
462
- const responsePayload = {
463
- protocolVersion: 1,
464
- batchId: payload.batchId,
465
- receivedAt: Date.now(),
466
- items: responseItems
467
- };
468
- return new Response(JSON.stringify(responsePayload), {
469
- status: 200,
470
- headers: {
471
- 'content-type': 'application/json; charset=utf-8',
472
- [DEFAULT_DATA_BATCH_HEADER]: '1',
473
- 'x-modernjs-data-batch-id': payload.batchId
474
- }
475
- });
476
- };
477
- const handleHttpApiRequest = async (request, context)=>{
478
- const pathname = getRequestPathname(request);
479
- if (batchEnabled && pathname === batchPath) return handleBatchRequest(request, context);
480
- return withDataPlatformValidation(request, context);
481
- };
482
- if (!options.rpc) return {
483
- handler: handleHttpApiRequest,
484
- dispose: async ()=>{
485
- await httpApiHandler.dispose();
486
- }
487
- };
488
- const rpcPath = normalizeRpcPath(options.rpc.path);
489
- const rpcHandler = createRpcApiHandler(options.rpc);
490
- return {
491
- handler: async (request, context)=>{
492
- if (isRpcRequest(request, rpcPath)) {
493
- const policyDenial = options.validateRequest?.(request);
494
- if (policyDenial) return policyDenial;
495
- return rpcHandler.handler(request, toEffectServiceContext(context));
496
- }
497
- return handleHttpApiRequest(request);
498
- },
499
- dispose: async ()=>{
500
- await Promise.all([
501
- httpApiHandler.dispose(),
502
- rpcHandler.dispose()
503
- ]);
504
- }
505
- };
506
- }
507
- export { EFFECT_VALIDATOR_AWARE_FACTORY, HttpApiBuilder, HttpTraceContext, __rspack_external_effect_Config_29be8a92 as Config, __rspack_external_effect_Effect_194ac36c as Effect, __rspack_external_effect_Layer_16f7a8fc as Layer, __rspack_external_effect_Option_4d691636 as Option, __rspack_external_effect_Schema_f8472650 as Schema, createHttpApiHandler, defineEffectBff, defineEffectRpcBff, isValidatorAwareHandlerFactory };
10
+ export { HttpTraceContext } from "effect/unstable/http";
11
+ export { HttpApiBuilder } from "effect/unstable/httpapi";
12
+ export { EFFECT_VALIDATOR_AWARE_FACTORY, isValidatorAwareHandlerFactory } from "./entry-shape.mjs";
13
+ export { defineEffectBff, defineEffectRpcBff } from "./handler/definition.mjs";
14
+ export { createHttpApiHandler } from "./handler/http.mjs";
15
+ export { __rspack_external_effect_Config_29be8a92 as Config, __rspack_external_effect_Effect_194ac36c as Effect, __rspack_external_effect_Layer_16f7a8fc as Layer, __rspack_external_effect_Option_4d691636 as Option, __rspack_external_effect_Schema_f8472650 as Schema };
@@ -0,0 +1,17 @@
1
+ import "node:module";
2
+ import { RpcSerialization } from "effect/unstable/rpc";
3
+ function getRpcSerializationLayer(serialization) {
4
+ switch(serialization){
5
+ case 'ndjson':
6
+ return RpcSerialization.layerNdjson;
7
+ case 'jsonRpc':
8
+ return RpcSerialization.layerJsonRpc();
9
+ case 'ndJsonRpc':
10
+ return RpcSerialization.layerNdJsonRpc();
11
+ case 'msgPack':
12
+ return RpcSerialization.layerMsgPack;
13
+ default:
14
+ return RpcSerialization.layerJsonRpc();
15
+ }
16
+ }
17
+ export { getRpcSerializationLayer };
@@ -0,0 +1,36 @@
1
+ import "node:module";
2
+ import { createDataBatchTransport } from "../data-platform/index.mjs";
3
+ import { resolveOrigin } from "./envelope.mjs";
4
+ const resolveRuntimeFetch = ()=>'function' == typeof fetch ? fetch.bind(globalThis) : void 0;
5
+ const configureGeneratedEffectClientRuntime = (config, configureRequest)=>{
6
+ const defaultOrigin = config.defaultOrigin;
7
+ if (config.requestId && configureRequest) {
8
+ const configurePayload = {
9
+ requestId: config.requestId,
10
+ requireEnvelope: true,
11
+ identityBinding: {
12
+ enabled: true,
13
+ strict: true
14
+ },
15
+ operationContract: {
16
+ enabled: true,
17
+ strict: true,
18
+ requireSchemaHash: true,
19
+ requireOperationVersion: true
20
+ },
21
+ setDomain: ()=>resolveOrigin(defaultOrigin)
22
+ };
23
+ const runtimeFetch = resolveRuntimeFetch();
24
+ if (false !== config.batch.enabled && runtimeFetch) configurePayload.request = createDataBatchTransport({
25
+ fetch: runtimeFetch,
26
+ endpoint: config.batch.endpoint,
27
+ flushIntervalMs: config.batch.flushIntervalMs,
28
+ maxBatchSize: config.batch.maxBatchSize,
29
+ maxBatchBytes: config.batch.maxBatchBytes,
30
+ requestTimeoutMs: config.batch.requestTimeoutMs,
31
+ allowedMethods: config.batch.allowedMethods
32
+ });
33
+ configureRequest(configurePayload);
34
+ }
35
+ };
36
+ export { configureGeneratedEffectClientRuntime };
@@ -0,0 +1,105 @@
1
+ import "node:module";
2
+ import { DEFAULT_DATA_BATCH_HEADER, DEFAULT_DATA_ENVELOPE_HEADER, createRequestEnvelope, encodeRequestEnvelopeHeader } from "../data-platform/index.mjs";
3
+ import { isRecord, stringOrUndefined } from "./guards.mjs";
4
+ import { normalizeRequest } from "./request.mjs";
5
+ import { applyRequestContext } from "./request-context.mjs";
6
+ const DATA_REQUEST_MODES = new Set([
7
+ 'cache-first',
8
+ 'stale-while-revalidate',
9
+ 'network-only'
10
+ ]);
11
+ const DATA_MUTATION_MODES = new Set([
12
+ 'optimistic',
13
+ 'pessimistic',
14
+ 'fire-and-forget'
15
+ ]);
16
+ const isDataRequestMode = (value)=>'string' == typeof value && DATA_REQUEST_MODES.has(value);
17
+ const isDataMutationMode = (value)=>'string' == typeof value && DATA_MUTATION_MODES.has(value);
18
+ const normalizeOrigin = (value)=>{
19
+ if ('string' != typeof value || 0 === value.length) return;
20
+ try {
21
+ return new URL(value).origin;
22
+ } catch {
23
+ return;
24
+ }
25
+ };
26
+ const resolveOrigin = (defaultOrigin)=>{
27
+ if ("u" > typeof window && window.location && 'string' == typeof window.location.origin && window.location.origin) return window.location.origin;
28
+ const globalLocation = globalThis?.location;
29
+ if (globalLocation && 'string' == typeof globalLocation.origin && globalLocation.origin) return globalLocation.origin;
30
+ return defaultOrigin;
31
+ };
32
+ const resolveTargetOrigin = (dataPlatform, defaultOrigin)=>{
33
+ const explicitTargetOrigin = stringOrUndefined(dataPlatform.targetOrigin) || stringOrUndefined(dataPlatform.endpointOrigin);
34
+ if (explicitTargetOrigin) return explicitTargetOrigin;
35
+ return defaultOrigin;
36
+ };
37
+ const shouldAttachEnvelopeHeader = (dataPlatform, defaultOrigin)=>{
38
+ if (true === dataPlatform.allowCrossOriginEnvelope) return true;
39
+ const currentOrigin = normalizeOrigin(resolveOrigin(defaultOrigin));
40
+ const targetOrigin = normalizeOrigin(resolveTargetOrigin(dataPlatform, defaultOrigin));
41
+ if (!currentOrigin || !targetOrigin) return true;
42
+ return currentOrigin === targetOrigin;
43
+ };
44
+ const toEnvelopeInput = (normalizedRequest)=>{
45
+ const payload = {};
46
+ if (isRecord(normalizedRequest.params)) payload.path = normalizedRequest.params;
47
+ if (isRecord(normalizedRequest.query)) payload.query = normalizedRequest.query;
48
+ if ('data' in normalizedRequest && void 0 !== normalizedRequest.data) payload.data = normalizedRequest.data;
49
+ if ('body' in normalizedRequest && void 0 !== normalizedRequest.body) payload.body = normalizedRequest.body;
50
+ if ("u" > typeof FormData && normalizedRequest.formData instanceof FormData) payload.formData = Array.from(normalizedRequest.formData.entries()).map(([key, value])=>[
51
+ key,
52
+ String(value)
53
+ ]);
54
+ if ("u" > typeof URLSearchParams && normalizedRequest.formUrlencoded instanceof URLSearchParams) payload.formUrlencoded = normalizedRequest.formUrlencoded.toString();
55
+ return payload;
56
+ };
57
+ const prepareEffectRequest = (options)=>{
58
+ const { endpoint, operation, request, config, createEffectRequestContext } = options;
59
+ const defaultOrigin = config.defaultOrigin;
60
+ const normalizedRequest = applyRequestContext(normalizeRequest(endpoint.method, request), request, createEffectRequestContext);
61
+ const dataPlatform = isRecord(request) && isRecord(request.dataPlatform) ? request.dataPlatform : {};
62
+ const strictEnvelope = true === dataPlatform.requireEnvelope || true === dataPlatform.strict;
63
+ if (!strictEnvelope && !shouldAttachEnvelopeHeader(dataPlatform, defaultOrigin)) return normalizedRequest;
64
+ try {
65
+ const namespace = stringOrUndefined(dataPlatform.appNamespace) || config.appNamespace;
66
+ const origin = stringOrUndefined(dataPlatform.origin) || resolveOrigin(defaultOrigin);
67
+ const envelope = createRequestEnvelope({
68
+ operation: {
69
+ ...operation,
70
+ appNamespace: namespace
71
+ },
72
+ scope: {
73
+ appNamespace: namespace,
74
+ origin,
75
+ tenantId: stringOrUndefined(dataPlatform.tenantId),
76
+ userId: stringOrUndefined(dataPlatform.userId),
77
+ sessionId: stringOrUndefined(dataPlatform.sessionId)
78
+ },
79
+ requestInput: {
80
+ method: endpoint.method,
81
+ routePath: endpoint.routePath,
82
+ payload: toEnvelopeInput(normalizedRequest)
83
+ },
84
+ requestMode: isDataRequestMode(dataPlatform.requestMode) ? dataPlatform.requestMode : void 0,
85
+ mutationMode: isDataMutationMode(dataPlatform.mutationMode) ? dataPlatform.mutationMode : void 0,
86
+ selectionPlan: isRecord(dataPlatform.selectionPlan) ? dataPlatform.selectionPlan : void 0,
87
+ traceContext: isRecord(dataPlatform.traceContext) ? dataPlatform.traceContext : void 0,
88
+ requireTraceContext: true === dataPlatform.requireTraceContext
89
+ });
90
+ const headerName = stringOrUndefined(dataPlatform.envelopeHeader) || DEFAULT_DATA_ENVELOPE_HEADER;
91
+ const headers = isRecord(normalizedRequest.headers) ? {
92
+ ...normalizedRequest.headers
93
+ } : {};
94
+ if (false === dataPlatform.batch) headers[DEFAULT_DATA_BATCH_HEADER] = 'off';
95
+ headers[headerName] = encodeRequestEnvelopeHeader(envelope);
96
+ return {
97
+ ...normalizedRequest,
98
+ headers
99
+ };
100
+ } catch (error) {
101
+ if (strictEnvelope) throw error;
102
+ return normalizedRequest;
103
+ }
104
+ };
105
+ export { prepareEffectRequest, resolveOrigin };
@@ -0,0 +1,4 @@
1
+ import "node:module";
2
+ const isRecord = (value)=>'object' == typeof value && null !== value;
3
+ const stringOrUndefined = (value)=>'string' == typeof value && value.length > 0 ? value : void 0;
4
+ export { isRecord, stringOrUndefined };