@credal/sdk 0.0.13 → 0.0.15

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 (332) hide show
  1. package/Client.d.ts +3 -0
  2. package/api/resources/common/types/index.d.ts +1 -0
  3. package/api/resources/common/types/index.js +1 -0
  4. package/api/resources/copilots/client/Client.d.ts +25 -11
  5. package/api/resources/copilots/client/Client.js +119 -37
  6. package/api/resources/copilots/client/requests/CreateCopilotRequest.d.ts +1 -1
  7. package/api/resources/copilots/client/requests/ProvideMessageFeedbackRequest.d.ts +1 -1
  8. package/api/resources/copilots/client/requests/SendMessageRequest.d.ts +14 -1
  9. package/api/resources/copilots/client/requests/StreamMessageRequest.d.ts +60 -0
  10. package/api/resources/copilots/client/requests/StreamMessageRequest.js +5 -0
  11. package/api/resources/copilots/client/requests/index.d.ts +1 -0
  12. package/api/resources/copilots/types/BlockedChunk.d.ts +10 -0
  13. package/api/resources/copilots/types/BlockedChunk.js +5 -0
  14. package/api/resources/copilots/types/BooleanFieldSchema.d.ts +8 -0
  15. package/api/resources/copilots/types/BooleanFieldSchema.js +5 -0
  16. package/api/resources/copilots/types/CollectionFilteredData.d.ts +9 -0
  17. package/api/resources/copilots/types/CollectionFilteredData.js +5 -0
  18. package/api/resources/copilots/types/DataChunk.d.ts +6 -0
  19. package/api/resources/copilots/types/DataChunk.js +5 -0
  20. package/api/resources/copilots/types/DataFilter.d.ts +9 -0
  21. package/api/resources/copilots/types/DataFilter.js +5 -0
  22. package/api/resources/copilots/types/DatetimeFieldSchema.d.ts +9 -0
  23. package/api/resources/copilots/types/DatetimeFieldSchema.js +5 -0
  24. package/api/resources/copilots/types/Filter.d.ts +19 -0
  25. package/api/resources/copilots/types/Filter.js +5 -0
  26. package/api/resources/copilots/types/FinalChunk.d.ts +7 -0
  27. package/api/resources/copilots/types/FinalChunk.js +5 -0
  28. package/api/resources/copilots/types/InitialChunk.d.ts +10 -0
  29. package/api/resources/copilots/types/InitialChunk.js +5 -0
  30. package/api/resources/copilots/types/InputVariable.d.ts +7 -0
  31. package/api/resources/copilots/types/InputVariable.js +5 -0
  32. package/api/resources/copilots/types/MessageReply.d.ts +1 -0
  33. package/api/resources/copilots/types/NumberFieldSchema.d.ts +9 -0
  34. package/api/resources/copilots/types/NumberFieldSchema.js +5 -0
  35. package/api/resources/copilots/types/StreamingChunk.d.ts +5 -0
  36. package/api/resources/copilots/types/StreamingChunk.js +5 -0
  37. package/api/resources/copilots/types/StringFieldSchema.d.ts +9 -0
  38. package/api/resources/copilots/types/StringFieldSchema.js +5 -0
  39. package/api/resources/copilots/types/WebSearchResult.d.ts +8 -0
  40. package/api/resources/copilots/types/WebSearchResult.js +5 -0
  41. package/api/resources/copilots/types/index.d.ts +14 -0
  42. package/api/resources/copilots/types/index.js +14 -0
  43. package/api/resources/documentCatalog/client/Client.d.ts +7 -4
  44. package/api/resources/documentCatalog/client/Client.js +13 -13
  45. package/api/resources/documentCollections/client/Client.d.ts +14 -11
  46. package/api/resources/documentCollections/client/Client.js +39 -29
  47. package/api/resources/documentCollections/client/requests/AddDocumentsToCollectionRequest.d.ts +2 -2
  48. package/api/resources/documentCollections/client/requests/CreateCollectionRequest.d.ts +1 -1
  49. package/api/resources/documentCollections/client/requests/RemoveDocumentsFromCollectionRequest.d.ts +2 -2
  50. package/api/resources/permissionsService/client/Client.d.ts +8 -5
  51. package/api/resources/permissionsService/client/Client.js +20 -14
  52. package/api/resources/permissionsService/client/requests/CheckBulkResourcesAuthorizationForUserRequest.d.ts +1 -1
  53. package/api/resources/permissionsService/client/requests/CheckResourceAuthorizationForUserRequest.d.ts +1 -1
  54. package/api/resources/search/client/Client.d.ts +5 -2
  55. package/api/resources/search/client/Client.js +7 -7
  56. package/api/resources/search/client/requests/SearchDocumentCollectionRequest.d.ts +1 -1
  57. package/api/resources/search/types/index.d.ts +0 -1
  58. package/api/resources/search/types/index.js +0 -1
  59. package/api/resources/users/client/Client.d.ts +4 -1
  60. package/api/resources/users/client/Client.js +5 -3
  61. package/core/fetcher/Fetcher.d.ts +4 -1
  62. package/core/fetcher/Fetcher.js +19 -176
  63. package/core/fetcher/createRequestUrl.d.ts +1 -0
  64. package/core/fetcher/createRequestUrl.js +13 -0
  65. package/core/fetcher/getFetchFn.d.ts +4 -0
  66. package/core/fetcher/getFetchFn.js +59 -0
  67. package/core/fetcher/getRequestBody.d.ts +7 -0
  68. package/core/fetcher/getRequestBody.js +23 -0
  69. package/core/fetcher/getResponseBody.d.ts +1 -0
  70. package/core/fetcher/getResponseBody.js +55 -0
  71. package/core/fetcher/makeRequest.d.ts +1 -0
  72. package/core/fetcher/makeRequest.js +42 -0
  73. package/core/fetcher/requestWithRetries.d.ts +1 -0
  74. package/core/fetcher/requestWithRetries.js +41 -0
  75. package/core/fetcher/signals.d.ts +12 -0
  76. package/core/fetcher/signals.js +37 -0
  77. package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
  78. package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +247 -0
  79. package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +22 -0
  80. package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +124 -0
  81. package/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
  82. package/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +229 -0
  83. package/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
  84. package/core/fetcher/stream-wrappers/chooseStreamWrapper.js +50 -0
  85. package/core/index.d.ts +1 -0
  86. package/core/index.js +1 -0
  87. package/core/runtime/runtime.d.ts +2 -1
  88. package/core/runtime/runtime.js +12 -1
  89. package/core/schemas/Schema.d.ts +8 -4
  90. package/core/schemas/Schema.js +1 -0
  91. package/core/schemas/builders/bigint/bigint.d.ts +2 -0
  92. package/core/schemas/builders/bigint/bigint.js +50 -0
  93. package/core/schemas/builders/bigint/index.d.ts +1 -0
  94. package/core/schemas/builders/bigint/index.js +5 -0
  95. package/core/schemas/builders/index.d.ts +1 -0
  96. package/core/schemas/builders/index.js +1 -0
  97. package/core/schemas/builders/lazy/lazy.d.ts +2 -2
  98. package/core/schemas/builders/lazy/lazy.js +8 -19
  99. package/core/schemas/builders/lazy/lazyObject.js +1 -10
  100. package/core/schemas/builders/list/list.js +31 -44
  101. package/core/schemas/builders/object/object.js +90 -111
  102. package/core/schemas/builders/object/types.d.ts +2 -2
  103. package/core/schemas/builders/object-like/getObjectLikeUtils.js +3 -12
  104. package/core/schemas/builders/record/record.js +49 -60
  105. package/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +2 -2
  106. package/core/schemas/builders/schema-utils/getSchemaUtils.js +18 -21
  107. package/core/schemas/builders/set/set.js +6 -15
  108. package/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +21 -32
  109. package/core/schemas/builders/union/union.js +51 -62
  110. package/core/schemas/utils/getErrorMessageForIncorrectType.js +4 -0
  111. package/core/schemas/utils/maybeSkipValidation.js +3 -12
  112. package/core/streaming-fetcher/Stream.d.ts +48 -0
  113. package/core/streaming-fetcher/Stream.js +170 -0
  114. package/core/streaming-fetcher/index.d.ts +1 -0
  115. package/core/streaming-fetcher/index.js +5 -0
  116. package/dist/Client.d.ts +3 -0
  117. package/dist/api/resources/common/types/index.d.ts +1 -0
  118. package/dist/api/resources/common/types/index.js +1 -0
  119. package/dist/api/resources/copilots/client/Client.d.ts +25 -11
  120. package/dist/api/resources/copilots/client/Client.js +119 -37
  121. package/dist/api/resources/copilots/client/requests/CreateCopilotRequest.d.ts +1 -1
  122. package/dist/api/resources/copilots/client/requests/ProvideMessageFeedbackRequest.d.ts +1 -1
  123. package/dist/api/resources/copilots/client/requests/SendMessageRequest.d.ts +14 -1
  124. package/dist/api/resources/copilots/client/requests/StreamMessageRequest.d.ts +60 -0
  125. package/dist/api/resources/copilots/client/requests/StreamMessageRequest.js +5 -0
  126. package/dist/api/resources/copilots/client/requests/index.d.ts +1 -0
  127. package/dist/api/resources/copilots/types/BlockedChunk.d.ts +10 -0
  128. package/dist/api/resources/copilots/types/BlockedChunk.js +5 -0
  129. package/dist/api/resources/copilots/types/BooleanFieldSchema.d.ts +8 -0
  130. package/dist/api/resources/copilots/types/BooleanFieldSchema.js +5 -0
  131. package/dist/api/resources/copilots/types/CollectionFilteredData.d.ts +9 -0
  132. package/dist/api/resources/copilots/types/CollectionFilteredData.js +5 -0
  133. package/dist/api/resources/copilots/types/DataChunk.d.ts +6 -0
  134. package/dist/api/resources/copilots/types/DataChunk.js +5 -0
  135. package/dist/api/resources/copilots/types/DataFilter.d.ts +9 -0
  136. package/dist/api/resources/copilots/types/DataFilter.js +5 -0
  137. package/dist/api/resources/copilots/types/DatetimeFieldSchema.d.ts +9 -0
  138. package/dist/api/resources/copilots/types/DatetimeFieldSchema.js +5 -0
  139. package/dist/api/resources/copilots/types/Filter.d.ts +19 -0
  140. package/dist/api/resources/copilots/types/Filter.js +5 -0
  141. package/dist/api/resources/copilots/types/FinalChunk.d.ts +7 -0
  142. package/dist/api/resources/copilots/types/FinalChunk.js +5 -0
  143. package/dist/api/resources/copilots/types/InitialChunk.d.ts +10 -0
  144. package/dist/api/resources/copilots/types/InitialChunk.js +5 -0
  145. package/dist/api/resources/copilots/types/InputVariable.d.ts +7 -0
  146. package/dist/api/resources/copilots/types/InputVariable.js +5 -0
  147. package/dist/api/resources/copilots/types/MessageReply.d.ts +1 -0
  148. package/dist/api/resources/copilots/types/NumberFieldSchema.d.ts +9 -0
  149. package/dist/api/resources/copilots/types/NumberFieldSchema.js +5 -0
  150. package/dist/api/resources/copilots/types/StreamingChunk.d.ts +5 -0
  151. package/dist/api/resources/copilots/types/StreamingChunk.js +5 -0
  152. package/dist/api/resources/copilots/types/StringFieldSchema.d.ts +9 -0
  153. package/dist/api/resources/copilots/types/StringFieldSchema.js +5 -0
  154. package/dist/api/resources/copilots/types/WebSearchResult.d.ts +8 -0
  155. package/dist/api/resources/copilots/types/WebSearchResult.js +5 -0
  156. package/dist/api/resources/copilots/types/index.d.ts +14 -0
  157. package/dist/api/resources/copilots/types/index.js +14 -0
  158. package/dist/api/resources/documentCatalog/client/Client.d.ts +7 -4
  159. package/dist/api/resources/documentCatalog/client/Client.js +13 -13
  160. package/dist/api/resources/documentCollections/client/Client.d.ts +14 -11
  161. package/dist/api/resources/documentCollections/client/Client.js +39 -29
  162. package/dist/api/resources/documentCollections/client/requests/AddDocumentsToCollectionRequest.d.ts +2 -2
  163. package/dist/api/resources/documentCollections/client/requests/CreateCollectionRequest.d.ts +1 -1
  164. package/dist/api/resources/documentCollections/client/requests/RemoveDocumentsFromCollectionRequest.d.ts +2 -2
  165. package/dist/api/resources/permissionsService/client/Client.d.ts +8 -5
  166. package/dist/api/resources/permissionsService/client/Client.js +20 -14
  167. package/dist/api/resources/permissionsService/client/requests/CheckBulkResourcesAuthorizationForUserRequest.d.ts +1 -1
  168. package/dist/api/resources/permissionsService/client/requests/CheckResourceAuthorizationForUserRequest.d.ts +1 -1
  169. package/dist/api/resources/search/client/Client.d.ts +5 -2
  170. package/dist/api/resources/search/client/Client.js +7 -7
  171. package/dist/api/resources/search/client/requests/SearchDocumentCollectionRequest.d.ts +1 -1
  172. package/dist/api/resources/search/types/index.d.ts +0 -1
  173. package/dist/api/resources/search/types/index.js +0 -1
  174. package/dist/api/resources/users/client/Client.d.ts +4 -1
  175. package/dist/api/resources/users/client/Client.js +5 -3
  176. package/dist/core/fetcher/Fetcher.d.ts +4 -1
  177. package/dist/core/fetcher/Fetcher.js +19 -176
  178. package/dist/core/fetcher/createRequestUrl.d.ts +1 -0
  179. package/dist/core/fetcher/createRequestUrl.js +13 -0
  180. package/dist/core/fetcher/getFetchFn.d.ts +4 -0
  181. package/dist/core/fetcher/getFetchFn.js +59 -0
  182. package/dist/core/fetcher/getRequestBody.d.ts +7 -0
  183. package/dist/core/fetcher/getRequestBody.js +23 -0
  184. package/dist/core/fetcher/getResponseBody.d.ts +1 -0
  185. package/dist/core/fetcher/getResponseBody.js +55 -0
  186. package/dist/core/fetcher/makeRequest.d.ts +1 -0
  187. package/dist/core/fetcher/makeRequest.js +42 -0
  188. package/dist/core/fetcher/requestWithRetries.d.ts +1 -0
  189. package/dist/core/fetcher/requestWithRetries.js +41 -0
  190. package/dist/core/fetcher/signals.d.ts +12 -0
  191. package/dist/core/fetcher/signals.js +37 -0
  192. package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
  193. package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +247 -0
  194. package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +22 -0
  195. package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +124 -0
  196. package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
  197. package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +229 -0
  198. package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
  199. package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js +50 -0
  200. package/dist/core/index.d.ts +1 -0
  201. package/dist/core/index.js +1 -0
  202. package/dist/core/runtime/runtime.d.ts +2 -1
  203. package/dist/core/runtime/runtime.js +12 -1
  204. package/dist/core/schemas/Schema.d.ts +8 -4
  205. package/dist/core/schemas/Schema.js +1 -0
  206. package/dist/core/schemas/builders/bigint/bigint.d.ts +2 -0
  207. package/dist/core/schemas/builders/bigint/bigint.js +50 -0
  208. package/dist/core/schemas/builders/bigint/index.d.ts +1 -0
  209. package/dist/core/schemas/builders/bigint/index.js +5 -0
  210. package/dist/core/schemas/builders/index.d.ts +1 -0
  211. package/dist/core/schemas/builders/index.js +1 -0
  212. package/dist/core/schemas/builders/lazy/lazy.d.ts +2 -2
  213. package/dist/core/schemas/builders/lazy/lazy.js +8 -19
  214. package/dist/core/schemas/builders/lazy/lazyObject.js +1 -10
  215. package/dist/core/schemas/builders/list/list.js +31 -44
  216. package/dist/core/schemas/builders/object/object.js +90 -111
  217. package/dist/core/schemas/builders/object/types.d.ts +2 -2
  218. package/dist/core/schemas/builders/object-like/getObjectLikeUtils.js +3 -12
  219. package/dist/core/schemas/builders/record/record.js +49 -60
  220. package/dist/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +2 -2
  221. package/dist/core/schemas/builders/schema-utils/getSchemaUtils.js +18 -21
  222. package/dist/core/schemas/builders/set/set.js +6 -15
  223. package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +21 -32
  224. package/dist/core/schemas/builders/union/union.js +51 -62
  225. package/dist/core/schemas/utils/getErrorMessageForIncorrectType.js +4 -0
  226. package/dist/core/schemas/utils/maybeSkipValidation.js +3 -12
  227. package/dist/core/streaming-fetcher/Stream.d.ts +48 -0
  228. package/dist/core/streaming-fetcher/Stream.js +170 -0
  229. package/dist/core/streaming-fetcher/index.d.ts +1 -0
  230. package/dist/core/streaming-fetcher/index.js +5 -0
  231. package/dist/serialization/resources/common/types/index.d.ts +1 -0
  232. package/dist/serialization/resources/common/types/index.js +1 -0
  233. package/dist/serialization/resources/copilots/client/requests/SendMessageRequest.d.ts +2 -0
  234. package/dist/serialization/resources/copilots/client/requests/SendMessageRequest.js +2 -0
  235. package/dist/serialization/resources/copilots/client/requests/StreamMessageRequest.d.ts +17 -0
  236. package/dist/serialization/resources/copilots/client/requests/StreamMessageRequest.js +38 -0
  237. package/dist/serialization/resources/copilots/client/requests/index.d.ts +1 -0
  238. package/dist/serialization/resources/copilots/client/requests/index.js +3 -1
  239. package/dist/serialization/resources/copilots/types/BlockedChunk.d.ts +16 -0
  240. package/dist/serialization/resources/copilots/types/BlockedChunk.js +37 -0
  241. package/dist/serialization/resources/copilots/types/BooleanFieldSchema.d.ts +14 -0
  242. package/dist/serialization/resources/copilots/types/BooleanFieldSchema.js +35 -0
  243. package/dist/serialization/resources/copilots/types/CollectionFilteredData.d.ts +15 -0
  244. package/dist/serialization/resources/copilots/types/CollectionFilteredData.js +36 -0
  245. package/dist/serialization/resources/copilots/types/DataChunk.d.ts +12 -0
  246. package/dist/serialization/resources/copilots/types/DataChunk.js +33 -0
  247. package/dist/serialization/resources/copilots/types/DataFilter.d.ts +15 -0
  248. package/dist/serialization/resources/copilots/types/DataFilter.js +36 -0
  249. package/dist/serialization/resources/copilots/types/DatetimeFieldSchema.d.ts +15 -0
  250. package/dist/serialization/resources/copilots/types/DatetimeFieldSchema.js +36 -0
  251. package/dist/serialization/resources/copilots/types/Filter.d.ts +26 -0
  252. package/dist/serialization/resources/copilots/types/Filter.js +45 -0
  253. package/dist/serialization/resources/copilots/types/FinalChunk.d.ts +13 -0
  254. package/dist/serialization/resources/copilots/types/FinalChunk.js +34 -0
  255. package/dist/serialization/resources/copilots/types/InitialChunk.d.ts +17 -0
  256. package/dist/serialization/resources/copilots/types/InitialChunk.js +38 -0
  257. package/dist/serialization/resources/copilots/types/InputVariable.d.ts +13 -0
  258. package/dist/serialization/resources/copilots/types/InputVariable.js +34 -0
  259. package/dist/serialization/resources/copilots/types/MessageReply.d.ts +2 -0
  260. package/dist/serialization/resources/copilots/types/MessageReply.js +2 -0
  261. package/dist/serialization/resources/copilots/types/NumberFieldSchema.d.ts +15 -0
  262. package/dist/serialization/resources/copilots/types/NumberFieldSchema.js +36 -0
  263. package/dist/serialization/resources/copilots/types/StreamingChunk.d.ts +14 -0
  264. package/dist/serialization/resources/copilots/types/StreamingChunk.js +35 -0
  265. package/dist/serialization/resources/copilots/types/StringFieldSchema.d.ts +15 -0
  266. package/dist/serialization/resources/copilots/types/StringFieldSchema.js +36 -0
  267. package/dist/serialization/resources/copilots/types/WebSearchResult.d.ts +14 -0
  268. package/dist/serialization/resources/copilots/types/WebSearchResult.js +35 -0
  269. package/dist/serialization/resources/copilots/types/index.d.ts +14 -0
  270. package/dist/serialization/resources/copilots/types/index.js +14 -0
  271. package/dist/serialization/resources/search/types/SingleFieldFilter.d.ts +1 -1
  272. package/dist/serialization/resources/search/types/SingleFieldFilter.js +1 -1
  273. package/dist/serialization/resources/search/types/index.d.ts +0 -1
  274. package/dist/serialization/resources/search/types/index.js +0 -1
  275. package/dist/version.d.ts +1 -0
  276. package/dist/version.js +4 -0
  277. package/package.json +12 -2
  278. package/reference.md +203 -511
  279. package/serialization/resources/common/types/index.d.ts +1 -0
  280. package/serialization/resources/common/types/index.js +1 -0
  281. package/serialization/resources/copilots/client/requests/SendMessageRequest.d.ts +2 -0
  282. package/serialization/resources/copilots/client/requests/SendMessageRequest.js +2 -0
  283. package/serialization/resources/copilots/client/requests/StreamMessageRequest.d.ts +17 -0
  284. package/serialization/resources/copilots/client/requests/StreamMessageRequest.js +38 -0
  285. package/serialization/resources/copilots/client/requests/index.d.ts +1 -0
  286. package/serialization/resources/copilots/client/requests/index.js +3 -1
  287. package/serialization/resources/copilots/types/BlockedChunk.d.ts +16 -0
  288. package/serialization/resources/copilots/types/BlockedChunk.js +37 -0
  289. package/serialization/resources/copilots/types/BooleanFieldSchema.d.ts +14 -0
  290. package/serialization/resources/copilots/types/BooleanFieldSchema.js +35 -0
  291. package/serialization/resources/copilots/types/CollectionFilteredData.d.ts +15 -0
  292. package/serialization/resources/copilots/types/CollectionFilteredData.js +36 -0
  293. package/serialization/resources/copilots/types/DataChunk.d.ts +12 -0
  294. package/serialization/resources/copilots/types/DataChunk.js +33 -0
  295. package/serialization/resources/copilots/types/DataFilter.d.ts +15 -0
  296. package/serialization/resources/copilots/types/DataFilter.js +36 -0
  297. package/serialization/resources/copilots/types/DatetimeFieldSchema.d.ts +15 -0
  298. package/serialization/resources/copilots/types/DatetimeFieldSchema.js +36 -0
  299. package/serialization/resources/copilots/types/Filter.d.ts +26 -0
  300. package/serialization/resources/copilots/types/Filter.js +45 -0
  301. package/serialization/resources/copilots/types/FinalChunk.d.ts +13 -0
  302. package/serialization/resources/copilots/types/FinalChunk.js +34 -0
  303. package/serialization/resources/copilots/types/InitialChunk.d.ts +17 -0
  304. package/serialization/resources/copilots/types/InitialChunk.js +38 -0
  305. package/serialization/resources/copilots/types/InputVariable.d.ts +13 -0
  306. package/serialization/resources/copilots/types/InputVariable.js +34 -0
  307. package/serialization/resources/copilots/types/MessageReply.d.ts +2 -0
  308. package/serialization/resources/copilots/types/MessageReply.js +2 -0
  309. package/serialization/resources/copilots/types/NumberFieldSchema.d.ts +15 -0
  310. package/serialization/resources/copilots/types/NumberFieldSchema.js +36 -0
  311. package/serialization/resources/copilots/types/StreamingChunk.d.ts +14 -0
  312. package/serialization/resources/copilots/types/StreamingChunk.js +35 -0
  313. package/serialization/resources/copilots/types/StringFieldSchema.d.ts +15 -0
  314. package/serialization/resources/copilots/types/StringFieldSchema.js +36 -0
  315. package/serialization/resources/copilots/types/WebSearchResult.d.ts +14 -0
  316. package/serialization/resources/copilots/types/WebSearchResult.js +35 -0
  317. package/serialization/resources/copilots/types/index.d.ts +14 -0
  318. package/serialization/resources/copilots/types/index.js +14 -0
  319. package/serialization/resources/search/types/SingleFieldFilter.d.ts +1 -1
  320. package/serialization/resources/search/types/SingleFieldFilter.js +1 -1
  321. package/serialization/resources/search/types/index.d.ts +0 -1
  322. package/serialization/resources/search/types/index.js +0 -1
  323. package/version.d.ts +1 -0
  324. package/version.js +4 -0
  325. /package/api/resources/{search → common}/types/Operator.d.ts +0 -0
  326. /package/api/resources/{search → common}/types/Operator.js +0 -0
  327. /package/dist/api/resources/{search → common}/types/Operator.d.ts +0 -0
  328. /package/dist/api/resources/{search → common}/types/Operator.js +0 -0
  329. /package/dist/serialization/resources/{search → common}/types/Operator.d.ts +0 -0
  330. /package/dist/serialization/resources/{search → common}/types/Operator.js +0 -0
  331. /package/serialization/resources/{search → common}/types/Operator.d.ts +0 -0
  332. /package/serialization/resources/{search → common}/types/Operator.js +0 -0
