openlayer 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (625) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +112 -60
  3. package/api-promise.d.mts +2 -0
  4. package/api-promise.d.mts.map +1 -0
  5. package/api-promise.d.ts +2 -0
  6. package/api-promise.d.ts.map +1 -0
  7. package/api-promise.js +6 -0
  8. package/api-promise.js.map +1 -0
  9. package/api-promise.mjs +2 -0
  10. package/api-promise.mjs.map +1 -0
  11. package/bin/cli +53 -0
  12. package/bin/migration-config.json +6 -0
  13. package/client.d.mts +186 -0
  14. package/client.d.mts.map +1 -0
  15. package/client.d.ts +186 -0
  16. package/client.d.ts.map +1 -0
  17. package/client.js +463 -0
  18. package/client.js.map +1 -0
  19. package/client.mjs +459 -0
  20. package/client.mjs.map +1 -0
  21. package/core/api-promise.d.mts +46 -0
  22. package/core/api-promise.d.mts.map +1 -0
  23. package/core/api-promise.d.ts +46 -0
  24. package/core/api-promise.d.ts.map +1 -0
  25. package/core/api-promise.js +74 -0
  26. package/core/api-promise.js.map +1 -0
  27. package/core/api-promise.mjs +70 -0
  28. package/core/api-promise.mjs.map +1 -0
  29. package/core/error.d.mts +46 -0
  30. package/core/error.d.mts.map +1 -0
  31. package/core/error.d.ts +46 -0
  32. package/core/error.d.ts.map +1 -0
  33. package/core/error.js +113 -0
  34. package/core/error.js.map +1 -0
  35. package/core/error.mjs +97 -0
  36. package/core/error.mjs.map +1 -0
  37. package/core/resource.d.mts +6 -0
  38. package/core/resource.d.mts.map +1 -0
  39. package/core/resource.d.ts +6 -0
  40. package/core/resource.d.ts.map +1 -0
  41. package/core/resource.js +11 -0
  42. package/core/resource.js.map +1 -0
  43. package/core/resource.mjs +7 -0
  44. package/core/resource.mjs.map +1 -0
  45. package/core/uploads.d.mts +3 -0
  46. package/core/uploads.d.mts.map +1 -0
  47. package/core/uploads.d.ts +3 -0
  48. package/core/uploads.d.ts.map +1 -0
  49. package/core/uploads.js +6 -0
  50. package/core/uploads.js.map +1 -0
  51. package/core/uploads.mjs +2 -0
  52. package/core/uploads.mjs.map +1 -0
  53. package/error.d.mts +2 -0
  54. package/error.d.mts.map +1 -0
  55. package/error.d.ts +1 -46
  56. package/error.d.ts.map +1 -1
  57. package/error.js +3 -110
  58. package/error.js.map +1 -1
  59. package/error.mjs +1 -96
  60. package/error.mjs.map +1 -1
  61. package/index.d.mts +6 -124
  62. package/index.d.mts.map +1 -0
  63. package/index.d.ts +5 -123
  64. package/index.d.ts.map +1 -1
  65. package/index.js +12 -140
  66. package/index.js.map +1 -1
  67. package/index.mjs +5 -103
  68. package/index.mjs.map +1 -1
  69. package/internal/builtin-types.d.mts +73 -0
  70. package/internal/builtin-types.d.mts.map +1 -0
  71. package/internal/builtin-types.d.ts +73 -0
  72. package/internal/builtin-types.d.ts.map +1 -0
  73. package/internal/builtin-types.js +4 -0
  74. package/internal/builtin-types.js.map +1 -0
  75. package/internal/builtin-types.mjs +3 -0
  76. package/internal/builtin-types.mjs.map +1 -0
  77. package/internal/detect-platform.d.mts +15 -0
  78. package/internal/detect-platform.d.mts.map +1 -0
  79. package/internal/detect-platform.d.ts +15 -0
  80. package/internal/detect-platform.d.ts.map +1 -0
  81. package/internal/detect-platform.js +162 -0
  82. package/internal/detect-platform.js.map +1 -0
  83. package/internal/detect-platform.mjs +157 -0
  84. package/internal/detect-platform.mjs.map +1 -0
  85. package/internal/errors.d.mts +3 -0
  86. package/internal/errors.d.mts.map +1 -0
  87. package/internal/errors.d.ts +3 -0
  88. package/internal/errors.d.ts.map +1 -0
  89. package/internal/errors.js +41 -0
  90. package/internal/errors.js.map +1 -0
  91. package/internal/errors.mjs +36 -0
  92. package/internal/errors.mjs.map +1 -0
  93. package/internal/headers.d.mts +20 -0
  94. package/internal/headers.d.mts.map +1 -0
  95. package/internal/headers.d.ts +20 -0
  96. package/internal/headers.d.ts.map +1 -0
  97. package/internal/headers.js +79 -0
  98. package/internal/headers.js.map +1 -0
  99. package/internal/headers.mjs +74 -0
  100. package/internal/headers.mjs.map +1 -0
  101. package/internal/parse.d.mts +12 -0
  102. package/internal/parse.d.mts.map +1 -0
  103. package/internal/parse.d.ts +12 -0
  104. package/internal/parse.d.ts.map +1 -0
  105. package/internal/parse.js +35 -0
  106. package/internal/parse.js.map +1 -0
  107. package/internal/parse.mjs +32 -0
  108. package/internal/parse.mjs.map +1 -0
  109. package/internal/qs/formats.d.mts +7 -0
  110. package/internal/qs/formats.d.mts.map +1 -0
  111. package/internal/qs/formats.d.ts +1 -0
  112. package/internal/qs/formats.d.ts.map +1 -1
  113. package/internal/qs/formats.js +4 -2
  114. package/internal/qs/formats.js.map +1 -1
  115. package/internal/qs/formats.mjs +2 -1
  116. package/internal/qs/formats.mjs.map +1 -1
  117. package/internal/qs/index.d.mts +10 -0
  118. package/internal/qs/index.d.mts.map +1 -0
  119. package/internal/qs/index.d.ts.map +1 -1
  120. package/internal/qs/stringify.d.mts +3 -0
  121. package/internal/qs/stringify.d.mts.map +1 -0
  122. package/internal/qs/stringify.d.ts.map +1 -1
  123. package/internal/qs/stringify.js +15 -17
  124. package/internal/qs/stringify.js.map +1 -1
  125. package/internal/qs/stringify.mjs +17 -19
  126. package/internal/qs/stringify.mjs.map +1 -1
  127. package/internal/qs/types.d.mts +57 -0
  128. package/internal/qs/types.d.mts.map +1 -0
  129. package/internal/qs/utils.d.mts +15 -0
  130. package/internal/qs/utils.d.mts.map +1 -0
  131. package/internal/qs/utils.d.ts +1 -0
  132. package/internal/qs/utils.d.ts.map +1 -1
  133. package/internal/qs/utils.js +14 -13
  134. package/internal/qs/utils.js.map +1 -1
  135. package/internal/qs/utils.mjs +12 -12
  136. package/internal/qs/utils.mjs.map +1 -1
  137. package/internal/request-options.d.mts +75 -0
  138. package/internal/request-options.d.mts.map +1 -0
  139. package/internal/request-options.d.ts +75 -0
  140. package/internal/request-options.d.ts.map +1 -0
  141. package/internal/request-options.js +14 -0
  142. package/internal/request-options.js.map +1 -0
  143. package/internal/request-options.mjs +10 -0
  144. package/internal/request-options.mjs.map +1 -0
  145. package/internal/shim-types.d.mts +17 -0
  146. package/internal/shim-types.d.mts.map +1 -0
  147. package/internal/shim-types.d.ts +17 -0
  148. package/internal/shim-types.d.ts.map +1 -0
  149. package/internal/shim-types.js +4 -0
  150. package/internal/shim-types.js.map +1 -0
  151. package/internal/shim-types.mjs +3 -0
  152. package/internal/shim-types.mjs.map +1 -0
  153. package/internal/shims.d.mts +20 -0
  154. package/internal/shims.d.mts.map +1 -0
  155. package/internal/shims.d.ts +20 -0
  156. package/internal/shims.d.ts.map +1 -0
  157. package/internal/shims.js +92 -0
  158. package/internal/shims.js.map +1 -0
  159. package/internal/shims.mjs +85 -0
  160. package/internal/shims.mjs.map +1 -0
  161. package/internal/to-file.d.mts +45 -0
  162. package/internal/to-file.d.mts.map +1 -0
  163. package/internal/to-file.d.ts +45 -0
  164. package/internal/to-file.d.ts.map +1 -0
  165. package/internal/to-file.js +91 -0
  166. package/internal/to-file.js.map +1 -0
  167. package/internal/to-file.mjs +88 -0
  168. package/internal/to-file.mjs.map +1 -0
  169. package/internal/tslib.js +85 -0
  170. package/internal/tslib.mjs +17 -0
  171. package/internal/types.d.mts +69 -0
  172. package/internal/types.d.mts.map +1 -0
  173. package/internal/types.d.ts +69 -0
  174. package/internal/types.d.ts.map +1 -0
  175. package/internal/types.js +4 -0
  176. package/internal/types.js.map +1 -0
  177. package/internal/types.mjs +3 -0
  178. package/internal/types.mjs.map +1 -0
  179. package/internal/uploads.d.mts +42 -0
  180. package/internal/uploads.d.mts.map +1 -0
  181. package/internal/uploads.d.ts +42 -0
  182. package/internal/uploads.d.ts.map +1 -0
  183. package/internal/uploads.js +141 -0
  184. package/internal/uploads.js.map +1 -0
  185. package/internal/uploads.mjs +131 -0
  186. package/internal/uploads.mjs.map +1 -0
  187. package/internal/utils/base64.d.mts +3 -0
  188. package/internal/utils/base64.d.mts.map +1 -0
  189. package/internal/utils/base64.d.ts +3 -0
  190. package/internal/utils/base64.d.ts.map +1 -0
  191. package/internal/utils/base64.js +38 -0
  192. package/internal/utils/base64.js.map +1 -0
  193. package/internal/utils/base64.mjs +33 -0
  194. package/internal/utils/base64.mjs.map +1 -0
  195. package/internal/utils/bytes.d.mts +4 -0
  196. package/internal/utils/bytes.d.mts.map +1 -0
  197. package/internal/utils/bytes.d.ts +4 -0
  198. package/internal/utils/bytes.d.ts.map +1 -0
  199. package/internal/utils/bytes.js +31 -0
  200. package/internal/utils/bytes.js.map +1 -0
  201. package/internal/utils/bytes.mjs +26 -0
  202. package/internal/utils/bytes.mjs.map +1 -0
  203. package/internal/utils/env.d.mts +9 -0
  204. package/internal/utils/env.d.mts.map +1 -0
  205. package/internal/utils/env.d.ts +9 -0
  206. package/internal/utils/env.d.ts.map +1 -0
  207. package/internal/utils/env.js +22 -0
  208. package/internal/utils/env.js.map +1 -0
  209. package/internal/utils/env.mjs +18 -0
  210. package/internal/utils/env.mjs.map +1 -0
  211. package/internal/utils/log.d.mts +37 -0
  212. package/internal/utils/log.d.mts.map +1 -0
  213. package/internal/utils/log.d.ts +37 -0
  214. package/internal/utils/log.d.ts.map +1 -0
  215. package/internal/utils/log.js +85 -0
  216. package/internal/utils/log.js.map +1 -0
  217. package/internal/utils/log.mjs +79 -0
  218. package/internal/utils/log.mjs.map +1 -0
  219. package/internal/utils/path.d.mts +15 -0
  220. package/internal/utils/path.d.mts.map +1 -0
  221. package/internal/utils/path.d.ts +15 -0
  222. package/internal/utils/path.d.ts.map +1 -0
  223. package/internal/utils/path.js +79 -0
  224. package/internal/utils/path.js.map +1 -0
  225. package/internal/utils/path.mjs +74 -0
  226. package/internal/utils/path.mjs.map +1 -0
  227. package/internal/utils/sleep.d.mts +2 -0
  228. package/internal/utils/sleep.d.mts.map +1 -0
  229. package/internal/utils/sleep.d.ts +2 -0
  230. package/internal/utils/sleep.d.ts.map +1 -0
  231. package/internal/utils/sleep.js +7 -0
  232. package/internal/utils/sleep.js.map +1 -0
  233. package/internal/utils/sleep.mjs +3 -0
  234. package/internal/utils/sleep.mjs.map +1 -0
  235. package/internal/utils/uuid.d.mts +5 -0
  236. package/internal/utils/uuid.d.mts.map +1 -0
  237. package/internal/utils/uuid.d.ts +5 -0
  238. package/internal/utils/uuid.d.ts.map +1 -0
  239. package/internal/utils/uuid.js +19 -0
  240. package/internal/utils/uuid.js.map +1 -0
  241. package/internal/utils/uuid.mjs +15 -0
  242. package/internal/utils/uuid.mjs.map +1 -0
  243. package/internal/utils/values.d.mts +18 -0
  244. package/internal/utils/values.d.mts.map +1 -0
  245. package/internal/utils/values.d.ts +18 -0
  246. package/internal/utils/values.d.ts.map +1 -0
  247. package/internal/utils/values.js +112 -0
  248. package/internal/utils/values.js.map +1 -0
  249. package/internal/utils/values.mjs +94 -0
  250. package/internal/utils/values.mjs.map +1 -0
  251. package/internal/utils.d.mts +7 -0
  252. package/internal/utils.d.mts.map +1 -0
  253. package/internal/utils.d.ts +7 -0
  254. package/internal/utils.d.ts.map +1 -0
  255. package/internal/utils.js +11 -0
  256. package/internal/utils.js.map +1 -0
  257. package/internal/utils.mjs +8 -0
  258. package/internal/utils.mjs.map +1 -0
  259. package/lib/core/cli.d.mts +24 -0
  260. package/lib/core/cli.d.mts.map +1 -0
  261. package/lib/core/cli.js +3 -35
  262. package/lib/core/cli.js.map +1 -1
  263. package/lib/core/openai-monitor.d.mts +57 -0
  264. package/lib/core/openai-monitor.d.mts.map +1 -0
  265. package/lib/core/openai-monitor.d.ts.map +1 -1
  266. package/lib/core/openai-monitor.js +2 -4
  267. package/lib/core/openai-monitor.js.map +1 -1
  268. package/lib/integrations/bedrockAgentTracer.d.mts +3 -0
  269. package/lib/integrations/bedrockAgentTracer.d.mts.map +1 -0
  270. package/lib/integrations/bedrockAgentTracer.d.ts.map +1 -1
  271. package/lib/integrations/bedrockAgentTracer.js +2 -4
  272. package/lib/integrations/bedrockAgentTracer.js.map +1 -1
  273. package/lib/integrations/index.d.mts +5 -0
  274. package/lib/integrations/index.d.mts.map +1 -0
  275. package/lib/integrations/index.d.ts.map +1 -1
  276. package/lib/integrations/index.js +5 -18
  277. package/lib/integrations/index.js.map +1 -1
  278. package/lib/integrations/langchainCallback.d.mts +89 -0
  279. package/lib/integrations/langchainCallback.d.mts.map +1 -0
  280. package/lib/integrations/langchainCallback.d.ts.map +1 -1
  281. package/lib/integrations/openAiTracer.d.mts +3 -0
  282. package/lib/integrations/openAiTracer.d.mts.map +1 -0
  283. package/lib/integrations/openAiTracer.d.ts.map +1 -1
  284. package/lib/integrations/openAiTracer.js +2 -4
  285. package/lib/integrations/openAiTracer.js.map +1 -1
  286. package/lib/integrations/tracedTool.d.mts +66 -0
  287. package/lib/integrations/tracedTool.d.mts.map +1 -0
  288. package/lib/integrations/tracedTool.d.ts.map +1 -1
  289. package/lib/integrations/tracedTool.js +0 -1
  290. package/lib/integrations/tracedTool.js.map +1 -1
  291. package/lib/integrations/tracedTool.mjs +0 -1
  292. package/lib/integrations/tracedTool.mjs.map +1 -1
  293. package/lib/tracing/steps.d.mts +174 -0
  294. package/lib/tracing/steps.d.mts.map +1 -0
  295. package/lib/tracing/tracer.d.mts +94 -0
  296. package/lib/tracing/tracer.d.mts.map +1 -0
  297. package/lib/tracing/tracer.d.ts.map +1 -1
  298. package/lib/tracing/tracer.js +2 -4
  299. package/lib/tracing/tracer.js.map +1 -1
  300. package/lib/tracing/traces.d.mts +9 -0
  301. package/lib/tracing/traces.d.mts.map +1 -0
  302. package/lib/tracing/traces.d.ts.map +1 -1
  303. package/package.json +114 -65
  304. package/resource.d.mts +2 -0
  305. package/resource.d.mts.map +1 -0
  306. package/resource.d.ts +1 -5
  307. package/resource.d.ts.map +1 -1
  308. package/resource.js +3 -8
  309. package/resource.js.map +1 -1
  310. package/resource.mjs +1 -6
  311. package/resource.mjs.map +1 -1
  312. package/resources/commits/commits.d.mts +139 -0
  313. package/resources/commits/commits.d.mts.map +1 -0
  314. package/resources/commits/commits.d.ts +4 -3
  315. package/resources/commits/commits.d.ts.map +1 -1
  316. package/resources/commits/commits.js +6 -37
  317. package/resources/commits/commits.js.map +1 -1
  318. package/resources/commits/commits.mjs +4 -3
  319. package/resources/commits/commits.mjs.map +1 -1
  320. package/resources/commits/index.d.mts +3 -0
  321. package/resources/commits/index.d.mts.map +1 -0
  322. package/resources/commits/index.d.ts.map +1 -1
  323. package/resources/commits/test-results.d.mts +214 -0
  324. package/resources/commits/test-results.d.mts.map +1 -0
  325. package/resources/commits/test-results.d.ts +4 -4
  326. package/resources/commits/test-results.d.ts.map +1 -1
  327. package/resources/commits/test-results.js +7 -7
  328. package/resources/commits/test-results.js.map +1 -1
  329. package/resources/commits/test-results.mjs +7 -7
  330. package/resources/commits/test-results.mjs.map +1 -1
  331. package/resources/commits.d.mts +2 -0
  332. package/resources/commits.d.mts.map +1 -0
  333. package/resources/commits.d.ts.map +1 -1
  334. package/resources/commits.js +2 -15
  335. package/resources/commits.js.map +1 -1
  336. package/resources/index.d.mts +5 -0
  337. package/resources/index.d.mts.map +1 -0
  338. package/resources/index.d.ts.map +1 -1
  339. package/resources/inference-pipelines/data.d.mts +257 -0
  340. package/resources/inference-pipelines/data.d.mts.map +1 -0
  341. package/resources/inference-pipelines/data.d.ts +4 -3
  342. package/resources/inference-pipelines/data.d.ts.map +1 -1
  343. package/resources/inference-pipelines/data.js +7 -3
  344. package/resources/inference-pipelines/data.js.map +1 -1
  345. package/resources/inference-pipelines/data.mjs +7 -3
  346. package/resources/inference-pipelines/data.mjs.map +1 -1
  347. package/resources/inference-pipelines/index.d.mts +5 -0
  348. package/resources/inference-pipelines/index.d.mts.map +1 -0
  349. package/resources/inference-pipelines/index.d.ts.map +1 -1
  350. package/resources/inference-pipelines/inference-pipelines.d.mts +507 -0
  351. package/resources/inference-pipelines/inference-pipelines.d.mts.map +1 -0
  352. package/resources/inference-pipelines/inference-pipelines.d.ts +6 -7
  353. package/resources/inference-pipelines/inference-pipelines.d.ts.map +1 -1
  354. package/resources/inference-pipelines/inference-pipelines.js +36 -51
  355. package/resources/inference-pipelines/inference-pipelines.js.map +1 -1
  356. package/resources/inference-pipelines/inference-pipelines.mjs +32 -15
  357. package/resources/inference-pipelines/inference-pipelines.mjs.map +1 -1
  358. package/resources/inference-pipelines/rows.d.mts +65 -0
  359. package/resources/inference-pipelines/rows.d.mts.map +1 -0
  360. package/resources/inference-pipelines/rows.d.ts +4 -3
  361. package/resources/inference-pipelines/rows.d.ts.map +1 -1
  362. package/resources/inference-pipelines/rows.js +4 -3
  363. package/resources/inference-pipelines/rows.js.map +1 -1
  364. package/resources/inference-pipelines/rows.mjs +4 -3
  365. package/resources/inference-pipelines/rows.mjs.map +1 -1
  366. package/resources/inference-pipelines/test-results.d.mts +218 -0
  367. package/resources/inference-pipelines/test-results.d.mts.map +1 -0
  368. package/resources/inference-pipelines/test-results.d.ts +4 -4
  369. package/resources/inference-pipelines/test-results.d.ts.map +1 -1
  370. package/resources/inference-pipelines/test-results.js +15 -7
  371. package/resources/inference-pipelines/test-results.js.map +1 -1
  372. package/resources/inference-pipelines/test-results.mjs +15 -7
  373. package/resources/inference-pipelines/test-results.mjs.map +1 -1
  374. package/resources/inference-pipelines.d.mts +2 -0
  375. package/resources/inference-pipelines.d.mts.map +1 -0
  376. package/resources/inference-pipelines.d.ts.map +1 -1
  377. package/resources/inference-pipelines.js +2 -15
  378. package/resources/inference-pipelines.js.map +1 -1
  379. package/resources/projects/commits.d.mts +323 -0
  380. package/resources/projects/commits.d.mts.map +1 -0
  381. package/resources/projects/commits.d.ts +5 -5
  382. package/resources/projects/commits.d.ts.map +1 -1
  383. package/resources/projects/commits.js +16 -9
  384. package/resources/projects/commits.js.map +1 -1
  385. package/resources/projects/commits.mjs +16 -9
  386. package/resources/projects/commits.mjs.map +1 -1
  387. package/resources/projects/index.d.mts +5 -0
  388. package/resources/projects/index.d.mts.map +1 -0
  389. package/resources/projects/index.d.ts.map +1 -1
  390. package/resources/projects/inference-pipelines.d.mts +533 -0
  391. package/resources/projects/inference-pipelines.d.mts.map +1 -0
  392. package/resources/projects/inference-pipelines.d.ts +5 -5
  393. package/resources/projects/inference-pipelines.d.ts.map +1 -1
  394. package/resources/projects/inference-pipelines.js +17 -9
  395. package/resources/projects/inference-pipelines.js.map +1 -1
  396. package/resources/projects/inference-pipelines.mjs +17 -9
  397. package/resources/projects/inference-pipelines.mjs.map +1 -1
  398. package/resources/projects/projects.d.mts +249 -0
  399. package/resources/projects/projects.d.mts.map +1 -0
  400. package/resources/projects/projects.d.ts +5 -5
  401. package/resources/projects/projects.d.ts.map +1 -1
  402. package/resources/projects/projects.js +13 -41
  403. package/resources/projects/projects.js.map +1 -1
  404. package/resources/projects/projects.mjs +9 -5
  405. package/resources/projects/projects.mjs.map +1 -1
  406. package/resources/projects/tests.d.mts +501 -0
  407. package/resources/projects/tests.d.mts.map +1 -0
  408. package/resources/projects/tests.d.ts +6 -6
  409. package/resources/projects/tests.d.ts.map +1 -1
  410. package/resources/projects/tests.js +18 -11
  411. package/resources/projects/tests.js.map +1 -1
  412. package/resources/projects/tests.mjs +18 -11
  413. package/resources/projects/tests.mjs.map +1 -1
  414. package/resources/projects.d.mts +2 -0
  415. package/resources/projects.d.mts.map +1 -0
  416. package/resources/projects.d.ts.map +1 -1
  417. package/resources/projects.js +2 -15
  418. package/resources/projects.js.map +1 -1
  419. package/resources/storage/index.d.mts +3 -0
  420. package/resources/storage/index.d.mts.map +1 -0
  421. package/resources/storage/index.d.ts.map +1 -1
  422. package/resources/storage/presigned-url.d.mts +33 -0
  423. package/resources/storage/presigned-url.d.mts.map +1 -0
  424. package/resources/storage/presigned-url.d.ts +4 -3
  425. package/resources/storage/presigned-url.d.ts.map +1 -1
  426. package/resources/storage/presigned-url.js +1 -1
  427. package/resources/storage/presigned-url.js.map +1 -1
  428. package/resources/storage/presigned-url.mjs +1 -1
  429. package/resources/storage/presigned-url.mjs.map +1 -1
  430. package/resources/storage/storage.d.mts +10 -0
  431. package/resources/storage/storage.d.mts.map +1 -0
  432. package/resources/storage/storage.d.ts +1 -1
  433. package/resources/storage/storage.d.ts.map +1 -1
  434. package/resources/storage/storage.js +3 -35
  435. package/resources/storage/storage.js.map +1 -1
  436. package/resources/storage/storage.mjs +1 -1
  437. package/resources/storage.d.mts +2 -0
  438. package/resources/storage.d.mts.map +1 -0
  439. package/resources/storage.d.ts.map +1 -1
  440. package/resources/storage.js +2 -15
  441. package/resources/storage.js.map +1 -1
  442. package/resources.d.mts +2 -0
  443. package/resources.d.mts.map +1 -0
  444. package/resources.d.ts.map +1 -1
  445. package/resources.js +2 -15
  446. package/resources.js.map +1 -1
  447. package/src/api-promise.ts +2 -0
  448. package/src/client.ts +756 -0
  449. package/src/core/README.md +3 -0
  450. package/src/core/api-promise.ts +92 -0
  451. package/src/core/error.ts +130 -0
  452. package/src/core/resource.ts +11 -0
  453. package/src/core/uploads.ts +2 -0
  454. package/src/error.ts +2 -130
  455. package/src/index.ts +5 -233
  456. package/src/internal/README.md +3 -0
  457. package/src/internal/builtin-types.ts +93 -0
  458. package/src/internal/detect-platform.ts +196 -0
  459. package/src/internal/errors.ts +33 -0
  460. package/src/internal/headers.ts +97 -0
  461. package/src/internal/parse.ts +50 -0
  462. package/src/internal/qs/formats.ts +2 -1
  463. package/src/internal/qs/stringify.ts +17 -20
  464. package/src/internal/qs/utils.ts +14 -14
  465. package/src/internal/request-options.ts +91 -0
  466. package/src/internal/shim-types.ts +26 -0
  467. package/src/internal/shims.ts +107 -0
  468. package/src/internal/to-file.ts +154 -0
  469. package/src/internal/types.ts +95 -0
  470. package/src/internal/uploads.ts +187 -0
  471. package/src/internal/utils/base64.ts +40 -0
  472. package/src/internal/utils/bytes.ts +32 -0
  473. package/src/internal/utils/env.ts +18 -0
  474. package/src/internal/utils/log.ts +126 -0
  475. package/src/internal/utils/path.ts +88 -0
  476. package/src/internal/utils/sleep.ts +3 -0
  477. package/src/internal/utils/uuid.ts +17 -0
  478. package/src/internal/utils/values.ts +105 -0
  479. package/src/internal/utils.ts +8 -0
  480. package/src/lib/integrations/tracedTool.ts +0 -1
  481. package/src/resource.ts +2 -11
  482. package/src/resources/commits/commits.ts +6 -4
  483. package/src/resources/commits/test-results.ts +9 -17
  484. package/src/resources/inference-pipelines/data.ts +11 -6
  485. package/src/resources/inference-pipelines/inference-pipelines.ts +18 -40
  486. package/src/resources/inference-pipelines/rows.ts +8 -6
  487. package/src/resources/inference-pipelines/test-results.ts +9 -17
  488. package/src/resources/projects/commits.ts +13 -21
  489. package/src/resources/projects/inference-pipelines.ts +13 -21
  490. package/src/resources/projects/projects.ts +7 -12
  491. package/src/resources/projects/tests.ts +17 -25
  492. package/src/resources/storage/presigned-url.ts +4 -6
  493. package/src/resources/storage/storage.ts +1 -1
  494. package/src/tsconfig.json +2 -2
  495. package/src/uploads.ts +2 -256
  496. package/src/version.ts +1 -1
  497. package/uploads.d.mts +2 -0
  498. package/uploads.d.mts.map +1 -0
  499. package/uploads.d.ts +1 -74
  500. package/uploads.d.ts.map +1 -1
  501. package/uploads.js +3 -167
  502. package/uploads.js.map +1 -1
  503. package/uploads.mjs +1 -156
  504. package/uploads.mjs.map +1 -1
  505. package/version.d.mts +2 -0
  506. package/version.d.mts.map +1 -0
  507. package/version.d.ts +1 -1
  508. package/version.js +1 -1
  509. package/version.mjs +1 -1
  510. package/_shims/MultipartBody.d.ts +0 -9
  511. package/_shims/MultipartBody.d.ts.map +0 -1
  512. package/_shims/MultipartBody.js +0 -16
  513. package/_shims/MultipartBody.js.map +0 -1
  514. package/_shims/MultipartBody.mjs +0 -12
  515. package/_shims/MultipartBody.mjs.map +0 -1
  516. package/_shims/README.md +0 -46
  517. package/_shims/auto/runtime-bun.d.ts +0 -5
  518. package/_shims/auto/runtime-bun.d.ts.map +0 -1
  519. package/_shims/auto/runtime-bun.js +0 -21
  520. package/_shims/auto/runtime-bun.js.map +0 -1
  521. package/_shims/auto/runtime-bun.mjs +0 -2
  522. package/_shims/auto/runtime-bun.mjs.map +0 -1
  523. package/_shims/auto/runtime-node.d.ts +0 -5
  524. package/_shims/auto/runtime-node.d.ts.map +0 -1
  525. package/_shims/auto/runtime-node.js +0 -21
  526. package/_shims/auto/runtime-node.js.map +0 -1
  527. package/_shims/auto/runtime-node.mjs +0 -2
  528. package/_shims/auto/runtime-node.mjs.map +0 -1
  529. package/_shims/auto/runtime.d.ts +0 -5
  530. package/_shims/auto/runtime.d.ts.map +0 -1
  531. package/_shims/auto/runtime.js +0 -21
  532. package/_shims/auto/runtime.js.map +0 -1
  533. package/_shims/auto/runtime.mjs +0 -2
  534. package/_shims/auto/runtime.mjs.map +0 -1
  535. package/_shims/auto/types-node.d.ts +0 -5
  536. package/_shims/auto/types-node.d.ts.map +0 -1
  537. package/_shims/auto/types-node.js +0 -21
  538. package/_shims/auto/types-node.js.map +0 -1
  539. package/_shims/auto/types-node.mjs +0 -2
  540. package/_shims/auto/types-node.mjs.map +0 -1
  541. package/_shims/auto/types.d.ts +0 -101
  542. package/_shims/auto/types.js +0 -3
  543. package/_shims/auto/types.mjs +0 -3
  544. package/_shims/bun-runtime.d.ts +0 -6
  545. package/_shims/bun-runtime.d.ts.map +0 -1
  546. package/_shims/bun-runtime.js +0 -13
  547. package/_shims/bun-runtime.js.map +0 -1
  548. package/_shims/bun-runtime.mjs +0 -10
  549. package/_shims/bun-runtime.mjs.map +0 -1
  550. package/_shims/index.d.ts +0 -83
  551. package/_shims/index.js +0 -17
  552. package/_shims/index.mjs +0 -11
  553. package/_shims/manual-types.d.ts +0 -12
  554. package/_shims/manual-types.js +0 -3
  555. package/_shims/manual-types.mjs +0 -3
  556. package/_shims/node-runtime.d.ts +0 -3
  557. package/_shims/node-runtime.d.ts.map +0 -1
  558. package/_shims/node-runtime.js +0 -98
  559. package/_shims/node-runtime.js.map +0 -1
  560. package/_shims/node-runtime.mjs +0 -56
  561. package/_shims/node-runtime.mjs.map +0 -1
  562. package/_shims/node-types.d.ts +0 -42
  563. package/_shims/node-types.js +0 -3
  564. package/_shims/node-types.mjs +0 -3
  565. package/_shims/registry.d.ts +0 -37
  566. package/_shims/registry.d.ts.map +0 -1
  567. package/_shims/registry.js +0 -41
  568. package/_shims/registry.js.map +0 -1
  569. package/_shims/registry.mjs +0 -37
  570. package/_shims/registry.mjs.map +0 -1
  571. package/_shims/web-runtime.d.ts +0 -5
  572. package/_shims/web-runtime.d.ts.map +0 -1
  573. package/_shims/web-runtime.js +0 -77
  574. package/_shims/web-runtime.js.map +0 -1
  575. package/_shims/web-runtime.mjs +0 -71
  576. package/_shims/web-runtime.mjs.map +0 -1
  577. package/_shims/web-types.d.ts +0 -83
  578. package/_shims/web-types.js +0 -3
  579. package/_shims/web-types.mjs +0 -3
  580. package/core.d.ts +0 -253
  581. package/core.d.ts.map +0 -1
  582. package/core.js +0 -924
  583. package/core.js.map +0 -1
  584. package/core.mjs +0 -892
  585. package/core.mjs.map +0 -1
  586. package/shims/node.d.ts +0 -26
  587. package/shims/node.d.ts.map +0 -1
  588. package/shims/node.js +0 -6
  589. package/shims/node.js.map +0 -1
  590. package/shims/node.mjs +0 -4
  591. package/shims/node.mjs.map +0 -1
  592. package/shims/web.d.ts +0 -26
  593. package/shims/web.d.ts.map +0 -1
  594. package/shims/web.js +0 -6
  595. package/shims/web.js.map +0 -1
  596. package/shims/web.mjs +0 -4
  597. package/shims/web.mjs.map +0 -1
  598. package/src/_shims/MultipartBody.ts +0 -9
  599. package/src/_shims/README.md +0 -46
  600. package/src/_shims/auto/runtime-bun.ts +0 -4
  601. package/src/_shims/auto/runtime-node.ts +0 -4
  602. package/src/_shims/auto/runtime.ts +0 -4
  603. package/src/_shims/auto/types-node.ts +0 -4
  604. package/src/_shims/auto/types.d.ts +0 -101
  605. package/src/_shims/auto/types.js +0 -3
  606. package/src/_shims/auto/types.mjs +0 -3
  607. package/src/_shims/bun-runtime.ts +0 -14
  608. package/src/_shims/index.d.ts +0 -83
  609. package/src/_shims/index.js +0 -17
  610. package/src/_shims/index.mjs +0 -11
  611. package/src/_shims/manual-types.d.ts +0 -12
  612. package/src/_shims/manual-types.js +0 -3
  613. package/src/_shims/manual-types.mjs +0 -3
  614. package/src/_shims/node-runtime.ts +0 -81
  615. package/src/_shims/node-types.d.ts +0 -42
  616. package/src/_shims/node-types.js +0 -3
  617. package/src/_shims/node-types.mjs +0 -3
  618. package/src/_shims/registry.ts +0 -67
  619. package/src/_shims/web-runtime.ts +0 -103
  620. package/src/_shims/web-types.d.ts +0 -83
  621. package/src/_shims/web-types.js +0 -3
  622. package/src/_shims/web-types.mjs +0 -3
  623. package/src/core.ts +0 -1236
  624. package/src/shims/node.ts +0 -50
  625. package/src/shims/web.ts +0 -50
