@roarkanalytics/sdk 0.1.0-alpha.1 → 0.1.0-alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (347) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +1 -1
  3. package/README.md +48 -85
  4. package/_shims/MultipartBody.d.ts +9 -0
  5. package/_shims/MultipartBody.d.ts.map +1 -0
  6. package/_shims/MultipartBody.js +16 -0
  7. package/_shims/MultipartBody.js.map +1 -0
  8. package/_shims/MultipartBody.mjs +12 -0
  9. package/_shims/MultipartBody.mjs.map +1 -0
  10. package/_shims/README.md +46 -0
  11. package/_shims/auto/runtime-bun.d.ts +5 -0
  12. package/_shims/auto/runtime-bun.d.ts.map +1 -0
  13. package/{internal/utils.js → _shims/auto/runtime-bun.js} +5 -8
  14. package/_shims/auto/runtime-bun.js.map +1 -0
  15. package/_shims/auto/runtime-bun.mjs +2 -0
  16. package/_shims/auto/runtime-bun.mjs.map +1 -0
  17. package/_shims/auto/runtime-node.d.ts +5 -0
  18. package/_shims/auto/runtime-node.d.ts.map +1 -0
  19. package/_shims/auto/runtime-node.js +21 -0
  20. package/_shims/auto/runtime-node.js.map +1 -0
  21. package/_shims/auto/runtime-node.mjs +2 -0
  22. package/_shims/auto/runtime-node.mjs.map +1 -0
  23. package/_shims/auto/runtime.d.ts +5 -0
  24. package/_shims/auto/runtime.d.ts.map +1 -0
  25. package/_shims/auto/runtime.js +21 -0
  26. package/_shims/auto/runtime.js.map +1 -0
  27. package/_shims/auto/runtime.mjs +2 -0
  28. package/_shims/auto/runtime.mjs.map +1 -0
  29. package/_shims/auto/types-node.d.ts +5 -0
  30. package/_shims/auto/types-node.d.ts.map +1 -0
  31. package/_shims/auto/types-node.js +21 -0
  32. package/_shims/auto/types-node.js.map +1 -0
  33. package/_shims/auto/types-node.mjs +2 -0
  34. package/_shims/auto/types-node.mjs.map +1 -0
  35. package/_shims/auto/types.d.ts +101 -0
  36. package/_shims/auto/types.js +3 -0
  37. package/_shims/auto/types.mjs +3 -0
  38. package/_shims/bun-runtime.d.ts +6 -0
  39. package/_shims/bun-runtime.d.ts.map +1 -0
  40. package/_shims/bun-runtime.js +14 -0
  41. package/_shims/bun-runtime.js.map +1 -0
  42. package/_shims/bun-runtime.mjs +10 -0
  43. package/_shims/bun-runtime.mjs.map +1 -0
  44. package/_shims/index.d.ts +81 -0
  45. package/_shims/index.js +13 -0
  46. package/_shims/index.mjs +7 -0
  47. package/_shims/manual-types.d.ts +12 -0
  48. package/_shims/manual-types.js +3 -0
  49. package/_shims/manual-types.mjs +3 -0
  50. package/_shims/node-runtime.d.ts +3 -0
  51. package/_shims/node-runtime.d.ts.map +1 -0
  52. package/_shims/node-runtime.js +89 -0
  53. package/_shims/node-runtime.js.map +1 -0
  54. package/_shims/node-runtime.mjs +56 -0
  55. package/_shims/node-runtime.mjs.map +1 -0
  56. package/_shims/node-types.d.ts +42 -0
  57. package/_shims/node-types.js +3 -0
  58. package/_shims/node-types.mjs +3 -0
  59. package/_shims/registry.d.ts +37 -0
  60. package/_shims/registry.d.ts.map +1 -0
  61. package/_shims/registry.js +41 -0
  62. package/_shims/registry.js.map +1 -0
  63. package/_shims/registry.mjs +37 -0
  64. package/_shims/registry.mjs.map +1 -0
  65. package/_shims/web-runtime.d.ts +5 -0
  66. package/_shims/web-runtime.d.ts.map +1 -0
  67. package/_shims/web-runtime.js +78 -0
  68. package/_shims/web-runtime.js.map +1 -0
  69. package/_shims/web-runtime.mjs +71 -0
  70. package/_shims/web-runtime.mjs.map +1 -0
  71. package/_shims/web-types.d.ts +83 -0
  72. package/_shims/web-types.js +3 -0
  73. package/_shims/web-types.mjs +3 -0
  74. package/core.d.ts +241 -0
  75. package/core.d.ts.map +1 -0
  76. package/core.js +908 -0
  77. package/core.js.map +1 -0
  78. package/core.mjs +876 -0
  79. package/core.mjs.map +1 -0
  80. package/error.d.ts +3 -3
  81. package/error.d.ts.map +1 -1
  82. package/error.js +6 -6
  83. package/error.js.map +1 -1
  84. package/error.mjs +3 -3
  85. package/error.mjs.map +1 -1
  86. package/index.d.mts +109 -5
  87. package/index.d.ts +109 -5
  88. package/index.d.ts.map +1 -1
  89. package/index.js +103 -11
  90. package/index.js.map +1 -1
  91. package/index.mjs +77 -5
  92. package/index.mjs.map +1 -1
  93. package/package.json +66 -82
  94. package/resource.d.ts +3 -3
  95. package/resource.d.ts.map +1 -1
  96. package/resource.js.map +1 -1
  97. package/resource.mjs.map +1 -1
  98. package/resources/calls.d.ts +2 -3
  99. package/resources/calls.d.ts.map +1 -1
  100. package/resources/calls.js.map +1 -1
  101. package/resources/calls.mjs.map +1 -1
  102. package/resources/index.d.ts.map +1 -1
  103. package/shims/node.d.ts +30 -0
  104. package/shims/node.d.ts.map +1 -0
  105. package/shims/node.js +31 -0
  106. package/shims/node.js.map +1 -0
  107. package/shims/node.mjs +5 -0
  108. package/shims/node.mjs.map +1 -0
  109. package/shims/web.d.ts +26 -0
  110. package/shims/web.d.ts.map +1 -0
  111. package/shims/web.js +31 -0
  112. package/shims/web.js.map +1 -0
  113. package/shims/web.mjs +5 -0
  114. package/shims/web.mjs.map +1 -0
  115. package/src/_shims/MultipartBody.ts +9 -0
  116. package/src/_shims/README.md +46 -0
  117. package/src/_shims/auto/runtime-bun.ts +4 -0
  118. package/src/_shims/auto/runtime-node.ts +4 -0
  119. package/src/_shims/auto/runtime.ts +4 -0
  120. package/src/_shims/auto/types-node.ts +4 -0
  121. package/src/_shims/auto/types.d.ts +101 -0
  122. package/src/_shims/auto/types.js +3 -0
  123. package/src/_shims/auto/types.mjs +3 -0
  124. package/src/_shims/bun-runtime.ts +14 -0
  125. package/src/_shims/index.d.ts +81 -0
  126. package/src/_shims/index.js +13 -0
  127. package/src/_shims/index.mjs +7 -0
  128. package/src/_shims/manual-types.d.ts +12 -0
  129. package/src/_shims/manual-types.js +3 -0
  130. package/src/_shims/manual-types.mjs +3 -0
  131. package/src/_shims/node-runtime.ts +81 -0
  132. package/src/_shims/node-types.d.ts +42 -0
  133. package/src/_shims/node-types.js +3 -0
  134. package/src/_shims/node-types.mjs +3 -0
  135. package/src/_shims/registry.ts +67 -0
  136. package/src/_shims/web-runtime.ts +103 -0
  137. package/src/_shims/web-types.d.ts +83 -0
  138. package/src/_shims/web-types.js +3 -0
  139. package/src/_shims/web-types.mjs +3 -0
  140. package/src/core.ts +1200 -0
  141. package/src/error.ts +3 -3
  142. package/src/index.ts +172 -5
  143. package/src/resource.ts +3 -3
  144. package/src/resources/calls.ts +2 -3
  145. package/src/shims/node.ts +50 -0
  146. package/src/shims/web.ts +50 -0
  147. package/src/tsconfig.json +2 -2
  148. package/src/uploads.ts +255 -1
  149. package/src/version.ts +1 -1
  150. package/uploads.d.ts +74 -1
  151. package/uploads.d.ts.map +1 -1
  152. package/uploads.js +168 -3
  153. package/uploads.js.map +1 -1
  154. package/uploads.mjs +157 -1
  155. package/uploads.mjs.map +1 -1
  156. package/version.d.ts +1 -1
  157. package/version.js +1 -1
  158. package/version.mjs +1 -1
  159. package/api-promise.d.mts +0 -47
  160. package/api-promise.d.mts.map +0 -1
  161. package/api-promise.d.ts +0 -47
  162. package/api-promise.d.ts.map +0 -1
  163. package/api-promise.js +0 -84
  164. package/api-promise.js.map +0 -1
  165. package/api-promise.mjs +0 -80
  166. package/api-promise.mjs.map +0 -1
  167. package/client.d.mts +0 -186
  168. package/client.d.mts.map +0 -1
  169. package/client.d.ts +0 -186
  170. package/client.d.ts.map +0 -1
  171. package/client.js +0 -449
  172. package/client.js.map +0 -1
  173. package/client.mjs +0 -422
  174. package/client.mjs.map +0 -1
  175. package/error.d.mts +0 -47
  176. package/error.d.mts.map +0 -1
  177. package/index.d.mts.map +0 -1
  178. package/internal/builtin-types.d.mts +0 -65
  179. package/internal/builtin-types.d.mts.map +0 -1
  180. package/internal/builtin-types.d.ts +0 -65
  181. package/internal/builtin-types.d.ts.map +0 -1
  182. package/internal/builtin-types.js +0 -4
  183. package/internal/builtin-types.js.map +0 -1
  184. package/internal/builtin-types.mjs +0 -3
  185. package/internal/builtin-types.mjs.map +0 -1
  186. package/internal/detect-platform.d.mts +0 -15
  187. package/internal/detect-platform.d.mts.map +0 -1
  188. package/internal/detect-platform.d.ts +0 -15
  189. package/internal/detect-platform.d.ts.map +0 -1
  190. package/internal/detect-platform.js +0 -162
  191. package/internal/detect-platform.js.map +0 -1
  192. package/internal/detect-platform.mjs +0 -157
  193. package/internal/detect-platform.mjs.map +0 -1
  194. package/internal/errors.d.mts +0 -3
  195. package/internal/errors.d.mts.map +0 -1
  196. package/internal/errors.d.ts +0 -3
  197. package/internal/errors.d.ts.map +0 -1
  198. package/internal/errors.js +0 -26
  199. package/internal/errors.js.map +0 -1
  200. package/internal/errors.mjs +0 -21
  201. package/internal/errors.mjs.map +0 -1
  202. package/internal/headers.d.mts +0 -21
  203. package/internal/headers.d.mts.map +0 -1
  204. package/internal/headers.d.ts +0 -21
  205. package/internal/headers.d.ts.map +0 -1
  206. package/internal/headers.js +0 -77
  207. package/internal/headers.js.map +0 -1
  208. package/internal/headers.mjs +0 -72
  209. package/internal/headers.mjs.map +0 -1
  210. package/internal/parse.d.mts +0 -10
  211. package/internal/parse.d.mts.map +0 -1
  212. package/internal/parse.d.ts +0 -10
  213. package/internal/parse.d.ts.map +0 -1
  214. package/internal/parse.js +0 -28
  215. package/internal/parse.js.map +0 -1
  216. package/internal/parse.mjs +0 -24
  217. package/internal/parse.mjs.map +0 -1
  218. package/internal/polyfill/crypto.node.d.ts +0 -10
  219. package/internal/polyfill/crypto.node.js +0 -11
  220. package/internal/polyfill/crypto.node.mjs +0 -2
  221. package/internal/polyfill/file.node.d.ts +0 -9
  222. package/internal/polyfill/file.node.js +0 -17
  223. package/internal/polyfill/file.node.mjs +0 -9
  224. package/internal/request-options.d.mts +0 -34
  225. package/internal/request-options.d.mts.map +0 -1
  226. package/internal/request-options.d.ts +0 -34
  227. package/internal/request-options.d.ts.map +0 -1
  228. package/internal/request-options.js +0 -39
  229. package/internal/request-options.js.map +0 -1
  230. package/internal/request-options.mjs +0 -34
  231. package/internal/request-options.mjs.map +0 -1
  232. package/internal/shim-types.d.mts +0 -28
  233. package/internal/shim-types.d.ts +0 -28
  234. package/internal/shims.d.mts +0 -61
  235. package/internal/shims.d.mts.map +0 -1
  236. package/internal/shims.d.ts +0 -61
  237. package/internal/shims.d.ts.map +0 -1
  238. package/internal/shims.js +0 -101
  239. package/internal/shims.js.map +0 -1
  240. package/internal/shims.mjs +0 -92
  241. package/internal/shims.mjs.map +0 -1
  242. package/internal/types.d.mts +0 -68
  243. package/internal/types.d.mts.map +0 -1
  244. package/internal/types.d.ts +0 -68
  245. package/internal/types.d.ts.map +0 -1
  246. package/internal/types.js +0 -4
  247. package/internal/types.js.map +0 -1
  248. package/internal/types.mjs +0 -3
  249. package/internal/types.mjs.map +0 -1
  250. package/internal/uploads.d.mts +0 -73
  251. package/internal/uploads.d.mts.map +0 -1
  252. package/internal/uploads.d.ts +0 -73
  253. package/internal/uploads.d.ts.map +0 -1
  254. package/internal/uploads.js +0 -208
  255. package/internal/uploads.js.map +0 -1
  256. package/internal/uploads.mjs +0 -200
  257. package/internal/uploads.mjs.map +0 -1
  258. package/internal/utils/base64.d.mts +0 -3
  259. package/internal/utils/base64.d.mts.map +0 -1
  260. package/internal/utils/base64.d.ts +0 -3
  261. package/internal/utils/base64.d.ts.map +0 -1
  262. package/internal/utils/base64.js +0 -33
  263. package/internal/utils/base64.js.map +0 -1
  264. package/internal/utils/base64.mjs +0 -28
  265. package/internal/utils/base64.mjs.map +0 -1
  266. package/internal/utils/env.d.mts +0 -9
  267. package/internal/utils/env.d.mts.map +0 -1
  268. package/internal/utils/env.d.ts +0 -9
  269. package/internal/utils/env.d.ts.map +0 -1
  270. package/internal/utils/env.js +0 -22
  271. package/internal/utils/env.js.map +0 -1
  272. package/internal/utils/env.mjs +0 -18
  273. package/internal/utils/env.mjs.map +0 -1
  274. package/internal/utils/log.d.mts +0 -4
  275. package/internal/utils/log.d.mts.map +0 -1
  276. package/internal/utils/log.d.ts +0 -4
  277. package/internal/utils/log.d.ts.map +0 -1
  278. package/internal/utils/log.js +0 -47
  279. package/internal/utils/log.js.map +0 -1
  280. package/internal/utils/log.mjs +0 -43
  281. package/internal/utils/log.mjs.map +0 -1
  282. package/internal/utils/sleep.d.mts +0 -2
  283. package/internal/utils/sleep.d.mts.map +0 -1
  284. package/internal/utils/sleep.d.ts +0 -2
  285. package/internal/utils/sleep.d.ts.map +0 -1
  286. package/internal/utils/sleep.js +0 -7
  287. package/internal/utils/sleep.js.map +0 -1
  288. package/internal/utils/sleep.mjs +0 -3
  289. package/internal/utils/sleep.mjs.map +0 -1
  290. package/internal/utils/uuid.d.mts +0 -5
  291. package/internal/utils/uuid.d.mts.map +0 -1
  292. package/internal/utils/uuid.d.ts +0 -5
  293. package/internal/utils/uuid.d.ts.map +0 -1
  294. package/internal/utils/uuid.js +0 -15
  295. package/internal/utils/uuid.js.map +0 -1
  296. package/internal/utils/uuid.mjs +0 -11
  297. package/internal/utils/uuid.mjs.map +0 -1
  298. package/internal/utils/values.d.mts +0 -15
  299. package/internal/utils/values.d.mts.map +0 -1
  300. package/internal/utils/values.d.ts +0 -15
  301. package/internal/utils/values.d.ts.map +0 -1
  302. package/internal/utils/values.js +0 -100
  303. package/internal/utils/values.js.map +0 -1
  304. package/internal/utils/values.mjs +0 -84
  305. package/internal/utils/values.mjs.map +0 -1
  306. package/internal/utils.d.mts +0 -7
  307. package/internal/utils.d.mts.map +0 -1
  308. package/internal/utils.d.ts +0 -7
  309. package/internal/utils.d.ts.map +0 -1
  310. package/internal/utils.js.map +0 -1
  311. package/internal/utils.mjs +0 -8
  312. package/internal/utils.mjs.map +0 -1
  313. package/resource.d.mts +0 -6
  314. package/resource.d.mts.map +0 -1
  315. package/resources/calls.d.mts +0 -85
  316. package/resources/calls.d.mts.map +0 -1
  317. package/resources/index.d.mts +0 -2
  318. package/resources/index.d.mts.map +0 -1
  319. package/src/api-promise.ts +0 -92
  320. package/src/client.ts +0 -646
  321. package/src/internal/builtin-types.ts +0 -79
  322. package/src/internal/detect-platform.ts +0 -196
  323. package/src/internal/errors.ts +0 -22
  324. package/src/internal/headers.ts +0 -96
  325. package/src/internal/parse.ts +0 -41
  326. package/src/internal/polyfill/crypto.node.d.ts +0 -10
  327. package/src/internal/polyfill/crypto.node.js +0 -11
  328. package/src/internal/polyfill/crypto.node.mjs +0 -2
  329. package/src/internal/polyfill/file.node.d.ts +0 -9
  330. package/src/internal/polyfill/file.node.js +0 -17
  331. package/src/internal/polyfill/file.node.mjs +0 -9
  332. package/src/internal/request-options.ts +0 -67
  333. package/src/internal/shim-types.d.ts +0 -28
  334. package/src/internal/shims.ts +0 -145
  335. package/src/internal/types.ts +0 -98
  336. package/src/internal/uploads.ts +0 -307
  337. package/src/internal/utils/base64.ts +0 -37
  338. package/src/internal/utils/env.ts +0 -18
  339. package/src/internal/utils/log.ts +0 -49
  340. package/src/internal/utils/sleep.ts +0 -3
  341. package/src/internal/utils/uuid.ts +0 -13
  342. package/src/internal/utils/values.ts +0 -94
  343. package/src/internal/utils.ts +0 -8
  344. package/uploads.d.mts +0 -2
  345. package/uploads.d.mts.map +0 -1
  346. package/version.d.mts +0 -2
  347. package/version.d.mts.map +0 -1
