@bleedingdev/modern-js-plugin-bff 3.8.3-ultramodern.1 → 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 (340) 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 +9 -6
  14. package/dist/cjs/utils/crossProjectApiPlugin.js +5 -1
  15. package/dist/cjs/utils/pluginGenerator.js +4 -4
  16. package/dist/cjs/utils/runtimeGenerator.js +4 -16
  17. package/dist/esm/cli/generator.mjs +45 -53
  18. package/dist/esm/cli/serverGlobalVars.mjs +1 -1
  19. package/dist/esm/cli.mjs +1 -0
  20. package/dist/esm/loader.mjs +5 -16
  21. package/dist/esm/runtime/data-platform/index.mjs +1 -7
  22. package/dist/esm/runtime/effect/edge-dispatcher.mjs +1 -38
  23. package/dist/esm/runtime/effect/edge.mjs +2 -2
  24. package/dist/esm/runtime/effect/index.mjs +16 -8
  25. package/dist/esm/runtime/effect-client/index.mjs +1 -98
  26. package/dist/esm/runtime/effect-client/runtime.mjs +1 -62
  27. package/dist/esm/runtime/hono/adapter.mjs +13 -54
  28. package/dist/esm/server.mjs +2 -2
  29. package/dist/esm/utils/client-generator/generate.mjs +8 -5
  30. package/dist/esm/utils/crossProjectApiPlugin.mjs +3 -2
  31. package/dist/esm/utils/pluginGenerator.mjs +5 -5
  32. package/dist/esm/utils/runtimeGenerator.mjs +4 -16
  33. package/dist/esm-node/cli/generator.mjs +45 -53
  34. package/dist/esm-node/cli/serverGlobalVars.mjs +1 -1
  35. package/dist/esm-node/cli.mjs +1 -0
  36. package/dist/esm-node/loader.mjs +5 -16
  37. package/dist/esm-node/runtime/data-platform/index.mjs +1 -7
  38. package/dist/esm-node/runtime/effect/edge-dispatcher.mjs +1 -38
  39. package/dist/esm-node/runtime/effect/edge.mjs +2 -2
  40. package/dist/esm-node/runtime/effect/index.mjs +16 -8
  41. package/dist/esm-node/runtime/effect-client/index.mjs +1 -98
  42. package/dist/esm-node/runtime/effect-client/runtime.mjs +1 -62
  43. package/dist/esm-node/runtime/hono/adapter.mjs +13 -54
  44. package/dist/esm-node/server.mjs +2 -2
  45. package/dist/esm-node/utils/client-generator/generate.mjs +8 -5
  46. package/dist/esm-node/utils/crossProjectApiPlugin.mjs +3 -2
  47. package/dist/esm-node/utils/pluginGenerator.mjs +5 -5
  48. package/dist/esm-node/utils/runtimeGenerator.mjs +4 -16
  49. package/dist/types/loader.d.ts +1 -0
  50. package/dist/types/runtime/data-platform/index.d.ts +1 -8
  51. package/dist/types/runtime/effect/edge-dispatcher.d.ts +1 -26
  52. package/dist/types/runtime/effect/edge.d.ts +2 -2
  53. package/dist/types/runtime/effect/index.d.ts +15 -7
  54. package/dist/types/runtime/effect-client/index.d.ts +1 -58
  55. package/dist/types/runtime/effect-client/runtime.d.ts +1 -5
  56. package/dist/types/runtime/hono/adapter.d.ts +1 -11
  57. package/dist/types/utils/client-generator/generate.d.ts +2 -1
  58. package/dist/types/utils/crossProjectApiPlugin.d.ts +1 -0
  59. package/dist/types/utils/pluginGenerator.d.ts +2 -1
  60. package/package.json +29 -28
  61. package/dist/cjs/runtime/data-platform/batch/queue.js +0 -284
  62. package/dist/cjs/runtime/data-platform/batch/request.js +0 -98
  63. package/dist/cjs/runtime/data-platform/batch/response.js +0 -64
  64. package/dist/cjs/runtime/data-platform/batch/telemetry.js +0 -67
  65. package/dist/cjs/runtime/data-platform/batch/url.js +0 -69
  66. package/dist/cjs/runtime/data-platform/batch-transport.js +0 -59
  67. package/dist/cjs/runtime/data-platform/codec.js +0 -155
  68. package/dist/cjs/runtime/data-platform/invalidation.js +0 -61
  69. package/dist/cjs/runtime/data-platform/trace.js +0 -73
  70. package/dist/cjs/runtime/data-platform/types.js +0 -48
  71. package/dist/cjs/runtime/data-platform/validation.js +0 -178
  72. package/dist/cjs/runtime/effect/adapter/constants.js +0 -44
  73. package/dist/cjs/runtime/effect/adapter/cross-project-policy.js +0 -66
  74. package/dist/cjs/runtime/effect/adapter/entry.js +0 -100
  75. package/dist/cjs/runtime/effect/adapter/error-response.js +0 -81
  76. package/dist/cjs/runtime/effect/adapter/handler.js +0 -53
  77. package/dist/cjs/runtime/effect/adapter.js +0 -155
  78. package/dist/cjs/runtime/effect/backend-federation/entry.js +0 -99
  79. package/dist/cjs/runtime/effect/backend-federation/identity.js +0 -82
  80. package/dist/cjs/runtime/effect/backend-federation/load.js +0 -75
  81. package/dist/cjs/runtime/effect/backend-federation/plugin.js +0 -63
  82. package/dist/cjs/runtime/effect/backend-federation/remotes.js +0 -51
  83. package/dist/cjs/runtime/effect/backend-federation/runtime.js +0 -128
  84. package/dist/cjs/runtime/effect/backend-federation/types.js +0 -18
  85. package/dist/cjs/runtime/effect/backend-federation/utils.js +0 -48
  86. package/dist/cjs/runtime/effect/backend-federation-manifest/errors.js +0 -83
  87. package/dist/cjs/runtime/effect/backend-federation-manifest/index.js +0 -55
  88. package/dist/cjs/runtime/effect/backend-federation-manifest/load.js +0 -94
  89. package/dist/cjs/runtime/effect/backend-federation-manifest/metadata.js +0 -101
  90. package/dist/cjs/runtime/effect/backend-federation-manifest/reference.js +0 -120
  91. package/dist/cjs/runtime/effect/backend-federation-manifest/remote.js +0 -68
  92. package/dist/cjs/runtime/effect/backend-federation-manifest/types.js +0 -18
  93. package/dist/cjs/runtime/effect/backend-federation-manifest/validation.js +0 -109
  94. package/dist/cjs/runtime/effect/backend-federation-manifest.js +0 -62
  95. package/dist/cjs/runtime/effect/backend-federation.js +0 -65
  96. package/dist/cjs/runtime/effect/context.js +0 -60
  97. package/dist/cjs/runtime/effect/dispatch.js +0 -101
  98. package/dist/cjs/runtime/effect/edge-context.js +0 -81
  99. package/dist/cjs/runtime/effect/endpoint-contracts.js +0 -121
  100. package/dist/cjs/runtime/effect/entry-shape.js +0 -84
  101. package/dist/cjs/runtime/effect/handler/batch-handler.js +0 -161
  102. package/dist/cjs/runtime/effect/handler/batch.js +0 -159
  103. package/dist/cjs/runtime/effect/handler/definition.js +0 -102
  104. package/dist/cjs/runtime/effect/handler/envelope.js +0 -104
  105. package/dist/cjs/runtime/effect/handler/http.js +0 -107
  106. package/dist/cjs/runtime/effect/handler/openapi.js +0 -57
  107. package/dist/cjs/runtime/effect/handler/routing.js +0 -100
  108. package/dist/cjs/runtime/effect/handler/rpc.js +0 -63
  109. package/dist/cjs/runtime/effect/handler/types.js +0 -43
  110. package/dist/cjs/runtime/effect/handler.js +0 -189
  111. package/dist/cjs/runtime/effect/module.js +0 -113
  112. package/dist/cjs/runtime/effect/operation-context.js +0 -103
  113. package/dist/cjs/runtime/effect/rpcSerialization.js +0 -54
  114. package/dist/cjs/runtime/effect-client/batch.js +0 -73
  115. package/dist/cjs/runtime/effect-client/envelope.js +0 -145
  116. package/dist/cjs/runtime/effect-client/guards.js +0 -44
  117. package/dist/cjs/runtime/effect-client/request-context.js +0 -64
  118. package/dist/cjs/runtime/effect-client/request.js +0 -66
  119. package/dist/cjs/runtime/effect-client/types.js +0 -18
  120. package/dist/cjs/runtime/safe-failure.js +0 -84
  121. package/dist/cjs/utils/crossProjectServerPolicy.js +0 -98
  122. package/dist/cjs/utils/effect-client-generator/generator.js +0 -69
  123. package/dist/cjs/utils/effect-client-generator/index.js +0 -51
  124. package/dist/cjs/utils/effect-client-generator/paths.js +0 -62
  125. package/dist/cjs/utils/effect-client-generator/rendering.js +0 -220
  126. package/dist/cjs/utils/effect-client-generator/runtime.js +0 -68
  127. package/dist/cjs/utils/effect-client-generator/types.js +0 -18
  128. package/dist/cjs/utils/effectClientGenerator.js +0 -49
  129. package/dist/cjs/utils/effectSourceLoader.js +0 -312
  130. package/dist/cjs/utils/headers.js +0 -46
  131. package/dist/esm/runtime/data-platform/batch/queue.mjs +0 -246
  132. package/dist/esm/runtime/data-platform/batch/request.mjs +0 -45
  133. package/dist/esm/runtime/data-platform/batch/response.mjs +0 -23
  134. package/dist/esm/runtime/data-platform/batch/telemetry.mjs +0 -23
  135. package/dist/esm/runtime/data-platform/batch/url.mjs +0 -25
  136. package/dist/esm/runtime/data-platform/batch-transport.mjs +0 -12
  137. package/dist/esm/runtime/data-platform/codec.mjs +0 -90
  138. package/dist/esm/runtime/data-platform/invalidation.mjs +0 -20
  139. package/dist/esm/runtime/data-platform/trace.mjs +0 -29
  140. package/dist/esm/runtime/data-platform/types.mjs +0 -4
  141. package/dist/esm/runtime/data-platform/validation.mjs +0 -128
  142. package/dist/esm/runtime/effect/adapter/constants.mjs +0 -6
  143. package/dist/esm/runtime/effect/adapter/cross-project-policy.mjs +0 -28
  144. package/dist/esm/runtime/effect/adapter/entry.mjs +0 -52
  145. package/dist/esm/runtime/effect/adapter/error-response.mjs +0 -43
  146. package/dist/esm/runtime/effect/adapter/handler.mjs +0 -15
  147. package/dist/esm/runtime/effect/adapter.mjs +0 -107
  148. package/dist/esm/runtime/effect/backend-federation/entry.mjs +0 -61
  149. package/dist/esm/runtime/effect/backend-federation/identity.mjs +0 -41
  150. package/dist/esm/runtime/effect/backend-federation/load.mjs +0 -37
  151. package/dist/esm/runtime/effect/backend-federation/plugin.mjs +0 -25
  152. package/dist/esm/runtime/effect/backend-federation/remotes.mjs +0 -13
  153. package/dist/esm/runtime/effect/backend-federation/runtime.mjs +0 -90
  154. package/dist/esm/runtime/effect/backend-federation/types.mjs +0 -0
  155. package/dist/esm/runtime/effect/backend-federation/utils.mjs +0 -7
  156. package/dist/esm/runtime/effect/backend-federation-manifest/errors.mjs +0 -32
  157. package/dist/esm/runtime/effect/backend-federation-manifest/index.mjs +0 -4
  158. package/dist/esm/runtime/effect/backend-federation-manifest/load.mjs +0 -56
  159. package/dist/esm/runtime/effect/backend-federation-manifest/metadata.mjs +0 -42
  160. package/dist/esm/runtime/effect/backend-federation-manifest/reference.mjs +0 -76
  161. package/dist/esm/runtime/effect/backend-federation-manifest/remote.mjs +0 -30
  162. package/dist/esm/runtime/effect/backend-federation-manifest/types.mjs +0 -0
  163. package/dist/esm/runtime/effect/backend-federation-manifest/validation.mjs +0 -65
  164. package/dist/esm/runtime/effect/backend-federation-manifest.mjs +0 -1
  165. package/dist/esm/runtime/effect/backend-federation.mjs +0 -5
  166. package/dist/esm/runtime/effect/context.mjs +0 -13
  167. package/dist/esm/runtime/effect/dispatch.mjs +0 -63
  168. package/dist/esm/runtime/effect/edge-context.mjs +0 -34
  169. package/dist/esm/runtime/effect/endpoint-contracts.mjs +0 -68
  170. package/dist/esm/runtime/effect/entry-shape.mjs +0 -36
  171. package/dist/esm/runtime/effect/handler/batch-handler.mjs +0 -123
  172. package/dist/esm/runtime/effect/handler/batch.mjs +0 -97
  173. package/dist/esm/runtime/effect/handler/definition.mjs +0 -61
  174. package/dist/esm/runtime/effect/handler/envelope.mjs +0 -63
  175. package/dist/esm/runtime/effect/handler/http.mjs +0 -69
  176. package/dist/esm/runtime/effect/handler/openapi.mjs +0 -19
  177. package/dist/esm/runtime/effect/handler/routing.mjs +0 -50
  178. package/dist/esm/runtime/effect/handler/rpc.mjs +0 -22
  179. package/dist/esm/runtime/effect/handler/types.mjs +0 -5
  180. package/dist/esm/runtime/effect/handler.mjs +0 -14
  181. package/dist/esm/runtime/effect/module.mjs +0 -75
  182. package/dist/esm/runtime/effect/operation-context.mjs +0 -65
  183. package/dist/esm/runtime/effect/rpcSerialization.mjs +0 -16
  184. package/dist/esm/runtime/effect-client/batch.mjs +0 -35
  185. package/dist/esm/runtime/effect-client/envelope.mjs +0 -104
  186. package/dist/esm/runtime/effect-client/guards.mjs +0 -3
  187. package/dist/esm/runtime/effect-client/request-context.mjs +0 -23
  188. package/dist/esm/runtime/effect-client/request.mjs +0 -28
  189. package/dist/esm/runtime/effect-client/types.mjs +0 -0
  190. package/dist/esm/runtime/safe-failure.mjs +0 -46
  191. package/dist/esm/utils/crossProjectServerPolicy.mjs +0 -44
  192. package/dist/esm/utils/effect-client-generator/generator.mjs +0 -28
  193. package/dist/esm/utils/effect-client-generator/index.mjs +0 -3
  194. package/dist/esm/utils/effect-client-generator/paths.mjs +0 -24
  195. package/dist/esm/utils/effect-client-generator/rendering.mjs +0 -179
  196. package/dist/esm/utils/effect-client-generator/runtime.mjs +0 -27
  197. package/dist/esm/utils/effect-client-generator/types.mjs +0 -0
  198. package/dist/esm/utils/effectClientGenerator.mjs +0 -1
  199. package/dist/esm/utils/effectSourceLoader.mjs +0 -256
  200. package/dist/esm/utils/headers.mjs +0 -8
  201. package/dist/esm-node/runtime/data-platform/batch/queue.mjs +0 -247
  202. package/dist/esm-node/runtime/data-platform/batch/request.mjs +0 -46
  203. package/dist/esm-node/runtime/data-platform/batch/response.mjs +0 -24
  204. package/dist/esm-node/runtime/data-platform/batch/telemetry.mjs +0 -24
  205. package/dist/esm-node/runtime/data-platform/batch/url.mjs +0 -26
  206. package/dist/esm-node/runtime/data-platform/batch-transport.mjs +0 -13
  207. package/dist/esm-node/runtime/data-platform/codec.mjs +0 -91
  208. package/dist/esm-node/runtime/data-platform/invalidation.mjs +0 -21
  209. package/dist/esm-node/runtime/data-platform/trace.mjs +0 -30
  210. package/dist/esm-node/runtime/data-platform/types.mjs +0 -5
  211. package/dist/esm-node/runtime/data-platform/validation.mjs +0 -129
  212. package/dist/esm-node/runtime/effect/adapter/constants.mjs +0 -7
  213. package/dist/esm-node/runtime/effect/adapter/cross-project-policy.mjs +0 -29
  214. package/dist/esm-node/runtime/effect/adapter/entry.mjs +0 -53
  215. package/dist/esm-node/runtime/effect/adapter/error-response.mjs +0 -44
  216. package/dist/esm-node/runtime/effect/adapter/handler.mjs +0 -16
  217. package/dist/esm-node/runtime/effect/adapter.mjs +0 -108
  218. package/dist/esm-node/runtime/effect/backend-federation/entry.mjs +0 -62
  219. package/dist/esm-node/runtime/effect/backend-federation/identity.mjs +0 -42
  220. package/dist/esm-node/runtime/effect/backend-federation/load.mjs +0 -38
  221. package/dist/esm-node/runtime/effect/backend-federation/plugin.mjs +0 -26
  222. package/dist/esm-node/runtime/effect/backend-federation/remotes.mjs +0 -14
  223. package/dist/esm-node/runtime/effect/backend-federation/runtime.mjs +0 -91
  224. package/dist/esm-node/runtime/effect/backend-federation/types.mjs +0 -1
  225. package/dist/esm-node/runtime/effect/backend-federation/utils.mjs +0 -8
  226. package/dist/esm-node/runtime/effect/backend-federation-manifest/errors.mjs +0 -33
  227. package/dist/esm-node/runtime/effect/backend-federation-manifest/index.mjs +0 -5
  228. package/dist/esm-node/runtime/effect/backend-federation-manifest/load.mjs +0 -57
  229. package/dist/esm-node/runtime/effect/backend-federation-manifest/metadata.mjs +0 -43
  230. package/dist/esm-node/runtime/effect/backend-federation-manifest/reference.mjs +0 -77
  231. package/dist/esm-node/runtime/effect/backend-federation-manifest/remote.mjs +0 -31
  232. package/dist/esm-node/runtime/effect/backend-federation-manifest/types.mjs +0 -1
  233. package/dist/esm-node/runtime/effect/backend-federation-manifest/validation.mjs +0 -66
  234. package/dist/esm-node/runtime/effect/backend-federation-manifest.mjs +0 -2
  235. package/dist/esm-node/runtime/effect/backend-federation.mjs +0 -6
  236. package/dist/esm-node/runtime/effect/context.mjs +0 -14
  237. package/dist/esm-node/runtime/effect/dispatch.mjs +0 -64
  238. package/dist/esm-node/runtime/effect/edge-context.mjs +0 -35
  239. package/dist/esm-node/runtime/effect/endpoint-contracts.mjs +0 -69
  240. package/dist/esm-node/runtime/effect/entry-shape.mjs +0 -37
  241. package/dist/esm-node/runtime/effect/handler/batch-handler.mjs +0 -124
  242. package/dist/esm-node/runtime/effect/handler/batch.mjs +0 -98
  243. package/dist/esm-node/runtime/effect/handler/definition.mjs +0 -62
  244. package/dist/esm-node/runtime/effect/handler/envelope.mjs +0 -64
  245. package/dist/esm-node/runtime/effect/handler/http.mjs +0 -70
  246. package/dist/esm-node/runtime/effect/handler/openapi.mjs +0 -20
  247. package/dist/esm-node/runtime/effect/handler/routing.mjs +0 -51
  248. package/dist/esm-node/runtime/effect/handler/rpc.mjs +0 -23
  249. package/dist/esm-node/runtime/effect/handler/types.mjs +0 -6
  250. package/dist/esm-node/runtime/effect/handler.mjs +0 -15
  251. package/dist/esm-node/runtime/effect/module.mjs +0 -76
  252. package/dist/esm-node/runtime/effect/operation-context.mjs +0 -66
  253. package/dist/esm-node/runtime/effect/rpcSerialization.mjs +0 -17
  254. package/dist/esm-node/runtime/effect-client/batch.mjs +0 -36
  255. package/dist/esm-node/runtime/effect-client/envelope.mjs +0 -105
  256. package/dist/esm-node/runtime/effect-client/guards.mjs +0 -4
  257. package/dist/esm-node/runtime/effect-client/request-context.mjs +0 -24
  258. package/dist/esm-node/runtime/effect-client/request.mjs +0 -29
  259. package/dist/esm-node/runtime/effect-client/types.mjs +0 -1
  260. package/dist/esm-node/runtime/safe-failure.mjs +0 -47
  261. package/dist/esm-node/utils/crossProjectServerPolicy.mjs +0 -46
  262. package/dist/esm-node/utils/effect-client-generator/generator.mjs +0 -29
  263. package/dist/esm-node/utils/effect-client-generator/index.mjs +0 -4
  264. package/dist/esm-node/utils/effect-client-generator/paths.mjs +0 -25
  265. package/dist/esm-node/utils/effect-client-generator/rendering.mjs +0 -180
  266. package/dist/esm-node/utils/effect-client-generator/runtime.mjs +0 -29
  267. package/dist/esm-node/utils/effect-client-generator/types.mjs +0 -1
  268. package/dist/esm-node/utils/effectClientGenerator.mjs +0 -2
  269. package/dist/esm-node/utils/effectSourceLoader.mjs +0 -257
  270. package/dist/esm-node/utils/headers.mjs +0 -9
  271. package/dist/types/runtime/data-platform/batch/queue.d.ts +0 -8
  272. package/dist/types/runtime/data-platform/batch/request.d.ts +0 -13
  273. package/dist/types/runtime/data-platform/batch/response.d.ts +0 -3
  274. package/dist/types/runtime/data-platform/batch/telemetry.d.ts +0 -4
  275. package/dist/types/runtime/data-platform/batch/url.d.ts +0 -4
  276. package/dist/types/runtime/data-platform/batch-transport.d.ts +0 -3
  277. package/dist/types/runtime/data-platform/codec.d.ts +0 -17
  278. package/dist/types/runtime/data-platform/invalidation.d.ts +0 -8
  279. package/dist/types/runtime/data-platform/trace.d.ts +0 -4
  280. package/dist/types/runtime/data-platform/types.d.ts +0 -146
  281. package/dist/types/runtime/data-platform/validation.d.ts +0 -29
  282. package/dist/types/runtime/effect/adapter/constants.d.ts +0 -1
  283. package/dist/types/runtime/effect/adapter/cross-project-policy.d.ts +0 -4
  284. package/dist/types/runtime/effect/adapter/entry.d.ts +0 -2
  285. package/dist/types/runtime/effect/adapter/error-response.d.ts +0 -2
  286. package/dist/types/runtime/effect/adapter/handler.d.ts +0 -7
  287. package/dist/types/runtime/effect/adapter.d.ts +0 -22
  288. package/dist/types/runtime/effect/backend-federation/entry.d.ts +0 -2
  289. package/dist/types/runtime/effect/backend-federation/identity.d.ts +0 -30
  290. package/dist/types/runtime/effect/backend-federation/load.d.ts +0 -13
  291. package/dist/types/runtime/effect/backend-federation/plugin.d.ts +0 -3
  292. package/dist/types/runtime/effect/backend-federation/remotes.d.ts +0 -2
  293. package/dist/types/runtime/effect/backend-federation/runtime.d.ts +0 -3
  294. package/dist/types/runtime/effect/backend-federation/types.d.ts +0 -73
  295. package/dist/types/runtime/effect/backend-federation/utils.d.ts +0 -2
  296. package/dist/types/runtime/effect/backend-federation-manifest/errors.d.ts +0 -11
  297. package/dist/types/runtime/effect/backend-federation-manifest/index.d.ts +0 -6
  298. package/dist/types/runtime/effect/backend-federation-manifest/load.d.ts +0 -3
  299. package/dist/types/runtime/effect/backend-federation-manifest/metadata.d.ts +0 -18
  300. package/dist/types/runtime/effect/backend-federation-manifest/reference.d.ts +0 -4
  301. package/dist/types/runtime/effect/backend-federation-manifest/remote.d.ts +0 -3
  302. package/dist/types/runtime/effect/backend-federation-manifest/types.d.ts +0 -51
  303. package/dist/types/runtime/effect/backend-federation-manifest/validation.d.ts +0 -5
  304. package/dist/types/runtime/effect/backend-federation-manifest.d.ts +0 -1
  305. package/dist/types/runtime/effect/backend-federation.d.ts +0 -7
  306. package/dist/types/runtime/effect/context.d.ts +0 -5
  307. package/dist/types/runtime/effect/dispatch.d.ts +0 -13
  308. package/dist/types/runtime/effect/edge-context.d.ts +0 -5
  309. package/dist/types/runtime/effect/endpoint-contracts.d.ts +0 -66
  310. package/dist/types/runtime/effect/entry-shape.d.ts +0 -31
  311. package/dist/types/runtime/effect/handler/batch-handler.d.ts +0 -11
  312. package/dist/types/runtime/effect/handler/batch.d.ts +0 -13
  313. package/dist/types/runtime/effect/handler/definition.d.ts +0 -7
  314. package/dist/types/runtime/effect/handler/envelope.d.ts +0 -13
  315. package/dist/types/runtime/effect/handler/http.d.ts +0 -15
  316. package/dist/types/runtime/effect/handler/openapi.d.ts +0 -4
  317. package/dist/types/runtime/effect/handler/routing.d.ts +0 -5
  318. package/dist/types/runtime/effect/handler/rpc.d.ts +0 -7
  319. package/dist/types/runtime/effect/handler/types.d.ts +0 -153
  320. package/dist/types/runtime/effect/handler.d.ts +0 -14
  321. package/dist/types/runtime/effect/module.d.ts +0 -36
  322. package/dist/types/runtime/effect/operation-context.d.ts +0 -10
  323. package/dist/types/runtime/effect/rpcSerialization.d.ts +0 -3
  324. package/dist/types/runtime/effect-client/batch.d.ts +0 -2
  325. package/dist/types/runtime/effect-client/envelope.d.ts +0 -15
  326. package/dist/types/runtime/effect-client/guards.d.ts +0 -2
  327. package/dist/types/runtime/effect-client/request-context.d.ts +0 -3
  328. package/dist/types/runtime/effect-client/request.d.ts +0 -1
  329. package/dist/types/runtime/effect-client/types.d.ts +0 -68
  330. package/dist/types/runtime/safe-failure.d.ts +0 -1
  331. package/dist/types/utils/crossProjectServerPolicy.d.ts +0 -36
  332. package/dist/types/utils/effect-client-generator/generator.d.ts +0 -10
  333. package/dist/types/utils/effect-client-generator/index.d.ts +0 -4
  334. package/dist/types/utils/effect-client-generator/paths.d.ts +0 -5
  335. package/dist/types/utils/effect-client-generator/rendering.d.ts +0 -4
  336. package/dist/types/utils/effect-client-generator/runtime.d.ts +0 -12
  337. package/dist/types/utils/effect-client-generator/types.d.ts +0 -27
  338. package/dist/types/utils/effectClientGenerator.d.ts +0 -2
  339. package/dist/types/utils/effectSourceLoader.d.ts +0 -25
  340. package/dist/types/utils/headers.d.ts +0 -1
