@letta-ai/letta-client 0.1.169 → 0.1.172

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 (330) hide show
  1. package/README.md +16 -3
  2. package/api/errors/BadRequestError.d.ts +2 -1
  3. package/api/errors/BadRequestError.js +2 -1
  4. package/api/errors/ConflictError.d.ts +2 -1
  5. package/api/errors/ConflictError.js +2 -1
  6. package/api/errors/InternalServerError.d.ts +2 -1
  7. package/api/errors/InternalServerError.js +2 -1
  8. package/api/errors/NotFoundError.d.ts +2 -1
  9. package/api/errors/NotFoundError.js +2 -1
  10. package/api/errors/PaymentRequiredError.d.ts +2 -1
  11. package/api/errors/PaymentRequiredError.js +2 -1
  12. package/api/errors/UnprocessableEntityError.d.ts +2 -1
  13. package/api/errors/UnprocessableEntityError.js +2 -1
  14. package/api/resources/agents/client/Client.d.ts +20 -10
  15. package/api/resources/agents/client/Client.js +166 -82
  16. package/api/resources/agents/resources/blocks/client/Client.d.ts +10 -5
  17. package/api/resources/agents/resources/blocks/client/Client.js +90 -45
  18. package/api/resources/agents/resources/context/client/Client.d.ts +2 -1
  19. package/api/resources/agents/resources/context/client/Client.js +18 -9
  20. package/api/resources/agents/resources/coreMemory/client/Client.d.ts +2 -1
  21. package/api/resources/agents/resources/coreMemory/client/Client.js +18 -9
  22. package/api/resources/agents/resources/files/client/Client.d.ts +6 -3
  23. package/api/resources/agents/resources/files/client/Client.js +45 -21
  24. package/api/resources/agents/resources/folders/client/Client.d.ts +6 -3
  25. package/api/resources/agents/resources/folders/client/Client.js +54 -27
  26. package/api/resources/agents/resources/groups/client/Client.d.ts +2 -1
  27. package/api/resources/agents/resources/groups/client/Client.js +19 -10
  28. package/api/resources/agents/resources/memoryVariables/client/Client.d.ts +2 -1
  29. package/api/resources/agents/resources/memoryVariables/client/Client.js +18 -9
  30. package/api/resources/agents/resources/messages/client/Client.d.ts +16 -8
  31. package/api/resources/agents/resources/messages/client/Client.js +155 -83
  32. package/api/resources/agents/resources/passages/client/Client.d.ts +8 -4
  33. package/api/resources/agents/resources/passages/client/Client.js +64 -31
  34. package/api/resources/agents/resources/sources/client/Client.d.ts +6 -3
  35. package/api/resources/agents/resources/sources/client/Client.js +54 -27
  36. package/api/resources/agents/resources/templates/client/Client.d.ts +6 -3
  37. package/api/resources/agents/resources/templates/client/Client.js +54 -27
  38. package/api/resources/agents/resources/tools/client/Client.d.ts +6 -3
  39. package/api/resources/agents/resources/tools/client/Client.js +54 -27
  40. package/api/resources/batches/client/Client.d.ts +8 -4
  41. package/api/resources/batches/client/Client.js +63 -30
  42. package/api/resources/blocks/client/Client.d.ts +12 -6
  43. package/api/resources/blocks/client/Client.js +100 -49
  44. package/api/resources/blocks/resources/agents/client/Client.d.ts +2 -1
  45. package/api/resources/blocks/resources/agents/client/Client.js +19 -10
  46. package/api/resources/clientSideAccessTokens/client/Client.d.ts +6 -3
  47. package/api/resources/clientSideAccessTokens/client/Client.js +46 -22
  48. package/api/resources/embeddingModels/client/Client.d.ts +2 -1
  49. package/api/resources/embeddingModels/client/Client.js +18 -9
  50. package/api/resources/folders/client/Client.d.ts +18 -9
  51. package/api/resources/folders/client/Client.js +154 -76
  52. package/api/resources/folders/resources/files/client/Client.d.ts +6 -3
  53. package/api/resources/folders/resources/files/client/Client.js +48 -24
  54. package/api/resources/folders/resources/passages/client/Client.d.ts +2 -1
  55. package/api/resources/folders/resources/passages/client/Client.js +19 -10
  56. package/api/resources/groups/client/Client.d.ts +12 -6
  57. package/api/resources/groups/client/Client.js +105 -52
  58. package/api/resources/groups/resources/messages/client/Client.d.ts +10 -5
  59. package/api/resources/groups/resources/messages/client/Client.js +91 -49
  60. package/api/resources/health/client/Client.d.ts +2 -1
  61. package/api/resources/health/client/Client.js +17 -8
  62. package/api/resources/identities/client/Client.d.ts +14 -7
  63. package/api/resources/identities/client/Client.js +123 -61
  64. package/api/resources/identities/resources/properties/client/Client.d.ts +2 -1
  65. package/api/resources/identities/resources/properties/client/Client.js +9 -3
  66. package/api/resources/jobs/client/Client.d.ts +10 -5
  67. package/api/resources/jobs/client/Client.js +92 -47
  68. package/api/resources/messages/client/Client.d.ts +2 -1
  69. package/api/resources/messages/client/Client.js +19 -10
  70. package/api/resources/models/client/Client.d.ts +2 -1
  71. package/api/resources/models/client/Client.js +27 -14
  72. package/api/resources/projects/client/Client.d.ts +2 -1
  73. package/api/resources/projects/client/Client.js +18 -9
  74. package/api/resources/providers/client/Client.d.ts +10 -5
  75. package/api/resources/providers/client/Client.js +77 -36
  76. package/api/resources/runs/client/Client.d.ts +8 -4
  77. package/api/resources/runs/client/Client.js +74 -38
  78. package/api/resources/runs/resources/messages/client/Client.d.ts +2 -1
  79. package/api/resources/runs/resources/messages/client/Client.js +21 -12
  80. package/api/resources/runs/resources/steps/client/Client.d.ts +2 -1
  81. package/api/resources/runs/resources/steps/client/Client.js +19 -10
  82. package/api/resources/runs/resources/usage/client/Client.d.ts +2 -1
  83. package/api/resources/runs/resources/usage/client/Client.js +18 -9
  84. package/api/resources/sources/client/Client.d.ts +20 -10
  85. package/api/resources/sources/client/Client.js +173 -86
  86. package/api/resources/sources/resources/files/client/Client.d.ts +6 -3
  87. package/api/resources/sources/resources/files/client/Client.js +48 -24
  88. package/api/resources/sources/resources/passages/client/Client.d.ts +2 -1
  89. package/api/resources/sources/resources/passages/client/Client.js +19 -10
  90. package/api/resources/steps/client/Client.d.ts +4 -2
  91. package/api/resources/steps/client/Client.js +41 -21
  92. package/api/resources/steps/resources/feedback/client/Client.d.ts +2 -1
  93. package/api/resources/steps/resources/feedback/client/Client.js +23 -12
  94. package/api/resources/tags/client/Client.d.ts +2 -1
  95. package/api/resources/tags/client/Client.js +19 -10
  96. package/api/resources/telemetry/client/Client.d.ts +2 -1
  97. package/api/resources/telemetry/client/Client.js +18 -9
  98. package/api/resources/templates/client/Client.d.ts +2 -1
  99. package/api/resources/templates/client/Client.js +18 -9
  100. package/api/resources/templates/resources/agents/client/Client.d.ts +2 -1
  101. package/api/resources/templates/resources/agents/client/Client.js +19 -10
  102. package/api/resources/tools/client/Client.d.ts +40 -20
  103. package/api/resources/tools/client/Client.js +356 -182
  104. package/api/resources/voice/client/Client.d.ts +2 -1
  105. package/api/resources/voice/client/Client.js +9 -3
  106. package/api/types/LettaStreamingRequest.d.ts +2 -0
  107. package/api/types/ModalSandboxConfig.d.ts +9 -0
  108. package/api/types/ModalSandboxConfig.js +5 -0
  109. package/api/types/SandboxConfigCreateConfig.d.ts +1 -1
  110. package/api/types/SandboxConfigUpdateConfig.d.ts +1 -1
  111. package/api/types/SandboxType.d.ts +2 -1
  112. package/api/types/SandboxType.js +1 -0
  113. package/api/types/ToolType.d.ts +1 -2
  114. package/api/types/ToolType.js +0 -1
  115. package/api/types/index.d.ts +1 -0
  116. package/api/types/index.js +1 -0
  117. package/core/fetcher/APIResponse.d.ts +10 -0
  118. package/core/fetcher/Fetcher.d.ts +1 -1
  119. package/core/fetcher/Fetcher.js +11 -3
  120. package/core/fetcher/Headers.d.ts +2 -0
  121. package/core/fetcher/Headers.js +84 -0
  122. package/core/fetcher/HttpResponsePromise.d.ts +58 -0
  123. package/core/fetcher/HttpResponsePromise.js +103 -0
  124. package/core/fetcher/RawResponse.d.ts +29 -0
  125. package/core/fetcher/RawResponse.js +44 -0
  126. package/core/fetcher/createRequestUrl.d.ts +1 -1
  127. package/core/fetcher/getRequestBody.js +2 -1
  128. package/core/fetcher/index.d.ts +3 -0
  129. package/core/fetcher/index.js +7 -1
  130. package/core/fetcher/requestWithRetries.js +1 -1
  131. package/core/form-data-utils/FormDataWrapper.d.ts +3 -0
  132. package/core/form-data-utils/FormDataWrapper.js +53 -10
  133. package/core/form-data-utils/encodeAsFormParameter.d.ts +4 -0
  134. package/core/form-data-utils/encodeAsFormParameter.js +18 -0
  135. package/core/form-data-utils/index.d.ts +1 -0
  136. package/core/form-data-utils/index.js +3 -0
  137. package/core/json.d.ts +15 -0
  138. package/core/json.js +24 -0
  139. package/core/schemas/Schema.d.ts +2 -0
  140. package/core/schemas/Schema.js +2 -0
  141. package/core/schemas/builders/bigint/bigint.d.ts +1 -1
  142. package/core/schemas/builders/bigint/bigint.js +21 -17
  143. package/core/schemas/builders/object/object.js +1 -0
  144. package/core/schemas/builders/record/record.js +1 -2
  145. package/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +4 -0
  146. package/core/schemas/builders/schema-utils/getSchemaUtils.js +64 -0
  147. package/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts +1 -1
  148. package/dist/api/errors/BadRequestError.d.ts +2 -1
  149. package/dist/api/errors/BadRequestError.js +2 -1
  150. package/dist/api/errors/ConflictError.d.ts +2 -1
  151. package/dist/api/errors/ConflictError.js +2 -1
  152. package/dist/api/errors/InternalServerError.d.ts +2 -1
  153. package/dist/api/errors/InternalServerError.js +2 -1
  154. package/dist/api/errors/NotFoundError.d.ts +2 -1
  155. package/dist/api/errors/NotFoundError.js +2 -1
  156. package/dist/api/errors/PaymentRequiredError.d.ts +2 -1
  157. package/dist/api/errors/PaymentRequiredError.js +2 -1
  158. package/dist/api/errors/UnprocessableEntityError.d.ts +2 -1
  159. package/dist/api/errors/UnprocessableEntityError.js +2 -1
  160. package/dist/api/resources/agents/client/Client.d.ts +20 -10
  161. package/dist/api/resources/agents/client/Client.js +166 -82
  162. package/dist/api/resources/agents/resources/blocks/client/Client.d.ts +10 -5
  163. package/dist/api/resources/agents/resources/blocks/client/Client.js +90 -45
  164. package/dist/api/resources/agents/resources/context/client/Client.d.ts +2 -1
  165. package/dist/api/resources/agents/resources/context/client/Client.js +18 -9
  166. package/dist/api/resources/agents/resources/coreMemory/client/Client.d.ts +2 -1
  167. package/dist/api/resources/agents/resources/coreMemory/client/Client.js +18 -9
  168. package/dist/api/resources/agents/resources/files/client/Client.d.ts +6 -3
  169. package/dist/api/resources/agents/resources/files/client/Client.js +45 -21
  170. package/dist/api/resources/agents/resources/folders/client/Client.d.ts +6 -3
  171. package/dist/api/resources/agents/resources/folders/client/Client.js +54 -27
  172. package/dist/api/resources/agents/resources/groups/client/Client.d.ts +2 -1
  173. package/dist/api/resources/agents/resources/groups/client/Client.js +19 -10
  174. package/dist/api/resources/agents/resources/memoryVariables/client/Client.d.ts +2 -1
  175. package/dist/api/resources/agents/resources/memoryVariables/client/Client.js +18 -9
  176. package/dist/api/resources/agents/resources/messages/client/Client.d.ts +16 -8
  177. package/dist/api/resources/agents/resources/messages/client/Client.js +155 -83
  178. package/dist/api/resources/agents/resources/passages/client/Client.d.ts +8 -4
  179. package/dist/api/resources/agents/resources/passages/client/Client.js +64 -31
  180. package/dist/api/resources/agents/resources/sources/client/Client.d.ts +6 -3
  181. package/dist/api/resources/agents/resources/sources/client/Client.js +54 -27
  182. package/dist/api/resources/agents/resources/templates/client/Client.d.ts +6 -3
  183. package/dist/api/resources/agents/resources/templates/client/Client.js +54 -27
  184. package/dist/api/resources/agents/resources/tools/client/Client.d.ts +6 -3
  185. package/dist/api/resources/agents/resources/tools/client/Client.js +54 -27
  186. package/dist/api/resources/batches/client/Client.d.ts +8 -4
  187. package/dist/api/resources/batches/client/Client.js +63 -30
  188. package/dist/api/resources/blocks/client/Client.d.ts +12 -6
  189. package/dist/api/resources/blocks/client/Client.js +100 -49
  190. package/dist/api/resources/blocks/resources/agents/client/Client.d.ts +2 -1
  191. package/dist/api/resources/blocks/resources/agents/client/Client.js +19 -10
  192. package/dist/api/resources/clientSideAccessTokens/client/Client.d.ts +6 -3
  193. package/dist/api/resources/clientSideAccessTokens/client/Client.js +46 -22
  194. package/dist/api/resources/embeddingModels/client/Client.d.ts +2 -1
  195. package/dist/api/resources/embeddingModels/client/Client.js +18 -9
  196. package/dist/api/resources/folders/client/Client.d.ts +18 -9
  197. package/dist/api/resources/folders/client/Client.js +154 -76
  198. package/dist/api/resources/folders/resources/files/client/Client.d.ts +6 -3
  199. package/dist/api/resources/folders/resources/files/client/Client.js +48 -24
  200. package/dist/api/resources/folders/resources/passages/client/Client.d.ts +2 -1
  201. package/dist/api/resources/folders/resources/passages/client/Client.js +19 -10
  202. package/dist/api/resources/groups/client/Client.d.ts +12 -6
  203. package/dist/api/resources/groups/client/Client.js +105 -52
  204. package/dist/api/resources/groups/resources/messages/client/Client.d.ts +10 -5
  205. package/dist/api/resources/groups/resources/messages/client/Client.js +91 -49
  206. package/dist/api/resources/health/client/Client.d.ts +2 -1
  207. package/dist/api/resources/health/client/Client.js +17 -8
  208. package/dist/api/resources/identities/client/Client.d.ts +14 -7
  209. package/dist/api/resources/identities/client/Client.js +123 -61
  210. package/dist/api/resources/identities/resources/properties/client/Client.d.ts +2 -1
  211. package/dist/api/resources/identities/resources/properties/client/Client.js +9 -3
  212. package/dist/api/resources/jobs/client/Client.d.ts +10 -5
  213. package/dist/api/resources/jobs/client/Client.js +92 -47
  214. package/dist/api/resources/messages/client/Client.d.ts +2 -1
  215. package/dist/api/resources/messages/client/Client.js +19 -10
  216. package/dist/api/resources/models/client/Client.d.ts +2 -1
  217. package/dist/api/resources/models/client/Client.js +27 -14
  218. package/dist/api/resources/projects/client/Client.d.ts +2 -1
  219. package/dist/api/resources/projects/client/Client.js +18 -9
  220. package/dist/api/resources/providers/client/Client.d.ts +10 -5
  221. package/dist/api/resources/providers/client/Client.js +77 -36
  222. package/dist/api/resources/runs/client/Client.d.ts +8 -4
  223. package/dist/api/resources/runs/client/Client.js +74 -38
  224. package/dist/api/resources/runs/resources/messages/client/Client.d.ts +2 -1
  225. package/dist/api/resources/runs/resources/messages/client/Client.js +21 -12
  226. package/dist/api/resources/runs/resources/steps/client/Client.d.ts +2 -1
  227. package/dist/api/resources/runs/resources/steps/client/Client.js +19 -10
  228. package/dist/api/resources/runs/resources/usage/client/Client.d.ts +2 -1
  229. package/dist/api/resources/runs/resources/usage/client/Client.js +18 -9
  230. package/dist/api/resources/sources/client/Client.d.ts +20 -10
  231. package/dist/api/resources/sources/client/Client.js +173 -86
  232. package/dist/api/resources/sources/resources/files/client/Client.d.ts +6 -3
  233. package/dist/api/resources/sources/resources/files/client/Client.js +48 -24
  234. package/dist/api/resources/sources/resources/passages/client/Client.d.ts +2 -1
  235. package/dist/api/resources/sources/resources/passages/client/Client.js +19 -10
  236. package/dist/api/resources/steps/client/Client.d.ts +4 -2
  237. package/dist/api/resources/steps/client/Client.js +41 -21
  238. package/dist/api/resources/steps/resources/feedback/client/Client.d.ts +2 -1
  239. package/dist/api/resources/steps/resources/feedback/client/Client.js +23 -12
  240. package/dist/api/resources/tags/client/Client.d.ts +2 -1
  241. package/dist/api/resources/tags/client/Client.js +19 -10
  242. package/dist/api/resources/telemetry/client/Client.d.ts +2 -1
  243. package/dist/api/resources/telemetry/client/Client.js +18 -9
  244. package/dist/api/resources/templates/client/Client.d.ts +2 -1
  245. package/dist/api/resources/templates/client/Client.js +18 -9
  246. package/dist/api/resources/templates/resources/agents/client/Client.d.ts +2 -1
  247. package/dist/api/resources/templates/resources/agents/client/Client.js +19 -10
  248. package/dist/api/resources/tools/client/Client.d.ts +40 -20
  249. package/dist/api/resources/tools/client/Client.js +356 -182
  250. package/dist/api/resources/voice/client/Client.d.ts +2 -1
  251. package/dist/api/resources/voice/client/Client.js +9 -3
  252. package/dist/api/types/LettaStreamingRequest.d.ts +2 -0
  253. package/dist/api/types/ModalSandboxConfig.d.ts +9 -0
  254. package/dist/api/types/ModalSandboxConfig.js +5 -0
  255. package/dist/api/types/SandboxConfigCreateConfig.d.ts +1 -1
  256. package/dist/api/types/SandboxConfigUpdateConfig.d.ts +1 -1
  257. package/dist/api/types/SandboxType.d.ts +2 -1
  258. package/dist/api/types/SandboxType.js +1 -0
  259. package/dist/api/types/ToolType.d.ts +1 -2
  260. package/dist/api/types/ToolType.js +0 -1
  261. package/dist/api/types/index.d.ts +1 -0
  262. package/dist/api/types/index.js +1 -0
  263. package/dist/core/fetcher/APIResponse.d.ts +10 -0
  264. package/dist/core/fetcher/Fetcher.d.ts +1 -1
  265. package/dist/core/fetcher/Fetcher.js +11 -3
  266. package/dist/core/fetcher/Headers.d.ts +2 -0
  267. package/dist/core/fetcher/Headers.js +84 -0
  268. package/dist/core/fetcher/HttpResponsePromise.d.ts +58 -0
  269. package/dist/core/fetcher/HttpResponsePromise.js +103 -0
  270. package/dist/core/fetcher/RawResponse.d.ts +29 -0
  271. package/dist/core/fetcher/RawResponse.js +44 -0
  272. package/dist/core/fetcher/createRequestUrl.d.ts +1 -1
  273. package/dist/core/fetcher/getRequestBody.js +2 -1
  274. package/dist/core/fetcher/index.d.ts +3 -0
  275. package/dist/core/fetcher/index.js +7 -1
  276. package/dist/core/fetcher/requestWithRetries.js +1 -1
  277. package/dist/core/form-data-utils/FormDataWrapper.d.ts +3 -0
  278. package/dist/core/form-data-utils/FormDataWrapper.js +53 -10
  279. package/dist/core/form-data-utils/encodeAsFormParameter.d.ts +4 -0
  280. package/dist/core/form-data-utils/encodeAsFormParameter.js +18 -0
  281. package/dist/core/form-data-utils/index.d.ts +1 -0
  282. package/dist/core/form-data-utils/index.js +3 -0
  283. package/dist/core/json.d.ts +15 -0
  284. package/dist/core/json.js +24 -0
  285. package/dist/core/schemas/Schema.d.ts +2 -0
  286. package/dist/core/schemas/Schema.js +2 -0
  287. package/dist/core/schemas/builders/bigint/bigint.d.ts +1 -1
  288. package/dist/core/schemas/builders/bigint/bigint.js +21 -17
  289. package/dist/core/schemas/builders/object/object.js +1 -0
  290. package/dist/core/schemas/builders/record/record.js +1 -2
  291. package/dist/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +4 -0
  292. package/dist/core/schemas/builders/schema-utils/getSchemaUtils.js +64 -0
  293. package/dist/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts +1 -1
  294. package/dist/errors/LettaError.d.ts +4 -1
  295. package/dist/errors/LettaError.js +6 -8
  296. package/dist/serialization/types/LettaStreamingRequest.d.ts +1 -0
  297. package/dist/serialization/types/LettaStreamingRequest.js +1 -0
  298. package/dist/serialization/types/ModalSandboxConfig.d.ts +13 -0
  299. package/dist/serialization/types/ModalSandboxConfig.js +44 -0
  300. package/dist/serialization/types/SandboxConfigCreateConfig.d.ts +2 -1
  301. package/dist/serialization/types/SandboxConfigCreateConfig.js +2 -1
  302. package/dist/serialization/types/SandboxConfigUpdateConfig.d.ts +2 -1
  303. package/dist/serialization/types/SandboxConfigUpdateConfig.js +2 -1
  304. package/dist/serialization/types/SandboxType.d.ts +1 -1
  305. package/dist/serialization/types/SandboxType.js +1 -1
  306. package/dist/serialization/types/ToolType.d.ts +1 -1
  307. package/dist/serialization/types/ToolType.js +0 -1
  308. package/dist/serialization/types/index.d.ts +1 -0
  309. package/dist/serialization/types/index.js +1 -0
  310. package/dist/version.d.ts +1 -1
  311. package/dist/version.js +1 -1
  312. package/errors/LettaError.d.ts +4 -1
  313. package/errors/LettaError.js +6 -8
  314. package/package.json +4 -4
  315. package/serialization/types/LettaStreamingRequest.d.ts +1 -0
  316. package/serialization/types/LettaStreamingRequest.js +1 -0
  317. package/serialization/types/ModalSandboxConfig.d.ts +13 -0
  318. package/serialization/types/ModalSandboxConfig.js +44 -0
  319. package/serialization/types/SandboxConfigCreateConfig.d.ts +2 -1
  320. package/serialization/types/SandboxConfigCreateConfig.js +2 -1
  321. package/serialization/types/SandboxConfigUpdateConfig.d.ts +2 -1
  322. package/serialization/types/SandboxConfigUpdateConfig.js +2 -1
  323. package/serialization/types/SandboxType.d.ts +1 -1
  324. package/serialization/types/SandboxType.js +1 -1
  325. package/serialization/types/ToolType.d.ts +1 -1
  326. package/serialization/types/ToolType.js +0 -1
  327. package/serialization/types/index.d.ts +1 -0
  328. package/serialization/types/index.js +1 -0
  329. package/version.d.ts +1 -1
  330. package/version.js +1 -1