@@ -1,79 +0,0 @@
1
- // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- export type Fetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
4
-
5
- /**
6
- * An alias to the builtin `RequestInit` type so we can
7
- * easily alias it in import statements if there are name clashes.
8
- *
9
- * https://developer.mozilla.org/docs/Web/API/RequestInit
10
- */
11
- type _RequestInit = RequestInit;
12
-
13
- /**
14
- * An alias to the builtin `Response` type so we can
15
- * easily alias it in import statements if there are name clashes.
16
- *
17
- * https://developer.mozilla.org/docs/Web/API/Response
18
- */
19
- type _Response = Response;
20
-
21
- /**
22
- * The type for the first argument to `fetch`.
23
- *
24
- * https://developer.mozilla.org/docs/Web/API/Window/fetch#resource
25
- */
26
- type _RequestInfo = Request | URL | string;
27
-
28
- /**
29
- * The type for constructing `RequestInit` Headers.
30
- *
31
- * https://developer.mozilla.org/docs/Web/API/RequestInit#setting_headers
32
- */
33
- type _HeadersInit = RequestInit['headers'];
34
-
35
- /**
36
- * The type for constructing `RequestInit` body.
37
- *
38
- * https://developer.mozilla.org/docs/Web/API/RequestInit#body
39
- */
40
- type _BodyInit = RequestInit['body'];
41
-
42
- export type {
43
- _BodyInit as BodyInit,
44
- _HeadersInit as HeadersInit,
45
- _RequestInfo as RequestInfo,
46
- _RequestInit as RequestInit,
47
- _Response as Response,
48
- };
49
-
50
- /**
51
- * A copy of the builtin `EndingType` type as it isn't fully supported in certain
52
- * environments and attempting to reference the global version will error.
53
- *
54
- * https://github.com/microsoft/TypeScript/blob/49ad1a3917a0ea57f5ff248159256e12bb1cb705/src/lib/dom.generated.d.ts#L27941
55
- */
56
- type EndingType = 'native' | 'transparent';
57
-
58
- /**
59
- * A copy of the builtin `BlobPropertyBag` type as it isn't fully supported in certain
60
- * environments and attempting to reference the global version will error.
61
- *
62
- * https://github.com/microsoft/TypeScript/blob/49ad1a3917a0ea57f5ff248159256e12bb1cb705/src/lib/dom.generated.d.ts#L154
63
- * https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob#options
64
- */
65
- export interface BlobPropertyBag {
66
- endings?: EndingType;
67
- type?: string;
68
- }
69
-
70
- /**
71
- * A copy of the builtin `FilePropertyBag` type as it isn't fully supported in certain
72
- * environments and attempting to reference the global version will error.
73
- *
74
- * https://github.com/microsoft/TypeScript/blob/49ad1a3917a0ea57f5ff248159256e12bb1cb705/src/lib/dom.generated.d.ts#L503
75
- * https://developer.mozilla.org/en-US/docs/Web/API/File/File#options
76
- */
77
- export interface FilePropertyBag extends BlobPropertyBag {
78
- lastModified?: number;
79
- }
@@ -1,196 +0,0 @@
1
- // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- import { VERSION } from '../version';
4
-
5
- export const isRunningInBrowser = () => {
6
- return (
7
- // @ts-ignore
8
- typeof window !== 'undefined' &&
9
- // @ts-ignore
10
- typeof window.document !== 'undefined' &&
11
- // @ts-ignore
12
- typeof navigator !== 'undefined'
13
- );
14
- };
15
-
16
- type DetectedPlatform = 'deno' | 'node' | 'edge' | 'unknown';
17
-
18
- /**
19
- * Note this does not detect 'browser'; for that, use getBrowserInfo().
20
- */
21
- function getDetectedPlatform(): DetectedPlatform {
22
- if (typeof Deno !== 'undefined' && Deno.build != null) {
23
- return 'deno';
24
- }
25
- if (typeof EdgeRuntime !== 'undefined') {
26
- return 'edge';
27
- }
28
- if (
29
- Object.prototype.toString.call(
30
- typeof (globalThis as any).process !== 'undefined' ? (globalThis as any).process : 0,
31
- ) === '[object process]'
32
- ) {
33
- return 'node';
34
- }
35
- return 'unknown';
36
- }
37
-
38
- declare const Deno: any;
39
- declare const EdgeRuntime: any;
40
- type Arch = 'x32' | 'x64' | 'arm' | 'arm64' | `other:${string}` | 'unknown';
41
- type PlatformName =
42
- | 'MacOS'
43
- | 'Linux'
44
- | 'Windows'
45
- | 'FreeBSD'
46
- | 'OpenBSD'
47
- | 'iOS'
48
- | 'Android'
49
- | `Other:${string}`
50
- | 'Unknown';
51
- type Browser = 'ie' | 'edge' | 'chrome' | 'firefox' | 'safari';
52
- type PlatformProperties = {
53
- 'X-Stainless-Lang': 'js';
54
- 'X-Stainless-Package-Version': string;
55
- 'X-Stainless-OS': PlatformName;
56
- 'X-Stainless-Arch': Arch;
57
- 'X-Stainless-Runtime': 'node' | 'deno' | 'edge' | `browser:${Browser}` | 'unknown';
58
- 'X-Stainless-Runtime-Version': string;
59
- };
60
- const getPlatformProperties = (): PlatformProperties => {
61
- const detectedPlatform = getDetectedPlatform();
62
- if (detectedPlatform === 'deno') {
63
- return {
64
- 'X-Stainless-Lang': 'js',
65
- 'X-Stainless-Package-Version': VERSION,
66
- 'X-Stainless-OS': normalizePlatform(Deno.build.os),
67
- 'X-Stainless-Arch': normalizeArch(Deno.build.arch),
68
- 'X-Stainless-Runtime': 'deno',
69
- 'X-Stainless-Runtime-Version':
70
- typeof Deno.version === 'string' ? Deno.version : Deno.version?.deno ?? 'unknown',
71
- };
72
- }
73
- if (typeof EdgeRuntime !== 'undefined') {
74
- return {
75
- 'X-Stainless-Lang': 'js',
76
- 'X-Stainless-Package-Version': VERSION,
77
- 'X-Stainless-OS': 'Unknown',
78
- 'X-Stainless-Arch': `other:${EdgeRuntime}`,
79
- 'X-Stainless-Runtime': 'edge',
80
- 'X-Stainless-Runtime-Version': (globalThis as any).process.version,
81
- };
82
- }
83
- // Check if Node.js
84
- if (detectedPlatform === 'node') {
85
- return {
86
- 'X-Stainless-Lang': 'js',
87
- 'X-Stainless-Package-Version': VERSION,
88
- 'X-Stainless-OS': normalizePlatform((globalThis as any).process.platform),
89
- 'X-Stainless-Arch': normalizeArch((globalThis as any).process.arch),
90
- 'X-Stainless-Runtime': 'node',
91
- 'X-Stainless-Runtime-Version': (globalThis as any).process.version,
92
- };
93
- }
94
-
95
- const browserInfo = getBrowserInfo();
96
- if (browserInfo) {
97
- return {
98
- 'X-Stainless-Lang': 'js',
99
- 'X-Stainless-Package-Version': VERSION,
100
- 'X-Stainless-OS': 'Unknown',
101
- 'X-Stainless-Arch': 'unknown',
102
- 'X-Stainless-Runtime': `browser:${browserInfo.browser}`,
103
- 'X-Stainless-Runtime-Version': browserInfo.version,
104
- };
105
- }
106
-
107
- // TODO add support for Cloudflare workers, etc.
108
- return {
109
- 'X-Stainless-Lang': 'js',
110
- 'X-Stainless-Package-Version': VERSION,
111
- 'X-Stainless-OS': 'Unknown',
112
- 'X-Stainless-Arch': 'unknown',
113
- 'X-Stainless-Runtime': 'unknown',
114
- 'X-Stainless-Runtime-Version': 'unknown',
115
- };
116
- };
117
-
118
- type BrowserInfo = {
119
- browser: Browser;
120
- version: string;
121
- };
122
-
123
- declare const navigator: { userAgent: string } | undefined;
124
-
125
- // Note: modified from https://github.com/JS-DevTools/host-environment/blob/b1ab79ecde37db5d6e163c050e54fe7d287d7c92/src/isomorphic.browser.ts
126
- function getBrowserInfo(): BrowserInfo | null {
127
- if (typeof navigator === 'undefined' || !navigator) {
128
- return null;
129
- }
130
-
131
- // NOTE: The order matters here!
132
- const browserPatterns = [
133
- { key: 'edge' as const, pattern: /Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
134
- { key: 'ie' as const, pattern: /MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
135
- { key: 'ie' as const, pattern: /Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/ },
136
- { key: 'chrome' as const, pattern: /Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
137
- { key: 'firefox' as const, pattern: /Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
138
- { key: 'safari' as const, pattern: /(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/ },
139
- ];
140
-
141
- // Find the FIRST matching browser
142
- for (const { key, pattern } of browserPatterns) {
143
- const match = pattern.exec(navigator.userAgent);
144
- if (match) {
145
- const major = match[1] || 0;
146
- const minor = match[2] || 0;
147
- const patch = match[3] || 0;
148
-
149
- return { browser: key, version: `${major}.${minor}.${patch}` };
150
- }
151
- }
152
-
153
- return null;
154
- }
155
-
156
- const normalizeArch = (arch: string): Arch => {
157
- // Node docs:
158
- // - https://nodejs.org/api/process.html#processarch
159
- // Deno docs:
160
- // - https://doc.deno.land/deno/stable/~/Deno.build
161
- if (arch === 'x32') return 'x32';
162
- if (arch === 'x86_64' || arch === 'x64') return 'x64';
163
- if (arch === 'arm') return 'arm';
164
- if (arch === 'aarch64' || arch === 'arm64') return 'arm64';
165
- if (arch) return `other:${arch}`;
166
- return 'unknown';
167
- };
168
-
169
- const normalizePlatform = (platform: string): PlatformName => {
170
- // Node platforms:
171
- // - https://nodejs.org/api/process.html#processplatform
172
- // Deno platforms:
173
- // - https://doc.deno.land/deno/stable/~/Deno.build
174
- // - https://github.com/denoland/deno/issues/14799
175
-
176
- platform = platform.toLowerCase();
177
-
178
- // NOTE: this iOS check is untested and may not work
179
- // Node does not work natively on IOS, there is a fork at
180
- // https://github.com/nodejs-mobile/nodejs-mobile
181
- // however it is unknown at the time of writing how to detect if it is running
182
- if (platform.includes('ios')) return 'iOS';
183
- if (platform === 'android') return 'Android';
184
- if (platform === 'darwin') return 'MacOS';
185
- if (platform === 'win32') return 'Windows';
186
- if (platform === 'freebsd') return 'FreeBSD';
187
- if (platform === 'openbsd') return 'OpenBSD';
188
- if (platform === 'linux') return 'Linux';
189
- if (platform) return `Other:${platform}`;
190
- return 'Unknown';
191
- };
192
-
193
- let _platformHeaders: PlatformProperties;
194
- export const getPlatformHeaders = () => {
195
- return (_platformHeaders ??= getPlatformProperties());
196
- };
@@ -1,22 +0,0 @@
1
- // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- export function isAbortError(err: unknown) {
4
- return (
5
- typeof err === 'object' &&
6
- err !== null &&
7
- // Spec-compliant fetch implementations
8
- (('name' in err && (err as any).name === 'AbortError') ||
9
- // Expo fetch
10
- ('message' in err && String((err as any).message).includes('FetchRequestCanceledException')))
11
- );
12
- }
13
-
14
- export const castToError = (err: any): Error => {
15
- if (err instanceof Error) return err;
16
- if (typeof err === 'object' && err !== null) {
17
- try {
18
- return new Error(JSON.stringify(err));
19
- } catch {}
20
- }
21
- return new Error(err);
22
- };
@@ -1,96 +0,0 @@
1
- // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- type HeaderValue = string | undefined | null;
4
- export type HeadersLike =
5
- | Headers
6
- | readonly [string, HeaderValue][]
7
- | Record<string, HeaderValue | readonly HeaderValue[]>
8
- | undefined
9
- | null
10
- | NullableHeaders;
11
-
12
- const brand_privateNullableHeaders = Symbol('brand.privateNullableHeaders');
13
-
14
- /**
15
- * @internal
16
- * Users can pass explicit nulls to unset default headers. When we parse them
17
- * into a standard headers type we need to preserve that information.
18
- */
19
- export type NullableHeaders = {
20
- /** Brand check, prevent users from creating a NullableHeaders. */
21
- [brand_privateNullableHeaders]: true;
22
- /** Parsed headers. */
23
- values: Headers;
24
- /** Set of lowercase header names explicitly set to null. */
25
- nulls: Set<string>;
26
- };
27
-
28
- const isArray = Array.isArray as (val: unknown) => val is readonly unknown[];
29
-
30
- function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [string, string | null]> {
31
- if (!headers) return;
32
-
33
- if (brand_privateNullableHeaders in headers) {
34
- const { values, nulls } = headers;
35
- yield* values.entries();
36
- for (const name of nulls) {
37
- yield [name, null];
38
- }
39
- return;
40
- }
41
-
42
- let shouldClear = false;
43
- let iter: Iterable<readonly [string, HeaderValue | readonly HeaderValue[]]>;
44
- if (headers instanceof Headers) {
45
- iter = headers.entries();
46
- } else if (isArray(headers)) {
47
- iter = headers;
48
- } else {
49
- shouldClear = true;
50
- iter = Object.entries(headers ?? {});
51
- }
52
- for (let row of iter) {
53
- const name = row[0];
54
- const values = isArray(row[1]) ? row[1] : [row[1]];
55
- let didClear = false;
56
- for (const value of values) {
57
- if (value === undefined) continue;
58
-
59
- // Objects keys always overwrite older headers, they never append.
60
- // Yield a null to clear the header before adding the new values.
61
- if (shouldClear && !didClear) {
62
- didClear = true;
63
- yield [name, null];
64
- }
65
- yield [name, value];
66
- }
67
- }
68
- }
69
-
70
- export const buildHeaders = (newHeaders: HeadersLike[]): NullableHeaders => {
71
- const targetHeaders = new Headers();
72
- const nullHeaders = new Set<string>();
73
- const seenHeaders = new Set<string>();
74
- for (const headers of newHeaders) {
75
- for (const [name, value] of iterateHeaders(headers)) {
76
- const lowerName = name.toLowerCase();
77
- if (!seenHeaders.has(lowerName)) {
78
- targetHeaders.delete(name);
79
- seenHeaders.add(lowerName);
80
- }
81
- if (value === null) {
82
- targetHeaders.delete(name);
83
- nullHeaders.add(lowerName);
84
- } else {
85
- targetHeaders.append(name, value);
86
- nullHeaders.delete(lowerName);
87
- }
88
- }
89
- }
90
- return { [brand_privateNullableHeaders]: true, values: targetHeaders, nulls: nullHeaders };
91
- };
92
-
93
- export const isEmptyHeaders = (headers: HeadersLike) => {
94
- for (const _ of iterateHeaders(headers)) return false;
95
- return true;
96
- };
@@ -1,41 +0,0 @@
1
- // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- import type { FinalRequestOptions } from './request-options';
4
- import { type Petstore } from '../client';
5
- import { logger } from './utils/log';
6
-
7
- export type APIResponseProps = {
8
- response: Response;
9
- options: FinalRequestOptions;
10
- controller: AbortController;
11
- };
12
-
13
- export async function defaultParseResponse<T>(client: Petstore, props: APIResponseProps): Promise<T> {
14
- const { response } = props;
15
-
16
- // fetch refuses to read the body when the status code is 204.
17
- if (response.status === 204) {
18
- return null as T;
19
- }
20
-
21
- if (props.options.__binaryResponse) {
22
- return response as unknown as T;
23
- }
24
-
25
- const contentType = response.headers.get('content-type');
26
- const isJSON =
27
- contentType?.includes('application/json') || contentType?.includes('application/vnd.api+json');
28
- if (isJSON) {
29
- const json = await response.json();
30
-
31
- logger(client).debug('response', response.status, response.url, response.headers, json);
32
-
33
- return json as T;
34
- }
35
-
36
- const text = await response.text();
37
- logger(client).debug('response', response.status, response.url, response.headers, text);
38
-
39
- // TODO handle blob, arraybuffer, other content types, etc.
40
- return text as unknown as T;
41
- }
@@ -1,10 +0,0 @@
1
- export declare const crypto: {
2
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues) */
3
- getRandomValues<T extends ArrayBufferView | null>(array: T): T;
4
- /**
5
- * Available only in secure contexts.
6
- *
7
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID)
8
- */
9
- randomUUID?: () => string;
10
- };
@@ -1,11 +0,0 @@
1
- if (typeof require !== 'undefined') {
2
- if (globalThis.crypto) {
3
- exports.crypto = globalThis.crypto;
4
- } else {
5
- try {
6
- // Use [require][0](...) and not require(...) so bundlers don't try to bundle the
7
- // crypto module.
8
- exports.crypto = [require][0]('node:crypto').webcrypto;
9
- } catch (e) {}
10
- }
11
- }
@@ -1,2 +0,0 @@
1
- import * as mod from './crypto.node.js';
2
- export const crypto = globalThis.crypto || mod.crypto;
@@ -1,9 +0,0 @@
1
- /**
2
- * This file polyfills the global `File` object for you if it's not already defined
3
- * when running on Node.js
4
- *
5
- * This is only needed on Node.js v18 & v19. Newer versions already define `File`
6
- * as a global.
7
- */
8
-
9
- export {};
@@ -1,17 +0,0 @@
1
- /**
2
- * This file polyfills the global `File` object for you if it's not already defined
3
- * when running on Node.js
4
- *
5
- * This is only needed on Node.js v18 & v19. Newer versions already define `File`
6
- * as a global.
7
- */
8
-
9
- if (typeof require !== 'undefined') {
10
- if (!globalThis.File) {
11
- try {
12
- // Use [require][0](...) and not require(...) so bundlers don't try to bundle the
13
- // buffer module.
14
- globalThis.File = [require][0]('node:buffer').File;
15
- } catch (e) {}
16
- }
17
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * This file polyfills the global `File` object for you if it's not already defined
3
- * when running on Node.js
4
- *
5
- * This is only needed on Node.js v18 & v19. Newer versions already define `File`
6
- * as a global.
7
- */
8
-
9
- import './file.node.js';
@@ -1,67 +0,0 @@
1
- // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- import { NullableHeaders } from './headers';
4
-
5
- import type { BodyInit } from './builtin-types';
6
- import { isEmptyObj, hasOwn } from './utils/values';
7
- import type { HTTPMethod, KeysEnum, MergedRequestInit } from './types';
8
- import { type HeadersLike } from './headers';
9
-
10
- export type FinalRequestOptions = RequestOptions & { method: HTTPMethod; path: string };
11
-
12
- export type RequestOptions = {
13
- method?: HTTPMethod;
14
- path?: string;
15
- query?: object | undefined | null;
16
- body?: unknown;
17
- headers?: HeadersLike;
18
- maxRetries?: number;
19
- stream?: boolean | undefined;
20
- timeout?: number;
21
- fetchOptions?: MergedRequestInit;
22
- signal?: AbortSignal | undefined | null;
23
- idempotencyKey?: string;
24
-
25
- __binaryResponse?: boolean | undefined;
26
- };
27
-
28
- // This is required so that we can determine if a given object matches the RequestOptions
29
- // type at runtime. While this requires duplication, it is enforced by the TypeScript
30
- // compiler such that any missing / extraneous keys will cause an error.
31
- const requestOptionsKeys: KeysEnum<RequestOptions> = {
32
- method: true,
33
- path: true,
34
- query: true,
35
- body: true,
36
- headers: true,
37
-
38
- maxRetries: true,
39
- stream: true,
40
- timeout: true,
41
- fetchOptions: true,
42
- signal: true,
43
- idempotencyKey: true,
44
-
45
- __binaryResponse: true,
46
- };
47
-
48
- export const isRequestOptions = (obj: unknown): obj is RequestOptions => {
49
- return (
50
- typeof obj === 'object' &&
51
- obj !== null &&
52
- !isEmptyObj(obj) &&
53
- Object.keys(obj).every((k) => hasOwn(requestOptionsKeys, k))
54
- );
55
- };
56
-
57
- export type EncodedContent = { bodyHeaders: HeadersLike; body: BodyInit };
58
- export type RequestEncoder = (request: { headers: NullableHeaders; body: unknown }) => EncodedContent;
59
-
60
- export const FallbackEncoder: RequestEncoder = ({ headers, body }) => {
61
- return {
62
- bodyHeaders: {
63
- 'content-type': 'application/json',
64
- },
65
- body: JSON.stringify(body),
66
- };
67
- };
@@ -1,28 +0,0 @@
1
- // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- /**
4
- * Shims for types that we can't always rely on being available globally.
5
- *
6
- * Note: these only exist at the type-level, there is no corresponding runtime
7
- * version for any of these symbols.
8
- */
9
-
10
- /**
11
- * In order to properly access the global `NodeJS` type, if it's available, we
12
- * need to make use of declaration shadowing. Without this, any checks for the
13
- * presence of `NodeJS.ReadableStream` will fail.
14
- */
15
- declare namespace NodeJS {
16
- interface ReadableStream {}
17
- }
18
-
19
- type HasProperties<T> = keyof T extends never ? false : true;
20
-
21
- // @ts-ignore
22
- type _ReadableStream<R = any> =
23
- // @ts-ignore
24
- HasProperties<NodeJS.ReadableStream> extends true ? NodeJS.ReadableStream<R> : ReadableStream<R>;
25
-
26
- // @ts-ignore
27
- declare const _ReadableStream: unknown extends typeof ReadableStream ? never : typeof ReadableStream;
28
- export { _ReadableStream as ReadableStream };