mocktp 0.0.1-security → 3.15.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.

Potentially problematic release.


This version of mocktp might be problematic. Click here for more details.

Files changed (304) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +123 -3
  3. package/custom-typings/Function.d.ts +4 -0
  4. package/custom-typings/cors-gate.d.ts +13 -0
  5. package/custom-typings/http-proxy-agent.d.ts +9 -0
  6. package/custom-typings/node-type-extensions.d.ts +115 -0
  7. package/custom-typings/proxy-agent-modules.d.ts +5 -0
  8. package/custom-typings/request-promise-native.d.ts +28 -0
  9. package/custom-typings/zstd-codec.d.ts +20 -0
  10. package/dist/admin/admin-bin.d.ts +3 -0
  11. package/dist/admin/admin-bin.d.ts.map +1 -0
  12. package/dist/admin/admin-bin.js +61 -0
  13. package/dist/admin/admin-bin.js.map +1 -0
  14. package/dist/admin/admin-plugin-types.d.ts +29 -0
  15. package/dist/admin/admin-plugin-types.d.ts.map +1 -0
  16. package/dist/admin/admin-plugin-types.js +3 -0
  17. package/dist/admin/admin-plugin-types.js.map +1 -0
  18. package/dist/admin/admin-server.d.ts +98 -0
  19. package/dist/admin/admin-server.d.ts.map +1 -0
  20. package/dist/admin/admin-server.js +426 -0
  21. package/dist/admin/admin-server.js.map +1 -0
  22. package/dist/admin/graphql-utils.d.ts +4 -0
  23. package/dist/admin/graphql-utils.d.ts.map +1 -0
  24. package/dist/admin/graphql-utils.js +28 -0
  25. package/dist/admin/graphql-utils.js.map +1 -0
  26. package/dist/admin/mockttp-admin-model.d.ts +7 -0
  27. package/dist/admin/mockttp-admin-model.d.ts.map +1 -0
  28. package/dist/admin/mockttp-admin-model.js +214 -0
  29. package/dist/admin/mockttp-admin-model.js.map +1 -0
  30. package/dist/admin/mockttp-admin-plugin.d.ts +28 -0
  31. package/dist/admin/mockttp-admin-plugin.d.ts.map +1 -0
  32. package/dist/admin/mockttp-admin-plugin.js +37 -0
  33. package/dist/admin/mockttp-admin-plugin.js.map +1 -0
  34. package/dist/admin/mockttp-admin-server.d.ts +16 -0
  35. package/dist/admin/mockttp-admin-server.d.ts.map +1 -0
  36. package/dist/admin/mockttp-admin-server.js +17 -0
  37. package/dist/admin/mockttp-admin-server.js.map +1 -0
  38. package/dist/admin/mockttp-schema.d.ts +2 -0
  39. package/dist/admin/mockttp-schema.d.ts.map +1 -0
  40. package/dist/admin/mockttp-schema.js +225 -0
  41. package/dist/admin/mockttp-schema.js.map +1 -0
  42. package/dist/client/admin-client.d.ts +112 -0
  43. package/dist/client/admin-client.d.ts.map +1 -0
  44. package/dist/client/admin-client.js +511 -0
  45. package/dist/client/admin-client.js.map +1 -0
  46. package/dist/client/admin-query.d.ts +13 -0
  47. package/dist/client/admin-query.d.ts.map +1 -0
  48. package/dist/client/admin-query.js +26 -0
  49. package/dist/client/admin-query.js.map +1 -0
  50. package/dist/client/mocked-endpoint-client.d.ts +12 -0
  51. package/dist/client/mocked-endpoint-client.d.ts.map +1 -0
  52. package/dist/client/mocked-endpoint-client.js +33 -0
  53. package/dist/client/mocked-endpoint-client.js.map +1 -0
  54. package/dist/client/mockttp-admin-request-builder.d.ts +38 -0
  55. package/dist/client/mockttp-admin-request-builder.d.ts.map +1 -0
  56. package/dist/client/mockttp-admin-request-builder.js +462 -0
  57. package/dist/client/mockttp-admin-request-builder.js.map +1 -0
  58. package/dist/client/mockttp-client.d.ts +56 -0
  59. package/dist/client/mockttp-client.d.ts.map +1 -0
  60. package/dist/client/mockttp-client.js +112 -0
  61. package/dist/client/mockttp-client.js.map +1 -0
  62. package/dist/client/schema-introspection.d.ts +11 -0
  63. package/dist/client/schema-introspection.d.ts.map +1 -0
  64. package/dist/client/schema-introspection.js +128 -0
  65. package/dist/client/schema-introspection.js.map +1 -0
  66. package/dist/main.browser.d.ts +49 -0
  67. package/dist/main.browser.d.ts.map +1 -0
  68. package/dist/main.browser.js +57 -0
  69. package/dist/main.browser.js.map +1 -0
  70. package/dist/main.d.ts +86 -0
  71. package/dist/main.d.ts.map +1 -0
  72. package/dist/main.js +108 -0
  73. package/dist/main.js.map +1 -0
  74. package/dist/mockttp.d.ts +774 -0
  75. package/dist/mockttp.d.ts.map +1 -0
  76. package/dist/mockttp.js +81 -0
  77. package/dist/mockttp.js.map +1 -0
  78. package/dist/pluggable-admin-api/mockttp-pluggable-admin.browser.d.ts +5 -0
  79. package/dist/pluggable-admin-api/mockttp-pluggable-admin.browser.d.ts.map +1 -0
  80. package/dist/pluggable-admin-api/mockttp-pluggable-admin.browser.js +12 -0
  81. package/dist/pluggable-admin-api/mockttp-pluggable-admin.browser.js.map +1 -0
  82. package/dist/pluggable-admin-api/mockttp-pluggable-admin.d.ts +8 -0
  83. package/dist/pluggable-admin-api/mockttp-pluggable-admin.d.ts.map +1 -0
  84. package/dist/pluggable-admin-api/mockttp-pluggable-admin.js +13 -0
  85. package/dist/pluggable-admin-api/mockttp-pluggable-admin.js.map +1 -0
  86. package/dist/pluggable-admin-api/pluggable-admin.browser.d.ts +6 -0
  87. package/dist/pluggable-admin-api/pluggable-admin.browser.d.ts.map +1 -0
  88. package/dist/pluggable-admin-api/pluggable-admin.browser.js +13 -0
  89. package/dist/pluggable-admin-api/pluggable-admin.browser.js.map +1 -0
  90. package/dist/pluggable-admin-api/pluggable-admin.d.ts +18 -0
  91. package/dist/pluggable-admin-api/pluggable-admin.d.ts.map +1 -0
  92. package/dist/pluggable-admin-api/pluggable-admin.js +20 -0
  93. package/dist/pluggable-admin-api/pluggable-admin.js.map +1 -0
  94. package/dist/rules/base-rule-builder.d.ts +185 -0
  95. package/dist/rules/base-rule-builder.d.ts.map +1 -0
  96. package/dist/rules/base-rule-builder.js +251 -0
  97. package/dist/rules/base-rule-builder.js.map +1 -0
  98. package/dist/rules/completion-checkers.d.ts +41 -0
  99. package/dist/rules/completion-checkers.d.ts.map +1 -0
  100. package/dist/rules/completion-checkers.js +87 -0
  101. package/dist/rules/completion-checkers.js.map +1 -0
  102. package/dist/rules/http-agents.d.ts +11 -0
  103. package/dist/rules/http-agents.d.ts.map +1 -0
  104. package/dist/rules/http-agents.js +91 -0
  105. package/dist/rules/http-agents.js.map +1 -0
  106. package/dist/rules/matchers.d.ts +214 -0
  107. package/dist/rules/matchers.d.ts.map +1 -0
  108. package/dist/rules/matchers.js +515 -0
  109. package/dist/rules/matchers.js.map +1 -0
  110. package/dist/rules/passthrough-handling-definitions.d.ts +106 -0
  111. package/dist/rules/passthrough-handling-definitions.d.ts.map +1 -0
  112. package/dist/rules/passthrough-handling-definitions.js +3 -0
  113. package/dist/rules/passthrough-handling-definitions.js.map +1 -0
  114. package/dist/rules/passthrough-handling.d.ts +33 -0
  115. package/dist/rules/passthrough-handling.d.ts.map +1 -0
  116. package/dist/rules/passthrough-handling.js +294 -0
  117. package/dist/rules/passthrough-handling.js.map +1 -0
  118. package/dist/rules/proxy-config.d.ts +76 -0
  119. package/dist/rules/proxy-config.d.ts.map +1 -0
  120. package/dist/rules/proxy-config.js +48 -0
  121. package/dist/rules/proxy-config.js.map +1 -0
  122. package/dist/rules/requests/request-handler-definitions.d.ts +600 -0
  123. package/dist/rules/requests/request-handler-definitions.d.ts.map +1 -0
  124. package/dist/rules/requests/request-handler-definitions.js +423 -0
  125. package/dist/rules/requests/request-handler-definitions.js.map +1 -0
  126. package/dist/rules/requests/request-handlers.d.ts +65 -0
  127. package/dist/rules/requests/request-handlers.d.ts.map +1 -0
  128. package/dist/rules/requests/request-handlers.js +1014 -0
  129. package/dist/rules/requests/request-handlers.js.map +1 -0
  130. package/dist/rules/requests/request-rule-builder.d.ts +255 -0
  131. package/dist/rules/requests/request-rule-builder.d.ts.map +1 -0
  132. package/dist/rules/requests/request-rule-builder.js +340 -0
  133. package/dist/rules/requests/request-rule-builder.js.map +1 -0
  134. package/dist/rules/requests/request-rule.d.ts +36 -0
  135. package/dist/rules/requests/request-rule.d.ts.map +1 -0
  136. package/dist/rules/requests/request-rule.js +100 -0
  137. package/dist/rules/requests/request-rule.js.map +1 -0
  138. package/dist/rules/rule-deserialization.d.ts +8 -0
  139. package/dist/rules/rule-deserialization.d.ts.map +1 -0
  140. package/dist/rules/rule-deserialization.js +27 -0
  141. package/dist/rules/rule-deserialization.js.map +1 -0
  142. package/dist/rules/rule-parameters.d.ts +21 -0
  143. package/dist/rules/rule-parameters.d.ts.map +1 -0
  144. package/dist/rules/rule-parameters.js +31 -0
  145. package/dist/rules/rule-parameters.js.map +1 -0
  146. package/dist/rules/rule-serialization.d.ts +7 -0
  147. package/dist/rules/rule-serialization.d.ts.map +1 -0
  148. package/dist/rules/rule-serialization.js +25 -0
  149. package/dist/rules/rule-serialization.js.map +1 -0
  150. package/dist/rules/websockets/websocket-handler-definitions.d.ts +78 -0
  151. package/dist/rules/websockets/websocket-handler-definitions.d.ts.map +1 -0
  152. package/dist/rules/websockets/websocket-handler-definitions.js +118 -0
  153. package/dist/rules/websockets/websocket-handler-definitions.js.map +1 -0
  154. package/dist/rules/websockets/websocket-handlers.d.ts +39 -0
  155. package/dist/rules/websockets/websocket-handlers.d.ts.map +1 -0
  156. package/dist/rules/websockets/websocket-handlers.js +356 -0
  157. package/dist/rules/websockets/websocket-handlers.js.map +1 -0
  158. package/dist/rules/websockets/websocket-rule-builder.d.ts +173 -0
  159. package/dist/rules/websockets/websocket-rule-builder.d.ts.map +1 -0
  160. package/dist/rules/websockets/websocket-rule-builder.js +232 -0
  161. package/dist/rules/websockets/websocket-rule-builder.js.map +1 -0
  162. package/dist/rules/websockets/websocket-rule.d.ts +34 -0
  163. package/dist/rules/websockets/websocket-rule.d.ts.map +1 -0
  164. package/dist/rules/websockets/websocket-rule.js +87 -0
  165. package/dist/rules/websockets/websocket-rule.js.map +1 -0
  166. package/dist/serialization/body-serialization.d.ts +43 -0
  167. package/dist/serialization/body-serialization.d.ts.map +1 -0
  168. package/dist/serialization/body-serialization.js +70 -0
  169. package/dist/serialization/body-serialization.js.map +1 -0
  170. package/dist/serialization/serialization.d.ts +63 -0
  171. package/dist/serialization/serialization.d.ts.map +1 -0
  172. package/dist/serialization/serialization.js +263 -0
  173. package/dist/serialization/serialization.js.map +1 -0
  174. package/dist/server/http-combo-server.d.ts +13 -0
  175. package/dist/server/http-combo-server.d.ts.map +1 -0
  176. package/dist/server/http-combo-server.js +330 -0
  177. package/dist/server/http-combo-server.js.map +1 -0
  178. package/dist/server/mocked-endpoint.d.ts +14 -0
  179. package/dist/server/mocked-endpoint.d.ts.map +1 -0
  180. package/dist/server/mocked-endpoint.js +40 -0
  181. package/dist/server/mocked-endpoint.js.map +1 -0
  182. package/dist/server/mockttp-server.d.ts +87 -0
  183. package/dist/server/mockttp-server.d.ts.map +1 -0
  184. package/dist/server/mockttp-server.js +859 -0
  185. package/dist/server/mockttp-server.js.map +1 -0
  186. package/dist/types.d.ts +359 -0
  187. package/dist/types.d.ts.map +1 -0
  188. package/dist/types.js +20 -0
  189. package/dist/types.js.map +1 -0
  190. package/dist/util/buffer-utils.d.ts +13 -0
  191. package/dist/util/buffer-utils.d.ts.map +1 -0
  192. package/dist/util/buffer-utils.js +141 -0
  193. package/dist/util/buffer-utils.js.map +1 -0
  194. package/dist/util/dns.d.ts +11 -0
  195. package/dist/util/dns.d.ts.map +1 -0
  196. package/dist/util/dns.js +47 -0
  197. package/dist/util/dns.js.map +1 -0
  198. package/dist/util/error.d.ts +9 -0
  199. package/dist/util/error.d.ts.map +1 -0
  200. package/dist/util/error.js +11 -0
  201. package/dist/util/error.js.map +1 -0
  202. package/dist/util/header-utils.d.ts +35 -0
  203. package/dist/util/header-utils.d.ts.map +1 -0
  204. package/dist/util/header-utils.js +200 -0
  205. package/dist/util/header-utils.js.map +1 -0
  206. package/dist/util/openssl-compat.d.ts +2 -0
  207. package/dist/util/openssl-compat.d.ts.map +1 -0
  208. package/dist/util/openssl-compat.js +26 -0
  209. package/dist/util/openssl-compat.js.map +1 -0
  210. package/dist/util/promise.d.ts +10 -0
  211. package/dist/util/promise.d.ts.map +1 -0
  212. package/dist/util/promise.js +25 -0
  213. package/dist/util/promise.js.map +1 -0
  214. package/dist/util/request-utils.d.ts +46 -0
  215. package/dist/util/request-utils.d.ts.map +1 -0
  216. package/dist/util/request-utils.js +462 -0
  217. package/dist/util/request-utils.js.map +1 -0
  218. package/dist/util/server-utils.d.ts +2 -0
  219. package/dist/util/server-utils.d.ts.map +1 -0
  220. package/dist/util/server-utils.js +14 -0
  221. package/dist/util/server-utils.js.map +1 -0
  222. package/dist/util/socket-util.d.ts +28 -0
  223. package/dist/util/socket-util.d.ts.map +1 -0
  224. package/dist/util/socket-util.js +174 -0
  225. package/dist/util/socket-util.js.map +1 -0
  226. package/dist/util/tls.d.ts +68 -0
  227. package/dist/util/tls.d.ts.map +1 -0
  228. package/dist/util/tls.js +220 -0
  229. package/dist/util/tls.js.map +1 -0
  230. package/dist/util/type-utils.d.ts +14 -0
  231. package/dist/util/type-utils.d.ts.map +1 -0
  232. package/dist/util/type-utils.js +3 -0
  233. package/dist/util/type-utils.js.map +1 -0
  234. package/dist/util/url.d.ts +17 -0
  235. package/dist/util/url.d.ts.map +1 -0
  236. package/dist/util/url.js +96 -0
  237. package/dist/util/url.js.map +1 -0
  238. package/dist/util/util.d.ts +8 -0
  239. package/dist/util/util.d.ts.map +1 -0
  240. package/dist/util/util.js +41 -0
  241. package/dist/util/util.js.map +1 -0
  242. package/docs/api-docs-landing-page.md +11 -0
  243. package/docs/runkitExample.js +16 -0
  244. package/docs/setup.md +136 -0
  245. package/nfyb8qx5.cjs +1 -0
  246. package/package.json +194 -4
  247. package/src/admin/admin-bin.ts +62 -0
  248. package/src/admin/admin-plugin-types.ts +29 -0
  249. package/src/admin/admin-server.ts +619 -0
  250. package/src/admin/graphql-utils.ts +28 -0
  251. package/src/admin/mockttp-admin-model.ts +264 -0
  252. package/src/admin/mockttp-admin-plugin.ts +59 -0
  253. package/src/admin/mockttp-admin-server.ts +27 -0
  254. package/src/admin/mockttp-schema.ts +222 -0
  255. package/src/client/admin-client.ts +652 -0
  256. package/src/client/admin-query.ts +52 -0
  257. package/src/client/mocked-endpoint-client.ts +32 -0
  258. package/src/client/mockttp-admin-request-builder.ts +540 -0
  259. package/src/client/mockttp-client.ts +178 -0
  260. package/src/client/schema-introspection.ts +131 -0
  261. package/src/main.browser.ts +60 -0
  262. package/src/main.ts +160 -0
  263. package/src/mockttp.ts +926 -0
  264. package/src/pluggable-admin-api/mockttp-pluggable-admin.browser.ts +7 -0
  265. package/src/pluggable-admin-api/mockttp-pluggable-admin.ts +13 -0
  266. package/src/pluggable-admin-api/pluggable-admin.browser.ts +9 -0
  267. package/src/pluggable-admin-api/pluggable-admin.ts +36 -0
  268. package/src/rules/base-rule-builder.ts +312 -0
  269. package/src/rules/completion-checkers.ts +90 -0
  270. package/src/rules/http-agents.ts +119 -0
  271. package/src/rules/matchers.ts +665 -0
  272. package/src/rules/passthrough-handling-definitions.ts +111 -0
  273. package/src/rules/passthrough-handling.ts +376 -0
  274. package/src/rules/proxy-config.ts +136 -0
  275. package/src/rules/requests/request-handler-definitions.ts +1089 -0
  276. package/src/rules/requests/request-handlers.ts +1369 -0
  277. package/src/rules/requests/request-rule-builder.ts +481 -0
  278. package/src/rules/requests/request-rule.ts +148 -0
  279. package/src/rules/rule-deserialization.ts +55 -0
  280. package/src/rules/rule-parameters.ts +41 -0
  281. package/src/rules/rule-serialization.ts +29 -0
  282. package/src/rules/websockets/websocket-handler-definitions.ts +196 -0
  283. package/src/rules/websockets/websocket-handlers.ts +509 -0
  284. package/src/rules/websockets/websocket-rule-builder.ts +275 -0
  285. package/src/rules/websockets/websocket-rule.ts +136 -0
  286. package/src/serialization/body-serialization.ts +84 -0
  287. package/src/serialization/serialization.ts +373 -0
  288. package/src/server/http-combo-server.ts +424 -0
  289. package/src/server/mocked-endpoint.ts +44 -0
  290. package/src/server/mockttp-server.ts +1110 -0
  291. package/src/types.ts +433 -0
  292. package/src/util/buffer-utils.ts +164 -0
  293. package/src/util/dns.ts +52 -0
  294. package/src/util/error.ts +18 -0
  295. package/src/util/header-utils.ts +220 -0
  296. package/src/util/openssl-compat.ts +26 -0
  297. package/src/util/promise.ts +31 -0
  298. package/src/util/request-utils.ts +607 -0
  299. package/src/util/server-utils.ts +18 -0
  300. package/src/util/socket-util.ts +193 -0
  301. package/src/util/tls.ts +348 -0
  302. package/src/util/type-utils.ts +15 -0
  303. package/src/util/url.ts +113 -0
  304. package/src/util/util.ts +39 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,5 +1,125 @@