@@ -21,6 +21,7 @@ export declare class Node18FormData implements CrossPlatformFormData {
21
21
  private fd;
22
22
  setup(): Promise<void>;
23
23
  append(key: string, value: any): void;
24
+ private getFileName;
24
25
  appendFile(key: string, value: unknown, fileName?: string): Promise<void>;
25
26
  getRequest(): Promise<FormDataRequest<unknown>>;
26
27
  }
@@ -41,6 +42,7 @@ export declare class Node16FormData implements CrossPlatformFormData {
41
42
  private fd;
42
43
  setup(): Promise<void>;
43
44
  append(key: string, value: any): void;
45
+ private getFileName;
44
46
  appendFile(key: string, value: unknown, fileName?: string): Promise<void>;
45
47
  getRequest(): FormDataRequest<Node16FormDataFd>;
46
48
  }
@@ -54,6 +56,7 @@ export declare class WebFormData implements CrossPlatformFormData {
54
56
  protected fd: WebFormDataFd;
55
57
  setup(): Promise<void>;
56
58
  append(key: string, value: any): void;
59
+ private getFileName;
57
60
  appendFile(key: string, value: any, fileName?: string): Promise<void>;
58
61
  getRequest(): FormDataRequest<WebFormDataFd>;
59
62
  }