@@ -11,8 +11,11 @@ export declare namespace PermissionsService {
11
11
  fetcher?: core.FetchFunction;
12
12
  }
13
13
  interface RequestOptions {
14
+ /** The maximum time to wait for a response in seconds. */
14
15
  timeoutInSeconds?: number;
16
+ /** The number of times to retry the request. Defaults to 2. */
15
17
  maxRetries?: number;
18
+ /** A hook to abort the request. */
16
19
  abortSignal?: AbortSignal;
17
20
  }
18
21
  }
@@ -26,11 +29,11 @@ export declare class PermissionsService {
26
29
  * @param {PermissionsService.RequestOptions} requestOptions - Request-specific configuration.
27
30
  *
28
31
  * @example
29
- * await credal.permissionsService.checkResourceAuthorizationForUser({
32
+ * await client.permissionsService.checkResourceAuthorizationForUser({
30
33
  * resourceIdentifier: {
31
34
  * type: "external-resource-id",
32
35
  * externalResourceId: "170NrBm0Do7gdzvr54UvyslPVWkQFOA0lgNycFmdZJQr",
33
- * resourceType: Credal.ResourceType.GoogleDriveItem
36
+ * resourceType: "GOOGLE_DRIVE_ITEM"
34
37
  * },
35
38
  * userEmail: "john.smith@foo.com"
36
39
  * })
@@ -43,14 +46,14 @@ export declare class PermissionsService {
43
46
  * @param {PermissionsService.RequestOptions} requestOptions - Request-specific configuration.
44
47
  *
45
48
  * @example
46
- * await credal.permissionsService.checkBulkResourcesAuthorizationForUser({
49
+ * await client.permissionsService.checkBulkResourcesAuthorizationForUser({
47
50
  * resourceIdentifiers: [{
48
51
  * type: "url",
49
52
  * url: "https://docs.google.com/document/d/170NrBm0Do7gdzvr54UvyslPVWkQFOA0lgNycFmdZJQr/edit"
50
53
  * }, {
51
54
  * type: "external-resource-id",
52
55
  * externalResourceId: "sfsdfvr54UvyslPVWkQFOA0dfsdfsdflgNycFmdZJQr",
53
- * resourceType: Credal.ResourceType.ZendeskTicket
56
+ * resourceType: "ZENDESK_TICKET"
54
57
  * }],
55
58
  * userEmail: "john.smith@foo.com"
56
59
  * })
@@ -63,7 +66,7 @@ export declare class PermissionsService {
63
66
  * @param {PermissionsService.RequestOptions} requestOptions - Request-specific configuration.
64
67
  *
65
68
  * @example
66
- * await credal.permissionsService.listCachedAuthorizedResourcesForUser({
69
+ * await client.permissionsService.listCachedAuthorizedResourcesForUser({
67
70
  * userEmail: "john.smith@foo.com"
68
71
  * })
69
72
  */
@@ -55,11 +55,11 @@ class PermissionsService {
55
55
  * @param {PermissionsService.RequestOptions} requestOptions - Request-specific configuration.
56
56
  *
57
57
  * @example
58
- * await credal.permissionsService.checkResourceAuthorizationForUser({
58
+ * await client.permissionsService.checkResourceAuthorizationForUser({
59
59
  * resourceIdentifier: {
60
60
  * type: "external-resource-id",
61
61
  * externalResourceId: "170NrBm0Do7gdzvr54UvyslPVWkQFOA0lgNycFmdZJQr",
62
- * resourceType: Credal.ResourceType.GoogleDriveItem
62
+ * resourceType: "GOOGLE_DRIVE_ITEM"
63
63
  * },
64
64
  * userEmail: "john.smith@foo.com"
65
65
  * })
@@ -74,12 +74,14 @@ class PermissionsService {
74
74
  Authorization: yield this._getAuthorizationHeader(),
75
75
  "X-Fern-Language": "JavaScript",
76
76
  "X-Fern-SDK-Name": "@credal/sdk",
77
- "X-Fern-SDK-Version": "0.0.13",
77
+ "X-Fern-SDK-Version": "0.0.15",
78
+ "User-Agent": "@credal/sdk/0.0.15",
78
79
  "X-Fern-Runtime": core.RUNTIME.type,
79
80
  "X-Fern-Runtime-Version": core.RUNTIME.version,
80
81
  },
81
82
  contentType: "application/json",
82
- body: yield serializers.CheckResourceAuthorizationForUserRequest.jsonOrThrow(request, {
83
+ requestType: "json",
84
+ body: serializers.CheckResourceAuthorizationForUserRequest.jsonOrThrow(request, {
83
85
  unrecognizedObjectKeys: "strip",
84
86
  }),
85
87
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -87,7 +89,7 @@ class PermissionsService {
87
89
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
88
90
  });
89
91
  if (_response.ok) {
90
- return yield serializers.CheckResourceAuthorizationResponse.parseOrThrow(_response.body, {
92
+ return serializers.CheckResourceAuthorizationResponse.parseOrThrow(_response.body, {
91
93
  unrecognizedObjectKeys: "passthrough",
92
94
  allowUnrecognizedUnionMembers: true,
93
95
  allowUnrecognizedEnumValues: true,
@@ -122,14 +124,14 @@ class PermissionsService {
122
124
  * @param {PermissionsService.RequestOptions} requestOptions - Request-specific configuration.
123
125
  *
124
126
  * @example
125
- * await credal.permissionsService.checkBulkResourcesAuthorizationForUser({
127
+ * await client.permissionsService.checkBulkResourcesAuthorizationForUser({
126
128
  * resourceIdentifiers: [{
127
129
  * type: "url",
128
130
  * url: "https://docs.google.com/document/d/170NrBm0Do7gdzvr54UvyslPVWkQFOA0lgNycFmdZJQr/edit"
129
131
  * }, {
130
132
  * type: "external-resource-id",
131
133
  * externalResourceId: "sfsdfvr54UvyslPVWkQFOA0dfsdfsdflgNycFmdZJQr",
132
- * resourceType: Credal.ResourceType.ZendeskTicket
134
+ * resourceType: "ZENDESK_TICKET"
133
135
  * }],
134
136
  * userEmail: "john.smith@foo.com"
135
137
  * })
@@ -144,12 +146,14 @@ class PermissionsService {
144
146
  Authorization: yield this._getAuthorizationHeader(),
145
147
  "X-Fern-Language": "JavaScript",
146
148
  "X-Fern-SDK-Name": "@credal/sdk",
147
- "X-Fern-SDK-Version": "0.0.13",
149
+ "X-Fern-SDK-Version": "0.0.15",
150
+ "User-Agent": "@credal/sdk/0.0.15",
148
151
  "X-Fern-Runtime": core.RUNTIME.type,
149
152
  "X-Fern-Runtime-Version": core.RUNTIME.version,
150
153
  },
151
154
  contentType: "application/json",
152
- body: yield serializers.CheckBulkResourcesAuthorizationForUserRequest.jsonOrThrow(request, {
155
+ requestType: "json",
156
+ body: serializers.CheckBulkResourcesAuthorizationForUserRequest.jsonOrThrow(request, {
153
157
  unrecognizedObjectKeys: "strip",
154
158
  }),
155
159
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -157,7 +161,7 @@ class PermissionsService {
157
161
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
158
162
  });
159
163
  if (_response.ok) {
160
- return yield serializers.CheckBulkResourcesAuthorizationResponse.parseOrThrow(_response.body, {
164
+ return serializers.CheckBulkResourcesAuthorizationResponse.parseOrThrow(_response.body, {
161
165
  unrecognizedObjectKeys: "passthrough",
162
166
  allowUnrecognizedUnionMembers: true,
163
167
  allowUnrecognizedEnumValues: true,
@@ -192,7 +196,7 @@ class PermissionsService {
192
196
  * @param {PermissionsService.RequestOptions} requestOptions - Request-specific configuration.
193
197
  *
194
198
  * @example
195
- * await credal.permissionsService.listCachedAuthorizedResourcesForUser({
199
+ * await client.permissionsService.listCachedAuthorizedResourcesForUser({
196
200
  * userEmail: "john.smith@foo.com"
197
201
  * })
198
202
  */
@@ -206,12 +210,14 @@ class PermissionsService {
206
210
  Authorization: yield this._getAuthorizationHeader(),
207
211
  "X-Fern-Language": "JavaScript",
208
212
  "X-Fern-SDK-Name": "@credal/sdk",
209
- "X-Fern-SDK-Version": "0.0.13",
213
+ "X-Fern-SDK-Version": "0.0.15",
214
+ "User-Agent": "@credal/sdk/0.0.15",
210
215
  "X-Fern-Runtime": core.RUNTIME.type,
211
216
  "X-Fern-Runtime-Version": core.RUNTIME.version,
212
217
  },
213
218
  contentType: "application/json",
214
- body: yield serializers.ListCachedAuthorizedResourcesForUserRequest.jsonOrThrow(request, {
219
+ requestType: "json",
220
+ body: serializers.ListCachedAuthorizedResourcesForUserRequest.jsonOrThrow(request, {
215
221
  unrecognizedObjectKeys: "strip",
216
222
  }),
217
223
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -219,7 +225,7 @@ class PermissionsService {
219
225
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
220
226
  });
221
227
  if (_response.ok) {
222
- return yield serializers.AuthorizedResourceListPage.parseOrThrow(_response.body, {
228
+ return serializers.AuthorizedResourceListPage.parseOrThrow(_response.body, {
223
229
  unrecognizedObjectKeys: "passthrough",
224
230
  allowUnrecognizedUnionMembers: true,
225
231
  allowUnrecognizedEnumValues: true,
@@ -11,7 +11,7 @@ import * as Credal from "../../../../index";
11
11
  * }, {
12
12
  * type: "external-resource-id",
13
13
  * externalResourceId: "sfsdfvr54UvyslPVWkQFOA0dfsdfsdflgNycFmdZJQr",
14
- * resourceType: Credal.ResourceType.ZendeskTicket
14
+ * resourceType: "ZENDESK_TICKET"
15
15
  * }],
16
16
  * userEmail: "john.smith@foo.com"
17
17
  * }
@@ -8,7 +8,7 @@ import * as Credal from "../../../../index";
8
8
  * resourceIdentifier: {
9
9
  * type: "external-resource-id",
10
10
  * externalResourceId: "170NrBm0Do7gdzvr54UvyslPVWkQFOA0lgNycFmdZJQr",
11
- * resourceType: Credal.ResourceType.GoogleDriveItem
11
+ * resourceType: "GOOGLE_DRIVE_ITEM"
12
12
  * },
13
13
  * userEmail: "john.smith@foo.com"
14
14
  * }
@@ -11,8 +11,11 @@ export declare namespace Search {
11
11
  fetcher?: core.FetchFunction;
12
12
  }
13
13
  interface RequestOptions {
14
+ /** The maximum time to wait for a response in seconds. */
14
15
  timeoutInSeconds?: number;
16
+ /** The number of times to retry the request. Defaults to 2. */
15
17
  maxRetries?: number;
18
+ /** A hook to abort the request. */
16
19
  abortSignal?: AbortSignal;
17
20
  }
18
21
  }
@@ -26,12 +29,12 @@ export declare class Search {
26
29
  * @param {Search.RequestOptions} requestOptions - Request-specific configuration.
27
30
  *
28
31
  * @example
29
- * await credal.search.searchDocumentCollection({
32
+ * await client.search.searchDocumentCollection({
30
33
  * collectionId: "82e4b12a-6990-45d4-8ebd-85c00e030c24",
31
34
  * searchQuery: "ABC Corp",
32
35
  * structuredQueryFilters: [{
33
36
  * field: "status",
34
- * operator: Credal.Operator.Equal,
37
+ * operator: "==",
35
38
  * value: "Open"
36
39
  * }],
37
40
  * userEmail: "jack@credal.ai",
@@ -55,12 +55,12 @@ class Search {
55
55
  * @param {Search.RequestOptions} requestOptions - Request-specific configuration.
56
56
  *
57
57
  * @example
58
- * await credal.search.searchDocumentCollection({
58
+ * await client.search.searchDocumentCollection({
59
59
  * collectionId: "82e4b12a-6990-45d4-8ebd-85c00e030c24",
60
60
  * searchQuery: "ABC Corp",
61
61
  * structuredQueryFilters: [{
62
62
  * field: "status",
63
- * operator: Credal.Operator.Equal,
63
+ * operator: "==",
64
64
  * value: "Open"
65
65
  * }],
66
66
  * userEmail: "jack@credal.ai",
@@ -84,20 +84,20 @@ class Search {
84
84
  Authorization: yield this._getAuthorizationHeader(),
85
85
  "X-Fern-Language": "JavaScript",
86
86
  "X-Fern-SDK-Name": "@credal/sdk",
87
- "X-Fern-SDK-Version": "0.0.13",
87
+ "X-Fern-SDK-Version": "0.0.15",
88
+ "User-Agent": "@credal/sdk/0.0.15",
88
89
  "X-Fern-Runtime": core.RUNTIME.type,
89
90
  "X-Fern-Runtime-Version": core.RUNTIME.version,
90
91
  },
91
92
  contentType: "application/json",
92
- body: yield serializers.SearchDocumentCollectionRequest.jsonOrThrow(request, {
93
- unrecognizedObjectKeys: "strip",
94
- }),
93
+ requestType: "json",
94
+ body: serializers.SearchDocumentCollectionRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
95
95
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
96
96
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
97
97
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
98
98
  });
99
99
  if (_response.ok) {
100
- return yield serializers.SearchDocumentCollectionResponse.parseOrThrow(_response.body, {
100
+ return serializers.SearchDocumentCollectionResponse.parseOrThrow(_response.body, {
101
101
  unrecognizedObjectKeys: "passthrough",
102
102
  allowUnrecognizedUnionMembers: true,
103
103
  allowUnrecognizedEnumValues: true,
@@ -9,7 +9,7 @@ import * as Credal from "../../../../index";
9
9
  * searchQuery: "ABC Corp",
10
10
  * structuredQueryFilters: [{
11
11
  * field: "status",
12
- * operator: Credal.Operator.Equal,
12
+ * operator: "==",
13
13
  * value: "Open"
14
14
  * }],
15
15
  * userEmail: "jack@credal.ai",
@@ -2,5 +2,4 @@ export * from "./DocumentCollectionSearchOptions";
2
2
  export * from "./SearchDocumentCollectionResponse";
3
3
  export * from "./DocumentCollectionSearchResult";
4
4
  export * from "./SearchResultChunk";
5
- export * from "./Operator";
6
5
  export * from "./SingleFieldFilter";
@@ -18,5 +18,4 @@ __exportStar(require("./DocumentCollectionSearchOptions"), exports);
18
18
  __exportStar(require("./SearchDocumentCollectionResponse"), exports);
19
19
  __exportStar(require("./DocumentCollectionSearchResult"), exports);
20
20
  __exportStar(require("./SearchResultChunk"), exports);
21
- __exportStar(require("./Operator"), exports);
22
21
  __exportStar(require("./SingleFieldFilter"), exports);
@@ -11,8 +11,11 @@ export declare namespace Users {
11
11
  fetcher?: core.FetchFunction;
12
12
  }
13
13
  interface RequestOptions {
14
+ /** The maximum time to wait for a response in seconds. */
14
15
  timeoutInSeconds?: number;
16
+ /** The number of times to retry the request. Defaults to 2. */
15
17
  maxRetries?: number;
18
+ /** A hook to abort the request. */
16
19
  abortSignal?: AbortSignal;
17
20
  }
18
21
  }
@@ -26,7 +29,7 @@ export declare class Users {
26
29
  * @param {Users.RequestOptions} requestOptions - Request-specific configuration.
27
30
  *
28
31
  * @example
29
- * await credal.users.metadata([{
32
+ * await client.users.metadata([{
30
33
  * metadata: {
31
34
  * "State": "NY",
32
35
  * "Job Role": "CEO"
@@ -55,7 +55,7 @@ class Users {
55
55
  * @param {Users.RequestOptions} requestOptions - Request-specific configuration.
56
56
  *
57
57
  * @example
58
- * await credal.users.metadata([{
58
+ * await client.users.metadata([{
59
59
  * metadata: {
60
60
  * "State": "NY",
61
61
  * "Job Role": "CEO"
@@ -79,12 +79,14 @@ class Users {
79
79
  Authorization: yield this._getAuthorizationHeader(),
80
80
  "X-Fern-Language": "JavaScript",
81
81
  "X-Fern-SDK-Name": "@credal/sdk",
82
- "X-Fern-SDK-Version": "0.0.13",
82
+ "X-Fern-SDK-Version": "0.0.15",
83
+ "User-Agent": "@credal/sdk/0.0.15",
83
84
  "X-Fern-Runtime": core.RUNTIME.type,
84
85
  "X-Fern-Runtime-Version": core.RUNTIME.version,
85
86
  },
86
87
  contentType: "application/json",
87
- body: yield serializers.users.metadata.Request.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
88
+ requestType: "json",
89
+ body: serializers.users.metadata.Request.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
88
90
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
89
91
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
90
92
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
@@ -12,7 +12,9 @@ export declare namespace Fetcher {
12
12
  maxRetries?: number;
13
13
  withCredentials?: boolean;
14
14
  abortSignal?: AbortSignal;
15
- responseType?: "json" | "blob" | "streaming" | "text";
15
+ requestType?: "json" | "file" | "bytes";
16
+ responseType?: "json" | "blob" | "sse" | "streaming" | "text" | "arrayBuffer";
17
+ duplex?: "half";
16
18
  }
17
19
  type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError;
18
20
  interface FailedStatusCodeError {
@@ -33,4 +35,5 @@ export declare namespace Fetcher {
33
35
  errorMessage: string;
34
36
  }
35
37
  }
38
+ export declare function fetcherImpl<R = unknown>(args: Fetcher.Args): Promise<APIResponse<R, Fetcher.Error>>;
36
39
  export declare const fetcher: FetchFunction;
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -31,18 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
9
  });
33
10
  };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
11
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.fetcher = void 0;
39
- const qs_1 = __importDefault(require("qs"));
40
- const runtime_1 = require("../runtime");
41
- const INITIAL_RETRY_DELAY = 1;
42
- const MAX_RETRY_DELAY = 60;
43
- const DEFAULT_MAX_RETRIES = 2;
12
+ exports.fetcher = exports.fetcherImpl = void 0;
13
+ const createRequestUrl_1 = require("./createRequestUrl");
14
+ const getFetchFn_1 = require("./getFetchFn");
15
+ const getRequestBody_1 = require("./getRequestBody");
16
+ const getResponseBody_1 = require("./getResponseBody");
17
+ const makeRequest_1 = require("./makeRequest");
18
+ const requestWithRetries_1 = require("./requestWithRetries");
44
19
  function fetcherImpl(args) {
45
- var _a, _b;
46
20
  return __awaiter(this, void 0, void 0, function* () {
47
21
  const headers = {};
48
22
  if (args.body !== undefined && args.contentType != null) {
@@ -55,121 +29,21 @@ function fetcherImpl(args) {
55
29
  }
56
30
  }
57
31
  }
58
- const url = Object.keys((_a = args.queryParameters) !== null && _a !== void 0 ? _a : {}).length > 0
59
- ? `${args.url}?${qs_1.default.stringify(args.queryParameters, { arrayFormat: "repeat" })}`
60
- : args.url;
61
- let body = undefined;
62
- const maybeStringifyBody = (body) => {
63
- if (body instanceof Uint8Array) {
64
- return body;
65
- }
66
- else if (args.contentType === "application/x-www-form-urlencoded" && typeof args.body === "string") {
67
- return args.body;
68
- }
69
- else {
70
- return JSON.stringify(body);
71
- }
72
- };
73
- if (runtime_1.RUNTIME.type === "node") {
74
- if (args.body instanceof (yield Promise.resolve().then(() => __importStar(require("formdata-node")))).FormData) {
75
- // @ts-expect-error
76
- body = args.body;
77
- }
78
- else {
79
- body = maybeStringifyBody(args.body);
80
- }
81
- }
82
- else {
83
- if (args.body instanceof (yield Promise.resolve().then(() => __importStar(require("form-data")))).default) {
84
- // @ts-expect-error
85
- body = args.body;
86
- }
87
- else {
88
- body = maybeStringifyBody(args.body);
89
- }
90
- }
91
- // In Node.js environments, the SDK always uses`node-fetch`.
92
- // If not in Node.js the SDK uses global fetch if available,
93
- // and falls back to node-fetch.
94
- const fetchFn = runtime_1.RUNTIME.type === "node"
95
- ? // `.default` is required due to this issue:
96
- // https://github.com/node-fetch/node-fetch/issues/450#issuecomment-387045223
97
- (yield Promise.resolve().then(() => __importStar(require("node-fetch")))).default
98
- : typeof fetch == "function"
99
- ? fetch
100
- : (yield Promise.resolve().then(() => __importStar(require("node-fetch")))).default;
101
- const makeRequest = () => __awaiter(this, void 0, void 0, function* () {
102
- const signals = [];
103
- // Add timeout signal
104
- let timeoutAbortId = undefined;
105
- if (args.timeoutMs != null) {
106
- const { signal, abortId } = getTimeoutSignal(args.timeoutMs);
107
- timeoutAbortId = abortId;
108
- signals.push(signal);
109
- }
110
- // Add arbitrary signal
111
- if (args.abortSignal != null) {
112
- signals.push(args.abortSignal);
113
- }
114
- const response = yield fetchFn(url, {
115
- method: args.method,
116
- headers,
117
- body,
118
- signal: anySignal(signals),
119
- credentials: args.withCredentials ? "include" : undefined,
120
- });
121
- if (timeoutAbortId != null) {
122
- clearTimeout(timeoutAbortId);
123
- }
124
- return response;
32
+ const url = (0, createRequestUrl_1.createRequestUrl)(args.url, args.queryParameters);
33
+ let requestBody = yield (0, getRequestBody_1.getRequestBody)({
34
+ body: args.body,
35
+ type: args.requestType === "json" ? "json" : "other",
125
36
  });
37
+ const fetchFn = yield (0, getFetchFn_1.getFetchFn)();
126
38
  try {
127
- let response = yield makeRequest();
128
- for (let i = 0; i < ((_b = args.maxRetries) !== null && _b !== void 0 ? _b : DEFAULT_MAX_RETRIES); ++i) {
129
- if (response.status === 408 ||
130
- response.status === 409 ||
131
- response.status === 429 ||
132
- response.status >= 500) {
133
- const delay = Math.min(INITIAL_RETRY_DELAY * Math.pow(i, 2), MAX_RETRY_DELAY);
134
- yield new Promise((resolve) => setTimeout(resolve, delay));
135
- response = yield makeRequest();
136
- }
137
- else {
138
- break;
139
- }
140
- }
141
- let body;
142
- if (response.body != null && args.responseType === "blob") {
143
- body = yield response.blob();
144
- }
145
- else if (response.body != null && args.responseType === "streaming") {
146
- body = response.body;
147
- }
148
- else if (response.body != null && args.responseType === "text") {
149
- body = yield response.text();
150
- }
151
- else {
152
- const text = yield response.text();
153
- if (text.length > 0) {
154
- try {
155
- body = JSON.parse(text);
156
- }
157
- catch (err) {
158
- return {
159
- ok: false,
160
- error: {
161
- reason: "non-json",
162
- statusCode: response.status,
163
- rawBody: text,
164
- },
165
- };
166
- }
167
- }
168
- }
39
+ const response = yield (0, requestWithRetries_1.requestWithRetries)(() => __awaiter(this, void 0, void 0, function* () {
40
+ return (0, makeRequest_1.makeRequest)(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex);
41
+ }), args.maxRetries);
42
+ let responseBody = yield (0, getResponseBody_1.getResponseBody)(response, args.responseType);
169
43
  if (response.status >= 200 && response.status < 400) {
170
44
  return {
171
45
  ok: true,
172
- body: body,
46
+ body: responseBody,
173
47
  headers: response.headers,
174
48
  };
175
49
  }
@@ -179,7 +53,7 @@ function fetcherImpl(args) {
179
53
  error: {
180
54
  reason: "status-code",
181
55
  statusCode: response.status,
182
- body,
56
+ body: responseBody,
183
57
  },
184
58
  };
185
59
  }
@@ -221,36 +95,5 @@ function fetcherImpl(args) {
221
95
  }
222
96
  });
223
97
  }
224
- const TIMEOUT = "timeout";
225
- function getTimeoutSignal(timeoutMs) {
226
- const controller = new AbortController();
227
- const abortId = setTimeout(() => controller.abort(TIMEOUT), timeoutMs);
228
- return { signal: controller.signal, abortId };
229
- }
230
- /**
231
- * Returns an abort signal that is getting aborted when
232
- * at least one of the specified abort signals is aborted.
233
- *
234
- * Requires at least node.js 18.
235
- */
236
- function anySignal(...args) {
237
- // Allowing signals to be passed either as array
238
- // of signals or as multiple arguments.
239
- const signals = (args.length === 1 && Array.isArray(args[0]) ? args[0] : args);
240
- const controller = new AbortController();
241
- for (const signal of signals) {
242
- if (signal.aborted) {
243
- // Exiting early if one of the signals
244
- // is already aborted.
245
- controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason);
246
- break;
247
- }
248
- // Listening for signals and removing the listeners
249
- // when at least one symbol is aborted.
250
- signal.addEventListener("abort", () => controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason), {
251
- signal: controller.signal,
252
- });
253
- }
254
- return controller.signal;
255
- }
98
+ exports.fetcherImpl = fetcherImpl;
256
99
  exports.fetcher = fetcherImpl;
@@ -0,0 +1 @@
1
+ export declare function createRequestUrl(baseUrl: string, queryParameters?: Record<string, string | string[] | object | object[]>): string;
@@ -0,0 +1,13 @@
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.createRequestUrl = void 0;
7
+ const qs_1 = __importDefault(require("qs"));
8
+ function createRequestUrl(baseUrl, queryParameters) {
9
+ return Object.keys(queryParameters !== null && queryParameters !== void 0 ? queryParameters : {}).length > 0
10
+ ? `${baseUrl}?${qs_1.default.stringify(queryParameters, { arrayFormat: "repeat" })}`
11
+ : baseUrl;
12
+ }
13
+ exports.createRequestUrl = createRequestUrl;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Returns a fetch function based on the runtime
3
+ */
4
+ export declare function getFetchFn(): Promise<any>;