@bleedingdev/modern-js-plugin-bff 3.5.0-ultramodern.9 → 3.5.0-ultramodern.90

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 (332) hide show
  1. package/dist/cjs/cli/compress.js +52 -0
  2. package/dist/cjs/cli/generator.js +184 -0
  3. package/dist/cjs/cli/prefix.js +50 -0
  4. package/dist/cjs/cli/serverGlobalVars.js +127 -0
  5. package/dist/cjs/cli/watch.js +51 -0
  6. package/dist/cjs/cli.js +11 -130
  7. package/dist/cjs/loader.js +19 -2
  8. package/dist/cjs/runtime/data-platform/batch/queue.js +284 -0
  9. package/dist/cjs/runtime/data-platform/batch/request.js +98 -0
  10. package/dist/cjs/runtime/data-platform/batch/response.js +64 -0
  11. package/dist/cjs/runtime/data-platform/batch/telemetry.js +67 -0
  12. package/dist/cjs/runtime/data-platform/batch/url.js +69 -0
  13. package/dist/cjs/runtime/data-platform/batch-transport.js +59 -0
  14. package/dist/cjs/runtime/data-platform/codec.js +155 -0
  15. package/dist/cjs/runtime/data-platform/index.js +30 -633
  16. package/dist/cjs/runtime/data-platform/invalidation.js +61 -0
  17. package/dist/cjs/runtime/data-platform/trace.js +73 -0
  18. package/dist/cjs/runtime/data-platform/types.js +48 -0
  19. package/dist/cjs/runtime/data-platform/validation.js +178 -0
  20. package/dist/cjs/runtime/effect/adapter/constants.js +44 -0
  21. package/dist/cjs/runtime/effect/adapter/cross-project-policy.js +61 -0
  22. package/dist/cjs/runtime/effect/adapter/entry.js +92 -0
  23. package/dist/cjs/runtime/effect/adapter/error-response.js +79 -0
  24. package/dist/cjs/runtime/effect/adapter/handler.js +53 -0
  25. package/dist/cjs/runtime/effect/adapter.js +26 -146
  26. package/dist/cjs/runtime/effect/backend-federation/entry.js +99 -0
  27. package/dist/cjs/runtime/effect/backend-federation/identity.js +82 -0
  28. package/dist/cjs/runtime/effect/backend-federation/load.js +66 -0
  29. package/dist/cjs/runtime/effect/backend-federation/plugin.js +53 -0
  30. package/dist/cjs/runtime/effect/backend-federation/remotes.js +50 -0
  31. package/dist/cjs/runtime/effect/backend-federation/runtime.js +64 -0
  32. package/dist/cjs/runtime/effect/backend-federation/types.js +18 -0
  33. package/dist/cjs/runtime/effect/backend-federation/utils.js +48 -0
  34. package/dist/cjs/runtime/effect/backend-federation-manifest/errors.js +83 -0
  35. package/dist/cjs/runtime/effect/backend-federation-manifest/index.js +55 -0
  36. package/dist/cjs/runtime/effect/backend-federation-manifest/load.js +94 -0
  37. package/dist/cjs/runtime/effect/backend-federation-manifest/metadata.js +101 -0
  38. package/dist/cjs/runtime/effect/backend-federation-manifest/reference.js +120 -0
  39. package/dist/cjs/runtime/effect/backend-federation-manifest/remote.js +68 -0
  40. package/dist/cjs/runtime/effect/backend-federation-manifest/types.js +18 -0
  41. package/dist/cjs/runtime/effect/backend-federation-manifest/validation.js +109 -0
  42. package/dist/cjs/runtime/effect/backend-federation-manifest.js +62 -0
  43. package/dist/cjs/runtime/effect/backend-federation.js +65 -0
  44. package/dist/cjs/runtime/effect/dispatch.js +101 -0
  45. package/dist/cjs/runtime/effect/edge.js +64 -71
  46. package/dist/cjs/runtime/effect/endpoint-contracts.js +7 -21
  47. package/dist/cjs/runtime/effect/entry-shape.js +84 -0
  48. package/dist/cjs/runtime/effect/handler/batch-handler.js +161 -0
  49. package/dist/cjs/runtime/effect/handler/batch.js +195 -0
  50. package/dist/cjs/runtime/effect/handler/definition.js +101 -0
  51. package/dist/cjs/runtime/effect/handler/envelope.js +104 -0
  52. package/dist/cjs/runtime/effect/handler/http.js +96 -0
  53. package/dist/cjs/runtime/effect/handler/openapi.js +57 -0
  54. package/dist/cjs/runtime/effect/handler/routing.js +100 -0
  55. package/dist/cjs/runtime/effect/handler/rpc.js +63 -0
  56. package/dist/cjs/runtime/effect/handler/types.js +43 -0
  57. package/dist/cjs/runtime/effect/handler.js +37 -529
  58. package/dist/cjs/runtime/effect/index.js +91 -15
  59. package/dist/cjs/runtime/effect/module.js +23 -80
  60. package/dist/cjs/runtime/effect/rpcSerialization.js +54 -0
  61. package/dist/cjs/runtime/effect-client/batch.js +73 -0
  62. package/dist/cjs/runtime/effect-client/envelope.js +145 -0
  63. package/dist/cjs/runtime/effect-client/guards.js +44 -0
  64. package/dist/cjs/runtime/effect-client/index.js +6 -16
  65. package/dist/cjs/runtime/effect-client/request-context.js +64 -0
  66. package/dist/cjs/runtime/effect-client/request.js +66 -0
  67. package/dist/cjs/runtime/effect-client/runtime.js +12 -178
  68. package/dist/cjs/runtime/effect-client/types.js +18 -0
  69. package/dist/cjs/runtime/safe-failure.js +2 -1
  70. package/dist/cjs/utils/client-generator/files.js +152 -0
  71. package/dist/cjs/utils/client-generator/generate.js +138 -0
  72. package/dist/cjs/utils/client-generator/index.js +83 -0
  73. package/dist/cjs/utils/client-generator/package-json.js +132 -0
  74. package/dist/cjs/utils/client-generator/write-package.js +125 -0
  75. package/dist/cjs/utils/clientGenerator.js +26 -303
  76. package/dist/cjs/utils/effect-client-generator/generator.js +68 -0
  77. package/dist/cjs/utils/effect-client-generator/index.js +51 -0
  78. package/dist/cjs/utils/effect-client-generator/paths.js +73 -0
  79. package/dist/cjs/utils/effect-client-generator/rendering.js +231 -0
  80. package/dist/cjs/utils/effect-client-generator/runtime.js +85 -0
  81. package/dist/cjs/utils/effect-client-generator/types.js +18 -0
  82. package/dist/cjs/utils/effectClientGenerator.js +5 -262
  83. package/dist/cjs/utils/effectSourceLoader.js +252 -0
  84. package/dist/esm/cli/compress.mjs +14 -0
  85. package/dist/esm/cli/generator.mjs +133 -0
  86. package/dist/esm/cli/prefix.mjs +9 -0
  87. package/dist/esm/cli/serverGlobalVars.mjs +76 -0
  88. package/dist/esm/cli/watch.mjs +13 -0
  89. package/dist/esm/cli.mjs +7 -121
  90. package/dist/esm/loader.mjs +19 -2
  91. package/dist/esm/runtime/data-platform/batch/queue.mjs +246 -0
  92. package/dist/esm/runtime/data-platform/batch/request.mjs +45 -0
  93. package/dist/esm/runtime/data-platform/batch/response.mjs +23 -0
  94. package/dist/esm/runtime/data-platform/batch/telemetry.mjs +23 -0
  95. package/dist/esm/runtime/data-platform/batch/url.mjs +25 -0
  96. package/dist/esm/runtime/data-platform/batch-transport.mjs +12 -0
  97. package/dist/esm/runtime/data-platform/codec.mjs +90 -0
  98. package/dist/esm/runtime/data-platform/index.mjs +6 -610
  99. package/dist/esm/runtime/data-platform/invalidation.mjs +20 -0
  100. package/dist/esm/runtime/data-platform/trace.mjs +29 -0
  101. package/dist/esm/runtime/data-platform/types.mjs +4 -0
  102. package/dist/esm/runtime/data-platform/validation.mjs +128 -0
  103. package/dist/esm/runtime/effect/adapter/constants.mjs +6 -0
  104. package/dist/esm/runtime/effect/adapter/cross-project-policy.mjs +23 -0
  105. package/dist/esm/runtime/effect/adapter/entry.mjs +44 -0
  106. package/dist/esm/runtime/effect/adapter/error-response.mjs +41 -0
  107. package/dist/esm/runtime/effect/adapter/handler.mjs +15 -0
  108. package/dist/esm/runtime/effect/adapter.mjs +27 -147
  109. package/dist/esm/runtime/effect/backend-federation/entry.mjs +61 -0
  110. package/dist/esm/runtime/effect/backend-federation/identity.mjs +41 -0
  111. package/dist/esm/runtime/effect/backend-federation/load.mjs +28 -0
  112. package/dist/esm/runtime/effect/backend-federation/plugin.mjs +15 -0
  113. package/dist/esm/runtime/effect/backend-federation/remotes.mjs +12 -0
  114. package/dist/esm/runtime/effect/backend-federation/runtime.mjs +26 -0
  115. package/dist/esm/runtime/effect/backend-federation/types.mjs +0 -0
  116. package/dist/esm/runtime/effect/backend-federation/utils.mjs +7 -0
  117. package/dist/esm/runtime/effect/backend-federation-manifest/errors.mjs +32 -0
  118. package/dist/esm/runtime/effect/backend-federation-manifest/index.mjs +4 -0
  119. package/dist/esm/runtime/effect/backend-federation-manifest/load.mjs +56 -0
  120. package/dist/esm/runtime/effect/backend-federation-manifest/metadata.mjs +42 -0
  121. package/dist/esm/runtime/effect/backend-federation-manifest/reference.mjs +76 -0
  122. package/dist/esm/runtime/effect/backend-federation-manifest/remote.mjs +30 -0
  123. package/dist/esm/runtime/effect/backend-federation-manifest/types.mjs +0 -0
  124. package/dist/esm/runtime/effect/backend-federation-manifest/validation.mjs +65 -0
  125. package/dist/esm/runtime/effect/backend-federation-manifest.mjs +1 -0
  126. package/dist/esm/runtime/effect/backend-federation.mjs +5 -0
  127. package/dist/esm/runtime/effect/dispatch.mjs +63 -0
  128. package/dist/esm/runtime/effect/edge.mjs +17 -63
  129. package/dist/esm/runtime/effect/endpoint-contracts.mjs +8 -13
  130. package/dist/esm/runtime/effect/entry-shape.mjs +36 -0
  131. package/dist/esm/runtime/effect/handler/batch-handler.mjs +123 -0
  132. package/dist/esm/runtime/effect/handler/batch.mjs +124 -0
  133. package/dist/esm/runtime/effect/handler/definition.mjs +60 -0
  134. package/dist/esm/runtime/effect/handler/envelope.mjs +63 -0
  135. package/dist/esm/runtime/effect/handler/http.mjs +58 -0
  136. package/dist/esm/runtime/effect/handler/openapi.mjs +19 -0
  137. package/dist/esm/runtime/effect/handler/routing.mjs +50 -0
  138. package/dist/esm/runtime/effect/handler/rpc.mjs +22 -0
  139. package/dist/esm/runtime/effect/handler/types.mjs +5 -0
  140. package/dist/esm/runtime/effect/handler.mjs +11 -506
  141. package/dist/esm/runtime/effect/index.mjs +5 -2
  142. package/dist/esm/runtime/effect/module.mjs +25 -82
  143. package/dist/esm/runtime/effect/rpcSerialization.mjs +16 -0
  144. package/dist/esm/runtime/effect-client/batch.mjs +35 -0
  145. package/dist/esm/runtime/effect-client/envelope.mjs +104 -0
  146. package/dist/esm/runtime/effect-client/guards.mjs +3 -0
  147. package/dist/esm/runtime/effect-client/index.mjs +27 -37
  148. package/dist/esm/runtime/effect-client/request-context.mjs +23 -0
  149. package/dist/esm/runtime/effect-client/request.mjs +28 -0
  150. package/dist/esm/runtime/effect-client/runtime.mjs +12 -178
  151. package/dist/esm/runtime/effect-client/types.mjs +0 -0
  152. package/dist/esm/runtime/safe-failure.mjs +2 -1
  153. package/dist/esm/utils/client-generator/files.mjs +68 -0
  154. package/dist/esm/utils/client-generator/generate.mjs +88 -0
  155. package/dist/esm/utils/client-generator/index.mjs +4 -0
  156. package/dist/esm/utils/client-generator/package-json.mjs +78 -0
  157. package/dist/esm/utils/client-generator/write-package.mjs +74 -0
  158. package/dist/esm/utils/clientGenerator.mjs +2 -293
  159. package/dist/esm/utils/effect-client-generator/generator.mjs +27 -0
  160. package/dist/esm/utils/effect-client-generator/index.mjs +3 -0
  161. package/dist/esm/utils/effect-client-generator/paths.mjs +25 -0
  162. package/dist/esm/utils/effect-client-generator/rendering.mjs +180 -0
  163. package/dist/esm/utils/effect-client-generator/runtime.mjs +34 -0
  164. package/dist/esm/utils/effect-client-generator/types.mjs +0 -0
  165. package/dist/esm/utils/effectClientGenerator.mjs +1 -249
  166. package/dist/esm/utils/effectSourceLoader.mjs +199 -0
  167. package/dist/esm-node/cli/compress.mjs +15 -0
  168. package/dist/esm-node/cli/generator.mjs +134 -0
  169. package/dist/esm-node/cli/prefix.mjs +10 -0
  170. package/dist/esm-node/cli/serverGlobalVars.mjs +77 -0
  171. package/dist/esm-node/cli/watch.mjs +14 -0
  172. package/dist/esm-node/cli.mjs +7 -121
  173. package/dist/esm-node/loader.mjs +19 -2
  174. package/dist/esm-node/runtime/data-platform/batch/queue.mjs +247 -0
  175. package/dist/esm-node/runtime/data-platform/batch/request.mjs +46 -0
  176. package/dist/esm-node/runtime/data-platform/batch/response.mjs +24 -0
  177. package/dist/esm-node/runtime/data-platform/batch/telemetry.mjs +24 -0
  178. package/dist/esm-node/runtime/data-platform/batch/url.mjs +26 -0
  179. package/dist/esm-node/runtime/data-platform/batch-transport.mjs +13 -0
  180. package/dist/esm-node/runtime/data-platform/codec.mjs +91 -0
  181. package/dist/esm-node/runtime/data-platform/index.mjs +6 -610
  182. package/dist/esm-node/runtime/data-platform/invalidation.mjs +21 -0
  183. package/dist/esm-node/runtime/data-platform/trace.mjs +30 -0
  184. package/dist/esm-node/runtime/data-platform/types.mjs +5 -0
  185. package/dist/esm-node/runtime/data-platform/validation.mjs +129 -0
  186. package/dist/esm-node/runtime/effect/adapter/constants.mjs +7 -0
  187. package/dist/esm-node/runtime/effect/adapter/cross-project-policy.mjs +24 -0
  188. package/dist/esm-node/runtime/effect/adapter/entry.mjs +45 -0
  189. package/dist/esm-node/runtime/effect/adapter/error-response.mjs +42 -0
  190. package/dist/esm-node/runtime/effect/adapter/handler.mjs +16 -0
  191. package/dist/esm-node/runtime/effect/adapter.mjs +28 -149
  192. package/dist/esm-node/runtime/effect/backend-federation/entry.mjs +62 -0
  193. package/dist/esm-node/runtime/effect/backend-federation/identity.mjs +42 -0
  194. package/dist/esm-node/runtime/effect/backend-federation/load.mjs +29 -0
  195. package/dist/esm-node/runtime/effect/backend-federation/plugin.mjs +16 -0
  196. package/dist/esm-node/runtime/effect/backend-federation/remotes.mjs +13 -0
  197. package/dist/esm-node/runtime/effect/backend-federation/runtime.mjs +27 -0
  198. package/dist/esm-node/runtime/effect/backend-federation/types.mjs +1 -0
  199. package/dist/esm-node/runtime/effect/backend-federation/utils.mjs +8 -0
  200. package/dist/esm-node/runtime/effect/backend-federation-manifest/errors.mjs +33 -0
  201. package/dist/esm-node/runtime/effect/backend-federation-manifest/index.mjs +5 -0
  202. package/dist/esm-node/runtime/effect/backend-federation-manifest/load.mjs +57 -0
  203. package/dist/esm-node/runtime/effect/backend-federation-manifest/metadata.mjs +43 -0
  204. package/dist/esm-node/runtime/effect/backend-federation-manifest/reference.mjs +77 -0
  205. package/dist/esm-node/runtime/effect/backend-federation-manifest/remote.mjs +31 -0
  206. package/dist/esm-node/runtime/effect/backend-federation-manifest/types.mjs +1 -0
  207. package/dist/esm-node/runtime/effect/backend-federation-manifest/validation.mjs +66 -0
  208. package/dist/esm-node/runtime/effect/backend-federation-manifest.mjs +2 -0
  209. package/dist/esm-node/runtime/effect/backend-federation.mjs +6 -0
  210. package/dist/esm-node/runtime/effect/dispatch.mjs +64 -0
  211. package/dist/esm-node/runtime/effect/edge.mjs +17 -63
  212. package/dist/esm-node/runtime/effect/endpoint-contracts.mjs +8 -13
  213. package/dist/esm-node/runtime/effect/entry-shape.mjs +37 -0
  214. package/dist/esm-node/runtime/effect/handler/batch-handler.mjs +124 -0
  215. package/dist/esm-node/runtime/effect/handler/batch.mjs +125 -0
  216. package/dist/esm-node/runtime/effect/handler/definition.mjs +61 -0
  217. package/dist/esm-node/runtime/effect/handler/envelope.mjs +64 -0
  218. package/dist/esm-node/runtime/effect/handler/http.mjs +59 -0
  219. package/dist/esm-node/runtime/effect/handler/openapi.mjs +20 -0
  220. package/dist/esm-node/runtime/effect/handler/routing.mjs +51 -0
  221. package/dist/esm-node/runtime/effect/handler/rpc.mjs +23 -0
  222. package/dist/esm-node/runtime/effect/handler/types.mjs +6 -0
  223. package/dist/esm-node/runtime/effect/handler.mjs +11 -506
  224. package/dist/esm-node/runtime/effect/index.mjs +5 -2
  225. package/dist/esm-node/runtime/effect/module.mjs +25 -82
  226. package/dist/esm-node/runtime/effect/rpcSerialization.mjs +17 -0
  227. package/dist/esm-node/runtime/effect-client/batch.mjs +36 -0
  228. package/dist/esm-node/runtime/effect-client/envelope.mjs +105 -0
  229. package/dist/esm-node/runtime/effect-client/guards.mjs +4 -0
  230. package/dist/esm-node/runtime/effect-client/index.mjs +27 -37
  231. package/dist/esm-node/runtime/effect-client/request-context.mjs +24 -0
  232. package/dist/esm-node/runtime/effect-client/request.mjs +29 -0
  233. package/dist/esm-node/runtime/effect-client/runtime.mjs +12 -178
  234. package/dist/esm-node/runtime/effect-client/types.mjs +1 -0
  235. package/dist/esm-node/runtime/safe-failure.mjs +2 -1
  236. package/dist/esm-node/utils/client-generator/files.mjs +69 -0
  237. package/dist/esm-node/utils/client-generator/generate.mjs +89 -0
  238. package/dist/esm-node/utils/client-generator/index.mjs +5 -0
  239. package/dist/esm-node/utils/client-generator/package-json.mjs +79 -0
  240. package/dist/esm-node/utils/client-generator/write-package.mjs +75 -0
  241. package/dist/esm-node/utils/clientGenerator.mjs +2 -293
  242. package/dist/esm-node/utils/effect-client-generator/generator.mjs +28 -0
  243. package/dist/esm-node/utils/effect-client-generator/index.mjs +4 -0
  244. package/dist/esm-node/utils/effect-client-generator/paths.mjs +26 -0
  245. package/dist/esm-node/utils/effect-client-generator/rendering.mjs +181 -0
  246. package/dist/esm-node/utils/effect-client-generator/runtime.mjs +36 -0
  247. package/dist/esm-node/utils/effect-client-generator/types.mjs +1 -0
  248. package/dist/esm-node/utils/effectClientGenerator.mjs +2 -251
  249. package/dist/esm-node/utils/effectSourceLoader.mjs +200 -0
  250. package/dist/types/cli/compress.d.ts +2 -0
  251. package/dist/types/cli/generator.d.ts +7 -0
  252. package/dist/types/cli/prefix.d.ts +2 -0
  253. package/dist/types/cli/serverGlobalVars.d.ts +4 -0
  254. package/dist/types/cli/watch.d.ts +1 -0
  255. package/dist/types/cli.d.ts +0 -1
  256. package/dist/types/runtime/data-platform/batch/queue.d.ts +8 -0
  257. package/dist/types/runtime/data-platform/batch/request.d.ts +13 -0
  258. package/dist/types/runtime/data-platform/batch/response.d.ts +3 -0
  259. package/dist/types/runtime/data-platform/batch/telemetry.d.ts +4 -0
  260. package/dist/types/runtime/data-platform/batch/url.d.ts +4 -0
  261. package/dist/types/runtime/data-platform/batch-transport.d.ts +3 -0
  262. package/dist/types/runtime/data-platform/codec.d.ts +17 -0
  263. package/dist/types/runtime/data-platform/index.d.ts +7 -191
  264. package/dist/types/runtime/data-platform/invalidation.d.ts +8 -0
  265. package/dist/types/runtime/data-platform/trace.d.ts +4 -0
  266. package/dist/types/runtime/data-platform/types.d.ts +146 -0
  267. package/dist/types/runtime/data-platform/validation.d.ts +29 -0
  268. package/dist/types/runtime/effect/adapter/constants.d.ts +1 -0
  269. package/dist/types/runtime/effect/adapter/cross-project-policy.d.ts +4 -0
  270. package/dist/types/runtime/effect/adapter/entry.d.ts +2 -0
  271. package/dist/types/runtime/effect/adapter/error-response.d.ts +2 -0
  272. package/dist/types/runtime/effect/adapter/handler.d.ts +7 -0
  273. package/dist/types/runtime/effect/adapter.d.ts +4 -13
  274. package/dist/types/runtime/effect/backend-federation/entry.d.ts +2 -0
  275. package/dist/types/runtime/effect/backend-federation/identity.d.ts +30 -0
  276. package/dist/types/runtime/effect/backend-federation/load.d.ts +13 -0
  277. package/dist/types/runtime/effect/backend-federation/plugin.d.ts +3 -0
  278. package/dist/types/runtime/effect/backend-federation/remotes.d.ts +2 -0
  279. package/dist/types/runtime/effect/backend-federation/runtime.d.ts +3 -0
  280. package/dist/types/runtime/effect/backend-federation/types.d.ts +73 -0
  281. package/dist/types/runtime/effect/backend-federation/utils.d.ts +2 -0
  282. package/dist/types/runtime/effect/backend-federation-manifest/errors.d.ts +11 -0
  283. package/dist/types/runtime/effect/backend-federation-manifest/index.d.ts +6 -0
  284. package/dist/types/runtime/effect/backend-federation-manifest/load.d.ts +3 -0
  285. package/dist/types/runtime/effect/backend-federation-manifest/metadata.d.ts +18 -0
  286. package/dist/types/runtime/effect/backend-federation-manifest/reference.d.ts +4 -0
  287. package/dist/types/runtime/effect/backend-federation-manifest/remote.d.ts +3 -0
  288. package/dist/types/runtime/effect/backend-federation-manifest/types.d.ts +51 -0
  289. package/dist/types/runtime/effect/backend-federation-manifest/validation.d.ts +5 -0
  290. package/dist/types/runtime/effect/backend-federation-manifest.d.ts +1 -0
  291. package/dist/types/runtime/effect/backend-federation.d.ts +7 -0
  292. package/dist/types/runtime/effect/dispatch.d.ts +13 -0
  293. package/dist/types/runtime/effect/edge.d.ts +8 -8
  294. package/dist/types/runtime/effect/endpoint-contracts.d.ts +5 -7
  295. package/dist/types/runtime/effect/entry-shape.d.ts +31 -0
  296. package/dist/types/runtime/effect/handler/batch-handler.d.ts +11 -0
  297. package/dist/types/runtime/effect/handler/batch.d.ts +17 -0
  298. package/dist/types/runtime/effect/handler/definition.d.ts +17 -0
  299. package/dist/types/runtime/effect/handler/envelope.d.ts +13 -0
  300. package/dist/types/runtime/effect/handler/http.d.ts +14 -0
  301. package/dist/types/runtime/effect/handler/openapi.d.ts +4 -0
  302. package/dist/types/runtime/effect/handler/routing.d.ts +5 -0
  303. package/dist/types/runtime/effect/handler/rpc.d.ts +7 -0
  304. package/dist/types/runtime/effect/handler/types.d.ts +148 -0
  305. package/dist/types/runtime/effect/handler.d.ts +4 -190
  306. package/dist/types/runtime/effect/index.d.ts +3 -0
  307. package/dist/types/runtime/effect/module.d.ts +3 -2
  308. package/dist/types/runtime/effect/rpcSerialization.d.ts +3 -0
  309. package/dist/types/runtime/effect-client/batch.d.ts +2 -0
  310. package/dist/types/runtime/effect-client/envelope.d.ts +15 -0
  311. package/dist/types/runtime/effect-client/guards.d.ts +2 -0
  312. package/dist/types/runtime/effect-client/index.d.ts +1 -1
  313. package/dist/types/runtime/effect-client/request-context.d.ts +3 -0
  314. package/dist/types/runtime/effect-client/request.d.ts +1 -0
  315. package/dist/types/runtime/effect-client/runtime.d.ts +2 -68
  316. package/dist/types/runtime/effect-client/types.d.ts +68 -0
  317. package/dist/types/utils/client-generator/files.d.ts +28 -0
  318. package/dist/types/utils/client-generator/generate.d.ts +26 -0
  319. package/dist/types/utils/client-generator/index.d.ts +7 -0
  320. package/dist/types/utils/client-generator/package-json.d.ts +16 -0
  321. package/dist/types/utils/client-generator/write-package.d.ts +6 -0
  322. package/dist/types/utils/clientGenerator.d.ts +2 -37
  323. package/dist/types/utils/crossProjectServerPolicy.d.ts +3 -2
  324. package/dist/types/utils/effect-client-generator/generator.d.ts +10 -0
  325. package/dist/types/utils/effect-client-generator/index.d.ts +4 -0
  326. package/dist/types/utils/effect-client-generator/paths.d.ts +5 -0
  327. package/dist/types/utils/effect-client-generator/rendering.d.ts +4 -0
  328. package/dist/types/utils/effect-client-generator/runtime.d.ts +12 -0
  329. package/dist/types/utils/effect-client-generator/types.d.ts +27 -0
  330. package/dist/types/utils/effectClientGenerator.d.ts +2 -41
  331. package/dist/types/utils/effectSourceLoader.d.ts +15 -0
  332. package/package.json +45 -33
