@inluxc/propmaster 0.0.0-stage → 1.0.0

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 (444) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +696 -2
  3. package/dist/src/annotations/index.d.ts +11 -0
  4. package/dist/src/annotations/index.d.ts.map +1 -0
  5. package/dist/src/annotations/index.js +11 -0
  6. package/dist/src/annotations/index.js.map +1 -0
  7. package/dist/src/annotations/recorder.d.ts +57 -0
  8. package/dist/src/annotations/recorder.d.ts.map +1 -0
  9. package/dist/src/annotations/recorder.js +100 -0
  10. package/dist/src/annotations/recorder.js.map +1 -0
  11. package/dist/src/annotations/truncation.d.ts +34 -0
  12. package/dist/src/annotations/truncation.d.ts.map +1 -0
  13. package/dist/src/annotations/truncation.js +54 -0
  14. package/dist/src/annotations/truncation.js.map +1 -0
  15. package/dist/src/auth/apply.d.ts +15 -0
  16. package/dist/src/auth/apply.d.ts.map +1 -0
  17. package/dist/src/auth/apply.js +21 -0
  18. package/dist/src/auth/apply.js.map +1 -0
  19. package/dist/src/auth/setup.d.ts +56 -0
  20. package/dist/src/auth/setup.d.ts.map +1 -0
  21. package/dist/src/auth/setup.js +79 -0
  22. package/dist/src/auth/setup.js.map +1 -0
  23. package/dist/src/auth/state-file.d.ts +8 -0
  24. package/dist/src/auth/state-file.d.ts.map +1 -0
  25. package/dist/src/auth/state-file.js +13 -0
  26. package/dist/src/auth/state-file.js.map +1 -0
  27. package/dist/src/auth/token-manager.d.ts +61 -0
  28. package/dist/src/auth/token-manager.d.ts.map +1 -0
  29. package/dist/src/auth/token-manager.js +200 -0
  30. package/dist/src/auth/token-manager.js.map +1 -0
  31. package/dist/src/cli/banner.d.ts +23 -0
  32. package/dist/src/cli/banner.d.ts.map +1 -0
  33. package/dist/src/cli/banner.js +67 -0
  34. package/dist/src/cli/banner.js.map +1 -0
  35. package/dist/src/cli/check-tests.d.ts +143 -0
  36. package/dist/src/cli/check-tests.d.ts.map +1 -0
  37. package/dist/src/cli/check-tests.js +541 -0
  38. package/dist/src/cli/check-tests.js.map +1 -0
  39. package/dist/src/cli/coverage.d.ts +14 -0
  40. package/dist/src/cli/coverage.d.ts.map +1 -0
  41. package/dist/src/cli/coverage.js +97 -0
  42. package/dist/src/cli/coverage.js.map +1 -0
  43. package/dist/src/cli/doctor.d.ts +82 -0
  44. package/dist/src/cli/doctor.d.ts.map +1 -0
  45. package/dist/src/cli/doctor.js +656 -0
  46. package/dist/src/cli/doctor.js.map +1 -0
  47. package/dist/src/cli/env.d.ts +76 -0
  48. package/dist/src/cli/env.d.ts.map +1 -0
  49. package/dist/src/cli/env.js +344 -0
  50. package/dist/src/cli/env.js.map +1 -0
  51. package/dist/src/cli/failures.d.ts +29 -0
  52. package/dist/src/cli/failures.d.ts.map +1 -0
  53. package/dist/src/cli/failures.js +114 -0
  54. package/dist/src/cli/failures.js.map +1 -0
  55. package/dist/src/cli/fixture-catalog.d.ts +83 -0
  56. package/dist/src/cli/fixture-catalog.d.ts.map +1 -0
  57. package/dist/src/cli/fixture-catalog.js +773 -0
  58. package/dist/src/cli/fixture-catalog.js.map +1 -0
  59. package/dist/src/cli/fixture.d.ts +149 -0
  60. package/dist/src/cli/fixture.d.ts.map +1 -0
  61. package/dist/src/cli/fixture.js +742 -0
  62. package/dist/src/cli/fixture.js.map +1 -0
  63. package/dist/src/cli/flaky.d.ts +25 -0
  64. package/dist/src/cli/flaky.d.ts.map +1 -0
  65. package/dist/src/cli/flaky.js +96 -0
  66. package/dist/src/cli/flaky.js.map +1 -0
  67. package/dist/src/cli/generate.d.ts +37 -0
  68. package/dist/src/cli/generate.d.ts.map +1 -0
  69. package/dist/src/cli/generate.js +230 -0
  70. package/dist/src/cli/generate.js.map +1 -0
  71. package/dist/src/cli/init.d.ts +36 -0
  72. package/dist/src/cli/init.d.ts.map +1 -0
  73. package/dist/src/cli/init.js +1039 -0
  74. package/dist/src/cli/init.js.map +1 -0
  75. package/dist/src/cli/json-edit.d.ts +58 -0
  76. package/dist/src/cli/json-edit.d.ts.map +1 -0
  77. package/dist/src/cli/json-edit.js +250 -0
  78. package/dist/src/cli/json-edit.js.map +1 -0
  79. package/dist/src/cli/layout.d.ts +31 -0
  80. package/dist/src/cli/layout.d.ts.map +1 -0
  81. package/dist/src/cli/layout.js +175 -0
  82. package/dist/src/cli/layout.js.map +1 -0
  83. package/dist/src/cli/mcp-setup.d.ts +141 -0
  84. package/dist/src/cli/mcp-setup.d.ts.map +1 -0
  85. package/dist/src/cli/mcp-setup.js +548 -0
  86. package/dist/src/cli/mcp-setup.js.map +1 -0
  87. package/dist/src/cli/organize.d.ts +136 -0
  88. package/dist/src/cli/organize.d.ts.map +1 -0
  89. package/dist/src/cli/organize.js +467 -0
  90. package/dist/src/cli/organize.js.map +1 -0
  91. package/dist/src/cli/prompts.d.ts +102 -0
  92. package/dist/src/cli/prompts.d.ts.map +1 -0
  93. package/dist/src/cli/prompts.js +346 -0
  94. package/dist/src/cli/prompts.js.map +1 -0
  95. package/dist/src/cli/standards.d.ts +160 -0
  96. package/dist/src/cli/standards.d.ts.map +1 -0
  97. package/dist/src/cli/standards.js +389 -0
  98. package/dist/src/cli/standards.js.map +1 -0
  99. package/dist/src/cli/style.d.ts +28 -0
  100. package/dist/src/cli/style.d.ts.map +1 -0
  101. package/dist/src/cli/style.js +57 -0
  102. package/dist/src/cli/style.js.map +1 -0
  103. package/dist/src/config/env-loader.d.ts +33 -0
  104. package/dist/src/config/env-loader.d.ts.map +1 -0
  105. package/dist/src/config/env-loader.js +72 -0
  106. package/dist/src/config/env-loader.js.map +1 -0
  107. package/dist/src/config/index.d.ts +10 -0
  108. package/dist/src/config/index.d.ts.map +1 -0
  109. package/dist/src/config/index.js +10 -0
  110. package/dist/src/config/index.js.map +1 -0
  111. package/dist/src/config/loader.d.ts +66 -0
  112. package/dist/src/config/loader.d.ts.map +1 -0
  113. package/dist/src/config/loader.js +810 -0
  114. package/dist/src/config/loader.js.map +1 -0
  115. package/dist/src/config/schema.d.ts +596 -0
  116. package/dist/src/config/schema.d.ts.map +1 -0
  117. package/dist/src/config/schema.js +9 -0
  118. package/dist/src/config/schema.js.map +1 -0
  119. package/dist/src/containers/container-manager.d.ts +157 -0
  120. package/dist/src/containers/container-manager.d.ts.map +1 -0
  121. package/dist/src/containers/container-manager.js +627 -0
  122. package/dist/src/containers/container-manager.js.map +1 -0
  123. package/dist/src/coverage/code-coverage.d.ts +89 -0
  124. package/dist/src/coverage/code-coverage.d.ts.map +1 -0
  125. package/dist/src/coverage/code-coverage.js +395 -0
  126. package/dist/src/coverage/code-coverage.js.map +1 -0
  127. package/dist/src/coverage/inventory.d.ts +80 -0
  128. package/dist/src/coverage/inventory.d.ts.map +1 -0
  129. package/dist/src/coverage/inventory.js +417 -0
  130. package/dist/src/coverage/inventory.js.map +1 -0
  131. package/dist/src/coverage/languages.d.ts +34 -0
  132. package/dist/src/coverage/languages.d.ts.map +1 -0
  133. package/dist/src/coverage/languages.js +156 -0
  134. package/dist/src/coverage/languages.js.map +1 -0
  135. package/dist/src/coverage/report.d.ts +128 -0
  136. package/dist/src/coverage/report.d.ts.map +1 -0
  137. package/dist/src/coverage/report.js +472 -0
  138. package/dist/src/coverage/report.js.map +1 -0
  139. package/dist/src/errors.d.ts +164 -0
  140. package/dist/src/errors.d.ts.map +1 -0
  141. package/dist/src/errors.js +267 -0
  142. package/dist/src/errors.js.map +1 -0
  143. package/dist/src/fixtures/amqp.fixture.d.ts +163 -0
  144. package/dist/src/fixtures/amqp.fixture.d.ts.map +1 -0
  145. package/dist/src/fixtures/amqp.fixture.js +494 -0
  146. package/dist/src/fixtures/amqp.fixture.js.map +1 -0
  147. package/dist/src/fixtures/appium.fixture.d.ts +112 -0
  148. package/dist/src/fixtures/appium.fixture.d.ts.map +1 -0
  149. package/dist/src/fixtures/appium.fixture.js +309 -0
  150. package/dist/src/fixtures/appium.fixture.js.map +1 -0
  151. package/dist/src/fixtures/aws.d.ts +44 -0
  152. package/dist/src/fixtures/aws.d.ts.map +1 -0
  153. package/dist/src/fixtures/aws.js +93 -0
  154. package/dist/src/fixtures/aws.js.map +1 -0
  155. package/dist/src/fixtures/cassandra.fixture.d.ts +179 -0
  156. package/dist/src/fixtures/cassandra.fixture.d.ts.map +1 -0
  157. package/dist/src/fixtures/cassandra.fixture.js +489 -0
  158. package/dist/src/fixtures/cassandra.fixture.js.map +1 -0
  159. package/dist/src/fixtures/clickhouse.fixture.d.ts +171 -0
  160. package/dist/src/fixtures/clickhouse.fixture.d.ts.map +1 -0
  161. package/dist/src/fixtures/clickhouse.fixture.js +514 -0
  162. package/dist/src/fixtures/clickhouse.fixture.js.map +1 -0
  163. package/dist/src/fixtures/database.fixture.d.ts +63 -0
  164. package/dist/src/fixtures/database.fixture.d.ts.map +1 -0
  165. package/dist/src/fixtures/database.fixture.js +407 -0
  166. package/dist/src/fixtures/database.fixture.js.map +1 -0
  167. package/dist/src/fixtures/dynamodb.fixture.d.ts +243 -0
  168. package/dist/src/fixtures/dynamodb.fixture.d.ts.map +1 -0
  169. package/dist/src/fixtures/dynamodb.fixture.js +580 -0
  170. package/dist/src/fixtures/dynamodb.fixture.js.map +1 -0
  171. package/dist/src/fixtures/graphql.fixture.d.ts +107 -0
  172. package/dist/src/fixtures/graphql.fixture.d.ts.map +1 -0
  173. package/dist/src/fixtures/graphql.fixture.js +158 -0
  174. package/dist/src/fixtures/graphql.fixture.js.map +1 -0
  175. package/dist/src/fixtures/grpc.fixture.d.ts +167 -0
  176. package/dist/src/fixtures/grpc.fixture.d.ts.map +1 -0
  177. package/dist/src/fixtures/grpc.fixture.js +635 -0
  178. package/dist/src/fixtures/grpc.fixture.js.map +1 -0
  179. package/dist/src/fixtures/inbox.fixture.d.ts +136 -0
  180. package/dist/src/fixtures/inbox.fixture.d.ts.map +1 -0
  181. package/dist/src/fixtures/inbox.fixture.js +239 -0
  182. package/dist/src/fixtures/inbox.fixture.js.map +1 -0
  183. package/dist/src/fixtures/index.d.ts +174 -0
  184. package/dist/src/fixtures/index.d.ts.map +1 -0
  185. package/dist/src/fixtures/index.js +370 -0
  186. package/dist/src/fixtures/index.js.map +1 -0
  187. package/dist/src/fixtures/kafka-driver.d.ts +108 -0
  188. package/dist/src/fixtures/kafka-driver.d.ts.map +1 -0
  189. package/dist/src/fixtures/kafka-driver.js +113 -0
  190. package/dist/src/fixtures/kafka-driver.js.map +1 -0
  191. package/dist/src/fixtures/kafka.fixture.d.ts +75 -0
  192. package/dist/src/fixtures/kafka.fixture.d.ts.map +1 -0
  193. package/dist/src/fixtures/kafka.fixture.js +188 -0
  194. package/dist/src/fixtures/kafka.fixture.js.map +1 -0
  195. package/dist/src/fixtures/mock-server.fixture.d.ts +142 -0
  196. package/dist/src/fixtures/mock-server.fixture.d.ts.map +1 -0
  197. package/dist/src/fixtures/mock-server.fixture.js +271 -0
  198. package/dist/src/fixtures/mock-server.fixture.js.map +1 -0
  199. package/dist/src/fixtures/mongodb.fixture.d.ts +121 -0
  200. package/dist/src/fixtures/mongodb.fixture.d.ts.map +1 -0
  201. package/dist/src/fixtures/mongodb.fixture.js +258 -0
  202. package/dist/src/fixtures/mongodb.fixture.js.map +1 -0
  203. package/dist/src/fixtures/neo4j.fixture.d.ts +72 -0
  204. package/dist/src/fixtures/neo4j.fixture.d.ts.map +1 -0
  205. package/dist/src/fixtures/neo4j.fixture.js +202 -0
  206. package/dist/src/fixtures/neo4j.fixture.js.map +1 -0
  207. package/dist/src/fixtures/openapi.fixture.d.ts +101 -0
  208. package/dist/src/fixtures/openapi.fixture.d.ts.map +1 -0
  209. package/dist/src/fixtures/openapi.fixture.js +266 -0
  210. package/dist/src/fixtures/openapi.fixture.js.map +1 -0
  211. package/dist/src/fixtures/optional-package.d.ts +54 -0
  212. package/dist/src/fixtures/optional-package.d.ts.map +1 -0
  213. package/dist/src/fixtures/optional-package.js +79 -0
  214. package/dist/src/fixtures/optional-package.js.map +1 -0
  215. package/dist/src/fixtures/otp.fixture.d.ts +60 -0
  216. package/dist/src/fixtures/otp.fixture.d.ts.map +1 -0
  217. package/dist/src/fixtures/otp.fixture.js +101 -0
  218. package/dist/src/fixtures/otp.fixture.js.map +1 -0
  219. package/dist/src/fixtures/realtime.fixture.d.ts +205 -0
  220. package/dist/src/fixtures/realtime.fixture.d.ts.map +1 -0
  221. package/dist/src/fixtures/realtime.fixture.js +606 -0
  222. package/dist/src/fixtures/realtime.fixture.js.map +1 -0
  223. package/dist/src/fixtures/redis.fixture.d.ts +55 -0
  224. package/dist/src/fixtures/redis.fixture.d.ts.map +1 -0
  225. package/dist/src/fixtures/redis.fixture.js +209 -0
  226. package/dist/src/fixtures/redis.fixture.js.map +1 -0
  227. package/dist/src/fixtures/s3.fixture.d.ts +126 -0
  228. package/dist/src/fixtures/s3.fixture.d.ts.map +1 -0
  229. package/dist/src/fixtures/s3.fixture.js +296 -0
  230. package/dist/src/fixtures/s3.fixture.js.map +1 -0
  231. package/dist/src/fixtures/search.fixture.d.ts +178 -0
  232. package/dist/src/fixtures/search.fixture.d.ts.map +1 -0
  233. package/dist/src/fixtures/search.fixture.js +472 -0
  234. package/dist/src/fixtures/search.fixture.js.map +1 -0
  235. package/dist/src/fixtures/sqs.fixture.d.ts +172 -0
  236. package/dist/src/fixtures/sqs.fixture.d.ts.map +1 -0
  237. package/dist/src/fixtures/sqs.fixture.js +428 -0
  238. package/dist/src/fixtures/sqs.fixture.js.map +1 -0
  239. package/dist/src/index.d.ts +43 -0
  240. package/dist/src/index.d.ts.map +1 -0
  241. package/dist/src/index.js +48 -0
  242. package/dist/src/index.js.map +1 -0
  243. package/dist/src/mcp/guards.d.ts +21 -0
  244. package/dist/src/mcp/guards.d.ts.map +1 -0
  245. package/dist/src/mcp/guards.js +118 -0
  246. package/dist/src/mcp/guards.js.map +1 -0
  247. package/dist/src/mcp/project-tools.d.ts +14 -0
  248. package/dist/src/mcp/project-tools.d.ts.map +1 -0
  249. package/dist/src/mcp/project-tools.js +252 -0
  250. package/dist/src/mcp/project-tools.js.map +1 -0
  251. package/dist/src/mcp/protocol.d.ts +116 -0
  252. package/dist/src/mcp/protocol.d.ts.map +1 -0
  253. package/dist/src/mcp/protocol.js +199 -0
  254. package/dist/src/mcp/protocol.js.map +1 -0
  255. package/dist/src/mcp/server.d.ts +43 -0
  256. package/dist/src/mcp/server.d.ts.map +1 -0
  257. package/dist/src/mcp/server.js +244 -0
  258. package/dist/src/mcp/server.js.map +1 -0
  259. package/dist/src/mcp/test-tools.d.ts +65 -0
  260. package/dist/src/mcp/test-tools.d.ts.map +1 -0
  261. package/dist/src/mcp/test-tools.js +380 -0
  262. package/dist/src/mcp/test-tools.js.map +1 -0
  263. package/dist/src/mcp/tools.d.ts +49 -0
  264. package/dist/src/mcp/tools.d.ts.map +1 -0
  265. package/dist/src/mcp/tools.js +726 -0
  266. package/dist/src/mcp/tools.js.map +1 -0
  267. package/dist/src/network-error.d.ts +11 -0
  268. package/dist/src/network-error.d.ts.map +1 -0
  269. package/dist/src/network-error.js +34 -0
  270. package/dist/src/network-error.js.map +1 -0
  271. package/dist/src/openapi/contract.d.ts +98 -0
  272. package/dist/src/openapi/contract.d.ts.map +1 -0
  273. package/dist/src/openapi/contract.js +407 -0
  274. package/dist/src/openapi/contract.js.map +1 -0
  275. package/dist/src/openapi/generate.d.ts +89 -0
  276. package/dist/src/openapi/generate.d.ts.map +1 -0
  277. package/dist/src/openapi/generate.js +607 -0
  278. package/dist/src/openapi/generate.js.map +1 -0
  279. package/dist/src/openapi/load.d.ts +8 -0
  280. package/dist/src/openapi/load.d.ts.map +1 -0
  281. package/dist/src/openapi/load.js +26 -0
  282. package/dist/src/openapi/load.js.map +1 -0
  283. package/dist/src/package-manager.d.ts +58 -0
  284. package/dist/src/package-manager.d.ts.map +1 -0
  285. package/dist/src/package-manager.js +137 -0
  286. package/dist/src/package-manager.js.map +1 -0
  287. package/dist/src/reporter/history.d.ts +85 -0
  288. package/dist/src/reporter/history.d.ts.map +1 -0
  289. package/dist/src/reporter/history.js +147 -0
  290. package/dist/src/reporter/history.js.map +1 -0
  291. package/dist/src/reporter/index.d.ts +59 -0
  292. package/dist/src/reporter/index.d.ts.map +1 -0
  293. package/dist/src/reporter/index.js +201 -0
  294. package/dist/src/reporter/index.js.map +1 -0
  295. package/dist/src/reporter/last-run.d.ts +88 -0
  296. package/dist/src/reporter/last-run.d.ts.map +1 -0
  297. package/dist/src/reporter/last-run.js +133 -0
  298. package/dist/src/reporter/last-run.js.map +1 -0
  299. package/dist/src/reporter/quarantine.d.ts +62 -0
  300. package/dist/src/reporter/quarantine.d.ts.map +1 -0
  301. package/dist/src/reporter/quarantine.js +148 -0
  302. package/dist/src/reporter/quarantine.js.map +1 -0
  303. package/dist/src/secrets/index.d.ts +4 -0
  304. package/dist/src/secrets/index.d.ts.map +1 -0
  305. package/dist/src/secrets/index.js +3 -0
  306. package/dist/src/secrets/index.js.map +1 -0
  307. package/dist/src/secrets/provider.interface.d.ts +30 -0
  308. package/dist/src/secrets/provider.interface.d.ts.map +1 -0
  309. package/dist/src/secrets/provider.interface.js +2 -0
  310. package/dist/src/secrets/provider.interface.js.map +1 -0
  311. package/dist/src/secrets/providers/aws.provider.d.ts +33 -0
  312. package/dist/src/secrets/providers/aws.provider.d.ts.map +1 -0
  313. package/dist/src/secrets/providers/aws.provider.js +88 -0
  314. package/dist/src/secrets/providers/aws.provider.js.map +1 -0
  315. package/dist/src/secrets/providers/azure.provider.d.ts +26 -0
  316. package/dist/src/secrets/providers/azure.provider.d.ts.map +1 -0
  317. package/dist/src/secrets/providers/azure.provider.js +71 -0
  318. package/dist/src/secrets/providers/azure.provider.js.map +1 -0
  319. package/dist/src/secrets/providers/env-file.provider.d.ts +29 -0
  320. package/dist/src/secrets/providers/env-file.provider.d.ts.map +1 -0
  321. package/dist/src/secrets/providers/env-file.provider.js +56 -0
  322. package/dist/src/secrets/providers/env-file.provider.js.map +1 -0
  323. package/dist/src/secrets/providers/gitlab.provider.d.ts +26 -0
  324. package/dist/src/secrets/providers/gitlab.provider.d.ts.map +1 -0
  325. package/dist/src/secrets/providers/gitlab.provider.js +67 -0
  326. package/dist/src/secrets/providers/gitlab.provider.js.map +1 -0
  327. package/dist/src/secrets/providers/index.d.ts +52 -0
  328. package/dist/src/secrets/providers/index.d.ts.map +1 -0
  329. package/dist/src/secrets/providers/index.js +81 -0
  330. package/dist/src/secrets/providers/index.js.map +1 -0
  331. package/dist/src/secrets/providers/openbao.provider.d.ts +28 -0
  332. package/dist/src/secrets/providers/openbao.provider.d.ts.map +1 -0
  333. package/dist/src/secrets/providers/openbao.provider.js +29 -0
  334. package/dist/src/secrets/providers/openbao.provider.js.map +1 -0
  335. package/dist/src/secrets/providers/vault-compatible.d.ts +140 -0
  336. package/dist/src/secrets/providers/vault-compatible.d.ts.map +1 -0
  337. package/dist/src/secrets/providers/vault-compatible.js +405 -0
  338. package/dist/src/secrets/providers/vault-compatible.js.map +1 -0
  339. package/dist/src/secrets/providers/vault.provider.d.ts +27 -0
  340. package/dist/src/secrets/providers/vault.provider.d.ts.map +1 -0
  341. package/dist/src/secrets/providers/vault.provider.js +23 -0
  342. package/dist/src/secrets/providers/vault.provider.js.map +1 -0
  343. package/dist/src/secrets/secrets-manager.d.ts +67 -0
  344. package/dist/src/secrets/secrets-manager.d.ts.map +1 -0
  345. package/dist/src/secrets/secrets-manager.js +255 -0
  346. package/dist/src/secrets/secrets-manager.js.map +1 -0
  347. package/dist/src/steps/amqp.steps.d.ts +37 -0
  348. package/dist/src/steps/amqp.steps.d.ts.map +1 -0
  349. package/dist/src/steps/amqp.steps.js +86 -0
  350. package/dist/src/steps/amqp.steps.js.map +1 -0
  351. package/dist/src/steps/appium.steps.d.ts +53 -0
  352. package/dist/src/steps/appium.steps.d.ts.map +1 -0
  353. package/dist/src/steps/appium.steps.js +109 -0
  354. package/dist/src/steps/appium.steps.js.map +1 -0
  355. package/dist/src/steps/aws.steps.d.ts +47 -0
  356. package/dist/src/steps/aws.steps.d.ts.map +1 -0
  357. package/dist/src/steps/aws.steps.js +116 -0
  358. package/dist/src/steps/aws.steps.js.map +1 -0
  359. package/dist/src/steps/browser.steps.d.ts +54 -0
  360. package/dist/src/steps/browser.steps.d.ts.map +1 -0
  361. package/dist/src/steps/browser.steps.js +102 -0
  362. package/dist/src/steps/browser.steps.js.map +1 -0
  363. package/dist/src/steps/cassandra.steps.d.ts +32 -0
  364. package/dist/src/steps/cassandra.steps.d.ts.map +1 -0
  365. package/dist/src/steps/cassandra.steps.js +81 -0
  366. package/dist/src/steps/cassandra.steps.js.map +1 -0
  367. package/dist/src/steps/clickhouse.steps.d.ts +30 -0
  368. package/dist/src/steps/clickhouse.steps.d.ts.map +1 -0
  369. package/dist/src/steps/clickhouse.steps.js +73 -0
  370. package/dist/src/steps/clickhouse.steps.js.map +1 -0
  371. package/dist/src/steps/database.steps.d.ts +43 -0
  372. package/dist/src/steps/database.steps.d.ts.map +1 -0
  373. package/dist/src/steps/database.steps.js +79 -0
  374. package/dist/src/steps/database.steps.js.map +1 -0
  375. package/dist/src/steps/dynamodb.steps.d.ts +32 -0
  376. package/dist/src/steps/dynamodb.steps.d.ts.map +1 -0
  377. package/dist/src/steps/dynamodb.steps.js +89 -0
  378. package/dist/src/steps/dynamodb.steps.js.map +1 -0
  379. package/dist/src/steps/graphql.steps.d.ts +60 -0
  380. package/dist/src/steps/graphql.steps.d.ts.map +1 -0
  381. package/dist/src/steps/graphql.steps.js +76 -0
  382. package/dist/src/steps/graphql.steps.js.map +1 -0
  383. package/dist/src/steps/grpc.steps.d.ts +29 -0
  384. package/dist/src/steps/grpc.steps.d.ts.map +1 -0
  385. package/dist/src/steps/grpc.steps.js +68 -0
  386. package/dist/src/steps/grpc.steps.js.map +1 -0
  387. package/dist/src/steps/inbox.steps.d.ts +30 -0
  388. package/dist/src/steps/inbox.steps.d.ts.map +1 -0
  389. package/dist/src/steps/inbox.steps.js +72 -0
  390. package/dist/src/steps/inbox.steps.js.map +1 -0
  391. package/dist/src/steps/index.d.ts +43 -0
  392. package/dist/src/steps/index.d.ts.map +1 -0
  393. package/dist/src/steps/index.js +26 -0
  394. package/dist/src/steps/index.js.map +1 -0
  395. package/dist/src/steps/kafka.steps.d.ts +56 -0
  396. package/dist/src/steps/kafka.steps.d.ts.map +1 -0
  397. package/dist/src/steps/kafka.steps.js +61 -0
  398. package/dist/src/steps/kafka.steps.js.map +1 -0
  399. package/dist/src/steps/mock-server.steps.d.ts +21 -0
  400. package/dist/src/steps/mock-server.steps.d.ts.map +1 -0
  401. package/dist/src/steps/mock-server.steps.js +45 -0
  402. package/dist/src/steps/mock-server.steps.js.map +1 -0
  403. package/dist/src/steps/mongodb.steps.d.ts +107 -0
  404. package/dist/src/steps/mongodb.steps.d.ts.map +1 -0
  405. package/dist/src/steps/mongodb.steps.js +117 -0
  406. package/dist/src/steps/mongodb.steps.js.map +1 -0
  407. package/dist/src/steps/openapi.steps.d.ts +49 -0
  408. package/dist/src/steps/openapi.steps.d.ts.map +1 -0
  409. package/dist/src/steps/openapi.steps.js +113 -0
  410. package/dist/src/steps/openapi.steps.js.map +1 -0
  411. package/dist/src/steps/otp.steps.d.ts +43 -0
  412. package/dist/src/steps/otp.steps.d.ts.map +1 -0
  413. package/dist/src/steps/otp.steps.js +83 -0
  414. package/dist/src/steps/otp.steps.js.map +1 -0
  415. package/dist/src/steps/realtime.steps.d.ts +40 -0
  416. package/dist/src/steps/realtime.steps.d.ts.map +1 -0
  417. package/dist/src/steps/realtime.steps.js +116 -0
  418. package/dist/src/steps/realtime.steps.js.map +1 -0
  419. package/dist/src/steps/redis.steps.d.ts +54 -0
  420. package/dist/src/steps/redis.steps.d.ts.map +1 -0
  421. package/dist/src/steps/redis.steps.js +89 -0
  422. package/dist/src/steps/redis.steps.js.map +1 -0
  423. package/dist/src/steps/search.steps.d.ts +23 -0
  424. package/dist/src/steps/search.steps.d.ts.map +1 -0
  425. package/dist/src/steps/search.steps.js +54 -0
  426. package/dist/src/steps/search.steps.js.map +1 -0
  427. package/dist/src/test-data/factory.d.ts +82 -0
  428. package/dist/src/test-data/factory.d.ts.map +1 -0
  429. package/dist/src/test-data/factory.js +116 -0
  430. package/dist/src/test-data/factory.js.map +1 -0
  431. package/dist/src/test-data/index.d.ts +4 -0
  432. package/dist/src/test-data/index.d.ts.map +1 -0
  433. package/dist/src/test-data/index.js +4 -0
  434. package/dist/src/test-data/index.js.map +1 -0
  435. package/dist/src/test-data/registry.d.ts +37 -0
  436. package/dist/src/test-data/registry.d.ts.map +1 -0
  437. package/dist/src/test-data/registry.js +51 -0
  438. package/dist/src/test-data/registry.js.map +1 -0
  439. package/dist/src/test-data/tracking.d.ts +47 -0
  440. package/dist/src/test-data/tracking.d.ts.map +1 -0
  441. package/dist/src/test-data/tracking.js +166 -0
  442. package/dist/src/test-data/tracking.js.map +1 -0
  443. package/environments.json +263 -0
  444. package/package.json +299 -5
