@deeptable/deeptable 0.1.0-alpha.1

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 (370) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +7 -0
  3. package/README.md +430 -0
  4. package/api-promise.d.mts +2 -0
  5. package/api-promise.d.mts.map +1 -0
  6. package/api-promise.d.ts +2 -0
  7. package/api-promise.d.ts.map +1 -0
  8. package/api-promise.js +6 -0
  9. package/api-promise.js.map +1 -0
  10. package/api-promise.mjs +2 -0
  11. package/api-promise.mjs.map +1 -0
  12. package/client.d.mts +189 -0
  13. package/client.d.mts.map +1 -0
  14. package/client.d.ts +189 -0
  15. package/client.d.ts.map +1 -0
  16. package/client.js +472 -0
  17. package/client.js.map +1 -0
  18. package/client.mjs +468 -0
  19. package/client.mjs.map +1 -0
  20. package/core/api-promise.d.mts +46 -0
  21. package/core/api-promise.d.mts.map +1 -0
  22. package/core/api-promise.d.ts +46 -0
  23. package/core/api-promise.d.ts.map +1 -0
  24. package/core/api-promise.js +74 -0
  25. package/core/api-promise.js.map +1 -0
  26. package/core/api-promise.mjs +70 -0
  27. package/core/api-promise.mjs.map +1 -0
  28. package/core/error.d.mts +46 -0
  29. package/core/error.d.mts.map +1 -0
  30. package/core/error.d.ts +46 -0
  31. package/core/error.d.ts.map +1 -0
  32. package/core/error.js +113 -0
  33. package/core/error.js.map +1 -0
  34. package/core/error.mjs +97 -0
  35. package/core/error.mjs.map +1 -0
  36. package/core/pagination.d.mts +54 -0
  37. package/core/pagination.d.mts.map +1 -0
  38. package/core/pagination.d.ts +54 -0
  39. package/core/pagination.d.ts.map +1 -0
  40. package/core/pagination.js +101 -0
  41. package/core/pagination.js.map +1 -0
  42. package/core/pagination.mjs +95 -0
  43. package/core/pagination.mjs.map +1 -0
  44. package/core/resource.d.mts +6 -0
  45. package/core/resource.d.mts.map +1 -0
  46. package/core/resource.d.ts +6 -0
  47. package/core/resource.d.ts.map +1 -0
  48. package/core/resource.js +11 -0
  49. package/core/resource.js.map +1 -0
  50. package/core/resource.mjs +7 -0
  51. package/core/resource.mjs.map +1 -0
  52. package/core/uploads.d.mts +3 -0
  53. package/core/uploads.d.mts.map +1 -0
  54. package/core/uploads.d.ts +3 -0
  55. package/core/uploads.d.ts.map +1 -0
  56. package/core/uploads.js +6 -0
  57. package/core/uploads.js.map +1 -0
  58. package/core/uploads.mjs +2 -0
  59. package/core/uploads.mjs.map +1 -0
  60. package/error.d.mts +2 -0
  61. package/error.d.mts.map +1 -0
  62. package/error.d.ts +2 -0
  63. package/error.d.ts.map +1 -0
  64. package/error.js +6 -0
  65. package/error.js.map +1 -0
  66. package/error.mjs +2 -0
  67. package/error.mjs.map +1 -0
  68. package/index.d.mts +7 -0
  69. package/index.d.mts.map +1 -0
  70. package/index.d.ts +7 -0
  71. package/index.d.ts.map +1 -0
  72. package/index.js +32 -0
  73. package/index.js.map +1 -0
  74. package/index.mjs +8 -0
  75. package/index.mjs.map +1 -0
  76. package/internal/builtin-types.d.mts +73 -0
  77. package/internal/builtin-types.d.mts.map +1 -0
  78. package/internal/builtin-types.d.ts +73 -0
  79. package/internal/builtin-types.d.ts.map +1 -0
  80. package/internal/builtin-types.js +4 -0
  81. package/internal/builtin-types.js.map +1 -0
  82. package/internal/builtin-types.mjs +3 -0
  83. package/internal/builtin-types.mjs.map +1 -0
  84. package/internal/detect-platform.d.mts +15 -0
  85. package/internal/detect-platform.d.mts.map +1 -0
  86. package/internal/detect-platform.d.ts +15 -0
  87. package/internal/detect-platform.d.ts.map +1 -0
  88. package/internal/detect-platform.js +162 -0
  89. package/internal/detect-platform.js.map +1 -0
  90. package/internal/detect-platform.mjs +157 -0
  91. package/internal/detect-platform.mjs.map +1 -0
  92. package/internal/errors.d.mts +3 -0
  93. package/internal/errors.d.mts.map +1 -0
  94. package/internal/errors.d.ts +3 -0
  95. package/internal/errors.d.ts.map +1 -0
  96. package/internal/errors.js +41 -0
  97. package/internal/errors.js.map +1 -0
  98. package/internal/errors.mjs +36 -0
  99. package/internal/errors.mjs.map +1 -0
  100. package/internal/headers.d.mts +20 -0
  101. package/internal/headers.d.mts.map +1 -0
  102. package/internal/headers.d.ts +20 -0
  103. package/internal/headers.d.ts.map +1 -0
  104. package/internal/headers.js +79 -0
  105. package/internal/headers.js.map +1 -0
  106. package/internal/headers.mjs +74 -0
  107. package/internal/headers.mjs.map +1 -0
  108. package/internal/parse.d.mts +12 -0
  109. package/internal/parse.d.mts.map +1 -0
  110. package/internal/parse.d.ts +12 -0
  111. package/internal/parse.d.ts.map +1 -0
  112. package/internal/parse.js +35 -0
  113. package/internal/parse.js.map +1 -0
  114. package/internal/parse.mjs +32 -0
  115. package/internal/parse.mjs.map +1 -0
  116. package/internal/request-options.d.mts +75 -0
  117. package/internal/request-options.d.mts.map +1 -0
  118. package/internal/request-options.d.ts +75 -0
  119. package/internal/request-options.d.ts.map +1 -0
  120. package/internal/request-options.js +14 -0
  121. package/internal/request-options.js.map +1 -0
  122. package/internal/request-options.mjs +10 -0
  123. package/internal/request-options.mjs.map +1 -0
  124. package/internal/shim-types.d.mts +17 -0
  125. package/internal/shim-types.d.mts.map +1 -0
  126. package/internal/shim-types.d.ts +17 -0
  127. package/internal/shim-types.d.ts.map +1 -0
  128. package/internal/shim-types.js +4 -0
  129. package/internal/shim-types.js.map +1 -0
  130. package/internal/shim-types.mjs +3 -0
  131. package/internal/shim-types.mjs.map +1 -0
  132. package/internal/shims.d.mts +20 -0
  133. package/internal/shims.d.mts.map +1 -0
  134. package/internal/shims.d.ts +20 -0
  135. package/internal/shims.d.ts.map +1 -0
  136. package/internal/shims.js +92 -0
  137. package/internal/shims.js.map +1 -0
  138. package/internal/shims.mjs +85 -0
  139. package/internal/shims.mjs.map +1 -0
  140. package/internal/to-file.d.mts +45 -0
  141. package/internal/to-file.d.mts.map +1 -0
  142. package/internal/to-file.d.ts +45 -0
  143. package/internal/to-file.d.ts.map +1 -0
  144. package/internal/to-file.js +91 -0
  145. package/internal/to-file.js.map +1 -0
  146. package/internal/to-file.mjs +88 -0
  147. package/internal/to-file.mjs.map +1 -0
  148. package/internal/tslib.js +81 -0
  149. package/internal/tslib.mjs +17 -0
  150. package/internal/types.d.mts +69 -0
  151. package/internal/types.d.mts.map +1 -0
  152. package/internal/types.d.ts +69 -0
  153. package/internal/types.d.ts.map +1 -0
  154. package/internal/types.js +4 -0
  155. package/internal/types.js.map +1 -0
  156. package/internal/types.mjs +3 -0
  157. package/internal/types.mjs.map +1 -0
  158. package/internal/uploads.d.mts +42 -0
  159. package/internal/uploads.d.mts.map +1 -0
  160. package/internal/uploads.d.ts +42 -0
  161. package/internal/uploads.d.ts.map +1 -0
  162. package/internal/uploads.js +141 -0
  163. package/internal/uploads.js.map +1 -0
  164. package/internal/uploads.mjs +131 -0
  165. package/internal/uploads.mjs.map +1 -0
  166. package/internal/utils/base64.d.mts +3 -0
  167. package/internal/utils/base64.d.mts.map +1 -0
  168. package/internal/utils/base64.d.ts +3 -0
  169. package/internal/utils/base64.d.ts.map +1 -0
  170. package/internal/utils/base64.js +38 -0
  171. package/internal/utils/base64.js.map +1 -0
  172. package/internal/utils/base64.mjs +33 -0
  173. package/internal/utils/base64.mjs.map +1 -0
  174. package/internal/utils/bytes.d.mts +4 -0
  175. package/internal/utils/bytes.d.mts.map +1 -0
  176. package/internal/utils/bytes.d.ts +4 -0
  177. package/internal/utils/bytes.d.ts.map +1 -0
  178. package/internal/utils/bytes.js +31 -0
  179. package/internal/utils/bytes.js.map +1 -0
  180. package/internal/utils/bytes.mjs +26 -0
  181. package/internal/utils/bytes.mjs.map +1 -0
  182. package/internal/utils/env.d.mts +9 -0
  183. package/internal/utils/env.d.mts.map +1 -0
  184. package/internal/utils/env.d.ts +9 -0
  185. package/internal/utils/env.d.ts.map +1 -0
  186. package/internal/utils/env.js +22 -0
  187. package/internal/utils/env.js.map +1 -0
  188. package/internal/utils/env.mjs +18 -0
  189. package/internal/utils/env.mjs.map +1 -0
  190. package/internal/utils/log.d.mts +37 -0
  191. package/internal/utils/log.d.mts.map +1 -0
  192. package/internal/utils/log.d.ts +37 -0
  193. package/internal/utils/log.d.ts.map +1 -0
  194. package/internal/utils/log.js +85 -0
  195. package/internal/utils/log.js.map +1 -0
  196. package/internal/utils/log.mjs +79 -0
  197. package/internal/utils/log.mjs.map +1 -0
  198. package/internal/utils/path.d.mts +15 -0
  199. package/internal/utils/path.d.mts.map +1 -0
  200. package/internal/utils/path.d.ts +15 -0
  201. package/internal/utils/path.d.ts.map +1 -0
  202. package/internal/utils/path.js +79 -0
  203. package/internal/utils/path.js.map +1 -0
  204. package/internal/utils/path.mjs +74 -0
  205. package/internal/utils/path.mjs.map +1 -0
  206. package/internal/utils/sleep.d.mts +2 -0
  207. package/internal/utils/sleep.d.mts.map +1 -0
  208. package/internal/utils/sleep.d.ts +2 -0
  209. package/internal/utils/sleep.d.ts.map +1 -0
  210. package/internal/utils/sleep.js +7 -0
  211. package/internal/utils/sleep.js.map +1 -0
  212. package/internal/utils/sleep.mjs +3 -0
  213. package/internal/utils/sleep.mjs.map +1 -0
  214. package/internal/utils/uuid.d.mts +5 -0
  215. package/internal/utils/uuid.d.mts.map +1 -0
  216. package/internal/utils/uuid.d.ts +5 -0
  217. package/internal/utils/uuid.d.ts.map +1 -0
  218. package/internal/utils/uuid.js +19 -0
  219. package/internal/utils/uuid.js.map +1 -0
  220. package/internal/utils/uuid.mjs +15 -0
  221. package/internal/utils/uuid.mjs.map +1 -0
  222. package/internal/utils/values.d.mts +18 -0
  223. package/internal/utils/values.d.mts.map +1 -0
  224. package/internal/utils/values.d.ts +18 -0
  225. package/internal/utils/values.d.ts.map +1 -0
  226. package/internal/utils/values.js +112 -0
  227. package/internal/utils/values.js.map +1 -0
  228. package/internal/utils/values.mjs +94 -0
  229. package/internal/utils/values.mjs.map +1 -0
  230. package/internal/utils.d.mts +7 -0
  231. package/internal/utils.d.mts.map +1 -0
  232. package/internal/utils.d.ts +7 -0
  233. package/internal/utils.d.ts.map +1 -0
  234. package/internal/utils.js +11 -0
  235. package/internal/utils.js.map +1 -0
  236. package/internal/utils.mjs +8 -0
  237. package/internal/utils.mjs.map +1 -0
  238. package/package.json +147 -0
  239. package/pagination.d.mts +2 -0
  240. package/pagination.d.mts.map +1 -0
  241. package/pagination.d.ts +2 -0
  242. package/pagination.d.ts.map +1 -0
  243. package/pagination.js +6 -0
  244. package/pagination.js.map +1 -0
  245. package/pagination.mjs +2 -0
  246. package/pagination.mjs.map +1 -0
  247. package/resource.d.mts +2 -0
  248. package/resource.d.mts.map +1 -0
  249. package/resource.d.ts +2 -0
  250. package/resource.d.ts.map +1 -0
  251. package/resource.js +6 -0
  252. package/resource.js.map +1 -0
  253. package/resource.mjs +2 -0
  254. package/resource.mjs.map +1 -0
  255. package/resources/files.d.mts +102 -0
  256. package/resources/files.d.mts.map +1 -0
  257. package/resources/files.d.ts +102 -0
  258. package/resources/files.d.ts.map +1 -0
  259. package/resources/files.js +75 -0
  260. package/resources/files.js.map +1 -0
  261. package/resources/files.mjs +71 -0
  262. package/resources/files.mjs.map +1 -0
  263. package/resources/index.d.mts +3 -0
  264. package/resources/index.d.mts.map +1 -0
  265. package/resources/index.d.ts +3 -0
  266. package/resources/index.d.ts.map +1 -0
  267. package/resources/index.js +9 -0
  268. package/resources/index.js.map +1 -0
  269. package/resources/index.mjs +4 -0
  270. package/resources/index.mjs.map +1 -0
  271. package/resources/structured-sheets/exports.d.mts +22 -0
  272. package/resources/structured-sheets/exports.d.mts.map +1 -0
  273. package/resources/structured-sheets/exports.d.ts +22 -0
  274. package/resources/structured-sheets/exports.d.ts.map +1 -0
  275. package/resources/structured-sheets/exports.js +33 -0
  276. package/resources/structured-sheets/exports.js.map +1 -0
  277. package/resources/structured-sheets/exports.mjs +29 -0
  278. package/resources/structured-sheets/exports.mjs.map +1 -0
  279. package/resources/structured-sheets/index.d.mts +3 -0
  280. package/resources/structured-sheets/index.d.mts.map +1 -0
  281. package/resources/structured-sheets/index.d.ts +3 -0
  282. package/resources/structured-sheets/index.d.ts.map +1 -0
  283. package/resources/structured-sheets/index.js +9 -0
  284. package/resources/structured-sheets/index.js.map +1 -0
  285. package/resources/structured-sheets/index.mjs +4 -0
  286. package/resources/structured-sheets/index.mjs.map +1 -0
  287. package/resources/structured-sheets/structured-sheets.d.mts +136 -0
  288. package/resources/structured-sheets/structured-sheets.d.mts.map +1 -0
  289. package/resources/structured-sheets/structured-sheets.d.ts +136 -0
  290. package/resources/structured-sheets/structured-sheets.d.ts.map +1 -0
  291. package/resources/structured-sheets/structured-sheets.js +85 -0
  292. package/resources/structured-sheets/structured-sheets.js.map +1 -0
  293. package/resources/structured-sheets/structured-sheets.mjs +80 -0
  294. package/resources/structured-sheets/structured-sheets.mjs.map +1 -0
  295. package/resources/structured-sheets.d.mts +2 -0
  296. package/resources/structured-sheets.d.mts.map +1 -0
  297. package/resources/structured-sheets.d.ts +2 -0
  298. package/resources/structured-sheets.d.ts.map +1 -0
  299. package/resources/structured-sheets.js +6 -0
  300. package/resources/structured-sheets.js.map +1 -0
  301. package/resources/structured-sheets.mjs +3 -0
  302. package/resources/structured-sheets.mjs.map +1 -0
  303. package/resources.d.mts +2 -0
  304. package/resources.d.mts.map +1 -0
  305. package/resources.d.ts +2 -0
  306. package/resources.d.ts.map +1 -0
  307. package/resources.js +5 -0
  308. package/resources.js.map +1 -0
  309. package/resources.mjs +2 -0
  310. package/resources.mjs.map +1 -0
  311. package/src/api-promise.ts +2 -0
  312. package/src/client.ts +773 -0
  313. package/src/core/README.md +3 -0
  314. package/src/core/api-promise.ts +92 -0
  315. package/src/core/error.ts +130 -0
  316. package/src/core/pagination.ts +156 -0
  317. package/src/core/resource.ts +11 -0
  318. package/src/core/uploads.ts +2 -0
  319. package/src/error.ts +2 -0
  320. package/src/index.ts +23 -0
  321. package/src/internal/README.md +3 -0
  322. package/src/internal/builtin-types.ts +93 -0
  323. package/src/internal/detect-platform.ts +196 -0
  324. package/src/internal/errors.ts +33 -0
  325. package/src/internal/headers.ts +97 -0
  326. package/src/internal/parse.ts +50 -0
  327. package/src/internal/request-options.ts +91 -0
  328. package/src/internal/shim-types.ts +26 -0
  329. package/src/internal/shims.ts +107 -0
  330. package/src/internal/to-file.ts +154 -0
  331. package/src/internal/types.ts +95 -0
  332. package/src/internal/uploads.ts +187 -0
  333. package/src/internal/utils/base64.ts +40 -0
  334. package/src/internal/utils/bytes.ts +32 -0
  335. package/src/internal/utils/env.ts +18 -0
  336. package/src/internal/utils/log.ts +126 -0
  337. package/src/internal/utils/path.ts +88 -0
  338. package/src/internal/utils/sleep.ts +3 -0
  339. package/src/internal/utils/uuid.ts +17 -0
  340. package/src/internal/utils/values.ts +105 -0
  341. package/src/internal/utils.ts +8 -0
  342. package/src/lib/.keep +4 -0
  343. package/src/pagination.ts +2 -0
  344. package/src/resource.ts +2 -0
  345. package/src/resources/files.ts +138 -0
  346. package/src/resources/index.ts +16 -0
  347. package/src/resources/structured-sheets/exports.ts +32 -0
  348. package/src/resources/structured-sheets/index.ts +10 -0
  349. package/src/resources/structured-sheets/structured-sheets.ts +184 -0
  350. package/src/resources/structured-sheets.ts +3 -0
  351. package/src/resources.ts +1 -0
  352. package/src/tsconfig.json +11 -0
  353. package/src/uploads.ts +2 -0
  354. package/src/version.ts +1 -0
  355. package/uploads.d.mts +2 -0
  356. package/uploads.d.mts.map +1 -0
  357. package/uploads.d.ts +2 -0
  358. package/uploads.d.ts.map +1 -0
  359. package/uploads.js +6 -0
  360. package/uploads.js.map +1 -0
  361. package/uploads.mjs +2 -0
  362. package/uploads.mjs.map +1 -0
  363. package/version.d.mts +2 -0
  364. package/version.d.mts.map +1 -0
  365. package/version.d.ts +2 -0
  366. package/version.d.ts.map +1 -0
  367. package/version.js +5 -0
  368. package/version.js.map +1 -0
  369. package/version.mjs +2 -0
  370. package/version.mjs.map +1 -0
