@bleedingdev/modern-js-plugin-bff 3.8.2-ultramodern.9 → 3.8.3-ultramodern.2

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 (348) hide show
  1. package/dist/cjs/cli/generator.js +45 -53
  2. package/dist/cjs/cli/serverGlobalVars.js +1 -1
  3. package/dist/cjs/cli.js +1 -0
  4. package/dist/cjs/loader.js +7 -18
  5. package/dist/cjs/runtime/data-platform/index.js +32 -94
  6. package/dist/cjs/runtime/effect/edge-dispatcher.js +5 -91
  7. package/dist/cjs/runtime/effect/edge.js +11 -45
  8. package/dist/cjs/runtime/effect/index.js +173 -55
  9. package/dist/cjs/runtime/effect-client/index.js +32 -166
  10. package/dist/cjs/runtime/effect-client/runtime.js +32 -70
  11. package/dist/cjs/runtime/hono/adapter.js +13 -54
  12. package/dist/cjs/server.js +2 -2
  13. package/dist/cjs/utils/client-generator/generate.js +11 -8
  14. package/dist/cjs/utils/client-generator/index.js +0 -3
  15. package/dist/cjs/utils/client-generator/type-facade.js +16 -10
  16. package/dist/cjs/utils/crossProjectApiPlugin.js +5 -1
  17. package/dist/cjs/utils/pluginGenerator.js +4 -4
  18. package/dist/cjs/utils/runtimeGenerator.js +4 -16
  19. package/dist/esm/cli/generator.mjs +45 -53
  20. package/dist/esm/cli/serverGlobalVars.mjs +1 -1
  21. package/dist/esm/cli.mjs +1 -0
  22. package/dist/esm/loader.mjs +5 -16
  23. package/dist/esm/runtime/data-platform/index.mjs +1 -7
  24. package/dist/esm/runtime/effect/edge-dispatcher.mjs +1 -38
  25. package/dist/esm/runtime/effect/edge.mjs +2 -2
  26. package/dist/esm/runtime/effect/index.mjs +16 -8
  27. package/dist/esm/runtime/effect-client/index.mjs +1 -98
  28. package/dist/esm/runtime/effect-client/runtime.mjs +1 -62
  29. package/dist/esm/runtime/hono/adapter.mjs +13 -54
  30. package/dist/esm/server.mjs +2 -2
  31. package/dist/esm/utils/client-generator/generate.mjs +11 -8
  32. package/dist/esm/utils/client-generator/index.mjs +1 -1
  33. package/dist/esm/utils/client-generator/type-facade.mjs +9 -6
  34. package/dist/esm/utils/crossProjectApiPlugin.mjs +3 -2
  35. package/dist/esm/utils/pluginGenerator.mjs +5 -5
  36. package/dist/esm/utils/runtimeGenerator.mjs +4 -16
  37. package/dist/esm-node/cli/generator.mjs +45 -53
  38. package/dist/esm-node/cli/serverGlobalVars.mjs +1 -1
  39. package/dist/esm-node/cli.mjs +1 -0
  40. package/dist/esm-node/loader.mjs +5 -16
  41. package/dist/esm-node/runtime/data-platform/index.mjs +1 -7
  42. package/dist/esm-node/runtime/effect/edge-dispatcher.mjs +1 -38
  43. package/dist/esm-node/runtime/effect/edge.mjs +2 -2
  44. package/dist/esm-node/runtime/effect/index.mjs +16 -8
  45. package/dist/esm-node/runtime/effect-client/index.mjs +1 -98
  46. package/dist/esm-node/runtime/effect-client/runtime.mjs +1 -62
  47. package/dist/esm-node/runtime/hono/adapter.mjs +13 -54
  48. package/dist/esm-node/server.mjs +2 -2
  49. package/dist/esm-node/utils/client-generator/generate.mjs +11 -8
  50. package/dist/esm-node/utils/client-generator/index.mjs +1 -1
  51. package/dist/esm-node/utils/client-generator/type-facade.mjs +9 -6
  52. package/dist/esm-node/utils/crossProjectApiPlugin.mjs +3 -2
  53. package/dist/esm-node/utils/pluginGenerator.mjs +5 -5
  54. package/dist/esm-node/utils/runtimeGenerator.mjs +4 -16
  55. package/dist/types/loader.d.ts +1 -0
  56. package/dist/types/runtime/data-platform/index.d.ts +1 -8
  57. package/dist/types/runtime/effect/edge-dispatcher.d.ts +1 -26
  58. package/dist/types/runtime/effect/edge.d.ts +2 -2
  59. package/dist/types/runtime/effect/index.d.ts +15 -7
  60. package/dist/types/runtime/effect-client/index.d.ts +1 -58
  61. package/dist/types/runtime/effect-client/runtime.d.ts +1 -5
  62. package/dist/types/runtime/hono/adapter.d.ts +1 -11
  63. package/dist/types/utils/client-generator/generate.d.ts +2 -1
  64. package/dist/types/utils/client-generator/index.d.ts +1 -1
  65. package/dist/types/utils/client-generator/type-facade.d.ts +2 -12
  66. package/dist/types/utils/crossProjectApiPlugin.d.ts +1 -0
  67. package/dist/types/utils/pluginGenerator.d.ts +2 -1
  68. package/package.json +34 -33
  69. package/dist/cjs/runtime/data-platform/batch/queue.js +0 -284
  70. package/dist/cjs/runtime/data-platform/batch/request.js +0 -98
  71. package/dist/cjs/runtime/data-platform/batch/response.js +0 -64
  72. package/dist/cjs/runtime/data-platform/batch/telemetry.js +0 -67
  73. package/dist/cjs/runtime/data-platform/batch/url.js +0 -69
  74. package/dist/cjs/runtime/data-platform/batch-transport.js +0 -59
  75. package/dist/cjs/runtime/data-platform/codec.js +0 -155
  76. package/dist/cjs/runtime/data-platform/invalidation.js +0 -61
  77. package/dist/cjs/runtime/data-platform/trace.js +0 -73
  78. package/dist/cjs/runtime/data-platform/types.js +0 -48
  79. package/dist/cjs/runtime/data-platform/validation.js +0 -178
  80. package/dist/cjs/runtime/effect/adapter/constants.js +0 -44
  81. package/dist/cjs/runtime/effect/adapter/cross-project-policy.js +0 -66
  82. package/dist/cjs/runtime/effect/adapter/entry.js +0 -100
  83. package/dist/cjs/runtime/effect/adapter/error-response.js +0 -81
  84. package/dist/cjs/runtime/effect/adapter/handler.js +0 -53
  85. package/dist/cjs/runtime/effect/adapter.js +0 -155
  86. package/dist/cjs/runtime/effect/backend-federation/entry.js +0 -99
  87. package/dist/cjs/runtime/effect/backend-federation/identity.js +0 -82
  88. package/dist/cjs/runtime/effect/backend-federation/load.js +0 -75
  89. package/dist/cjs/runtime/effect/backend-federation/plugin.js +0 -63
  90. package/dist/cjs/runtime/effect/backend-federation/remotes.js +0 -51
  91. package/dist/cjs/runtime/effect/backend-federation/runtime.js +0 -128
  92. package/dist/cjs/runtime/effect/backend-federation/types.js +0 -18
  93. package/dist/cjs/runtime/effect/backend-federation/utils.js +0 -48
  94. package/dist/cjs/runtime/effect/backend-federation-manifest/errors.js +0 -83
  95. package/dist/cjs/runtime/effect/backend-federation-manifest/index.js +0 -55
  96. package/dist/cjs/runtime/effect/backend-federation-manifest/load.js +0 -94
  97. package/dist/cjs/runtime/effect/backend-federation-manifest/metadata.js +0 -101
  98. package/dist/cjs/runtime/effect/backend-federation-manifest/reference.js +0 -120
  99. package/dist/cjs/runtime/effect/backend-federation-manifest/remote.js +0 -68
  100. package/dist/cjs/runtime/effect/backend-federation-manifest/types.js +0 -18
  101. package/dist/cjs/runtime/effect/backend-federation-manifest/validation.js +0 -109
  102. package/dist/cjs/runtime/effect/backend-federation-manifest.js +0 -62
  103. package/dist/cjs/runtime/effect/backend-federation.js +0 -65
  104. package/dist/cjs/runtime/effect/context.js +0 -60
  105. package/dist/cjs/runtime/effect/dispatch.js +0 -101
  106. package/dist/cjs/runtime/effect/edge-context.js +0 -81
  107. package/dist/cjs/runtime/effect/endpoint-contracts.js +0 -121
  108. package/dist/cjs/runtime/effect/entry-shape.js +0 -84
  109. package/dist/cjs/runtime/effect/handler/batch-handler.js +0 -161
  110. package/dist/cjs/runtime/effect/handler/batch.js +0 -159
  111. package/dist/cjs/runtime/effect/handler/definition.js +0 -102
  112. package/dist/cjs/runtime/effect/handler/envelope.js +0 -104
  113. package/dist/cjs/runtime/effect/handler/http.js +0 -107
  114. package/dist/cjs/runtime/effect/handler/openapi.js +0 -57
  115. package/dist/cjs/runtime/effect/handler/routing.js +0 -100
  116. package/dist/cjs/runtime/effect/handler/rpc.js +0 -63
  117. package/dist/cjs/runtime/effect/handler/types.js +0 -43
  118. package/dist/cjs/runtime/effect/handler.js +0 -189
  119. package/dist/cjs/runtime/effect/module.js +0 -113
  120. package/dist/cjs/runtime/effect/operation-context.js +0 -103
  121. package/dist/cjs/runtime/effect/rpcSerialization.js +0 -54
  122. package/dist/cjs/runtime/effect-client/batch.js +0 -73
  123. package/dist/cjs/runtime/effect-client/envelope.js +0 -145
  124. package/dist/cjs/runtime/effect-client/guards.js +0 -44
  125. package/dist/cjs/runtime/effect-client/request-context.js +0 -64
  126. package/dist/cjs/runtime/effect-client/request.js +0 -66
  127. package/dist/cjs/runtime/effect-client/types.js +0 -18
  128. package/dist/cjs/runtime/safe-failure.js +0 -84
  129. package/dist/cjs/utils/crossProjectServerPolicy.js +0 -98
  130. package/dist/cjs/utils/effect-client-generator/generator.js +0 -69
  131. package/dist/cjs/utils/effect-client-generator/index.js +0 -51
  132. package/dist/cjs/utils/effect-client-generator/paths.js +0 -62
  133. package/dist/cjs/utils/effect-client-generator/rendering.js +0 -220
  134. package/dist/cjs/utils/effect-client-generator/runtime.js +0 -68
  135. package/dist/cjs/utils/effect-client-generator/types.js +0 -18
  136. package/dist/cjs/utils/effectClientGenerator.js +0 -49
  137. package/dist/cjs/utils/effectSourceLoader.js +0 -312
  138. package/dist/cjs/utils/headers.js +0 -46
  139. package/dist/esm/runtime/data-platform/batch/queue.mjs +0 -246
  140. package/dist/esm/runtime/data-platform/batch/request.mjs +0 -45
  141. package/dist/esm/runtime/data-platform/batch/response.mjs +0 -23
  142. package/dist/esm/runtime/data-platform/batch/telemetry.mjs +0 -23
  143. package/dist/esm/runtime/data-platform/batch/url.mjs +0 -25
  144. package/dist/esm/runtime/data-platform/batch-transport.mjs +0 -12
  145. package/dist/esm/runtime/data-platform/codec.mjs +0 -90
  146. package/dist/esm/runtime/data-platform/invalidation.mjs +0 -20
  147. package/dist/esm/runtime/data-platform/trace.mjs +0 -29
  148. package/dist/esm/runtime/data-platform/types.mjs +0 -4
  149. package/dist/esm/runtime/data-platform/validation.mjs +0 -128
  150. package/dist/esm/runtime/effect/adapter/constants.mjs +0 -6
  151. package/dist/esm/runtime/effect/adapter/cross-project-policy.mjs +0 -28
  152. package/dist/esm/runtime/effect/adapter/entry.mjs +0 -52
  153. package/dist/esm/runtime/effect/adapter/error-response.mjs +0 -43
  154. package/dist/esm/runtime/effect/adapter/handler.mjs +0 -15
  155. package/dist/esm/runtime/effect/adapter.mjs +0 -107
  156. package/dist/esm/runtime/effect/backend-federation/entry.mjs +0 -61
  157. package/dist/esm/runtime/effect/backend-federation/identity.mjs +0 -41
  158. package/dist/esm/runtime/effect/backend-federation/load.mjs +0 -37
  159. package/dist/esm/runtime/effect/backend-federation/plugin.mjs +0 -25
  160. package/dist/esm/runtime/effect/backend-federation/remotes.mjs +0 -13
  161. package/dist/esm/runtime/effect/backend-federation/runtime.mjs +0 -90
  162. package/dist/esm/runtime/effect/backend-federation/types.mjs +0 -0
  163. package/dist/esm/runtime/effect/backend-federation/utils.mjs +0 -7
  164. package/dist/esm/runtime/effect/backend-federation-manifest/errors.mjs +0 -32
  165. package/dist/esm/runtime/effect/backend-federation-manifest/index.mjs +0 -4
  166. package/dist/esm/runtime/effect/backend-federation-manifest/load.mjs +0 -56
  167. package/dist/esm/runtime/effect/backend-federation-manifest/metadata.mjs +0 -42
  168. package/dist/esm/runtime/effect/backend-federation-manifest/reference.mjs +0 -76
  169. package/dist/esm/runtime/effect/backend-federation-manifest/remote.mjs +0 -30
  170. package/dist/esm/runtime/effect/backend-federation-manifest/types.mjs +0 -0
  171. package/dist/esm/runtime/effect/backend-federation-manifest/validation.mjs +0 -65
  172. package/dist/esm/runtime/effect/backend-federation-manifest.mjs +0 -1
  173. package/dist/esm/runtime/effect/backend-federation.mjs +0 -5
  174. package/dist/esm/runtime/effect/context.mjs +0 -13
  175. package/dist/esm/runtime/effect/dispatch.mjs +0 -63
  176. package/dist/esm/runtime/effect/edge-context.mjs +0 -34
  177. package/dist/esm/runtime/effect/endpoint-contracts.mjs +0 -68
  178. package/dist/esm/runtime/effect/entry-shape.mjs +0 -36
  179. package/dist/esm/runtime/effect/handler/batch-handler.mjs +0 -123
  180. package/dist/esm/runtime/effect/handler/batch.mjs +0 -97
  181. package/dist/esm/runtime/effect/handler/definition.mjs +0 -61
  182. package/dist/esm/runtime/effect/handler/envelope.mjs +0 -63
  183. package/dist/esm/runtime/effect/handler/http.mjs +0 -69
  184. package/dist/esm/runtime/effect/handler/openapi.mjs +0 -19
  185. package/dist/esm/runtime/effect/handler/routing.mjs +0 -50
  186. package/dist/esm/runtime/effect/handler/rpc.mjs +0 -22
  187. package/dist/esm/runtime/effect/handler/types.mjs +0 -5
  188. package/dist/esm/runtime/effect/handler.mjs +0 -14
  189. package/dist/esm/runtime/effect/module.mjs +0 -75
  190. package/dist/esm/runtime/effect/operation-context.mjs +0 -65
  191. package/dist/esm/runtime/effect/rpcSerialization.mjs +0 -16
  192. package/dist/esm/runtime/effect-client/batch.mjs +0 -35
  193. package/dist/esm/runtime/effect-client/envelope.mjs +0 -104
  194. package/dist/esm/runtime/effect-client/guards.mjs +0 -3
  195. package/dist/esm/runtime/effect-client/request-context.mjs +0 -23
  196. package/dist/esm/runtime/effect-client/request.mjs +0 -28
  197. package/dist/esm/runtime/effect-client/types.mjs +0 -0
  198. package/dist/esm/runtime/safe-failure.mjs +0 -46
  199. package/dist/esm/utils/crossProjectServerPolicy.mjs +0 -44
  200. package/dist/esm/utils/effect-client-generator/generator.mjs +0 -28
  201. package/dist/esm/utils/effect-client-generator/index.mjs +0 -3
  202. package/dist/esm/utils/effect-client-generator/paths.mjs +0 -24
  203. package/dist/esm/utils/effect-client-generator/rendering.mjs +0 -179
  204. package/dist/esm/utils/effect-client-generator/runtime.mjs +0 -27
  205. package/dist/esm/utils/effect-client-generator/types.mjs +0 -0
  206. package/dist/esm/utils/effectClientGenerator.mjs +0 -1
  207. package/dist/esm/utils/effectSourceLoader.mjs +0 -256
  208. package/dist/esm/utils/headers.mjs +0 -8
  209. package/dist/esm-node/runtime/data-platform/batch/queue.mjs +0 -247
  210. package/dist/esm-node/runtime/data-platform/batch/request.mjs +0 -46
  211. package/dist/esm-node/runtime/data-platform/batch/response.mjs +0 -24
  212. package/dist/esm-node/runtime/data-platform/batch/telemetry.mjs +0 -24
  213. package/dist/esm-node/runtime/data-platform/batch/url.mjs +0 -26
  214. package/dist/esm-node/runtime/data-platform/batch-transport.mjs +0 -13
  215. package/dist/esm-node/runtime/data-platform/codec.mjs +0 -91
  216. package/dist/esm-node/runtime/data-platform/invalidation.mjs +0 -21
  217. package/dist/esm-node/runtime/data-platform/trace.mjs +0 -30
  218. package/dist/esm-node/runtime/data-platform/types.mjs +0 -5
  219. package/dist/esm-node/runtime/data-platform/validation.mjs +0 -129
  220. package/dist/esm-node/runtime/effect/adapter/constants.mjs +0 -7
  221. package/dist/esm-node/runtime/effect/adapter/cross-project-policy.mjs +0 -29
  222. package/dist/esm-node/runtime/effect/adapter/entry.mjs +0 -53
  223. package/dist/esm-node/runtime/effect/adapter/error-response.mjs +0 -44
  224. package/dist/esm-node/runtime/effect/adapter/handler.mjs +0 -16
  225. package/dist/esm-node/runtime/effect/adapter.mjs +0 -108
  226. package/dist/esm-node/runtime/effect/backend-federation/entry.mjs +0 -62
  227. package/dist/esm-node/runtime/effect/backend-federation/identity.mjs +0 -42
  228. package/dist/esm-node/runtime/effect/backend-federation/load.mjs +0 -38
  229. package/dist/esm-node/runtime/effect/backend-federation/plugin.mjs +0 -26
  230. package/dist/esm-node/runtime/effect/backend-federation/remotes.mjs +0 -14
  231. package/dist/esm-node/runtime/effect/backend-federation/runtime.mjs +0 -91
  232. package/dist/esm-node/runtime/effect/backend-federation/types.mjs +0 -1
  233. package/dist/esm-node/runtime/effect/backend-federation/utils.mjs +0 -8
  234. package/dist/esm-node/runtime/effect/backend-federation-manifest/errors.mjs +0 -33
  235. package/dist/esm-node/runtime/effect/backend-federation-manifest/index.mjs +0 -5
  236. package/dist/esm-node/runtime/effect/backend-federation-manifest/load.mjs +0 -57
  237. package/dist/esm-node/runtime/effect/backend-federation-manifest/metadata.mjs +0 -43
  238. package/dist/esm-node/runtime/effect/backend-federation-manifest/reference.mjs +0 -77
  239. package/dist/esm-node/runtime/effect/backend-federation-manifest/remote.mjs +0 -31
  240. package/dist/esm-node/runtime/effect/backend-federation-manifest/types.mjs +0 -1
  241. package/dist/esm-node/runtime/effect/backend-federation-manifest/validation.mjs +0 -66
  242. package/dist/esm-node/runtime/effect/backend-federation-manifest.mjs +0 -2
  243. package/dist/esm-node/runtime/effect/backend-federation.mjs +0 -6
  244. package/dist/esm-node/runtime/effect/context.mjs +0 -14
  245. package/dist/esm-node/runtime/effect/dispatch.mjs +0 -64
  246. package/dist/esm-node/runtime/effect/edge-context.mjs +0 -35
  247. package/dist/esm-node/runtime/effect/endpoint-contracts.mjs +0 -69
  248. package/dist/esm-node/runtime/effect/entry-shape.mjs +0 -37
  249. package/dist/esm-node/runtime/effect/handler/batch-handler.mjs +0 -124
  250. package/dist/esm-node/runtime/effect/handler/batch.mjs +0 -98
  251. package/dist/esm-node/runtime/effect/handler/definition.mjs +0 -62
  252. package/dist/esm-node/runtime/effect/handler/envelope.mjs +0 -64
  253. package/dist/esm-node/runtime/effect/handler/http.mjs +0 -70
  254. package/dist/esm-node/runtime/effect/handler/openapi.mjs +0 -20
  255. package/dist/esm-node/runtime/effect/handler/routing.mjs +0 -51
  256. package/dist/esm-node/runtime/effect/handler/rpc.mjs +0 -23
  257. package/dist/esm-node/runtime/effect/handler/types.mjs +0 -6
  258. package/dist/esm-node/runtime/effect/handler.mjs +0 -15
  259. package/dist/esm-node/runtime/effect/module.mjs +0 -76
  260. package/dist/esm-node/runtime/effect/operation-context.mjs +0 -66
  261. package/dist/esm-node/runtime/effect/rpcSerialization.mjs +0 -17
  262. package/dist/esm-node/runtime/effect-client/batch.mjs +0 -36
  263. package/dist/esm-node/runtime/effect-client/envelope.mjs +0 -105
  264. package/dist/esm-node/runtime/effect-client/guards.mjs +0 -4
  265. package/dist/esm-node/runtime/effect-client/request-context.mjs +0 -24
  266. package/dist/esm-node/runtime/effect-client/request.mjs +0 -29
  267. package/dist/esm-node/runtime/effect-client/types.mjs +0 -1
  268. package/dist/esm-node/runtime/safe-failure.mjs +0 -47
  269. package/dist/esm-node/utils/crossProjectServerPolicy.mjs +0 -46
  270. package/dist/esm-node/utils/effect-client-generator/generator.mjs +0 -29
  271. package/dist/esm-node/utils/effect-client-generator/index.mjs +0 -4
  272. package/dist/esm-node/utils/effect-client-generator/paths.mjs +0 -25
  273. package/dist/esm-node/utils/effect-client-generator/rendering.mjs +0 -180
  274. package/dist/esm-node/utils/effect-client-generator/runtime.mjs +0 -29
  275. package/dist/esm-node/utils/effect-client-generator/types.mjs +0 -1
  276. package/dist/esm-node/utils/effectClientGenerator.mjs +0 -2
  277. package/dist/esm-node/utils/effectSourceLoader.mjs +0 -257
  278. package/dist/esm-node/utils/headers.mjs +0 -9
  279. package/dist/types/runtime/data-platform/batch/queue.d.ts +0 -8
  280. package/dist/types/runtime/data-platform/batch/request.d.ts +0 -13
  281. package/dist/types/runtime/data-platform/batch/response.d.ts +0 -3
  282. package/dist/types/runtime/data-platform/batch/telemetry.d.ts +0 -4
  283. package/dist/types/runtime/data-platform/batch/url.d.ts +0 -4
  284. package/dist/types/runtime/data-platform/batch-transport.d.ts +0 -3
  285. package/dist/types/runtime/data-platform/codec.d.ts +0 -17
  286. package/dist/types/runtime/data-platform/invalidation.d.ts +0 -8
  287. package/dist/types/runtime/data-platform/trace.d.ts +0 -4
  288. package/dist/types/runtime/data-platform/types.d.ts +0 -146
  289. package/dist/types/runtime/data-platform/validation.d.ts +0 -29
  290. package/dist/types/runtime/effect/adapter/constants.d.ts +0 -1
  291. package/dist/types/runtime/effect/adapter/cross-project-policy.d.ts +0 -4
  292. package/dist/types/runtime/effect/adapter/entry.d.ts +0 -2
  293. package/dist/types/runtime/effect/adapter/error-response.d.ts +0 -2
  294. package/dist/types/runtime/effect/adapter/handler.d.ts +0 -7
  295. package/dist/types/runtime/effect/adapter.d.ts +0 -22
  296. package/dist/types/runtime/effect/backend-federation/entry.d.ts +0 -2
  297. package/dist/types/runtime/effect/backend-federation/identity.d.ts +0 -30
  298. package/dist/types/runtime/effect/backend-federation/load.d.ts +0 -13
  299. package/dist/types/runtime/effect/backend-federation/plugin.d.ts +0 -3
  300. package/dist/types/runtime/effect/backend-federation/remotes.d.ts +0 -2
  301. package/dist/types/runtime/effect/backend-federation/runtime.d.ts +0 -3
  302. package/dist/types/runtime/effect/backend-federation/types.d.ts +0 -73
  303. package/dist/types/runtime/effect/backend-federation/utils.d.ts +0 -2
  304. package/dist/types/runtime/effect/backend-federation-manifest/errors.d.ts +0 -11
  305. package/dist/types/runtime/effect/backend-federation-manifest/index.d.ts +0 -6
  306. package/dist/types/runtime/effect/backend-federation-manifest/load.d.ts +0 -3
  307. package/dist/types/runtime/effect/backend-federation-manifest/metadata.d.ts +0 -18
  308. package/dist/types/runtime/effect/backend-federation-manifest/reference.d.ts +0 -4
  309. package/dist/types/runtime/effect/backend-federation-manifest/remote.d.ts +0 -3
  310. package/dist/types/runtime/effect/backend-federation-manifest/types.d.ts +0 -51
  311. package/dist/types/runtime/effect/backend-federation-manifest/validation.d.ts +0 -5
  312. package/dist/types/runtime/effect/backend-federation-manifest.d.ts +0 -1
  313. package/dist/types/runtime/effect/backend-federation.d.ts +0 -7
  314. package/dist/types/runtime/effect/context.d.ts +0 -5
  315. package/dist/types/runtime/effect/dispatch.d.ts +0 -13
  316. package/dist/types/runtime/effect/edge-context.d.ts +0 -5
  317. package/dist/types/runtime/effect/endpoint-contracts.d.ts +0 -66
  318. package/dist/types/runtime/effect/entry-shape.d.ts +0 -31
  319. package/dist/types/runtime/effect/handler/batch-handler.d.ts +0 -11
  320. package/dist/types/runtime/effect/handler/batch.d.ts +0 -13
  321. package/dist/types/runtime/effect/handler/definition.d.ts +0 -7
  322. package/dist/types/runtime/effect/handler/envelope.d.ts +0 -13
  323. package/dist/types/runtime/effect/handler/http.d.ts +0 -15
  324. package/dist/types/runtime/effect/handler/openapi.d.ts +0 -4
  325. package/dist/types/runtime/effect/handler/routing.d.ts +0 -5
  326. package/dist/types/runtime/effect/handler/rpc.d.ts +0 -7
  327. package/dist/types/runtime/effect/handler/types.d.ts +0 -153
  328. package/dist/types/runtime/effect/handler.d.ts +0 -14
  329. package/dist/types/runtime/effect/module.d.ts +0 -36
  330. package/dist/types/runtime/effect/operation-context.d.ts +0 -10
  331. package/dist/types/runtime/effect/rpcSerialization.d.ts +0 -3
  332. package/dist/types/runtime/effect-client/batch.d.ts +0 -2
  333. package/dist/types/runtime/effect-client/envelope.d.ts +0 -15
  334. package/dist/types/runtime/effect-client/guards.d.ts +0 -2
  335. package/dist/types/runtime/effect-client/request-context.d.ts +0 -3
  336. package/dist/types/runtime/effect-client/request.d.ts +0 -1
  337. package/dist/types/runtime/effect-client/types.d.ts +0 -68
  338. package/dist/types/runtime/safe-failure.d.ts +0 -1
  339. package/dist/types/utils/crossProjectServerPolicy.d.ts +0 -36
  340. package/dist/types/utils/effect-client-generator/generator.d.ts +0 -10
  341. package/dist/types/utils/effect-client-generator/index.d.ts +0 -4
  342. package/dist/types/utils/effect-client-generator/paths.d.ts +0 -5
  343. package/dist/types/utils/effect-client-generator/rendering.d.ts +0 -4
  344. package/dist/types/utils/effect-client-generator/runtime.d.ts +0 -12
  345. package/dist/types/utils/effect-client-generator/types.d.ts +0 -27
  346. package/dist/types/utils/effectClientGenerator.d.ts +0 -2
  347. package/dist/types/utils/effectSourceLoader.d.ts +0 -25
  348. package/dist/types/utils/headers.d.ts +0 -1