@@ -1,43 +0,0 @@
1
- import "node:module";
2
- import { backendFederationMetadata, backendFederationVersionBoundary } from "@modern-js/utils/universal";
3
- function stringValue(value) {
4
- return 'string' == typeof value && value.length > 0 ? value : void 0;
5
- }
6
- function isRecord(value) {
7
- return 'object' == typeof value && null !== value;
8
- }
9
- function recordField(value, field) {
10
- const fieldValue = value?.[field];
11
- return isRecord(fieldValue) ? fieldValue : void 0;
12
- }
13
- function resolveRemoteEntryFromMetadata(manifest) {
14
- const metaData = recordField(manifest, 'metaData');
15
- const remoteEntry = recordField(metaData, 'remoteEntry');
16
- const publicPath = stringValue(metaData?.publicPath) ?? stringValue(metaData?.ssrPublicPath);
17
- const entryName = stringValue(remoteEntry?.name);
18
- if (!publicPath || !entryName) return;
19
- const entryPath = stringValue(remoteEntry?.path) ?? '';
20
- const normalizedBase = publicPath.replace(/\/+$/u, '');
21
- const normalizedPath = entryPath.replace(/^\/+|\/+$/gu, '');
22
- return [
23
- normalizedBase,
24
- normalizedPath,
25
- entryName
26
- ].filter(Boolean).join('/');
27
- }
28
- function metadata_backendFederationMetadata(manifest) {
29
- return backendFederationMetadata(manifest);
30
- }
31
- function versionBoundaryMetadata(manifest) {
32
- return backendFederationVersionBoundary(manifest);
33
- }
34
- function deliveryUnitMetadata(record) {
35
- return recordField(record, 'deliveryUnit');
36
- }
37
- function manifestDeliveryUnit(backendFederation, boundary) {
38
- return {
39
- boundary: deliveryUnitMetadata(boundary),
40
- top: deliveryUnitMetadata(backendFederation)
41
- };
42
- }
43
- export { deliveryUnitMetadata, isRecord, manifestDeliveryUnit, metadata_backendFederationMetadata as backendFederationMetadata, recordField, resolveRemoteEntryFromMetadata, stringValue, versionBoundaryMetadata };
@@ -1,77 +0,0 @@
1
- import "node:module";
2
- import { BACKEND_FEDERATION_MANIFEST_FILE } from "../backend-federation.mjs";
3
- import { BackendFederationManifestAdapterError, assertManifestAdapter } from "./errors.mjs";
4
- import { isRecord } from "./metadata.mjs";
5
- function getProcessEnv() {
6
- return "u" > typeof process ? process.env : void 0;
7
- }
8
- function resolveManifestReferenceSource(options) {
9
- if (options.manifestPath) return 'path';
10
- if (options.manifestUrl) return 'url';
11
- if (options.manifestEnv) return 'env';
12
- }
13
- function resolveBackendFederationManifestReference(options) {
14
- if (options.manifestPath) return options.manifestPath;
15
- if (options.manifestUrl) return options.manifestUrl;
16
- if (!options.manifestEnv) return;
17
- return options.env?.[options.manifestEnv] ?? getProcessEnv()?.[options.manifestEnv];
18
- }
19
- function assertExpectedIdentityForReference(options, source) {
20
- if (void 0 === source || 'path' === source || options.allowLegacyManifest) return;
21
- if (options.expected?.unitId && options.expected.buildMarker) return;
22
- throw new BackendFederationManifestAdapterError('version_mismatch', `[BFF][Effect] Backend federation ${source} manifest references require expected.unitId and expected.buildMarker. Pass allowLegacyManifest: true to load legacy manifest references.`, void 0, {
23
- label: 'expected.deliveryUnit',
24
- expected: 'unitId + buildMarker',
25
- received: options.expected,
26
- referenceSource: source
27
- });
28
- }
29
- function isHttpUrl(value) {
30
- return /^https?:\/\//iu.test(value);
31
- }
32
- async function readFileReference(reference) {
33
- const [{ fileURLToPath }, fs] = await Promise.all([
34
- import("node:url"),
35
- import("node:fs/promises")
36
- ]);
37
- const filePath = reference.startsWith('file:') ? fileURLToPath(reference) : reference;
38
- return fs.readFile(filePath, 'utf8');
39
- }
40
- async function withTimeout(promise, timeoutMs, label) {
41
- if (!timeoutMs || timeoutMs <= 0) return promise;
42
- let timeout;
43
- try {
44
- return await Promise.race([
45
- promise,
46
- new Promise((_, reject)=>{
47
- timeout = setTimeout(()=>{
48
- reject(new BackendFederationManifestAdapterError('timeout', `[BFF][Effect] ${label} timed out after ${timeoutMs}ms.`));
49
- }, timeoutMs);
50
- })
51
- ]);
52
- } finally{
53
- if (timeout) clearTimeout(timeout);
54
- }
55
- }
56
- async function loadBackendFederationManifest(options) {
57
- if (options.manifest) return options.manifest;
58
- const reference = resolveBackendFederationManifestReference(options);
59
- if (!reference) throw new BackendFederationManifestAdapterError('manifest_unavailable', `[BFF][Effect] Backend federation manifest reference is missing. Pass manifest, manifestPath, manifestUrl, or manifestEnv for ${BACKEND_FEDERATION_MANIFEST_FILE}.`);
60
- assertExpectedIdentityForReference(options, resolveManifestReferenceSource(options));
61
- try {
62
- const source = isHttpUrl(reference) ? await (async ()=>{
63
- const fetchManifest = options.fetch ?? globalThis.fetch;
64
- if (!fetchManifest) throw new BackendFederationManifestAdapterError('manifest_unavailable', `[BFF][Effect] Backend federation manifest ${reference} requires a fetch implementation.`);
65
- const response = await withTimeout(fetchManifest(reference), options.timeoutMs, `Backend federation manifest ${reference}`);
66
- if (!response.ok) throw new BackendFederationManifestAdapterError('manifest_unavailable', `[BFF][Effect] Backend federation manifest ${reference} returned HTTP ${response.status}${response.statusText ? ` ${response.statusText}` : ''}.`);
67
- return response.text();
68
- })() : await withTimeout(readFileReference(reference), options.timeoutMs, `Backend federation manifest ${reference}`);
69
- const manifest = JSON.parse(source);
70
- assertManifestAdapter(isRecord(manifest), 'manifest_invalid', `[BFF][Effect] Backend federation manifest ${reference} must be a JSON object.`);
71
- return manifest;
72
- } catch (error) {
73
- if (error instanceof BackendFederationManifestAdapterError) throw error;
74
- throw new BackendFederationManifestAdapterError('manifest_unavailable', `[BFF][Effect] Backend federation manifest ${reference} could not be loaded.`, error);
75
- }
76
- }
77
- export { loadBackendFederationManifest, resolveBackendFederationManifestReference, withTimeout };
@@ -1,31 +0,0 @@
1
- import "node:module";
2
- import { backendFederationExposeNames } from "@modern-js/utils/universal";
3
- import { BACKEND_FEDERATION_EFFECT_EXPOSE } from "../backend-federation.mjs";
4
- import { assertManifestAdapter } from "./errors.mjs";
5
- import { backendFederationMetadata, recordField, resolveRemoteEntryFromMetadata, stringValue } from "./metadata.mjs";
6
- function resolveBackendFederationRemoteFromManifest(manifest, remoteOverride = {}) {
7
- const backendFederation = backendFederationMetadata(manifest);
8
- const entry = recordField(manifest, 'entry');
9
- const metaData = recordField(manifest, 'metaData');
10
- const remoteEntry = recordField(metaData, 'remoteEntry');
11
- const remoteName = remoteOverride.name ?? stringValue(backendFederation?.name) ?? stringValue(manifest.name) ?? stringValue(manifest.id);
12
- const remoteEntryUrl = remoteOverride.entry ?? stringValue(backendFederation?.containerEntry) ?? stringValue(entry?.url) ?? resolveRemoteEntryFromMetadata(manifest);
13
- const remoteType = remoteOverride.type ?? stringValue(backendFederation?.remoteType) ?? stringValue(entry?.type) ?? stringValue(remoteEntry?.type) ?? 'module';
14
- const expose = remoteOverride.expose ?? backendFederationExposeNames(backendFederation)[0] ?? BACKEND_FEDERATION_EFFECT_EXPOSE;
15
- assertManifestAdapter(remoteName, 'manifest_invalid', '[BFF][Effect] Backend federation manifest must declare a remote name.');
16
- assertManifestAdapter(remoteEntryUrl, 'manifest_invalid', '[BFF][Effect] Backend federation manifest must declare a backend remote entry URL.');
17
- assertManifestAdapter(expose === BACKEND_FEDERATION_EFFECT_EXPOSE, 'manifest_invalid', `[BFF][Effect] Backend federation manifest expose must be ${BACKEND_FEDERATION_EFFECT_EXPOSE}.`);
18
- return {
19
- name: remoteName,
20
- entry: remoteEntryUrl,
21
- type: remoteType,
22
- ...remoteOverride.entryGlobalName ? {
23
- entryGlobalName: remoteOverride.entryGlobalName
24
- } : {},
25
- expose,
26
- ...remoteOverride.shareScope ? {
27
- shareScope: remoteOverride.shareScope
28
- } : {}
29
- };
30
- }
31
- export { resolveBackendFederationRemoteFromManifest };
@@ -1 +0,0 @@
1
- import "node:module";
@@ -1,66 +0,0 @@
1
- import "node:module";
2
- import { formatBackendFederationValidationErrors, validateBackendFederationManifest } from "@modern-js/utils/universal";
3
- import { BACKEND_FEDERATION_CONTRACT_VERSION, BACKEND_FEDERATION_NODE_ADAPTER_VERSION } from "../backend-federation.mjs";
4
- import { BackendFederationManifestAdapterError, assertConsistentValue, assertManifestAdapter, assertVersionValue } from "./errors.mjs";
5
- import { backendFederationMetadata, manifestDeliveryUnit, recordField, stringValue, versionBoundaryMetadata } from "./metadata.mjs";
6
- function resolveExpectedBuildMarker(expected) {
7
- if (void 0 !== expected.buildVersion && void 0 !== expected.buildMarker && expected.buildVersion !== expected.buildMarker) throw new BackendFederationManifestAdapterError('version_mismatch', `[BFF][Effect] Backend federation expected buildVersion/buildMarker mismatch: buildVersion ${expected.buildVersion}, buildMarker ${expected.buildMarker}.`, void 0, {
8
- label: 'expected.buildVersion/buildMarker',
9
- expected: expected.buildVersion,
10
- received: expected.buildMarker
11
- });
12
- return expected.buildMarker;
13
- }
14
- function validation_validateBackendFederationManifest(manifest, expected = {}) {
15
- const expectedBuildMarker = resolveExpectedBuildMarker(expected);
16
- const backendFederation = backendFederationMetadata(manifest);
17
- assertManifestAdapter(backendFederation, 'manifest_invalid', '[BFF][Effect] Backend federation manifest must declare backendFederation metadata.');
18
- const manifestShape = validateBackendFederationManifest(manifest, {
19
- expectedContractVersion: false,
20
- expectedNodeAdapterVersion: false,
21
- validateDeliveryUnit: false
22
- });
23
- assertManifestAdapter(manifestShape.ok, 'manifest_invalid', `[BFF][Effect] Backend federation manifest schema invalid: ${formatBackendFederationValidationErrors(manifestShape.errors)}.`);
24
- assertManifestAdapter('effect' === backendFederation.runtimeFramework, 'strict_effect_required', '[BFF][Effect] Backend federation manifest must declare runtimeFramework: "effect".');
25
- assertManifestAdapter(true === backendFederation.strictEffectApproach, 'strict_effect_required', '[BFF][Effect] Backend federation manifest must declare strictEffectApproach: true.');
26
- assertVersionValue(stringValue(backendFederation.contractVersion), expected.contractVersion ?? BACKEND_FEDERATION_CONTRACT_VERSION, 'manifest contractVersion');
27
- assertVersionValue(stringValue(backendFederation.nodeAdapterVersion), expected.nodeAdapterVersion ?? BACKEND_FEDERATION_NODE_ADAPTER_VERSION, 'manifest nodeAdapterVersion');
28
- const boundary = versionBoundaryMetadata(manifest);
29
- assertVersionValue(stringValue(backendFederation.name) ?? stringValue(manifest.name) ?? stringValue(manifest.id), expected.remoteName, 'manifest remoteName');
30
- assertVersionValue(stringValue(boundary?.packageName), expected.packageName, 'versionBoundary.packageName');
31
- assertVersionValue(stringValue(boundary?.version), expected.version, 'versionBoundary.version');
32
- assertVersionValue(stringValue(boundary?.buildVersion), expected.buildVersion, 'versionBoundary.buildVersion');
33
- assertConsistentValue(stringValue(manifest.version), stringValue(boundary?.version), 'manifest versionBoundary.version');
34
- assertConsistentValue(stringValue(manifest.buildVersion), stringValue(boundary?.buildVersion), 'manifest versionBoundary.buildVersion');
35
- const deliveryUnit = manifestDeliveryUnit(backendFederation, boundary);
36
- assertConsistentValue(stringValue(deliveryUnit.boundary?.buildMarker), stringValue(boundary?.buildVersion), 'versionBoundary.deliveryUnit.buildMarker vs versionBoundary.buildVersion');
37
- assertConsistentValue(stringValue(deliveryUnit.top?.unitId), stringValue(deliveryUnit.boundary?.unitId), 'backendFederation.deliveryUnit.unitId vs versionBoundary.deliveryUnit.unitId');
38
- const manifestUnitId = stringValue(deliveryUnit.boundary?.unitId) ?? stringValue(deliveryUnit.top?.unitId);
39
- assertVersionValue(manifestUnitId, expected.unitId, 'deliveryUnit.unitId');
40
- assertVersionValue(stringValue(deliveryUnit.boundary?.buildMarker), expectedBuildMarker, 'deliveryUnit.buildMarker');
41
- }
42
- function validateLoadedBackendFederationContract(loaded, manifest, remote) {
43
- const loadedContract = loaded.backendFederationContract;
44
- const backendFederation = backendFederationMetadata(manifest);
45
- const boundary = versionBoundaryMetadata(manifest);
46
- const compatibility = recordField(loadedContract, 'compatibility');
47
- assertManifestAdapter(compatibility, 'version_mismatch', `[BFF][Effect] Backend federation expose ${remote.name}/${remote.expose?.replace(/^\.\//u, '')} must declare compatibility metadata.`);
48
- assertVersionValue(stringValue(loadedContract?.role), 'microvertical-server', 'expose role');
49
- assertVersionValue(stringValue(loadedContract?.name), remote.name, 'expose name');
50
- assertVersionValue(stringValue(compatibility.contractVersion), stringValue(backendFederation?.contractVersion), 'expose contractVersion');
51
- assertVersionValue(stringValue(compatibility.nodeAdapterVersion), stringValue(backendFederation?.nodeAdapterVersion), 'expose nodeAdapterVersion');
52
- assertVersionValue(stringValue(compatibility.packageName), stringValue(boundary?.packageName), 'expose packageName');
53
- assertVersionValue(stringValue(compatibility.build), stringValue(boundary?.buildVersion), 'expose buildVersion');
54
- const deliveryUnit = manifestDeliveryUnit(backendFederation, boundary);
55
- const manifestUnitId = stringValue(deliveryUnit.boundary?.unitId) ?? stringValue(deliveryUnit.top?.unitId);
56
- const manifestBuildMarker = stringValue(deliveryUnit.boundary?.buildMarker);
57
- assertConsistentValue(manifestUnitId, stringValue(compatibility.unitId), 'deliveryUnit.unitId vs expose compatibility.unitId');
58
- assertConsistentValue(manifestBuildMarker, stringValue(compatibility.build), 'deliveryUnit.buildMarker vs expose compatibility.build');
59
- }
60
- function classifyLoadError(error) {
61
- const message = error instanceof Error ? error.message : String(error);
62
- if (message.includes('delivery-unit identity mismatch')) return 'version_mismatch';
63
- if (message.includes('strictEffectApproach') || message.includes('runtimeFramework')) return 'strict_effect_required';
64
- return 'remote_unavailable';
65
- }
66
- export { classifyLoadError, validateLoadedBackendFederationContract, validation_validateBackendFederationManifest as validateBackendFederationManifest };
@@ -1,2 +0,0 @@
1
- import "node:module";
2
- export * from "./backend-federation-manifest/index.mjs";
@@ -1,6 +0,0 @@
1
- import "node:module";
2
- export { BACKEND_FEDERATION_CONTRACT_VERSION, BACKEND_FEDERATION_EFFECT_EXPOSE, BACKEND_FEDERATION_MANIFEST_FILE, BACKEND_FEDERATION_NODE_ADAPTER_VERSION } from "@modern-js/utils/universal";
3
- export { validateExpectedBackendFederationIdentity } from "./backend-federation/identity.mjs";
4
- export { loadBackendFederatedEffectApi } from "./backend-federation/load.mjs";
5
- export { createBackendFederationLoadEntryPlugin } from "./backend-federation/plugin.mjs";
6
- export { createBackendFederationRuntime } from "./backend-federation/runtime.mjs";
@@ -1,14 +0,0 @@
1
- import "node:module";
2
- import { AsyncLocalStorage } from "node:async_hooks";
3
- const kEffectContextStorage = Symbol.for('modernjs.plugin-bff.effectContextStorage');
4
- const globalStore = globalThis;
5
- const effectContextStorage = globalStore[kEffectContextStorage] ?? (globalStore[kEffectContextStorage] = new AsyncLocalStorage());
6
- const runWithEffectContext = (context, cb)=>effectContextStorage.run(context, cb);
7
- const useEffectContext = ()=>{
8
- const context = effectContextStorage.getStore();
9
- if (!context) throw new Error("Can't call useEffectContext out of Effect runtime scope");
10
- return context;
11
- };
12
- const useOperationContext = ()=>useEffectContext().operationContext;
13
- export { createEffectOperationContext } from "./operation-context.mjs";
14
- export { runWithEffectContext, useEffectContext, useOperationContext };
@@ -1,64 +0,0 @@
1
- import "node:module";
2
- import { createSafeFailureResponse } from "../safe-failure.mjs";
3
- import { createEffectOperationContext } from "./operation-context.mjs";
4
- function normalizeEffectBffPrefix(prefix) {
5
- if (!prefix || '/' === prefix) return '';
6
- return prefix.endsWith('/') ? prefix.slice(0, -1) : prefix;
7
- }
8
- function removeEffectBffPrefixFromPath(pathname, prefix) {
9
- const normalized = normalizeEffectBffPrefix(prefix);
10
- if (!normalized || pathname !== normalized && !pathname.startsWith(`${normalized}/`)) return pathname;
11
- const sliced = pathname.slice(normalized.length);
12
- return sliced.startsWith('/') ? sliced : `/${sliced}`;
13
- }
14
- function matchesEffectBffPrefix(pathname, prefix) {
15
- const normalized = normalizeEffectBffPrefix(prefix);
16
- return !normalized || pathname === normalized || pathname.startsWith(`${normalized}/`);
17
- }
18
- function createEffectBffMountedRequest(req, prefix) {
19
- const url = new URL(req.url);
20
- const nextPath = removeEffectBffPrefixFromPath(url.pathname, prefix);
21
- if (nextPath !== url.pathname) {
22
- url.pathname = nextPath;
23
- return new Request(url, req);
24
- }
25
- return req;
26
- }
27
- function createEffectBffDispatchContext(originalRequest, mountedRequest, options) {
28
- const path = options.path ?? new URL(originalRequest.url).pathname;
29
- const method = options.method ?? originalRequest.method;
30
- const env = options.env ?? {};
31
- return {
32
- request: mountedRequest,
33
- env,
34
- path,
35
- method,
36
- operationContext: createEffectOperationContext({
37
- request: mountedRequest,
38
- env,
39
- path,
40
- method
41
- })
42
- };
43
- }
44
- async function dispatchEffectBffRequestWithContext(handler, request, options) {
45
- const requestPath = new URL(request.url).pathname;
46
- if (!matchesEffectBffPrefix(requestPath, options.prefix)) return new Response('', {
47
- status: 404
48
- });
49
- const mountedRequest = createEffectBffMountedRequest(request, options.prefix);
50
- const effectContext = createEffectBffDispatchContext(request, mountedRequest, options);
51
- try {
52
- const response = await options.runWithEffectContext(effectContext, ()=>handler(mountedRequest, effectContext));
53
- if (!(response instanceof Response)) throw new Error('[BFF][Effect] Effect handler must return Response instance.');
54
- return new Response(response.body, response);
55
- } catch (error) {
56
- if (error instanceof Response) return new Response(error.body, error);
57
- if (options.onError) {
58
- const errorResponse = await options.onError(error, effectContext);
59
- if (errorResponse instanceof Response) return errorResponse;
60
- }
61
- return createSafeFailureResponse(error);
62
- }
63
- }
64
- export { dispatchEffectBffRequestWithContext };
@@ -1,35 +0,0 @@
1
- import "node:module";
2
- const kEffectContext = Symbol.for('modernjs.plugin-bff.edgeEffectContext');
3
- const kEffectContextStorage = Symbol.for('modernjs.plugin-bff.edgeEffectContextStorage');
4
- const globalStore = globalThis;
5
- const isPromiseLike = (value)=>'object' == typeof value && null !== value && 'then' in value && 'function' == typeof value.then;
6
- const getRuntimeStorage = ()=>{
7
- if (globalStore[kEffectContextStorage]) return globalStore[kEffectContextStorage];
8
- if ('function' == typeof globalStore.AsyncLocalStorage) globalStore[kEffectContextStorage] = new globalStore.AsyncLocalStorage();
9
- return globalStore[kEffectContextStorage];
10
- };
11
- const runWithEffectContext = (context, cb)=>{
12
- const storage = getRuntimeStorage();
13
- if (storage) return storage.run(context, cb);
14
- const previous = globalStore[kEffectContext];
15
- globalStore[kEffectContext] = context;
16
- try {
17
- const result = cb();
18
- if (isPromiseLike(result)) return Promise.resolve(result).finally(()=>{
19
- globalStore[kEffectContext] = previous;
20
- });
21
- globalStore[kEffectContext] = previous;
22
- return result;
23
- } catch (error) {
24
- globalStore[kEffectContext] = previous;
25
- throw error;
26
- }
27
- };
28
- const useEffectContext = ()=>{
29
- const context = getRuntimeStorage()?.getStore() ?? globalStore[kEffectContext];
30
- if (!context) throw new Error("Can't call useEffectContext out of Effect runtime scope");
31
- return context;
32
- };
33
- const useOperationContext = ()=>useEffectContext().operationContext;
34
- export { createEffectOperationContext } from "./operation-context.mjs";
35
- export { runWithEffectContext, useEffectContext, useOperationContext };
@@ -1,69 +0,0 @@
1
- import "node:module";
2
- import { createOperationContractHash } from "@modern-js/bff-core";
3
- import { classifyEffectBffEntryModule, isValidatorAwareHandlerFactory } from "./entry-shape.mjs";
4
- function resolveEffectEndpointName(endpoint) {
5
- if ('string' == typeof endpoint.identifier && endpoint.identifier) return endpoint.identifier;
6
- if ('string' == typeof endpoint.name && endpoint.name) return endpoint.name;
7
- return '';
8
- }
9
- function ensureLeadingSlash(pathname) {
10
- return pathname.startsWith('/') ? pathname : `/${pathname}`;
11
- }
12
- function normalizeEffectPrefix(prefix) {
13
- if ('/' === prefix) return '';
14
- return ensureLeadingSlash(prefix || '/api');
15
- }
16
- function getEffectRoutePath(prefix, endpointPath) {
17
- const normalizedPrefix = normalizeEffectPrefix(prefix);
18
- const normalizedEndpointPath = ensureLeadingSlash(endpointPath);
19
- const finalEndpointPath = '/' === normalizedEndpointPath ? '' : endpointPath;
20
- if (!normalizedPrefix && !finalEndpointPath) return '/';
21
- return `${normalizedPrefix}${finalEndpointPath || ''}`;
22
- }
23
- function resolveEffectApiId(api) {
24
- const fallback = 'EffectHttpApi';
25
- if ('identifier' in api && 'string' == typeof api.identifier && api.identifier) return api.identifier;
26
- return fallback;
27
- }
28
- function collectEffectEndpoints(reflect, api, prefix) {
29
- const endpoints = [];
30
- const apiId = resolveEffectApiId(api);
31
- reflect(api, {
32
- onGroup: ()=>{},
33
- onEndpoint: ({ group, endpoint })=>{
34
- endpoints.push({
35
- apiId,
36
- groupName: String(group.identifier),
37
- endpointName: resolveEffectEndpointName(endpoint),
38
- method: String(endpoint.method).toUpperCase(),
39
- routePath: getEffectRoutePath(prefix, String(endpoint.path))
40
- });
41
- }
42
- });
43
- return endpoints.sort((a, b)=>{
44
- if (a.groupName === b.groupName) return a.endpointName.localeCompare(b.endpointName);
45
- return a.groupName.localeCompare(b.groupName);
46
- });
47
- }
48
- function toOperationContractSources(endpoints) {
49
- return endpoints.map(createEffectOperationContractSource);
50
- }
51
- function createEffectOperationContractSource(endpoint) {
52
- return {
53
- name: endpoint.endpointName,
54
- httpMethod: endpoint.method,
55
- routePath: endpoint.routePath
56
- };
57
- }
58
- async function extractHttpApiFromModule(mod, isHttpApi) {
59
- const facts = classifyEffectBffEntryModule(mod, {
60
- isRequestHandler: (value)=>'function' == typeof value,
61
- isValidatorAwareHandlerFactory: isValidatorAwareHandlerFactory,
62
- isHttpApi
63
- });
64
- return !facts?.legacyShape && facts?.api !== void 0 && facts.hasRuntimeLayer && (void 0 === facts.createHandler || facts.createHandlerValidatorAware) ? facts.api : null;
65
- }
66
- function createEffectEndpointContractHash(endpoint, requestId) {
67
- return createOperationContractHash(createEffectOperationContractSource(endpoint), requestId);
68
- }
69
- export { collectEffectEndpoints, createEffectEndpointContractHash, ensureLeadingSlash, extractHttpApiFromModule, normalizeEffectPrefix, toOperationContractSources };
@@ -1,37 +0,0 @@
1
- import "node:module";
2
- const EFFECT_VALIDATOR_AWARE_FACTORY = Symbol.for('modernjs.effect.validatorAware');
3
- function isValidatorAwareHandlerFactory(factory) {
4
- return Boolean('function' == typeof factory && factory[EFFECT_VALIDATOR_AWARE_FACTORY]);
5
- }
6
- const strictEffectApproachMessage = '[BFF][Effect] strictEffectApproach is enforced: Effect API entries export defineEffectBff(...) or { api, layer } HttpApi module. Raw handler exports, default request handlers, unbranded custom createHandler factories not valid Effect API entries.';
7
- function isEffectEntryRecord(value) {
8
- return 'object' == typeof value && null !== value;
9
- }
10
- function classifyEffectBffEntryModule(value, predicates) {
11
- if (!isEffectEntryRecord(value)) return null;
12
- const rootModule = value;
13
- if (predicates.isRequestHandler(rootModule.handler)) return createEntryShapeFacts(rootModule, predicates, '`handler` export');
14
- const defaultEntry = rootModule.default;
15
- if (predicates.isRequestHandler(defaultEntry)) return createEntryShapeFacts(rootModule, predicates, 'default request handler');
16
- const module = isEffectEntryRecord(defaultEntry) ? {
17
- ...rootModule,
18
- ...defaultEntry
19
- } : rootModule;
20
- if (predicates.isRequestHandler(module.handler)) return createEntryShapeFacts(module, predicates, '`handler` export');
21
- return createEntryShapeFacts(module, predicates);
22
- }
23
- function createEntryShapeFacts(module, predicates, legacyShape) {
24
- const createHandler = 'function' == typeof module.createHandler ? module.createHandler : void 0;
25
- const api = predicates.isHttpApi(module.api) ? module.api : void 0;
26
- const hasRuntimeLayer = void 0 !== module.layer;
27
- return {
28
- module,
29
- legacyShape,
30
- createHandler,
31
- createHandlerValidatorAware: void 0 !== createHandler && predicates.isValidatorAwareHandlerFactory(createHandler),
32
- api,
33
- layer: module.layer,
34
- hasRuntimeLayer
35
- };
36
- }
37
- export { EFFECT_VALIDATOR_AWARE_FACTORY, classifyEffectBffEntryModule, isValidatorAwareHandlerFactory, strictEffectApproachMessage };
@@ -1,124 +0,0 @@
1
- import "node:module";
2
- import { DEFAULT_DATA_BATCH_HEADER, DEFAULT_DATA_ENVELOPE_HEADER, decodeRequestEnvelopeHeader, isPlainObject, measureTextBytes, normalizeMethod } from "../../data-platform/index.mjs";
3
- import { createBatchValidationResponse, isBatchRequestPayload, mapWithConcurrency, normalizeBatchAllowedMethods, normalizeBatchPath, promiseWithTimeout, toBatchItemError, toHeaderRecord } from "./batch.mjs";
4
- import { getMountedPrefixFromContext, removeMountedPrefixFromBatchPath } from "./routing.mjs";
5
- function createDataPlatformBatchRequestHandler(options) {
6
- const dataPlatformBatchOptions = options.dataPlatform?.batch;
7
- const batchEnabled = dataPlatformBatchOptions?.enabled !== false;
8
- const batchPath = normalizeBatchPath(dataPlatformBatchOptions?.endpoint);
9
- const batchMaxSize = Math.max(1, dataPlatformBatchOptions?.maxBatchSize ?? 16);
10
- const batchMaxBytes = Math.max(1024, dataPlatformBatchOptions?.maxBatchBytes ?? 65536);
11
- const batchConcurrency = Math.max(1, dataPlatformBatchOptions?.maxConcurrency ?? 4);
12
- const batchItemTimeoutMs = Math.max(0, dataPlatformBatchOptions?.requestTimeoutMs ?? 10000);
13
- const batchAllowedMethods = normalizeBatchAllowedMethods(dataPlatformBatchOptions?.allowedMethods);
14
- const envelopeHeader = options.dataPlatform?.envelopeHeader || DEFAULT_DATA_ENVELOPE_HEADER;
15
- const normalizedEnvelopeHeader = envelopeHeader.toLowerCase();
16
- const handle = async (request, context)=>{
17
- const mountedPrefix = getMountedPrefixFromContext(request, context);
18
- const method = normalizeMethod(request.method);
19
- if ('POST' !== method) return createBatchValidationResponse('Batch endpoint only supports POST requests', 405);
20
- const contentType = request.headers.get('content-type') || '';
21
- if (!contentType.includes('application/json')) return createBatchValidationResponse('Batch endpoint requires application/json content-type', 415);
22
- const payloadText = await request.text();
23
- if (measureTextBytes(payloadText) > batchMaxBytes) return createBatchValidationResponse(`Batch payload exceeds max size (${String(batchMaxBytes)} bytes)`, 413);
24
- let payload;
25
- try {
26
- payload = JSON.parse(payloadText);
27
- } catch {
28
- return createBatchValidationResponse('Invalid batch payload JSON');
29
- }
30
- if (!isBatchRequestPayload(payload)) return createBatchValidationResponse('Invalid batch payload shape');
31
- if (0 === payload.items.length) return createBatchValidationResponse('Batch payload items cannot be empty');
32
- if (payload.items.length > batchMaxSize) return createBatchValidationResponse(`Batch item count exceeds max size (${String(batchMaxSize)})`, 413);
33
- const responseItems = await mapWithConcurrency(payload.items, batchConcurrency, async (rawItem, index)=>{
34
- const fallbackId = `item_${String(index)}`;
35
- const itemId = isPlainObject(rawItem) && 'string' == typeof rawItem.id ? rawItem.id : fallbackId;
36
- if (!isPlainObject(rawItem)) return toBatchItemError(itemId, 400, 'Invalid batch item; expected object');
37
- if ('string' != typeof rawItem.path || 0 === rawItem.path.length) return toBatchItemError(itemId, 400, 'Invalid batch item path');
38
- if (!rawItem.path.startsWith('/')) return toBatchItemError(itemId, 400, 'Batch item path must start with "/"');
39
- const normalizedItemPath = removeMountedPrefixFromBatchPath(rawItem.path, mountedPrefix);
40
- const itemPathname = normalizedItemPath.split('?')[0] || normalizedItemPath;
41
- if (itemPathname === batchPath || itemPathname.startsWith(`${batchPath}/`)) return toBatchItemError(itemId, 400, 'Batch item path cannot target batch endpoint');
42
- const itemMethod = normalizeMethod('string' == typeof rawItem.method ? rawItem.method : void 0);
43
- if (!batchAllowedMethods.has(itemMethod)) return toBatchItemError(itemId, 405, `Batch item method ${itemMethod} is not allowed`);
44
- if (void 0 !== rawItem.body && null !== rawItem.body && 'string' != typeof rawItem.body) return toBatchItemError(itemId, 400, 'Batch item body must be a string when provided');
45
- if (('GET' === itemMethod || 'HEAD' === itemMethod) && 'string' == typeof rawItem.body) return toBatchItemError(itemId, 400, `${itemMethod} batch item cannot include body`);
46
- const normalizedHeaders = {};
47
- if (void 0 !== rawItem.headers) {
48
- if (!isPlainObject(rawItem.headers)) return toBatchItemError(itemId, 400, 'Batch item headers must be an object');
49
- for (const [key, value] of Object.entries(rawItem.headers)){
50
- if ('string' != typeof value) return toBatchItemError(itemId, 400, `Invalid header "${key}" for batch item`);
51
- normalizedHeaders[key.toLowerCase()] = value;
52
- }
53
- }
54
- if (!normalizedHeaders.traceparent) {
55
- const encodedEnvelope = normalizedHeaders[normalizedEnvelopeHeader];
56
- if ('string' == typeof encodedEnvelope) {
57
- const envelope = decodeRequestEnvelopeHeader(encodedEnvelope);
58
- if (envelope?.traceparent) normalizedHeaders.traceparent = envelope.traceparent;
59
- }
60
- }
61
- if (!normalizedHeaders.traceparent) {
62
- const requestTraceparent = request.headers.get('traceparent');
63
- if (requestTraceparent) normalizedHeaders.traceparent = requestTraceparent;
64
- }
65
- const targetUrl = new URL(normalizedItemPath, request.url);
66
- const requestHeaders = new Headers(normalizedHeaders);
67
- const body = 'GET' === itemMethod || 'HEAD' === itemMethod ? void 0 : rawItem.body;
68
- if (void 0 === body) requestHeaders.delete('content-type');
69
- const itemRequest = new Request(targetUrl.toString(), {
70
- method: itemMethod,
71
- headers: requestHeaders,
72
- body
73
- });
74
- try {
75
- const itemResponse = await promiseWithTimeout(options.handleItem(itemRequest, context), batchItemTimeoutMs);
76
- if (!(itemResponse instanceof Response)) return toBatchItemError(itemId, 500, 'Invalid response returned by batch item handler');
77
- const bodyText = await itemResponse.text();
78
- const responseItem = {
79
- id: itemId,
80
- status: itemResponse.status,
81
- headers: toHeaderRecord(itemResponse.headers),
82
- ...bodyText ? {
83
- body: bodyText
84
- } : {}
85
- };
86
- return responseItem;
87
- } catch (error) {
88
- if (error instanceof Response) {
89
- const bodyText = await error.text();
90
- return {
91
- id: itemId,
92
- status: error.status,
93
- headers: toHeaderRecord(error.headers),
94
- ...bodyText ? {
95
- body: bodyText
96
- } : {}
97
- };
98
- }
99
- const message = error instanceof Error ? error.message : String(error);
100
- return toBatchItemError(itemId, 500, message);
101
- }
102
- });
103
- const responsePayload = {
104
- protocolVersion: 1,
105
- batchId: payload.batchId,
106
- receivedAt: Date.now(),
107
- items: responseItems
108
- };
109
- return new Response(JSON.stringify(responsePayload), {
110
- status: 200,
111
- headers: {
112
- 'content-type': 'application/json; charset=utf-8',
113
- [DEFAULT_DATA_BATCH_HEADER]: '1',
114
- 'x-modernjs-data-batch-id': payload.batchId
115
- }
116
- });
117
- };
118
- return {
119
- enabled: batchEnabled,
120
- path: batchPath,
121
- handle
122
- };
123
- }
124
- export { createDataPlatformBatchRequestHandler };