@graphrefly/ts 0.0.1 → 0.0.3

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 (333) hide show
  1. package/README.md +197 -117
  2. package/dist/actions-types-CH-XCU9O.d.cts +657 -0
  3. package/dist/actions-types-w2iPQTkv.d.ts +657 -0
  4. package/dist/adapters/index.cjs +5157 -2951
  5. package/dist/adapters/index.cjs.map +1 -1
  6. package/dist/adapters/index.d.cts +207 -70
  7. package/dist/adapters/index.d.ts +207 -70
  8. package/dist/adapters/index.js +3738 -1688
  9. package/dist/adapters/index.js.map +1 -1
  10. package/dist/adapters/nestjs/microservices.cjs +841 -0
  11. package/dist/adapters/nestjs/microservices.cjs.map +1 -0
  12. package/dist/adapters/nestjs/microservices.d.cts +45 -0
  13. package/dist/adapters/nestjs/microservices.d.ts +45 -0
  14. package/dist/adapters/nestjs/microservices.js +206 -0
  15. package/dist/adapters/nestjs/microservices.js.map +1 -0
  16. package/dist/adapters/nestjs/native.cjs +1391 -0
  17. package/dist/adapters/nestjs/native.cjs.map +1 -0
  18. package/dist/adapters/nestjs/native.d.cts +111 -0
  19. package/dist/adapters/nestjs/native.d.ts +111 -0
  20. package/dist/adapters/nestjs/native.js +577 -0
  21. package/dist/adapters/nestjs/native.js.map +1 -0
  22. package/dist/adapters/nestjs/websockets.cjs +924 -0
  23. package/dist/adapters/nestjs/websockets.cjs.map +1 -0
  24. package/dist/adapters/nestjs/websockets.d.cts +47 -0
  25. package/dist/adapters/nestjs/websockets.d.ts +47 -0
  26. package/dist/adapters/nestjs/websockets.js +286 -0
  27. package/dist/adapters/nestjs/websockets.js.map +1 -0
  28. package/dist/adapters/nestjs.cjs +1085 -0
  29. package/dist/adapters/nestjs.cjs.map +1 -0
  30. package/dist/adapters/nestjs.d.cts +385 -0
  31. package/dist/adapters/nestjs.d.ts +385 -0
  32. package/dist/adapters/nestjs.js +112 -0
  33. package/dist/adapters/nestjs.js.map +1 -0
  34. package/dist/adapters/observe-storage.d.cts +3 -3
  35. package/dist/adapters/observe-storage.d.ts +3 -3
  36. package/dist/adapters/observe-storage.js +4 -4
  37. package/dist/adapters/react.cjs.map +1 -1
  38. package/dist/adapters/react.d.cts +2 -2
  39. package/dist/adapters/react.d.ts +2 -2
  40. package/dist/adapters/react.js +1 -1
  41. package/dist/adapters/solid.cjs.map +1 -1
  42. package/dist/adapters/solid.d.cts +2 -2
  43. package/dist/adapters/solid.d.ts +2 -2
  44. package/dist/adapters/solid.js +1 -1
  45. package/dist/adapters/svelte.cjs.map +1 -1
  46. package/dist/adapters/svelte.d.cts +2 -2
  47. package/dist/adapters/svelte.d.ts +2 -2
  48. package/dist/adapters/svelte.js +1 -1
  49. package/dist/adapters/vue.cjs.map +1 -1
  50. package/dist/adapters/vue.d.cts +2 -2
  51. package/dist/adapters/vue.d.ts +2 -2
  52. package/dist/adapters/vue.js +1 -1
  53. package/dist/{agent-runtime-BesGDZcB.d.ts → agent-runtime-types-core-CKwrBDyi.d.ts} +171 -320
  54. package/dist/{agent-runtime-DZTJ3C-p.d.cts → agent-runtime-types-core-bfl4m0vM.d.cts} +171 -320
  55. package/dist/agent-runtime-types-tool-BLPV3azj.d.cts +695 -0
  56. package/dist/agent-runtime-types-tool-hwqvVqNt.d.ts +695 -0
  57. package/dist/agentic-memory-retention-CLwI76JK.d.ts +14 -0
  58. package/dist/agentic-memory-retention-Cz8GR6ie.d.cts +14 -0
  59. package/dist/{agentic-memory-DfuVZ-lY.d.cts → agentic-memory-types-JDr7MPhh.d.cts} +13 -57
  60. package/dist/{agentic-memory-BmRCvh0d.d.ts → agentic-memory-types-khYJgzKL.d.ts} +13 -57
  61. package/dist/{capability-admission-B0BzqAm5.d.cts → capability-admission-B8RNFyaZ.d.cts} +3 -3
  62. package/dist/{capability-admission-g0mn9hpq.d.ts → capability-admission-Dkw1Xz3r.d.ts} +3 -3
  63. package/dist/chunk-2KUAG2GZ.js +9693 -0
  64. package/dist/chunk-2KUAG2GZ.js.map +1 -0
  65. package/dist/{chunk-CZNV3VXM.js → chunk-3J7UPZL5.js} +11 -11
  66. package/dist/{chunk-HKK2JD7Z.js → chunk-3LYI6ADX.js} +12 -125
  67. package/dist/chunk-3LYI6ADX.js.map +1 -0
  68. package/dist/{chunk-YXMZ2N6J.js → chunk-4M37FH2I.js} +1071 -1025
  69. package/dist/chunk-4M37FH2I.js.map +1 -0
  70. package/dist/{chunk-YDSIVHRR.js → chunk-4NWSNI4K.js} +1598 -1584
  71. package/dist/chunk-4NWSNI4K.js.map +1 -0
  72. package/dist/{chunk-Z2ANQ6JW.js → chunk-4Q77MMJY.js} +2 -2
  73. package/dist/{chunk-SS2A464I.js → chunk-54WPEODM.js} +3 -3
  74. package/dist/chunk-54WPEODM.js.map +1 -0
  75. package/dist/chunk-6E76H4OU.js +132 -0
  76. package/dist/chunk-6E76H4OU.js.map +1 -0
  77. package/dist/chunk-7GOTIIQ7.js +819 -0
  78. package/dist/chunk-7GOTIIQ7.js.map +1 -0
  79. package/dist/{chunk-V7CIJE4B.js → chunk-DKFWDTVY.js} +92 -9
  80. package/dist/chunk-DKFWDTVY.js.map +1 -0
  81. package/dist/{chunk-FBUU43PM.js → chunk-E4QCH32M.js} +448 -446
  82. package/dist/chunk-E4QCH32M.js.map +1 -0
  83. package/dist/{chunk-XKXWK2KP.js → chunk-GXU6WFEJ.js} +1157 -1021
  84. package/dist/chunk-GXU6WFEJ.js.map +1 -0
  85. package/dist/{chunk-K3FXTC3I.js → chunk-HJACH5PU.js} +3 -3
  86. package/dist/{chunk-GTPCOEOZ.js → chunk-IDMLXLLG.js} +3 -3
  87. package/dist/{chunk-DKP56CSW.js → chunk-JKAYLDQV.js} +2 -2
  88. package/dist/{chunk-4VLAQHZI.js → chunk-K7FB3JTD.js} +17 -1
  89. package/dist/chunk-K7FB3JTD.js.map +1 -0
  90. package/dist/{chunk-43BKLFZU.js → chunk-KFURM6FM.js} +10 -10
  91. package/dist/{chunk-H75VXTGT.js → chunk-L6LDXRWE.js} +3 -3
  92. package/dist/{chunk-H75VXTGT.js.map → chunk-L6LDXRWE.js.map} +1 -1
  93. package/dist/chunk-MCOFHMUU.js +4131 -0
  94. package/dist/chunk-MCOFHMUU.js.map +1 -0
  95. package/dist/chunk-MQEQMS7B.js +1009 -0
  96. package/dist/chunk-MQEQMS7B.js.map +1 -0
  97. package/dist/chunk-MTELVIYR.js +1421 -0
  98. package/dist/chunk-MTELVIYR.js.map +1 -0
  99. package/dist/{chunk-3JR3EDB2.js → chunk-NNDIFUKX.js} +121 -115
  100. package/dist/chunk-NNDIFUKX.js.map +1 -0
  101. package/dist/{chunk-2747WN4Y.js → chunk-PUSRRALM.js} +3 -3
  102. package/dist/{chunk-QFY4AFY4.js → chunk-PVC7WDKI.js} +58 -52
  103. package/dist/chunk-PVC7WDKI.js.map +1 -0
  104. package/dist/{chunk-VTHLCFN4.js → chunk-RAHNUYA5.js} +2 -2
  105. package/dist/chunk-TQPCAIQI.js +612 -0
  106. package/dist/chunk-TQPCAIQI.js.map +1 -0
  107. package/dist/{chunk-IXZBUWSP.js → chunk-UEMN5URK.js} +2 -2
  108. package/dist/chunk-WOS7RJYZ.js +1320 -0
  109. package/dist/chunk-WOS7RJYZ.js.map +1 -0
  110. package/dist/{chunk-6PHB5CJS.js → chunk-ZLFRB6FI.js} +2 -2
  111. package/dist/composition/index.cjs +1228 -1076
  112. package/dist/composition/index.cjs.map +1 -1
  113. package/dist/composition/index.d.cts +3 -3
  114. package/dist/composition/index.d.ts +3 -3
  115. package/dist/composition/index.js +4 -4
  116. package/dist/core/index.cjs +1198 -1046
  117. package/dist/core/index.cjs.map +1 -1
  118. package/dist/core/index.d.cts +23 -2
  119. package/dist/core/index.d.ts +23 -2
  120. package/dist/core/index.js +2 -2
  121. package/dist/cqrs/index.d.cts +3 -3
  122. package/dist/cqrs/index.d.ts +3 -3
  123. package/dist/cqrs/messaging.d.cts +4 -4
  124. package/dist/cqrs/messaging.d.ts +4 -4
  125. package/dist/cqrs/work-queue.d.cts +5 -5
  126. package/dist/cqrs/work-queue.d.ts +5 -5
  127. package/dist/data-structures/index.cjs +1226 -1074
  128. package/dist/data-structures/index.cjs.map +1 -1
  129. package/dist/data-structures/index.d.cts +8 -7
  130. package/dist/data-structures/index.d.ts +8 -7
  131. package/dist/data-structures/index.js +6 -5
  132. package/dist/{describe-DYMw_l1C.d.cts → describe-BumQ-3_0.d.cts} +1 -1
  133. package/dist/{describe-BpyJuWkw.d.ts → describe-cYr_Z5zm.d.ts} +1 -1
  134. package/dist/executors/tool-provider-adapters.cjs +3091 -0
  135. package/dist/executors/tool-provider-adapters.cjs.map +1 -0
  136. package/dist/executors/tool-provider-adapters.d.cts +174 -0
  137. package/dist/executors/tool-provider-adapters.d.ts +174 -0
  138. package/dist/executors/tool-provider-adapters.js +1336 -0
  139. package/dist/executors/tool-provider-adapters.js.map +1 -0
  140. package/dist/executors/tool-provider-runtime.cjs +5178 -0
  141. package/dist/executors/tool-provider-runtime.cjs.map +1 -0
  142. package/dist/executors/tool-provider-runtime.d.cts +17 -0
  143. package/dist/executors/tool-provider-runtime.d.ts +17 -0
  144. package/dist/executors/tool-provider-runtime.js +15 -0
  145. package/dist/executors/tool-provider-runtime.js.map +1 -0
  146. package/dist/executors/tool-provider.cjs +6392 -0
  147. package/dist/executors/tool-provider.cjs.map +1 -0
  148. package/dist/executors/tool-provider.d.cts +60 -0
  149. package/dist/executors/tool-provider.d.ts +60 -0
  150. package/dist/executors/tool-provider.js +89 -0
  151. package/dist/executors/tool-provider.js.map +1 -0
  152. package/dist/executors/work-queue.d.cts +6 -6
  153. package/dist/executors/work-queue.d.ts +6 -6
  154. package/dist/graph/index.cjs +1499 -1341
  155. package/dist/graph/index.cjs.map +1 -1
  156. package/dist/graph/index.d.cts +9 -8
  157. package/dist/graph/index.d.ts +9 -8
  158. package/dist/graph/index.js +23 -22
  159. package/dist/{graph-DCEWh4T2.d.cts → graph-C1C-wb0L.d.cts} +266 -137
  160. package/dist/{graph-D-1-SQeC.d.ts → graph-CS0b4V9B.d.ts} +266 -137
  161. package/dist/{index-72VZC0-E.d.cts → index-DLrNopda.d.cts} +151 -10
  162. package/dist/{index-Bmxeu0nK.d.ts → index-DzJni3_6.d.ts} +151 -10
  163. package/dist/index.cjs +3397 -3140
  164. package/dist/index.cjs.map +1 -1
  165. package/dist/index.d.cts +12 -9
  166. package/dist/index.d.ts +12 -9
  167. package/dist/index.js +110 -109
  168. package/dist/inspection/boundary.d.cts +4 -4
  169. package/dist/inspection/boundary.d.ts +4 -4
  170. package/dist/measurements-BWAnochv.d.ts +294 -0
  171. package/dist/measurements-B_gJfD8h.d.cts +294 -0
  172. package/dist/messaging/index.cjs +57 -51
  173. package/dist/messaging/index.cjs.map +1 -1
  174. package/dist/messaging/index.d.cts +11 -276
  175. package/dist/messaging/index.d.ts +11 -276
  176. package/dist/messaging/index.js +1 -1
  177. package/dist/operators/index.cjs +1228 -1076
  178. package/dist/operators/index.cjs.map +1 -1
  179. package/dist/operators/index.d.cts +5 -5
  180. package/dist/operators/index.d.ts +5 -5
  181. package/dist/operators/index.js +5 -5
  182. package/dist/orchestration/index.cjs +8844 -6071
  183. package/dist/orchestration/index.cjs.map +1 -1
  184. package/dist/orchestration/index.d.cts +171 -224
  185. package/dist/orchestration/index.d.ts +171 -224
  186. package/dist/orchestration/index.js +42 -991
  187. package/dist/orchestration/index.js.map +1 -1
  188. package/dist/orchestration/messaging.d.cts +5 -8
  189. package/dist/orchestration/messaging.d.ts +5 -8
  190. package/dist/orchestration/work-queue.cjs +1243 -5
  191. package/dist/orchestration/work-queue.cjs.map +1 -1
  192. package/dist/orchestration/work-queue.d.cts +121 -10
  193. package/dist/orchestration/work-queue.d.ts +121 -10
  194. package/dist/orchestration/work-queue.js +1067 -4
  195. package/dist/orchestration/work-queue.js.map +1 -1
  196. package/dist/patterns/event-flow.cjs +6 -20
  197. package/dist/patterns/event-flow.cjs.map +1 -1
  198. package/dist/patterns/event-flow.d.cts +4 -4
  199. package/dist/patterns/event-flow.d.ts +4 -4
  200. package/dist/patterns/event-flow.js +2 -2
  201. package/dist/patterns/index.cjs +453 -465
  202. package/dist/patterns/index.cjs.map +1 -1
  203. package/dist/patterns/index.d.cts +6 -5
  204. package/dist/patterns/index.d.ts +6 -5
  205. package/dist/patterns/index.js +3 -3
  206. package/dist/process-types-BB7oRhX3.d.cts +200 -0
  207. package/dist/process-types-QNhyoYJ8.d.ts +200 -0
  208. package/dist/{reactive-collection-DNV0-gFi.d.cts → reactive-collection-BYlWvtnp.d.cts} +4 -34
  209. package/dist/{reactive-collection-BAmfrGjd.d.ts → reactive-collection-efOEdGFN.d.ts} +4 -34
  210. package/dist/{reactive-collection-storage-BNEldDyi.d.cts → reactive-collection-storage-BjoLsoiC.d.cts} +5 -5
  211. package/dist/{reactive-collection-storage-YZsAQsWK.d.ts → reactive-collection-storage-DwW6UuK_.d.ts} +5 -5
  212. package/dist/{reactive-map-DRD1LJ2H.d.cts → reactive-map-BHacbIqz.d.cts} +7 -2
  213. package/dist/{reactive-map-EsDiCmJk.d.ts → reactive-map-DN4Jyqnf.d.ts} +7 -2
  214. package/dist/render/index.d.cts +2 -2
  215. package/dist/render/index.d.ts +2 -2
  216. package/dist/scheduled-readiness-BmqXxnzX.d.ts +91 -0
  217. package/dist/scheduled-readiness-CYSw7KDE.d.cts +91 -0
  218. package/dist/semantic-memory-graph-B_LwbM-E.d.cts +30 -0
  219. package/dist/semantic-memory-graph-rsFNNhwn.d.ts +30 -0
  220. package/dist/{semantic-memory-graph-DKuNzuWw.d.cts → semantic-memory-graph-types-Y73bbwVI.d.cts} +2 -28
  221. package/dist/{semantic-memory-graph-uwbwJdhe.d.ts → semantic-memory-graph-types-safmPkuX.d.ts} +2 -28
  222. package/dist/solutions/index.cjs +6353 -6169
  223. package/dist/solutions/index.cjs.map +1 -1
  224. package/dist/solutions/index.d.cts +12 -10
  225. package/dist/solutions/index.d.ts +12 -10
  226. package/dist/solutions/index.js +5 -5
  227. package/dist/solutions/reactive-layout/browser/index.cjs +116 -108
  228. package/dist/solutions/reactive-layout/browser/index.cjs.map +1 -1
  229. package/dist/solutions/reactive-layout/browser/index.d.cts +4 -4
  230. package/dist/solutions/reactive-layout/browser/index.d.ts +4 -4
  231. package/dist/solutions/reactive-layout/browser/index.js +3 -3
  232. package/dist/solutions/reactive-layout/index.cjs +3578 -3350
  233. package/dist/solutions/reactive-layout/index.cjs.map +1 -1
  234. package/dist/solutions/reactive-layout/index.d.cts +32 -576
  235. package/dist/solutions/reactive-layout/index.d.ts +32 -576
  236. package/dist/solutions/reactive-layout/index.js +65 -5
  237. package/dist/solutions/reactive-layout/node-canvas/index.cjs +127 -117
  238. package/dist/solutions/reactive-layout/node-canvas/index.cjs.map +1 -1
  239. package/dist/solutions/reactive-layout/node-canvas/index.d.cts +4 -4
  240. package/dist/solutions/reactive-layout/node-canvas/index.d.ts +4 -4
  241. package/dist/solutions/reactive-layout/node-canvas/index.js +3 -3
  242. package/dist/solutions/reactive-layout/react-native/index.cjs +127 -117
  243. package/dist/solutions/reactive-layout/react-native/index.cjs.map +1 -1
  244. package/dist/solutions/reactive-layout/react-native/index.d.cts +4 -4
  245. package/dist/solutions/reactive-layout/react-native/index.d.ts +4 -4
  246. package/dist/solutions/reactive-layout/react-native/index.js +3 -3
  247. package/dist/solutions/reactive-layout/skia/index.cjs +127 -117
  248. package/dist/solutions/reactive-layout/skia/index.cjs.map +1 -1
  249. package/dist/solutions/reactive-layout/skia/index.d.cts +4 -4
  250. package/dist/solutions/reactive-layout/skia/index.d.ts +4 -4
  251. package/dist/solutions/reactive-layout/skia/index.js +3 -3
  252. package/dist/solutions/work-item/actions.cjs +1609 -1428
  253. package/dist/solutions/work-item/actions.cjs.map +1 -1
  254. package/dist/solutions/work-item/actions.d.cts +23 -184
  255. package/dist/solutions/work-item/actions.d.ts +23 -184
  256. package/dist/solutions/work-item/actions.js +1558 -934
  257. package/dist/solutions/work-item/actions.js.map +1 -1
  258. package/dist/solutions/work-item/scheduling.cjs +9181 -1838
  259. package/dist/solutions/work-item/scheduling.cjs.map +1 -1
  260. package/dist/solutions/work-item/scheduling.d.cts +1763 -328
  261. package/dist/solutions/work-item/scheduling.d.ts +1763 -328
  262. package/dist/solutions/work-item/scheduling.js +117 -3
  263. package/dist/solutions/work-item/work-queue.d.cts +7 -7
  264. package/dist/solutions/work-item/work-queue.d.ts +7 -7
  265. package/dist/sources/browser.cjs +1318 -1083
  266. package/dist/sources/browser.cjs.map +1 -1
  267. package/dist/sources/browser.d.cts +22 -6
  268. package/dist/sources/browser.d.ts +22 -6
  269. package/dist/sources/browser.js +4 -4
  270. package/dist/sources/browser.js.map +1 -1
  271. package/dist/sources/index.cjs +1318 -1083
  272. package/dist/sources/index.cjs.map +1 -1
  273. package/dist/sources/index.d.cts +4 -4
  274. package/dist/sources/index.d.ts +4 -4
  275. package/dist/sources/index.js +4 -4
  276. package/dist/sources/node.d.cts +3 -3
  277. package/dist/sources/node.d.ts +3 -3
  278. package/dist/storage/browser.cjs +16 -0
  279. package/dist/storage/browser.cjs.map +1 -1
  280. package/dist/storage/browser.js +3 -3
  281. package/dist/storage/index.cjs +16 -0
  282. package/dist/storage/index.cjs.map +1 -1
  283. package/dist/storage/index.d.cts +5 -4
  284. package/dist/storage/index.d.ts +5 -4
  285. package/dist/storage/index.js +6 -6
  286. package/dist/storage/node.cjs +16 -0
  287. package/dist/storage/node.cjs.map +1 -1
  288. package/dist/storage/node.js +3 -3
  289. package/dist/{store-C-joM4gh.d.ts → store-6_CHF6Ge.d.ts} +1 -1
  290. package/dist/{store-CNJwmT-h.d.cts → store-BljX8RkQ.d.cts} +1 -1
  291. package/dist/types-BAw2QVVE.d.cts +274 -0
  292. package/dist/types-BUbbbh4f.d.cts +34 -0
  293. package/dist/types-CMnzoL54.d.cts +457 -0
  294. package/dist/{types-CcPIn7sy.d.cts → types-CTN3XoMl.d.cts} +57 -108
  295. package/dist/types-CV_ohy5T.d.cts +357 -0
  296. package/dist/{types-BsJvElYZ.d.ts → types-DChxk1vK.d.ts} +57 -108
  297. package/dist/types-DRu7SnLV.d.ts +274 -0
  298. package/dist/types-DeID_FRl.d.ts +34 -0
  299. package/dist/types-IhKH0hGW.d.ts +357 -0
  300. package/dist/types-ePlD2uyT.d.ts +457 -0
  301. package/dist/{work-item-runtime-qaVgsL0T.d.cts → work-item-runtime-types-BTxLskN5.d.cts} +3 -93
  302. package/dist/{work-item-runtime-C3M79vE9.d.ts → work-item-runtime-types-DAsZbb2y.d.ts} +3 -93
  303. package/dist/work-queue/index.cjs +957 -953
  304. package/dist/work-queue/index.cjs.map +1 -1
  305. package/dist/work-queue/index.d.cts +9 -357
  306. package/dist/work-queue/index.d.ts +9 -357
  307. package/dist/work-queue/index.js +957 -953
  308. package/dist/work-queue/index.js.map +1 -1
  309. package/package.json +611 -513
  310. package/dist/chunk-3JR3EDB2.js.map +0 -1
  311. package/dist/chunk-4VLAQHZI.js.map +0 -1
  312. package/dist/chunk-6XAIOL3X.js +0 -2407
  313. package/dist/chunk-6XAIOL3X.js.map +0 -1
  314. package/dist/chunk-FBUU43PM.js.map +0 -1
  315. package/dist/chunk-HKK2JD7Z.js.map +0 -1
  316. package/dist/chunk-PC3BTTBE.js +0 -3217
  317. package/dist/chunk-PC3BTTBE.js.map +0 -1
  318. package/dist/chunk-QFY4AFY4.js.map +0 -1
  319. package/dist/chunk-SS2A464I.js.map +0 -1
  320. package/dist/chunk-V7CIJE4B.js.map +0 -1
  321. package/dist/chunk-XKXWK2KP.js.map +0 -1
  322. package/dist/chunk-YDSIVHRR.js.map +0 -1
  323. package/dist/chunk-YXMZ2N6J.js.map +0 -1
  324. /package/dist/{chunk-CZNV3VXM.js.map → chunk-3J7UPZL5.js.map} +0 -0
  325. /package/dist/{chunk-Z2ANQ6JW.js.map → chunk-4Q77MMJY.js.map} +0 -0
  326. /package/dist/{chunk-K3FXTC3I.js.map → chunk-HJACH5PU.js.map} +0 -0
  327. /package/dist/{chunk-GTPCOEOZ.js.map → chunk-IDMLXLLG.js.map} +0 -0
  328. /package/dist/{chunk-DKP56CSW.js.map → chunk-JKAYLDQV.js.map} +0 -0
  329. /package/dist/{chunk-43BKLFZU.js.map → chunk-KFURM6FM.js.map} +0 -0
  330. /package/dist/{chunk-2747WN4Y.js.map → chunk-PUSRRALM.js.map} +0 -0
  331. /package/dist/{chunk-VTHLCFN4.js.map → chunk-RAHNUYA5.js.map} +0 -0
  332. /package/dist/{chunk-IXZBUWSP.js.map → chunk-UEMN5URK.js.map} +0 -0
  333. /package/dist/{chunk-6PHB5CJS.js.map → chunk-ZLFRB6FI.js.map} +0 -0