@@ -0,0 +1,635 @@
1
+ /**
2
+ * gRPC fixture.
3
+ *
4
+ * `grpcClient` calls gRPC services the way `openApiClient` calls REST ones:
5
+ *
6
+ * - Services come from `.proto` files, or from the server itself through
7
+ * server reflection (v1, falling back to v1alpha) for anything the proto
8
+ * files don't cover. With reflection, a test needs no proto files at all.
9
+ * - `call()` for unary methods, `serverStream()` (messages collected into an
10
+ * array), `clientStream()` and `bidiStream()`. Methods are named
11
+ * `package.Service/Method`.
12
+ * - Metadata per call or on every call, a deadline on every call, TLS and
13
+ * bearer tokens from config, the secrets providers or the auth helpers.
14
+ * - A failed call throws GrpcError with the status code (`code`, `codeName`),
15
+ * the server's message and its trailers. `invoke()` returns the status
16
+ * instead of throwing, for tests that expect a failure.
17
+ *
18
+ * The driver (@grpc/grpc-js and @grpc/proto-loader) is loaded on first use.
19
+ */
20
+ import { readFileSync } from 'node:fs';
21
+ import { authApplies, bearerSource } from '../auth/apply.js';
22
+ import { FixtureInitError, FixtureOperationError } from '../errors.js';
23
+ import { loadOptional } from './optional-package.js';
24
+ export const DEFAULT_GRPC_TIMEOUT = 10_000;
25
+ /** proto-loader options: field names as in the .proto, 64-bit ints and enums as strings, defaults filled in. */
26
+ export const DEFAULT_LOADER_OPTIONS = { keepCase: true, longs: String, enums: String, defaults: true, oneofs: true };
27
+ /** gRPC status codes by number. */
28
+ export const GRPC_STATUS_NAMES = [
29
+ 'OK', 'CANCELLED', 'UNKNOWN', 'INVALID_ARGUMENT', 'DEADLINE_EXCEEDED', 'NOT_FOUND', 'ALREADY_EXISTS',
30
+ 'PERMISSION_DENIED', 'RESOURCE_EXHAUSTED', 'FAILED_PRECONDITION', 'ABORTED', 'OUT_OF_RANGE',
31
+ 'UNIMPLEMENTED', 'INTERNAL', 'UNAVAILABLE', 'DATA_LOSS', 'UNAUTHENTICATED',
32
+ ];
33
+ /**
34
+ * A call that ended with a non-OK status. `code`/`codeName` are the gRPC
35
+ * status, `statusDetails` the server's message, `trailers` its trailing metadata.
36
+ */
37
+ export class GrpcError extends FixtureOperationError {
38
+ method;
39
+ code;
40
+ statusDetails;
41
+ trailers;
42
+ messages;
43
+ /** Status name, e.g. `NOT_FOUND`. */
44
+ codeName;
45
+ constructor(operation, method, code,
46
+ /** The server's status message. */
47
+ statusDetails, trailers,
48
+ /** Messages received before the failure (streaming calls). */
49
+ messages = []) {
50
+ const codeName = statusName(code);
51
+ super('grpc', operation, { method, code, codeName, details: statusDetails });
52
+ this.method = method;
53
+ this.code = code;
54
+ this.statusDetails = statusDetails;
55
+ this.trailers = trailers;
56
+ this.messages = messages;
57
+ this.codeName = codeName;
58
+ const shown = Object.fromEntries(Object.entries(trailers).filter(([k]) => !TRANSPORT_HEADERS.has(k)));
59
+ const extra = Object.keys(shown).length ? ` (trailers: ${JSON.stringify(shown)})` : '';
60
+ const received = messages.length ? ` after ${messages.length} message(s)` : '';
61
+ this.message = `gRPC ${method} failed${received}: ${code} ${codeName}${statusDetails ? `: ${statusDetails}` : ''}${extra}`;
62
+ this.name = 'GrpcError';
63
+ }
64
+ }
65
+ // ─── Pure helpers ───────────────────────────────────────────────────────────
66
+ /** HTTP/2 headers a trailers-only response repeats; left out of error messages (still in `trailers`). */
67
+ const TRANSPORT_HEADERS = new Set(['content-type', 'date', 'server', 'grpc-accept-encoding', 'grpc-encoding', 'accept-encoding']);
68
+ export function statusName(code) {
69
+ return GRPC_STATUS_NAMES[code] ?? 'UNKNOWN';
70
+ }
71
+ /** `host:port`, plus TLS when the address says `grpcs://` (or `https://`). */
72
+ export function parseAddress(address) {
73
+ const m = /^(grpcs?|https?):\/\/([^/]+)\/?$/i.exec(address.trim());
74
+ if (!m)
75
+ return { target: address.trim() };
76
+ const secure = /^(grpcs|https)$/i.test(m[1]);
77
+ return { target: m[2], tls: secure };
78
+ }
79
+ /** `pkg.Svc/Method`, `/pkg.Svc/Method` or `pkg.Svc.Method` → `{ service, method }`. */
80
+ export function parseMethod(name) {
81
+ const trimmed = name.trim().replace(/^\//, '');
82
+ const slash = trimmed.lastIndexOf('/');
83
+ const cut = slash >= 0 ? slash : trimmed.lastIndexOf('.');
84
+ if (cut <= 0 || cut === trimmed.length - 1) {
85
+ throw new Error(`"${name}" isn't a method name: use package.Service/Method`);
86
+ }
87
+ return { service: trimmed.slice(0, cut), method: trimmed.slice(cut + 1) };
88
+ }
89
+ /** A PEM value: the text itself, or the file it points to. */
90
+ export function readPem(value) {
91
+ return Buffer.from(value.includes('-----BEGIN') ? value : readFileSync(value, 'utf8'));
92
+ }
93
+ /** grpc-js Metadata → plain object; repeated keys joined, binary values base64. */
94
+ export function metadataToObject(md) {
95
+ const out = {};
96
+ if (!md)
97
+ return out;
98
+ for (const [key, values] of Object.entries(md.toJSON())) {
99
+ out[key] = values.map((v) => (Buffer.isBuffer(v) ? v.toString('base64') : v)).join(', ');
100
+ }
101
+ return out;
102
+ }
103
+ function kindOf(requestStream, responseStream) {
104
+ if (requestStream)
105
+ return responseStream ? 'bidiStream' : 'clientStream';
106
+ return responseStream ? 'serverStream' : 'unary';
107
+ }
108
+ // Minimal protobuf wire format, enough for reflection's FileDescriptorProto bytes.
109
+ function readVarint(buf, pos) {
110
+ let result = 0;
111
+ let shift = 0;
112
+ let byte;
113
+ do {
114
+ if (pos >= buf.length)
115
+ throw new Error('truncated varint');
116
+ byte = buf[pos++];
117
+ result += (byte & 0x7f) * 2 ** shift;
118
+ shift += 7;
119
+ } while (byte & 0x80);
120
+ return [result, pos];
121
+ }
122
+ function writeVarint(n) {
123
+ const bytes = [];
124
+ while (n > 0x7f) {
125
+ bytes.push((n % 128) | 0x80);
126
+ n = Math.floor(n / 128);
127
+ }
128
+ bytes.push(n);
129
+ return Buffer.from(bytes);
130
+ }
131
+ /** Name (field 1) and imports (field 3) of a serialized FileDescriptorProto. */
132
+ export function descriptorNameAndDeps(bytes) {
133
+ let pos = 0;
134
+ let name = '';
135
+ const dependencies = [];
136
+ while (pos < bytes.length) {
137
+ let key;
138
+ [key, pos] = readVarint(bytes, pos);
139
+ const field = Math.floor(key / 8);
140
+ const wire = key & 7;
141
+ if (wire === 0)
142
+ [, pos] = readVarint(bytes, pos);
143
+ else if (wire === 1)
144
+ pos += 8;
145
+ else if (wire === 5)
146
+ pos += 4;
147
+ else if (wire === 2) {
148
+ let len;
149
+ [len, pos] = readVarint(bytes, pos);
150
+ const text = () => Buffer.from(bytes.subarray(pos, pos + len)).toString('utf8');
151
+ if (field === 1)
152
+ name = text();
153
+ else if (field === 3)
154
+ dependencies.push(text());
155
+ pos += len;
156
+ }
157
+ else
158
+ throw new Error(`unsupported wire type ${wire}`);
159
+ }
160
+ return { name, dependencies };
161
+ }
162
+ /** Serialized FileDescriptorSet: field 1, repeated, one entry per file. */
163
+ export function fileDescriptorSet(files) {
164
+ return Buffer.concat(files.flatMap((f) => [Buffer.from([0x0a]), writeVarint(f.length), Buffer.from(f)]));
165
+ }
166
+ /** The reflection service (v1 and v1alpha share their messages), for proto-loader's fromJSON. */
167
+ function reflectionJson(version) {
168
+ return {
169
+ nested: { grpc: { nested: { reflection: { nested: { [version]: { nested: {
170
+ ServerReflection: { methods: { ServerReflectionInfo: { requestType: 'ServerReflectionRequest', requestStream: true, responseType: 'ServerReflectionResponse', responseStream: true } } },
171
+ ServerReflectionRequest: {
172
+ oneofs: { messageRequest: { oneof: ['fileByFilename', 'fileContainingSymbol', 'listServices'] } },
173
+ fields: { host: { type: 'string', id: 1 }, fileByFilename: { type: 'string', id: 3 }, fileContainingSymbol: { type: 'string', id: 4 }, listServices: { type: 'string', id: 7 } },
174
+ },
175
+ ServerReflectionResponse: {
176
+ fields: {
177
+ validHost: { type: 'string', id: 1 },
178
+ originalRequest: { type: 'ServerReflectionRequest', id: 2 },
179
+ fileDescriptorResponse: { type: 'FileDescriptorResponse', id: 4 },
180
+ listServicesResponse: { type: 'ListServiceResponse', id: 6 },
181
+ errorResponse: { type: 'ErrorResponse', id: 7 },
182
+ },
183
+ },
184
+ FileDescriptorResponse: { fields: { fileDescriptorProto: { rule: 'repeated', type: 'bytes', id: 1 } } },
185
+ ListServiceResponse: { fields: { service: { rule: 'repeated', type: 'ServiceResponse', id: 1 } } },
186
+ ServiceResponse: { fields: { name: { type: 'string', id: 1 } } },
187
+ ErrorResponse: { fields: { errorCode: { type: 'int32', id: 1 }, errorMessage: { type: 'string', id: 2 } } },
188
+ } } } } } } },
189
+ };
190
+ }
191
+ /** Proto files parsed once per process, by files + options. */
192
+ const protoCache = new Map();
193
+ async function loadDriver() {
194
+ const install = ['@grpc/grpc-js', '@grpc/proto-loader'];
195
+ const [grpc, loader] = await Promise.all([
196
+ loadOptional('@grpc/grpc-js', 'grpcClient', install),
197
+ loadOptional('@grpc/proto-loader', 'grpcClient', install),
198
+ ]);
199
+ // Both are CommonJS: the namespace may carry them under `default`.
200
+ return { grpc: (grpc.credentials ? grpc : grpc.default), loader: (loader.loadSync ? loader : loader.default) };
201
+ }
202
+ /** The services in a package definition: entries that aren't message or enum types. */
203
+ function servicesOf(def) {
204
+ const out = new Map();
205
+ for (const [name, value] of Object.entries(def)) {
206
+ if (!('format' in value))
207
+ out.set(name, value);
208
+ }
209
+ return out;
210
+ }
211
+ function credentialsFor(grpc, tls) {
212
+ if (!tls)
213
+ return grpc.credentials.createInsecure();
214
+ const t = tls === true ? {} : tls;
215
+ const verify = {};
216
+ if (t.insecureSkipVerify) {
217
+ verify.rejectUnauthorized = false;
218
+ verify.checkServerIdentity = () => undefined;
219
+ }
220
+ return grpc.credentials.createSsl(t.ca ? readPem(t.ca) : null, t.key ? readPem(t.key) : null, t.cert ? readPem(t.cert) : null, verify);
221
+ }
222
+ function toMetadata(grpc, ...sources) {
223
+ const md = new grpc.Metadata();
224
+ for (const source of sources) {
225
+ for (const [key, value] of Object.entries(source ?? {})) {
226
+ const k = key.toLowerCase();
227
+ md.remove(k); // a later source replaces the key
228
+ for (const v of Array.isArray(value) ? value : [value]) {
229
+ md.add(k, k.endsWith('-bin') && !Buffer.isBuffer(v) ? Buffer.from(v) : v);
230
+ }
231
+ }
232
+ }
233
+ return md;
234
+ }
235
+ /**
236
+ * Creates a gRPC client outside the fixture (e.g. in a global setup).
237
+ * Nothing connects until the first call. Call `close()` when done.
238
+ */
239
+ export function createGrpcClient(config, deps = {}) {
240
+ if (!config.address) {
241
+ throw new FixtureInitError('grpc', 'connect', {
242
+ reason: 'no gRPC address configured: set grpc.address in environments.json, PW_GRPC_ADDRESS, or the project use block',
243
+ });
244
+ }
245
+ const { target, tls: addressTls } = parseAddress(config.address);
246
+ const tls = config.tls ?? addressTls;
247
+ const defaultTimeout = config.timeout ?? DEFAULT_GRPC_TIMEOUT;
248
+ const loaderOptions = { ...DEFAULT_LOADER_OPTIONS, ...config.loaderOptions };
249
+ const reflectionEnabled = config.reflection ?? true;
250
+ const clientMetadata = { ...config.metadata };
251
+ if (config.authToken)
252
+ clientMetadata.authorization = `Bearer ${config.authToken}`;
253
+ let driver;
254
+ let channel;
255
+ const fromProtos = new Map();
256
+ const protoLoads = [];
257
+ const fromReflection = new Map();
258
+ let reflectionVersion;
259
+ const getDriver = () => (driver ??= loadDriver());
260
+ const getChannel = async () => {
261
+ const { grpc } = await getDriver();
262
+ if (!channel) {
263
+ const options = { ...config.channelOptions };
264
+ const serverName = typeof tls === 'object' ? tls.serverName : undefined;
265
+ if (serverName) {
266
+ options['grpc.ssl_target_name_override'] = serverName;
267
+ options['grpc.default_authority'] = serverName;
268
+ }
269
+ channel = new grpc.Client(target, credentialsFor(grpc, tls), options);
270
+ }
271
+ return channel;
272
+ };
273
+ const loadProtoFiles = async (files, includeDirs) => {
274
+ const { loader } = await getDriver();
275
+ const key = JSON.stringify([files, includeDirs, config.loaderOptions]);
276
+ let pending = protoCache.get(key);
277
+ if (!pending) {
278
+ pending = loader.load(files, { ...loaderOptions, includeDirs });
279
+ protoCache.set(key, pending);
280
+ pending.catch(() => protoCache.delete(key));
281
+ }
282
+ let def;
283
+ try {
284
+ def = await pending;
285
+ }
286
+ catch (error) {
287
+ throw new FixtureOperationError('grpc', 'loadProtos', { files, includeDirs, reason: error.message }, error);
288
+ }
289
+ for (const [name, svc] of servicesOf(def))
290
+ fromProtos.set(name, svc);
291
+ };
292
+ if (config.protoFiles?.length) {
293
+ const load = loadProtoFiles(config.protoFiles, config.includeDirs);
294
+ load.catch(() => undefined); // reported on the first call, not as an unhandled rejection
295
+ protoLoads.push(load);
296
+ }
297
+ /** One reflection stream: sends `first`, follows up with the imports it lacks, resolves with every response. */
298
+ const reflect = async (first, version) => {
299
+ const { grpc, loader } = await getDriver();
300
+ const def = loader.fromJSON(reflectionJson(version), { keepCase: false });
301
+ const service = def[`grpc.reflection.${version}.ServerReflection`].ServerReflectionInfo;
302
+ const ch = await getChannel();
303
+ const deadline = defaultTimeout > 0 ? Date.now() + defaultTimeout : Infinity;
304
+ return new Promise((resolve, reject) => {
305
+ const stream = ch.makeBidiStreamRequest(service.path, service.requestSerialize, service.responseDeserialize, toMetadata(grpc, clientMetadata), { deadline });
306
+ const responses = [];
307
+ const seen = new Set();
308
+ const requested = new Set();
309
+ let pending = 1;
310
+ const send = (req) => {
311
+ pending++;
312
+ stream.write(req);
313
+ };
314
+ stream.on('data', (res) => {
315
+ responses.push(res);
316
+ // A response often carries the file's imports too: note every file first, then ask for the rest.
317
+ const files = (res.fileDescriptorResponse?.fileDescriptorProto ?? []).map(descriptorNameAndDeps);
318
+ for (const { name } of files)
319
+ seen.add(name);
320
+ for (const { dependencies } of files) {
321
+ for (const dep of dependencies) {
322
+ if (!seen.has(dep) && !requested.has(dep)) {
323
+ requested.add(dep);
324
+ send({ fileByFilename: dep });
325
+ }
326
+ }
327
+ }
328
+ if (--pending === 0)
329
+ stream.end();
330
+ });
331
+ stream.on('error', reject);
332
+ stream.on('end', () => resolve(responses));
333
+ stream.write(first);
334
+ });
335
+ };
336
+ /** Runs a reflection request, on v1 first and on v1alpha when the server only has that. */
337
+ const reflectAny = async (first) => {
338
+ if (reflectionVersion)
339
+ return reflect(first, reflectionVersion);
340
+ try {
341
+ const res = await reflect(first, 'v1');
342
+ reflectionVersion = 'v1';
343
+ return res;
344
+ }
345
+ catch (error) {
346
+ if (error.code !== 12)
347
+ throw error;
348
+ const res = await reflect(first, 'v1alpha');
349
+ reflectionVersion = 'v1alpha';
350
+ return res;
351
+ }
352
+ };
353
+ const reflectService = (name) => {
354
+ let pending = fromReflection.get(name);
355
+ if (!pending) {
356
+ pending = (async () => {
357
+ const responses = await reflectAny({ fileContainingSymbol: name });
358
+ const failed = responses.find((r) => r.errorResponse && r.originalRequest?.fileContainingSymbol);
359
+ if (failed)
360
+ throw new Error(`the server doesn't know ${name} (${failed.errorResponse.errorMessage || `code ${failed.errorResponse.errorCode}`})`);
361
+ const files = new Map();
362
+ for (const r of responses) {
363
+ for (const bytes of r.fileDescriptorResponse?.fileDescriptorProto ?? [])
364
+ files.set(descriptorNameAndDeps(bytes).name, bytes);
365
+ }
366
+ const { loader } = await getDriver();
367
+ const def = loader.loadFileDescriptorSetFromBuffer(fileDescriptorSet([...files.values()]), loaderOptions);
368
+ const svc = servicesOf(def).get(name);
369
+ if (!svc)
370
+ throw new Error(`the server's descriptors for ${name} don't define it as a service`);
371
+ return svc;
372
+ })();
373
+ fromReflection.set(name, pending);
374
+ pending.catch(() => fromReflection.delete(name));
375
+ }
376
+ return pending;
377
+ };
378
+ const reflectionServices = async () => {
379
+ const responses = await reflectAny({ listServices: '' });
380
+ return responses.flatMap((r) => r.listServicesResponse?.service.map((s) => s.name) ?? []);
381
+ };
382
+ const reflectionError = (error) => new FixtureOperationError('grpc', 'reflection', { address: target, reason: reasonOf(error) }, error instanceof Error ? error : undefined);
383
+ /** The service, from the proto files or else from reflection. */
384
+ const findService = async (service) => {
385
+ await Promise.all(protoLoads);
386
+ const local = fromProtos.get(service);
387
+ if (local)
388
+ return local;
389
+ const known = [...fromProtos.keys()].sort();
390
+ if (!reflectionEnabled) {
391
+ throw new FixtureOperationError('grpc', 'call', {
392
+ service,
393
+ reason: `no proto file defines ${service} and reflection is off; services: ${known.join(', ') || 'none (set grpc.protoFiles)'}`,
394
+ });
395
+ }
396
+ try {
397
+ return await reflectService(service);
398
+ }
399
+ catch (error) {
400
+ const code = error.code;
401
+ if (typeof code === 'number') {
402
+ // The reflection call itself failed: the server is unreachable or has no reflection.
403
+ const reason = code === 12
404
+ ? `the server doesn't offer server reflection, so ${service} can't be looked up: list its .proto files in grpc.protoFiles`
405
+ : code === 14
406
+ ? `can't reach ${target}: ${reasonOf(error)}${tls || /ECONNREFUSED|ENOTFOUND|EAI_AGAIN/.test(reasonOf(error)) ? '' : '. If the server uses TLS, use a grpcs:// address or set grpc.tls'}`
407
+ : `looking up ${service} through server reflection failed: ${reasonOf(error)}`;
408
+ throw new FixtureOperationError('grpc', 'reflection', { service, address: target, reason }, error);
409
+ }
410
+ let names = known;
411
+ try {
412
+ names = [...new Set([...known, ...(await reflectionServices())])].sort();
413
+ }
414
+ catch {
415
+ // keep the proto services only
416
+ }
417
+ throw new FixtureOperationError('grpc', 'reflection', {
418
+ service,
419
+ address: target,
420
+ reason: `${reasonOf(error)}; known services: ${names.join(', ') || 'none'}`,
421
+ }, error instanceof Error ? error : undefined);
422
+ }
423
+ };
424
+ const findMethod = async (name, expected) => {
425
+ const { service, method } = parseMethod(name);
426
+ const svc = await findService(service);
427
+ const def = svc[method] ?? Object.values(svc).find((m) => m.originalName === method || m.path.endsWith(`/${method}`));
428
+ if (!def) {
429
+ const available = Object.values(svc).map((m) => m.path.split('/').pop()).join(', ');
430
+ throw new FixtureOperationError('grpc', 'call', { method: name, reason: `${service} has no method ${method}; it has ${available}` });
431
+ }
432
+ const info = methodInfo(def);
433
+ if (expected && info.kind !== expected) {
434
+ throw new FixtureOperationError('grpc', 'call', {
435
+ method: name,
436
+ reason: `${info.path} is a ${describeKind(info.kind)} method: use grpcClient.${info.kind === 'unary' ? 'call' : info.kind}()`,
437
+ });
438
+ }
439
+ return { def, info };
440
+ };
441
+ const callOptions = (o) => {
442
+ const timeout = o?.timeout ?? defaultTimeout;
443
+ return timeout > 0 ? { deadline: Date.now() + timeout } : {};
444
+ };
445
+ const callMetadata = async (o) => {
446
+ const { grpc } = await getDriver();
447
+ const md = toMetadata(grpc, clientMetadata, o?.metadata);
448
+ if (deps.bearer && md.get('authorization').length === 0)
449
+ md.set('authorization', `Bearer ${await deps.bearer()}`);
450
+ return md;
451
+ };
452
+ /** Runs the call; resolves once the status arrives. */
453
+ const run = async (name, request, o, expected) => {
454
+ const { def, info } = await findMethod(name, expected);
455
+ const ch = await getChannel();
456
+ const metadata = await callMetadata(o);
457
+ const options = callOptions(o);
458
+ const path = def.path;
459
+ const ser = def.requestSerialize;
460
+ const de = def.responseDeserialize;
461
+ const requests = Array.isArray(request) ? request : [request ?? {}];
462
+ return new Promise((resolve) => {
463
+ let headers = {};
464
+ let response;
465
+ const messages = [];
466
+ let cancelledByLimit = false;
467
+ const finish = (status) => {
468
+ const code = cancelledByLimit && status.code === 1 ? 0 : status.code;
469
+ resolve({
470
+ ok: code === 0,
471
+ code,
472
+ codeName: statusName(code),
473
+ details: code === 0 && cancelledByLimit ? '' : cleanDetails(status.details),
474
+ ...(info.responseStream ? { messages } : { response: code === 0 ? response : undefined }),
475
+ metadata: headers,
476
+ trailers: metadataToObject(status.metadata),
477
+ });
478
+ };
479
+ const onMetadata = (md) => {
480
+ headers = metadataToObject(md);
481
+ };
482
+ const ignore = () => {
483
+ // the status event carries the failure
484
+ };
485
+ if (info.kind === 'unary' || info.kind === 'clientStream') {
486
+ const callback = (_err, value) => {
487
+ response = value;
488
+ };
489
+ const call = info.kind === 'unary'
490
+ ? ch.makeUnaryRequest(path, ser, de, requests[0], metadata, options, callback)
491
+ : ch.makeClientStreamRequest(path, ser, de, metadata, options, callback);
492
+ call.on('metadata', onMetadata);
493
+ call.on('status', finish);
494
+ if (info.kind === 'clientStream') {
495
+ const writable = call;
496
+ for (const r of requests)
497
+ writable.write(r);
498
+ writable.end();
499
+ }
500
+ return;
501
+ }
502
+ const stream = info.kind === 'serverStream'
503
+ ? ch.makeServerStreamRequest(path, ser, de, requests[0], metadata, options)
504
+ : ch.makeBidiStreamRequest(path, ser, de, metadata, options);
505
+ stream.on('metadata', onMetadata);
506
+ stream.on('status', finish);
507
+ stream.on('error', ignore);
508
+ stream.on('data', (m) => {
509
+ if (o?.limit !== undefined && messages.length >= o.limit)
510
+ return;
511
+ messages.push(m);
512
+ if (o?.limit !== undefined && messages.length >= o.limit) {
513
+ cancelledByLimit = true;
514
+ stream.cancel();
515
+ }
516
+ });
517
+ if (info.kind === 'bidiStream') {
518
+ const duplex = stream;
519
+ for (const r of requests)
520
+ duplex.write(r);
521
+ duplex.end();
522
+ }
523
+ });
524
+ };
525
+ const throwIfFailed = (operation, name, result) => {
526
+ if (!result.ok)
527
+ throw new GrpcError(operation, name, result.code, result.details, result.trailers, result.messages ?? []);
528
+ return result;
529
+ };
530
+ return {
531
+ address: target,
532
+ async call(method, request, o) {
533
+ return throwIfFailed('call', method, await run(method, request, o, 'unary')).response;
534
+ },
535
+ async invoke(method, request, o) {
536
+ return run(method, request, o);
537
+ },
538
+ async serverStream(method, request, o) {
539
+ return throwIfFailed('serverStream', method, await run(method, request, o, 'serverStream')).messages;
540
+ },
541
+ async clientStream(method, requests, o) {
542
+ return throwIfFailed('clientStream', method, await run(method, requests, o, 'clientStream')).response;
543
+ },
544
+ async bidiStream(method, requests, o) {
545
+ return throwIfFailed('bidiStream', method, await run(method, requests, o, 'bidiStream')).messages;
546
+ },
547
+ async services() {
548
+ await Promise.all(protoLoads);
549
+ const names = new Set(fromProtos.keys());
550
+ if (reflectionEnabled) {
551
+ try {
552
+ for (const n of await reflectionServices())
553
+ names.add(n);
554
+ }
555
+ catch (error) {
556
+ if (names.size === 0)
557
+ throw reflectionError(error);
558
+ }
559
+ }
560
+ return [...names].sort();
561
+ },
562
+ async methods(service) {
563
+ return Object.values(await findService(service)).map(methodInfo);
564
+ },
565
+ async loadProtos(files, o) {
566
+ const load = loadProtoFiles(Array.isArray(files) ? files : [files], o?.includeDirs ?? config.includeDirs);
567
+ protoLoads.push(load.catch(() => undefined));
568
+ await load;
569
+ },
570
+ setMetadata(key, value) {
571
+ clientMetadata[key.toLowerCase()] = value;
572
+ },
573
+ setAuthToken(token) {
574
+ clientMetadata.authorization = `Bearer ${token}`;
575
+ },
576
+ close() {
577
+ channel?.close();
578
+ channel = undefined;
579
+ },
580
+ };
581
+ }
582
+ function methodInfo(def) {
583
+ const typeName = (t) => t?.type?.name ?? '?';
584
+ const path = def.path.replace(/^\//, '');
585
+ return {
586
+ path,
587
+ name: path.split('/').pop(),
588
+ requestType: typeName(def.requestType),
589
+ responseType: typeName(def.responseType),
590
+ requestStream: def.requestStream,
591
+ responseStream: def.responseStream,
592
+ kind: kindOf(def.requestStream, def.responseStream),
593
+ };
594
+ }
595
+ function describeKind(kind) {
596
+ return { unary: 'unary', serverStream: 'server-streaming', clientStream: 'client-streaming', bidiStream: 'bidirectional-streaming' }[kind];
597
+ }
598
+ function reasonOf(error) {
599
+ const e = error;
600
+ if (typeof e?.code === 'number' && e.details !== undefined)
601
+ return `${e.code} ${statusName(e.code)}: ${cleanDetails(e.details)}`;
602
+ return e?.message ?? String(error);
603
+ }
604
+ /** grpc-js status text without its empty "Resolution note:" suffix. */
605
+ function cleanDetails(details) {
606
+ return details.replace(/\.?\s*Resolution note:\s*$/, '');
607
+ }
608
+ /** The gRPC config: the project option, else ConfigLoader (environments.json, .env, PW_GRPC_*). */
609
+ export async function resolveGrpcConfig(grpc) {
610
+ if (grpc)
611
+ return grpc;
612
+ const { ConfigLoader } = await import('../config/loader.js');
613
+ try {
614
+ return new ConfigLoader().load().grpc ?? {};
615
+ }
616
+ catch {
617
+ return {};
618
+ }
619
+ }
620
+ /** Fixture definition for test.extend(). The channel is closed after the test. */
621
+ export const grpcFixture = {
622
+ grpcClient: async ({ grpc, authConfig, authRole, authTokens }, use) => {
623
+ const config = await resolveGrpcConfig(grpc);
624
+ // An explicit grpc.authToken wins over the auth helpers' token.
625
+ const bearer = !config.authToken && authApplies(authConfig, 'grpc') ? bearerSource(authTokens, authConfig, authRole) : undefined;
626
+ const client = createGrpcClient(config, { bearer });
627
+ try {
628
+ await use(client);
629
+ }
630
+ finally {
631
+ client.close();
632
+ }
633
+ },
634
+ };
635
+ //# sourceMappingURL=grpc.fixture.js.map