@detectant-api/sdk 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (407) hide show
  1. package/README.md +111 -0
  2. package/dist/cjs/BaseClient.d.ts +54 -0
  3. package/dist/cjs/BaseClient.js +77 -0
  4. package/dist/cjs/Client.d.ts +86 -0
  5. package/dist/cjs/Client.js +255 -0
  6. package/dist/cjs/api/client/index.d.ts +1 -0
  7. package/dist/cjs/api/client/index.js +17 -0
  8. package/dist/cjs/api/client/requests/CreateScanBatchRequest.d.ts +5 -0
  9. package/dist/cjs/api/client/requests/CreateScanBatchRequest.js +3 -0
  10. package/dist/cjs/api/client/requests/CreateScanRequest.d.ts +5 -0
  11. package/dist/cjs/api/client/requests/CreateScanRequest.js +3 -0
  12. package/dist/cjs/api/client/requests/index.d.ts +2 -0
  13. package/dist/cjs/api/client/requests/index.js +2 -0
  14. package/dist/cjs/api/errors/BadRequestError.d.ts +7 -0
  15. package/dist/cjs/api/errors/BadRequestError.js +54 -0
  16. package/dist/cjs/api/errors/ContentTooLargeError.d.ts +7 -0
  17. package/dist/cjs/api/errors/ContentTooLargeError.js +54 -0
  18. package/dist/cjs/api/errors/ForbiddenError.d.ts +7 -0
  19. package/dist/cjs/api/errors/ForbiddenError.js +54 -0
  20. package/dist/cjs/api/errors/InternalServerError.d.ts +7 -0
  21. package/dist/cjs/api/errors/InternalServerError.js +54 -0
  22. package/dist/cjs/api/errors/NotFoundError.d.ts +7 -0
  23. package/dist/cjs/api/errors/NotFoundError.js +54 -0
  24. package/dist/cjs/api/errors/ServiceUnavailableError.d.ts +5 -0
  25. package/dist/cjs/api/errors/ServiceUnavailableError.js +54 -0
  26. package/dist/cjs/api/errors/TooManyRequestsError.d.ts +7 -0
  27. package/dist/cjs/api/errors/TooManyRequestsError.js +54 -0
  28. package/dist/cjs/api/errors/UnauthorizedError.d.ts +7 -0
  29. package/dist/cjs/api/errors/UnauthorizedError.js +54 -0
  30. package/dist/cjs/api/errors/index.d.ts +8 -0
  31. package/dist/cjs/api/errors/index.js +24 -0
  32. package/dist/cjs/api/index.d.ts +4 -0
  33. package/dist/cjs/api/index.js +20 -0
  34. package/dist/cjs/api/resources/health/client/Client.d.ts +43 -0
  35. package/dist/cjs/api/resources/health/client/Client.js +152 -0
  36. package/dist/cjs/api/resources/health/client/index.d.ts +1 -0
  37. package/dist/cjs/api/resources/health/client/index.js +2 -0
  38. package/dist/cjs/api/resources/health/exports.d.ts +2 -0
  39. package/dist/cjs/api/resources/health/exports.js +21 -0
  40. package/dist/cjs/api/resources/health/index.d.ts +1 -0
  41. package/dist/cjs/api/resources/health/index.js +17 -0
  42. package/dist/cjs/api/resources/index.d.ts +3 -0
  43. package/dist/cjs/api/resources/index.js +42 -0
  44. package/dist/cjs/api/resources/scans/client/Client.d.ts +54 -0
  45. package/dist/cjs/api/resources/scans/client/Client.js +196 -0
  46. package/dist/cjs/api/resources/scans/client/index.d.ts +1 -0
  47. package/dist/cjs/api/resources/scans/client/index.js +17 -0
  48. package/dist/cjs/api/resources/scans/client/requests/GetScanRequest.d.ts +10 -0
  49. package/dist/cjs/api/resources/scans/client/requests/GetScanRequest.js +3 -0
  50. package/dist/cjs/api/resources/scans/client/requests/ListScansRequest.d.ts +18 -0
  51. package/dist/cjs/api/resources/scans/client/requests/ListScansRequest.js +3 -0
  52. package/dist/cjs/api/resources/scans/client/requests/index.d.ts +2 -0
  53. package/dist/cjs/api/resources/scans/client/requests/index.js +2 -0
  54. package/dist/cjs/api/resources/scans/exports.d.ts +2 -0
  55. package/dist/cjs/api/resources/scans/exports.js +21 -0
  56. package/dist/cjs/api/resources/scans/index.d.ts +1 -0
  57. package/dist/cjs/api/resources/scans/index.js +17 -0
  58. package/dist/cjs/api/types/ApiError.d.ts +8 -0
  59. package/dist/cjs/api/types/ApiError.js +3 -0
  60. package/dist/cjs/api/types/ErrorResponse.d.ts +4 -0
  61. package/dist/cjs/api/types/ErrorResponse.js +3 -0
  62. package/dist/cjs/api/types/HealthResponse.d.ts +10 -0
  63. package/dist/cjs/api/types/HealthResponse.js +11 -0
  64. package/dist/cjs/api/types/Scan.d.ts +32 -0
  65. package/dist/cjs/api/types/Scan.js +17 -0
  66. package/dist/cjs/api/types/ScanBatchResponse.d.ts +5 -0
  67. package/dist/cjs/api/types/ScanBatchResponse.js +3 -0
  68. package/dist/cjs/api/types/ScanBatchResult.d.ts +13 -0
  69. package/dist/cjs/api/types/ScanBatchResult.js +3 -0
  70. package/dist/cjs/api/types/ScanFailure.d.ts +11 -0
  71. package/dist/cjs/api/types/ScanFailure.js +11 -0
  72. package/dist/cjs/api/types/ScanList.d.ts +7 -0
  73. package/dist/cjs/api/types/ScanList.js +3 -0
  74. package/dist/cjs/api/types/TypeAnalysis.d.ts +26 -0
  75. package/dist/cjs/api/types/TypeAnalysis.js +20 -0
  76. package/dist/cjs/api/types/TypeAnalysisReason.d.ts +13 -0
  77. package/dist/cjs/api/types/TypeAnalysisReason.js +12 -0
  78. package/dist/cjs/api/types/TypeDeclaration.d.ts +6 -0
  79. package/dist/cjs/api/types/TypeDeclaration.js +3 -0
  80. package/dist/cjs/api/types/TypeIdentification.d.ts +6 -0
  81. package/dist/cjs/api/types/TypeIdentification.js +3 -0
  82. package/dist/cjs/api/types/index.d.ts +12 -0
  83. package/dist/cjs/api/types/index.js +28 -0
  84. package/dist/cjs/auth/HeaderAuthProvider.d.ts +20 -0
  85. package/dist/cjs/auth/HeaderAuthProvider.js +80 -0
  86. package/dist/cjs/auth/index.d.ts +1 -0
  87. package/dist/cjs/auth/index.js +5 -0
  88. package/dist/cjs/core/auth/AuthProvider.d.ts +8 -0
  89. package/dist/cjs/core/auth/AuthProvider.js +9 -0
  90. package/dist/cjs/core/auth/AuthRequest.d.ts +9 -0
  91. package/dist/cjs/core/auth/AuthRequest.js +2 -0
  92. package/dist/cjs/core/auth/BasicAuth.d.ts +8 -0
  93. package/dist/cjs/core/auth/BasicAuth.js +33 -0
  94. package/dist/cjs/core/auth/BearerToken.d.ts +7 -0
  95. package/dist/cjs/core/auth/BearerToken.js +16 -0
  96. package/dist/cjs/core/auth/NoOpAuthProvider.d.ts +5 -0
  97. package/dist/cjs/core/auth/NoOpAuthProvider.js +9 -0
  98. package/dist/cjs/core/auth/index.d.ts +5 -0
  99. package/dist/cjs/core/auth/index.js +11 -0
  100. package/dist/cjs/core/base64.d.ts +2 -0
  101. package/dist/cjs/core/base64.js +26 -0
  102. package/dist/cjs/core/exports.d.ts +2 -0
  103. package/dist/cjs/core/exports.js +18 -0
  104. package/dist/cjs/core/fetcher/APIResponse.d.ts +20 -0
  105. package/dist/cjs/core/fetcher/APIResponse.js +2 -0
  106. package/dist/cjs/core/fetcher/BinaryResponse.d.ts +19 -0
  107. package/dist/cjs/core/fetcher/BinaryResponse.js +17 -0
  108. package/dist/cjs/core/fetcher/EndpointMetadata.d.ts +13 -0
  109. package/dist/cjs/core/fetcher/EndpointMetadata.js +2 -0
  110. package/dist/cjs/core/fetcher/EndpointSupplier.d.ts +12 -0
  111. package/dist/cjs/core/fetcher/EndpointSupplier.js +22 -0
  112. package/dist/cjs/core/fetcher/Fetcher.d.ts +56 -0
  113. package/dist/cjs/core/fetcher/Fetcher.js +244 -0
  114. package/dist/cjs/core/fetcher/Headers.d.ts +2 -0
  115. package/dist/cjs/core/fetcher/Headers.js +84 -0
  116. package/dist/cjs/core/fetcher/HttpResponsePromise.d.ts +58 -0
  117. package/dist/cjs/core/fetcher/HttpResponsePromise.js +103 -0
  118. package/dist/cjs/core/fetcher/RawResponse.d.ts +29 -0
  119. package/dist/cjs/core/fetcher/RawResponse.js +44 -0
  120. package/dist/cjs/core/fetcher/Supplier.d.ts +4 -0
  121. package/dist/cjs/core/fetcher/Supplier.js +22 -0
  122. package/dist/cjs/core/fetcher/createRequestUrl.d.ts +1 -0
  123. package/dist/cjs/core/fetcher/createRequestUrl.js +8 -0
  124. package/dist/cjs/core/fetcher/getErrorResponseBody.d.ts +1 -0
  125. package/dist/cjs/core/fetcher/getErrorResponseBody.js +45 -0
  126. package/dist/cjs/core/fetcher/getFetchFn.d.ts +1 -0
  127. package/dist/cjs/core/fetcher/getFetchFn.js +17 -0
  128. package/dist/cjs/core/fetcher/getHeader.d.ts +1 -0
  129. package/dist/cjs/core/fetcher/getHeader.js +11 -0
  130. package/dist/cjs/core/fetcher/getRequestBody.d.ts +7 -0
  131. package/dist/cjs/core/fetcher/getRequestBody.js +27 -0
  132. package/dist/cjs/core/fetcher/getResponseBody.d.ts +1 -0
  133. package/dist/cjs/core/fetcher/getResponseBody.js +80 -0
  134. package/dist/cjs/core/fetcher/index.d.ts +13 -0
  135. package/dist/cjs/core/fetcher/index.js +19 -0
  136. package/dist/cjs/core/fetcher/makePassthroughRequest.d.ts +49 -0
  137. package/dist/cjs/core/fetcher/makePassthroughRequest.js +157 -0
  138. package/dist/cjs/core/fetcher/makeRequest.d.ts +6 -0
  139. package/dist/cjs/core/fetcher/makeRequest.js +61 -0
  140. package/dist/cjs/core/fetcher/redactUrl.d.ts +2 -0
  141. package/dist/cjs/core/fetcher/redactUrl.js +88 -0
  142. package/dist/cjs/core/fetcher/requestWithRetries.d.ts +1 -0
  143. package/dist/cjs/core/fetcher/requestWithRetries.js +70 -0
  144. package/dist/cjs/core/fetcher/signals.d.ts +5 -0
  145. package/dist/cjs/core/fetcher/signals.js +32 -0
  146. package/dist/cjs/core/file/exports.d.ts +1 -0
  147. package/dist/cjs/core/file/exports.js +2 -0
  148. package/dist/cjs/core/file/file.d.ts +10 -0
  149. package/dist/cjs/core/file/file.js +225 -0
  150. package/dist/cjs/core/file/index.d.ts +2 -0
  151. package/dist/cjs/core/file/index.js +18 -0
  152. package/dist/cjs/core/file/types.d.ts +66 -0
  153. package/dist/cjs/core/file/types.js +2 -0
  154. package/dist/cjs/core/form-data-utils/FormDataWrapper.d.ts +15 -0
  155. package/dist/cjs/core/form-data-utils/FormDataWrapper.js +188 -0
  156. package/dist/cjs/core/form-data-utils/encodeAsFormParameter.d.ts +1 -0
  157. package/dist/cjs/core/form-data-utils/encodeAsFormParameter.js +12 -0
  158. package/dist/cjs/core/form-data-utils/index.d.ts +2 -0
  159. package/dist/cjs/core/form-data-utils/index.js +20 -0
  160. package/dist/cjs/core/headers.d.ts +2 -0
  161. package/dist/cjs/core/headers.js +31 -0
  162. package/dist/cjs/core/index.d.ts +8 -0
  163. package/dist/cjs/core/index.js +47 -0
  164. package/dist/cjs/core/json.d.ts +15 -0
  165. package/dist/cjs/core/json.js +24 -0
  166. package/dist/cjs/core/logging/exports.d.ts +18 -0
  167. package/dist/cjs/core/logging/exports.js +45 -0
  168. package/dist/cjs/core/logging/index.d.ts +1 -0
  169. package/dist/cjs/core/logging/index.js +17 -0
  170. package/dist/cjs/core/logging/logger.d.ts +126 -0
  171. package/dist/cjs/core/logging/logger.js +144 -0
  172. package/dist/cjs/core/requestBody.d.ts +12 -0
  173. package/dist/cjs/core/requestBody.js +26 -0
  174. package/dist/cjs/core/runtime/index.d.ts +1 -0
  175. package/dist/cjs/core/runtime/index.js +6 -0
  176. package/dist/cjs/core/runtime/runtime.d.ts +28 -0
  177. package/dist/cjs/core/runtime/runtime.js +176 -0
  178. package/dist/cjs/core/url/QueryStringBuilder.d.ts +47 -0
  179. package/dist/cjs/core/url/QueryStringBuilder.js +83 -0
  180. package/dist/cjs/core/url/encodePathParam.d.ts +1 -0
  181. package/dist/cjs/core/url/encodePathParam.js +21 -0
  182. package/dist/cjs/core/url/index.d.ts +4 -0
  183. package/dist/cjs/core/url/index.js +11 -0
  184. package/dist/cjs/core/url/join.d.ts +1 -0
  185. package/dist/cjs/core/url/join.js +68 -0
  186. package/dist/cjs/core/url/qs.d.ts +7 -0
  187. package/dist/cjs/core/url/qs.js +76 -0
  188. package/dist/cjs/environments.d.ts +4 -0
  189. package/dist/cjs/environments.js +7 -0
  190. package/dist/cjs/errors/DetectantApiError.d.ts +15 -0
  191. package/dist/cjs/errors/DetectantApiError.js +39 -0
  192. package/dist/cjs/errors/DetectantApiTimeoutError.d.ts +6 -0
  193. package/dist/cjs/errors/DetectantApiTimeoutError.js +52 -0
  194. package/dist/cjs/errors/handleNonStatusCodeError.d.ts +2 -0
  195. package/dist/cjs/errors/handleNonStatusCodeError.js +68 -0
  196. package/dist/cjs/errors/index.d.ts +2 -0
  197. package/dist/cjs/errors/index.js +7 -0
  198. package/dist/cjs/exports.d.ts +1 -0
  199. package/dist/cjs/exports.js +17 -0
  200. package/dist/cjs/index.d.ts +6 -0
  201. package/dist/cjs/index.js +48 -0
  202. package/dist/cjs/version.d.ts +1 -0
  203. package/dist/cjs/version.js +4 -0
  204. package/dist/esm/BaseClient.d.mts +54 -0
  205. package/dist/esm/BaseClient.mjs +40 -0
  206. package/dist/esm/Client.d.mts +86 -0
  207. package/dist/esm/Client.mjs +218 -0
  208. package/dist/esm/api/client/index.d.mts +1 -0
  209. package/dist/esm/api/client/index.mjs +1 -0
  210. package/dist/esm/api/client/requests/CreateScanBatchRequest.d.mts +5 -0
  211. package/dist/esm/api/client/requests/CreateScanBatchRequest.mjs +2 -0
  212. package/dist/esm/api/client/requests/CreateScanRequest.d.mts +5 -0
  213. package/dist/esm/api/client/requests/CreateScanRequest.mjs +2 -0
  214. package/dist/esm/api/client/requests/index.d.mts +2 -0
  215. package/dist/esm/api/client/requests/index.mjs +1 -0
  216. package/dist/esm/api/errors/BadRequestError.d.mts +7 -0
  217. package/dist/esm/api/errors/BadRequestError.mjs +17 -0
  218. package/dist/esm/api/errors/ContentTooLargeError.d.mts +7 -0
  219. package/dist/esm/api/errors/ContentTooLargeError.mjs +17 -0
  220. package/dist/esm/api/errors/ForbiddenError.d.mts +7 -0
  221. package/dist/esm/api/errors/ForbiddenError.mjs +17 -0
  222. package/dist/esm/api/errors/InternalServerError.d.mts +7 -0
  223. package/dist/esm/api/errors/InternalServerError.mjs +17 -0
  224. package/dist/esm/api/errors/NotFoundError.d.mts +7 -0
  225. package/dist/esm/api/errors/NotFoundError.mjs +17 -0
  226. package/dist/esm/api/errors/ServiceUnavailableError.d.mts +5 -0
  227. package/dist/esm/api/errors/ServiceUnavailableError.mjs +17 -0
  228. package/dist/esm/api/errors/TooManyRequestsError.d.mts +7 -0
  229. package/dist/esm/api/errors/TooManyRequestsError.mjs +17 -0
  230. package/dist/esm/api/errors/UnauthorizedError.d.mts +7 -0
  231. package/dist/esm/api/errors/UnauthorizedError.mjs +17 -0
  232. package/dist/esm/api/errors/index.d.mts +8 -0
  233. package/dist/esm/api/errors/index.mjs +8 -0
  234. package/dist/esm/api/index.d.mts +4 -0
  235. package/dist/esm/api/index.mjs +4 -0
  236. package/dist/esm/api/resources/health/client/Client.d.mts +43 -0
  237. package/dist/esm/api/resources/health/client/Client.mjs +115 -0
  238. package/dist/esm/api/resources/health/client/index.d.mts +1 -0
  239. package/dist/esm/api/resources/health/client/index.mjs +1 -0
  240. package/dist/esm/api/resources/health/exports.d.mts +2 -0
  241. package/dist/esm/api/resources/health/exports.mjs +3 -0
  242. package/dist/esm/api/resources/health/index.d.mts +1 -0
  243. package/dist/esm/api/resources/health/index.mjs +1 -0
  244. package/dist/esm/api/resources/index.d.mts +3 -0
  245. package/dist/esm/api/resources/index.mjs +3 -0
  246. package/dist/esm/api/resources/scans/client/Client.d.mts +54 -0
  247. package/dist/esm/api/resources/scans/client/Client.mjs +159 -0
  248. package/dist/esm/api/resources/scans/client/index.d.mts +1 -0
  249. package/dist/esm/api/resources/scans/client/index.mjs +1 -0
  250. package/dist/esm/api/resources/scans/client/requests/GetScanRequest.d.mts +10 -0
  251. package/dist/esm/api/resources/scans/client/requests/GetScanRequest.mjs +2 -0
  252. package/dist/esm/api/resources/scans/client/requests/ListScansRequest.d.mts +18 -0
  253. package/dist/esm/api/resources/scans/client/requests/ListScansRequest.mjs +2 -0
  254. package/dist/esm/api/resources/scans/client/requests/index.d.mts +2 -0
  255. package/dist/esm/api/resources/scans/client/requests/index.mjs +1 -0
  256. package/dist/esm/api/resources/scans/exports.d.mts +2 -0
  257. package/dist/esm/api/resources/scans/exports.mjs +3 -0
  258. package/dist/esm/api/resources/scans/index.d.mts +1 -0
  259. package/dist/esm/api/resources/scans/index.mjs +1 -0
  260. package/dist/esm/api/types/ApiError.d.mts +8 -0
  261. package/dist/esm/api/types/ApiError.mjs +2 -0
  262. package/dist/esm/api/types/ErrorResponse.d.mts +4 -0
  263. package/dist/esm/api/types/ErrorResponse.mjs +2 -0
  264. package/dist/esm/api/types/HealthResponse.d.mts +10 -0
  265. package/dist/esm/api/types/HealthResponse.mjs +8 -0
  266. package/dist/esm/api/types/Scan.d.mts +32 -0
  267. package/dist/esm/api/types/Scan.mjs +14 -0
  268. package/dist/esm/api/types/ScanBatchResponse.d.mts +5 -0
  269. package/dist/esm/api/types/ScanBatchResponse.mjs +2 -0
  270. package/dist/esm/api/types/ScanBatchResult.d.mts +13 -0
  271. package/dist/esm/api/types/ScanBatchResult.mjs +2 -0
  272. package/dist/esm/api/types/ScanFailure.d.mts +11 -0
  273. package/dist/esm/api/types/ScanFailure.mjs +8 -0
  274. package/dist/esm/api/types/ScanList.d.mts +7 -0
  275. package/dist/esm/api/types/ScanList.mjs +2 -0
  276. package/dist/esm/api/types/TypeAnalysis.d.mts +26 -0
  277. package/dist/esm/api/types/TypeAnalysis.mjs +17 -0
  278. package/dist/esm/api/types/TypeAnalysisReason.d.mts +13 -0
  279. package/dist/esm/api/types/TypeAnalysisReason.mjs +9 -0
  280. package/dist/esm/api/types/TypeDeclaration.d.mts +6 -0
  281. package/dist/esm/api/types/TypeDeclaration.mjs +2 -0
  282. package/dist/esm/api/types/TypeIdentification.d.mts +6 -0
  283. package/dist/esm/api/types/TypeIdentification.mjs +2 -0
  284. package/dist/esm/api/types/index.d.mts +12 -0
  285. package/dist/esm/api/types/index.mjs +12 -0
  286. package/dist/esm/auth/HeaderAuthProvider.d.mts +20 -0
  287. package/dist/esm/auth/HeaderAuthProvider.mjs +43 -0
  288. package/dist/esm/auth/index.d.mts +1 -0
  289. package/dist/esm/auth/index.mjs +1 -0
  290. package/dist/esm/core/auth/AuthProvider.d.mts +8 -0
  291. package/dist/esm/core/auth/AuthProvider.mjs +6 -0
  292. package/dist/esm/core/auth/AuthRequest.d.mts +9 -0
  293. package/dist/esm/core/auth/AuthRequest.mjs +1 -0
  294. package/dist/esm/core/auth/BasicAuth.d.mts +8 -0
  295. package/dist/esm/core/auth/BasicAuth.mjs +30 -0
  296. package/dist/esm/core/auth/BearerToken.d.mts +7 -0
  297. package/dist/esm/core/auth/BearerToken.mjs +13 -0
  298. package/dist/esm/core/auth/NoOpAuthProvider.d.mts +5 -0
  299. package/dist/esm/core/auth/NoOpAuthProvider.mjs +5 -0
  300. package/dist/esm/core/auth/index.d.mts +5 -0
  301. package/dist/esm/core/auth/index.mjs +4 -0
  302. package/dist/esm/core/base64.d.mts +2 -0
  303. package/dist/esm/core/base64.mjs +22 -0
  304. package/dist/esm/core/exports.d.mts +2 -0
  305. package/dist/esm/core/exports.mjs +2 -0
  306. package/dist/esm/core/fetcher/APIResponse.d.mts +20 -0
  307. package/dist/esm/core/fetcher/APIResponse.mjs +1 -0
  308. package/dist/esm/core/fetcher/BinaryResponse.d.mts +19 -0
  309. package/dist/esm/core/fetcher/BinaryResponse.mjs +14 -0
  310. package/dist/esm/core/fetcher/EndpointMetadata.d.mts +13 -0
  311. package/dist/esm/core/fetcher/EndpointMetadata.mjs +1 -0
  312. package/dist/esm/core/fetcher/EndpointSupplier.d.mts +12 -0
  313. package/dist/esm/core/fetcher/EndpointSupplier.mjs +19 -0
  314. package/dist/esm/core/fetcher/Fetcher.d.mts +56 -0
  315. package/dist/esm/core/fetcher/Fetcher.mjs +240 -0
  316. package/dist/esm/core/fetcher/Headers.d.mts +2 -0
  317. package/dist/esm/core/fetcher/Headers.mjs +82 -0
  318. package/dist/esm/core/fetcher/HttpResponsePromise.d.mts +58 -0
  319. package/dist/esm/core/fetcher/HttpResponsePromise.mjs +99 -0
  320. package/dist/esm/core/fetcher/RawResponse.d.mts +29 -0
  321. package/dist/esm/core/fetcher/RawResponse.mjs +40 -0
  322. package/dist/esm/core/fetcher/Supplier.d.mts +4 -0
  323. package/dist/esm/core/fetcher/Supplier.mjs +19 -0
  324. package/dist/esm/core/fetcher/createRequestUrl.d.mts +1 -0
  325. package/dist/esm/core/fetcher/createRequestUrl.mjs +5 -0
  326. package/dist/esm/core/fetcher/getErrorResponseBody.d.mts +1 -0
  327. package/dist/esm/core/fetcher/getErrorResponseBody.mjs +42 -0
  328. package/dist/esm/core/fetcher/getFetchFn.d.mts +1 -0
  329. package/dist/esm/core/fetcher/getFetchFn.mjs +14 -0
  330. package/dist/esm/core/fetcher/getHeader.d.mts +1 -0
  331. package/dist/esm/core/fetcher/getHeader.mjs +8 -0
  332. package/dist/esm/core/fetcher/getRequestBody.d.mts +7 -0
  333. package/dist/esm/core/fetcher/getRequestBody.mjs +24 -0
  334. package/dist/esm/core/fetcher/getResponseBody.d.mts +1 -0
  335. package/dist/esm/core/fetcher/getResponseBody.mjs +77 -0
  336. package/dist/esm/core/fetcher/index.d.mts +13 -0
  337. package/dist/esm/core/fetcher/index.mjs +7 -0
  338. package/dist/esm/core/fetcher/makePassthroughRequest.d.mts +49 -0
  339. package/dist/esm/core/fetcher/makePassthroughRequest.mjs +154 -0
  340. package/dist/esm/core/fetcher/makeRequest.d.mts +6 -0
  341. package/dist/esm/core/fetcher/makeRequest.mjs +55 -0
  342. package/dist/esm/core/fetcher/redactUrl.d.mts +2 -0
  343. package/dist/esm/core/fetcher/redactUrl.mjs +84 -0
  344. package/dist/esm/core/fetcher/requestWithRetries.d.mts +1 -0
  345. package/dist/esm/core/fetcher/requestWithRetries.mjs +67 -0
  346. package/dist/esm/core/fetcher/signals.d.mts +5 -0
  347. package/dist/esm/core/fetcher/signals.mjs +28 -0
  348. package/dist/esm/core/file/exports.d.mts +1 -0
  349. package/dist/esm/core/file/exports.mjs +1 -0
  350. package/dist/esm/core/file/file.d.mts +10 -0
  351. package/dist/esm/core/file/file.mjs +188 -0
  352. package/dist/esm/core/file/index.d.mts +2 -0
  353. package/dist/esm/core/file/index.mjs +2 -0
  354. package/dist/esm/core/file/types.d.mts +66 -0
  355. package/dist/esm/core/file/types.mjs +1 -0
  356. package/dist/esm/core/form-data-utils/FormDataWrapper.d.mts +15 -0
  357. package/dist/esm/core/form-data-utils/FormDataWrapper.mjs +150 -0
  358. package/dist/esm/core/form-data-utils/encodeAsFormParameter.d.mts +1 -0
  359. package/dist/esm/core/form-data-utils/encodeAsFormParameter.mjs +9 -0
  360. package/dist/esm/core/form-data-utils/index.d.mts +2 -0
  361. package/dist/esm/core/form-data-utils/index.mjs +2 -0
  362. package/dist/esm/core/headers.d.mts +2 -0
  363. package/dist/esm/core/headers.mjs +27 -0
  364. package/dist/esm/core/index.d.mts +8 -0
  365. package/dist/esm/core/index.mjs +8 -0
  366. package/dist/esm/core/json.d.mts +15 -0
  367. package/dist/esm/core/json.mjs +19 -0
  368. package/dist/esm/core/logging/exports.d.mts +18 -0
  369. package/dist/esm/core/logging/exports.mjs +9 -0
  370. package/dist/esm/core/logging/index.d.mts +1 -0
  371. package/dist/esm/core/logging/index.mjs +1 -0
  372. package/dist/esm/core/logging/logger.d.mts +126 -0
  373. package/dist/esm/core/logging/logger.mjs +138 -0
  374. package/dist/esm/core/requestBody.d.mts +12 -0
  375. package/dist/esm/core/requestBody.mjs +23 -0
  376. package/dist/esm/core/runtime/index.d.mts +1 -0
  377. package/dist/esm/core/runtime/index.mjs +1 -0
  378. package/dist/esm/core/runtime/runtime.d.mts +28 -0
  379. package/dist/esm/core/runtime/runtime.mjs +172 -0
  380. package/dist/esm/core/url/QueryStringBuilder.d.mts +47 -0
  381. package/dist/esm/core/url/QueryStringBuilder.mjs +80 -0
  382. package/dist/esm/core/url/encodePathParam.d.mts +1 -0
  383. package/dist/esm/core/url/encodePathParam.mjs +18 -0
  384. package/dist/esm/core/url/index.d.mts +4 -0
  385. package/dist/esm/core/url/index.mjs +4 -0
  386. package/dist/esm/core/url/join.d.mts +1 -0
  387. package/dist/esm/core/url/join.mjs +65 -0
  388. package/dist/esm/core/url/qs.d.mts +7 -0
  389. package/dist/esm/core/url/qs.mjs +73 -0
  390. package/dist/esm/environments.d.mts +4 -0
  391. package/dist/esm/environments.mjs +4 -0
  392. package/dist/esm/errors/DetectantApiError.d.mts +15 -0
  393. package/dist/esm/errors/DetectantApiError.mjs +35 -0
  394. package/dist/esm/errors/DetectantApiTimeoutError.d.mts +6 -0
  395. package/dist/esm/errors/DetectantApiTimeoutError.mjs +15 -0
  396. package/dist/esm/errors/handleNonStatusCodeError.d.mts +2 -0
  397. package/dist/esm/errors/handleNonStatusCodeError.mjs +32 -0
  398. package/dist/esm/errors/index.d.mts +2 -0
  399. package/dist/esm/errors/index.mjs +2 -0
  400. package/dist/esm/exports.d.mts +1 -0
  401. package/dist/esm/exports.mjs +1 -0
  402. package/dist/esm/index.d.mts +6 -0
  403. package/dist/esm/index.mjs +5 -0
  404. package/dist/esm/version.d.mts +1 -0
  405. package/dist/esm/version.mjs +1 -0
  406. package/package.json +91 -1
  407. package/reference.md +380 -0