@@ -48,6 +48,15 @@ const runtime_1 = require("../runtime");
48
48
  function isNamedValue(value) {
49
49
  return typeof value === "object" && value != null && "name" in value;
50
50
  }
51
+ function isPathedValue(value) {
52
+ return typeof value === "object" && value != null && "path" in value;
53
+ }
54
+ function getLastPathSegment(pathStr) {
55
+ const lastForwardSlash = pathStr.lastIndexOf("/");
56
+ const lastBackSlash = pathStr.lastIndexOf("\\");
57
+ const lastSlashIndex = Math.max(lastForwardSlash, lastBackSlash);
58
+ return lastSlashIndex >= 0 ? pathStr.substring(lastSlashIndex + 1) : pathStr;
59
+ }
51
60
  function newFormData() {
52
61
  return __awaiter(this, void 0, void 0, function* () {
53
62
  let formdata;
@@ -77,12 +86,22 @@ class Node18FormData {
77
86
  var _a;
78
87
  (_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, value);
79
88
  }
89
+ getFileName(value, filename) {
90
+ if (filename != null) {
91
+ return filename;
92
+ }
93
+ if (isNamedValue(value)) {
94
+ return value.name;
95
+ }
96
+ if (isPathedValue(value) && value.path) {
97
+ return getLastPathSegment(value.path.toString());
98
+ }
99
+ return undefined;
100
+ }
80
101
  appendFile(key, value, fileName) {
81
102
  return __awaiter(this, void 0, void 0, function* () {
82
103
  var _a, _b;
83
- if (fileName == null && isNamedValue(value)) {
84
- fileName = value.name;
85
- }
104
+ fileName = this.getFileName(value, fileName);
86
105
  if (value instanceof Blob) {
87
106
  (_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, value, fileName);
88
107
  }
@@ -123,12 +142,22 @@ class Node16FormData {
123
142
  var _a;
124
143
  (_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, value);
125
144
  }
145
+ getFileName(value, filename) {
146
+ if (filename != null) {
147
+ return filename;
148
+ }
149
+ if (isNamedValue(value)) {
150
+ return value.name;
151
+ }
152
+ if (isPathedValue(value) && value.path) {
153
+ return getLastPathSegment(value.path.toString());
154
+ }
155
+ return undefined;
156
+ }
126
157
  appendFile(key, value, fileName) {
127
158
  return __awaiter(this, void 0, void 0, function* () {
128
159
  var _a, _b;
129
- if (fileName == null && isNamedValue(value)) {
130
- fileName = value.name;
131
- }
160
+ fileName = this.getFileName(value, fileName);
132
161
  let bufferedValue;
133
162
  if (value instanceof Blob) {
134
163
  bufferedValue = Buffer.from(yield value.arrayBuffer());
@@ -165,13 +194,27 @@ class WebFormData {
165
194
  var _a;
166
195
  (_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, value);
167
196
  }
197
+ getFileName(value, filename) {
198
+ if (filename != null) {
199
+ return filename;
200
+ }
201
+ if (isNamedValue(value)) {
202
+ return value.name;
203
+ }
204
+ if (isPathedValue(value) && value.path) {
205
+ return getLastPathSegment(value.path.toString());
206
+ }
207
+ return undefined;
208
+ }
168
209
  appendFile(key, value, fileName) {
169
210
  return __awaiter(this, void 0, void 0, function* () {
170
- var _a;
171
- if (fileName == null && isNamedValue(value)) {
172
- fileName = value.name;
211
+ var _a, _b;
212
+ fileName = this.getFileName(value, fileName);
213
+ if (value instanceof Blob) {
214
+ (_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, value, fileName);
215
+ return;
173
216
  }
174
- (_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, new Blob([value]), fileName);
217
+ (_b = this.fd) === null || _b === void 0 ? void 0 : _b.append(key, new Blob([value]), fileName);
175
218
  });
176
219
  }
177
220
  getRequest() {
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Takes an unknown value, stringifies it using qs, and parses it into a key-value record
3
+ */
4
+ export declare function encodeAsFormParameter(value: unknown): Record<string, string>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.encodeAsFormParameter = encodeAsFormParameter;
7
+ const qs_1 = __importDefault(require("qs"));
8
+ /**
9
+ * Takes an unknown value, stringifies it using qs, and parses it into a key-value record
10
+ */
11
+ function encodeAsFormParameter(value) {
12
+ const stringified = qs_1.default.stringify(value, { encode: false });
13
+ const keyValuePairs = stringified.split("&").map((pair) => {
14
+ const [key, value] = pair.split("=");
15
+ return [key, value];
16
+ });
17
+ return Object.fromEntries(keyValuePairs);
18
+ }
@@ -1 +1,2 @@
1
+ export { encodeAsFormParameter } from "./encodeAsFormParameter";
1
2
  export * from "./FormDataWrapper";
@@ -14,4 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.encodeAsFormParameter = void 0;
18
+ var encodeAsFormParameter_1 = require("./encodeAsFormParameter");
19
+ Object.defineProperty(exports, "encodeAsFormParameter", { enumerable: true, get: function () { return encodeAsFormParameter_1.encodeAsFormParameter; } });
17
20
  __exportStar(require("./FormDataWrapper"), exports);
package/core/json.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Serialize a value to JSON
3
+ * @param value A JavaScript value, usually an object or array, to be converted.
4
+ * @param replacer A function that transforms the results.
5
+ * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
6
+ * @returns JSON string
7
+ */
8
+ export declare const toJson: (value: unknown, replacer?: (this: unknown, key: string, value: unknown) => unknown, space?: string | number) => string;
9
+ /**
10
+ * Parse JSON string to object, array, or other type
11
+ * @param text A valid JSON string.
12
+ * @param reviver A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is.
13
+ * @returns Parsed object, array, or other type
14
+ */
15
+ export declare function fromJson<T = unknown>(text: string, reviver?: (this: unknown, key: string, value: unknown) => unknown): T;
package/core/json.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toJson = void 0;
4
+ exports.fromJson = fromJson;
5
+ /**
6
+ * Serialize a value to JSON
7
+ * @param value A JavaScript value, usually an object or array, to be converted.
8
+ * @param replacer A function that transforms the results.
9
+ * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
10
+ * @returns JSON string
11
+ */
12
+ const toJson = (value, replacer, space) => {
13
+ return JSON.stringify(value, replacer, space);
14
+ };
15
+ exports.toJson = toJson;
16
+ /**
17
+ * Parse JSON string to object, array, or other type
18
+ * @param text A valid JSON string.
19
+ * @param reviver A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is.
20
+ * @returns Parsed object, array, or other type
21
+ */
22
+ function fromJson(text, reviver) {
23
+ return JSON.parse(text, reviver);
24
+ }
@@ -24,7 +24,9 @@ export declare const SchemaType: {
24
24
  readonly SET: "set";
25
25
  readonly UNION: "union";
26
26
  readonly UNDISCRIMINATED_UNION: "undiscriminatedUnion";
27
+ readonly NULLABLE: "nullable";
27
28
  readonly OPTIONAL: "optional";
29
+ readonly OPTIONAL_NULLABLE: "optionalNullable";
28
30
  };
29
31
  export type SchemaType = (typeof SchemaType)[keyof typeof SchemaType];
30
32
  export type MaybeValid<T> = Valid<T> | Invalid;
@@ -18,5 +18,7 @@ exports.SchemaType = {
18
18
  SET: "set",
19
19
  UNION: "union",
20
20
  UNDISCRIMINATED_UNION: "undiscriminatedUnion",
21
+ NULLABLE: "nullable",
21
22
  OPTIONAL: "optional",
23
+ OPTIONAL_NULLABLE: "optionalNullable",
22
24
  };
@@ -1,2 +1,2 @@
1
1
  import { Schema } from "../../Schema";
2
- export declare function bigint(): Schema<string, bigint>;
2
+ export declare function bigint(): Schema<bigint | number, bigint>;
@@ -8,30 +8,30 @@ const schema_utils_1 = require("../schema-utils");
8
8
  function bigint() {
9
9
  const baseSchema = {
10
10
  parse: (raw, { breadcrumbsPrefix = [] } = {}) => {
11
- if (typeof raw !== "string") {
11
+ if (typeof raw === "bigint") {
12
12
  return {
13
- ok: false,
14
- errors: [
15
- {
16
- path: breadcrumbsPrefix,
17
- message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(raw, "string"),
18
- },
19
- ],
13
+ ok: true,
14
+ value: raw,
20
15
  };
21
16
  }
22
- return {
23
- ok: true,
24
- value: BigInt(raw),
25
- };
26
- },
27
- json: (bigint, { breadcrumbsPrefix = [] } = {}) => {
28
- if (typeof bigint === "bigint") {
17
+ if (typeof raw === "number") {
29
18
  return {
30
19
  ok: true,
31
- value: bigint.toString(),
20
+ value: BigInt(raw),
32
21
  };
33
22
  }
34
- else {
23
+ return {
24
+ ok: false,
25
+ errors: [
26
+ {
27
+ path: breadcrumbsPrefix,
28
+ message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(raw, "bigint | number"),
29
+ },
30
+ ],
31
+ };
32
+ },
33
+ json: (bigint, { breadcrumbsPrefix = [] } = {}) => {
34
+ if (typeof bigint !== "bigint") {
35
35
  return {
36
36
  ok: false,
37
37
  errors: [
@@ -42,6 +42,10 @@ function bigint() {
42
42
  ],
43
43
  };
44
44
  }
45
+ return {
46
+ ok: true,
47
+ value: bigint,
48
+ };
45
49
  },
46
50
  getType: () => Schema_1.SchemaType.BIGINT,
47
51
  };
@@ -253,6 +253,7 @@ function isSchemaOptional(schema) {
253
253
  case Schema_1.SchemaType.ANY:
254
254
  case Schema_1.SchemaType.UNKNOWN:
255
255
  case Schema_1.SchemaType.OPTIONAL:
256
+ case Schema_1.SchemaType.OPTIONAL_NULLABLE:
256
257
  return true;
257
258
  default:
258
259
  return false;
@@ -56,8 +56,7 @@ function validateAndTransformRecord({ value, isKeyNumeric, transformKey, transfo
56
56
  };
57
57
  }
58
58
  return (0, entries_1.entries)(value).reduce((accPromise, [stringKey, value]) => {
59
- // skip nullish keys
60
- if (value == null) {
59
+ if (value === undefined) {
61
60
  return accPromise;
62
61
  }
63
62
  const acc = accPromise;
@@ -1,6 +1,8 @@
1
1
  import { BaseSchema, Schema, SchemaOptions } from "../../Schema";
2
2
  export interface SchemaUtils<Raw, Parsed> {
3
+ nullable: () => Schema<Raw | null, Parsed | null>;
3
4
  optional: () => Schema<Raw | null | undefined, Parsed | undefined>;
5
+ optionalNullable: () => Schema<Raw | null | undefined, Parsed | null | undefined>;
4
6
  transform: <Transformed>(transformer: SchemaTransformer<Parsed, Transformed>) => Schema<Raw, Transformed>;
5
7
  parseOrThrow: (raw: unknown, opts?: SchemaOptions) => Parsed;
6
8
  jsonOrThrow: (raw: unknown, opts?: SchemaOptions) => Raw;
@@ -13,5 +15,7 @@ export declare function getSchemaUtils<Raw, Parsed>(schema: BaseSchema<Raw, Pars
13
15
  /**
14
16
  * schema utils are defined in one file to resolve issues with circular imports
15
17
  */
18
+ export declare function nullable<Raw, Parsed>(schema: BaseSchema<Raw, Parsed>): Schema<Raw | null, Parsed | null>;
16
19
  export declare function optional<Raw, Parsed>(schema: BaseSchema<Raw, Parsed>): Schema<Raw | null | undefined, Parsed | undefined>;
20
+ export declare function optionalNullable<Raw, Parsed>(schema: BaseSchema<Raw, Parsed>): Schema<Raw | null | undefined, Parsed | null | undefined>;
17
21
  export declare function transform<Raw, Parsed, Transformed>(schema: BaseSchema<Raw, Parsed>, transformer: SchemaTransformer<Parsed, Transformed>): Schema<Raw, Transformed>;
@@ -1,14 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSchemaUtils = getSchemaUtils;
4
+ exports.nullable = nullable;
4
5
  exports.optional = optional;
6
+ exports.optionalNullable = optionalNullable;
5
7
  exports.transform = transform;
6
8
  const Schema_1 = require("../../Schema");
7
9
  const JsonError_1 = require("./JsonError");
8
10
  const ParseError_1 = require("./ParseError");
9
11
  function getSchemaUtils(schema) {
10
12
  return {
13
+ nullable: () => nullable(schema),
11
14
  optional: () => optional(schema),
15
+ optionalNullable: () => optionalNullable(schema),
12
16
  transform: (transformer) => transform(schema, transformer),
13
17
  parseOrThrow: (raw, opts) => {
14
18
  const parsed = schema.parse(raw, opts);
@@ -29,6 +33,30 @@ function getSchemaUtils(schema) {
29
33
  /**
30
34
  * schema utils are defined in one file to resolve issues with circular imports
31
35
  */
36
+ function nullable(schema) {
37
+ const baseSchema = {
38
+ parse: (raw, opts) => {
39
+ if (raw == null) {
40
+ return {
41
+ ok: true,
42
+ value: null,
43
+ };
44
+ }
45
+ return schema.parse(raw, opts);
46
+ },
47
+ json: (parsed, opts) => {
48
+ if (parsed == null) {
49
+ return {
50
+ ok: true,
51
+ value: null,
52
+ };
53
+ }
54
+ return schema.json(parsed, opts);
55
+ },
56
+ getType: () => Schema_1.SchemaType.NULLABLE,
57
+ };
58
+ return Object.assign(Object.assign({}, baseSchema), getSchemaUtils(baseSchema));
59
+ }
32
60
  function optional(schema) {
33
61
  const baseSchema = {
34
62
  parse: (raw, opts) => {
@@ -59,6 +87,42 @@ function optional(schema) {
59
87
  };
60
88
  return Object.assign(Object.assign({}, baseSchema), getSchemaUtils(baseSchema));
61
89
  }
90
+ function optionalNullable(schema) {
91
+ const baseSchema = {
92
+ parse: (raw, opts) => {
93
+ if (raw === undefined) {
94
+ return {
95
+ ok: true,
96
+ value: undefined,
97
+ };
98
+ }
99
+ if (raw === null) {
100
+ return {
101
+ ok: true,
102
+ value: null,
103
+ };
104
+ }
105
+ return schema.parse(raw, opts);
106
+ },
107
+ json: (parsed, opts) => {
108
+ if (parsed === undefined) {
109
+ return {
110
+ ok: true,
111
+ value: undefined,
112
+ };
113
+ }
114
+ if (parsed === null) {
115
+ return {
116
+ ok: true,
117
+ value: null,
118
+ };
119
+ }
120
+ return schema.json(parsed, opts);
121
+ },
122
+ getType: () => Schema_1.SchemaType.OPTIONAL_NULLABLE,
123
+ };
124
+ return Object.assign(Object.assign({}, baseSchema), getSchemaUtils(baseSchema));
125
+ }
62
126
  function transform(schema, transformer) {
63
127
  const baseSchema = {
64
128
  parse: (raw, opts) => {
@@ -2,6 +2,6 @@ export type addQuestionMarksToNullableProperties<T> = {
2
2
  [K in OptionalKeys<T>]?: T[K];
3
3
  } & Pick<T, RequiredKeys<T>>;
4
4
  export type OptionalKeys<T> = {
5
- [K in keyof T]-?: undefined extends T[K] ? K : null extends T[K] ? K : 1 extends (any extends T[K] ? 0 : 1) ? never : K;
5
+ [K in keyof T]-?: undefined extends T[K] ? K : never;
6
6
  }[keyof T];
7
7
  export type RequiredKeys<T> = Exclude<keyof T, OptionalKeys<T>>;
@@ -2,6 +2,7 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  import * as errors from "../../errors/index";
5
+ import * as core from "../../core";
5
6
  export declare class BadRequestError extends errors.LettaError {
6
- constructor(body?: unknown);
7
+ constructor(body?: unknown, rawResponse?: core.RawResponse);
7
8
  }
@@ -39,11 +39,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.BadRequestError = void 0;
40
40
  const errors = __importStar(require("../../errors/index"));
41
41
  class BadRequestError extends errors.LettaError {
42
- constructor(body) {
42
+ constructor(body, rawResponse) {
43
43
  super({
44
44
  message: "BadRequestError",
45
45
  statusCode: 400,
46
46
  body: body,
47
+ rawResponse: rawResponse,
47
48
  });
48
49
  Object.setPrototypeOf(this, BadRequestError.prototype);
49
50
  }
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import * as errors from "../../errors/index";
5
5
  import * as Letta from "../index";
6
+ import * as core from "../../core";
6
7
  export declare class ConflictError extends errors.LettaError {
7
- constructor(body: Letta.ConflictErrorBody);
8
+ constructor(body: Letta.ConflictErrorBody, rawResponse?: core.RawResponse);
8
9
  }
@@ -39,11 +39,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.ConflictError = void 0;
40
40
  const errors = __importStar(require("../../errors/index"));
41
41
  class ConflictError extends errors.LettaError {
42
- constructor(body) {
42
+ constructor(body, rawResponse) {
43
43
  super({
44
44
  message: "ConflictError",
45
45
  statusCode: 409,
46
46
  body: body,
47
+ rawResponse: rawResponse,
47
48
  });
48
49
  Object.setPrototypeOf(this, ConflictError.prototype);
49
50
  }
@@ -2,6 +2,7 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  import * as errors from "../../errors/index";
5
+ import * as core from "../../core";
5
6
  export declare class InternalServerError extends errors.LettaError {
6
- constructor(body?: unknown);
7
+ constructor(body?: unknown, rawResponse?: core.RawResponse);
7
8
  }
@@ -39,11 +39,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.InternalServerError = void 0;
40
40
  const errors = __importStar(require("../../errors/index"));
41
41
  class InternalServerError extends errors.LettaError {
42
- constructor(body) {
42
+ constructor(body, rawResponse) {
43
43
  super({
44
44
  message: "InternalServerError",
45
45
  statusCode: 500,
46
46
  body: body,
47
+ rawResponse: rawResponse,
47
48
  });
48
49
  Object.setPrototypeOf(this, InternalServerError.prototype);
49
50
  }
@@ -2,6 +2,7 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  import * as errors from "../../errors/index";
5
+ import * as core from "../../core";
5
6
  export declare class NotFoundError extends errors.LettaError {
6
- constructor(body?: unknown);
7
+ constructor(body?: unknown, rawResponse?: core.RawResponse);
7
8
  }
@@ -39,11 +39,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.NotFoundError = void 0;
40
40
  const errors = __importStar(require("../../errors/index"));
41
41
  class NotFoundError extends errors.LettaError {
42
- constructor(body) {
42
+ constructor(body, rawResponse) {
43
43
  super({
44
44
  message: "NotFoundError",
45
45
  statusCode: 404,
46
46
  body: body,
47
+ rawResponse: rawResponse,
47
48
  });
48
49
  Object.setPrototypeOf(this, NotFoundError.prototype);
49
50
  }
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import * as errors from "../../errors/index";
5
5
  import * as Letta from "../index";
6
+ import * as core from "../../core";
6
7
  export declare class PaymentRequiredError extends errors.LettaError {
7
- constructor(body: Letta.PaymentRequiredErrorBody);
8
+ constructor(body: Letta.PaymentRequiredErrorBody, rawResponse?: core.RawResponse);
8
9
  }
@@ -39,11 +39,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.PaymentRequiredError = void 0;
40
40
  const errors = __importStar(require("../../errors/index"));
41
41
  class PaymentRequiredError extends errors.LettaError {
42
- constructor(body) {
42
+ constructor(body, rawResponse) {
43
43
  super({
44
44
  message: "PaymentRequiredError",
45
45
  statusCode: 402,
46
46
  body: body,
47
+ rawResponse: rawResponse,
47
48
  });
48
49
  Object.setPrototypeOf(this, PaymentRequiredError.prototype);
49
50
  }
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import * as errors from "../../errors/index";
5
5
  import * as Letta from "../index";
6
+ import * as core from "../../core";
6
7
  export declare class UnprocessableEntityError extends errors.LettaError {
7
- constructor(body: Letta.HttpValidationError);
8
+ constructor(body: Letta.HttpValidationError, rawResponse?: core.RawResponse);
8
9
  }
@@ -39,11 +39,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.UnprocessableEntityError = void 0;
40
40
  const errors = __importStar(require("../../errors/index"));
41
41
  class UnprocessableEntityError extends errors.LettaError {
42
- constructor(body) {
42
+ constructor(body, rawResponse) {
43
43
  super({
44
44
  message: "UnprocessableEntityError",
45
45
  statusCode: 422,
46
46
  body: body,
47
+ rawResponse: rawResponse,
47
48
  });
48
49
  Object.setPrototypeOf(this, UnprocessableEntityError.prototype);
49
50
  }