@@ -1,128 +0,0 @@
1
- import { buildScopeKey, createOperationId, hashString, isPlainObject, normalizeOrigin, sanitizeSegment, stableStringify } from "./codec.mjs";
2
- import { formatTraceparentHeader, parseTraceparentHeader } from "./trace.mjs";
3
- function validateSelectionPlan(plan, options = {}) {
4
- const maxDepthLimit = options.maxDepth ?? 8;
5
- const maxFieldsLimit = options.maxFields ?? 256;
6
- const allowedLeafPaths = options.allowedLeafPaths ? new Set(options.allowedLeafPaths) : null;
7
- const errors = [];
8
- let maxDepth = 0;
9
- let fieldCount = 0;
10
- const walk = (node, path)=>{
11
- if (!isPlainObject(node)) return void errors.push(`Selection node at "${path.join('.') || '<root>'}" must be an object`);
12
- const keys = Object.keys(node);
13
- if (0 === keys.length) return void errors.push(`Selection node at "${path.join('.') || '<root>'}" cannot be empty`);
14
- for (const key of keys){
15
- fieldCount += 1;
16
- if (fieldCount > maxFieldsLimit) return void errors.push(`Selection has too many fields: ${String(fieldCount)} > ${String(maxFieldsLimit)}`);
17
- const nextPath = [
18
- ...path,
19
- key
20
- ];
21
- const depth = nextPath.length;
22
- if (depth > maxDepth) maxDepth = depth;
23
- if (depth > maxDepthLimit) return void errors.push(`Selection exceeds maxDepth at "${nextPath.join('.')}" (${String(depth)} > ${String(maxDepthLimit)})`);
24
- const value = node[key];
25
- if (true === value) {
26
- if (allowedLeafPaths && !allowedLeafPaths.has(nextPath.join('.'))) errors.push(`Unknown selected field "${nextPath.join('.')}"`);
27
- continue;
28
- }
29
- if (!isPlainObject(value)) {
30
- errors.push(`Invalid selection value at "${nextPath.join('.')}"; expected true or nested object`);
31
- continue;
32
- }
33
- walk(value, nextPath);
34
- }
35
- };
36
- walk(plan, []);
37
- return {
38
- ok: 0 === errors.length,
39
- errors,
40
- stats: {
41
- maxDepth,
42
- fieldCount
43
- }
44
- };
45
- }
46
- function createRequestEnvelope(input) {
47
- if (input.requireTraceContext && !input.traceContext) throw new Error('Trace context is required for this request envelope');
48
- const traceparent = input.traceContext ? formatTraceparentHeader(input.traceContext) : void 0;
49
- const envelope = {
50
- protocolVersion: input.protocolVersion ?? 1,
51
- operationId: createOperationId(input.operation),
52
- appNamespace: sanitizeSegment(input.scope.appNamespace),
53
- origin: normalizeOrigin(input.scope.origin),
54
- requestMode: input.requestMode ?? 'cache-first',
55
- mutationMode: input.mutationMode,
56
- scopeKey: buildScopeKey(input.scope),
57
- input: input.requestInput,
58
- inputHash: hashString(stableStringify(input.requestInput ?? null)),
59
- selectionPlan: input.selectionPlan,
60
- selectionHash: input.selectionPlan ? hashString(stableStringify(input.selectionPlan)) : void 0,
61
- traceparent,
62
- timestamp: input.timestamp ?? Date.now()
63
- };
64
- return envelope;
65
- }
66
- function validateRequestEnvelope(envelope, options = {}) {
67
- const errors = [];
68
- if (void 0 !== options.expectedProtocolVersion && envelope.protocolVersion !== options.expectedProtocolVersion) errors.push(`Protocol mismatch: expected ${String(options.expectedProtocolVersion)} but received ${String(envelope.protocolVersion)}`);
69
- if (options.expectedNamespace && envelope.appNamespace !== options.expectedNamespace) errors.push(`Namespace mismatch: expected ${options.expectedNamespace} but received ${envelope.appNamespace}`);
70
- if (options.expectedOrigin) {
71
- const expectedOrigin = normalizeOrigin(options.expectedOrigin);
72
- if (envelope.origin !== expectedOrigin) errors.push(`Origin mismatch: expected ${expectedOrigin} but received ${envelope.origin}`);
73
- }
74
- if (!envelope.operationId) errors.push('Missing operationId');
75
- if (!envelope.scopeKey) errors.push('Missing scopeKey');
76
- if (options.requireTraceContext && !envelope.traceparent) errors.push('Missing trace context');
77
- if (envelope.traceparent && !parseTraceparentHeader(envelope.traceparent)) errors.push('Invalid traceparent header');
78
- const computedInputHash = hashString(stableStringify(envelope.input ?? null));
79
- if (computedInputHash !== envelope.inputHash) errors.push('Input hash mismatch');
80
- if (envelope.selectionPlan) {
81
- const computedSelectionHash = hashString(stableStringify(envelope.selectionPlan));
82
- if (computedSelectionHash !== envelope.selectionHash) errors.push('Selection hash mismatch');
83
- }
84
- return {
85
- ok: 0 === errors.length,
86
- errors
87
- };
88
- }
89
- function createHydrationEnvelope(input) {
90
- const envelopeWithoutChecksum = {
91
- protocolVersion: input.protocolVersion ?? 1,
92
- runtimeVersion: input.runtimeVersion,
93
- appNamespace: sanitizeSegment(input.scope.appNamespace),
94
- origin: normalizeOrigin(input.scope.origin),
95
- createdAt: input.createdAt ?? Date.now(),
96
- payload: input.payload
97
- };
98
- const checksum = hashString(stableStringify(envelopeWithoutChecksum));
99
- return {
100
- ...envelopeWithoutChecksum,
101
- checksum
102
- };
103
- }
104
- function validateHydrationEnvelope(envelope, options = {}) {
105
- const errors = [];
106
- if (void 0 !== options.expectedProtocolVersion && envelope.protocolVersion !== options.expectedProtocolVersion) errors.push(`Protocol mismatch: expected ${String(options.expectedProtocolVersion)} but received ${String(envelope.protocolVersion)}`);
107
- if (options.expectedNamespace && envelope.appNamespace !== options.expectedNamespace) errors.push(`Namespace mismatch: expected ${options.expectedNamespace} but received ${envelope.appNamespace}`);
108
- if (options.expectedOrigin) {
109
- const expectedOrigin = normalizeOrigin(options.expectedOrigin);
110
- if (envelope.origin !== expectedOrigin) errors.push(`Origin mismatch: expected ${expectedOrigin} but received ${envelope.origin}`);
111
- }
112
- if (options.expectedRuntimeVersion && envelope.runtimeVersion !== options.expectedRuntimeVersion) errors.push(`Runtime version mismatch: expected ${options.expectedRuntimeVersion} but received ${envelope.runtimeVersion}`);
113
- const checksumBase = {
114
- protocolVersion: envelope.protocolVersion,
115
- runtimeVersion: envelope.runtimeVersion,
116
- appNamespace: envelope.appNamespace,
117
- origin: envelope.origin,
118
- createdAt: envelope.createdAt,
119
- payload: envelope.payload
120
- };
121
- const checksum = hashString(stableStringify(checksumBase));
122
- if (checksum !== envelope.checksum) errors.push('Hydration checksum mismatch');
123
- return {
124
- ok: 0 === errors.length,
125
- errors
126
- };
127
- }
128
- export { createHydrationEnvelope, createRequestEnvelope, validateHydrationEnvelope, validateRequestEnvelope, validateSelectionPlan };
@@ -1,6 +0,0 @@
1
- const before = [
2
- 'custom-server-hook',
3
- 'custom-server-middleware',
4
- 'render'
5
- ];
6
- export { before };
@@ -1,28 +0,0 @@
1
- import { logger } from "@modern-js/utils";
2
- import { HttpApi } from "effect/unstable/httpapi";
3
- import { resolveAdapterCrossProjectPolicy } from "../../../utils/crossProjectServerPolicy.mjs";
4
- import { collectEffectEndpoints, extractHttpApiFromModule, toOperationContractSources } from "../endpoint-contracts.mjs";
5
- function resolveEffectAdapterCrossProjectPolicy(api, prefix, mod) {
6
- const contractSourcesPromise = null === mod ? Promise.resolve([]) : Promise.resolve().then(()=>extractHttpApiFromModule(mod, HttpApi.isHttpApi)).then((effectApi)=>{
7
- if (null !== effectApi) {
8
- const reflect = (apiValue, handlers)=>{
9
- if (!HttpApi.isHttpApi(apiValue)) throw new Error('[BFF][Effect] Endpoint reflection received a non-HttpApi value.');
10
- HttpApi.reflect(apiValue, {
11
- onGroup: handlers.onGroup ?? (()=>{}),
12
- onEndpoint: handlers.onEndpoint
13
- });
14
- };
15
- return toOperationContractSources(collectEffectEndpoints(reflect, effectApi, prefix));
16
- }
17
- return [];
18
- }).catch((error)=>{
19
- logger.warn(`[BFF][Effect] Failed reflect HttpApi endpoints cross-project policy: ${String(error)}`);
20
- return [];
21
- });
22
- return contractSourcesPromise.then((contractSources)=>{
23
- const policy = resolveAdapterCrossProjectPolicy(api, contractSources);
24
- if (policy?.enabled === true && 0 === contractSources.length) logger.warn('[BFF][Effect] Cross-project policy enabled but no HttpApi endpoints could be reflected; requests fail operation-contract matching unless allowUnknownOperations is enabled.');
25
- return policy;
26
- });
27
- }
28
- export { resolveEffectAdapterCrossProjectPolicy };
@@ -1,52 +0,0 @@
1
- import { API_DIR, findExists, fs, isProd } from "@modern-js/utils";
2
- import path from "path";
3
- const JS_OR_TS_EXTS = [
4
- '.js',
5
- '.jsx',
6
- '.ts',
7
- '.tsx',
8
- '.mjs',
9
- '.mts',
10
- '.cjs',
11
- '.cts'
12
- ];
13
- function resolveJsOrTsEntry(entryWithoutOrWithExt) {
14
- const extension = path.extname(entryWithoutOrWithExt);
15
- if (JS_OR_TS_EXTS.includes(extension)) return fs.existsSync(entryWithoutOrWithExt) ? entryWithoutOrWithExt : void 0;
16
- return findExists(JS_OR_TS_EXTS.map((ext)=>`${entryWithoutOrWithExt}${ext}`)) || void 0;
17
- }
18
- function builtEntryPath(entryPath) {
19
- return entryPath.replace(/\.(?:[cm]?ts|tsx|jsx)$/u, '.js');
20
- }
21
- function relativeAppPath(appDirectory, entryPath) {
22
- const relativePath = path.relative(appDirectory, entryPath);
23
- return '..' === relativePath || relativePath.startsWith(`..${path.sep}`) ? void 0 : relativePath;
24
- }
25
- function isDependencyPath(relativePath) {
26
- return relativePath?.split(/[\\/]/u).includes('node_modules') ?? false;
27
- }
28
- function resolveEffectAdapterEntryFile(api) {
29
- const { appDirectory, apiDirectory, distDirectory } = api.getServerContext();
30
- const appRoot = path.resolve(appDirectory || process.cwd());
31
- const productionRoot = isProd() && distDirectory ? path.resolve(distDirectory) : void 0;
32
- const bffConfig = api.getServerConfig()?.bff;
33
- const configuredEntry = bffConfig?.effect?.entry;
34
- if (configuredEntry) {
35
- const sourceEntry = path.isAbsolute(configuredEntry) ? configuredEntry : path.resolve(appRoot, configuredEntry);
36
- if (productionRoot) {
37
- const relativeEntry = relativeAppPath(appRoot, sourceEntry);
38
- if (void 0 === relativeEntry || isDependencyPath(relativeEntry)) return resolveJsOrTsEntry(sourceEntry);
39
- return relativeEntry ? resolveJsOrTsEntry(builtEntryPath(path.resolve(productionRoot, relativeEntry))) : void 0;
40
- }
41
- return resolveJsOrTsEntry(sourceEntry);
42
- }
43
- const resolvedApiDirectory = path.resolve(appRoot, apiDirectory || API_DIR);
44
- const productionApiDirectory = productionRoot ? void 0 !== relativeAppPath(productionRoot, resolvedApiDirectory) ? resolvedApiDirectory : (()=>{
45
- const relativeApiDirectory = relativeAppPath(appRoot, resolvedApiDirectory);
46
- if (isDependencyPath(relativeApiDirectory)) return resolvedApiDirectory;
47
- return relativeApiDirectory ? path.resolve(productionRoot, relativeApiDirectory) : void 0;
48
- })() : resolvedApiDirectory;
49
- if (!productionApiDirectory) return;
50
- return resolveJsOrTsEntry(path.resolve(productionApiDirectory, 'index'));
51
- }
52
- export { resolveEffectAdapterEntryFile };
@@ -1,43 +0,0 @@
1
- import { logger } from "@modern-js/utils";
2
- import { createSafeFailureResponse } from "../../safe-failure.mjs";
3
- function createEffectAdapterRuntimeErrorResponse(api, error, c) {
4
- try {
5
- const serverConfig = api.getServerConfig();
6
- const onErrorHandler = serverConfig?.onError;
7
- if (void 0 !== onErrorHandler) {
8
- const onErrorContext = ensureJsonContext(c);
9
- return Promise.resolve(onErrorHandler(error instanceof Error ? error : new Error(String(error)), onErrorContext)).then((result)=>result instanceof Response ? result : createSafeFailureResponse(error)).catch((configError)=>{
10
- logger.error(`Error in serverConfig.onError handler: ${String(configError)}`);
11
- return createSafeFailureResponse(error);
12
- });
13
- }
14
- logger.error(error instanceof Error ? error : new Error(String(error)));
15
- } catch (configError) {
16
- logger.error(`Error in serverConfig.onError handler: ${configError}`);
17
- }
18
- return Promise.resolve(createSafeFailureResponse(error));
19
- }
20
- function ensureJsonContext(c) {
21
- if ('json' in c && 'function' == typeof c.json) return c;
22
- const headers = {
23
- 'content-type': 'application/json; charset=utf-8'
24
- };
25
- const withJson = Object.assign({}, c, {
26
- json (data, statusOrInit = 200, extraHeaders) {
27
- const responseInit = 'number' == typeof statusOrInit ? {
28
- status: statusOrInit,
29
- headers: extraHeaders
30
- } : statusOrInit;
31
- const responseHeaders = new Headers(headers);
32
- if (void 0 !== responseInit.headers) new Headers(responseInit.headers).forEach((value, key)=>{
33
- responseHeaders.set(key, value);
34
- });
35
- return new Response(JSON.stringify(data), {
36
- ...responseInit,
37
- headers: responseHeaders
38
- });
39
- }
40
- });
41
- return withJson;
42
- }
43
- export { createEffectAdapterRuntimeErrorResponse };
@@ -1,15 +0,0 @@
1
- import { logger } from "@modern-js/utils";
2
- import { checkCrossProjectPolicyForRequest } from "../../../utils/crossProjectServerPolicy.mjs";
3
- import { resolveEffectBffModuleHandler } from "../module.mjs";
4
- async function loadEffectAdapterHandlerFromModule(api, mod, crossProjectPolicy) {
5
- const effectConfig = api.getServerConfig()?.bff?.effect;
6
- return resolveEffectBffModuleHandler(mod, {
7
- openapi: effectConfig?.openapi,
8
- dataPlatform: effectConfig?.dataPlatform,
9
- validateRequest: (request)=>checkCrossProjectPolicyForRequest(request, crossProjectPolicy),
10
- onWarning: (message)=>{
11
- logger.warn(message);
12
- }
13
- });
14
- }
15
- export { loadEffectAdapterHandlerFromModule };
@@ -1,107 +0,0 @@
1
- import { fs, isProd, logger } from "@modern-js/utils";
2
- import path from "path";
3
- import { loadEffectBuiltModule, loadEffectSourceModule } from "../../utils/effectSourceLoader.mjs";
4
- import { before } from "./adapter/constants.mjs";
5
- import { resolveEffectAdapterCrossProjectPolicy } from "./adapter/cross-project-policy.mjs";
6
- import { resolveEffectAdapterEntryFile } from "./adapter/entry.mjs";
7
- import { createEffectAdapterRuntimeErrorResponse } from "./adapter/error-response.mjs";
8
- import { loadEffectAdapterHandlerFromModule } from "./adapter/handler.mjs";
9
- import { runWithEffectContext } from "./context.mjs";
10
- import { dispatchEffectBffRequestWithContext } from "./dispatch.mjs";
11
- class EffectAdapter {
12
- resolveEntryFile() {
13
- return resolveEffectAdapterEntryFile(this.api);
14
- }
15
- async reloadHandler() {
16
- if (!this.isEffect) return;
17
- const entryFile = this.resolveEntryFile();
18
- if (!entryFile) {
19
- await this.disposeCurrentHandler();
20
- this.handler = null;
21
- return;
22
- }
23
- if (!await fs.pathExists(entryFile)) {
24
- await this.disposeCurrentHandler();
25
- this.handler = null;
26
- return;
27
- }
28
- await this.disposeCurrentHandler();
29
- let mod;
30
- try {
31
- const { appDirectory } = this.api.getServerContext();
32
- mod = await (isProd() ? loadEffectBuiltModule(entryFile) : loadEffectSourceModule({
33
- resourcePath: entryFile,
34
- appDir: appDirectory || path.dirname(entryFile)
35
- }));
36
- } catch (error) {
37
- logger.error(`[BFF][Effect] Failed to load Effect entry: ${entryFile}\n${String(error)}`);
38
- this.handler = null;
39
- return;
40
- }
41
- this.crossProjectPolicy = await resolveEffectAdapterCrossProjectPolicy(this.api, this.prefix, mod);
42
- const loaded = await loadEffectAdapterHandlerFromModule(this.api, mod, this.crossProjectPolicy);
43
- if (!loaded) {
44
- logger.warn(`[BFF][Effect] Invalid Effect entry module: ${entryFile}. Export defineEffectBff(...) or a { api, layer } HttpApi module.`);
45
- this.handler = null;
46
- return;
47
- }
48
- this.handler = loaded.handler;
49
- this.dispose = loaded.dispose || null;
50
- }
51
- async disposeCurrentHandler() {
52
- if (!this.dispose) return;
53
- try {
54
- await this.dispose();
55
- } catch (error) {
56
- logger.warn(`[BFF][Effect] Failed dispose previous handler: ${String(error)}`);
57
- } finally{
58
- this.dispose = null;
59
- }
60
- }
61
- constructor(api){
62
- this.isEffect = true;
63
- this.handler = null;
64
- this.dispose = null;
65
- this.prefix = '/api';
66
- this.registerMiddleware = async (options)=>{
67
- const { prefix, enableHandleWeb } = options;
68
- const { bffRuntimeFramework, middlewares: globalMiddlewares } = this.api.getServerContext();
69
- if ('hono' === bffRuntimeFramework) {
70
- this.isEffect = false;
71
- return;
72
- }
73
- this.prefix = prefix || this.prefix;
74
- await this.reloadHandler();
75
- this.effectMiddleware = {
76
- name: 'effect-api-handler',
77
- path: enableHandleWeb ? '*' : `${prefix}/*`,
78
- method: 'all',
79
- order: 'post',
80
- before: before,
81
- handler: async (c, next)=>{
82
- if (!this.handler) {
83
- if (enableHandleWeb) return void await next();
84
- return createEffectAdapterRuntimeErrorResponse(this.api, new Error('[BFF][Effect] Missing Effect entry. Define api/index or configure bff.effect.entry.'), c);
85
- }
86
- const response = await dispatchEffectBffRequestWithContext(this.handler, c.req.raw, {
87
- prefix,
88
- env: c.env,
89
- path: c.req.path,
90
- method: c.req.method,
91
- runWithEffectContext: runWithEffectContext,
92
- onError: (error)=>createEffectAdapterRuntimeErrorResponse(this.api, error, c)
93
- });
94
- if (404 === response.status && enableHandleWeb) return void await next();
95
- return new Response(response.body, response);
96
- }
97
- };
98
- globalMiddlewares.push(this.effectMiddleware);
99
- };
100
- this.onApiHandlersUpdated = async ()=>{
101
- if (!this.isEffect || isProd()) return;
102
- await this.reloadHandler();
103
- };
104
- this.api = api;
105
- }
106
- }
107
- export { EffectAdapter };
@@ -1,61 +0,0 @@
1
- import { isRecord, normalizeExpose } from "./utils.mjs";
2
- function decodeDataUrl(url) {
3
- const commaIndex = url.indexOf(',');
4
- if (commaIndex < 0) throw new Error('[BFF][Effect] Invalid backend federation data URL entry.');
5
- return decodeURIComponent(url.slice(commaIndex + 1));
6
- }
7
- async function readCommonJsEntrySource(remote) {
8
- if (remote.entry.startsWith('data:')) return decodeDataUrl(remote.entry);
9
- if (remote.entry.startsWith('http://') || remote.entry.startsWith('https://')) {
10
- const response = await fetch(remote.entry);
11
- if (!response.ok) throw new Error(`[BFF][Effect] Failed to load backend federation remote ${remote.name}: ${response.status}`);
12
- return response.text();
13
- }
14
- throw new Error(`[BFF][Effect] Backend federation remote ${remote.name} cannot load CommonJS entry ${remote.entry}.`);
15
- }
16
- function evaluateCommonJsEntry(remote, source) {
17
- const module = {
18
- exports: {}
19
- };
20
- const exports = module.exports;
21
- const evaluate = new Function('module', 'exports', 'globalThis', source);
22
- evaluate(module, exports, globalThis);
23
- const entry = module.exports.default ?? module.exports;
24
- if (!isRecord(entry)) throw new Error(`[BFF][Effect] Backend federation remote ${remote.name} entry must load object module.`);
25
- return entry;
26
- }
27
- async function importModuleEntry(remote) {
28
- const entry = await import(remote.entry);
29
- return entry.default ?? entry;
30
- }
31
- async function resolvePluginEntry(remote, plugins) {
32
- for (const plugin of plugins ?? []){
33
- const loadEntry = plugin.loadEntry;
34
- if ('function' != typeof loadEntry) continue;
35
- const entry = await loadEntry({
36
- remoteInfo: remote
37
- });
38
- if (entry) return entry;
39
- }
40
- }
41
- async function loadBackendFederationEntry(remote, plugins) {
42
- const pluginEntry = await resolvePluginEntry(remote, plugins);
43
- if (pluginEntry) return pluginEntry;
44
- if (remote.entryGlobalName) {
45
- const globalEntry = globalThis[remote.entryGlobalName];
46
- if (isRecord(globalEntry)) return globalEntry;
47
- }
48
- if ('module' === remote.type || remote.entry.startsWith('file:')) return importModuleEntry(remote);
49
- return evaluateCommonJsEntry(remote, await readCommonJsEntrySource(remote));
50
- }
51
- async function loadBackendFederationExpose(remote, expose, options) {
52
- const entry = await loadBackendFederationEntry(remote, options.plugins);
53
- if ('function' == typeof entry.init) await entry.init({
54
- hostName: options.hostName
55
- });
56
- if ('function' != typeof entry.get) throw new Error(`[BFF][Effect] Backend federation remote ${remote.name} entry must expose get().`);
57
- const factory = await entry.get(expose);
58
- if ('function' != typeof factory) throw new Error(`[BFF][Effect] Backend federation expose ${remote.name}/${normalizeExpose(expose)} must load factory function.`);
59
- return factory();
60
- }
61
- export { loadBackendFederationExpose };
@@ -1,41 +0,0 @@
1
- import { isRecord } from "./utils.mjs";
2
- function validateExpectedBackendFederationIdentity(loaded, expected, options = {}) {
3
- const allowMissing = true === options.allowMissingIdentityMetadata;
4
- const issues = [];
5
- const contract = isRecord(loaded) ? loaded.backendFederationContract : void 0;
6
- const compatibility = isRecord(contract) ? contract.compatibility : void 0;
7
- if (!isRecord(compatibility)) {
8
- if (allowMissing) return [];
9
- return [
10
- {
11
- path: 'backendFederationContract.compatibility',
12
- message: 'loaded module declares no compatibility metadata; delivery-unit identity cannot be validated'
13
- }
14
- ];
15
- }
16
- const unitId = compatibility.unitId;
17
- if ('string' != typeof unitId || 0 === unitId.length) {
18
- if (!allowMissing) issues.push({
19
- path: 'backendFederationContract.compatibility.unitId',
20
- message: `missing delivery-unit id; expected ${expected.unitId}`
21
- });
22
- } else if (unitId !== expected.unitId) issues.push({
23
- path: 'backendFederationContract.compatibility.unitId',
24
- message: `expected ${expected.unitId}, received ${unitId}`
25
- });
26
- const build = compatibility.build;
27
- if ('string' != typeof build || 0 === build.length) {
28
- if (!allowMissing) issues.push({
29
- path: 'backendFederationContract.compatibility.build',
30
- message: `missing build marker; expected ${expected.buildMarker}`
31
- });
32
- } else if (build !== expected.buildMarker) issues.push({
33
- path: 'backendFederationContract.compatibility.build',
34
- message: `expected ${expected.buildMarker}, received ${build}`
35
- });
36
- return issues;
37
- }
38
- function formatBackendFederationIdentityIssues(issues) {
39
- return issues.map((issue)=>`${issue.path}: ${issue.message}`).join('; ');
40
- }
41
- export { formatBackendFederationIdentityIssues, validateExpectedBackendFederationIdentity };
@@ -1,37 +0,0 @@
1
- import { BACKEND_FEDERATION_EFFECT_EXPOSE } from "@modern-js/utils/universal";
2
- import { formatBackendFederationIdentityIssues, validateExpectedBackendFederationIdentity } from "./identity.mjs";
3
- import { createBackendFederationRuntime } from "./runtime.mjs";
4
- import { isRecord, normalizeExpose } from "./utils.mjs";
5
- import * as __rspack_external_effect_Effect_41060786 from "effect/Effect";
6
- import * as __rspack_external_effect_Logger_1691a01b from "effect/Logger";
7
- const LEGACY_LOAD_WARNING = '[BFF][Effect] loadBackendFederatedEffectApi was called without an expected delivery-unit identity (expected.unitId + expected.buildMarker). Identity-less public backend loads are deprecated (ADR-0019/MV-G23) and will be rejected in a future major.';
8
- const legacyWarningLogger = __rspack_external_effect_Logger_1691a01b.withLeveledConsole(__rspack_external_effect_Logger_1691a01b.formatLogFmt);
9
- function warnLegacyLoad() {
10
- __rspack_external_effect_Effect_41060786.runSync(__rspack_external_effect_Effect_41060786.provideService(__rspack_external_effect_Effect_41060786.logWarning(LEGACY_LOAD_WARNING), __rspack_external_effect_Logger_1691a01b.CurrentLoggers, new Set([
11
- legacyWarningLogger
12
- ])));
13
- }
14
- function loadBackendFederatedEffectApi(options) {
15
- const remoteName = options.remote?.name ?? options.remoteName;
16
- if (void 0 === remoteName || 0 === remoteName.length) return Promise.reject(new Error('[BFF][Effect] Missing backend federation remote name.'));
17
- if (void 0 === options.expected) warnLegacyLoad();
18
- const runtime = options.runtime ?? createBackendFederationRuntime(options);
19
- const expose = options.expose ?? options.remote?.expose ?? BACKEND_FEDERATION_EFFECT_EXPOSE;
20
- const remoteRequest = `${remoteName}/${normalizeExpose(expose)}`;
21
- return runtime.loadRemote(remoteRequest).then((loaded)=>{
22
- if (!isRecord(loaded)) throw new Error(`[BFF][Effect] Backend federation expose ${remoteRequest} must load an object module.`);
23
- const backendContract = loaded.backendFederationContract;
24
- if (!isRecord(backendContract) || true !== backendContract.strictEffectApproach) throw new Error(`[BFF][Effect] Backend federation expose ${remoteRequest} must expose strict Effect metadata (strictEffectApproach: true).`);
25
- if ('effect' !== backendContract.runtimeFramework) throw new Error(`[BFF][Effect] Backend federation expose ${remoteRequest} must expose strict Effect metadata (runtimeFramework: "effect").`);
26
- if ('string' == typeof backendContract.name && backendContract.name !== remoteName) throw new Error(`[BFF][Effect] Backend federation expose ${remoteRequest} metadata name mismatch: expected ${remoteName}, received ${backendContract.name}.`);
27
- if (!('runtime' in loaded)) throw new Error(`[BFF][Effect] Backend federation expose ${remoteRequest} must expose api and runtime.`);
28
- if (void 0 !== options.expected) {
29
- const issues = validateExpectedBackendFederationIdentity(loaded, options.expected, {
30
- allowMissingIdentityMetadata: true === options.allowMissingIdentityMetadata
31
- });
32
- if (issues.length > 0) throw new Error(`[BFF][Effect] Backend federation expose ${remoteRequest} delivery-unit identity mismatch: ${formatBackendFederationIdentityIssues(issues)}.`);
33
- }
34
- return loaded;
35
- });
36
- }
37
- export { loadBackendFederatedEffectApi };
@@ -1,25 +0,0 @@
1
- function createBackendFederationLoadEntryPlugin(options) {
2
- return {
3
- name: 'modernjs-backend-federation-load-entry',
4
- loadEntry ({ remoteInfo }) {
5
- return Promise.resolve(options.resolveEntry({
6
- name: remoteInfo.name,
7
- entry: remoteInfo.entry,
8
- type: remoteInfo.type,
9
- entryGlobalName: remoteInfo.entryGlobalName,
10
- shareScope: remoteInfo.shareScope
11
- })).then((entry)=>{
12
- if (void 0 === entry) return;
13
- return {
14
- get (id) {
15
- return ()=>Promise.resolve(entry.get(id)).then((factory)=>factory());
16
- },
17
- init (...args) {
18
- return entry.init?.(...args);
19
- }
20
- };
21
- });
22
- }
23
- };
24
- }
25
- export { createBackendFederationLoadEntryPlugin };
@@ -1,13 +0,0 @@
1
- function collectRemotes(options) {
2
- const remotes = [
3
- ...options.remotes ?? []
4
- ];
5
- const configuredRemote = options.remote;
6
- if (void 0 !== configuredRemote) {
7
- const existingIndex = remotes.findIndex((remote)=>remote.name === configuredRemote.name);
8
- if (existingIndex >= 0) remotes[existingIndex] = configuredRemote;
9
- else remotes.push(configuredRemote);
10
- }
11
- return remotes;
12
- }
13
- export { collectRemotes };
@@ -1,90 +0,0 @@
1
- import { ModuleFederation } from "@module-federation/runtime";
2
- import { loadBackendFederationExpose } from "./entry.mjs";
3
- import { createBackendFederationLoadEntryPlugin } from "./plugin.mjs";
4
- import { collectRemotes } from "./remotes.mjs";
5
- function _check_private_redeclaration(obj, privateCollection) {
6
- if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
7
- }
8
- function _class_apply_descriptor_get(receiver, descriptor) {
9
- if (descriptor.get) return descriptor.get.call(receiver);
10
- return descriptor.value;
11
- }
12
- function _class_apply_descriptor_set(receiver, descriptor, value) {
13
- if (descriptor.set) descriptor.set.call(receiver, value);
14
- else {
15
- if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
16
- descriptor.value = value;
17
- }
18
- }
19
- function _class_extract_field_descriptor(receiver, privateMap, action) {
20
- if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
21
- return privateMap.get(receiver);
22
- }
23
- function _class_private_field_get(receiver, privateMap) {
24
- var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
25
- return _class_apply_descriptor_get(receiver, descriptor);
26
- }
27
- function _class_private_field_init(obj, privateMap, value) {
28
- _check_private_redeclaration(obj, privateMap);
29
- privateMap.set(obj, value);
30
- }
31
- function _class_private_field_set(receiver, privateMap, value) {
32
- var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
33
- _class_apply_descriptor_set(receiver, descriptor, value);
34
- return value;
35
- }
36
- let nextRuntimeId = 0;
37
- function parseRemoteRequest(request) {
38
- const [remoteName, ...exposeParts] = request.split('/');
39
- if (void 0 === remoteName || 0 === remoteName.length || 0 === exposeParts.length) return;
40
- return remoteName;
41
- }
42
- function createLocalEntryPlugin(options, remotes) {
43
- return createBackendFederationLoadEntryPlugin({
44
- resolveEntry (resolvedRemote) {
45
- const remote = remotes.find((candidate)=>candidate.name === resolvedRemote.name);
46
- if (void 0 === remote) return;
47
- return {
48
- get (expose) {
49
- return ()=>loadBackendFederationExpose(remote, expose, options);
50
- }
51
- };
52
- }
53
- });
54
- }
55
- function isolateRegisteredRemoteEntries(remotes) {
56
- const runtimeId = nextRuntimeId;
57
- nextRuntimeId += 1;
58
- return remotes.map((remote)=>({
59
- ...remote,
60
- entry: `${remote.entry}#modernjs-backend-runtime-${runtimeId}`
61
- }));
62
- }
63
- var _remoteNames = /*#__PURE__*/ new WeakMap();
64
- class BackendFederationRuntime extends ModuleFederation {
65
- loadRemote(request, loadOptions) {
66
- const remoteName = parseRemoteRequest(request);
67
- if (void 0 === remoteName) return Promise.reject(new Error(`[BFF][Effect] Invalid backend federation request ${request}.`));
68
- if (!_class_private_field_get(this, _remoteNames).has(remoteName)) return Promise.reject(new Error(`[BFF][Effect] Missing backend federation remote ${remoteName}.`));
69
- return super.loadRemote(request, loadOptions);
70
- }
71
- constructor(options, remotes){
72
- super({
73
- name: options.hostName,
74
- remotes: isolateRegisteredRemoteEntries(remotes),
75
- shared: {},
76
- plugins: [
77
- createLocalEntryPlugin(options, remotes)
78
- ]
79
- }), _class_private_field_init(this, _remoteNames, {
80
- writable: true,
81
- value: void 0
82
- });
83
- _class_private_field_set(this, _remoteNames, new Set(remotes.map((remote)=>remote.name)));
84
- }
85
- }
86
- function createBackendFederationRuntime(options) {
87
- const remotes = collectRemotes(options);
88
- return new BackendFederationRuntime(options, remotes);
89
- }
90
- export { createBackendFederationRuntime };