package/client.d.ts ADDED
@@ -0,0 +1,186 @@
1
+ import type { RequestInit, RequestInfo } from "./internal/builtin-types.js";
2
+ import type { PromiseOrValue, MergedRequestInit, FinalizedRequestInit } from "./internal/types.js";
3
+ export type { Logger, LogLevel } from "./internal/utils/log.js";
4
+ import * as Opts from "./internal/request-options.js";
5
+ import * as Errors from "./core/error.js";
6
+ import * as Uploads from "./core/uploads.js";
7
+ import * as API from "./resources/index.js";
8
+ import { APIPromise } from "./core/api-promise.js";
9
+ import { CommitRetrieveResponse, Commits } from "./resources/commits/commits.js";
10
+ import { InferencePipelineRetrieveParams, InferencePipelineRetrieveResponse, InferencePipelineUpdateParams, InferencePipelineUpdateResponse, InferencePipelines } from "./resources/inference-pipelines/inference-pipelines.js";
11
+ import { ProjectCreateParams, ProjectCreateResponse, ProjectListParams, ProjectListResponse, Projects } from "./resources/projects/projects.js";
12
+ import { Storage } from "./resources/storage/storage.js";
13
+ import { type Fetch } from "./internal/builtin-types.js";
14
+ import { HeadersLike, NullableHeaders } from "./internal/headers.js";
15
+ import { FinalRequestOptions, RequestOptions } from "./internal/request-options.js";
16
+ import { type LogLevel, type Logger } from "./internal/utils/log.js";
17
+ export interface ClientOptions {
18
+ /**
19
+ * Defaults to process.env['OPENLAYER_API_KEY'].
20
+ */
21
+ apiKey?: string | null | undefined;
22
+ /**
23
+ * Override the default base URL for the API, e.g., "https://api.example.com/v2/"
24
+ *
25
+ * Defaults to process.env['OPENLAYER_BASE_URL'].
26
+ */
27
+ baseURL?: string | null | undefined;
28
+ /**
29
+ * The maximum amount of time (in milliseconds) that the client should wait for a response
30
+ * from the server before timing out a single request.
31
+ *
32
+ * Note that request timeouts are retried by default, so in a worst-case scenario you may wait
33
+ * much longer than this timeout before the promise succeeds or fails.
34
+ *
35
+ * @unit milliseconds
36
+ */
37
+ timeout?: number | undefined;
38
+ /**
39
+ * Additional `RequestInit` options to be passed to `fetch` calls.
40
+ * Properties will be overridden by per-request `fetchOptions`.
41
+ */
42
+ fetchOptions?: MergedRequestInit | undefined;
43
+ /**
44
+ * Specify a custom `fetch` function implementation.
45
+ *
46
+ * If not provided, we expect that `fetch` is defined globally.
47
+ */
48
+ fetch?: Fetch | undefined;
49
+ /**
50
+ * The maximum number of times that the client will retry a request in case of a
51
+ * temporary failure, like a network error or a 5XX error from the server.
52
+ *
53
+ * @default 2
54
+ */
55
+ maxRetries?: number | undefined;
56
+ /**
57
+ * Default headers to include with every request to the API.
58
+ *
59
+ * These can be removed in individual requests by explicitly setting the
60
+ * header to `null` in request options.
61
+ */
62
+ defaultHeaders?: HeadersLike | undefined;
63
+ /**
64
+ * Default query parameters to include with every request to the API.
65
+ *
66
+ * These can be removed in individual requests by explicitly setting the
67
+ * param to `undefined` in request options.
68
+ */
69
+ defaultQuery?: Record<string, string | undefined> | undefined;
70
+ /**
71
+ * Set the log level.
72
+ *
73
+ * Defaults to process.env['OPENLAYER_LOG'] or 'warn' if it isn't set.
74
+ */
75
+ logLevel?: LogLevel | undefined;
76
+ /**
77
+ * Set the logger.
78
+ *
79
+ * Defaults to globalThis.console.
80
+ */
81
+ logger?: Logger | undefined;
82
+ }
83
+ /**
84
+ * API Client for interfacing with the Openlayer API.
85
+ */
86
+ export declare class Openlayer {
87
+ #private;
88
+ apiKey: string | null;
89
+ baseURL: string;
90
+ maxRetries: number;
91
+ timeout: number;
92
+ logger: Logger | undefined;
93
+ logLevel: LogLevel | undefined;
94
+ fetchOptions: MergedRequestInit | undefined;
95
+ private fetch;
96
+ protected idempotencyHeader?: string;
97
+ private _options;
98
+ /**
99
+ * API Client for interfacing with the Openlayer API.
100
+ *
101
+ * @param {string | null | undefined} [opts.apiKey=process.env['OPENLAYER_API_KEY'] ?? null]
102
+ * @param {string} [opts.baseURL=process.env['OPENLAYER_BASE_URL'] ?? https://api.openlayer.com/v1] - Override the default base URL for the API.
103
+ * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
104
+ * @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
105
+ * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
106
+ * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
107
+ * @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
108
+ * @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
109
+ */
110
+ constructor({ baseURL, apiKey, ...opts }?: ClientOptions);
111
+ /**
112
+ * Create a new client instance re-using the same options given to the current client with optional overriding.
113
+ */
114
+ withOptions(options: Partial<ClientOptions>): this;
115
+ protected defaultQuery(): Record<string, string | undefined> | undefined;
116
+ protected validateHeaders({ values, nulls }: NullableHeaders): void;
117
+ protected authHeaders(opts: FinalRequestOptions): Promise<NullableHeaders | undefined>;
118
+ protected stringifyQuery(query: Record<string, unknown>): string;
119
+ private getUserAgent;
120
+ protected defaultIdempotencyKey(): string;
121
+ protected makeStatusError(status: number, error: Object, message: string | undefined, headers: Headers): Errors.APIError;
122
+ buildURL(path: string, query: Record<string, unknown> | null | undefined, defaultBaseURL?: string | undefined): string;
123
+ /**
124
+ * Used as a callback for mutating the given `FinalRequestOptions` object.
125
+ */
126
+ protected prepareOptions(options: FinalRequestOptions): Promise<void>;
127
+ /**
128
+ * Used as a callback for mutating the given `RequestInit` object.
129
+ *
130
+ * This is useful for cases where you want to add certain headers based off of
131
+ * the request properties, e.g. `method` or `url`.
132
+ */
133
+ protected prepareRequest(request: RequestInit, { url, options }: {
134
+ url: string;
135
+ options: FinalRequestOptions;
136
+ }): Promise<void>;
137
+ get<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
138
+ post<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
139
+ patch<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
140
+ put<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
141
+ delete<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
142
+ private methodRequest;
143
+ request<Rsp>(options: PromiseOrValue<FinalRequestOptions>, remainingRetries?: number | null): APIPromise<Rsp>;
144
+ private makeRequest;
145
+ fetchWithTimeout(url: RequestInfo, init: RequestInit | undefined, ms: number, controller: AbortController): Promise<Response>;
146
+ private shouldRetry;
147
+ private retryRequest;
148
+ private calculateDefaultRetryTimeoutMillis;
149
+ buildRequest(inputOptions: FinalRequestOptions, { retryCount }?: {
150
+ retryCount?: number;
151
+ }): Promise<{
152
+ req: FinalizedRequestInit;
153
+ url: string;
154
+ timeout: number;
155
+ }>;
156
+ private buildHeaders;
157
+ private buildBody;
158
+ static Openlayer: typeof Openlayer;
159
+ static DEFAULT_TIMEOUT: number;
160
+ static OpenlayerError: typeof Errors.OpenlayerError;
161
+ static APIError: typeof Errors.APIError;
162
+ static APIConnectionError: typeof Errors.APIConnectionError;
163
+ static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
164
+ static APIUserAbortError: typeof Errors.APIUserAbortError;
165
+ static NotFoundError: typeof Errors.NotFoundError;
166
+ static ConflictError: typeof Errors.ConflictError;
167
+ static RateLimitError: typeof Errors.RateLimitError;
168
+ static BadRequestError: typeof Errors.BadRequestError;
169
+ static AuthenticationError: typeof Errors.AuthenticationError;
170
+ static InternalServerError: typeof Errors.InternalServerError;
171
+ static PermissionDeniedError: typeof Errors.PermissionDeniedError;
172
+ static UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
173
+ static toFile: typeof Uploads.toFile;
174
+ projects: API.Projects;
175
+ commits: API.Commits;
176
+ inferencePipelines: API.InferencePipelines;
177
+ storage: API.Storage;
178
+ }
179
+ export declare namespace Openlayer {
180
+ export type RequestOptions = Opts.RequestOptions;
181
+ export { Projects as Projects, type ProjectCreateResponse as ProjectCreateResponse, type ProjectListResponse as ProjectListResponse, type ProjectCreateParams as ProjectCreateParams, type ProjectListParams as ProjectListParams, };
182
+ export { Commits as Commits, type CommitRetrieveResponse as CommitRetrieveResponse };
183
+ export { InferencePipelines as InferencePipelines, type InferencePipelineRetrieveResponse as InferencePipelineRetrieveResponse, type InferencePipelineUpdateResponse as InferencePipelineUpdateResponse, type InferencePipelineRetrieveParams as InferencePipelineRetrieveParams, type InferencePipelineUpdateParams as InferencePipelineUpdateParams, };
184
+ export { Storage as Storage };
185
+ }
186
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["src/client.ts"],"names":[],"mappings":"OAEO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAY;OAC3C,KAAK,EAAc,cAAc,EAAE,iBAAiB,EAAE,oBAAoB,EAAE;YAIvE,EAAE,MAAM,EAAE,QAAQ,EAAE;OAKzB,KAAK,IAAI;OAGT,KAAK,MAAM;OACX,KAAK,OAAO;OACZ,KAAK,GAAG;OACR,EAAE,UAAU,EAAE;OACd,EAAE,sBAAsB,EAAE,OAAO,EAAE;OACnC,EACL,+BAA+B,EAC/B,iCAAiC,EACjC,6BAA6B,EAC7B,+BAA+B,EAC/B,kBAAkB,EACnB;OACM,EACL,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,QAAQ,EACT;OACM,EAAE,OAAO,EAAE;OACX,EAAE,KAAK,KAAK,EAAE;OACd,EAAE,W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AAI,iCAAiC,EAC3E,KAAK,+BAA+B,IAAI,+BAA+B,EACvE,KAAK,+BAA+B,IAAI,+BAA+B,EACvE,KAAK,6BAA6B,IAAI,6BAA6B,GACpE,CAAC;IAEF,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,CAAC;CAC/B"}
package/client.js ADDED
@@ -0,0 +1,463 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ var _Openlayer_instances, _a, _Openlayer_encoder, _Openlayer_baseURLOverridden;
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.Openlayer = void 0;
6
+ const tslib_1 = require("./internal/tslib.js");
7
+ const uuid_1 = require("./internal/utils/uuid.js");
8
+ const values_1 = require("./internal/utils/values.js");
9
+ const sleep_1 = require("./internal/utils/sleep.js");
10
+ const errors_1 = require("./internal/errors.js");
11
+ const detect_platform_1 = require("./internal/detect-platform.js");
12
+ const Shims = tslib_1.__importStar(require("./internal/shims.js"));
13
+ const Opts = tslib_1.__importStar(require("./internal/request-options.js"));
14
+ const qs = tslib_1.__importStar(require("./internal/qs/index.js"));
15
+ const version_1 = require("./version.js");
16
+ const Errors = tslib_1.__importStar(require("./core/error.js"));
17
+ const Uploads = tslib_1.__importStar(require("./core/uploads.js"));
18
+ const API = tslib_1.__importStar(require("./resources/index.js"));
19
+ const api_promise_1 = require("./core/api-promise.js");
20
+ const commits_1 = require("./resources/commits/commits.js");
21
+ const inference_pipelines_1 = require("./resources/inference-pipelines/inference-pipelines.js");
22
+ const projects_1 = require("./resources/projects/projects.js");
23
+ const storage_1 = require("./resources/storage/storage.js");
24
+ const headers_1 = require("./internal/headers.js");
25
+ const env_1 = require("./internal/utils/env.js");
26
+ const log_1 = require("./internal/utils/log.js");
27
+ const values_2 = require("./internal/utils/values.js");
28
+ /**
29
+ * API Client for interfacing with the Openlayer API.
30
+ */
31
+ class Openlayer {
32
+ /**
33
+ * API Client for interfacing with the Openlayer API.
34
+ *
35
+ * @param {string | null | undefined} [opts.apiKey=process.env['OPENLAYER_API_KEY'] ?? null]
36
+ * @param {string} [opts.baseURL=process.env['OPENLAYER_BASE_URL'] ?? https://api.openlayer.com/v1] - Override the default base URL for the API.
37
+ * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
38
+ * @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
39
+ * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
40
+ * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
41
+ * @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
42
+ * @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
43
+ */
44
+ constructor({ baseURL = (0, env_1.readEnv)('OPENLAYER_BASE_URL'), apiKey = (0, env_1.readEnv)('OPENLAYER_API_KEY') ?? null, ...opts } = {}) {
45
+ _Openlayer_instances.add(this);
46
+ _Openlayer_encoder.set(this, void 0);
47
+ this.projects = new API.Projects(this);
48
+ this.commits = new API.Commits(this);
49
+ this.inferencePipelines = new API.InferencePipelines(this);
50
+ this.storage = new API.Storage(this);
51
+ const options = {
52
+ apiKey,
53
+ ...opts,
54
+ baseURL: baseURL || `https://api.openlayer.com/v1`,
55
+ };
56
+ this.baseURL = options.baseURL;
57
+ this.timeout = options.timeout ?? _a.DEFAULT_TIMEOUT /* 1 minute */;
58
+ this.logger = options.logger ?? console;
59
+ const defaultLogLevel = 'warn';
60
+ // Set default logLevel early so that we can log a warning in parseLogLevel.
61
+ this.logLevel = defaultLogLevel;
62
+ this.logLevel =
63
+ (0, log_1.parseLogLevel)(options.logLevel, 'ClientOptions.logLevel', this) ??
64
+ (0, log_1.parseLogLevel)((0, env_1.readEnv)('OPENLAYER_LOG'), "process.env['OPENLAYER_LOG']", this) ??
65
+ defaultLogLevel;
66
+ this.fetchOptions = options.fetchOptions;
67
+ this.maxRetries = options.maxRetries ?? 2;
68
+ this.fetch = options.fetch ?? Shims.getDefaultFetch();
69
+ tslib_1.__classPrivateFieldSet(this, _Openlayer_encoder, Opts.FallbackEncoder, "f");
70
+ this._options = options;
71
+ this.apiKey = apiKey;
72
+ }
73
+ /**
74
+ * Create a new client instance re-using the same options given to the current client with optional overriding.
75
+ */
76
+ withOptions(options) {
77
+ const client = new this.constructor({
78
+ ...this._options,
79
+ baseURL: this.baseURL,
80
+ maxRetries: this.maxRetries,
81
+ timeout: this.timeout,
82
+ logger: this.logger,
83
+ logLevel: this.logLevel,
84
+ fetch: this.fetch,
85
+ fetchOptions: this.fetchOptions,
86
+ apiKey: this.apiKey,
87
+ ...options,
88
+ });
89
+ return client;
90
+ }
91
+ defaultQuery() {
92
+ return this._options.defaultQuery;
93
+ }
94
+ validateHeaders({ values, nulls }) {
95
+ if (this.apiKey && values.get('authorization')) {
96
+ return;
97
+ }
98
+ if (nulls.has('authorization')) {
99
+ return;
100
+ }
101
+ throw new Error('Could not resolve authentication method. Expected the apiKey to be set. Or for the "Authorization" headers to be explicitly omitted');
102
+ }
103
+ async authHeaders(opts) {
104
+ if (this.apiKey == null) {
105
+ return undefined;
106
+ }
107
+ return (0, headers_1.buildHeaders)([{ Authorization: `Bearer ${this.apiKey}` }]);
108
+ }
109
+ stringifyQuery(query) {
110
+ return qs.stringify(query, { arrayFormat: 'comma' });
111
+ }
112
+ getUserAgent() {
113
+ return `${this.constructor.name}/JS ${version_1.VERSION}`;
114
+ }
115
+ defaultIdempotencyKey() {
116
+ return `stainless-node-retry-${(0, uuid_1.uuid4)()}`;
117
+ }
118
+ makeStatusError(status, error, message, headers) {
119
+ return Errors.APIError.generate(status, error, message, headers);
120
+ }
121
+ buildURL(path, query, defaultBaseURL) {
122
+ const baseURL = (!tslib_1.__classPrivateFieldGet(this, _Openlayer_instances, "m", _Openlayer_baseURLOverridden).call(this) && defaultBaseURL) || this.baseURL;
123
+ const url = (0, values_1.isAbsoluteURL)(path) ?
124
+ new URL(path)
125
+ : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
126
+ const defaultQuery = this.defaultQuery();
127
+ if (!(0, values_2.isEmptyObj)(defaultQuery)) {
128
+ query = { ...defaultQuery, ...query };
129
+ }
130
+ if (typeof query === 'object' && query && !Array.isArray(query)) {
131
+ url.search = this.stringifyQuery(query);
132
+ }
133
+ return url.toString();
134
+ }
135
+ /**
136
+ * Used as a callback for mutating the given `FinalRequestOptions` object.
137
+ */
138
+ async prepareOptions(options) { }
139
+ /**
140
+ * Used as a callback for mutating the given `RequestInit` object.
141
+ *
142
+ * This is useful for cases where you want to add certain headers based off of
143
+ * the request properties, e.g. `method` or `url`.
144
+ */
145
+ async prepareRequest(request, { url, options }) { }
146
+ get(path, opts) {
147
+ return this.methodRequest('get', path, opts);
148
+ }
149
+ post(path, opts) {
150
+ return this.methodRequest('post', path, opts);
151
+ }
152
+ patch(path, opts) {
153
+ return this.methodRequest('patch', path, opts);
154
+ }
155
+ put(path, opts) {
156
+ return this.methodRequest('put', path, opts);
157
+ }
158
+ delete(path, opts) {
159
+ return this.methodRequest('delete', path, opts);
160
+ }
161
+ methodRequest(method, path, opts) {
162
+ return this.request(Promise.resolve(opts).then((opts) => {
163
+ return { method, path, ...opts };
164
+ }));
165
+ }
166
+ request(options, remainingRetries = null) {
167
+ return new api_promise_1.APIPromise(this, this.makeRequest(options, remainingRetries, undefined));
168
+ }
169
+ async makeRequest(optionsInput, retriesRemaining, retryOfRequestLogID) {
170
+ const options = await optionsInput;
171
+ const maxRetries = options.maxRetries ?? this.maxRetries;
172
+ if (retriesRemaining == null) {
173
+ retriesRemaining = maxRetries;
174
+ }
175
+ await this.prepareOptions(options);
176
+ const { req, url, timeout } = await this.buildRequest(options, {
177
+ retryCount: maxRetries - retriesRemaining,
178
+ });
179
+ await this.prepareRequest(req, { url, options });
180
+ /** Not an API request ID, just for correlating local log entries. */
181
+ const requestLogID = 'log_' + ((Math.random() * (1 << 24)) | 0).toString(16).padStart(6, '0');
182
+ const retryLogStr = retryOfRequestLogID === undefined ? '' : `, retryOf: ${retryOfRequestLogID}`;
183
+ const startTime = Date.now();
184
+ (0, log_1.loggerFor)(this).debug(`[${requestLogID}] sending request`, (0, log_1.formatRequestDetails)({
185
+ retryOfRequestLogID,
186
+ method: options.method,
187
+ url,
188
+ options,
189
+ headers: req.headers,
190
+ }));
191
+ if (options.signal?.aborted) {
192
+ throw new Errors.APIUserAbortError();
193
+ }
194
+ const controller = new AbortController();
195
+ const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(errors_1.castToError);
196
+ const headersTime = Date.now();
197
+ if (response instanceof globalThis.Error) {
198
+ const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
199
+ if (options.signal?.aborted) {
200
+ throw new Errors.APIUserAbortError();
201
+ }
202
+ // detect native connection timeout errors
203
+ // deno throws "TypeError: error sending request for url (https://example/): client error (Connect): tcp connect error: Operation timed out (os error 60): Operation timed out (os error 60)"
204
+ // undici throws "TypeError: fetch failed" with cause "ConnectTimeoutError: Connect Timeout Error (attempted address: example:443, timeout: 1ms)"
205
+ // others do not provide enough information to distinguish timeouts from other connection errors
206
+ const isTimeout = (0, errors_1.isAbortError)(response) ||
207
+ /timed? ?out/i.test(String(response) + ('cause' in response ? String(response.cause) : ''));
208
+ if (retriesRemaining) {
209
+ (0, log_1.loggerFor)(this).info(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - ${retryMessage}`);
210
+ (0, log_1.loggerFor)(this).debug(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (${retryMessage})`, (0, log_1.formatRequestDetails)({
211
+ retryOfRequestLogID,
212
+ url,
213
+ durationMs: headersTime - startTime,
214
+ message: response.message,
215
+ }));
216
+ return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID);
217
+ }
218
+ (0, log_1.loggerFor)(this).info(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - error; no more retries left`);
219
+ (0, log_1.loggerFor)(this).debug(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (error; no more retries left)`, (0, log_1.formatRequestDetails)({
220
+ retryOfRequestLogID,
221
+ url,
222
+ durationMs: headersTime - startTime,
223
+ message: response.message,
224
+ }));
225
+ if (isTimeout) {
226
+ throw new Errors.APIConnectionTimeoutError();
227
+ }
228
+ throw new Errors.APIConnectionError({ cause: response });
229
+ }
230
+ const responseInfo = `[${requestLogID}${retryLogStr}] ${req.method} ${url} ${response.ok ? 'succeeded' : 'failed'} with status ${response.status} in ${headersTime - startTime}ms`;
231
+ if (!response.ok) {
232
+ const shouldRetry = await this.shouldRetry(response);
233
+ if (retriesRemaining && shouldRetry) {
234
+ const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
235
+ // We don't need the body of this response.
236
+ await Shims.CancelReadableStream(response.body);
237
+ (0, log_1.loggerFor)(this).info(`${responseInfo} - ${retryMessage}`);
238
+ (0, log_1.loggerFor)(this).debug(`[${requestLogID}] response error (${retryMessage})`, (0, log_1.formatRequestDetails)({
239
+ retryOfRequestLogID,
240
+ url: response.url,
241
+ status: response.status,
242
+ headers: response.headers,
243
+ durationMs: headersTime - startTime,
244
+ }));
245
+ return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID, response.headers);
246
+ }
247
+ const retryMessage = shouldRetry ? `error; no more retries left` : `error; not retryable`;
248
+ (0, log_1.loggerFor)(this).info(`${responseInfo} - ${retryMessage}`);
249
+ const errText = await response.text().catch((err) => (0, errors_1.castToError)(err).message);
250
+ const errJSON = (0, values_1.safeJSON)(errText);
251
+ const errMessage = errJSON ? undefined : errText;
252
+ (0, log_1.loggerFor)(this).debug(`[${requestLogID}] response error (${retryMessage})`, (0, log_1.formatRequestDetails)({
253
+ retryOfRequestLogID,
254
+ url: response.url,
255
+ status: response.status,
256
+ headers: response.headers,
257
+ message: errMessage,
258
+ durationMs: Date.now() - startTime,
259
+ }));
260
+ const err = this.makeStatusError(response.status, errJSON, errMessage, response.headers);
261
+ throw err;
262
+ }
263
+ (0, log_1.loggerFor)(this).info(responseInfo);
264
+ (0, log_1.loggerFor)(this).debug(`[${requestLogID}] response start`, (0, log_1.formatRequestDetails)({
265
+ retryOfRequestLogID,
266
+ url: response.url,
267
+ status: response.status,
268
+ headers: response.headers,
269
+ durationMs: headersTime - startTime,
270
+ }));
271
+ return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
272
+ }
273
+ async fetchWithTimeout(url, init, ms, controller) {
274
+ const { signal, method, ...options } = init || {};
275
+ if (signal)
276
+ signal.addEventListener('abort', () => controller.abort());
277
+ const timeout = setTimeout(() => controller.abort(), ms);
278
+ const isReadableBody = (globalThis.ReadableStream && options.body instanceof globalThis.ReadableStream) ||
279
+ (typeof options.body === 'object' && options.body !== null && Symbol.asyncIterator in options.body);
280
+ const fetchOptions = {
281
+ signal: controller.signal,
282
+ ...(isReadableBody ? { duplex: 'half' } : {}),
283
+ method: 'GET',
284
+ ...options,
285
+ };
286
+ if (method) {
287
+ // Custom methods like 'patch' need to be uppercased
288
+ // See https://github.com/nodejs/undici/issues/2294
289
+ fetchOptions.method = method.toUpperCase();
290
+ }
291
+ try {
292
+ // use undefined this binding; fetch errors if bound to something else in browser/cloudflare
293
+ return await this.fetch.call(undefined, url, fetchOptions);
294
+ }
295
+ finally {
296
+ clearTimeout(timeout);
297
+ }
298
+ }
299
+ async shouldRetry(response) {
300
+ // Note this is not a standard header.
301
+ const shouldRetryHeader = response.headers.get('x-should-retry');
302
+ // If the server explicitly says whether or not to retry, obey.
303
+ if (shouldRetryHeader === 'true')
304
+ return true;
305
+ if (shouldRetryHeader === 'false')
306
+ return false;
307
+ // Retry on request timeouts.
308
+ if (response.status === 408)
309
+ return true;
310
+ // Retry on lock timeouts.
311
+ if (response.status === 409)
312
+ return true;
313
+ // Retry on rate limits.
314
+ if (response.status === 429)
315
+ return true;
316
+ // Retry internal errors.
317
+ if (response.status >= 500)
318
+ return true;
319
+ return false;
320
+ }
321
+ async retryRequest(options, retriesRemaining, requestLogID, responseHeaders) {
322
+ let timeoutMillis;
323
+ // Note the `retry-after-ms` header may not be standard, but is a good idea and we'd like proactive support for it.
324
+ const retryAfterMillisHeader = responseHeaders?.get('retry-after-ms');
325
+ if (retryAfterMillisHeader) {
326
+ const timeoutMs = parseFloat(retryAfterMillisHeader);
327
+ if (!Number.isNaN(timeoutMs)) {
328
+ timeoutMillis = timeoutMs;
329
+ }
330
+ }
331
+ // About the Retry-After header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
332
+ const retryAfterHeader = responseHeaders?.get('retry-after');
333
+ if (retryAfterHeader && !timeoutMillis) {
334
+ const timeoutSeconds = parseFloat(retryAfterHeader);
335
+ if (!Number.isNaN(timeoutSeconds)) {
336
+ timeoutMillis = timeoutSeconds * 1000;
337
+ }
338
+ else {
339
+ timeoutMillis = Date.parse(retryAfterHeader) - Date.now();
340
+ }
341
+ }
342
+ // If the API asks us to wait a certain amount of time (and it's a reasonable amount),
343
+ // just do what it says, but otherwise calculate a default
344
+ if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
345
+ const maxRetries = options.maxRetries ?? this.maxRetries;
346
+ timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
347
+ }
348
+ await (0, sleep_1.sleep)(timeoutMillis);
349
+ return this.makeRequest(options, retriesRemaining - 1, requestLogID);
350
+ }
351
+ calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries) {
352
+ const initialRetryDelay = 0.5;
353
+ const maxRetryDelay = 8.0;
354
+ const numRetries = maxRetries - retriesRemaining;
355
+ // Apply exponential backoff, but not more than the max.
356
+ const sleepSeconds = Math.min(initialRetryDelay * Math.pow(2, numRetries), maxRetryDelay);
357
+ // Apply some jitter, take up to at most 25 percent of the retry time.
358
+ const jitter = 1 - Math.random() * 0.25;
359
+ return sleepSeconds * jitter * 1000;
360
+ }
361
+ async buildRequest(inputOptions, { retryCount = 0 } = {}) {
362
+ const options = { ...inputOptions };
363
+ const { method, path, query, defaultBaseURL } = options;
364
+ const url = this.buildURL(path, query, defaultBaseURL);
365
+ if ('timeout' in options)
366
+ (0, values_1.validatePositiveInteger)('timeout', options.timeout);
367
+ options.timeout = options.timeout ?? this.timeout;
368
+ const { bodyHeaders, body } = this.buildBody({ options });
369
+ const reqHeaders = await this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
370
+ const req = {
371
+ method,
372
+ headers: reqHeaders,
373
+ ...(options.signal && { signal: options.signal }),
374
+ ...(globalThis.ReadableStream &&
375
+ body instanceof globalThis.ReadableStream && { duplex: 'half' }),
376
+ ...(body && { body }),
377
+ ...(this.fetchOptions ?? {}),
378
+ ...(options.fetchOptions ?? {}),
379
+ };
380
+ return { req, url, timeout: options.timeout };
381
+ }
382
+ async buildHeaders({ options, method, bodyHeaders, retryCount, }) {
383
+ let idempotencyHeaders = {};
384
+ if (this.idempotencyHeader && method !== 'get') {
385
+ if (!options.idempotencyKey)
386
+ options.idempotencyKey = this.defaultIdempotencyKey();
387
+ idempotencyHeaders[this.idempotencyHeader] = options.idempotencyKey;
388
+ }
389
+ const headers = (0, headers_1.buildHeaders)([
390
+ idempotencyHeaders,
391
+ {
392
+ Accept: 'application/json',
393
+ 'User-Agent': this.getUserAgent(),
394
+ 'X-Stainless-Retry-Count': String(retryCount),
395
+ ...(options.timeout ? { 'X-Stainless-Timeout': String(Math.trunc(options.timeout / 1000)) } : {}),
396
+ ...(0, detect_platform_1.getPlatformHeaders)(),
397
+ },
398
+ await this.authHeaders(options),
399
+ this._options.defaultHeaders,
400
+ bodyHeaders,
401
+ options.headers,
402
+ ]);
403
+ this.validateHeaders(headers);
404
+ return headers.values;
405
+ }
406
+ buildBody({ options: { body, headers: rawHeaders } }) {
407
+ if (!body) {
408
+ return { bodyHeaders: undefined, body: undefined };
409
+ }
410
+ const headers = (0, headers_1.buildHeaders)([rawHeaders]);
411
+ if (
412
+ // Pass raw type verbatim
413
+ ArrayBuffer.isView(body) ||
414
+ body instanceof ArrayBuffer ||
415
+ body instanceof DataView ||
416
+ (typeof body === 'string' &&
417
+ // Preserve legacy string encoding behavior for now
418
+ headers.values.has('content-type')) ||
419
+ // `Blob` is superset of `File`
420
+ (globalThis.Blob && body instanceof globalThis.Blob) ||
421
+ // `FormData` -> `multipart/form-data`
422
+ body instanceof FormData ||
423
+ // `URLSearchParams` -> `application/x-www-form-urlencoded`
424
+ body instanceof URLSearchParams ||
425
+ // Send chunked stream (each chunk has own `length`)
426
+ (globalThis.ReadableStream && body instanceof globalThis.ReadableStream)) {
427
+ return { bodyHeaders: undefined, body: body };
428
+ }
429
+ else if (typeof body === 'object' &&
430
+ (Symbol.asyncIterator in body ||
431
+ (Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
432
+ return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body) };
433
+ }
434
+ else {
435
+ return tslib_1.__classPrivateFieldGet(this, _Openlayer_encoder, "f").call(this, { body, headers });
436
+ }
437
+ }
438
+ }
439
+ exports.Openlayer = Openlayer;
440
+ _a = Openlayer, _Openlayer_encoder = new WeakMap(), _Openlayer_instances = new WeakSet(), _Openlayer_baseURLOverridden = function _Openlayer_baseURLOverridden() {
441
+ return this.baseURL !== 'https://api.openlayer.com/v1';
442
+ };
443
+ Openlayer.Openlayer = _a;
444
+ Openlayer.DEFAULT_TIMEOUT = 60000; // 1 minute
445
+ Openlayer.OpenlayerError = Errors.OpenlayerError;
446
+ Openlayer.APIError = Errors.APIError;
447
+ Openlayer.APIConnectionError = Errors.APIConnectionError;
448
+ Openlayer.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
449
+ Openlayer.APIUserAbortError = Errors.APIUserAbortError;
450
+ Openlayer.NotFoundError = Errors.NotFoundError;
451
+ Openlayer.ConflictError = Errors.ConflictError;
452
+ Openlayer.RateLimitError = Errors.RateLimitError;
453
+ Openlayer.BadRequestError = Errors.BadRequestError;
454
+ Openlayer.AuthenticationError = Errors.AuthenticationError;
455
+ Openlayer.InternalServerError = Errors.InternalServerError;
456
+ Openlayer.PermissionDeniedError = Errors.PermissionDeniedError;
457
+ Openlayer.UnprocessableEntityError = Errors.UnprocessableEntityError;
458
+ Openlayer.toFile = Uploads.toFile;
459
+ Openlayer.Projects = projects_1.Projects;
460
+ Openlayer.Commits = commits_1.Commits;
461
+ Openlayer.InferencePipelines = inference_pipelines_1.InferencePipelines;
462
+ Openlayer.Storage = storage_1.Storage;
463
+ //# sourceMappingURL=client.js.map