@@ -28,640 +28,37 @@ var __webpack_require__ = {};
28
28
  var __webpack_exports__ = {};
29
29
  __webpack_require__.r(__webpack_exports__);
30
30
  __webpack_require__.d(__webpack_exports__, {
31
- DATA_BATCH_TRANSPORT_OTEL_EVENT: ()=>DATA_BATCH_TRANSPORT_OTEL_EVENT,
32
- DEFAULT_DATA_BATCH_ENDPOINT: ()=>DEFAULT_DATA_BATCH_ENDPOINT,
33
- DEFAULT_DATA_BATCH_HEADER: ()=>DEFAULT_DATA_BATCH_HEADER,
34
- DEFAULT_DATA_ENVELOPE_HEADER: ()=>DEFAULT_DATA_ENVELOPE_HEADER,
35
- buildQueryKey: ()=>buildQueryKey,
36
- buildScopeKey: ()=>buildScopeKey,
37
- createDataBatchTransport: ()=>createDataBatchTransport,
38
- createDataBatchTransportTelemetryAttributes: ()=>createDataBatchTransportTelemetryAttributes,
39
- createHydrationEnvelope: ()=>createHydrationEnvelope,
40
- createInvalidationEvent: ()=>createInvalidationEvent,
41
- createOperationId: ()=>createOperationId,
42
- createRequestEnvelope: ()=>createRequestEnvelope,
43
- decodeRequestEnvelopeHeader: ()=>decodeRequestEnvelopeHeader,
44
- deriveChildTraceContext: ()=>deriveChildTraceContext,
45
- emitDataBatchTransportEvent: ()=>emitDataBatchTransportEvent,
46
- encodeRequestEnvelopeHeader: ()=>encodeRequestEnvelopeHeader,
47
- formatTraceparentHeader: ()=>formatTraceparentHeader,
48
- normalizeOrigin: ()=>normalizeOrigin,
49
- parseTraceparentHeader: ()=>parseTraceparentHeader,
50
- shouldApplyInvalidation: ()=>shouldApplyInvalidation,
51
- stableStringify: ()=>stableStringify,
52
- validateHydrationEnvelope: ()=>validateHydrationEnvelope,
53
- validateRequestEnvelope: ()=>validateRequestEnvelope,
54
- validateSelectionPlan: ()=>validateSelectionPlan
31
+ DATA_BATCH_TRANSPORT_OTEL_EVENT: ()=>external_batch_transport_js_namespaceObject.DATA_BATCH_TRANSPORT_OTEL_EVENT,
32
+ DEFAULT_DATA_BATCH_ENDPOINT: ()=>external_types_js_namespaceObject.DEFAULT_DATA_BATCH_ENDPOINT,
33
+ DEFAULT_DATA_BATCH_HEADER: ()=>external_types_js_namespaceObject.DEFAULT_DATA_BATCH_HEADER,
34
+ DEFAULT_DATA_ENVELOPE_HEADER: ()=>external_types_js_namespaceObject.DEFAULT_DATA_ENVELOPE_HEADER,
35
+ buildQueryKey: ()=>external_codec_js_namespaceObject.buildQueryKey,
36
+ buildScopeKey: ()=>external_codec_js_namespaceObject.buildScopeKey,
37
+ createDataBatchTransport: ()=>external_batch_transport_js_namespaceObject.createDataBatchTransport,
38
+ createDataBatchTransportTelemetryAttributes: ()=>external_batch_transport_js_namespaceObject.createDataBatchTransportTelemetryAttributes,
39
+ createHydrationEnvelope: ()=>external_validation_js_namespaceObject.createHydrationEnvelope,
40
+ createInvalidationEvent: ()=>external_invalidation_js_namespaceObject.createInvalidationEvent,
41
+ createOperationId: ()=>external_codec_js_namespaceObject.createOperationId,
42
+ createRequestEnvelope: ()=>external_validation_js_namespaceObject.createRequestEnvelope,
43
+ decodeRequestEnvelopeHeader: ()=>external_codec_js_namespaceObject.decodeRequestEnvelopeHeader,
44
+ deriveChildTraceContext: ()=>external_trace_js_namespaceObject.deriveChildTraceContext,
45
+ emitDataBatchTransportEvent: ()=>external_batch_transport_js_namespaceObject.emitDataBatchTransportEvent,
46
+ encodeRequestEnvelopeHeader: ()=>external_codec_js_namespaceObject.encodeRequestEnvelopeHeader,
47
+ formatTraceparentHeader: ()=>external_trace_js_namespaceObject.formatTraceparentHeader,
48
+ normalizeOrigin: ()=>external_codec_js_namespaceObject.normalizeOrigin,
49
+ parseTraceparentHeader: ()=>external_trace_js_namespaceObject.parseTraceparentHeader,
50
+ shouldApplyInvalidation: ()=>external_invalidation_js_namespaceObject.shouldApplyInvalidation,
51
+ stableStringify: ()=>external_codec_js_namespaceObject.stableStringify,
52
+ validateHydrationEnvelope: ()=>external_validation_js_namespaceObject.validateHydrationEnvelope,
53
+ validateRequestEnvelope: ()=>external_validation_js_namespaceObject.validateRequestEnvelope,
54
+ validateSelectionPlan: ()=>external_validation_js_namespaceObject.validateSelectionPlan
55
55
  });