@@ -0,0 +1,1391 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from2, except, desc) => {
11
+ if (from2 && typeof from2 === "object" || typeof from2 === "function") {
12
+ for (let key of __getOwnPropNames(from2))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/adapters/nestjs/native.ts
21
+ var native_exports = {};
22
+ __export(native_exports, {
23
+ GRAPHREFLY_NEST_CRON_SCHEDULER: () => GRAPHREFLY_NEST_CRON_SCHEDULER,
24
+ GRAPHREFLY_NEST_EXCEPTION_FILTER: () => GRAPHREFLY_NEST_EXCEPTION_FILTER,
25
+ GRAPHREFLY_NEST_LIFECYCLE_HOOKS: () => GRAPHREFLY_NEST_LIFECYCLE_HOOKS,
26
+ GraphExceptionFilterBridge: () => GraphExceptionFilterBridge,
27
+ GraphGuardDeniedException: () => GraphGuardDeniedException,
28
+ GraphGuardDeniedFilter: () => GraphGuardDeniedFilter,
29
+ createGraphCronController: () => createGraphCronController,
30
+ createGraphExceptionFilter: () => createGraphExceptionFilter,
31
+ createGraphGuardDeniedFilter: () => createGraphGuardDeniedFilter,
32
+ graphCronTarget: () => graphCronTarget,
33
+ graphLifecycleTarget: () => graphLifecycleTarget,
34
+ isGraphGuardDeniedException: () => isGraphGuardDeniedException,
35
+ provideGraphBoundaryInterceptor: () => provideGraphBoundaryInterceptor,
36
+ provideGraphCronScheduler: () => provideGraphCronScheduler,
37
+ provideGraphExceptionFilter: () => provideGraphExceptionFilter,
38
+ provideGraphGuard: () => provideGraphGuard,
39
+ provideGraphGuardDeniedFilter: () => provideGraphGuardDeniedFilter,
40
+ provideGraphLifecycleHooks: () => provideGraphLifecycleHooks,
41
+ provideGraphNativeHttpProviders: () => provideGraphNativeHttpProviders,
42
+ provideGraphNativeProviders: () => provideGraphNativeProviders
43
+ });
44
+ module.exports = __toCommonJS(native_exports);
45
+ var import_common = require("@nestjs/common");
46
+ var import_core = require("@nestjs/core");
47
+ var import_rxjs = require("rxjs");
48
+
49
+ // src/graph/sources.ts
50
+ function assertNonEmptyString(value, label) {
51
+ if (typeof value !== "string" || value.length === 0) {
52
+ throw new TypeError(`${label} must be a non-empty string`);
53
+ }
54
+ }
55
+ function parseCronField(field, min, max) {
56
+ if (field.length === 0) throw new Error("Invalid cron field: empty");
57
+ const out = /* @__PURE__ */ new Set();
58
+ for (const part of field.split(",")) {
59
+ if (part.length === 0) throw new Error(`Invalid cron field: ${field}`);
60
+ const stepParts = part.split("/");
61
+ if (stepParts.length > 2) throw new Error(`Invalid cron step: ${part}`);
62
+ const [range, stepText] = stepParts;
63
+ if (range == null || range.length === 0) throw new Error(`Invalid cron field: ${field}`);
64
+ if (stepText === "") throw new Error(`Invalid cron step: ${part}`);
65
+ const step = stepText == null ? 1 : parseCronInt(stepText, `Invalid cron step: ${part}`);
66
+ if (step < 1) throw new Error(`Invalid cron step: ${part}`);
67
+ let start;
68
+ let end;
69
+ if (range === "*") {
70
+ start = min;
71
+ end = max;
72
+ } else if (range.includes("-")) {
73
+ const [a, b, extra] = range.split("-");
74
+ if (extra !== void 0 || a === "" || b === "")
75
+ throw new Error(`Invalid cron field: ${field}`);
76
+ start = parseCronInt(a, `Invalid cron field: ${field}`);
77
+ end = parseCronInt(b, `Invalid cron field: ${field}`);
78
+ } else {
79
+ start = parseCronInt(range, `Invalid cron field: ${field}`);
80
+ end = start;
81
+ }
82
+ if (!Number.isInteger(start) || !Number.isInteger(end)) {
83
+ throw new Error(`Invalid cron field: ${field}`);
84
+ }
85
+ if (start < min || end > max) {
86
+ throw new RangeError(`Cron field out of range: ${field} (${min}-${max})`);
87
+ }
88
+ if (start > end) throw new Error(`Invalid cron range: ${start}-${end} in ${field}`);
89
+ for (let i = start; i <= end; i += step) out.add(i);
90
+ }
91
+ return out;
92
+ }
93
+ function parseCronInt(text, message) {
94
+ if (!/^\d+$/.test(text)) throw new Error(message);
95
+ const value = Number.parseInt(text, 10);
96
+ if (!Number.isSafeInteger(value)) throw new Error(message);
97
+ return value;
98
+ }
99
+ function parseCron(expr) {
100
+ const parts = expr.trim().split(/\s+/);
101
+ if (parts.length !== 5 || parts.some((part) => part.length === 0)) {
102
+ throw new Error(`Invalid cron: expected 5 fields, got ${parts.length}`);
103
+ }
104
+ return {
105
+ minutes: parseCronField(parts[0], 0, 59),
106
+ hours: parseCronField(parts[1], 0, 23),
107
+ daysOfMonth: parseCronField(parts[2], 1, 31),
108
+ months: parseCronField(parts[3], 1, 12),
109
+ daysOfWeek: parseCronField(parts[4], 0, 6)
110
+ };
111
+ }
112
+ function matchesCron(schedule, date, opts = {}) {
113
+ const fields = cronWallClockFields(date, opts.timezone);
114
+ return schedule.minutes.has(fields.minute) && schedule.hours.has(fields.hour) && schedule.daysOfMonth.has(fields.day) && schedule.months.has(fields.month) && schedule.daysOfWeek.has(fields.dayOfWeek);
115
+ }
116
+ function cronWallClockFields(date, timezone) {
117
+ if (timezone === void 0) {
118
+ return {
119
+ year: date.getFullYear(),
120
+ month: date.getMonth() + 1,
121
+ day: date.getDate(),
122
+ hour: date.getHours(),
123
+ minute: date.getMinutes(),
124
+ dayOfWeek: date.getDay()
125
+ };
126
+ }
127
+ const parts = timezoneFormatter(timezone).formatToParts(date);
128
+ const values = {};
129
+ for (const part of parts) {
130
+ if (part.type === "year" || part.type === "month" || part.type === "day" || part.type === "hour" || part.type === "minute") {
131
+ values[part.type] = Number.parseInt(part.value, 10);
132
+ }
133
+ }
134
+ const year = values.year;
135
+ const month = values.month;
136
+ const day = values.day;
137
+ const hour = values.hour;
138
+ const minute = values.minute;
139
+ if (year === void 0 || month === void 0 || day === void 0 || hour === void 0 || minute === void 0) {
140
+ throw new Error(`fromCron: timezone projection failed for ${timezone}`);
141
+ }
142
+ return {
143
+ year,
144
+ month,
145
+ day,
146
+ hour,
147
+ minute,
148
+ dayOfWeek: new Date(Date.UTC(year, month - 1, day)).getUTCDay()
149
+ };
150
+ }
151
+ var TIMEZONE_FORMATTERS = /* @__PURE__ */ new Map();
152
+ function timezoneFormatter(timezone) {
153
+ const existing = TIMEZONE_FORMATTERS.get(timezone);
154
+ if (existing !== void 0) return existing;
155
+ assertNonEmptyString(timezone, "fromCron: timezone");
156
+ try {
157
+ const formatter = new Intl.DateTimeFormat("en-US-u-ca-gregory-nu-latn", {
158
+ timeZone: timezone,
159
+ year: "numeric",
160
+ month: "2-digit",
161
+ day: "2-digit",
162
+ hour: "2-digit",
163
+ minute: "2-digit",
164
+ hourCycle: "h23"
165
+ });
166
+ formatter.format(/* @__PURE__ */ new Date(0));
167
+ TIMEZONE_FORMATTERS.set(timezone, formatter);
168
+ return formatter;
169
+ } catch (error) {
170
+ throw new RangeError(
171
+ `fromCron: unsupported IANA timezone '${timezone}' (${error instanceof Error ? error.message : String(error)})`
172
+ );
173
+ }
174
+ }
175
+
176
+ // src/adapters/nestjs.ts
177
+ var NEST_BOUNDARY_ENVELOPE_VERSION = 1;
178
+ var NEST_BOUNDARY_PAYLOAD_MAX_BYTES = 64 * 1024;
179
+ var NEST_HTTP_DIAGNOSTICS_MAX_RETAINED = 100;
180
+ var NEST_BOUNDARY_BINDINGS = /* @__PURE__ */ new WeakMap();
181
+ function toNestHttp(egress, opts = {}) {
182
+ const bindingId = stableBindingId("http", opts);
183
+ const scopedBindingId = opts.bindingId;
184
+ const maxDiagnostics = diagnosticsRetainedLimit(opts.maxDiagnostics);
185
+ const maxPayloadBytes = payloadByteLimit(opts.maxPayloadBytes);
186
+ const pending = /* @__PURE__ */ new Map();
187
+ const diagnostics = [];
188
+ let active = true;
189
+ let terminal;
190
+ const report = (diagnostic) => {
191
+ pushDiagnostic(diagnostics, diagnostic, maxDiagnostics);
192
+ try {
193
+ const phase = diagnostic.phase ?? opts.diagnosticPhase ?? "http";
194
+ const payload = sanitizeNestDiagnostic({ ...diagnostic, phase }, phase);
195
+ opts.diagnosticBoundary?.emit(payload, { payload });
196
+ } catch {
197
+ }
198
+ };
199
+ const keyOf = (requestId, requestBindingId) => requestBindingId === void 0 ? requestId : `${requestBindingId}\0${requestId}`;
200
+ const rejectEntry = (entry, error, envelope, message) => {
201
+ try {
202
+ entry.handle.reject(error, envelope);
203
+ } catch (rejectError) {
204
+ report({
205
+ kind: "reject-threw",
206
+ requestId: entry.requestId,
207
+ bindingId: entry.bindingId,
208
+ message,
209
+ error: rejectError
210
+ });
211
+ }
212
+ };
213
+ const rejectPending = (kind, error, message) => {
214
+ const entries = [...pending.values()];
215
+ pending.clear();
216
+ if (entries.length === 0) return 0;
217
+ report({ kind, bindingId: scopedBindingId, message, error });
218
+ for (const entry of entries) {
219
+ rejectEntry(entry, error, void 0, `toNestHttp(${bindingId}) pending reject threw`);
220
+ }
221
+ return entries.length;
222
+ };
223
+ const unsubscribe = egress.subscribe((msg) => {
224
+ if (!active) return;
225
+ if (msg[0] === "ERROR" || msg[0] === "COMPLETE" || msg[0] === "TEARDOWN") {
226
+ const error = msg[0] === "ERROR" ? msg[1] : new Error(`toNestHttp(${bindingId}) egress received ${msg[0]}`);
227
+ const message = `toNestHttp(${bindingId}) rejected pending requests after ${msg[0]}`;
228
+ terminal = { error, message };
229
+ const rejectedCount = rejectPending("terminal-egress", error, message);
230
+ if (rejectedCount === 0)
231
+ report({ kind: "terminal-egress", bindingId: scopedBindingId, message, error });
232
+ return;
233
+ }
234
+ if (msg[0] !== "DATA") return;
235
+ const envelope = msg[1];
236
+ const malformed = validateEnvelope(envelope, maxPayloadBytes);
237
+ if (malformed !== void 0) {
238
+ const correlated = malformedCorrelation(msg[1], scopedBindingId);
239
+ if (correlated !== void 0) {
240
+ const pendingKey2 = keyOf(correlated.requestId, scopedBindingId);
241
+ const entry2 = pending.get(pendingKey2);
242
+ if (entry2 !== void 0) {
243
+ pending.delete(pendingKey2);
244
+ rejectEntry(
245
+ entry2,
246
+ new Error(malformed),
247
+ void 0,
248
+ `toNestHttp(${bindingId}) rejected malformed correlated egress`
249
+ );
250
+ }
251
+ }
252
+ report({
253
+ kind: "malformed-egress",
254
+ requestId: correlated?.requestId,
255
+ bindingId: correlated?.bindingId,
256
+ message: malformed
257
+ });
258
+ return;
259
+ }
260
+ if (scopedBindingId !== void 0 && envelope.bindingId !== scopedBindingId) {
261
+ report({
262
+ kind: "binding-mismatch",
263
+ requestId: envelope.requestId,
264
+ bindingId: envelope.bindingId,
265
+ expectedBindingId: scopedBindingId,
266
+ message: `toNestHttp(${bindingId}) ignored egress for binding ${envelope.bindingId}`
267
+ });
268
+ return;
269
+ }
270
+ const pendingKey = keyOf(envelope.requestId, scopedBindingId);
271
+ const entry = pending.get(pendingKey);
272
+ if (entry === void 0) {
273
+ report({
274
+ kind: "stale-egress",
275
+ requestId: envelope.requestId,
276
+ bindingId: envelope.bindingId,
277
+ message: `toNestHttp(${bindingId}) ignored stale requestId ${envelope.requestId}`
278
+ });
279
+ return;
280
+ }
281
+ pending.delete(pendingKey);
282
+ try {
283
+ entry.handle.resolve(
284
+ opts.transform?.(envelope.payload, envelope) ?? envelope.payload,
285
+ envelope
286
+ );
287
+ } catch (error) {
288
+ report({
289
+ kind: "resolve-threw",
290
+ requestId: envelope.requestId,
291
+ bindingId: envelope.bindingId,
292
+ message: `toNestHttp(${bindingId}) response handle threw while resolving`,
293
+ error
294
+ });
295
+ rejectEntry(
296
+ entry,
297
+ error,
298
+ envelope,
299
+ `toNestHttp(${bindingId}) response handle threw while rejecting`
300
+ );
301
+ }
302
+ });
303
+ return {
304
+ kind: "http",
305
+ bindingId,
306
+ attach(registration) {
307
+ if (!active) throw new Error(`toNestHttp(${bindingId}) is disposed`);
308
+ assertNonEmptyString2(registration.requestId, "toNestHttp.attach(requestId)");
309
+ const registrationBindingId = registration.bindingId ?? scopedBindingId;
310
+ if (scopedBindingId !== void 0 && registrationBindingId !== scopedBindingId) {
311
+ throw new Error(
312
+ `toNestHttp.attach expected bindingId ${scopedBindingId}, got ${registrationBindingId}`
313
+ );
314
+ }
315
+ if (terminal !== void 0) {
316
+ const entry2 = {
317
+ requestId: registration.requestId,
318
+ bindingId: registrationBindingId,
319
+ handle: registration.handle
320
+ };
321
+ report({
322
+ kind: "terminal-egress",
323
+ requestId: registration.requestId,
324
+ bindingId: registrationBindingId,
325
+ message: terminal.message,
326
+ error: terminal.error
327
+ });
328
+ rejectEntry(
329
+ entry2,
330
+ terminal.error,
331
+ void 0,
332
+ `toNestHttp(${bindingId}) terminal response handle reject threw`
333
+ );
334
+ return () => false;
335
+ }
336
+ const key = keyOf(registration.requestId, scopedBindingId);
337
+ if (pending.has(key)) {
338
+ throw new Error(`toNestHttp.attach duplicate pending requestId ${registration.requestId}`);
339
+ }
340
+ const entry = {
341
+ requestId: registration.requestId,
342
+ bindingId: registrationBindingId,
343
+ handle: registration.handle
344
+ };
345
+ pending.set(key, entry);
346
+ return () => {
347
+ if (pending.get(key) !== entry) return false;
348
+ return pending.delete(key);
349
+ };
350
+ },
351
+ pendingCount: () => pending.size,
352
+ diagnostics: () => diagnostics.slice(),
353
+ dispose() {
354
+ if (!active) return;
355
+ active = false;
356
+ rejectPending(
357
+ "dispose-pending",
358
+ new Error(`toNestHttp(${bindingId}) disposed before response resolution`),
359
+ `toNestHttp(${bindingId}) rejected pending requests during dispose`
360
+ );
361
+ unsubscribe();
362
+ }
363
+ };
364
+ }
365
+ function createNestGraphBoundaryRunner(opts = {}) {
366
+ const httpBoundaries = /* @__PURE__ */ new Map();
367
+ const httpBoundaryFor = (node, bindingId) => {
368
+ let byBinding = httpBoundaries.get(node);
369
+ if (byBinding === void 0) {
370
+ byBinding = /* @__PURE__ */ new Map();
371
+ httpBoundaries.set(node, byBinding);
372
+ }
373
+ let boundary = byBinding.get(bindingId);
374
+ if (boundary === void 0) {
375
+ boundary = toNestHttp(node, {
376
+ bindingId,
377
+ diagnosticBoundary: opts.diagnosticBoundary,
378
+ diagnosticPhase: opts.diagnosticPhase ?? "http"
379
+ });
380
+ byBinding.set(bindingId, boundary);
381
+ }
382
+ return boundary;
383
+ };
384
+ return {
385
+ run(target, methodKey, host, opts2 = {}) {
386
+ const ctor = typeof target === "function" ? target : target.constructor;
387
+ const bindings = getNestBoundaryBindings(ctor, methodKey);
388
+ if (bindings.length === 0) return void 0;
389
+ const requestId = requestIdFromRunOptions(host, opts2);
390
+ const replies = bindings.filter(isHttpReplyBinding);
391
+ const ingress = bindings.filter(
392
+ (binding) => binding.direction === "ingress" && (binding.kind === "request" || binding.kind === "interceptor")
393
+ );
394
+ if (replies.length > 0 && ingress.length === 0) {
395
+ throw new Error("Nest GraphHttpReply requires at least one ingress boundary");
396
+ }
397
+ const ingressEmits = ingress.map((binding) => ({
398
+ binding,
399
+ requestId: requestIdFromBinding(host, binding) ?? requestId
400
+ }));
401
+ const replyRequestIds = uniqueDefinedStrings(ingressEmits.map((entry) => entry.requestId));
402
+ if (replies.length > 0 && replyRequestIds.length === 0) {
403
+ throw new Error("Nest GraphHttpReply requires a stable requestId");
404
+ }
405
+ const cleanups = [];
406
+ let resolveReply;
407
+ let rejectReply;
408
+ const replyPromise = replies.length === 0 ? void 0 : new Promise((resolve, reject) => {
409
+ resolveReply = resolve;
410
+ rejectReply = reject;
411
+ });
412
+ try {
413
+ for (const reply of replies) {
414
+ const http = httpBoundaryFor(reply.replyNode, reply.bindingId);
415
+ for (const replyRequestId of replyRequestIds) {
416
+ cleanups.push(
417
+ http.attach({
418
+ requestId: replyRequestId,
419
+ bindingId: reply.bindingId,
420
+ handle: {
421
+ resolve: resolveReply ?? (() => void 0),
422
+ reject: rejectReply ?? (() => void 0)
423
+ }
424
+ })
425
+ );
426
+ }
427
+ }
428
+ for (const entry of ingressEmits) {
429
+ entry.binding.boundary.emit(host, {
430
+ bindingId: entry.binding.bindingId,
431
+ requestId: entry.requestId,
432
+ ...bindingPayloadEmitOption(host, entry.binding),
433
+ requireRequestId: requiresRequestId(entry.binding.kind)
434
+ });
435
+ }
436
+ } catch (error) {
437
+ for (const cleanup of cleanups) cleanup();
438
+ throw error;
439
+ }
440
+ return replyPromise?.finally(() => {
441
+ for (const cleanup of cleanups) cleanup();
442
+ });
443
+ },
444
+ dispose() {
445
+ for (const byBinding of httpBoundaries.values()) {
446
+ for (const boundary of byBinding.values()) boundary.dispose();
447
+ }
448
+ httpBoundaries.clear();
449
+ }
450
+ };
451
+ }
452
+ function getNestBoundaryBindings(target, methodKey) {
453
+ const ctor = typeof target === "function" ? target : target.constructor;
454
+ const bindings = boundaryBindingsFor(ctor);
455
+ return sortBoundaryBindings(
456
+ methodKey === void 0 ? bindings : bindings.filter((binding) => binding.methodKey === methodKey)
457
+ );
458
+ }
459
+ function resolveNestMethodKey(ctor, handler) {
460
+ return methodKeyForHandler(ctor, handler);
461
+ }
462
+ function bindingRequestId(host, binding, fallback) {
463
+ if (binding.direction === "ingress") {
464
+ const requestId = requestIdFromBinding(host, binding);
465
+ if (requestId !== void 0) return requestId;
466
+ }
467
+ if (typeof fallback === "string") {
468
+ assertNonEmptyString2(fallback, "requestId");
469
+ return fallback;
470
+ }
471
+ if (typeof fallback === "function") {
472
+ const requestId = fallback(host);
473
+ if (requestId !== void 0) assertNonEmptyString2(requestId, "requestId");
474
+ return requestId;
475
+ }
476
+ return requestIdOf(host, {}, {});
477
+ }
478
+ function bindingEmitOptions(host, binding, requestId) {
479
+ return {
480
+ bindingId: binding.bindingId,
481
+ requestId,
482
+ ...bindingPayloadEmitOption(host, binding),
483
+ requireRequestId: requiresRequestId(binding.kind)
484
+ };
485
+ }
486
+ function isDataIssue(value) {
487
+ return value !== null && typeof value === "object" && value.kind === "issue" && typeof value.code === "string" && typeof value.message === "string";
488
+ }
489
+ function isHttpDataIssue(value) {
490
+ return isDataIssue(value) && Number.isInteger(value.status);
491
+ }
492
+ function issueResponse(issue, _host) {
493
+ if (isHttpDataIssue(issue)) {
494
+ return {
495
+ status: issue.status,
496
+ body: issue.body ?? { code: issue.code, message: issue.message },
497
+ headers: issue.headers
498
+ };
499
+ }
500
+ return {
501
+ status: 400,
502
+ body: { code: issue.code, message: issue.message }
503
+ };
504
+ }
505
+ function protocolError(_errorPayload, _host) {
506
+ return {
507
+ status: 500,
508
+ body: { code: "graphrefly.protocol_error", message: "GraphReFly reply pipeline failed" }
509
+ };
510
+ }
511
+ function lowerHttpReplyPayload(payload, host, opts = {}) {
512
+ if (isHttpResponsePayload(payload)) return payload;
513
+ if (isDataIssue(payload)) return (opts.issueResponse ?? issueResponse)(payload, host);
514
+ return { status: 200, body: payload };
515
+ }
516
+ function lowerProtocolError(errorPayload, host, opts = {}) {
517
+ return (opts.protocolError ?? protocolError)(errorPayload, host);
518
+ }
519
+ function sanitizeNestDiagnostic(diagnostic, defaultPhase = "adapter") {
520
+ const payload = {
521
+ kind: diagnostic.kind,
522
+ phase: diagnostic.phase ?? defaultPhase,
523
+ message: diagnostic.message,
524
+ ...optionalStringField("requestId", diagnostic.requestId),
525
+ ...optionalStringField("bindingId", diagnostic.bindingId),
526
+ ...optionalStringField("expectedBindingId", diagnostic.expectedBindingId),
527
+ ...optionalDiagnosticError(diagnostic.error)
528
+ };
529
+ assertGraphVisibleData(payload, "NestDiagnosticPayload", NEST_BOUNDARY_PAYLOAD_MAX_BYTES);
530
+ return payload;
531
+ }
532
+ function stableBindingId(kind, opts) {
533
+ const bindingId = opts.bindingId ?? opts.name ?? `nestjs.${kind}`;
534
+ assertNonEmptyString2(bindingId, "bindingId");
535
+ return bindingId;
536
+ }
537
+ function requiresRequestId(kind) {
538
+ return kind === "request" || kind === "guard" || kind === "interceptor" || kind === "error";
539
+ }
540
+ function requestIdFromRunOptions(host, opts) {
541
+ if (typeof opts.requestId === "string") {
542
+ assertNonEmptyString2(opts.requestId, "requestId");
543
+ return opts.requestId;
544
+ }
545
+ if (typeof opts.requestId === "function") {
546
+ const requestId = opts.requestId(host);
547
+ if (requestId !== void 0) assertNonEmptyString2(requestId, "requestId");
548
+ return requestId;
549
+ }
550
+ return requestIdOf(host, {}, {});
551
+ }
552
+ function requestIdFromBinding(host, binding) {
553
+ if (typeof binding.requestId === "string") {
554
+ assertNonEmptyString2(binding.requestId, "requestId");
555
+ return binding.requestId;
556
+ }
557
+ if (typeof binding.requestId === "function") {
558
+ const requestId = binding.requestId(host);
559
+ if (requestId !== void 0) assertNonEmptyString2(requestId, "requestId");
560
+ return requestId;
561
+ }
562
+ return void 0;
563
+ }
564
+ function bindingPayloadEmitOption(host, binding) {
565
+ return binding.payload === void 0 ? {} : { payload: binding.payload(host) };
566
+ }
567
+ function isHttpResponsePayload(value) {
568
+ if (value === null || typeof value !== "object") return false;
569
+ const status = value.status;
570
+ if (!Number.isInteger(status)) return false;
571
+ const headers = value.headers;
572
+ return headers === void 0 || isStringRecord(headers);
573
+ }
574
+ function isStringRecord(value) {
575
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
576
+ for (const entry of Object.values(value)) if (typeof entry !== "string") return false;
577
+ return true;
578
+ }
579
+ function isHttpReplyBinding(binding) {
580
+ return binding.direction === "egress" && binding.kind === "http";
581
+ }
582
+ function uniqueDefinedStrings(values) {
583
+ const seen = /* @__PURE__ */ new Set();
584
+ for (const value of values) {
585
+ if (value !== void 0) seen.add(value);
586
+ }
587
+ return [...seen];
588
+ }
589
+ function methodKeyForHandler(ctor, handler) {
590
+ for (const binding of boundaryBindingsFor(ctor)) {
591
+ const candidate = methodOnPrototypeChain(ctor, binding.methodKey);
592
+ if (candidate === handler || String(binding.methodKey) === handler.name)
593
+ return binding.methodKey;
594
+ }
595
+ return void 0;
596
+ }
597
+ function boundaryBindingsFor(ctor) {
598
+ const bindings = [];
599
+ const seen = /* @__PURE__ */ new Set();
600
+ let current = ctor;
601
+ while (typeof current === "function" && current !== Function.prototype) {
602
+ for (const binding of NEST_BOUNDARY_BINDINGS.get(current) ?? []) {
603
+ if (seen.has(binding)) continue;
604
+ seen.add(binding);
605
+ bindings.push(binding);
606
+ }
607
+ current = Object.getPrototypeOf(current);
608
+ }
609
+ return bindings;
610
+ }
611
+ function sortBoundaryBindings(bindings) {
612
+ return bindings.map((binding, index) => ({ binding, index })).sort((a, b) => (a.binding.order ?? 0) - (b.binding.order ?? 0) || a.index - b.index).map(({ binding }) => binding);
613
+ }
614
+ function methodOnPrototypeChain(ctor, methodKey) {
615
+ let proto = ctor.prototype;
616
+ while (proto !== null && typeof proto === "object") {
617
+ if (Object.hasOwn(proto, methodKey)) {
618
+ return proto[methodKey];
619
+ }
620
+ proto = Object.getPrototypeOf(proto);
621
+ }
622
+ return void 0;
623
+ }
624
+ function requestIdOf(host, opts, emitOpts) {
625
+ const fromEmit = emitOpts.requestId;
626
+ if (fromEmit !== void 0) {
627
+ assertNonEmptyString2(fromEmit, "requestId");
628
+ return fromEmit;
629
+ }
630
+ if (typeof opts.requestId === "string") {
631
+ assertNonEmptyString2(opts.requestId, "requestId");
632
+ return opts.requestId;
633
+ }
634
+ if (typeof opts.requestId === "function") {
635
+ const requestId = opts.requestId(host);
636
+ if (requestId !== void 0) assertNonEmptyString2(requestId, "requestId");
637
+ return requestId;
638
+ }
639
+ const record = host;
640
+ if (typeof record?.requestId === "string" && record.requestId.length > 0) return record.requestId;
641
+ if (typeof record?.id === "string" && record.id.length > 0) return record.id;
642
+ if (emitOpts.requireRequestId ?? opts.requireRequestId ?? false) {
643
+ throw new Error("Nest boundary ingress requires a stable requestId");
644
+ }
645
+ return void 0;
646
+ }
647
+ function validateEnvelope(value, maxPayloadBytes) {
648
+ try {
649
+ assertGraphVisibleData(value, "NestBoundaryEnvelope", maxPayloadBytes);
650
+ } catch (error) {
651
+ return error instanceof Error ? error.message : "egress envelope must be data-only material";
652
+ }
653
+ if (value === null || typeof value !== "object") return "egress DATA is not an envelope object";
654
+ const envelope = value;
655
+ if (typeof envelope.requestId !== "string" || envelope.requestId.length === 0) {
656
+ return "egress envelope requestId must be a non-empty string";
657
+ }
658
+ if (typeof envelope.bindingId !== "string" || envelope.bindingId.length === 0) {
659
+ return "egress envelope bindingId must be a non-empty string";
660
+ }
661
+ try {
662
+ parseEnvelopeVersion(envelope.version, "egress envelope version");
663
+ } catch {
664
+ return `egress envelope version must be ${NEST_BOUNDARY_ENVELOPE_VERSION}`;
665
+ }
666
+ return void 0;
667
+ }
668
+ function malformedCorrelation(value, scopedBindingId) {
669
+ if (value === null || typeof value !== "object") return void 0;
670
+ const requestId = value.requestId;
671
+ const bindingId = value.bindingId;
672
+ if (typeof requestId !== "string" || requestId.length === 0) return void 0;
673
+ if (typeof bindingId !== "string" || bindingId.length === 0) return void 0;
674
+ if (scopedBindingId !== void 0 && bindingId !== scopedBindingId) return void 0;
675
+ return { requestId, bindingId };
676
+ }
677
+ function parseEnvelopeVersion(value, label) {
678
+ if (value !== NEST_BOUNDARY_ENVELOPE_VERSION) {
679
+ throw new Error(`${label} must be ${NEST_BOUNDARY_ENVELOPE_VERSION}`);
680
+ }
681
+ return value;
682
+ }
683
+ function assertNonEmptyString2(value, label) {
684
+ if (value.length === 0) throw new Error(`${label} must be a non-empty string`);
685
+ }
686
+ function optionalStringField(key, value) {
687
+ return value === void 0 ? {} : { [key]: value };
688
+ }
689
+ function optionalDiagnosticError(error) {
690
+ const summarized = summarizeDiagnosticError(error);
691
+ return summarized === void 0 ? {} : { error: summarized };
692
+ }
693
+ function summarizeDiagnosticError(error) {
694
+ if (error === void 0) return void 0;
695
+ if (error instanceof Error) {
696
+ return {
697
+ ...optionalDiagnosticName(safeDiagnosticString(() => error.name)),
698
+ message: safeDiagnosticString(() => error.message) ?? "diagnostic error"
699
+ };
700
+ }
701
+ if (typeof error === "string") return { message: error };
702
+ if (typeof error === "number" || typeof error === "boolean" || typeof error === "bigint") {
703
+ return { message: String(error) };
704
+ }
705
+ if (typeof error === "symbol") return { message: error.description ?? "symbol" };
706
+ if (typeof error === "function") return { message: "opaque diagnostic function" };
707
+ if (error !== null && typeof error === "object") {
708
+ const record = error;
709
+ const message = safeDiagnosticString(() => record.message);
710
+ if (message !== void 0) {
711
+ return {
712
+ ...optionalDiagnosticName(safeDiagnosticString(() => record.name)),
713
+ message
714
+ };
715
+ }
716
+ return { message: "opaque diagnostic error" };
717
+ }
718
+ return { message: String(error) };
719
+ }
720
+ function safeDiagnosticString(read) {
721
+ try {
722
+ const value = read();
723
+ return typeof value === "string" ? value : void 0;
724
+ } catch {
725
+ return void 0;
726
+ }
727
+ }
728
+ function optionalDiagnosticName(name) {
729
+ return name === void 0 || name.length === 0 ? {} : { name };
730
+ }
731
+ function payloadByteLimit(value) {
732
+ if (value === void 0) return NEST_BOUNDARY_PAYLOAD_MAX_BYTES;
733
+ if (!Number.isSafeInteger(value) || value < 1) {
734
+ throw new Error("Nest boundary maxPayloadBytes must be a positive safe integer");
735
+ }
736
+ return value;
737
+ }
738
+ function diagnosticsRetainedLimit(value) {
739
+ if (value === void 0) return NEST_HTTP_DIAGNOSTICS_MAX_RETAINED;
740
+ if (!Number.isSafeInteger(value) || value < 0) {
741
+ throw new Error("toNestHttp maxDiagnostics must be a non-negative safe integer");
742
+ }
743
+ return value;
744
+ }
745
+ function pushDiagnostic(diagnostics, diagnostic, maxDiagnostics) {
746
+ if (maxDiagnostics === 0) return;
747
+ diagnostics.push(diagnostic);
748
+ if (diagnostics.length > maxDiagnostics)
749
+ diagnostics.splice(0, diagnostics.length - maxDiagnostics);
750
+ }
751
+ function assertGraphVisibleData(value, path, maxPayloadBytes, seen = /* @__PURE__ */ new WeakSet()) {
752
+ if (value === void 0) {
753
+ throw new TypeError(`${path} cannot be undefined; undefined is SENTINEL/no DATA`);
754
+ }
755
+ if (value === null) return;
756
+ const type = typeof value;
757
+ if (type === "string" || type === "boolean") return;
758
+ if (type === "number") {
759
+ if (!Number.isFinite(value)) throw new TypeError(`${path} number must be finite`);
760
+ return;
761
+ }
762
+ if (type === "function" || type === "symbol" || type === "bigint") {
763
+ throw new TypeError(`${path} must be data-only; found ${type}`);
764
+ }
765
+ if (type !== "object") return;
766
+ if (seen.has(value)) throw new TypeError(`${path} must be acyclic data`);
767
+ seen.add(value);
768
+ if (Array.isArray(value)) {
769
+ try {
770
+ for (let i = 0; i < value.length; i += 1) {
771
+ const descriptor = Object.getOwnPropertyDescriptor(value, i);
772
+ if (descriptor === void 0) {
773
+ throw new TypeError(`${path}[${i}] cannot be a sparse array hole`);
774
+ }
775
+ if (!descriptor.enumerable || !("value" in descriptor)) {
776
+ throw new TypeError(`${path}[${i}] must be enumerable plain data`);
777
+ }
778
+ assertGraphVisibleData(descriptor.value, `${path}[${i}]`, maxPayloadBytes, seen);
779
+ }
780
+ for (const key of Reflect.ownKeys(value)) {
781
+ if (key === "length") continue;
782
+ if (typeof key === "symbol" || !/^(0|[1-9]\d*)$/.test(key)) {
783
+ throw new TypeError(`${path} arrays must not carry hidden or extra properties`);
784
+ }
785
+ }
786
+ assertPayloadSize(value, path, maxPayloadBytes);
787
+ } finally {
788
+ seen.delete(value);
789
+ }
790
+ return;
791
+ }
792
+ const proto = Object.getPrototypeOf(value);
793
+ if (proto !== Object.prototype && proto !== null) {
794
+ throw new TypeError(`${path} must be a plain data object or array`);
795
+ }
796
+ try {
797
+ for (const key of Reflect.ownKeys(value)) {
798
+ if (typeof key === "symbol") throw new TypeError(`${path} must not carry symbol keys`);
799
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
800
+ if (descriptor === void 0) continue;
801
+ if (!descriptor.enumerable || !("value" in descriptor)) {
802
+ throw new TypeError(`${path}.${key} must be enumerable plain data`);
803
+ }
804
+ assertGraphVisibleData(descriptor.value, `${path}.${key}`, maxPayloadBytes, seen);
805
+ }
806
+ assertPayloadSize(value, path, maxPayloadBytes);
807
+ } finally {
808
+ seen.delete(value);
809
+ }
810
+ }
811
+ function assertPayloadSize(value, path, maxPayloadBytes) {
812
+ const serialized = JSON.stringify(value);
813
+ if (serialized !== void 0 && utf8ByteLength(serialized) > maxPayloadBytes) {
814
+ throw new TypeError(`${path} exceeds ${maxPayloadBytes} bytes`);
815
+ }
816
+ }
817
+ function utf8ByteLength(value) {
818
+ let bytes = 0;
819
+ for (let i = 0; i < value.length; i += 1) {
820
+ const code = value.charCodeAt(i);
821
+ if (code < 128) {
822
+ bytes += 1;
823
+ } else if (code < 2048) {
824
+ bytes += 2;
825
+ } else if (code >= 55296 && code <= 56319 && i + 1 < value.length) {
826
+ const next = value.charCodeAt(i + 1);
827
+ if (next >= 56320 && next <= 57343) {
828
+ bytes += 4;
829
+ i += 1;
830
+ } else {
831
+ bytes += 3;
832
+ }
833
+ } else {
834
+ bytes += 3;
835
+ }
836
+ }
837
+ return bytes;
838
+ }
839
+
840
+ // src/adapters/nestjs/native.ts
841
+ var GRAPHREFLY_NEST_CRON_SCHEDULER = /* @__PURE__ */ Symbol.for("graphrefly:nest:cron-scheduler");
842
+ var GRAPHREFLY_NEST_EXCEPTION_FILTER = /* @__PURE__ */ Symbol.for("graphrefly:nest:exception-filter");
843
+ var GRAPHREFLY_NEST_LIFECYCLE_HOOKS = /* @__PURE__ */ Symbol.for("graphrefly:nest:lifecycle-hooks");
844
+ function provideGraphBoundaryInterceptor(opts = {}) {
845
+ return { provide: import_core.APP_INTERCEPTOR, useValue: new GraphBoundaryInterceptorBridge(opts) };
846
+ }
847
+ function provideGraphGuard(opts = {}) {
848
+ return { provide: import_core.APP_GUARD, useValue: new GraphGuardBridge(opts) };
849
+ }
850
+ function provideGraphExceptionFilter(opts) {
851
+ return { provide: GRAPHREFLY_NEST_EXCEPTION_FILTER, useValue: createGraphExceptionFilter(opts) };
852
+ }
853
+ function createGraphExceptionFilter(opts) {
854
+ return new GraphExceptionFilterBridge(opts);
855
+ }
856
+ function provideGraphGuardDeniedFilter() {
857
+ return GraphGuardDeniedFilter;
858
+ }
859
+ function createGraphGuardDeniedFilter() {
860
+ return new GraphGuardDeniedFilter();
861
+ }
862
+ function provideGraphCronScheduler(opts) {
863
+ return { provide: GRAPHREFLY_NEST_CRON_SCHEDULER, useValue: new GraphCronSchedulerBridge(opts) };
864
+ }
865
+ function provideGraphLifecycleHooks(opts) {
866
+ return {
867
+ provide: GRAPHREFLY_NEST_LIFECYCLE_HOOKS,
868
+ useValue: new GraphLifecycleHooksBridge(opts)
869
+ };
870
+ }
871
+ function provideGraphNativeHttpProviders(opts = {}) {
872
+ const providers = [];
873
+ if (opts.boundaryInterceptor !== false)
874
+ providers.push(provideGraphBoundaryInterceptor(opts.boundaryInterceptor ?? {}));
875
+ if (opts.guard !== false) providers.push(provideGraphGuard(opts.guard ?? {}));
876
+ if (opts.guardDeniedFilter ?? true) providers.push(provideGraphGuardDeniedFilter());
877
+ if (opts.exceptionFilter !== void 0)
878
+ providers.push(provideGraphExceptionFilter(opts.exceptionFilter));
879
+ return providers;
880
+ }
881
+ function provideGraphNativeProviders(opts = {}) {
882
+ const providers = [];
883
+ if (opts.http !== false) providers.push(...provideGraphNativeHttpProviders(opts.http ?? {}));
884
+ if (opts.cronScheduler !== void 0)
885
+ providers.push(provideGraphCronScheduler(opts.cronScheduler));
886
+ if (opts.lifecycleHooks !== void 0)
887
+ providers.push(provideGraphLifecycleHooks(opts.lifecycleHooks));
888
+ return providers;
889
+ }
890
+ function graphCronTarget(target, methodKey, opts) {
891
+ return { ...opts, target, methodKey };
892
+ }
893
+ function graphLifecycleTarget(target, methodKey, opts = {}) {
894
+ return { ...opts, target, methodKey };
895
+ }
896
+ function createGraphCronController(opts) {
897
+ return new GraphCronControllerImpl(opts);
898
+ }
899
+ var GraphBoundaryInterceptorBridge = class {
900
+ constructor(opts) {
901
+ this.opts = opts;
902
+ this.runner = createNestGraphBoundaryRunner({
903
+ diagnosticBoundary: opts.diagnosticBoundary,
904
+ diagnosticPhase: "http"
905
+ });
906
+ }
907
+ runner;
908
+ intercept(context, next) {
909
+ const host = this.opts.host?.(context) ?? defaultHttpHost(context);
910
+ const result = this.runner.run(
911
+ context.getClass(),
912
+ methodKeyForContext(context),
913
+ host,
914
+ this.opts
915
+ );
916
+ const reply = firstHttpReply(context);
917
+ const value = result === void 0 ? next.handle() : Promise.resolve(result).then(
918
+ (payload) => writeHttpResponse(
919
+ context,
920
+ lowerHttpReplyPayload(payload, host, {
921
+ issueResponse: reply?.issueResponse ?? this.opts.issueResponse
922
+ })
923
+ ),
924
+ (errorPayload) => writeHttpResponse(
925
+ context,
926
+ lowerProtocolError(errorPayload, host, {
927
+ protocolError: reply?.protocolError ?? this.opts.protocolError
928
+ })
929
+ )
930
+ );
931
+ return isObservableLike(value) ? value : (0, import_rxjs.from)(Promise.resolve(value));
932
+ }
933
+ onModuleDestroy() {
934
+ this.runner.dispose();
935
+ }
936
+ };
937
+ var GraphGuardBridge = class {
938
+ constructor(opts) {
939
+ this.opts = opts;
940
+ }
941
+ decisions = /* @__PURE__ */ new WeakMap();
942
+ disposableDecisions = /* @__PURE__ */ new Set();
943
+ async canActivate(context) {
944
+ const methodKey = methodKeyForContext(context);
945
+ const bindings = getNestBoundaryBindings(context.getClass(), methodKey);
946
+ const guards = bindings.filter(isGuardIngress);
947
+ if (guards.length === 0) return true;
948
+ const decisions = bindings.filter(isGuardDecision);
949
+ if (decisions.length === 0) return false;
950
+ const host = this.opts.host?.(context) ?? defaultHttpHost(context);
951
+ const guardEmits = guards.map((guard) => ({
952
+ guard,
953
+ requestId: bindingRequestId(host, guard, this.opts.requestId)
954
+ }));
955
+ if (guardEmits.some((entry) => entry.requestId === void 0)) return false;
956
+ const requestIds = new Set(guardEmits.map((entry) => entry.requestId));
957
+ const cleanups = [];
958
+ try {
959
+ const pending = [];
960
+ for (const requestId of requestIds) {
961
+ for (const decision of decisions) {
962
+ const state = { status: "pending", binding: decision };
963
+ pending.push(state);
964
+ cleanups.push(
965
+ this.decisionBoundary(decision).attach({
966
+ requestId,
967
+ bindingId: decision.bindingId,
968
+ handle: {
969
+ resolve(payload) {
970
+ state.status = "resolved";
971
+ state.payload = payload;
972
+ },
973
+ reject(error) {
974
+ state.status = "rejected";
975
+ state.error = error;
976
+ }
977
+ }
978
+ })
979
+ );
980
+ }
981
+ }
982
+ for (const entry of guardEmits)
983
+ entry.guard.boundary.emit(host, bindingEmitOptions(host, entry.guard, entry.requestId));
984
+ const rejected = pending.find((state) => state.status === "rejected");
985
+ if (rejected !== void 0) {
986
+ throw new GraphGuardProtocolErrorException(
987
+ lowerProtocolError(rejected.error, host, {
988
+ protocolError: rejected.binding.protocolError ?? this.opts.protocolError
989
+ })
990
+ );
991
+ }
992
+ if (pending.some((state) => state.status !== "resolved")) return false;
993
+ const denied = pending.find(
994
+ (state) => state.status === "resolved" && state.payload?.kind === "deny"
995
+ );
996
+ if (denied !== void 0) {
997
+ throw new GraphGuardDeniedException(
998
+ guardDecisionResponse(denied.payload, host, {
999
+ issueResponse: denied.binding.issueResponse ?? this.opts.issueResponse
1000
+ })
1001
+ );
1002
+ }
1003
+ return pending.every((state) => state.payload?.kind === "allow");
1004
+ } catch (error) {
1005
+ if (isGraphGuardDeniedException(error) || error instanceof GraphGuardProtocolErrorException) {
1006
+ throw error;
1007
+ }
1008
+ return false;
1009
+ } finally {
1010
+ for (const cleanup of cleanups) cleanup();
1011
+ }
1012
+ }
1013
+ onModuleDestroy() {
1014
+ for (const boundary of this.disposableDecisions) boundary.dispose();
1015
+ this.disposableDecisions.clear();
1016
+ }
1017
+ decisionBoundary(binding) {
1018
+ const node = binding.decisionNode;
1019
+ let byBinding = this.decisions.get(node);
1020
+ if (byBinding === void 0) {
1021
+ byBinding = /* @__PURE__ */ new Map();
1022
+ this.decisions.set(node, byBinding);
1023
+ }
1024
+ const existing = byBinding.get(binding.bindingId);
1025
+ if (existing !== void 0) return existing;
1026
+ const boundary = toNestHttp(binding.decisionNode, {
1027
+ bindingId: binding.bindingId,
1028
+ diagnosticBoundary: this.opts.diagnosticBoundary,
1029
+ diagnosticPhase: "guard"
1030
+ });
1031
+ byBinding.set(binding.bindingId, boundary);
1032
+ this.disposableDecisions.add(boundary);
1033
+ return boundary;
1034
+ }
1035
+ };
1036
+ var GraphExceptionFilterBridge = class {
1037
+ constructor(opts) {
1038
+ this.opts = opts;
1039
+ }
1040
+ replies = /* @__PURE__ */ new WeakMap();
1041
+ disposableReplies = /* @__PURE__ */ new Set();
1042
+ catch(exception, host) {
1043
+ const target = this.opts.target(host, exception);
1044
+ if (target === void 0) throw exception;
1045
+ const bindings = getNestBoundaryBindings(target.target, target.methodKey);
1046
+ const filters = bindings.filter(isErrorIngress);
1047
+ if (filters.length === 0) throw exception;
1048
+ const nativeHost = this.opts.host?.(host, exception) ?? defaultArgumentsHost(host, exception);
1049
+ const filterEmits = filters.map((filter) => ({
1050
+ filter,
1051
+ requestId: bindingRequestId(nativeHost, filter, this.opts.requestId)
1052
+ }));
1053
+ const handleFilters = filterEmits.filter((entry) => entry.filter.mode !== "observe");
1054
+ const observeOnly = handleFilters.length === 0;
1055
+ const replies = bindings.filter(isHttpReply);
1056
+ const cleanups = [];
1057
+ const emitFilters = () => {
1058
+ for (const entry of filterEmits) {
1059
+ entry.filter.boundary.emit(
1060
+ nativeHost,
1061
+ bindingEmitOptions(nativeHost, entry.filter, entry.requestId)
1062
+ );
1063
+ }
1064
+ };
1065
+ if (observeOnly) {
1066
+ emitFilters();
1067
+ throw exception;
1068
+ }
1069
+ const requestIds = new Set(
1070
+ handleFilters.map((entry) => entry.requestId).filter((requestId) => requestId !== void 0)
1071
+ );
1072
+ if (replies.length === 0 || requestIds.size === 0) {
1073
+ for (const entry of filterEmits) {
1074
+ if (entry.requestId === void 0) continue;
1075
+ entry.filter.boundary.emit(
1076
+ nativeHost,
1077
+ bindingEmitOptions(nativeHost, entry.filter, entry.requestId)
1078
+ );
1079
+ }
1080
+ const filter = handleFilters[0]?.filter;
1081
+ const lowered = lowerCaughtException(exception, nativeHost, {
1082
+ issueResponse: filter?.issueResponse ?? this.opts.issueResponse,
1083
+ protocolError: filter?.protocolError ?? this.opts.protocolError
1084
+ });
1085
+ return writeHttpResponse(host, lowered);
1086
+ }
1087
+ const pending = [];
1088
+ try {
1089
+ for (const requestId of requestIds) {
1090
+ for (const reply of replies) {
1091
+ const state = { status: "pending", reply };
1092
+ pending.push(state);
1093
+ cleanups.push(
1094
+ this.replyBoundary(reply).attach({
1095
+ requestId,
1096
+ bindingId: reply.bindingId,
1097
+ handle: {
1098
+ resolve(payload) {
1099
+ state.status = "resolved";
1100
+ state.payload = payload;
1101
+ },
1102
+ reject(error) {
1103
+ state.status = "rejected";
1104
+ state.error = error;
1105
+ }
1106
+ }
1107
+ })
1108
+ );
1109
+ }
1110
+ }
1111
+ emitFilters();
1112
+ const resolved = pending.find((state) => state.status === "resolved");
1113
+ if (resolved !== void 0) {
1114
+ return writeHttpResponse(
1115
+ host,
1116
+ lowerHttpReplyPayload(resolved.payload, nativeHost, {
1117
+ issueResponse: resolved.reply.issueResponse ?? handleFilters[0]?.filter.issueResponse ?? this.opts.issueResponse
1118
+ })
1119
+ );
1120
+ }
1121
+ const rejected = pending.find((state) => state.status === "rejected");
1122
+ if (rejected !== void 0) {
1123
+ return writeHttpResponse(
1124
+ host,
1125
+ lowerProtocolError(rejected.error, nativeHost, {
1126
+ protocolError: rejected.reply.protocolError ?? handleFilters[0]?.filter.protocolError ?? this.opts.protocolError
1127
+ })
1128
+ );
1129
+ }
1130
+ const filter = handleFilters[0]?.filter;
1131
+ return writeHttpResponse(
1132
+ host,
1133
+ lowerCaughtException(exception, nativeHost, {
1134
+ issueResponse: filter?.issueResponse ?? this.opts.issueResponse,
1135
+ protocolError: filter?.protocolError ?? this.opts.protocolError
1136
+ })
1137
+ );
1138
+ } finally {
1139
+ for (const cleanup of cleanups) cleanup();
1140
+ }
1141
+ }
1142
+ onModuleDestroy() {
1143
+ for (const boundary of this.disposableReplies) boundary.dispose();
1144
+ this.disposableReplies.clear();
1145
+ }
1146
+ replyBoundary(binding) {
1147
+ const node = binding.replyNode;
1148
+ let byBinding = this.replies.get(node);
1149
+ if (byBinding === void 0) {
1150
+ byBinding = /* @__PURE__ */ new Map();
1151
+ this.replies.set(node, byBinding);
1152
+ }
1153
+ const existing = byBinding.get(binding.bindingId);
1154
+ if (existing !== void 0) return existing;
1155
+ const boundary = toNestHttp(binding.replyNode, {
1156
+ bindingId: binding.bindingId,
1157
+ diagnosticBoundary: this.opts.diagnosticBoundary,
1158
+ diagnosticPhase: "filter"
1159
+ });
1160
+ byBinding.set(binding.bindingId, boundary);
1161
+ this.disposableReplies.add(boundary);
1162
+ return boundary;
1163
+ }
1164
+ };
1165
+ var GraphCronControllerImpl = class {
1166
+ targets;
1167
+ constructor(opts) {
1168
+ this.targets = opts.targets.map((target) => ({
1169
+ target,
1170
+ schedule: parseCron(target.expr),
1171
+ fired: /* @__PURE__ */ new Set()
1172
+ }));
1173
+ }
1174
+ check(now) {
1175
+ for (const entry of this.targets) {
1176
+ emitCronTarget(entry.target, entry.schedule, entry.fired, now);
1177
+ }
1178
+ }
1179
+ };
1180
+ var GraphCronSchedulerBridge = class {
1181
+ constructor(opts) {
1182
+ this.opts = opts;
1183
+ }
1184
+ timers = [];
1185
+ onModuleInit() {
1186
+ try {
1187
+ for (const target of this.opts.targets) this.startTarget(target);
1188
+ } catch (error) {
1189
+ this.onModuleDestroy();
1190
+ throw error;
1191
+ }
1192
+ }
1193
+ onModuleDestroy() {
1194
+ for (const timer of this.timers.splice(0)) clearInterval(timer);
1195
+ }
1196
+ startTarget(target) {
1197
+ const tickMs = target.tickMs ?? 6e4;
1198
+ if (!Number.isFinite(tickMs) || tickMs <= 0) {
1199
+ throw new RangeError("provideGraphCronScheduler: tickMs must be a positive finite number");
1200
+ }
1201
+ const controller = createGraphCronController({ targets: [target] });
1202
+ const check = () => controller.check(/* @__PURE__ */ new Date());
1203
+ check();
1204
+ this.timers.push(setInterval(check, tickMs));
1205
+ }
1206
+ };
1207
+ var GraphLifecycleHooksBridge = class {
1208
+ constructor(opts) {
1209
+ this.opts = opts;
1210
+ }
1211
+ onModuleInit() {
1212
+ this.emit("module-init");
1213
+ }
1214
+ onModuleDestroy() {
1215
+ this.emit("module-destroy");
1216
+ }
1217
+ emit(event) {
1218
+ for (const target of this.opts.targets) {
1219
+ if (target.event !== void 0 && target.event !== event) continue;
1220
+ const host = target.host?.(event) ?? { event };
1221
+ for (const binding of lifecycleBindings(target)) {
1222
+ binding.boundary.emit(host, bindingEmitOptions(host, binding, void 0));
1223
+ }
1224
+ }
1225
+ }
1226
+ };
1227
+ function methodKeyForContext(context) {
1228
+ const resolved = resolveNestMethodKey(
1229
+ context.getClass(),
1230
+ context.getHandler()
1231
+ );
1232
+ return resolved ?? context.getHandler().name;
1233
+ }
1234
+ function defaultHttpHost(context) {
1235
+ const request = context.switchToHttp?.().getRequest?.();
1236
+ return request ?? {};
1237
+ }
1238
+ function defaultArgumentsHost(host, exception) {
1239
+ const request = host.switchToHttp?.().getRequest?.();
1240
+ if (request !== void 0 && request !== null) return { ...request, exception };
1241
+ return { exception };
1242
+ }
1243
+ function isObservableLike(value) {
1244
+ return value !== null && typeof value === "object" && typeof value.subscribe === "function";
1245
+ }
1246
+ function isGuardIngress(binding) {
1247
+ return binding.direction === "ingress" && binding.kind === "guard";
1248
+ }
1249
+ function isErrorIngress(binding) {
1250
+ return binding.direction === "ingress" && binding.kind === "error";
1251
+ }
1252
+ function isHttpReply(binding) {
1253
+ return binding.direction === "egress" && binding.kind === "http";
1254
+ }
1255
+ function isGuardDecision(binding) {
1256
+ return binding.direction === "egress" && binding.kind === "guard-decision";
1257
+ }
1258
+ function firstHttpReply(context) {
1259
+ return getNestBoundaryBindings(context.getClass(), methodKeyForContext(context)).find(
1260
+ isHttpReply
1261
+ );
1262
+ }
1263
+ function lifecycleBindings(target) {
1264
+ return getNestBoundaryBindings(target.target, target.methodKey).filter(
1265
+ (binding) => binding.direction === "ingress" && binding.kind === "lifecycle"
1266
+ );
1267
+ }
1268
+ function cronBindings(target) {
1269
+ return getNestBoundaryBindings(target.target, target.methodKey).filter(
1270
+ (binding) => binding.direction === "ingress" && binding.kind === "cron"
1271
+ );
1272
+ }
1273
+ function emitCronTarget(target, schedule, fired, now) {
1274
+ if (!matchesCron(schedule, now, { timezone: target.timezone })) return;
1275
+ const key = cronProviderMinuteKey(now, target.timezone);
1276
+ for (const existing of fired) {
1277
+ if (!existing.startsWith(`${key.dayKey}:`)) fired.delete(existing);
1278
+ }
1279
+ if (fired.has(key.minuteKey)) return;
1280
+ fired.add(key.minuteKey);
1281
+ const host = target.host?.(now) ?? {
1282
+ iso: now.toISOString(),
1283
+ timestamp_ms: now.getTime(),
1284
+ timestamp_ns: (BigInt(now.getTime()) * 1000000n).toString(),
1285
+ timezone: target.timezone
1286
+ };
1287
+ for (const binding of cronBindings(target)) {
1288
+ binding.boundary.emit(host, bindingEmitOptions(host, binding, void 0));
1289
+ }
1290
+ }
1291
+ function cronProviderMinuteKey(date, timezone) {
1292
+ if (timezone === void 0) {
1293
+ const dayKey2 = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
1294
+ return { dayKey: dayKey2, minuteKey: `${dayKey2}:${date.getHours()}:${date.getMinutes()}` };
1295
+ }
1296
+ const parts = new Intl.DateTimeFormat("en-US-u-ca-gregory-nu-latn", {
1297
+ timeZone: timezone,
1298
+ year: "numeric",
1299
+ month: "2-digit",
1300
+ day: "2-digit",
1301
+ hour: "2-digit",
1302
+ minute: "2-digit",
1303
+ hourCycle: "h23"
1304
+ }).formatToParts(date);
1305
+ const byType = new Map(parts.map((part) => [part.type, part.value]));
1306
+ const dayKey = `${byType.get("year")}-${byType.get("month")}-${byType.get("day")}`;
1307
+ return { dayKey, minuteKey: `${dayKey}:${byType.get("hour")}:${byType.get("minute")}` };
1308
+ }
1309
+ function lowerCaughtException(exception, host, opts) {
1310
+ if (isDataIssue(exception)) return lowerHttpReplyPayload(exception, host, opts);
1311
+ return (opts.protocolError ?? protocolError)(exception, host);
1312
+ }
1313
+ function guardDecisionResponse(decision, host, opts) {
1314
+ if (decision.issue !== void 0) return lowerHttpReplyPayload(decision.issue, host, opts);
1315
+ if (Number.isInteger(decision.status)) {
1316
+ return {
1317
+ status: decision.status,
1318
+ body: decision.body ?? {
1319
+ code: "graphrefly.guard_denied",
1320
+ message: decision.reason ?? "GraphReFly guard denied request"
1321
+ },
1322
+ headers: decision.headers
1323
+ };
1324
+ }
1325
+ return {
1326
+ status: 403,
1327
+ body: {
1328
+ code: "graphrefly.guard_denied",
1329
+ message: decision.reason ?? "GraphReFly guard denied request"
1330
+ },
1331
+ headers: decision.headers
1332
+ };
1333
+ }
1334
+ var GraphGuardDeniedException = class extends import_common.HttpException {
1335
+ payload;
1336
+ constructor(payload) {
1337
+ super(payload.body ?? {}, payload.status);
1338
+ this.payload = payload;
1339
+ }
1340
+ };
1341
+ var GraphGuardProtocolErrorException = class extends import_common.HttpException {
1342
+ constructor(payload) {
1343
+ super(payload.body ?? {}, payload.status);
1344
+ }
1345
+ };
1346
+ function isGraphGuardDeniedException(value) {
1347
+ return value instanceof GraphGuardDeniedException;
1348
+ }
1349
+ var GraphGuardDeniedFilter = class {
1350
+ catch(exception, host) {
1351
+ if (!isGraphGuardDeniedException(exception)) throw exception;
1352
+ return writeHttpResponse(host, exception.payload);
1353
+ }
1354
+ };
1355
+ (0, import_common.Catch)(GraphGuardDeniedException)(GraphGuardDeniedFilter);
1356
+ function writeHttpResponse(host, payload) {
1357
+ const response = host.switchToHttp?.().getResponse?.();
1358
+ if (response === void 0) return payload;
1359
+ for (const [name, value] of Object.entries(payload.headers ?? {})) {
1360
+ if (typeof response.setHeader === "function") response.setHeader(name, value);
1361
+ else response.header?.(name, value);
1362
+ }
1363
+ response.status?.(payload.status);
1364
+ if (typeof response.json === "function") return response.json(payload.body ?? {});
1365
+ if (typeof response.send === "function") return response.send(payload.body);
1366
+ return payload;
1367
+ }
1368
+ // Annotate the CommonJS export names for ESM import in node:
1369
+ 0 && (module.exports = {
1370
+ GRAPHREFLY_NEST_CRON_SCHEDULER,
1371
+ GRAPHREFLY_NEST_EXCEPTION_FILTER,
1372
+ GRAPHREFLY_NEST_LIFECYCLE_HOOKS,
1373
+ GraphExceptionFilterBridge,
1374
+ GraphGuardDeniedException,
1375
+ GraphGuardDeniedFilter,
1376
+ createGraphCronController,
1377
+ createGraphExceptionFilter,
1378
+ createGraphGuardDeniedFilter,
1379
+ graphCronTarget,
1380
+ graphLifecycleTarget,
1381
+ isGraphGuardDeniedException,
1382
+ provideGraphBoundaryInterceptor,
1383
+ provideGraphCronScheduler,
1384
+ provideGraphExceptionFilter,
1385
+ provideGraphGuard,
1386
+ provideGraphGuardDeniedFilter,
1387
+ provideGraphLifecycleHooks,
1388
+ provideGraphNativeHttpProviders,
1389
+ provideGraphNativeProviders
1390
+ });
1391
+ //# sourceMappingURL=native.cjs.map