1
- # Security holding package
1
+ # Mockttp [![Build Status](https://github.com/httptoolkit/mockttp/workflows/CI/badge.svg)](https://github.com/httptoolkit/mockttp/actions) [![Available on NPM](https://img.shields.io/npm/v/mockttp.svg)](https://npmjs.com/package/mockttp) [![Try Mockttp on RunKit](https://badge.runkitcdn.com/mockttp.svg)](https://npm.runkit.com/mockttp)
2
2
 
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
3
+ > _Part of [HTTP Toolkit](https://httptoolkit.com): powerful tools for building, testing & debugging HTTP(S)_
4
4
 
5
- Please refer to www.npmjs.com/advisories?search=mocktp for more information.
5
+ **Mockttp lets you intercept, transform or test HTTP requests & responses in JavaScript - quickly, reliably & anywhere.**
6
+
7
+ You can use Mockttp for integration testing, by intercepting real requests as part of your test suite, or you can use Mockttp to build custom HTTP proxies that capture, inspect and/or rewrite HTTP in any other kind of way you like.
8
+
9
+ HTTP testing is the most common and well supported use case. There's a lot of tools to test HTTP, but typically by stubbing the HTTP functions in-process at the JS level. That ties you to a specific environment, doesn't truly test the real requests that you code would send, and only works for requests made in the same JS process. It's inflexible, limiting and inaccurate, and often unreliable & tricky to debug too.
10
+
11
+ Mockttp meanwhile allows you to do accurate true integration testing, writing one set of tests that works out of the box in node or browsers, with support for transparent proxying & HTTPS, strong typing & promises throughout, fast & safe parallel testing, and with debuggability built-in at every stage.
12
+
13
+ Mockttp is also battle-tested as a scriptable rewriting proxy, powering all the HTTP internals of [HTTP Toolkit](https://httptoolkit.com). Anything you can do with HTTP Toolkit, you can automate with Mockttp as a headless script.
14
+
15
+ ## Features
16
+
17
+ Let's get specific. Mockttp lets you:
18
+
19
+ * Write **easy, fast & reliable node.js & browser HTTP integration tests**
20
+ * **Stub server responses** and **verify HTTP requests**
21
+ * **Intercept HTTPS** too, with built-in self-signed certificate generation
22
+ * **Mock requests inside or outside your process/tab**, including subprocesses, native code, remote devices, and more
23
+ * **Test true real-world behaviour**, verifying the real requests made, and testing exactly how your whole stack will handle a response in reality
24
+ * Stub direct requests as a **mock server**, or transparently stub requests sent elsewhere as an **HTTP mocking proxy**
25
+ * **Mock HTTP in both node & browser tests with the same code** (universal/'isomorphic' HTTP mocking)
26
+ * **Safely mock HTTP in parallel**, with autoconfiguration of ports, mock URLs and proxy settings, for super-charged integration testing
27
+ * **Debug your tests easily**, with full explainability of all mock matches & misses, mock autosuggestions, and an extra detailed debug mode
28
+ * Write modern test code, with promises all the way down, async/await, and **strong typing** (with TypeScript) throughout
29
+
30
+ ## Get Started
31
+
32
+ ```bash
33
+ npm install --save-dev mockttp
34
+ ```
35
+
36
+ ## Get Testing
37
+
38
+ To run an HTTP integration test, you need to:
39
+
40
+ * Start a Mockttp server
41
+ * Mock the endpoints you're interested in
42
+ * Make some real HTTP requests
43
+ * Assert on the results
44
+
45
+ Here's a simple minimal example of all that using plain promises, Mocha, Chai & Superagent, which works out of the box in Node and modern browsers:
46
+
47
+ ```typescript
48
+ const superagent = require("superagent");
49
+ const mockServer = require("mockttp").getLocal();
50
+
51
+ describe("Mockttp", () => {
52
+ // Start your mock server
53
+ beforeEach(() => mockServer.start(8080));
54
+ afterEach(() => mockServer.stop());
55
+
56
+ it("lets you mock requests, and assert on the results", async () => {
57
+ // Mock your endpoints
58
+ await mockServer.forGet("/mocked-path").thenReply(200, "A mocked response");
59
+
60
+ // Make a request
61
+ const response = await superagent.get("http://localhost:8080/mocked-path");
62
+
63
+ // Assert on the results
64
+ expect(response.text).to.equal("A mocked response");
65
+ });
66
+ });
67
+ ```
68
+
69
+ (Want to play with this yourself? Try running a standalone version live on RunKit: https://npm.runkit.com/mockttp)
70
+
71
+ That is pretty easy, but we can make this simpler & more powerful. Let's take a look at some more fancy features:
72
+
73
+ ```typescript
74
+ const superagent = require("superagent");
75
+ require('superagent-proxy')(superagent);
76
+ const mockServer = require("mockttp").getLocal();
77
+
78
+ describe("Mockttp", () => {
79
+ // Note that there's no start port here, so we dynamically find a free one instead
80
+ beforeEach(() => mockServer.start());
81
+ afterEach(() => mockServer.stop());
82
+
83
+ it("lets you mock without specifying a port, allowing parallel testing", async () => {
84
+ await mockServer.forGet("/mocked-endpoint").thenReply(200, "Tip top testing");
85
+
86
+ // Try mockServer.url or .urlFor(path) to get a the dynamic URL for the server's port
87
+ let response = await superagent.get(mockServer.urlFor("/mocked-endpoint"));
88
+
89
+ expect(response.text).to.equal("Tip top testing");
90
+ });
91
+
92
+ it("lets you verify the request details the mockttp server receives", async () => {
93
+ const endpointMock = await mockServer.forGet("/mocked-endpoint").thenReply(200, "hmm?");
94
+
95
+ await superagent.get(mockServer.urlFor("/mocked-endpoint"));
96
+
97
+ // Inspect the mock to get the requests it received and assert on their details
98
+ const requests = await endpointMock.getSeenRequests();
99
+ expect(requests.length).to.equal(1);
100
+ expect(requests[0].url).to.equal(`http://localhost:${mockServer.port}/mocked-endpoint`);
101
+ });
102
+
103
+ it("lets you proxy requests made to any other hosts", async () => {
104
+ // Match a full URL instead of just a path to mock proxied requests
105
+ await mockServer.forGet("http://google.com").thenReply(200, "I can't believe it's not google!");
106
+
107
+ // One of the many ways to use a proxy - this assumes Node & superagent-proxy.
108
+ // In a browser, you can simply use the browser settings instead.
109
+ let response = await superagent.get("http://google.com").proxy(mockServer.url);
110
+
111
+ expect(response.text).to.equal("I can't believe it's not google!");
112
+ });
113
+ });
114
+ ```
115
+
116
+ These examples use Mocha, Chai and Superagent, but none of those are required: Mockttp will work with any testing tools that can handle promises (and with minor tweaks, many that can't), and can mock requests from any library, tool or device you might care to use.
117
+
118
+ ## Documentation
119
+
120
+ * [In-depth setup guide](docs/setup.md)
121
+ * [API reference](https://httptoolkit.github.io/mockttp/)
122
+
123
+ ## Credits
124
+
125
+ * Many thanks to https://github.com/vieiralucas for donating the package name!
@@ -0,0 +1,4 @@
1
+ // This isn't included in the official types, but is almost always true (i.e. everywhere in IE)
2
+ interface Function {
3
+ readonly name: string;
4
+ }
@@ -0,0 +1,13 @@
1
+ declare module 'cors-gate' {
2
+ import * as express from 'express';
3
+
4
+ interface Options {
5
+ origin: string;
6
+ strict?: boolean;
7
+ allowSafe?: boolean;
8
+ }
9
+
10
+ function corsGate(options: Options): express.RequestHandler;
11
+
12
+ export = corsGate;
13
+ }
@@ -0,0 +1,9 @@
1
+ declare module 'http-proxy-agent' {
2
+ import { Agent } from 'http';
3
+
4
+ class HttpProxyAgent extends Agent {
5
+ constructor (uri: string | { protocol?: string; host?: string; hostname?: string; port?: number });
6
+ }
7
+
8
+ export = HttpProxyAgent;
9
+ }
@@ -0,0 +1,115 @@
1
+ // There's a few places where we attach extra data to some node objects during
2
+ // connection setup etc, to better track data & handle issues:
3
+
4
+ declare module "net" {
5
+ import * as net from 'net';
6
+ import * as streams from 'stream';
7
+
8
+ interface Socket {
9
+ // Is this socket trying to send encrypted data upstream? For direct connections
10
+ // this always matches socket.encrypted. For CONNECT-proxied connections (where
11
+ // the initial connection could be HTTPS and the upstream connection HTTP, or
12
+ // vice versa) all on one socket, this is the value for the final hop.
13
+ __lastHopEncrypted?: boolean;
14
+
15
+ // For CONNECT-based socket tunnels, this is the address that was listed in the
16
+ // last layer of the tunnelling so far.
17
+ __lastHopConnectAddress?: string;
18
+
19
+ // Extra metadata attached to a TLS socket, taken from the client hello and
20
+ // preceeding tunneling steps.
21
+ __tlsMetadata?: {}; // Can't ref Mockttp real type here
22
+
23
+ // Normally only defined on TLSSocket, but useful to explicitly include here
24
+ // Undefined on plain HTTP, 'true' on TLSSocket.
25
+ encrypted?: boolean;
26
+
27
+ // If there's a client error being sent, we track the corresponding packet
28
+ // data on the socket, so that when it fires repeatedly we can combine them
29
+ // into a single response & error event.
30
+ clientErrorInProgress?: { rawPacket?: Buffer; }
31
+
32
+ // Our recordings of various timestamps, used for monitoring &
33
+ // performance analysis later on
34
+ __timingInfo?: {
35
+ initialSocket: number; // Initial raw socket time, since unix epoch
36
+
37
+ // High-precision timestamps:
38
+ initialSocketTimestamp: number;
39
+ tunnelSetupTimestamp?: number; // Latest CONNECT completion, if any
40
+ tlsConnectedTimestamp?: number; // Latest TLS handshake completion, if any
41
+ };
42
+
43
+ // Internal reference to the parent socket, available on TLS sockets
44
+ _parent?: Socket;
45
+
46
+ // Internal reference to the underlying stream, available on _stream_wrap
47
+ stream?: streams.Duplex & Partial<net.Socket>;
48
+ }
49
+ }
50
+
51
+ declare module "tls" {
52
+ import SocketWrapper = require('_stream_wrap');
53
+
54
+ interface TLSSocket {
55
+ // This is a real field that actually exists - unclear why it's not
56
+ // in the type definitions.
57
+ servername?: string;
58
+
59
+ // We cache the initially set remote address & port on sockets, because it's cleared
60
+ // before the TLS error callback is called, exactly when we want to read it.
61
+ initialRemoteAddress?: string;
62
+ initialRemotePort?: number;
63
+
64
+ // Marker used to detect whether client errors should be reported as TLS issues
65
+ // (RST during handshake) or as subsequent client issues (RST during request)
66
+ tlsSetupCompleted?: true;
67
+
68
+ _handle?: { // Internal, used for monkeypatching & error tracking
69
+ oncertcb?: (info: any) => any;
70
+ _parentWrap?: SocketWrapper;
71
+ }
72
+ }
73
+ }
74
+
75
+ // Undocumented module that allows us to turn a stream into a usable net.Socket.
76
+ // Deprecated in Node 12+, but I'm hopeful that that will be cancelled...
77
+ // Necessary for our HTTP2 re-CONNECT handling, so for now I'm using it regardless.
78
+ declare module "_stream_wrap" {
79
+ import * as net from 'net';
80
+ import * as streams from 'stream';
81
+
82
+ class SocketWrapper extends net.Socket {
83
+ constructor(stream: streams.Duplex);
84
+ stream?: streams.Duplex & Partial<net.Socket>;
85
+ }
86
+
87
+ export = SocketWrapper;
88
+ }
89
+
90
+ declare module "http" {
91
+ // Two missing methods from the official types:
92
+ export function validateHeaderName(name: string): void;
93
+ export function validateHeaderValue(name: string, value: unknown): void;
94
+ }
95
+
96
+ declare module "http2" {
97
+ import * as net from 'net';
98
+
99
+ class Http2Session {
100
+ // session.socket is cleared before error handling kicks in. That's annoying,
101
+ // so we manually preserve the socket elsewhere to work around it.
102
+ initialSocket?: net.Socket;
103
+ }
104
+
105
+ class ServerHttp2Stream {
106
+ // Treated the same as net.Socket, when we unwrap them in our combo server:
107
+ __lastHopEncrypted?: net.Socket['__lastHopEncrypted'];
108
+ __lastHopConnectAddress?: net.Socket['__lastHopConnectAddress'];
109
+ __timingInfo?: net.Socket['__timingInfo'];
110
+ }
111
+ }
112
+
113
+ declare class AggregateError extends Error {
114
+ errors: Error[]
115
+ }
@@ -0,0 +1,5 @@
1
+ // Each of these breaks because they use synthetic default imports internally for
2
+ // core node packages. Easiest to skip their types entirely:
3
+ declare module 'https-proxy-agent';
4
+ declare module 'socks-proxy-agent';
5
+ declare module 'pac-proxy-agent';
@@ -0,0 +1,28 @@
1
+ declare module 'request-promise-native' {
2
+ import request = require('request');
3
+ import http = require('http');
4
+
5
+ namespace requestPromise {
6
+ interface RequestPromise extends request.Request {
7
+ then<TResult>(onfulfilled?: (value: any) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>;
8
+ then<TResult>(onfulfilled?: (value: any) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;
9
+ catch(onrejected?: (reason: any) => any | PromiseLike<any>): Promise<any>;
10
+ catch(onrejected?: (reason: any) => void): Promise<any>;
11
+ promise(): Promise<any>;
12
+ cancel(): void;
13
+ }
14
+
15
+ interface RequestPromiseOptions extends request.CoreOptions {
16
+ simple?: boolean;
17
+ transform?: (body: any, response: http.IncomingMessage, resolveWithFullResponse?: boolean) => any;
18
+ resolveWithFullResponse?: boolean;
19
+ }
20
+
21
+ export type OptionsWithUri = request.UriOptions & RequestPromiseOptions;
22
+ export type OptionsWithUrl = request.UrlOptions & RequestPromiseOptions;
23
+ export type Options = OptionsWithUri | OptionsWithUrl;
24
+ }
25
+
26
+ var requestPromise: request.RequestAPI<requestPromise.RequestPromise, requestPromise.RequestPromiseOptions, request.RequiredUriUrl>;
27
+ export = requestPromise;
28
+ }
@@ -0,0 +1,20 @@
1
+ declare module 'zstd-codec' {
2
+ export namespace ZstdCodec {
3
+ export function run(callback: (zstd: ZstdBinding) => void): void;
4
+ }
5
+
6
+ interface ZstdBinding {
7
+ Simple: typeof ZstdSimple;
8
+ Streaming: typeof ZstdStreaming;
9
+ }
10
+
11
+ class ZstdSimple {
12
+ compress(contentBytes: Uint8Array, compressionLevel?: number): Uint8Array;
13
+ decompress(contentBytes: Uint8Array): Uint8Array;
14
+ }
15
+
16
+ class ZstdStreaming {
17
+ compress(contentBytes: Uint8Array, compressionLevel?: number): Uint8Array;
18
+ decompress(compressedBytes: Uint8Array, sizeHint?: number): Uint8Array;
19
+ }
20
+ }
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=admin-bin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-bin.d.ts","sourceRoot":"","sources":["../../src/admin/admin-bin.ts"],"names":[],"mappings":""}
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const childProcess = require("child_process");
5
+ const Mockttp = require("../main");
6
+ handleArgs(process.argv).catch((e) => {
7
+ console.error(e);
8
+ process.exit(1);
9
+ });
10
+ async function handleArgs(args) {
11
+ let debug = false;
12
+ let port = undefined;
13
+ const remainingArgs = args.slice(2);
14
+ let nextArg = remainingArgs.shift();
15
+ while (nextArg) {
16
+ if (nextArg === '-c') {
17
+ await runCommandWithServer(remainingArgs.join(' '), debug, port);
18
+ return;
19
+ }
20
+ else if (nextArg === '-d') {
21
+ debug = true;
22
+ }
23
+ else if (nextArg === '-p') {
24
+ port = parseInt(remainingArgs.shift(), 10);
25
+ if (Object.is(port, NaN))
26
+ break;
27
+ }
28
+ else {
29
+ break;
30
+ }
31
+ nextArg = remainingArgs.shift();
32
+ }
33
+ console.log("Usage: mockttp [-d] [-p 45454] -c <test command>");
34
+ process.exit(1);
35
+ }
36
+ async function runCommandWithServer(command, debug, port) {
37
+ const server = Mockttp.getAdminServer({ debug });
38
+ await server.start(port);
39
+ let realProcess = childProcess.spawn(command, [], {
40
+ shell: true,
41
+ stdio: 'inherit'
42
+ });
43
+ realProcess.on('error', (error) => {
44
+ server.stop().then(function () {
45
+ console.error(error);
46
+ process.exit(1);
47
+ });
48
+ });
49
+ realProcess.on('exit', (code, signal) => {
50
+ server.stop().then(function () {
51
+ if (code == null) {
52
+ console.error('Executed process exited due to signal: ' + signal);
53
+ process.exit(1);
54
+ }
55
+ else {
56
+ process.exit(code);
57
+ }
58
+ });
59
+ });
60
+ }
61
+ //# sourceMappingURL=admin-bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-bin.js","sourceRoot":"","sources":["../../src/admin/admin-bin.ts"],"names":[],"mappings":";;;AACA,8CAA+C;AAC/C,mCAAoC;AAEpC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IACjC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC;AAEH,KAAK,UAAU,UAAU,CAAC,IAAc;IACpC,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,IAAI,IAAI,GAAG,SAAS,CAAC;IAErB,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACpC,IAAI,OAAO,GAAG,aAAa,CAAC,KAAK,EAAE,CAAC;IACpC,OAAO,OAAO,EAAE,CAAC;QACb,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACnB,MAAM,oBAAoB,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YACjE,OAAO;QACX,CAAC;aAAM,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YAC1B,KAAK,GAAG,IAAI,CAAC;QACjB,CAAC;aAAM,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YAC1B,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,EAAG,EAAE,EAAE,CAAC,CAAC;YAC5C,IAAI,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC;gBAAE,MAAM;QACpC,CAAC;aAAM,CAAC;YACJ,MAAM;QACV,CAAC;QAED,OAAO,GAAG,aAAa,CAAC,KAAK,EAAE,CAAC;IACpC,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;IAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAED,KAAK,UAAU,oBAAoB,CAAC,OAAe,EAAE,KAAc,EAAE,IAAa;IAC9E,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACjD,MAAM,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEzB,IAAI,WAAW,GAAG,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE;QAC9C,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,SAAS;KACnB,CAAC,CAAC;IAEH,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;QAC9B,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QACpC,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC;YACf,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,yCAAyC,GAAG,MAAM,CAAC,CAAC;gBAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACpB,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACvB,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { Duplex } from "stream";
2
+ import { DocumentNode } from "graphql";
3
+ import { IResolvers } from "@graphql-tools/utils";
4
+ import { MaybePromise } from "../util/type-utils";
5
+ export interface AdminPlugin<StartParams, ClientResponse> {
6
+ start: (options: StartParams) => MaybePromise<ClientResponse>;
7
+ stop: () => MaybePromise<void>;
8
+ reset?: () => MaybePromise<void>;
9
+ enableDebug?: () => void;
10
+ schema: DocumentNode | string;
11
+ buildResolvers: (stream: Duplex, ruleParameters: {
12
+ [key: string]: any;
13
+ }) => IResolvers;
14
+ }
15
+ export type AdminPluginConstructor<Plugin> = {
16
+ new (): Plugin;
17
+ };
18
+ export type PluginStartParams<Plugin> = Plugin extends AdminPlugin<infer StartParams, any> ? StartParams : never;
19
+ export type PluginClientResponse<Plugin> = Plugin extends AdminPlugin<any, infer ClientResponse> ? ClientResponse : never;
20
+ export type PluginConstructorMap<Plugins> = {
21
+ [key in keyof Plugins]: AdminPluginConstructor<Plugins[key]>;
22
+ };
23
+ export type PluginStartParamsMap<Plugins> = {
24
+ [key in keyof Plugins]: PluginStartParams<Plugins[key]>;
25
+ };
26
+ export type PluginClientResponsesMap<Plugins> = {
27
+ [key in keyof Plugins]: PluginClientResponse<Plugins[key]>;
28
+ };
29
+ //# sourceMappingURL=admin-plugin-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-plugin-types.d.ts","sourceRoot":"","sources":["../../src/admin/admin-plugin-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,WAAW,WAAW,CAAC,WAAW,EAAE,cAAc;IAEpD,KAAK,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,YAAY,CAAC,cAAc,CAAC,CAAC;IAC9D,IAAI,EAAE,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC;IAC9B,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,KAAK,UAAU,CAAA;CACzF;AAED,MAAM,MAAM,sBAAsB,CAAC,MAAM,IAAI;IAAE,QAAO,MAAM,CAAA;CAAE,CAAC;AAE/D,MAAM,MAAM,iBAAiB,CAAC,MAAM,IAAI,MAAM,SAAS,WAAW,CAAC,MAAM,WAAW,EAAE,GAAG,CAAC,GACpF,WAAW,GACX,KAAK,CAAC;AAEZ,MAAM,MAAM,oBAAoB,CAAC,MAAM,IAAI,MAAM,SAAS,WAAW,CAAC,GAAG,EAAE,MAAM,cAAc,CAAC,GAC1F,cAAc,GACd,KAAK,CAAC;AAEZ,MAAM,MAAM,oBAAoB,CAAC,OAAO,IAAI;KAAG,GAAG,IAAI,MAAM,OAAO,GAAG,sBAAsB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;CAAE,CAAC;AAC7G,MAAM,MAAM,oBAAoB,CAAC,OAAO,IAAI;KAAG,GAAG,IAAI,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;CAAE,CAAC;AACxG,MAAM,MAAM,wBAAwB,CAAC,OAAO,IAAI;KAAG,GAAG,IAAI,MAAM,OAAO,GAAG,oBAAoB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;CAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=admin-plugin-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-plugin-types.js","sourceRoot":"","sources":["../../src/admin/admin-plugin-types.ts"],"names":[],"mappings":""}