56
- const create_request_namespaceObject = require("@modern-js/create-request");
57
- const api_namespaceObject = require("@opentelemetry/api");
58
- const DATA_BATCH_TRANSPORT_OTEL_EVENT = 'modernjs.data.batch';
59
- function createDataBatchTransportTelemetryAttributes(event) {
60
- return {
61
- 'modernjs.data.batch.type': event.type,
62
- 'modernjs.data.batch.endpoint': event.endpoint,
63
- 'modernjs.data.batch.degraded': 'fallback' === event.type || 'disable' === event.type,
64
- ...event.batchId ? {
65
- 'modernjs.data.batch.id': event.batchId
66
- } : {},
67
- ...'number' == typeof event.size ? {
68
- 'modernjs.data.batch.size': event.size
69
- } : {},
70
- ...event.reason ? {
71
- 'modernjs.data.batch.reason': event.reason
72
- } : {}
73
- };
74
- }
75
- function emitDataBatchTransportEvent(onEvent, event) {
76
- onEvent?.(event);
77
- api_namespaceObject.trace.getActiveSpan()?.addEvent(DATA_BATCH_TRANSPORT_OTEL_EVENT, createDataBatchTransportTelemetryAttributes(event));
78
- }
79
- const DEFAULT_DATA_ENVELOPE_HEADER = 'x-modernjs-data-envelope';
80
- const DEFAULT_DATA_BATCH_ENDPOINT = '/_data/batch';
81
- const DEFAULT_DATA_BATCH_HEADER = 'x-modernjs-data-batch';
82
- function isPlainObject(value) {
83
- if ('object' != typeof value || null === value || Array.isArray(value)) return false;
84
- const proto = Object.getPrototypeOf(value);
85
- return proto === Object.prototype || null === proto;
86
- }
87
- function canonicalize(value) {
88
- if (Array.isArray(value)) return value.map((item)=>canonicalize(item));
89
- if (isPlainObject(value)) return Object.keys(value).sort().reduce((acc, key)=>{
90
- acc[key] = canonicalize(value[key]);
91
- return acc;
92
- }, {});
93
- return value;
94
- }
95
- function stableStringify(value) {
96
- return JSON.stringify(canonicalize(value));
97
- }
98
- function encodeRequestEnvelopeHeader(envelope) {
99
- return encodeURIComponent(stableStringify(envelope));
100
- }
101
- function isRequestEnvelopeShape(value) {
102
- if (!isPlainObject(value)) return false;
103
- 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;
104
- }
105
- function decodeRequestEnvelopeHeader(value) {
106
- try {
107
- const decoded = decodeURIComponent(value);
108
- const parsed = JSON.parse(decoded);
109
- if (!isRequestEnvelopeShape(parsed)) return null;
110
- return parsed;
111
- } catch {
112
- return null;
113
- }
114
- }
115
- function hashString(value) {
116
- let hash = 0x811c9dc5;
117
- for(let index = 0; index < value.length; index++){
118
- hash ^= value.charCodeAt(index);
119
- hash = Math.imul(hash, 0x01000193);
120
- }
121
- return (hash >>> 0).toString(16).padStart(8, '0');
122
- }
123
- function sanitizeSegment(segment) {
124
- const normalized = segment.trim().replace(/[^a-zA-Z0-9_-]+/g, '_');
125
- return normalized.length > 0 ? normalized : 'unknown';
126
- }
127
- function normalizeOrigin(origin) {
128
- const normalized = origin.trim();
129
- try {
130
- const url = new URL(normalized);
131
- return `${url.protocol}//${url.host}`.toLowerCase();
132
- } catch {
133
- return normalized.toLowerCase();
134
- }
135
- }
136
- function normalizeOperationDescriptor(input) {
137
- return {
138
- appNamespace: sanitizeSegment(input.appNamespace),
139
- apiId: sanitizeSegment(input.apiId),
140
- group: sanitizeSegment(input.group),
141
- endpoint: sanitizeSegment(input.endpoint),
142
- schemaHash: input.schemaHash || null,
143
- version: input.version ?? 1
144
- };
145
- }
146
- function createOperationId(input) {
147
- const descriptor = normalizeOperationDescriptor(input);
148
- const readable = `${descriptor.appNamespace}.${descriptor.apiId}.${descriptor.group}.${descriptor.endpoint}.v${String(descriptor.version)}`;
149
- return `${readable}:${hashString(stableStringify(descriptor))}`;
150
- }
151
- function buildScopeKey(scope) {
152
- const canonical = {
153
- appNamespace: sanitizeSegment(scope.appNamespace),
154
- origin: normalizeOrigin(scope.origin),
155
- tenantId: scope.tenantId ?? null,
156
- userId: scope.userId ?? null,
157
- sessionId: scope.sessionId ?? null
158
- };
159
- return `${canonical.appNamespace}:${hashString(stableStringify(canonical))}`;
160
- }
161
- function buildQueryKey(input) {
162
- const canonical = {
163
- operationId: input.operationId,
164
- scopeKey: input.scopeKey,
165
- requestMode: input.requestMode ?? 'cache-first',
166
- requestInput: input.requestInput ?? null,
167
- selectionPlan: input.selectionPlan ?? null
168
- };
169
- return `${input.operationId}:${hashString(stableStringify(canonical))}`;
170
- }
171
- function isAllZeroHex(value) {
172
- return /^0+$/.test(value);
173
- }
174
- function isValidHex(value, length) {
175
- return value.length === length && /^[0-9a-f]+$/.test(value);
176
- }
177
- function parseTraceparentHeader(header) {
178
- return (0, create_request_namespaceObject.parseTraceparent)(header) ?? null;
179
- }
180
- function formatTraceparentHeader(trace) {
181
- const traceId = trace.traceId.toLowerCase();
182
- const spanId = trace.spanId.toLowerCase();
183
- if (!isValidHex(traceId, 32) || !isValidHex(spanId, 16)) throw new Error('Invalid trace context: traceId/spanId format mismatch');
184
- if (isAllZeroHex(traceId) || isAllZeroHex(spanId)) throw new Error('Invalid trace context: traceId/spanId cannot be zero');
185
- const flags = trace.sampled ? '01' : '00';
186
- return `00-${traceId}-${spanId}-${flags}`;
187
- }
188
- function deriveChildTraceContext(parent, childSpanId) {
189
- const normalizedSpanId = childSpanId.toLowerCase();
190
- if (!isValidHex(normalizedSpanId, 16) || isAllZeroHex(normalizedSpanId)) throw new Error('Invalid child span id');
191
- return {
192
- traceId: parent.traceId.toLowerCase(),
193
- spanId: normalizedSpanId,
194
- sampled: parent.sampled,
195
- parentSpanId: parent.spanId.toLowerCase()
196
- };
197
- }
198
- function validateSelectionPlan(plan, options = {}) {
199
- const maxDepthLimit = options.maxDepth ?? 8;
200
- const maxFieldsLimit = options.maxFields ?? 256;
201
- const allowedLeafPaths = options.allowedLeafPaths ? new Set(options.allowedLeafPaths) : null;
202
- const errors = [];
203
- let maxDepth = 0;
204
- let fieldCount = 0;
205
- const walk = (node, path)=>{
206
- if (!isPlainObject(node)) return void errors.push(`Selection node at "${path.join('.') || '<root>'}" must be an object`);
207
- const keys = Object.keys(node);
208
- if (0 === keys.length) return void errors.push(`Selection node at "${path.join('.') || '<root>'}" cannot be empty`);
209
- for (const key of keys){
210
- fieldCount += 1;
211
- if (fieldCount > maxFieldsLimit) return void errors.push(`Selection has too many fields: ${String(fieldCount)} > ${String(maxFieldsLimit)}`);
212
- const nextPath = [
213
- ...path,
214
- key
215
- ];
216
- const depth = nextPath.length;
217
- if (depth > maxDepth) maxDepth = depth;
218
- if (depth > maxDepthLimit) return void errors.push(`Selection exceeds maxDepth at "${nextPath.join('.')}" (${String(depth)} > ${String(maxDepthLimit)})`);
219
- const value = node[key];
220
- if (true === value) {
221
- if (allowedLeafPaths && !allowedLeafPaths.has(nextPath.join('.'))) errors.push(`Unknown selected field "${nextPath.join('.')}"`);
222
- continue;
223
- }
224
- if (!isPlainObject(value)) {
225
- errors.push(`Invalid selection value at "${nextPath.join('.')}"; expected true or nested object`);
226
- continue;
227
- }
228
- walk(value, nextPath);
229
- }
230
- };
231
- walk(plan, []);
232
- return {
233
- ok: 0 === errors.length,
234
- errors,
235
- stats: {
236
- maxDepth,
237
- fieldCount
238
- }
239
- };
240
- }
241
- function createRequestEnvelope(input) {
242
- if (input.requireTraceContext && !input.traceContext) throw new Error('Trace context is required for this request envelope');
243
- const traceparent = input.traceContext ? formatTraceparentHeader(input.traceContext) : void 0;
244
- const envelope = {
245
- protocolVersion: input.protocolVersion ?? 1,
246
- operationId: createOperationId(input.operation),
247
- appNamespace: sanitizeSegment(input.scope.appNamespace),
248
- origin: normalizeOrigin(input.scope.origin),
249
- requestMode: input.requestMode ?? 'cache-first',
250
- mutationMode: input.mutationMode,
251
- scopeKey: buildScopeKey(input.scope),
252
- input: input.requestInput,
253
- inputHash: hashString(stableStringify(input.requestInput ?? null)),
254
- selectionPlan: input.selectionPlan,
255
- selectionHash: input.selectionPlan ? hashString(stableStringify(input.selectionPlan)) : void 0,
256
- traceparent,
257
- timestamp: input.timestamp ?? Date.now()
258
- };
259
- return envelope;
260
- }
261
- function validateRequestEnvelope(envelope, options = {}) {
262
- const errors = [];
263
- if (void 0 !== options.expectedProtocolVersion && envelope.protocolVersion !== options.expectedProtocolVersion) errors.push(`Protocol mismatch: expected ${String(options.expectedProtocolVersion)} but received ${String(envelope.protocolVersion)}`);
264
- if (options.expectedNamespace && envelope.appNamespace !== options.expectedNamespace) errors.push(`Namespace mismatch: expected ${options.expectedNamespace} but received ${envelope.appNamespace}`);
265
- if (options.expectedOrigin) {
266
- const expectedOrigin = normalizeOrigin(options.expectedOrigin);
267
- if (envelope.origin !== expectedOrigin) errors.push(`Origin mismatch: expected ${expectedOrigin} but received ${envelope.origin}`);
268
- }
269
- if (!envelope.operationId) errors.push('Missing operationId');
270
- if (!envelope.scopeKey) errors.push('Missing scopeKey');
271
- if (options.requireTraceContext && !envelope.traceparent) errors.push('Missing trace context');
272
- if (envelope.traceparent && !parseTraceparentHeader(envelope.traceparent)) errors.push('Invalid traceparent header');
273
- const computedInputHash = hashString(stableStringify(envelope.input ?? null));
274
- if (computedInputHash !== envelope.inputHash) errors.push('Input hash mismatch');
275
- if (envelope.selectionPlan) {
276
- const computedSelectionHash = hashString(stableStringify(envelope.selectionPlan));
277
- if (computedSelectionHash !== envelope.selectionHash) errors.push('Selection hash mismatch');
278
- }
279
- return {
280
- ok: 0 === errors.length,
281
- errors
282
- };
283
- }
284
- function createHydrationEnvelope(input) {
285
- const envelopeWithoutChecksum = {
286
- protocolVersion: input.protocolVersion ?? 1,
287
- runtimeVersion: input.runtimeVersion,
288
- appNamespace: sanitizeSegment(input.scope.appNamespace),
289
- origin: normalizeOrigin(input.scope.origin),
290
- createdAt: input.createdAt ?? Date.now(),
291
- payload: input.payload
292
- };
293
- const checksum = hashString(stableStringify(envelopeWithoutChecksum));
294
- return {
295
- ...envelopeWithoutChecksum,
296
- checksum
297
- };
298
- }
299
- function validateHydrationEnvelope(envelope, options = {}) {
300
- const errors = [];
301
- if (void 0 !== options.expectedProtocolVersion && envelope.protocolVersion !== options.expectedProtocolVersion) errors.push(`Protocol mismatch: expected ${String(options.expectedProtocolVersion)} but received ${String(envelope.protocolVersion)}`);
302
- if (options.expectedNamespace && envelope.appNamespace !== options.expectedNamespace) errors.push(`Namespace mismatch: expected ${options.expectedNamespace} but received ${envelope.appNamespace}`);
303
- if (options.expectedOrigin) {
304
- const expectedOrigin = normalizeOrigin(options.expectedOrigin);
305
- if (envelope.origin !== expectedOrigin) errors.push(`Origin mismatch: expected ${expectedOrigin} but received ${envelope.origin}`);
306
- }
307
- if (options.expectedRuntimeVersion && envelope.runtimeVersion !== options.expectedRuntimeVersion) errors.push(`Runtime version mismatch: expected ${options.expectedRuntimeVersion} but received ${envelope.runtimeVersion}`);
308
- const checksumBase = {
309
- protocolVersion: envelope.protocolVersion,
310
- runtimeVersion: envelope.runtimeVersion,
311
- appNamespace: envelope.appNamespace,
312
- origin: envelope.origin,
313
- createdAt: envelope.createdAt,
314
- payload: envelope.payload
315
- };
316
- const checksum = hashString(stableStringify(checksumBase));
317
- if (checksum !== envelope.checksum) errors.push('Hydration checksum mismatch');
318
- return {
319
- ok: 0 === errors.length,
320
- errors
321
- };
322
- }
323
- function createInvalidationEvent(input) {
324
- return {
325
- sourceNamespace: sanitizeSegment(input.sourceOperation.appNamespace),
326
- sourceOperationId: createOperationId(input.sourceOperation),
327
- scopeKey: buildScopeKey(input.sourceScope),
328
- targetNamespaces: input.targetNamespaces?.map((namespace)=>sanitizeSegment(namespace)),
329
- targetOperationIds: input.targetOperations?.map((operation)=>createOperationId(operation))
330
- };
331
- }
332
- function shouldApplyInvalidation(event, subscriber) {
333
- if (subscriber.scopeKey && subscriber.scopeKey !== event.scopeKey) return false;
334
- const sameNamespace = subscriber.namespace === event.sourceNamespace;
335
- const allowedCrossNamespace = true === subscriber.acceptCrossNamespace && event.targetNamespaces?.includes(subscriber.namespace) === true;
336
- if (!sameNamespace && !allowedCrossNamespace) return false;
337
- if (!subscriber.operationIds || 0 === subscriber.operationIds.length) return true;
338
- if (!event.targetOperationIds || 0 === event.targetOperationIds.length) return true;
339
- return subscriber.operationIds.some((operationId)=>event.targetOperationIds?.includes(operationId));
340
- }
341
- function resolveRuntimeOrigin() {
342
- if ("u" > typeof window && window.location && 'string' == typeof window.location.origin && window.location.origin) return window.location.origin;
343
- if ("u" > typeof globalThis && globalThis.location && 'string' == typeof globalThis.location?.origin) return globalThis.location.origin;
344
- return 'http://localhost';
345
- }
346
- function toAbsoluteUrl(input) {
347
- if (input instanceof URL) return input;
348
- if ("u" > typeof Request && input instanceof Request) return new URL(input.url);
349
- const value = String(input);
350
- try {
351
- return new URL(value);
352
- } catch {
353
- return new URL(value, resolveRuntimeOrigin());
354
- }
355
- }
356
- function normalizeBatchEndpoint(requestUrl, endpoint) {
357
- const value = endpoint || DEFAULT_DATA_BATCH_ENDPOINT;
358
- try {
359
- return new URL(value);
360
- } catch {
361
- return new URL(value, requestUrl.origin);
362
- }
363
- }
364
- function toHeaderRecord(headers) {
365
- if (!headers) return {};
366
- if (headers instanceof Headers) {
367
- const next = {};
368
- headers.forEach((value, key)=>{
369
- next[key.toLowerCase()] = value;
370
- });
371
- return next;
372
- }
373
- if (Array.isArray(headers)) return headers.reduce((acc, [key, value])=>{
374
- acc[String(key).toLowerCase()] = String(value);
375
- return acc;
376
- }, {});
377
- return Object.entries(headers).reduce((acc, [key, value])=>{
378
- if (void 0 === value) return acc;
379
- acc[String(key).toLowerCase()] = Array.isArray(value) ? value.join(', ') : String(value);
380
- return acc;
381
- }, {});
382
- }
383
- function isBatchResponseItem(value) {
384
- return isPlainObject(value) && 'string' == typeof value.id && 'number' == typeof value.status;
385
- }
386
- function isBatchResponsePayload(value) {
387
- return isPlainObject(value) && 1 === value.protocolVersion && 'string' == typeof value.batchId && 'number' == typeof value.receivedAt && Array.isArray(value.items) && value.items.every((item)=>isBatchResponseItem(item));
388
- }
389
- function measureTextBytes(value) {
390
- if ("u" > typeof TextEncoder) return new TextEncoder().encode(value).length;
391
- if ("u" > typeof Buffer) return Buffer.byteLength(value);
392
- return value.length;
393
- }
394
- function createBatchId() {
395
- const now = Date.now().toString(36);
396
- const random = Math.random().toString(16).slice(2, 10);
397
- return `batch_${now}_${random}`;
398
- }
399
- function normalizeMethod(method) {
400
- return (method || 'GET').toUpperCase();
401
- }
402
- function toRequestBody(initBody) {
403
- if ('string' == typeof initBody) return initBody;
404
- if ("u" > typeof URLSearchParams && initBody instanceof URLSearchParams) return initBody.toString();
405
- }
406
- function shouldBatchRequest(input) {
407
- if (input.requestUrl.href === input.batchEndpoint) return false;
408
- if ('off' === input.headers[DEFAULT_DATA_BATCH_HEADER]) return false;
409
- if (!input.allowedMethods.has(input.method)) return false;
410
- if (void 0 !== input.body) return false;
411
- return true;
412
- }
413
- async function parseResponseLikeCreateRequest(response) {
414
- const contentType = response.headers.get('content-type') || '';
415
- if (!response.ok) {
416
- let data = null;
417
- data = contentType.includes('application/json') ? await response.json() : await response.text();
418
- response.data = data;
419
- throw response;
420
- }
421
- if (contentType.includes('application/json') || contentType.includes('text/json')) return response.json();
422
- if (contentType.includes('text/html') || contentType.includes('text/plain')) return response.text();
423
- if (contentType.includes('application/x-www-form-urlencoded') || contentType.includes('multipart/form-data')) return response.formData();
424
- if (contentType.includes('application/octet-stream')) return response.arrayBuffer();
425
- if (contentType.includes('image/png')) return response;
426
- return response.text();
427
- }
428
- function ensureBucket(buckets, endpoint) {
429
- const existing = buckets.get(endpoint);
430
- if (existing) return existing;
431
- const next = {
432
- items: [],
433
- bytes: 0,
434
- timer: null,
435
- flushing: false
436
- };
437
- buckets.set(endpoint, next);
438
- return next;
439
- }
440
- function createDataBatchTransport(options = {}) {
441
- const fallbackFetch = 'function' == typeof fetch ? fetch.bind(globalThis) : void 0;
442
- const baseFetch = options.fetch || fallbackFetch;
443
- if (!baseFetch) throw new Error('createDataBatchTransport requires a fetch implementation');
444
- const flushIntervalMs = Math.max(0, options.flushIntervalMs ?? 8);
445
- const maxBatchSize = Math.max(1, options.maxBatchSize ?? 16);
446
- const maxBatchBytes = Math.max(1024, options.maxBatchBytes ?? 65536);
447
- const requestTimeoutMs = options.requestTimeoutMs;
448
- const allowedMethods = new Set((options.allowedMethods && options.allowedMethods.length > 0 ? options.allowedMethods : [
449
- 'GET'
450
- ]).map((method)=>method.toUpperCase()));
451
- const onEvent = options.onEvent;
452
- const buckets = new Map();
453
- const pendingByKey = new Map();
454
- const disabledEndpoints = new Set();
455
- const runSingle = async (request)=>{
456
- const response = await baseFetch(request.requestUrl, request.requestInit);
457
- return parseResponseLikeCreateRequest(response);
458
- };
459
- const settleRequests = async (items, runner)=>{
460
- await Promise.all(items.map(async (item)=>{
461
- try {
462
- const value = await runner(item);
463
- item.resolve(value);
464
- } catch (error) {
465
- item.reject(error);
466
- } finally{
467
- pendingByKey.delete(item.key);
468
- }
469
- }));
470
- };
471
- const flushBucket = async (endpoint)=>{
472
- const bucket = buckets.get(endpoint);
473
- if (!bucket || bucket.flushing) return;
474
- if (bucket.timer) {
475
- clearTimeout(bucket.timer);
476
- bucket.timer = null;
477
- }
478
- if (0 === bucket.items.length) return;
479
- bucket.flushing = true;
480
- const items = bucket.items;
481
- bucket.items = [];
482
- bucket.bytes = 0;
483
- if (1 === items.length || disabledEndpoints.has(endpoint)) {
484
- emitDataBatchTransportEvent(onEvent, {
485
- type: disabledEndpoints.has(endpoint) ? 'fallback' : 'flush',
486
- endpoint,
487
- size: items.length,
488
- reason: disabledEndpoints.has(endpoint) ? 'batch-disabled' : void 0
489
- });
490
- await settleRequests(items, runSingle);
491
- bucket.flushing = false;
492
- return;
493
- }
494
- const batchId = createBatchId();
495
- const payload = {
496
- protocolVersion: 1,
497
- batchId,
498
- sentAt: Date.now(),
499
- items: items.map((item)=>item.item)
500
- };
501
- emitDataBatchTransportEvent(onEvent, {
502
- type: 'flush',
503
- endpoint,
504
- batchId,
505
- size: items.length
506
- });
507
- const payloadJson = JSON.stringify(payload);
508
- const traceparent = items.find((item)=>'string' == typeof item.item.headers?.traceparent)?.item.headers?.traceparent || void 0;
509
- const requestInit = {
510
- method: 'POST',
511
- headers: {
512
- accept: 'application/json, */*;q=0.8',
513
- 'content-type': 'application/json; charset=utf-8',
514
- [DEFAULT_DATA_BATCH_HEADER]: '1',
515
- ...traceparent ? {
516
- traceparent
517
- } : {}
518
- },
519
- body: payloadJson
520
- };
521
- let timeoutHandle = null;
522
- try {
523
- const controller = requestTimeoutMs && requestTimeoutMs > 0 ? new AbortController() : void 0;
524
- if (controller) {
525
- requestInit.signal = controller.signal;
526
- timeoutHandle = setTimeout(()=>{
527
- controller.abort();
528
- emitDataBatchTransportEvent(onEvent, {
529
- type: 'fallback',
530
- endpoint,
531
- batchId,
532
- size: items.length,
533
- reason: 'batch-timeout'
534
- });
535
- }, requestTimeoutMs);
536
- }
537
- const response = await baseFetch(endpoint, requestInit);
538
- if (!response.ok) {
539
- if (404 === response.status || 405 === response.status) {
540
- disabledEndpoints.add(endpoint);
541
- emitDataBatchTransportEvent(onEvent, {
542
- type: 'disable',
543
- endpoint,
544
- batchId,
545
- reason: `batch-endpoint-unavailable-${String(response.status)}`
546
- });
547
- } else emitDataBatchTransportEvent(onEvent, {
548
- type: 'fallback',
549
- endpoint,
550
- batchId,
551
- size: items.length,
552
- reason: `batch-response-${String(response.status)}`
553
- });
554
- await settleRequests(items, runSingle);
555
- bucket.flushing = false;
556
- return;
557
- }
558
- const result = await response.json();
559
- if (!isBatchResponsePayload(result)) {
560
- emitDataBatchTransportEvent(onEvent, {
561
- type: 'fallback',
562
- endpoint,
563
- batchId,
564
- size: items.length,
565
- reason: 'invalid-batch-response'
566
- });
567
- await settleRequests(items, runSingle);
568
- bucket.flushing = false;
569
- return;
570
- }
571
- const itemMap = new Map();
572
- for (const item of result.items)itemMap.set(item.id, item);
573
- await settleRequests(items, async (request)=>{
574
- const resultItem = itemMap.get(request.item.id);
575
- if (!resultItem) return runSingle(request);
576
- const reconstructedResponse = new Response(resultItem.body ?? '', {
577
- status: resultItem.status,
578
- headers: resultItem.headers
579
- });
580
- return parseResponseLikeCreateRequest(reconstructedResponse);
581
- });
582
- } catch (error) {
583
- emitDataBatchTransportEvent(onEvent, {
584
- type: 'fallback',
585
- endpoint,
586
- batchId,
587
- size: items.length,
588
- reason: 'batch-transport-error'
589
- });
590
- await settleRequests(items, runSingle);
591
- } finally{
592
- if (timeoutHandle) clearTimeout(timeoutHandle);
593
- bucket.flushing = false;
594
- }
595
- };
596
- return (input, init)=>{
597
- const requestUrl = toAbsoluteUrl(input);
598
- const batchEndpointUrl = normalizeBatchEndpoint(requestUrl, options.endpoint);
599
- const endpoint = batchEndpointUrl.toString();
600
- const method = normalizeMethod(init?.method);
601
- const body = toRequestBody(init?.body ?? null);
602
- const headers = toHeaderRecord(init?.headers);
603
- const normalizedInit = {
604
- ...init,
605
- method,
606
- headers,
607
- body
608
- };
609
- if (disabledEndpoints.has(endpoint) || !shouldBatchRequest({
610
- method,
611
- body,
612
- headers,
613
- allowedMethods,
614
- batchEndpoint: endpoint,
615
- requestUrl
616
- })) return baseFetch(requestUrl.toString(), normalizedInit).then(parseResponseLikeCreateRequest);
617
- const item = {
618
- id: `${Date.now().toString(36)}_${Math.random().toString(16).slice(2, 8)}`,
619
- path: `${requestUrl.pathname}${requestUrl.search}`,
620
- method,
621
- headers,
622
- ...body ? {
623
- body
624
- } : {}
625
- };
626
- const key = stableStringify({
627
- endpoint,
628
- path: item.path,
629
- method: item.method,
630
- headers: item.headers,
631
- body: item.body ?? null
632
- });
633
- const existing = pendingByKey.get(key);
634
- if (existing) return existing;
635
- const size = measureTextBytes(stableStringify(item));
636
- const promise = new Promise((resolve, reject)=>{
637
- const bucket = ensureBucket(buckets, endpoint);
638
- const queued = {
639
- key,
640
- endpoint,
641
- requestUrl: requestUrl.toString(),
642
- requestInit: normalizedInit,
643
- item,
644
- size,
645
- resolve,
646
- reject
647
- };
648
- bucket.items.push(queued);
649
- bucket.bytes += size;
650
- emitDataBatchTransportEvent(onEvent, {
651
- type: 'enqueue',
652
- endpoint,
653
- size: bucket.items.length
654
- });
655
- if (bucket.items.length >= maxBatchSize || bucket.bytes >= maxBatchBytes) return void flushBucket(endpoint);
656
- if (!bucket.timer) bucket.timer = setTimeout(()=>{
657
- bucket.timer = null;
658
- flushBucket(endpoint);
659
- }, flushIntervalMs);
660
- });
661
- pendingByKey.set(key, promise);
662
- return promise;
663
- };
664
- }
56
+ const external_batch_transport_js_namespaceObject = require("./batch-transport.js");
57
+ const external_codec_js_namespaceObject = require("./codec.js");
58
+ const external_invalidation_js_namespaceObject = require("./invalidation.js");
59
+ const external_trace_js_namespaceObject = require("./trace.js");
60
+ const external_types_js_namespaceObject = require("./types.js");
61
+ const external_validation_js_namespaceObject = require("./validation.js");
665
62
  exports.DATA_BATCH_TRANSPORT_OTEL_EVENT = __webpack_exports__.DATA_BATCH_TRANSPORT_OTEL_EVENT;
666
63
  exports.DEFAULT_DATA_BATCH_ENDPOINT = __webpack_exports__.DEFAULT_DATA_BATCH_ENDPOINT;
667
64
  exports.DEFAULT_DATA_BATCH_HEADER = __webpack_exports__.DEFAULT_DATA_BATCH_HEADER;