@@ -0,0 +1,88 @@
1
+ import { DeepTableError } from '../../core/error';
2
+
3
+ /**
4
+ * Percent-encode everything that isn't safe to have in a path without encoding safe chars.
5
+ *
6
+ * Taken from https://datatracker.ietf.org/doc/html/rfc3986#section-3.3:
7
+ * > unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
8
+ * > sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
9
+ * > pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
10
+ */
11
+ export function encodeURIPath(str: string) {
12
+ return str.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
13
+ }
14
+
15
+ const EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
16
+
17
+ export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
18
+ function path(statics: readonly string[], ...params: readonly unknown[]): string {
19
+ // If there are no params, no processing is needed.
20
+ if (statics.length === 1) return statics[0]!;
21
+
22
+ let postPath = false;
23
+ const invalidSegments = [];
24
+ const path = statics.reduce((previousValue, currentValue, index) => {
25
+ if (/[?#]/.test(currentValue)) {
26
+ postPath = true;
27
+ }
28
+ const value = params[index];
29
+ let encoded = (postPath ? encodeURIComponent : pathEncoder)('' + value);
30
+ if (
31
+ index !== params.length &&
32
+ (value == null ||
33
+ (typeof value === 'object' &&
34
+ // handle values from other realms
35
+ value.toString ===
36
+ Object.getPrototypeOf(Object.getPrototypeOf((value as any).hasOwnProperty ?? EMPTY) ?? EMPTY)
37
+ ?.toString))
38
+ ) {
39
+ encoded = value + '';
40
+ invalidSegments.push({
41
+ start: previousValue.length + currentValue.length,
42
+ length: encoded.length,
43
+ error: `Value of type ${Object.prototype.toString
44
+ .call(value)
45
+ .slice(8, -1)} is not a valid path parameter`,
46
+ });
47
+ }
48
+ return previousValue + currentValue + (index === params.length ? '' : encoded);
49
+ }, '');
50
+
51
+ const pathOnly = path.split(/[?#]/, 1)[0]!;
52
+ const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
53
+ let match;
54
+
55
+ // Find all invalid segments
56
+ while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
57
+ invalidSegments.push({
58
+ start: match.index,
59
+ length: match[0].length,
60
+ error: `Value "${match[0]}" can\'t be safely passed as a path parameter`,
61
+ });
62
+ }
63
+
64
+ invalidSegments.sort((a, b) => a.start - b.start);
65
+
66
+ if (invalidSegments.length > 0) {
67
+ let lastEnd = 0;
68
+ const underline = invalidSegments.reduce((acc, segment) => {
69
+ const spaces = ' '.repeat(segment.start - lastEnd);
70
+ const arrows = '^'.repeat(segment.length);
71
+ lastEnd = segment.start + segment.length;
72
+ return acc + spaces + arrows;
73
+ }, '');
74
+
75
+ throw new DeepTableError(
76
+ `Path parameters result in path with invalid segments:\n${invalidSegments
77
+ .map((e) => e.error)
78
+ .join('\n')}\n${path}\n${underline}`,
79
+ );
80
+ }
81
+
82
+ return path;
83
+ };
84
+
85
+ /**
86
+ * URI-encodes path params and ensures no unsafe /./ or /../ path segments are introduced.
87
+ */
88
+ export const path = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export const sleep = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms));
@@ -0,0 +1,17 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ /**
4
+ * https://stackoverflow.com/a/2117523
5
+ */
6
+ export let uuid4 = function () {
7
+ const { crypto } = globalThis as any;
8
+ if (crypto?.randomUUID) {
9
+ uuid4 = crypto.randomUUID.bind(crypto);
10
+ return crypto.randomUUID();
11
+ }
12
+ const u8 = new Uint8Array(1);
13
+ const randomByte = crypto ? () => crypto.getRandomValues(u8)[0]! : () => (Math.random() * 0xff) & 0xff;
14
+ return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) =>
15
+ (+c ^ (randomByte() & (15 >> (+c / 4)))).toString(16),
16
+ );
17
+ };
@@ -0,0 +1,105 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { DeepTableError } from '../../core/error';
4
+
5
+ // https://url.spec.whatwg.org/#url-scheme-string
6
+ const startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i;
7
+
8
+ export const isAbsoluteURL = (url: string): boolean => {
9
+ return startsWithSchemeRegexp.test(url);
10
+ };
11
+
12
+ export let isArray = (val: unknown): val is unknown[] => ((isArray = Array.isArray), isArray(val));
13
+ export let isReadonlyArray = isArray as (val: unknown) => val is readonly unknown[];
14
+
15
+ /** Returns an object if the given value isn't an object, otherwise returns as-is */
16
+ export function maybeObj(x: unknown): object {
17
+ if (typeof x !== 'object') {
18
+ return {};
19
+ }
20
+
21
+ return x ?? {};
22
+ }
23
+
24
+ // https://stackoverflow.com/a/34491287
25
+ export function isEmptyObj(obj: Object | null | undefined): boolean {
26
+ if (!obj) return true;
27
+ for (const _k in obj) return false;
28
+ return true;
29
+ }
30
+
31
+ // https://eslint.org/docs/latest/rules/no-prototype-builtins
32
+ export function hasOwn<T extends object = object>(obj: T, key: PropertyKey): key is keyof T {
33
+ return Object.prototype.hasOwnProperty.call(obj, key);
34
+ }
35
+
36
+ export function isObj(obj: unknown): obj is Record<string, unknown> {
37
+ return obj != null && typeof obj === 'object' && !Array.isArray(obj);
38
+ }
39
+
40
+ export const ensurePresent = <T>(value: T | null | undefined): T => {
41
+ if (value == null) {
42
+ throw new DeepTableError(`Expected a value to be given but received ${value} instead.`);
43
+ }
44
+
45
+ return value;
46
+ };
47
+
48
+ export const validatePositiveInteger = (name: string, n: unknown): number => {
49
+ if (typeof n !== 'number' || !Number.isInteger(n)) {
50
+ throw new DeepTableError(`${name} must be an integer`);
51
+ }
52
+ if (n < 0) {
53
+ throw new DeepTableError(`${name} must be a positive integer`);
54
+ }
55
+ return n;
56
+ };
57
+
58
+ export const coerceInteger = (value: unknown): number => {
59
+ if (typeof value === 'number') return Math.round(value);
60
+ if (typeof value === 'string') return parseInt(value, 10);
61
+
62
+ throw new DeepTableError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
63
+ };
64
+
65
+ export const coerceFloat = (value: unknown): number => {
66
+ if (typeof value === 'number') return value;
67
+ if (typeof value === 'string') return parseFloat(value);
68
+
69
+ throw new DeepTableError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
70
+ };
71
+
72
+ export const coerceBoolean = (value: unknown): boolean => {
73
+ if (typeof value === 'boolean') return value;
74
+ if (typeof value === 'string') return value === 'true';
75
+ return Boolean(value);
76
+ };
77
+
78
+ export const maybeCoerceInteger = (value: unknown): number | undefined => {
79
+ if (value == null) {
80
+ return undefined;
81
+ }
82
+ return coerceInteger(value);
83
+ };
84
+
85
+ export const maybeCoerceFloat = (value: unknown): number | undefined => {
86
+ if (value == null) {
87
+ return undefined;
88
+ }
89
+ return coerceFloat(value);
90
+ };
91
+
92
+ export const maybeCoerceBoolean = (value: unknown): boolean | undefined => {
93
+ if (value == null) {
94
+ return undefined;
95
+ }
96
+ return coerceBoolean(value);
97
+ };
98
+
99
+ export const safeJSON = (text: string) => {
100
+ try {
101
+ return JSON.parse(text);
102
+ } catch (err) {
103
+ return undefined;
104
+ }
105
+ };
@@ -0,0 +1,8 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export * from './utils/values';
4
+ export * from './utils/base64';
5
+ export * from './utils/env';
6
+ export * from './utils/log';
7
+ export * from './utils/uuid';
8
+ export * from './utils/sleep';
package/src/lib/.keep ADDED
@@ -0,0 +1,4 @@
1
+ File generated from our OpenAPI spec by Stainless.
2
+
3
+ This directory can be used to store custom files to expand the SDK.
4
+ It is ignored by Stainless code generation and its content (other than this keep file) won't be touched.
@@ -0,0 +1,2 @@
1
+ /** @deprecated Import from ./core/pagination instead */
2
+ export * from './core/pagination';
@@ -0,0 +1,2 @@
1
+ /** @deprecated Import from ./core/resource instead */
2
+ export * from './core/resource';
@@ -0,0 +1,138 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import { APIPromise } from '../core/api-promise';
5
+ import { CursorIDPage, type CursorIDPageParams, PagePromise } from '../core/pagination';
6
+ import { type Uploadable } from '../core/uploads';
7
+ import { buildHeaders } from '../internal/headers';
8
+ import { RequestOptions } from '../internal/request-options';
9
+ import { multipartFormRequestOptions } from '../internal/uploads';
10
+ import { path } from '../internal/utils/path';
11
+
12
+ export class Files extends APIResource {
13
+ /**
14
+ * Get metadata for a specific file.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const file = await client.files.retrieve(
19
+ * 'file_01abc2def3ghjkmnpqrs4uvwxy',
20
+ * );
21
+ * ```
22
+ */
23
+ retrieve(fileID: string, options?: RequestOptions): APIPromise<File> {
24
+ return this._client.get(path`/v1/files/${fileID}`, options);
25
+ }
26
+
27
+ /**
28
+ * List all files uploaded by the current user.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * // Automatically fetches more pages as needed.
33
+ * for await (const file of client.files.list()) {
34
+ * // ...
35
+ * }
36
+ * ```
37
+ */
38
+ list(
39
+ query: FileListParams | null | undefined = {},
40
+ options?: RequestOptions,
41
+ ): PagePromise<FilesCursorIDPage, File> {
42
+ return this._client.getAPIList('/v1/files', CursorIDPage<File>, { query, ...options });
43
+ }
44
+
45
+ /**
46
+ * Delete a file. This cannot be undone.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * await client.files.delete(
51
+ * 'file_01abc2def3ghjkmnpqrs4uvwxy',
52
+ * );
53
+ * ```
54
+ */
55
+ delete(fileID: string, options?: RequestOptions): APIPromise<void> {
56
+ return this._client.delete(path`/v1/files/${fileID}`, {
57
+ ...options,
58
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
59
+ });
60
+ }
61
+
62
+ /**
63
+ * Upload an Excel spreadsheet file for later processing.
64
+ *
65
+ * Supported formats:
66
+ *
67
+ * - Excel (.xlsx)
68
+ *
69
+ * Maximum file size: 100 MB
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * const file = await client.files.upload({
74
+ * file: fs.createReadStream('path/to/file'),
75
+ * });
76
+ * ```
77
+ */
78
+ upload(body: FileUploadParams, options?: RequestOptions): APIPromise<File> {
79
+ return this._client.post('/v1/files', multipartFormRequestOptions({ body, ...options }, this._client));
80
+ }
81
+ }
82
+
83
+ export type FilesCursorIDPage = CursorIDPage<File>;
84
+
85
+ /**
86
+ * Response representing an uploaded file.
87
+ *
88
+ * This is returned from POST (upload), GET (retrieve), and list endpoints.
89
+ */
90
+ export interface File {
91
+ /**
92
+ * The unique identifier for this file.
93
+ */
94
+ id: string;
95
+
96
+ /**
97
+ * The MIME type of the file.
98
+ */
99
+ content_type: string;
100
+
101
+ /**
102
+ * The timestamp when the file was uploaded.
103
+ */
104
+ created_at: string;
105
+
106
+ /**
107
+ * The original filename of the uploaded file.
108
+ */
109
+ file_name: string;
110
+
111
+ /**
112
+ * The size of the file in bytes.
113
+ */
114
+ size: number;
115
+
116
+ /**
117
+ * The object type, which is always 'file'.
118
+ */
119
+ object?: 'file';
120
+ }
121
+
122
+ export interface FileListParams extends CursorIDPageParams {}
123
+
124
+ export interface FileUploadParams {
125
+ /**
126
+ * The spreadsheet file to upload
127
+ */
128
+ file: Uploadable;
129
+ }
130
+
131
+ export declare namespace Files {
132
+ export {
133
+ type File as File,
134
+ type FilesCursorIDPage as FilesCursorIDPage,
135
+ type FileListParams as FileListParams,
136
+ type FileUploadParams as FileUploadParams,
137
+ };
138
+ }
@@ -0,0 +1,16 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export {
4
+ Files,
5
+ type File,
6
+ type FileListParams,
7
+ type FileUploadParams,
8
+ type FilesCursorIDPage,
9
+ } from './files';
10
+ export {
11
+ StructuredSheets,
12
+ type StructuredSheetResponse,
13
+ type StructuredSheetCreateParams,
14
+ type StructuredSheetListParams,
15
+ type StructuredSheetResponsesCursorIDPage,
16
+ } from './structured-sheets/structured-sheets';
@@ -0,0 +1,32 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import { APIPromise } from '../../core/api-promise';
5
+ import { buildHeaders } from '../../internal/headers';
6
+ import { RequestOptions } from '../../internal/request-options';
7
+ import { path } from '../../internal/utils/path';
8
+
9
+ export class Exports extends APIResource {
10
+ /**
11
+ * Download the structured data as a SQLite database file. Only available when
12
+ * conversion status is 'completed'.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const response =
17
+ * await client.structuredSheets.exports.downloadSqlite(
18
+ * 'ss_01abc2def3ghjkmnpqrs4uvwxy',
19
+ * );
20
+ *
21
+ * const content = await response.blob();
22
+ * console.log(content);
23
+ * ```
24
+ */
25
+ downloadSqlite(structuredSheetsID: string, options?: RequestOptions): APIPromise<Response> {
26
+ return this._client.get(path`/v1/structured-sheets/${structuredSheetsID}/exports/sqlite`, {
27
+ ...options,
28
+ headers: buildHeaders([{ Accept: 'application/x-sqlite3' }, options?.headers]),
29
+ __binaryResponse: true,
30
+ });
31
+ }
32
+ }
@@ -0,0 +1,10 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export { Exports } from './exports';
4
+ export {
5
+ StructuredSheets,
6
+ type StructuredSheetResponse,
7
+ type StructuredSheetCreateParams,
8
+ type StructuredSheetListParams,
9
+ type StructuredSheetResponsesCursorIDPage,
10
+ } from './structured-sheets';
@@ -0,0 +1,184 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import * as ExportsAPI from './exports';
5
+ import { Exports } from './exports';
6
+ import { APIPromise } from '../../core/api-promise';
7
+ import { CursorIDPage, type CursorIDPageParams, PagePromise } from '../../core/pagination';
8
+ import { buildHeaders } from '../../internal/headers';
9
+ import { RequestOptions } from '../../internal/request-options';
10
+ import { path } from '../../internal/utils/path';
11
+
12
+ export class StructuredSheets extends APIResource {
13
+ exports: ExportsAPI.Exports = new ExportsAPI.Exports(this._client);
14
+
15
+ /**
16
+ * Start converting a spreadsheet workbook into structured data. This initiates an
17
+ * asynchronous conversion process. Poll the returned resource using the `id` to
18
+ * check completion status.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * const structuredSheetResponse =
23
+ * await client.structuredSheets.create({
24
+ * file_id: 'file_01h45ytscbebyvny4gc8cr8ma2',
25
+ * });
26
+ * ```
27
+ */
28
+ create(body: StructuredSheetCreateParams, options?: RequestOptions): APIPromise<StructuredSheetResponse> {
29
+ return this._client.post('/v1/structured-sheets', { body, ...options });
30
+ }
31
+
32
+ /**
33
+ * Get the status and details of a structured sheets conversion.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * const structuredSheetResponse =
38
+ * await client.structuredSheets.retrieve(
39
+ * 'ss_01abc2def3ghjkmnpqrs4uvwxy',
40
+ * );
41
+ * ```
42
+ */
43
+ retrieve(structuredSheetsID: string, options?: RequestOptions): APIPromise<StructuredSheetResponse> {
44
+ return this._client.get(path`/v1/structured-sheets/${structuredSheetsID}`, options);
45
+ }
46
+
47
+ /**
48
+ * List all structured sheets conversions for the authenticated user. Results are
49
+ * paginated using cursor-based pagination.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * // Automatically fetches more pages as needed.
54
+ * for await (const structuredSheetResponse of client.structuredSheets.list()) {
55
+ * // ...
56
+ * }
57
+ * ```
58
+ */
59
+ list(
60
+ query: StructuredSheetListParams | null | undefined = {},
61
+ options?: RequestOptions,
62
+ ): PagePromise<StructuredSheetResponsesCursorIDPage, StructuredSheetResponse> {
63
+ return this._client.getAPIList('/v1/structured-sheets', CursorIDPage<StructuredSheetResponse>, {
64
+ query,
65
+ ...options,
66
+ });
67
+ }
68
+
69
+ /**
70
+ * Delete a structured sheets conversion and its associated exports. This action
71
+ * cannot be undone.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * await client.structuredSheets.delete(
76
+ * 'ss_01abc2def3ghjkmnpqrs4uvwxy',
77
+ * );
78
+ * ```
79
+ */
80
+ delete(structuredSheetsID: string, options?: RequestOptions): APIPromise<void> {
81
+ return this._client.delete(path`/v1/structured-sheets/${structuredSheetsID}`, {
82
+ ...options,
83
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
84
+ });
85
+ }
86
+ }
87
+
88
+ export type StructuredSheetResponsesCursorIDPage = CursorIDPage<StructuredSheetResponse>;
89
+
90
+ /**
91
+ * Response representing a structured sheets conversion job.
92
+ *
93
+ * This is returned from POST (create), GET (retrieve), and list endpoints.
94
+ */
95
+ export interface StructuredSheetResponse {
96
+ /**
97
+ * The unique identifier for this structured sheets conversion.
98
+ */
99
+ id: string;
100
+
101
+ /**
102
+ * The timestamp when the conversion was started.
103
+ */
104
+ created_at: string;
105
+
106
+ /**
107
+ * The unique identifier for the source file.
108
+ */
109
+ file_id: string;
110
+
111
+ /**
112
+ * The current processing status.
113
+ */
114
+ status: 'pending' | 'queued' | 'in_progress' | 'completed' | 'failed' | 'cancelled';
115
+
116
+ /**
117
+ * The timestamp when the conversion was last updated.
118
+ */
119
+ updated_at: string;
120
+
121
+ /**
122
+ * List of export formats available for download (e.g., ['sqlite']).
123
+ */
124
+ exports_available?: Array<string>;
125
+
126
+ /**
127
+ * Error information when processing fails.
128
+ */
129
+ last_error?: StructuredSheetResponse.LastError | null;
130
+
131
+ /**
132
+ * The object type, which is always 'structured_sheet'.
133
+ */
134
+ object?: 'structured_sheet';
135
+
136
+ /**
137
+ * List of sheet names included in this conversion.
138
+ */
139
+ sheet_names?: Array<string>;
140
+ }
141
+
142
+ export namespace StructuredSheetResponse {
143
+ /**
144
+ * Error information when processing fails.
145
+ */
146
+ export interface LastError {
147
+ /**
148
+ * A machine-readable error code.
149
+ */
150
+ code: string;
151
+
152
+ /**
153
+ * A human-readable description of the error.
154
+ */
155
+ message: string;
156
+ }
157
+ }
158
+
159
+ export interface StructuredSheetCreateParams {
160
+ /**
161
+ * The unique identifier of the file to convert.
162
+ */
163
+ file_id: string;
164
+
165
+ /**
166
+ * List of sheet names to convert. If None, all sheets will be converted.
167
+ */
168
+ sheet_names?: Array<string> | null;
169
+ }
170
+
171
+ export interface StructuredSheetListParams extends CursorIDPageParams {}
172
+
173
+ StructuredSheets.Exports = Exports;
174
+
175
+ export declare namespace StructuredSheets {
176
+ export {
177
+ type StructuredSheetResponse as StructuredSheetResponse,
178
+ type StructuredSheetResponsesCursorIDPage as StructuredSheetResponsesCursorIDPage,
179
+ type StructuredSheetCreateParams as StructuredSheetCreateParams,
180
+ type StructuredSheetListParams as StructuredSheetListParams,
181
+ };
182
+
183
+ export { Exports as Exports };
184
+ }
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export * from './structured-sheets/index';
@@ -0,0 +1 @@
1
+ export * from './resources/index';
@@ -0,0 +1,11 @@
1
+ {
2
+ // this config is included in the published src directory to prevent TS errors
3
+ // from appearing when users go to source, and VSCode opens the source .ts file
4
+ // via declaration maps
5
+ "include": ["index.ts"],
6
+ "compilerOptions": {
7
+ "target": "ES2015",
8
+ "lib": ["DOM", "DOM.Iterable", "ES2018"],
9
+ "moduleResolution": "node"
10
+ }
11
+ }
package/src/uploads.ts ADDED
@@ -0,0 +1,2 @@
1
+ /** @deprecated Import from ./core/uploads instead */
2
+ export * from './core/uploads';
package/src/version.ts ADDED
@@ -0,0 +1 @@
1
+ export const VERSION = '0.1.0-alpha.1'; // x-release-please-version
package/uploads.d.mts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./core/uploads.mjs";
2
+ //# sourceMappingURL=uploads.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploads.d.mts","sourceRoot":"","sources":["src/uploads.ts"],"names":[],"mappings":""}
package/uploads.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./core/uploads.js";
2
+ //# sourceMappingURL=uploads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploads.d.ts","sourceRoot":"","sources":["src/uploads.ts"],"names":[],"mappings":""}
package/uploads.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("./internal/tslib.js");
4
+ /** @deprecated Import from ./core/uploads instead */
5
+ tslib_1.__exportStar(require("./core/uploads.js"), exports);
6
+ //# sourceMappingURL=uploads.js.map
package/uploads.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploads.js","sourceRoot":"","sources":["src/uploads.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,4DAA+B"}
package/uploads.mjs ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./core/uploads.mjs";
2
+ //# sourceMappingURL=uploads.mjs.map