package/README.md ADDED
@@ -0,0 +1,111 @@
1
+ <p align="center">
2
+ <img src="../../app/dashboard/public/images/detectant-github-banner.png" alt="Detectant" width="100%">
3
+ </p>
4
+
5
+ # Detectant TypeScript SDK
6
+
7
+ Scan files for malware from Node.js and TypeScript.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @detectant-api/sdk
13
+ ```
14
+
15
+ Set your API key in the environment:
16
+
17
+ ```bash
18
+ export DETECTANT_API_KEY="your-api-key"
19
+ ```
20
+
21
+ ## Create a client
22
+
23
+ ```ts
24
+ import { Detectant } from "@detectant-api/sdk";
25
+
26
+ const detectant = new Detectant({
27
+ apiKey: process.env.DETECTANT_API_KEY,
28
+ });
29
+ ```
30
+
31
+ ## Scan one file
32
+
33
+ The simplest Node.js option is a file path:
34
+
35
+ ```ts
36
+ const result = await detectant.scan({ path: "./invoice.pdf" });
37
+
38
+ console.log(result.verdict, result.detections);
39
+ ```
40
+
41
+ The call completes after the file has been analyzed and returns its scan result.
42
+
43
+ ### Supported file inputs
44
+
45
+ Choose the input that already fits your application:
46
+
47
+ ```ts
48
+ import { createReadStream, readFileSync } from "node:fs";
49
+
50
+ // A path — recommended when the file is on disk
51
+ await detectant.scan({ path: "./invoice.pdf" });
52
+
53
+ // A Node.js readable stream
54
+ await detectant.scan(createReadStream("./invoice.pdf"));
55
+
56
+ // A Buffer or Uint8Array already in memory
57
+ await detectant.scan(readFileSync("./invoice.pdf"));
58
+ await detectant.scan(new Uint8Array([/* file bytes */]));
59
+
60
+ // A browser File, such as one selected with <input type="file">
61
+ await detectant.scan(fileInput.files![0]);
62
+
63
+ // A Blob
64
+ await detectant.scan(new Blob([fileBytes], { type: "application/pdf" }));
65
+ ```
66
+
67
+ For in-memory data, add a filename and content type when they are known:
68
+
69
+ ```ts
70
+ await detectant.scan({
71
+ data: fileBuffer,
72
+ filename: "invoice.pdf",
73
+ contentType: "application/pdf",
74
+ });
75
+ ```
76
+
77
+ The SDK accepts file paths, Node.js streams, web `ReadableStream`s, `Buffer`s,
78
+ `Uint8Array`s, `ArrayBuffer`s, `Blob`s, and `File`s.
79
+
80
+ ## Scan a batch
81
+
82
+ Upload between 1 and 20 files. Results are returned in the same order as the inputs.
83
+
84
+ ```ts
85
+ const batch = await detectant.scanBatch([
86
+ { path: "./invoice.pdf" },
87
+ { path: "./archive.zip" },
88
+ ]);
89
+
90
+ for (const item of batch.results) {
91
+ if (item.scan) {
92
+ console.log(item.filename, item.scan.verdict);
93
+ } else {
94
+ console.error(item.filename, item.error);
95
+ }
96
+ }
97
+ ```
98
+
99
+ One file can fail without preventing the other files in the batch from being scanned. Check each item's `scan` and `error` values.
100
+
101
+ ## Configuration
102
+
103
+ Use `baseUrl` for a self-hosted or local API, and increase the timeout for large files when needed:
104
+
105
+ ```ts
106
+ const detectant = new Detectant({
107
+ apiKey: process.env.DETECTANT_API_KEY,
108
+ baseUrl: "https://api.example.com",
109
+ timeoutInSeconds: 120,
110
+ });
111
+ ```
@@ -0,0 +1,54 @@
1
+ import { HeaderAuthProvider } from "./auth/HeaderAuthProvider.js";
2
+ import * as core from "./core/index.js";
3
+ import type * as environments from "./environments.js";
4
+ export type AuthOption = false | core.AuthProvider["getAuthRequest"] | core.AuthProvider | HeaderAuthProvider.AuthOptions;
5
+ export type BaseClientOptions = {
6
+ environment?: core.Supplier<environments.DetectantApiEnvironment | string>;
7
+ /** Specify a custom URL to connect the client to. */
8
+ baseUrl?: core.Supplier<string>;
9
+ /** Additional headers to include in requests. */
10
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
11
+ /** The default maximum time to wait for a response in seconds. */
12
+ timeoutInSeconds?: number;
13
+ /** The default number of times to retry the request. Defaults to 2. */
14
+ maxRetries?: number;
15
+ /** Provide a custom fetch implementation. Useful for platforms that don't have a built-in fetch or need a custom implementation. */
16
+ fetch?: typeof fetch;
17
+ /** Configure logging for the client. */
18
+ logging?: core.logging.LogConfig | core.logging.Logger;
19
+ /** Default options for SSE stream reconnection behavior. Has no effect on non-resumable endpoints. */
20
+ stream?: {
21
+ reconnectionEnabled?: boolean;
22
+ maxReconnectionAttempts?: number;
23
+ };
24
+ /** Override auth. Pass false to disable, a function returning auth headers, an AuthProvider, or auth options. */
25
+ auth?: AuthOption;
26
+ } & HeaderAuthProvider.AuthOptions;
27
+ export interface BaseRequestOptions {
28
+ /** The maximum time to wait for a response in seconds. */
29
+ timeoutInSeconds?: number;
30
+ /** The number of times to retry the request. Defaults to 2. */
31
+ maxRetries?: number;
32
+ /** A hook to abort the request. */
33
+ abortSignal?: AbortSignal;
34
+ /** Additional query string parameters to include in the request. */
35
+ queryParams?: Record<string, unknown>;
36
+ /** A dictionary containing additional parameters to spread into the request's body. */
37
+ additionalBodyParameters?: Record<string, unknown>;
38
+ /** Additional headers to include in the request. */
39
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
40
+ /** Options for SSE stream reconnection behavior. Has no effect on non-resumable endpoints. */
41
+ stream?: {
42
+ reconnectionEnabled?: boolean;
43
+ maxReconnectionAttempts?: number;
44
+ };
45
+ }
46
+ export type NormalizedClientOptions<T extends BaseClientOptions = BaseClientOptions> = T & {
47
+ logging: core.logging.Logger;
48
+ authProvider?: core.AuthProvider;
49
+ };
50
+ export type NormalizedClientOptionsWithAuth<T extends BaseClientOptions = BaseClientOptions> = NormalizedClientOptions<T> & {
51
+ authProvider: core.AuthProvider;
52
+ };
53
+ export declare function normalizeClientOptions<T extends BaseClientOptions = BaseClientOptions>(options: T): NormalizedClientOptions<T>;
54
+ export declare function normalizeClientOptionsWithAuth<T extends BaseClientOptions = BaseClientOptions>(options: T): NormalizedClientOptionsWithAuth<T>;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.normalizeClientOptions = normalizeClientOptions;
38
+ exports.normalizeClientOptionsWithAuth = normalizeClientOptionsWithAuth;
39
+ const HeaderAuthProvider_js_1 = require("./auth/HeaderAuthProvider.js");
40
+ const headers_js_1 = require("./core/headers.js");
41
+ const core = __importStar(require("./core/index.js"));
42
+ function normalizeClientOptions(options) {
43
+ const headers = (0, headers_js_1.mergeHeaders)({
44
+ "X-Fern-Language": "JavaScript",
45
+ "X-Fern-SDK-Name": "@detectant-api/sdk",
46
+ "X-Fern-SDK-Version": "0.0.2",
47
+ "User-Agent": "@detectant-api/sdk/0.0.2",
48
+ "X-Fern-Runtime": core.RUNTIME.type,
49
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
50
+ }, options === null || options === void 0 ? void 0 : options.headers);
51
+ return Object.assign(Object.assign({}, options), { logging: core.logging.createLogger(options === null || options === void 0 ? void 0 : options.logging), headers });
52
+ }
53
+ function normalizeClientOptionsWithAuth(options) {
54
+ var _a;
55
+ const normalized = normalizeClientOptions(options);
56
+ if (options.auth === false) {
57
+ normalized.authProvider = new core.NoOpAuthProvider();
58
+ return normalized;
59
+ }
60
+ if (options.auth != null) {
61
+ if (typeof options.auth === "function") {
62
+ normalized.authProvider = { getAuthRequest: options.auth };
63
+ return normalized;
64
+ }
65
+ if (core.isAuthProvider(options.auth)) {
66
+ normalized.authProvider = options.auth;
67
+ return normalized;
68
+ }
69
+ Object.assign(normalized, options.auth);
70
+ }
71
+ const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
72
+ (_a = normalized.authProvider) !== null && _a !== void 0 ? _a : (normalized.authProvider = new HeaderAuthProvider_js_1.HeaderAuthProvider(normalizedWithNoOpAuthProvider));
73
+ return normalized;
74
+ }
75
+ function withNoOpAuthProvider(options) {
76
+ return Object.assign(Object.assign({}, options), { authProvider: new core.NoOpAuthProvider() });
77
+ }
@@ -0,0 +1,86 @@
1
+ import * as DetectantApi from "./api/index.js";
2
+ import { HealthClient } from "./api/resources/health/client/Client.js";
3
+ import { ScansClient } from "./api/resources/scans/client/Client.js";
4
+ import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
5
+ import { type NormalizedClientOptionsWithAuth } from "./BaseClient.js";
6
+ import * as core from "./core/index.js";
7
+ export declare namespace Detectant {
8
+ type Options = BaseClientOptions;
9
+ interface RequestOptions extends BaseRequestOptions {
10
+ }
11
+ }
12
+ export declare class Detectant {
13
+ protected readonly _options: NormalizedClientOptionsWithAuth<Detectant.Options>;
14
+ protected _health: HealthClient | undefined;
15
+ protected _scans: ScansClient | undefined;
16
+ constructor(options?: Detectant.Options);
17
+ get health(): HealthClient;
18
+ get scans(): ScansClient;
19
+ /**
20
+ * Uploads one file and synchronously runs content-type and malware analysis.
21
+ * Only the first multipart part named `file` with a filename is
22
+ * scanned; other parts are ignored. Free accounts accept files up to
23
+ * 50 MiB; Grow and Scale accounts accept files up to 250 MiB.
24
+ *
25
+ * @param {core.file.Uploadable} file
26
+ * @param {Detectant.RequestOptions} requestOptions - Request-specific configuration.
27
+ *
28
+ * @throws {@link DetectantApi.BadRequestError}
29
+ * @throws {@link DetectantApi.UnauthorizedError}
30
+ * @throws {@link DetectantApi.ForbiddenError}
31
+ * @throws {@link DetectantApi.ContentTooLargeError}
32
+ * @throws {@link DetectantApi.TooManyRequestsError}
33
+ * @throws {@link DetectantApi.InternalServerError}
34
+ * @throws {@link DetectantApi.ServiceUnavailableError}
35
+ * @throws {@link errors.DetectantApiError}
36
+ * @throws {@link errors.DetectantApiTimeoutError}
37
+ *
38
+ * @example
39
+ * import { createReadStream } from "fs";
40
+ * await client.scan(createReadStream("path/to/file"))
41
+ */
42
+ scan(file: core.file.Uploadable, requestOptions?: Detectant.RequestOptions): core.HttpResponsePromise<DetectantApi.Scan>;
43
+ private __scan;
44
+ /**
45
+ * Uploads between 1 and 20 files in repeated `files` multipart parts. Each
46
+ * file uses its account plan's 50 MiB or 250 MiB per-file limit, validation, content-type
47
+ * analysis, malware detection, persistence, usage accounting, and billing path
48
+ * as `createScan`. The encoded multipart request limit is the plan's
49
+ * per-file limit × 20 plus 1 MiB for multipart framing.
50
+ *
51
+ * Results preserve submitted-file order. File-level validation or scanner
52
+ * failures are returned in the corresponding result and do not prevent
53
+ * other files from being scanned. The whole request is rejected only for
54
+ * request-level failures such as invalid multipart data, authentication or
55
+ * rate-limit failure, more than 20 files, or an oversized total request.
56
+ *
57
+ * @param {core.file.Uploadable[]} files
58
+ * @param {Detectant.RequestOptions} requestOptions - Request-specific configuration.
59
+ *
60
+ * @throws {@link DetectantApi.BadRequestError}
61
+ * @throws {@link DetectantApi.UnauthorizedError}
62
+ * @throws {@link DetectantApi.ForbiddenError}
63
+ * @throws {@link DetectantApi.ContentTooLargeError}
64
+ * @throws {@link DetectantApi.TooManyRequestsError}
65
+ * @throws {@link DetectantApi.InternalServerError}
66
+ * @throws {@link errors.DetectantApiError}
67
+ * @throws {@link errors.DetectantApiTimeoutError}
68
+ *
69
+ * @example
70
+ * import { createReadStream } from "fs";
71
+ * await client.scanBatch([createReadStream("path/to/file")])
72
+ */
73
+ scanBatch(files: core.file.Uploadable[], requestOptions?: Detectant.RequestOptions): core.HttpResponsePromise<DetectantApi.ScanBatchResponse>;
74
+ private __scanBatch;
75
+ /**
76
+ * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
77
+ * This is useful for making requests to endpoints not yet supported in the SDK.
78
+ * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
79
+ *
80
+ * @param {Request | string | URL} input - The URL, path, or Request object.
81
+ * @param {RequestInit} init - Standard fetch RequestInit options.
82
+ * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
83
+ * @returns {Promise<Response>} A standard Response object.
84
+ */
85
+ fetch(input: Request | string | URL, init?: RequestInit, requestOptions?: core.PassthroughRequest.RequestOptions): Promise<Response>;
86
+ }
@@ -0,0 +1,255 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.Detectant = void 0;
47
+ const DetectantApi = __importStar(require("./api/index.js"));
48
+ const Client_js_1 = require("./api/resources/health/client/Client.js");
49
+ const Client_js_2 = require("./api/resources/scans/client/Client.js");
50
+ const BaseClient_js_1 = require("./BaseClient.js");
51
+ const headers_js_1 = require("./core/headers.js");
52
+ const core = __importStar(require("./core/index.js"));
53
+ const environments = __importStar(require("./environments.js"));
54
+ const handleNonStatusCodeError_js_1 = require("./errors/handleNonStatusCodeError.js");
55
+ const errors = __importStar(require("./errors/index.js"));
56
+ class Detectant {
57
+ constructor(options = {}) {
58
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
59
+ }
60
+ get health() {
61
+ var _a;
62
+ return ((_a = this._health) !== null && _a !== void 0 ? _a : (this._health = new Client_js_1.HealthClient(this._options)));
63
+ }
64
+ get scans() {
65
+ var _a;
66
+ return ((_a = this._scans) !== null && _a !== void 0 ? _a : (this._scans = new Client_js_2.ScansClient(this._options)));
67
+ }
68
+ /**
69
+ * Uploads one file and synchronously runs content-type and malware analysis.
70
+ * Only the first multipart part named `file` with a filename is
71
+ * scanned; other parts are ignored. Free accounts accept files up to
72
+ * 50 MiB; Grow and Scale accounts accept files up to 250 MiB.
73
+ *
74
+ * @param {core.file.Uploadable} file
75
+ * @param {Detectant.RequestOptions} requestOptions - Request-specific configuration.
76
+ *
77
+ * @throws {@link DetectantApi.BadRequestError}
78
+ * @throws {@link DetectantApi.UnauthorizedError}
79
+ * @throws {@link DetectantApi.ForbiddenError}
80
+ * @throws {@link DetectantApi.ContentTooLargeError}
81
+ * @throws {@link DetectantApi.TooManyRequestsError}
82
+ * @throws {@link DetectantApi.InternalServerError}
83
+ * @throws {@link DetectantApi.ServiceUnavailableError}
84
+ * @throws {@link errors.DetectantApiError}
85
+ * @throws {@link errors.DetectantApiTimeoutError}
86
+ *
87
+ * @example
88
+ * import { createReadStream } from "fs";
89
+ * await client.scan(createReadStream("path/to/file"))
90
+ */
91
+ scan(file, requestOptions) {
92
+ return core.HttpResponsePromise.fromPromise(this.__scan(file, requestOptions));
93
+ }
94
+ __scan(file, requestOptions) {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
97
+ const _body = yield core.newFormData();
98
+ yield _body.appendFile("file", file);
99
+ const _maybeEncodedRequest = yield _body.getRequest();
100
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
101
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, _maybeEncodedRequest.headers)), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
102
+ const _response = yield core.fetcher({
103
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.DetectantApiEnvironment.Default, "v1/scans"),
104
+ method: "POST",
105
+ headers: _headers,
106
+ queryString: core.url.queryBuilder().mergeAdditional(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams).build(),
107
+ requestType: "file",
108
+ duplex: _maybeEncodedRequest.duplex,
109
+ body: _maybeEncodedRequest.body,
110
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
111
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
112
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
113
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
114
+ logging: this._options.logging,
115
+ });
116
+ if (_response.ok) {
117
+ return { data: _response.body, rawResponse: _response.rawResponse };
118
+ }
119
+ if (_response.error.reason === "status-code") {
120
+ switch (_response.error.statusCode) {
121
+ case 400:
122
+ throw new DetectantApi.BadRequestError(_response.error.body, _response.rawResponse);
123
+ case 401:
124
+ throw new DetectantApi.UnauthorizedError(_response.error.body, _response.rawResponse);
125
+ case 403:
126
+ throw new DetectantApi.ForbiddenError(_response.error.body, _response.rawResponse);
127
+ case 413:
128
+ throw new DetectantApi.ContentTooLargeError(_response.error.body, _response.rawResponse);
129
+ case 429:
130
+ throw new DetectantApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
131
+ case 500:
132
+ throw new DetectantApi.InternalServerError(_response.error.body, _response.rawResponse);
133
+ case 503:
134
+ throw new DetectantApi.ServiceUnavailableError(_response.error.body, _response.rawResponse);
135
+ default:
136
+ throw new errors.DetectantApiError({
137
+ statusCode: _response.error.statusCode,
138
+ body: _response.error.body,
139
+ rawResponse: _response.rawResponse,
140
+ });
141
+ }
142
+ }
143
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/v1/scans");
144
+ });
145
+ }
146
+ /**
147
+ * Uploads between 1 and 20 files in repeated `files` multipart parts. Each
148
+ * file uses its account plan's 50 MiB or 250 MiB per-file limit, validation, content-type
149
+ * analysis, malware detection, persistence, usage accounting, and billing path
150
+ * as `createScan`. The encoded multipart request limit is the plan's
151
+ * per-file limit × 20 plus 1 MiB for multipart framing.
152
+ *
153
+ * Results preserve submitted-file order. File-level validation or scanner
154
+ * failures are returned in the corresponding result and do not prevent
155
+ * other files from being scanned. The whole request is rejected only for
156
+ * request-level failures such as invalid multipart data, authentication or
157
+ * rate-limit failure, more than 20 files, or an oversized total request.
158
+ *
159
+ * @param {core.file.Uploadable[]} files
160
+ * @param {Detectant.RequestOptions} requestOptions - Request-specific configuration.
161
+ *
162
+ * @throws {@link DetectantApi.BadRequestError}
163
+ * @throws {@link DetectantApi.UnauthorizedError}
164
+ * @throws {@link DetectantApi.ForbiddenError}
165
+ * @throws {@link DetectantApi.ContentTooLargeError}
166
+ * @throws {@link DetectantApi.TooManyRequestsError}
167
+ * @throws {@link DetectantApi.InternalServerError}
168
+ * @throws {@link errors.DetectantApiError}
169
+ * @throws {@link errors.DetectantApiTimeoutError}
170
+ *
171
+ * @example
172
+ * import { createReadStream } from "fs";
173
+ * await client.scanBatch([createReadStream("path/to/file")])
174
+ */
175
+ scanBatch(files, requestOptions) {
176
+ return core.HttpResponsePromise.fromPromise(this.__scanBatch(files, requestOptions));
177
+ }
178
+ __scanBatch(files, requestOptions) {
179
+ return __awaiter(this, void 0, void 0, function* () {
180
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
181
+ const _body = yield core.newFormData();
182
+ for (const _file of files) {
183
+ yield _body.appendFile("files", _file);
184
+ }
185
+ const _maybeEncodedRequest = yield _body.getRequest();
186
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
187
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, _maybeEncodedRequest.headers)), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
188
+ const _response = yield core.fetcher({
189
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.DetectantApiEnvironment.Default, "v1/scans/batch"),
190
+ method: "POST",
191
+ headers: _headers,
192
+ queryString: core.url.queryBuilder().mergeAdditional(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams).build(),
193
+ requestType: "file",
194
+ duplex: _maybeEncodedRequest.duplex,
195
+ body: _maybeEncodedRequest.body,
196
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
197
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
198
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
199
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
200
+ logging: this._options.logging,
201
+ });
202
+ if (_response.ok) {
203
+ return { data: _response.body, rawResponse: _response.rawResponse };
204
+ }
205
+ if (_response.error.reason === "status-code") {
206
+ switch (_response.error.statusCode) {
207
+ case 400:
208
+ throw new DetectantApi.BadRequestError(_response.error.body, _response.rawResponse);
209
+ case 401:
210
+ throw new DetectantApi.UnauthorizedError(_response.error.body, _response.rawResponse);
211
+ case 403:
212
+ throw new DetectantApi.ForbiddenError(_response.error.body, _response.rawResponse);
213
+ case 413:
214
+ throw new DetectantApi.ContentTooLargeError(_response.error.body, _response.rawResponse);
215
+ case 429:
216
+ throw new DetectantApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
217
+ case 500:
218
+ throw new DetectantApi.InternalServerError(_response.error.body, _response.rawResponse);
219
+ default:
220
+ throw new errors.DetectantApiError({
221
+ statusCode: _response.error.statusCode,
222
+ body: _response.error.body,
223
+ rawResponse: _response.rawResponse,
224
+ });
225
+ }
226
+ }
227
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/v1/scans/batch");
228
+ });
229
+ }
230
+ /**
231
+ * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
232
+ * This is useful for making requests to endpoints not yet supported in the SDK.
233
+ * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
234
+ *
235
+ * @param {Request | string | URL} input - The URL, path, or Request object.
236
+ * @param {RequestInit} init - Standard fetch RequestInit options.
237
+ * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
238
+ * @returns {Promise<Response>} A standard Response object.
239
+ */
240
+ fetch(input, init, requestOptions) {
241
+ return __awaiter(this, void 0, void 0, function* () {
242
+ var _a;
243
+ return core.makePassthroughRequest(input, init, {
244
+ baseUrl: (_a = this._options.baseUrl) !== null && _a !== void 0 ? _a : this._options.environment,
245
+ headers: this._options.headers,
246
+ timeoutInSeconds: this._options.timeoutInSeconds,
247
+ maxRetries: this._options.maxRetries,
248
+ fetch: this._options.fetch,
249
+ logging: this._options.logging,
250
+ getAuthHeaders: () => __awaiter(this, void 0, void 0, function* () { return (yield this._options.authProvider.getAuthRequest()).headers; }),
251
+ }, requestOptions);
252
+ });
253
+ }
254
+ }
255
+ exports.Detectant = Detectant;
@@ -0,0 +1 @@
1
+ export * from "./requests/index.js";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./requests/index.js"), exports);
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @example
3
+ * {}
4
+ */
5
+ export type CreateScanBatchRequest = {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @example
3
+ * {}
4
+ */
5
+ export type CreateScanRequest = {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export type { CreateScanBatchRequest } from "./CreateScanBatchRequest.js";
2
+ export type { CreateScanRequest } from "./CreateScanRequest.js";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import type * as core from "../../core/index.js";
2
+ import * as errors from "../../errors/index.js";
3
+ import type * as DetectantApi from "../index.js";
4
+ export declare class BadRequestError extends errors.DetectantApiError {
5
+ readonly body: DetectantApi.ErrorResponse;
6
+ constructor(body: DetectantApi.ErrorResponse, rawResponse?: core.RawResponse);
7
+ }