@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,91 +0,0 @@
1
- import "node:module";
2
- function isPlainObject(value) {
3
- if ('object' != typeof value || null === value || Array.isArray(value)) return false;
4
- const proto = Object.getPrototypeOf(value);
5
- return proto === Object.prototype || null === proto;
6
- }
7
- function canonicalize(value) {
8
- if (Array.isArray(value)) return value.map((item)=>canonicalize(item));
9
- if (isPlainObject(value)) return Object.keys(value).sort().reduce((acc, key)=>{
10
- acc[key] = canonicalize(value[key]);
11
- return acc;
12
- }, {});
13
- return value;
14
- }
15
- function stableStringify(value) {
16
- return JSON.stringify(canonicalize(value));
17
- }
18
- function encodeRequestEnvelopeHeader(envelope) {
19
- return encodeURIComponent(stableStringify(envelope));
20
- }
21
- function isRequestEnvelopeShape(value) {
22
- if (!isPlainObject(value)) return false;
23
- return 1 === value.protocolVersion && 'string' == typeof value.operationId && 'string' == typeof value.appNamespace && 'string' == typeof value.origin && 'string' == typeof value.scopeKey && 'string' == typeof value.inputHash && 'number' == typeof value.timestamp;
24
- }
25
- function decodeRequestEnvelopeHeader(value) {
26
- try {
27
- const decoded = decodeURIComponent(value);
28
- const parsed = JSON.parse(decoded);
29
- if (!isRequestEnvelopeShape(parsed)) return null;
30
- return parsed;
31
- } catch {
32
- return null;
33
- }
34
- }
35
- function hashString(value) {
36
- let hash = 0x811c9dc5;
37
- for(let index = 0; index < value.length; index++){
38
- hash ^= value.charCodeAt(index);
39
- hash = Math.imul(hash, 0x01000193);
40
- }
41
- return (hash >>> 0).toString(16).padStart(8, '0');
42
- }
43
- function sanitizeSegment(segment) {
44
- const normalized = segment.trim().replace(/[^a-zA-Z0-9_-]+/g, '_');
45
- return normalized.length > 0 ? normalized : 'unknown';
46
- }
47
- function normalizeOrigin(origin) {
48
- const normalized = origin.trim();
49
- try {
50
- const url = new URL(normalized);
51
- return `${url.protocol}//${url.host}`.toLowerCase();
52
- } catch {
53
- return normalized.toLowerCase();
54
- }
55
- }
56
- function normalizeOperationDescriptor(input) {
57
- return {
58
- appNamespace: sanitizeSegment(input.appNamespace),
59
- apiId: sanitizeSegment(input.apiId),
60
- group: sanitizeSegment(input.group),
61
- endpoint: sanitizeSegment(input.endpoint),
62
- schemaHash: input.schemaHash || null,
63
- version: input.version ?? 1
64
- };
65
- }
66
- function createOperationId(input) {
67
- const descriptor = normalizeOperationDescriptor(input);
68
- const readable = `${descriptor.appNamespace}.${descriptor.apiId}.${descriptor.group}.${descriptor.endpoint}.v${String(descriptor.version)}`;
69
- return `${readable}:${hashString(stableStringify(descriptor))}`;
70
- }
71
- function buildScopeKey(scope) {
72
- const canonical = {
73
- appNamespace: sanitizeSegment(scope.appNamespace),
74
- origin: normalizeOrigin(scope.origin),
75
- tenantId: scope.tenantId ?? null,
76
- userId: scope.userId ?? null,
77
- sessionId: scope.sessionId ?? null
78
- };
79
- return `${canonical.appNamespace}:${hashString(stableStringify(canonical))}`;
80
- }
81
- function buildQueryKey(input) {
82
- const canonical = {
83
- operationId: input.operationId,
84
- scopeKey: input.scopeKey,
85
- requestMode: input.requestMode ?? 'cache-first',
86
- requestInput: input.requestInput ?? null,
87
- selectionPlan: input.selectionPlan ?? null
88
- };
89
- return `${input.operationId}:${hashString(stableStringify(canonical))}`;
90
- }
91
- export { buildQueryKey, buildScopeKey, createOperationId, decodeRequestEnvelopeHeader, encodeRequestEnvelopeHeader, hashString, isPlainObject, normalizeOrigin, sanitizeSegment, stableStringify };
@@ -1,21 +0,0 @@
1
- import "node:module";
2
- import { buildScopeKey, createOperationId, sanitizeSegment } from "./codec.mjs";
3
- function createInvalidationEvent(input) {
4
- return {
5
- sourceNamespace: sanitizeSegment(input.sourceOperation.appNamespace),
6
- sourceOperationId: createOperationId(input.sourceOperation),
7
- scopeKey: buildScopeKey(input.sourceScope),
8
- targetNamespaces: input.targetNamespaces?.map((namespace)=>sanitizeSegment(namespace)),
9
- targetOperationIds: input.targetOperations?.map((operation)=>createOperationId(operation))
10
- };
11
- }
12
- function shouldApplyInvalidation(event, subscriber) {
13
- if (subscriber.scopeKey && subscriber.scopeKey !== event.scopeKey) return false;
14
- const sameNamespace = subscriber.namespace === event.sourceNamespace;
15
- const allowedCrossNamespace = true === subscriber.acceptCrossNamespace && event.targetNamespaces?.includes(subscriber.namespace) === true;
16
- if (!sameNamespace && !allowedCrossNamespace) return false;
17
- if (!subscriber.operationIds || 0 === subscriber.operationIds.length) return true;
18
- if (!event.targetOperationIds || 0 === event.targetOperationIds.length) return true;
19
- return subscriber.operationIds.some((operationId)=>event.targetOperationIds?.includes(operationId));
20
- }
21
- export { createInvalidationEvent, shouldApplyInvalidation };
@@ -1,30 +0,0 @@
1
- import "node:module";
2
- import { parseTraceparent } from "@modern-js/create-request";
3
- function isAllZeroHex(value) {
4
- return /^0+$/.test(value);
5
- }
6
- function isValidHex(value, length) {
7
- return value.length === length && /^[0-9a-f]+$/.test(value);
8
- }
9
- function parseTraceparentHeader(header) {
10
- return parseTraceparent(header) ?? null;
11
- }
12
- function formatTraceparentHeader(trace) {
13
- const traceId = trace.traceId.toLowerCase();
14
- const spanId = trace.spanId.toLowerCase();
15
- if (!isValidHex(traceId, 32) || !isValidHex(spanId, 16)) throw new Error('Invalid trace context: traceId/spanId format mismatch');
16
- if (isAllZeroHex(traceId) || isAllZeroHex(spanId)) throw new Error('Invalid trace context: traceId/spanId cannot be zero');
17
- const flags = trace.sampled ? '01' : '00';
18
- return `00-${traceId}-${spanId}-${flags}`;
19
- }
20
- function deriveChildTraceContext(parent, childSpanId) {
21
- const normalizedSpanId = childSpanId.toLowerCase();
22
- if (!isValidHex(normalizedSpanId, 16) || isAllZeroHex(normalizedSpanId)) throw new Error('Invalid child span id');
23
- return {
24
- traceId: parent.traceId.toLowerCase(),
25
- spanId: normalizedSpanId,
26
- sampled: parent.sampled,
27
- parentSpanId: parent.spanId.toLowerCase()
28
- };
29
- }
30
- export { deriveChildTraceContext, formatTraceparentHeader, parseTraceparentHeader };
@@ -1,5 +0,0 @@
1
- import "node:module";
2
- const DEFAULT_DATA_ENVELOPE_HEADER = 'x-modernjs-data-envelope';
3
- const DEFAULT_DATA_BATCH_ENDPOINT = '/_data/batch';
4
- const DEFAULT_DATA_BATCH_HEADER = 'x-modernjs-data-batch';
5
- export { DEFAULT_DATA_BATCH_ENDPOINT, DEFAULT_DATA_BATCH_HEADER, DEFAULT_DATA_ENVELOPE_HEADER };
@@ -1,129 +0,0 @@
1
- import "node:module";
2
- import { buildScopeKey, createOperationId, hashString, isPlainObject, normalizeOrigin, sanitizeSegment, stableStringify } from "./codec.mjs";
3
- import { formatTraceparentHeader, parseTraceparentHeader } from "./trace.mjs";
4
- function validateSelectionPlan(plan, options = {}) {
5
- const maxDepthLimit = options.maxDepth ?? 8;
6
- const maxFieldsLimit = options.maxFields ?? 256;
7
- const allowedLeafPaths = options.allowedLeafPaths ? new Set(options.allowedLeafPaths) : null;
8
- const errors = [];
9
- let maxDepth = 0;
10
- let fieldCount = 0;
11
- const walk = (node, path)=>{
12
- if (!isPlainObject(node)) return void errors.push(`Selection node at "${path.join('.') || '<root>'}" must be an object`);
13
- const keys = Object.keys(node);
14
- if (0 === keys.length) return void errors.push(`Selection node at "${path.join('.') || '<root>'}" cannot be empty`);
15
- for (const key of keys){
16
- fieldCount += 1;
17
- if (fieldCount > maxFieldsLimit) return void errors.push(`Selection has too many fields: ${String(fieldCount)} > ${String(maxFieldsLimit)}`);
18
- const nextPath = [
19
- ...path,
20
- key
21
- ];
22
- const depth = nextPath.length;
23
- if (depth > maxDepth) maxDepth = depth;
24
- if (depth > maxDepthLimit) return void errors.push(`Selection exceeds maxDepth at "${nextPath.join('.')}" (${String(depth)} > ${String(maxDepthLimit)})`);
25
- const value = node[key];
26
- if (true === value) {
27
- if (allowedLeafPaths && !allowedLeafPaths.has(nextPath.join('.'))) errors.push(`Unknown selected field "${nextPath.join('.')}"`);
28
- continue;
29
- }
30
- if (!isPlainObject(value)) {
31
- errors.push(`Invalid selection value at "${nextPath.join('.')}"; expected true or nested object`);
32
- continue;
33
- }
34
- walk(value, nextPath);
35
- }
36
- };
37
- walk(plan, []);
38
- return {
39
- ok: 0 === errors.length,
40
- errors,
41
- stats: {
42
- maxDepth,
43
- fieldCount
44
- }
45
- };
46
- }
47
- function createRequestEnvelope(input) {
48
- if (input.requireTraceContext && !input.traceContext) throw new Error('Trace context is required for this request envelope');
49
- const traceparent = input.traceContext ? formatTraceparentHeader(input.traceContext) : void 0;
50
- const envelope = {
51
- protocolVersion: input.protocolVersion ?? 1,
52
- operationId: createOperationId(input.operation),
53
- appNamespace: sanitizeSegment(input.scope.appNamespace),
54
- origin: normalizeOrigin(input.scope.origin),
55
- requestMode: input.requestMode ?? 'cache-first',
56
- mutationMode: input.mutationMode,
57
- scopeKey: buildScopeKey(input.scope),
58
- input: input.requestInput,
59
- inputHash: hashString(stableStringify(input.requestInput ?? null)),
60
- selectionPlan: input.selectionPlan,
61
- selectionHash: input.selectionPlan ? hashString(stableStringify(input.selectionPlan)) : void 0,
62
- traceparent,
63
- timestamp: input.timestamp ?? Date.now()
64
- };
65
- return envelope;
66
- }
67
- function validateRequestEnvelope(envelope, options = {}) {
68
- const errors = [];
69
- if (void 0 !== options.expectedProtocolVersion && envelope.protocolVersion !== options.expectedProtocolVersion) errors.push(`Protocol mismatch: expected ${String(options.expectedProtocolVersion)} but received ${String(envelope.protocolVersion)}`);
70
- if (options.expectedNamespace && envelope.appNamespace !== options.expectedNamespace) errors.push(`Namespace mismatch: expected ${options.expectedNamespace} but received ${envelope.appNamespace}`);
71
- if (options.expectedOrigin) {
72
- const expectedOrigin = normalizeOrigin(options.expectedOrigin);
73
- if (envelope.origin !== expectedOrigin) errors.push(`Origin mismatch: expected ${expectedOrigin} but received ${envelope.origin}`);
74
- }
75
- if (!envelope.operationId) errors.push('Missing operationId');
76
- if (!envelope.scopeKey) errors.push('Missing scopeKey');
77
- if (options.requireTraceContext && !envelope.traceparent) errors.push('Missing trace context');
78
- if (envelope.traceparent && !parseTraceparentHeader(envelope.traceparent)) errors.push('Invalid traceparent header');
79
- const computedInputHash = hashString(stableStringify(envelope.input ?? null));
80
- if (computedInputHash !== envelope.inputHash) errors.push('Input hash mismatch');
81
- if (envelope.selectionPlan) {
82
- const computedSelectionHash = hashString(stableStringify(envelope.selectionPlan));
83
- if (computedSelectionHash !== envelope.selectionHash) errors.push('Selection hash mismatch');
84
- }
85
- return {
86
- ok: 0 === errors.length,
87
- errors
88
- };
89
- }
90
- function createHydrationEnvelope(input) {
91
- const envelopeWithoutChecksum = {
92
- protocolVersion: input.protocolVersion ?? 1,
93
- runtimeVersion: input.runtimeVersion,
94
- appNamespace: sanitizeSegment(input.scope.appNamespace),
95
- origin: normalizeOrigin(input.scope.origin),
96
- createdAt: input.createdAt ?? Date.now(),
97
- payload: input.payload
98
- };
99
- const checksum = hashString(stableStringify(envelopeWithoutChecksum));
100
- return {
101
- ...envelopeWithoutChecksum,
102
- checksum
103
- };
104
- }
105
- function validateHydrationEnvelope(envelope, options = {}) {
106
- const errors = [];
107
- if (void 0 !== options.expectedProtocolVersion && envelope.protocolVersion !== options.expectedProtocolVersion) errors.push(`Protocol mismatch: expected ${String(options.expectedProtocolVersion)} but received ${String(envelope.protocolVersion)}`);
108
- if (options.expectedNamespace && envelope.appNamespace !== options.expectedNamespace) errors.push(`Namespace mismatch: expected ${options.expectedNamespace} but received ${envelope.appNamespace}`);
109
- if (options.expectedOrigin) {
110
- const expectedOrigin = normalizeOrigin(options.expectedOrigin);
111
- if (envelope.origin !== expectedOrigin) errors.push(`Origin mismatch: expected ${expectedOrigin} but received ${envelope.origin}`);
112
- }
113
- if (options.expectedRuntimeVersion && envelope.runtimeVersion !== options.expectedRuntimeVersion) errors.push(`Runtime version mismatch: expected ${options.expectedRuntimeVersion} but received ${envelope.runtimeVersion}`);
114
- const checksumBase = {
115
- protocolVersion: envelope.protocolVersion,
116
- runtimeVersion: envelope.runtimeVersion,
117
- appNamespace: envelope.appNamespace,
118
- origin: envelope.origin,
119
- createdAt: envelope.createdAt,
120
- payload: envelope.payload
121
- };
122
- const checksum = hashString(stableStringify(checksumBase));
123
- if (checksum !== envelope.checksum) errors.push('Hydration checksum mismatch');
124
- return {
125
- ok: 0 === errors.length,
126
- errors
127
- };
128
- }
129
- export { createHydrationEnvelope, createRequestEnvelope, validateHydrationEnvelope, validateRequestEnvelope, validateSelectionPlan };
@@ -1,7 +0,0 @@
1
- import "node:module";
2
- const before = [
3
- 'custom-server-hook',
4
- 'custom-server-middleware',
5
- 'render'
6
- ];
7
- export { before };
@@ -1,29 +0,0 @@
1
- import "node:module";
2
- import { logger } from "@modern-js/utils";
3
- import { HttpApi } from "effect/unstable/httpapi";
4
- import { resolveAdapterCrossProjectPolicy } from "../../../utils/crossProjectServerPolicy.mjs";
5
- import { collectEffectEndpoints, extractHttpApiFromModule, toOperationContractSources } from "../endpoint-contracts.mjs";
6
- function resolveEffectAdapterCrossProjectPolicy(api, prefix, mod) {
7
- const contractSourcesPromise = null === mod ? Promise.resolve([]) : Promise.resolve().then(()=>extractHttpApiFromModule(mod, HttpApi.isHttpApi)).then((effectApi)=>{
8
- if (null !== effectApi) {
9
- const reflect = (apiValue, handlers)=>{
10
- if (!HttpApi.isHttpApi(apiValue)) throw new Error('[BFF][Effect] Endpoint reflection received a non-HttpApi value.');
11
- HttpApi.reflect(apiValue, {
12
- onGroup: handlers.onGroup ?? (()=>{}),
13
- onEndpoint: handlers.onEndpoint
14
- });
15
- };
16
- return toOperationContractSources(collectEffectEndpoints(reflect, effectApi, prefix));
17
- }
18
- return [];
19
- }).catch((error)=>{
20
- logger.warn(`[BFF][Effect] Failed reflect HttpApi endpoints cross-project policy: ${String(error)}`);
21
- return [];
22
- });
23
- return contractSourcesPromise.then((contractSources)=>{
24
- const policy = resolveAdapterCrossProjectPolicy(api, contractSources);
25
- 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.');
26
- return policy;
27
- });
28
- }
29
- export { resolveEffectAdapterCrossProjectPolicy };
@@ -1,53 +0,0 @@
1
- import "node:module";
2
- import { API_DIR, findExists, fs, isProd } from "@modern-js/utils";
3
- import path from "path";
4
- const JS_OR_TS_EXTS = [
5
- '.js',
6
- '.jsx',
7
- '.ts',
8
- '.tsx',
9
- '.mjs',
10
- '.mts',
11
- '.cjs',
12
- '.cts'
13
- ];
14
- function resolveJsOrTsEntry(entryWithoutOrWithExt) {
15
- const extension = path.extname(entryWithoutOrWithExt);
16
- if (JS_OR_TS_EXTS.includes(extension)) return fs.existsSync(entryWithoutOrWithExt) ? entryWithoutOrWithExt : void 0;
17
- return findExists(JS_OR_TS_EXTS.map((ext)=>`${entryWithoutOrWithExt}${ext}`)) || void 0;
18
- }
19
- function builtEntryPath(entryPath) {
20
- return entryPath.replace(/\.(?:[cm]?ts|tsx|jsx)$/u, '.js');
21
- }
22
- function relativeAppPath(appDirectory, entryPath) {
23
- const relativePath = path.relative(appDirectory, entryPath);
24
- return '..' === relativePath || relativePath.startsWith(`..${path.sep}`) ? void 0 : relativePath;
25
- }
26
- function isDependencyPath(relativePath) {
27
- return relativePath?.split(/[\\/]/u).includes('node_modules') ?? false;
28
- }
29
- function resolveEffectAdapterEntryFile(api) {
30
- const { appDirectory, apiDirectory, distDirectory } = api.getServerContext();
31
- const appRoot = path.resolve(appDirectory || process.cwd());
32
- const productionRoot = isProd() && distDirectory ? path.resolve(distDirectory) : void 0;
33
- const bffConfig = api.getServerConfig()?.bff;
34
- const configuredEntry = bffConfig?.effect?.entry;
35
- if (configuredEntry) {
36
- const sourceEntry = path.isAbsolute(configuredEntry) ? configuredEntry : path.resolve(appRoot, configuredEntry);
37
- if (productionRoot) {
38
- const relativeEntry = relativeAppPath(appRoot, sourceEntry);
39
- if (void 0 === relativeEntry || isDependencyPath(relativeEntry)) return resolveJsOrTsEntry(sourceEntry);
40
- return relativeEntry ? resolveJsOrTsEntry(builtEntryPath(path.resolve(productionRoot, relativeEntry))) : void 0;
41
- }
42
- return resolveJsOrTsEntry(sourceEntry);
43
- }
44
- const resolvedApiDirectory = path.resolve(appRoot, apiDirectory || API_DIR);
45
- const productionApiDirectory = productionRoot ? void 0 !== relativeAppPath(productionRoot, resolvedApiDirectory) ? resolvedApiDirectory : (()=>{
46
- const relativeApiDirectory = relativeAppPath(appRoot, resolvedApiDirectory);
47
- if (isDependencyPath(relativeApiDirectory)) return resolvedApiDirectory;
48
- return relativeApiDirectory ? path.resolve(productionRoot, relativeApiDirectory) : void 0;
49
- })() : resolvedApiDirectory;
50
- if (!productionApiDirectory) return;
51
- return resolveJsOrTsEntry(path.resolve(productionApiDirectory, 'index'));
52
- }
53
- export { resolveEffectAdapterEntryFile };
@@ -1,44 +0,0 @@
1
- import "node:module";
2
- import { logger } from "@modern-js/utils";
3
- import { createSafeFailureResponse } from "../../safe-failure.mjs";
4
- function createEffectAdapterRuntimeErrorResponse(api, error, c) {
5
- try {
6
- const serverConfig = api.getServerConfig();
7
- const onErrorHandler = serverConfig?.onError;
8
- if (void 0 !== onErrorHandler) {
9
- const onErrorContext = ensureJsonContext(c);
10
- return Promise.resolve(onErrorHandler(error instanceof Error ? error : new Error(String(error)), onErrorContext)).then((result)=>result instanceof Response ? result : createSafeFailureResponse(error)).catch((configError)=>{
11
- logger.error(`Error in serverConfig.onError handler: ${String(configError)}`);
12
- return createSafeFailureResponse(error);
13
- });
14
- }
15
- logger.error(error instanceof Error ? error : new Error(String(error)));
16
- } catch (configError) {
17
- logger.error(`Error in serverConfig.onError handler: ${configError}`);
18
- }
19
- return Promise.resolve(createSafeFailureResponse(error));
20
- }
21
- function ensureJsonContext(c) {
22
- if ('json' in c && 'function' == typeof c.json) return c;
23
- const headers = {
24
- 'content-type': 'application/json; charset=utf-8'
25
- };
26
- const withJson = Object.assign({}, c, {
27
- json (data, statusOrInit = 200, extraHeaders) {
28
- const responseInit = 'number' == typeof statusOrInit ? {
29
- status: statusOrInit,
30
- headers: extraHeaders
31
- } : statusOrInit;
32
- const responseHeaders = new Headers(headers);
33
- if (void 0 !== responseInit.headers) new Headers(responseInit.headers).forEach((value, key)=>{
34
- responseHeaders.set(key, value);
35
- });
36
- return new Response(JSON.stringify(data), {
37
- ...responseInit,
38
- headers: responseHeaders
39
- });
40
- }
41
- });
42
- return withJson;
43
- }
44
- export { createEffectAdapterRuntimeErrorResponse };
@@ -1,16 +0,0 @@
1
- import "node:module";
2
- import { logger } from "@modern-js/utils";
3
- import { checkCrossProjectPolicyForRequest } from "../../../utils/crossProjectServerPolicy.mjs";
4
- import { resolveEffectBffModuleHandler } from "../module.mjs";
5
- async function loadEffectAdapterHandlerFromModule(api, mod, crossProjectPolicy) {
6
- const effectConfig = api.getServerConfig()?.bff?.effect;
7
- return resolveEffectBffModuleHandler(mod, {
8
- openapi: effectConfig?.openapi,
9
- dataPlatform: effectConfig?.dataPlatform,
10
- validateRequest: (request)=>checkCrossProjectPolicyForRequest(request, crossProjectPolicy),
11
- onWarning: (message)=>{
12
- logger.warn(message);
13
- }
14
- });
15
- }
16
- export { loadEffectAdapterHandlerFromModule };
@@ -1,108 +0,0 @@
1
- import "node:module";
2
- import { fs, isProd, logger } from "@modern-js/utils";
3
- import path from "path";
4
- import { loadEffectBuiltModule, loadEffectSourceModule } from "../../utils/effectSourceLoader.mjs";
5
- import { before } from "./adapter/constants.mjs";
6
- import { resolveEffectAdapterCrossProjectPolicy } from "./adapter/cross-project-policy.mjs";
7
- import { resolveEffectAdapterEntryFile } from "./adapter/entry.mjs";
8
- import { createEffectAdapterRuntimeErrorResponse } from "./adapter/error-response.mjs";
9
- import { loadEffectAdapterHandlerFromModule } from "./adapter/handler.mjs";
10
- import { runWithEffectContext } from "./context.mjs";
11
- import { dispatchEffectBffRequestWithContext } from "./dispatch.mjs";
12
- class EffectAdapter {
13
- resolveEntryFile() {
14
- return resolveEffectAdapterEntryFile(this.api);
15
- }
16
- async reloadHandler() {
17
- if (!this.isEffect) return;
18
- const entryFile = this.resolveEntryFile();
19
- if (!entryFile) {
20
- await this.disposeCurrentHandler();
21
- this.handler = null;
22
- return;
23
- }
24
- if (!await fs.pathExists(entryFile)) {
25
- await this.disposeCurrentHandler();
26
- this.handler = null;
27
- return;
28
- }
29
- await this.disposeCurrentHandler();
30
- let mod;
31
- try {
32
- const { appDirectory } = this.api.getServerContext();
33
- mod = await (isProd() ? loadEffectBuiltModule(entryFile) : loadEffectSourceModule({
34
- resourcePath: entryFile,
35
- appDir: appDirectory || path.dirname(entryFile)
36
- }));
37
- } catch (error) {
38
- logger.error(`[BFF][Effect] Failed to load Effect entry: ${entryFile}\n${String(error)}`);
39
- this.handler = null;
40
- return;
41
- }
42
- this.crossProjectPolicy = await resolveEffectAdapterCrossProjectPolicy(this.api, this.prefix, mod);
43
- const loaded = await loadEffectAdapterHandlerFromModule(this.api, mod, this.crossProjectPolicy);
44
- if (!loaded) {
45
- logger.warn(`[BFF][Effect] Invalid Effect entry module: ${entryFile}. Export defineEffectBff(...) or a { api, layer } HttpApi module.`);
46
- this.handler = null;
47
- return;
48
- }
49
- this.handler = loaded.handler;
50
- this.dispose = loaded.dispose || null;
51
- }
52
- async disposeCurrentHandler() {
53
- if (!this.dispose) return;
54
- try {
55
- await this.dispose();
56
- } catch (error) {
57
- logger.warn(`[BFF][Effect] Failed dispose previous handler: ${String(error)}`);
58
- } finally{
59
- this.dispose = null;
60
- }
61
- }
62
- constructor(api){
63
- this.isEffect = true;
64
- this.handler = null;
65
- this.dispose = null;
66
- this.prefix = '/api';
67
- this.registerMiddleware = async (options)=>{
68
- const { prefix, enableHandleWeb } = options;
69
- const { bffRuntimeFramework, middlewares: globalMiddlewares } = this.api.getServerContext();
70
- if ('hono' === bffRuntimeFramework) {
71
- this.isEffect = false;
72
- return;
73
- }
74
- this.prefix = prefix || this.prefix;
75
- await this.reloadHandler();
76
- this.effectMiddleware = {
77
- name: 'effect-api-handler',
78
- path: enableHandleWeb ? '*' : `${prefix}/*`,
79
- method: 'all',
80
- order: 'post',
81
- before: before,
82
- handler: async (c, next)=>{
83
- if (!this.handler) {
84
- if (enableHandleWeb) return void await next();
85
- return createEffectAdapterRuntimeErrorResponse(this.api, new Error('[BFF][Effect] Missing Effect entry. Define api/index or configure bff.effect.entry.'), c);
86
- }
87
- const response = await dispatchEffectBffRequestWithContext(this.handler, c.req.raw, {
88
- prefix,
89
- env: c.env,
90
- path: c.req.path,
91
- method: c.req.method,
92
- runWithEffectContext: runWithEffectContext,
93
- onError: (error)=>createEffectAdapterRuntimeErrorResponse(this.api, error, c)
94
- });
95
- if (404 === response.status && enableHandleWeb) return void await next();
96
- return new Response(response.body, response);
97
- }
98
- };
99
- globalMiddlewares.push(this.effectMiddleware);
100
- };
101
- this.onApiHandlersUpdated = async ()=>{
102
- if (!this.isEffect || isProd()) return;
103
- await this.reloadHandler();
104
- };
105
- this.api = api;
106
- }
107
- }
108
- export { EffectAdapter };
@@ -1,62 +0,0 @@
1
- import "node:module";
2
- import { isRecord, normalizeExpose } from "./utils.mjs";
3
- function decodeDataUrl(url) {
4
- const commaIndex = url.indexOf(',');
5
- if (commaIndex < 0) throw new Error('[BFF][Effect] Invalid backend federation data URL entry.');
6
- return decodeURIComponent(url.slice(commaIndex + 1));
7
- }
8
- async function readCommonJsEntrySource(remote) {
9
- if (remote.entry.startsWith('data:')) return decodeDataUrl(remote.entry);
10
- if (remote.entry.startsWith('http://') || remote.entry.startsWith('https://')) {
11
- const response = await fetch(remote.entry);
12
- if (!response.ok) throw new Error(`[BFF][Effect] Failed to load backend federation remote ${remote.name}: ${response.status}`);
13
- return response.text();
14
- }
15
- throw new Error(`[BFF][Effect] Backend federation remote ${remote.name} cannot load CommonJS entry ${remote.entry}.`);
16
- }
17
- function evaluateCommonJsEntry(remote, source) {
18
- const module = {
19
- exports: {}
20
- };
21
- const exports = module.exports;
22
- const evaluate = new Function('module', 'exports', 'globalThis', source);
23
- evaluate(module, exports, globalThis);
24
- const entry = module.exports.default ?? module.exports;
25
- if (!isRecord(entry)) throw new Error(`[BFF][Effect] Backend federation remote ${remote.name} entry must load object module.`);
26
- return entry;
27
- }
28
- async function importModuleEntry(remote) {
29
- const entry = await import(remote.entry);
30
- return entry.default ?? entry;
31
- }
32
- async function resolvePluginEntry(remote, plugins) {
33
- for (const plugin of plugins ?? []){
34
- const loadEntry = plugin.loadEntry;
35
- if ('function' != typeof loadEntry) continue;
36
- const entry = await loadEntry({
37
- remoteInfo: remote
38
- });
39
- if (entry) return entry;
40
- }
41
- }
42
- async function loadBackendFederationEntry(remote, plugins) {
43
- const pluginEntry = await resolvePluginEntry(remote, plugins);
44
- if (pluginEntry) return pluginEntry;
45
- if (remote.entryGlobalName) {
46
- const globalEntry = globalThis[remote.entryGlobalName];
47
- if (isRecord(globalEntry)) return globalEntry;
48
- }
49
- if ('module' === remote.type || remote.entry.startsWith('file:')) return importModuleEntry(remote);
50
- return evaluateCommonJsEntry(remote, await readCommonJsEntrySource(remote));
51
- }
52
- async function loadBackendFederationExpose(remote, expose, options) {
53
- const entry = await loadBackendFederationEntry(remote, options.plugins);
54
- if ('function' == typeof entry.init) await entry.init({
55
- hostName: options.hostName
56
- });
57
- if ('function' != typeof entry.get) throw new Error(`[BFF][Effect] Backend federation remote ${remote.name} entry must expose get().`);
58
- const factory = await entry.get(expose);
59
- if ('function' != typeof factory) throw new Error(`[BFF][Effect] Backend federation expose ${remote.name}/${normalizeExpose(expose)} must load factory function.`);
60
- return factory();
61
- }
62
- export { loadBackendFederationExpose };
@@ -1,42 +0,0 @@
1
- import "node:module";
2
- import { isRecord } from "./utils.mjs";
3
- function validateExpectedBackendFederationIdentity(loaded, expected, options = {}) {
4
- const allowMissing = true === options.allowMissingIdentityMetadata;
5
- const issues = [];
6
- const contract = isRecord(loaded) ? loaded.backendFederationContract : void 0;
7
- const compatibility = isRecord(contract) ? contract.compatibility : void 0;
8
- if (!isRecord(compatibility)) {
9
- if (allowMissing) return [];
10
- return [
11
- {
12
- path: 'backendFederationContract.compatibility',
13
- message: 'loaded module declares no compatibility metadata; delivery-unit identity cannot be validated'
14
- }
15
- ];
16
- }
17
- const unitId = compatibility.unitId;
18
- if ('string' != typeof unitId || 0 === unitId.length) {
19
- if (!allowMissing) issues.push({
20
- path: 'backendFederationContract.compatibility.unitId',
21
- message: `missing delivery-unit id; expected ${expected.unitId}`
22
- });
23
- } else if (unitId !== expected.unitId) issues.push({
24
- path: 'backendFederationContract.compatibility.unitId',
25
- message: `expected ${expected.unitId}, received ${unitId}`
26
- });
27
- const build = compatibility.build;
28
- if ('string' != typeof build || 0 === build.length) {
29
- if (!allowMissing) issues.push({
30
- path: 'backendFederationContract.compatibility.build',
31
- message: `missing build marker; expected ${expected.buildMarker}`
32
- });
33
- } else if (build !== expected.buildMarker) issues.push({
34
- path: 'backendFederationContract.compatibility.build',
35
- message: `expected ${expected.buildMarker}, received ${build}`
36
- });
37
- return issues;
38
- }
39
- function formatBackendFederationIdentityIssues(issues) {
40
- return issues.map((issue)=>`${issue.path}: ${issue.message}`).join('; ');
41
- }
42
- export { formatBackendFederationIdentityIssues, validateExpectedBackendFederationIdentity };