opik 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (554) hide show
  1. package/dist/Node18UniversalStreamWrapper-5PLK6H2I.js +216 -0
  2. package/dist/NodePre18StreamWrapper-PJE27LW2.js +88 -0
  3. package/dist/UndiciStreamWrapper-M2WUKUR4.js +204 -0
  4. package/dist/chunk-MLKGABMK.js +9 -0
  5. package/dist/index.cjs +10735 -0
  6. package/dist/index.d.cts +3653 -0
  7. package/dist/index.d.ts +3653 -0
  8. package/dist/index.js +10173 -0
  9. package/examples/manual-trace.js +16 -0
  10. package/package.json +56 -0
  11. package/src/opik/client/Client.ts +65 -0
  12. package/src/opik/config/Config.ts +35 -0
  13. package/src/opik/index.ts +2 -0
  14. package/src/opik/rest_api/Client.ts +247 -0
  15. package/src/opik/rest_api/api/errors/BadRequestError.ts +16 -0
  16. package/src/opik/rest_api/api/errors/ConflictError.ts +16 -0
  17. package/src/opik/rest_api/api/errors/ForbiddenError.ts +17 -0
  18. package/src/opik/rest_api/api/errors/NotFoundError.ts +16 -0
  19. package/src/opik/rest_api/api/errors/NotImplementedError.ts +16 -0
  20. package/src/opik/rest_api/api/errors/UnauthorizedError.ts +17 -0
  21. package/src/opik/rest_api/api/errors/UnprocessableEntityError.ts +16 -0
  22. package/src/opik/rest_api/api/errors/index.ts +7 -0
  23. package/src/opik/rest_api/api/index.ts +3 -0
  24. package/src/opik/rest_api/api/resources/chatCompletions/client/Client.ts +125 -0
  25. package/src/opik/rest_api/api/resources/chatCompletions/client/index.ts +1 -0
  26. package/src/opik/rest_api/api/resources/chatCompletions/client/requests/ChatCompletionRequest.ts +33 -0
  27. package/src/opik/rest_api/api/resources/chatCompletions/client/requests/index.ts +1 -0
  28. package/src/opik/rest_api/api/resources/chatCompletions/index.ts +1 -0
  29. package/src/opik/rest_api/api/resources/check/client/Client.ts +141 -0
  30. package/src/opik/rest_api/api/resources/check/client/index.ts +1 -0
  31. package/src/opik/rest_api/api/resources/check/index.ts +1 -0
  32. package/src/opik/rest_api/api/resources/datasets/client/Client.ts +1244 -0
  33. package/src/opik/rest_api/api/resources/datasets/client/index.ts +1 -0
  34. package/src/opik/rest_api/api/resources/datasets/client/requests/DatasetIdentifier.ts +13 -0
  35. package/src/opik/rest_api/api/resources/datasets/client/requests/DatasetIdentifierPublic.ts +13 -0
  36. package/src/opik/rest_api/api/resources/datasets/client/requests/DatasetItemBatchWrite.ts +21 -0
  37. package/src/opik/rest_api/api/resources/datasets/client/requests/DatasetItemStreamRequest.ts +9 -0
  38. package/src/opik/rest_api/api/resources/datasets/client/requests/DatasetItemsDelete.ts +13 -0
  39. package/src/opik/rest_api/api/resources/datasets/client/requests/DatasetUpdate.ts +14 -0
  40. package/src/opik/rest_api/api/resources/datasets/client/requests/DatasetWrite.ts +15 -0
  41. package/src/opik/rest_api/api/resources/datasets/client/requests/FindDatasetItemsWithExperimentItemsRequest.ts +17 -0
  42. package/src/opik/rest_api/api/resources/datasets/client/requests/FindDatasetsRequest.ts +16 -0
  43. package/src/opik/rest_api/api/resources/datasets/client/requests/GetDatasetItemsOutputColumnsRequest.ts +11 -0
  44. package/src/opik/rest_api/api/resources/datasets/client/requests/GetDatasetItemsRequest.ts +13 -0
  45. package/src/opik/rest_api/api/resources/datasets/client/requests/index.ts +11 -0
  46. package/src/opik/rest_api/api/resources/datasets/index.ts +1 -0
  47. package/src/opik/rest_api/api/resources/experiments/client/Client.ts +858 -0
  48. package/src/opik/rest_api/api/resources/experiments/client/index.ts +1 -0
  49. package/src/opik/rest_api/api/resources/experiments/client/requests/ExperimentItemStreamRequest.ts +9 -0
  50. package/src/opik/rest_api/api/resources/experiments/client/requests/ExperimentItemsBatch.ts +19 -0
  51. package/src/opik/rest_api/api/resources/experiments/client/requests/ExperimentItemsDelete.ts +13 -0
  52. package/src/opik/rest_api/api/resources/experiments/client/requests/ExperimentWrite.ts +19 -0
  53. package/src/opik/rest_api/api/resources/experiments/client/requests/ExperimentsDelete.ts +13 -0
  54. package/src/opik/rest_api/api/resources/experiments/client/requests/FindExperimentsRequest.ts +16 -0
  55. package/src/opik/rest_api/api/resources/experiments/client/requests/FindFeedbackScoreNamesRequest.ts +11 -0
  56. package/src/opik/rest_api/api/resources/experiments/client/requests/IdentifierPublic.ts +13 -0
  57. package/src/opik/rest_api/api/resources/experiments/client/requests/index.ts +8 -0
  58. package/src/opik/rest_api/api/resources/experiments/index.ts +1 -0
  59. package/src/opik/rest_api/api/resources/feedbackDefinitions/client/Client.ts +515 -0
  60. package/src/opik/rest_api/api/resources/feedbackDefinitions/client/index.ts +1 -0
  61. package/src/opik/rest_api/api/resources/feedbackDefinitions/client/requests/FindFeedbackDefinitionsRequest.ts +16 -0
  62. package/src/opik/rest_api/api/resources/feedbackDefinitions/client/requests/index.ts +1 -0
  63. package/src/opik/rest_api/api/resources/feedbackDefinitions/index.ts +2 -0
  64. package/src/opik/rest_api/api/resources/feedbackDefinitions/types/FindFeedbackDefinitionsRequestType.ts +10 -0
  65. package/src/opik/rest_api/api/resources/feedbackDefinitions/types/index.ts +1 -0
  66. package/src/opik/rest_api/api/resources/index.ts +23 -0
  67. package/src/opik/rest_api/api/resources/llmProviderKey/client/Client.ts +412 -0
  68. package/src/opik/rest_api/api/resources/llmProviderKey/client/index.ts +1 -0
  69. package/src/opik/rest_api/api/resources/llmProviderKey/client/requests/ProviderApiKeyUpdate.ts +13 -0
  70. package/src/opik/rest_api/api/resources/llmProviderKey/client/requests/ProviderApiKeyWrite.ts +13 -0
  71. package/src/opik/rest_api/api/resources/llmProviderKey/client/requests/index.ts +2 -0
  72. package/src/opik/rest_api/api/resources/llmProviderKey/index.ts +1 -0
  73. package/src/opik/rest_api/api/resources/projects/client/Client.ts +720 -0
  74. package/src/opik/rest_api/api/resources/projects/client/index.ts +1 -0
  75. package/src/opik/rest_api/api/resources/projects/client/requests/FindProjectsRequest.ts +14 -0
  76. package/src/opik/rest_api/api/resources/projects/client/requests/ProjectMetricRequestPublic.ts +16 -0
  77. package/src/opik/rest_api/api/resources/projects/client/requests/ProjectRetrievePublic.ts +13 -0
  78. package/src/opik/rest_api/api/resources/projects/client/requests/ProjectUpdate.ts +12 -0
  79. package/src/opik/rest_api/api/resources/projects/client/requests/ProjectWrite.ts +14 -0
  80. package/src/opik/rest_api/api/resources/projects/client/requests/index.ts +5 -0
  81. package/src/opik/rest_api/api/resources/projects/index.ts +2 -0
  82. package/src/opik/rest_api/api/resources/projects/types/ProjectMetricRequestPublicInterval.ts +11 -0
  83. package/src/opik/rest_api/api/resources/projects/types/ProjectMetricRequestPublicMetricType.ts +18 -0
  84. package/src/opik/rest_api/api/resources/projects/types/index.ts +2 -0
  85. package/src/opik/rest_api/api/resources/prompts/client/Client.ts +900 -0
  86. package/src/opik/rest_api/api/resources/prompts/client/index.ts +1 -0
  87. package/src/opik/rest_api/api/resources/prompts/client/requests/CreatePromptVersionDetail.ts +19 -0
  88. package/src/opik/rest_api/api/resources/prompts/client/requests/GetPromptVersionsRequest.ts +12 -0
  89. package/src/opik/rest_api/api/resources/prompts/client/requests/GetPromptsRequest.ts +13 -0
  90. package/src/opik/rest_api/api/resources/prompts/client/requests/PromptUpdatable.ts +14 -0
  91. package/src/opik/rest_api/api/resources/prompts/client/requests/PromptVersionRetrieveDetail.ts +14 -0
  92. package/src/opik/rest_api/api/resources/prompts/client/requests/PromptWrite.ts +16 -0
  93. package/src/opik/rest_api/api/resources/prompts/client/requests/index.ts +6 -0
  94. package/src/opik/rest_api/api/resources/prompts/index.ts +1 -0
  95. package/src/opik/rest_api/api/resources/spans/client/Client.ts +957 -0
  96. package/src/opik/rest_api/api/resources/spans/client/index.ts +1 -0
  97. package/src/opik/rest_api/api/resources/spans/client/requests/FindFeedbackScoreNames1Request.ts +14 -0
  98. package/src/opik/rest_api/api/resources/spans/client/requests/GetSpanStatsRequest.ts +17 -0
  99. package/src/opik/rest_api/api/resources/spans/client/requests/GetSpansByProjectRequest.ts +20 -0
  100. package/src/opik/rest_api/api/resources/spans/client/requests/SpanBatchWrite.ts +20 -0
  101. package/src/opik/rest_api/api/resources/spans/client/requests/SpanUpdate.ts +29 -0
  102. package/src/opik/rest_api/api/resources/spans/client/requests/index.ts +5 -0
  103. package/src/opik/rest_api/api/resources/spans/index.ts +2 -0
  104. package/src/opik/rest_api/api/resources/spans/types/FindFeedbackScoreNames1RequestType.ts +11 -0
  105. package/src/opik/rest_api/api/resources/spans/types/GetSpanStatsRequestType.ts +11 -0
  106. package/src/opik/rest_api/api/resources/spans/types/GetSpansByProjectRequestType.ts +11 -0
  107. package/src/opik/rest_api/api/resources/spans/types/index.ts +3 -0
  108. package/src/opik/rest_api/api/resources/systemUsage/client/Client.ts +347 -0
  109. package/src/opik/rest_api/api/resources/systemUsage/client/index.ts +1 -0
  110. package/src/opik/rest_api/api/resources/systemUsage/index.ts +1 -0
  111. package/src/opik/rest_api/api/resources/traces/client/Client.ts +990 -0
  112. package/src/opik/rest_api/api/resources/traces/client/index.ts +1 -0
  113. package/src/opik/rest_api/api/resources/traces/client/requests/FindFeedbackScoreNames2Request.ts +11 -0
  114. package/src/opik/rest_api/api/resources/traces/client/requests/GetTraceStatsRequest.ts +13 -0
  115. package/src/opik/rest_api/api/resources/traces/client/requests/GetTracesByProjectRequest.ts +16 -0
  116. package/src/opik/rest_api/api/resources/traces/client/requests/TraceBatchWrite.ts +18 -0
  117. package/src/opik/rest_api/api/resources/traces/client/requests/TraceUpdate.ts +22 -0
  118. package/src/opik/rest_api/api/resources/traces/client/requests/index.ts +5 -0
  119. package/src/opik/rest_api/api/resources/traces/index.ts +1 -0
  120. package/src/opik/rest_api/api/types/AssistantMessage.ts +14 -0
  121. package/src/opik/rest_api/api/types/AssistantMessageRole.ts +13 -0
  122. package/src/opik/rest_api/api/types/AuthDetailsHolder.ts +5 -0
  123. package/src/opik/rest_api/api/types/AvgValueStatPublic.ts +7 -0
  124. package/src/opik/rest_api/api/types/BatchDelete.ts +7 -0
  125. package/src/opik/rest_api/api/types/BiInformation.ts +9 -0
  126. package/src/opik/rest_api/api/types/BiInformationResponse.ts +9 -0
  127. package/src/opik/rest_api/api/types/CategoricalFeedbackDefinition.ts +13 -0
  128. package/src/opik/rest_api/api/types/CategoricalFeedbackDefinitionCreate.ts +9 -0
  129. package/src/opik/rest_api/api/types/CategoricalFeedbackDefinitionPublic.ts +13 -0
  130. package/src/opik/rest_api/api/types/CategoricalFeedbackDefinitionUpdate.ts +9 -0
  131. package/src/opik/rest_api/api/types/CategoricalFeedbackDetail.ts +7 -0
  132. package/src/opik/rest_api/api/types/CategoricalFeedbackDetailCreate.ts +7 -0
  133. package/src/opik/rest_api/api/types/CategoricalFeedbackDetailPublic.ts +7 -0
  134. package/src/opik/rest_api/api/types/CategoricalFeedbackDetailUpdate.ts +7 -0
  135. package/src/opik/rest_api/api/types/ChatCompletionChoice.ts +12 -0
  136. package/src/opik/rest_api/api/types/ChatCompletionResponse.ts +14 -0
  137. package/src/opik/rest_api/api/types/ChunkedOutputJsonNode.ts +10 -0
  138. package/src/opik/rest_api/api/types/ChunkedOutputJsonNodeType.ts +7 -0
  139. package/src/opik/rest_api/api/types/Column.ts +13 -0
  140. package/src/opik/rest_api/api/types/ColumnCompare.ts +13 -0
  141. package/src/opik/rest_api/api/types/ColumnCompareTypesItem.ts +14 -0
  142. package/src/opik/rest_api/api/types/ColumnPublic.ts +13 -0
  143. package/src/opik/rest_api/api/types/ColumnPublicTypesItem.ts +14 -0
  144. package/src/opik/rest_api/api/types/ColumnTypesItem.ts +14 -0
  145. package/src/opik/rest_api/api/types/CompletionTokensDetails.ts +7 -0
  146. package/src/opik/rest_api/api/types/CountValueStatPublic.ts +7 -0
  147. package/src/opik/rest_api/api/types/DataPointNumberPublic.ts +8 -0
  148. package/src/opik/rest_api/api/types/Dataset.ts +17 -0
  149. package/src/opik/rest_api/api/types/DatasetItem.ts +21 -0
  150. package/src/opik/rest_api/api/types/DatasetItemBatch.ts +13 -0
  151. package/src/opik/rest_api/api/types/DatasetItemCompare.ts +21 -0
  152. package/src/opik/rest_api/api/types/DatasetItemCompareSource.ts +12 -0
  153. package/src/opik/rest_api/api/types/DatasetItemPageCompare.ts +13 -0
  154. package/src/opik/rest_api/api/types/DatasetItemPagePublic.ts +13 -0
  155. package/src/opik/rest_api/api/types/DatasetItemPublic.ts +21 -0
  156. package/src/opik/rest_api/api/types/DatasetItemPublicSource.ts +12 -0
  157. package/src/opik/rest_api/api/types/DatasetItemSource.ts +12 -0
  158. package/src/opik/rest_api/api/types/DatasetItemWrite.ts +16 -0
  159. package/src/opik/rest_api/api/types/DatasetItemWriteSource.ts +12 -0
  160. package/src/opik/rest_api/api/types/DatasetPagePublic.ts +12 -0
  161. package/src/opik/rest_api/api/types/DatasetPublic.ts +17 -0
  162. package/src/opik/rest_api/api/types/DeleteFeedbackScore.ts +7 -0
  163. package/src/opik/rest_api/api/types/Delta.ts +12 -0
  164. package/src/opik/rest_api/api/types/DeltaRole.ts +13 -0
  165. package/src/opik/rest_api/api/types/ErrorInfo.ts +9 -0
  166. package/src/opik/rest_api/api/types/ErrorInfoPublic.ts +9 -0
  167. package/src/opik/rest_api/api/types/ErrorInfoWrite.ts +9 -0
  168. package/src/opik/rest_api/api/types/ErrorMessage.ts +9 -0
  169. package/src/opik/rest_api/api/types/ErrorMessageDetail.ts +9 -0
  170. package/src/opik/rest_api/api/types/ErrorMessagePublic.ts +7 -0
  171. package/src/opik/rest_api/api/types/Experiment.ts +20 -0
  172. package/src/opik/rest_api/api/types/ExperimentItem.ts +19 -0
  173. package/src/opik/rest_api/api/types/ExperimentItemCompare.ts +19 -0
  174. package/src/opik/rest_api/api/types/ExperimentItemPublic.ts +14 -0
  175. package/src/opik/rest_api/api/types/ExperimentPagePublic.ts +12 -0
  176. package/src/opik/rest_api/api/types/ExperimentPublic.ts +20 -0
  177. package/src/opik/rest_api/api/types/Feedback.ts +26 -0
  178. package/src/opik/rest_api/api/types/FeedbackCreate.ts +22 -0
  179. package/src/opik/rest_api/api/types/FeedbackDefinitionPagePublic.ts +12 -0
  180. package/src/opik/rest_api/api/types/FeedbackObjectPublic.ts +26 -0
  181. package/src/opik/rest_api/api/types/FeedbackPublic.ts +26 -0
  182. package/src/opik/rest_api/api/types/FeedbackScore.ts +17 -0
  183. package/src/opik/rest_api/api/types/FeedbackScoreAverage.ts +8 -0
  184. package/src/opik/rest_api/api/types/FeedbackScoreAveragePublic.ts +8 -0
  185. package/src/opik/rest_api/api/types/FeedbackScoreBatch.ts +9 -0
  186. package/src/opik/rest_api/api/types/FeedbackScoreBatchItem.ts +16 -0
  187. package/src/opik/rest_api/api/types/FeedbackScoreBatchItemSource.ts +10 -0
  188. package/src/opik/rest_api/api/types/FeedbackScoreCompare.ts +17 -0
  189. package/src/opik/rest_api/api/types/FeedbackScoreCompareSource.ts +10 -0
  190. package/src/opik/rest_api/api/types/FeedbackScorePublic.ts +17 -0
  191. package/src/opik/rest_api/api/types/FeedbackScorePublicSource.ts +10 -0
  192. package/src/opik/rest_api/api/types/FeedbackScoreSource.ts +10 -0
  193. package/src/opik/rest_api/api/types/FeedbackUpdate.ts +22 -0
  194. package/src/opik/rest_api/api/types/Function.ts +12 -0
  195. package/src/opik/rest_api/api/types/FunctionCall.ts +8 -0
  196. package/src/opik/rest_api/api/types/JsonNode.ts +5 -0
  197. package/src/opik/rest_api/api/types/JsonNodeCompare.ts +5 -0
  198. package/src/opik/rest_api/api/types/JsonNodePublic.ts +5 -0
  199. package/src/opik/rest_api/api/types/JsonNodeWrite.ts +5 -0
  200. package/src/opik/rest_api/api/types/JsonObjectSchema.ts +14 -0
  201. package/src/opik/rest_api/api/types/JsonSchema.ts +11 -0
  202. package/src/opik/rest_api/api/types/JsonSchemaElement.ts +7 -0
  203. package/src/opik/rest_api/api/types/Message.ts +5 -0
  204. package/src/opik/rest_api/api/types/NumericalFeedbackDefinition.ts +13 -0
  205. package/src/opik/rest_api/api/types/NumericalFeedbackDefinitionCreate.ts +9 -0
  206. package/src/opik/rest_api/api/types/NumericalFeedbackDefinitionPublic.ts +13 -0
  207. package/src/opik/rest_api/api/types/NumericalFeedbackDefinitionUpdate.ts +9 -0
  208. package/src/opik/rest_api/api/types/NumericalFeedbackDetail.ts +8 -0
  209. package/src/opik/rest_api/api/types/NumericalFeedbackDetailCreate.ts +8 -0
  210. package/src/opik/rest_api/api/types/NumericalFeedbackDetailPublic.ts +8 -0
  211. package/src/opik/rest_api/api/types/NumericalFeedbackDetailUpdate.ts +8 -0
  212. package/src/opik/rest_api/api/types/PageColumns.ts +9 -0
  213. package/src/opik/rest_api/api/types/PercentageValueStatPublic.ts +9 -0
  214. package/src/opik/rest_api/api/types/PercentageValuesPublic.ts +9 -0
  215. package/src/opik/rest_api/api/types/Project.ts +14 -0
  216. package/src/opik/rest_api/api/types/ProjectMetricResponsePublic.ts +12 -0
  217. package/src/opik/rest_api/api/types/ProjectMetricResponsePublicInterval.ts +11 -0
  218. package/src/opik/rest_api/api/types/ProjectMetricResponsePublicMetricType.ts +18 -0
  219. package/src/opik/rest_api/api/types/ProjectPagePublic.ts +13 -0
  220. package/src/opik/rest_api/api/types/ProjectPublic.ts +14 -0
  221. package/src/opik/rest_api/api/types/ProjectStatItemObjectPublic.ts +28 -0
  222. package/src/opik/rest_api/api/types/ProjectStatsPublic.ts +9 -0
  223. package/src/opik/rest_api/api/types/Prompt.ts +18 -0
  224. package/src/opik/rest_api/api/types/PromptDetail.ts +17 -0
  225. package/src/opik/rest_api/api/types/PromptPagePublic.ts +12 -0
  226. package/src/opik/rest_api/api/types/PromptPublic.ts +14 -0
  227. package/src/opik/rest_api/api/types/PromptVersion.ts +15 -0
  228. package/src/opik/rest_api/api/types/PromptVersionDetail.ts +15 -0
  229. package/src/opik/rest_api/api/types/PromptVersionLink.ts +9 -0
  230. package/src/opik/rest_api/api/types/PromptVersionLinkPublic.ts +9 -0
  231. package/src/opik/rest_api/api/types/PromptVersionLinkWrite.ts +7 -0
  232. package/src/opik/rest_api/api/types/PromptVersionPagePublic.ts +12 -0
  233. package/src/opik/rest_api/api/types/PromptVersionPublic.ts +14 -0
  234. package/src/opik/rest_api/api/types/ProviderApiKey.ts +13 -0
  235. package/src/opik/rest_api/api/types/ProviderApiKeyPublic.ts +12 -0
  236. package/src/opik/rest_api/api/types/ResponseFormat.ts +10 -0
  237. package/src/opik/rest_api/api/types/ResponseFormatType.ts +11 -0
  238. package/src/opik/rest_api/api/types/ResultsNumberPublic.ts +10 -0
  239. package/src/opik/rest_api/api/types/Span.ts +32 -0
  240. package/src/opik/rest_api/api/types/SpanBatch.ts +9 -0
  241. package/src/opik/rest_api/api/types/SpanPagePublic.ts +12 -0
  242. package/src/opik/rest_api/api/types/SpanPublic.ts +30 -0
  243. package/src/opik/rest_api/api/types/SpanPublicType.ts +11 -0
  244. package/src/opik/rest_api/api/types/SpanType.ts +11 -0
  245. package/src/opik/rest_api/api/types/SpanWrite.ts +25 -0
  246. package/src/opik/rest_api/api/types/SpanWriteType.ts +11 -0
  247. package/src/opik/rest_api/api/types/StreamOptions.ts +7 -0
  248. package/src/opik/rest_api/api/types/Tool.ts +10 -0
  249. package/src/opik/rest_api/api/types/ToolCall.ts +12 -0
  250. package/src/opik/rest_api/api/types/Trace.ts +27 -0
  251. package/src/opik/rest_api/api/types/TraceBatch.ts +9 -0
  252. package/src/opik/rest_api/api/types/TraceCountResponse.ts +9 -0
  253. package/src/opik/rest_api/api/types/TracePagePublic.ts +12 -0
  254. package/src/opik/rest_api/api/types/TracePublic.ts +25 -0
  255. package/src/opik/rest_api/api/types/TraceWrite.ts +19 -0
  256. package/src/opik/rest_api/api/types/Usage.ts +12 -0
  257. package/src/opik/rest_api/api/types/WorkspaceTraceCount.ts +8 -0
  258. package/src/opik/rest_api/api/types/index.ts +138 -0
  259. package/src/opik/rest_api/core/api-promise/APIPromise.ts +54 -0
  260. package/src/opik/rest_api/core/api-promise/index.ts +1 -0
  261. package/src/opik/rest_api/core/fetcher/APIResponse.ts +12 -0
  262. package/src/opik/rest_api/core/fetcher/Fetcher.ts +143 -0
  263. package/src/opik/rest_api/core/fetcher/Supplier.ts +11 -0
  264. package/src/opik/rest_api/core/fetcher/createRequestUrl.ts +10 -0
  265. package/src/opik/rest_api/core/fetcher/getFetchFn.ts +25 -0
  266. package/src/opik/rest_api/core/fetcher/getHeader.ts +8 -0
  267. package/src/opik/rest_api/core/fetcher/getRequestBody.ts +14 -0
  268. package/src/opik/rest_api/core/fetcher/getResponseBody.ts +34 -0
  269. package/src/opik/rest_api/core/fetcher/index.ts +5 -0
  270. package/src/opik/rest_api/core/fetcher/makeRequest.ts +44 -0
  271. package/src/opik/rest_api/core/fetcher/requestWithRetries.ts +33 -0
  272. package/src/opik/rest_api/core/fetcher/signals.ts +38 -0
  273. package/src/opik/rest_api/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts +256 -0
  274. package/src/opik/rest_api/core/fetcher/stream-wrappers/NodePre18StreamWrapper.ts +106 -0
  275. package/src/opik/rest_api/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts +243 -0
  276. package/src/opik/rest_api/core/fetcher/stream-wrappers/chooseStreamWrapper.ts +33 -0
  277. package/src/opik/rest_api/core/index.ts +4 -0
  278. package/src/opik/rest_api/core/runtime/index.ts +1 -0
  279. package/src/opik/rest_api/core/runtime/runtime.ts +126 -0
  280. package/src/opik/rest_api/core/schemas/Schema.ts +99 -0
  281. package/src/opik/rest_api/core/schemas/builders/bigint/bigint.ts +50 -0
  282. package/src/opik/rest_api/core/schemas/builders/bigint/index.ts +1 -0
  283. package/src/opik/rest_api/core/schemas/builders/date/date.ts +65 -0
  284. package/src/opik/rest_api/core/schemas/builders/date/index.ts +1 -0
  285. package/src/opik/rest_api/core/schemas/builders/enum/enum.ts +43 -0
  286. package/src/opik/rest_api/core/schemas/builders/enum/index.ts +1 -0
  287. package/src/opik/rest_api/core/schemas/builders/index.ts +14 -0
  288. package/src/opik/rest_api/core/schemas/builders/lazy/index.ts +3 -0
  289. package/src/opik/rest_api/core/schemas/builders/lazy/lazy.ts +32 -0
  290. package/src/opik/rest_api/core/schemas/builders/lazy/lazyObject.ts +20 -0
  291. package/src/opik/rest_api/core/schemas/builders/list/index.ts +1 -0
  292. package/src/opik/rest_api/core/schemas/builders/list/list.ts +73 -0
  293. package/src/opik/rest_api/core/schemas/builders/literals/booleanLiteral.ts +29 -0
  294. package/src/opik/rest_api/core/schemas/builders/literals/index.ts +2 -0
  295. package/src/opik/rest_api/core/schemas/builders/literals/stringLiteral.ts +29 -0
  296. package/src/opik/rest_api/core/schemas/builders/object/index.ts +22 -0
  297. package/src/opik/rest_api/core/schemas/builders/object/object.ts +324 -0
  298. package/src/opik/rest_api/core/schemas/builders/object/objectWithoutOptionalProperties.ts +18 -0
  299. package/src/opik/rest_api/core/schemas/builders/object/property.ts +23 -0
  300. package/src/opik/rest_api/core/schemas/builders/object/types.ts +72 -0
  301. package/src/opik/rest_api/core/schemas/builders/object-like/getObjectLikeUtils.ts +79 -0
  302. package/src/opik/rest_api/core/schemas/builders/object-like/index.ts +2 -0
  303. package/src/opik/rest_api/core/schemas/builders/object-like/types.ts +11 -0
  304. package/src/opik/rest_api/core/schemas/builders/primitives/any.ts +4 -0
  305. package/src/opik/rest_api/core/schemas/builders/primitives/boolean.ts +25 -0
  306. package/src/opik/rest_api/core/schemas/builders/primitives/index.ts +5 -0
  307. package/src/opik/rest_api/core/schemas/builders/primitives/number.ts +25 -0
  308. package/src/opik/rest_api/core/schemas/builders/primitives/string.ts +25 -0
  309. package/src/opik/rest_api/core/schemas/builders/primitives/unknown.ts +4 -0
  310. package/src/opik/rest_api/core/schemas/builders/record/index.ts +2 -0
  311. package/src/opik/rest_api/core/schemas/builders/record/record.ts +130 -0
  312. package/src/opik/rest_api/core/schemas/builders/record/types.ts +17 -0
  313. package/src/opik/rest_api/core/schemas/builders/schema-utils/JsonError.ts +9 -0
  314. package/src/opik/rest_api/core/schemas/builders/schema-utils/ParseError.ts +9 -0
  315. package/src/opik/rest_api/core/schemas/builders/schema-utils/getSchemaUtils.ts +105 -0
  316. package/src/opik/rest_api/core/schemas/builders/schema-utils/index.ts +4 -0
  317. package/src/opik/rest_api/core/schemas/builders/schema-utils/stringifyValidationErrors.ts +8 -0
  318. package/src/opik/rest_api/core/schemas/builders/set/index.ts +1 -0
  319. package/src/opik/rest_api/core/schemas/builders/set/set.ts +43 -0
  320. package/src/opik/rest_api/core/schemas/builders/undiscriminated-union/index.ts +6 -0
  321. package/src/opik/rest_api/core/schemas/builders/undiscriminated-union/types.ts +10 -0
  322. package/src/opik/rest_api/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.ts +60 -0
  323. package/src/opik/rest_api/core/schemas/builders/union/discriminant.ts +14 -0
  324. package/src/opik/rest_api/core/schemas/builders/union/index.ts +10 -0
  325. package/src/opik/rest_api/core/schemas/builders/union/types.ts +26 -0
  326. package/src/opik/rest_api/core/schemas/builders/union/union.ts +170 -0
  327. package/src/opik/rest_api/core/schemas/index.ts +2 -0
  328. package/src/opik/rest_api/core/schemas/utils/MaybePromise.ts +1 -0
  329. package/src/opik/rest_api/core/schemas/utils/addQuestionMarksToNullableProperties.ts +15 -0
  330. package/src/opik/rest_api/core/schemas/utils/createIdentitySchemaCreator.ts +21 -0
  331. package/src/opik/rest_api/core/schemas/utils/entries.ts +3 -0
  332. package/src/opik/rest_api/core/schemas/utils/filterObject.ts +10 -0
  333. package/src/opik/rest_api/core/schemas/utils/getErrorMessageForIncorrectType.ts +25 -0
  334. package/src/opik/rest_api/core/schemas/utils/isPlainObject.ts +17 -0
  335. package/src/opik/rest_api/core/schemas/utils/keys.ts +3 -0
  336. package/src/opik/rest_api/core/schemas/utils/maybeSkipValidation.ts +38 -0
  337. package/src/opik/rest_api/core/schemas/utils/partition.ts +12 -0
  338. package/src/opik/rest_api/environments.ts +9 -0
  339. package/src/opik/rest_api/errors/OpikApiError.ts +45 -0
  340. package/src/opik/rest_api/errors/OpikApiTimeoutError.ts +10 -0
  341. package/src/opik/rest_api/errors/index.ts +2 -0
  342. package/src/opik/rest_api/index.ts +4 -0
  343. package/src/opik/rest_api/serialization/index.ts +2 -0
  344. package/src/opik/rest_api/serialization/resources/chatCompletions/client/index.ts +1 -0
  345. package/src/opik/rest_api/serialization/resources/chatCompletions/client/requests/ChatCompletionRequest.ts +72 -0
  346. package/src/opik/rest_api/serialization/resources/chatCompletions/client/requests/index.ts +1 -0
  347. package/src/opik/rest_api/serialization/resources/chatCompletions/index.ts +1 -0
  348. package/src/opik/rest_api/serialization/resources/datasets/client/index.ts +1 -0
  349. package/src/opik/rest_api/serialization/resources/datasets/client/requests/DatasetIdentifier.ts +20 -0
  350. package/src/opik/rest_api/serialization/resources/datasets/client/requests/DatasetIdentifierPublic.ts +20 -0
  351. package/src/opik/rest_api/serialization/resources/datasets/client/requests/DatasetItemBatchWrite.ts +25 -0
  352. package/src/opik/rest_api/serialization/resources/datasets/client/requests/DatasetItemStreamRequest.ts +24 -0
  353. package/src/opik/rest_api/serialization/resources/datasets/client/requests/DatasetItemsDelete.ts +20 -0
  354. package/src/opik/rest_api/serialization/resources/datasets/client/requests/DatasetUpdate.ts +20 -0
  355. package/src/opik/rest_api/serialization/resources/datasets/client/requests/DatasetWrite.ts +22 -0
  356. package/src/opik/rest_api/serialization/resources/datasets/client/requests/index.ts +7 -0
  357. package/src/opik/rest_api/serialization/resources/datasets/index.ts +1 -0
  358. package/src/opik/rest_api/serialization/resources/experiments/client/findFeedbackScoreNames.ts +15 -0
  359. package/src/opik/rest_api/serialization/resources/experiments/client/index.ts +2 -0
  360. package/src/opik/rest_api/serialization/resources/experiments/client/requests/ExperimentItemStreamRequest.ts +24 -0
  361. package/src/opik/rest_api/serialization/resources/experiments/client/requests/ExperimentItemsBatch.ts +21 -0
  362. package/src/opik/rest_api/serialization/resources/experiments/client/requests/ExperimentItemsDelete.ts +20 -0
  363. package/src/opik/rest_api/serialization/resources/experiments/client/requests/ExperimentWrite.ts +28 -0
  364. package/src/opik/rest_api/serialization/resources/experiments/client/requests/ExperimentsDelete.ts +20 -0
  365. package/src/opik/rest_api/serialization/resources/experiments/client/requests/IdentifierPublic.ts +18 -0
  366. package/src/opik/rest_api/serialization/resources/experiments/client/requests/index.ts +6 -0
  367. package/src/opik/rest_api/serialization/resources/experiments/index.ts +1 -0
  368. package/src/opik/rest_api/serialization/resources/feedbackDefinitions/index.ts +1 -0
  369. package/src/opik/rest_api/serialization/resources/feedbackDefinitions/types/FindFeedbackDefinitionsRequestType.ts +16 -0
  370. package/src/opik/rest_api/serialization/resources/feedbackDefinitions/types/index.ts +1 -0
  371. package/src/opik/rest_api/serialization/resources/index.ts +20 -0
  372. package/src/opik/rest_api/serialization/resources/llmProviderKey/client/index.ts +1 -0
  373. package/src/opik/rest_api/serialization/resources/llmProviderKey/client/requests/ProviderApiKeyUpdate.ts +20 -0
  374. package/src/opik/rest_api/serialization/resources/llmProviderKey/client/requests/ProviderApiKeyWrite.ts +20 -0
  375. package/src/opik/rest_api/serialization/resources/llmProviderKey/client/requests/index.ts +2 -0
  376. package/src/opik/rest_api/serialization/resources/llmProviderKey/index.ts +1 -0
  377. package/src/opik/rest_api/serialization/resources/projects/client/index.ts +1 -0
  378. package/src/opik/rest_api/serialization/resources/projects/client/requests/ProjectMetricRequestPublic.ts +28 -0
  379. package/src/opik/rest_api/serialization/resources/projects/client/requests/ProjectRetrievePublic.ts +20 -0
  380. package/src/opik/rest_api/serialization/resources/projects/client/requests/ProjectUpdate.ts +20 -0
  381. package/src/opik/rest_api/serialization/resources/projects/client/requests/ProjectWrite.ts +20 -0
  382. package/src/opik/rest_api/serialization/resources/projects/client/requests/index.ts +4 -0
  383. package/src/opik/rest_api/serialization/resources/projects/index.ts +2 -0
  384. package/src/opik/rest_api/serialization/resources/projects/types/ProjectMetricRequestPublicInterval.ts +16 -0
  385. package/src/opik/rest_api/serialization/resources/projects/types/ProjectMetricRequestPublicMetricType.ts +16 -0
  386. package/src/opik/rest_api/serialization/resources/projects/types/index.ts +2 -0
  387. package/src/opik/rest_api/serialization/resources/prompts/client/index.ts +1 -0
  388. package/src/opik/rest_api/serialization/resources/prompts/client/requests/CreatePromptVersionDetail.ts +23 -0
  389. package/src/opik/rest_api/serialization/resources/prompts/client/requests/PromptUpdatable.ts +20 -0
  390. package/src/opik/rest_api/serialization/resources/prompts/client/requests/PromptVersionRetrieveDetail.ts +22 -0
  391. package/src/opik/rest_api/serialization/resources/prompts/client/requests/PromptWrite.ts +24 -0
  392. package/src/opik/rest_api/serialization/resources/prompts/client/requests/index.ts +4 -0
  393. package/src/opik/rest_api/serialization/resources/prompts/index.ts +1 -0
  394. package/src/opik/rest_api/serialization/resources/spans/client/findFeedbackScoreNames1.ts +13 -0
  395. package/src/opik/rest_api/serialization/resources/spans/client/index.ts +2 -0
  396. package/src/opik/rest_api/serialization/resources/spans/client/requests/SpanBatchWrite.ts +19 -0
  397. package/src/opik/rest_api/serialization/resources/spans/client/requests/SpanUpdate.ts +44 -0
  398. package/src/opik/rest_api/serialization/resources/spans/client/requests/index.ts +2 -0
  399. package/src/opik/rest_api/serialization/resources/spans/index.ts +2 -0
  400. package/src/opik/rest_api/serialization/resources/spans/types/FindFeedbackScoreNames1RequestType.ts +16 -0
  401. package/src/opik/rest_api/serialization/resources/spans/types/GetSpanStatsRequestType.ts +16 -0
  402. package/src/opik/rest_api/serialization/resources/spans/types/GetSpansByProjectRequestType.ts +16 -0
  403. package/src/opik/rest_api/serialization/resources/spans/types/index.ts +3 -0
  404. package/src/opik/rest_api/serialization/resources/traces/client/findFeedbackScoreNames2.ts +13 -0
  405. package/src/opik/rest_api/serialization/resources/traces/client/index.ts +2 -0
  406. package/src/opik/rest_api/serialization/resources/traces/client/requests/TraceBatchWrite.ts +19 -0
  407. package/src/opik/rest_api/serialization/resources/traces/client/requests/TraceUpdate.ts +34 -0
  408. package/src/opik/rest_api/serialization/resources/traces/client/requests/index.ts +2 -0
  409. package/src/opik/rest_api/serialization/resources/traces/index.ts +1 -0
  410. package/src/opik/rest_api/serialization/types/AssistantMessage.ts +33 -0
  411. package/src/opik/rest_api/serialization/types/AssistantMessageRole.ts +16 -0
  412. package/src/opik/rest_api/serialization/types/AuthDetailsHolder.ts +16 -0
  413. package/src/opik/rest_api/serialization/types/AvgValueStatPublic.ts +20 -0
  414. package/src/opik/rest_api/serialization/types/BatchDelete.ts +18 -0
  415. package/src/opik/rest_api/serialization/types/BiInformation.ts +22 -0
  416. package/src/opik/rest_api/serialization/types/BiInformationResponse.ts +21 -0
  417. package/src/opik/rest_api/serialization/types/CategoricalFeedbackDefinition.ts +29 -0
  418. package/src/opik/rest_api/serialization/types/CategoricalFeedbackDefinitionCreate.ts +21 -0
  419. package/src/opik/rest_api/serialization/types/CategoricalFeedbackDefinitionPublic.ts +29 -0
  420. package/src/opik/rest_api/serialization/types/CategoricalFeedbackDefinitionUpdate.ts +21 -0
  421. package/src/opik/rest_api/serialization/types/CategoricalFeedbackDetail.ts +20 -0
  422. package/src/opik/rest_api/serialization/types/CategoricalFeedbackDetailCreate.ts +20 -0
  423. package/src/opik/rest_api/serialization/types/CategoricalFeedbackDetailPublic.ts +20 -0
  424. package/src/opik/rest_api/serialization/types/CategoricalFeedbackDetailUpdate.ts +20 -0
  425. package/src/opik/rest_api/serialization/types/ChatCompletionChoice.ts +28 -0
  426. package/src/opik/rest_api/serialization/types/ChatCompletionResponse.ts +32 -0
  427. package/src/opik/rest_api/serialization/types/ChunkedOutputJsonNode.ts +23 -0
  428. package/src/opik/rest_api/serialization/types/ChunkedOutputJsonNodeType.ts +20 -0
  429. package/src/opik/rest_api/serialization/types/Column.ts +25 -0
  430. package/src/opik/rest_api/serialization/types/ColumnCompare.ts +25 -0
  431. package/src/opik/rest_api/serialization/types/ColumnCompareTypesItem.ts +16 -0
  432. package/src/opik/rest_api/serialization/types/ColumnPublic.ts +25 -0
  433. package/src/opik/rest_api/serialization/types/ColumnPublicTypesItem.ts +16 -0
  434. package/src/opik/rest_api/serialization/types/ColumnTypesItem.ts +14 -0
  435. package/src/opik/rest_api/serialization/types/CompletionTokensDetails.ts +20 -0
  436. package/src/opik/rest_api/serialization/types/CountValueStatPublic.ts +20 -0
  437. package/src/opik/rest_api/serialization/types/DataPointNumberPublic.ts +22 -0
  438. package/src/opik/rest_api/serialization/types/Dataset.ts +44 -0
  439. package/src/opik/rest_api/serialization/types/DatasetItem.ts +48 -0
  440. package/src/opik/rest_api/serialization/types/DatasetItemBatch.ts +25 -0
  441. package/src/opik/rest_api/serialization/types/DatasetItemCompare.ts +51 -0
  442. package/src/opik/rest_api/serialization/types/DatasetItemCompareSource.ts +16 -0
  443. package/src/opik/rest_api/serialization/types/DatasetItemPageCompare.ts +30 -0
  444. package/src/opik/rest_api/serialization/types/DatasetItemPagePublic.ts +30 -0
  445. package/src/opik/rest_api/serialization/types/DatasetItemPublic.ts +51 -0
  446. package/src/opik/rest_api/serialization/types/DatasetItemPublicSource.ts +16 -0
  447. package/src/opik/rest_api/serialization/types/DatasetItemSource.ts +16 -0
  448. package/src/opik/rest_api/serialization/types/DatasetItemWrite.ts +37 -0
  449. package/src/opik/rest_api/serialization/types/DatasetItemWriteSource.ts +16 -0
  450. package/src/opik/rest_api/serialization/types/DatasetPagePublic.ts +27 -0
  451. package/src/opik/rest_api/serialization/types/DatasetPublic.ts +44 -0
  452. package/src/opik/rest_api/serialization/types/DeleteFeedbackScore.ts +20 -0
  453. package/src/opik/rest_api/serialization/types/Delta.ts +26 -0
  454. package/src/opik/rest_api/serialization/types/DeltaRole.ts +14 -0
  455. package/src/opik/rest_api/serialization/types/ErrorInfo.ts +22 -0
  456. package/src/opik/rest_api/serialization/types/ErrorInfoPublic.ts +24 -0
  457. package/src/opik/rest_api/serialization/types/ErrorInfoWrite.ts +22 -0
  458. package/src/opik/rest_api/serialization/types/ErrorMessage.ts +22 -0
  459. package/src/opik/rest_api/serialization/types/ErrorMessageDetail.ts +24 -0
  460. package/src/opik/rest_api/serialization/types/ErrorMessagePublic.ts +20 -0
  461. package/src/opik/rest_api/serialization/types/Experiment.ts +46 -0
  462. package/src/opik/rest_api/serialization/types/ExperimentItem.ts +43 -0
  463. package/src/opik/rest_api/serialization/types/ExperimentItemCompare.ts +45 -0
  464. package/src/opik/rest_api/serialization/types/ExperimentItemPublic.ts +34 -0
  465. package/src/opik/rest_api/serialization/types/ExperimentPagePublic.ts +27 -0
  466. package/src/opik/rest_api/serialization/types/ExperimentPublic.ts +48 -0
  467. package/src/opik/rest_api/serialization/types/Feedback.ts +48 -0
  468. package/src/opik/rest_api/serialization/types/FeedbackCreate.ts +41 -0
  469. package/src/opik/rest_api/serialization/types/FeedbackDefinitionPagePublic.ts +27 -0
  470. package/src/opik/rest_api/serialization/types/FeedbackObjectPublic.ts +51 -0
  471. package/src/opik/rest_api/serialization/types/FeedbackPublic.ts +49 -0
  472. package/src/opik/rest_api/serialization/types/FeedbackScore.ts +35 -0
  473. package/src/opik/rest_api/serialization/types/FeedbackScoreAverage.ts +22 -0
  474. package/src/opik/rest_api/serialization/types/FeedbackScoreAveragePublic.ts +22 -0
  475. package/src/opik/rest_api/serialization/types/FeedbackScoreBatch.ts +21 -0
  476. package/src/opik/rest_api/serialization/types/FeedbackScoreBatchItem.ts +33 -0
  477. package/src/opik/rest_api/serialization/types/FeedbackScoreBatchItemSource.ts +16 -0
  478. package/src/opik/rest_api/serialization/types/FeedbackScoreCompare.ts +37 -0
  479. package/src/opik/rest_api/serialization/types/FeedbackScoreCompareSource.ts +16 -0
  480. package/src/opik/rest_api/serialization/types/FeedbackScorePublic.ts +37 -0
  481. package/src/opik/rest_api/serialization/types/FeedbackScorePublicSource.ts +16 -0
  482. package/src/opik/rest_api/serialization/types/FeedbackScoreSource.ts +16 -0
  483. package/src/opik/rest_api/serialization/types/FeedbackUpdate.ts +41 -0
  484. package/src/opik/rest_api/serialization/types/Function.ts +25 -0
  485. package/src/opik/rest_api/serialization/types/FunctionCall.ts +20 -0
  486. package/src/opik/rest_api/serialization/types/JsonNode.ts +14 -0
  487. package/src/opik/rest_api/serialization/types/JsonNodeCompare.ts +14 -0
  488. package/src/opik/rest_api/serialization/types/JsonNodePublic.ts +14 -0
  489. package/src/opik/rest_api/serialization/types/JsonNodeWrite.ts +14 -0
  490. package/src/opik/rest_api/serialization/types/JsonObjectSchema.ts +34 -0
  491. package/src/opik/rest_api/serialization/types/JsonSchema.ts +23 -0
  492. package/src/opik/rest_api/serialization/types/JsonSchemaElement.ts +20 -0
  493. package/src/opik/rest_api/serialization/types/Message.ts +16 -0
  494. package/src/opik/rest_api/serialization/types/NumericalFeedbackDefinition.ts +29 -0
  495. package/src/opik/rest_api/serialization/types/NumericalFeedbackDefinitionCreate.ts +21 -0
  496. package/src/opik/rest_api/serialization/types/NumericalFeedbackDefinitionPublic.ts +29 -0
  497. package/src/opik/rest_api/serialization/types/NumericalFeedbackDefinitionUpdate.ts +21 -0
  498. package/src/opik/rest_api/serialization/types/NumericalFeedbackDetail.ts +22 -0
  499. package/src/opik/rest_api/serialization/types/NumericalFeedbackDetailCreate.ts +22 -0
  500. package/src/opik/rest_api/serialization/types/NumericalFeedbackDetailPublic.ts +22 -0
  501. package/src/opik/rest_api/serialization/types/NumericalFeedbackDetailUpdate.ts +22 -0
  502. package/src/opik/rest_api/serialization/types/PageColumns.ts +19 -0
  503. package/src/opik/rest_api/serialization/types/PercentageValueStatPublic.ts +21 -0
  504. package/src/opik/rest_api/serialization/types/PercentageValuesPublic.ts +24 -0
  505. package/src/opik/rest_api/serialization/types/Project.ts +32 -0
  506. package/src/opik/rest_api/serialization/types/ProjectMetricResponsePublic.ts +29 -0
  507. package/src/opik/rest_api/serialization/types/ProjectMetricResponsePublicInterval.ts +16 -0
  508. package/src/opik/rest_api/serialization/types/ProjectMetricResponsePublicMetricType.ts +16 -0
  509. package/src/opik/rest_api/serialization/types/ProjectPagePublic.ts +29 -0
  510. package/src/opik/rest_api/serialization/types/ProjectPublic.ts +32 -0
  511. package/src/opik/rest_api/serialization/types/ProjectStatItemObjectPublic.ts +50 -0
  512. package/src/opik/rest_api/serialization/types/ProjectStatsPublic.ts +21 -0
  513. package/src/opik/rest_api/serialization/types/Prompt.ts +37 -0
  514. package/src/opik/rest_api/serialization/types/PromptDetail.ts +35 -0
  515. package/src/opik/rest_api/serialization/types/PromptPagePublic.ts +27 -0
  516. package/src/opik/rest_api/serialization/types/PromptPublic.ts +32 -0
  517. package/src/opik/rest_api/serialization/types/PromptVersion.ts +30 -0
  518. package/src/opik/rest_api/serialization/types/PromptVersionDetail.ts +32 -0
  519. package/src/opik/rest_api/serialization/types/PromptVersionLink.ts +24 -0
  520. package/src/opik/rest_api/serialization/types/PromptVersionLinkPublic.ts +24 -0
  521. package/src/opik/rest_api/serialization/types/PromptVersionLinkWrite.ts +20 -0
  522. package/src/opik/rest_api/serialization/types/PromptVersionPagePublic.ts +27 -0
  523. package/src/opik/rest_api/serialization/types/PromptVersionPublic.ts +30 -0
  524. package/src/opik/rest_api/serialization/types/ProviderApiKey.ts +30 -0
  525. package/src/opik/rest_api/serialization/types/ProviderApiKeyPublic.ts +30 -0
  526. package/src/opik/rest_api/serialization/types/ResponseFormat.ts +22 -0
  527. package/src/opik/rest_api/serialization/types/ResponseFormatType.ts +16 -0
  528. package/src/opik/rest_api/serialization/types/ResultsNumberPublic.ts +23 -0
  529. package/src/opik/rest_api/serialization/types/Span.ts +65 -0
  530. package/src/opik/rest_api/serialization/types/SpanBatch.ts +19 -0
  531. package/src/opik/rest_api/serialization/types/SpanPagePublic.ts +25 -0
  532. package/src/opik/rest_api/serialization/types/SpanPublic.ts +67 -0
  533. package/src/opik/rest_api/serialization/types/SpanPublicType.ts +14 -0
  534. package/src/opik/rest_api/serialization/types/SpanType.ts +15 -0
  535. package/src/opik/rest_api/serialization/types/SpanWrite.ts +51 -0
  536. package/src/opik/rest_api/serialization/types/SpanWriteType.ts +14 -0
  537. package/src/opik/rest_api/serialization/types/StreamOptions.ts +18 -0
  538. package/src/opik/rest_api/serialization/types/Tool.ts +20 -0
  539. package/src/opik/rest_api/serialization/types/ToolCall.ts +25 -0
  540. package/src/opik/rest_api/serialization/types/Trace.ts +54 -0
  541. package/src/opik/rest_api/serialization/types/TraceBatch.ts +19 -0
  542. package/src/opik/rest_api/serialization/types/TraceCountResponse.ts +24 -0
  543. package/src/opik/rest_api/serialization/types/TracePagePublic.ts +27 -0
  544. package/src/opik/rest_api/serialization/types/TracePublic.ts +56 -0
  545. package/src/opik/rest_api/serialization/types/TraceWrite.ts +38 -0
  546. package/src/opik/rest_api/serialization/types/Usage.ts +27 -0
  547. package/src/opik/rest_api/serialization/types/WorkspaceTraceCount.ts +22 -0
  548. package/src/opik/rest_api/serialization/types/index.ts +138 -0
  549. package/src/opik/tracer/Span.ts +34 -0
  550. package/src/opik/tracer/Trace.ts +61 -0
  551. package/tests/client.test.ts +25 -0
  552. package/tsconfig.json +25 -0
  553. package/tsup.config.ts +11 -0
  554. package/vitest.config.ts +13 -0
@@ -0,0 +1,130 @@
1
+ import { MaybeValid, Schema, SchemaType, ValidationError } from "../../Schema";
2
+ import { entries } from "../../utils/entries";
3
+ import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType";
4
+ import { isPlainObject } from "../../utils/isPlainObject";
5
+ import { maybeSkipValidation } from "../../utils/maybeSkipValidation";
6
+ import { getSchemaUtils } from "../schema-utils";
7
+ import { BaseRecordSchema, RecordSchema } from "./types";
8
+
9
+ export function record<RawKey extends string | number, RawValue, ParsedValue, ParsedKey extends string | number>(
10
+ keySchema: Schema<RawKey, ParsedKey>,
11
+ valueSchema: Schema<RawValue, ParsedValue>
12
+ ): RecordSchema<RawKey, RawValue, ParsedKey, ParsedValue> {
13
+ const baseSchema: BaseRecordSchema<RawKey, RawValue, ParsedKey, ParsedValue> = {
14
+ parse: (raw, opts) => {
15
+ return validateAndTransformRecord({
16
+ value: raw,
17
+ isKeyNumeric: keySchema.getType() === SchemaType.NUMBER,
18
+ transformKey: (key) =>
19
+ keySchema.parse(key, {
20
+ ...opts,
21
+ breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), `${key} (key)`],
22
+ }),
23
+ transformValue: (value, key) =>
24
+ valueSchema.parse(value, {
25
+ ...opts,
26
+ breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), `${key}`],
27
+ }),
28
+ breadcrumbsPrefix: opts?.breadcrumbsPrefix,
29
+ });
30
+ },
31
+ json: (parsed, opts) => {
32
+ return validateAndTransformRecord({
33
+ value: parsed,
34
+ isKeyNumeric: keySchema.getType() === SchemaType.NUMBER,
35
+ transformKey: (key) =>
36
+ keySchema.json(key, {
37
+ ...opts,
38
+ breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), `${key} (key)`],
39
+ }),
40
+ transformValue: (value, key) =>
41
+ valueSchema.json(value, {
42
+ ...opts,
43
+ breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), `${key}`],
44
+ }),
45
+ breadcrumbsPrefix: opts?.breadcrumbsPrefix,
46
+ });
47
+ },
48
+ getType: () => SchemaType.RECORD,
49
+ };
50
+
51
+ return {
52
+ ...maybeSkipValidation(baseSchema),
53
+ ...getSchemaUtils(baseSchema),
54
+ };
55
+ }
56
+
57
+ function validateAndTransformRecord<TransformedKey extends string | number, TransformedValue>({
58
+ value,
59
+ isKeyNumeric,
60
+ transformKey,
61
+ transformValue,
62
+ breadcrumbsPrefix = [],
63
+ }: {
64
+ value: unknown;
65
+ isKeyNumeric: boolean;
66
+ transformKey: (key: string | number) => MaybeValid<TransformedKey>;
67
+ transformValue: (value: unknown, key: string | number) => MaybeValid<TransformedValue>;
68
+ breadcrumbsPrefix: string[] | undefined;
69
+ }): MaybeValid<Record<TransformedKey, TransformedValue>> {
70
+ if (!isPlainObject(value)) {
71
+ return {
72
+ ok: false,
73
+ errors: [
74
+ {
75
+ path: breadcrumbsPrefix,
76
+ message: getErrorMessageForIncorrectType(value, "object"),
77
+ },
78
+ ],
79
+ };
80
+ }
81
+
82
+ return entries(value).reduce<MaybeValid<Record<TransformedKey, TransformedValue>>>(
83
+ (accPromise, [stringKey, value]) => {
84
+ // skip nullish keys
85
+ if (value == null) {
86
+ return accPromise;
87
+ }
88
+
89
+ const acc = accPromise;
90
+
91
+ let key: string | number = stringKey;
92
+ if (isKeyNumeric) {
93
+ const numberKey = stringKey.length > 0 ? Number(stringKey) : NaN;
94
+ if (!isNaN(numberKey)) {
95
+ key = numberKey;
96
+ }
97
+ }
98
+ const transformedKey = transformKey(key);
99
+
100
+ const transformedValue = transformValue(value, key);
101
+
102
+ if (acc.ok && transformedKey.ok && transformedValue.ok) {
103
+ return {
104
+ ok: true,
105
+ value: {
106
+ ...acc.value,
107
+ [transformedKey.value]: transformedValue.value,
108
+ },
109
+ };
110
+ }
111
+
112
+ const errors: ValidationError[] = [];
113
+ if (!acc.ok) {
114
+ errors.push(...acc.errors);
115
+ }
116
+ if (!transformedKey.ok) {
117
+ errors.push(...transformedKey.errors);
118
+ }
119
+ if (!transformedValue.ok) {
120
+ errors.push(...transformedValue.errors);
121
+ }
122
+
123
+ return {
124
+ ok: false,
125
+ errors,
126
+ };
127
+ },
128
+ { ok: true, value: {} as Record<TransformedKey, TransformedValue> }
129
+ );
130
+ }
@@ -0,0 +1,17 @@
1
+ import { BaseSchema } from "../../Schema";
2
+ import { SchemaUtils } from "../schema-utils";
3
+
4
+ export type RecordSchema<
5
+ RawKey extends string | number,
6
+ RawValue,
7
+ ParsedKey extends string | number,
8
+ ParsedValue
9
+ > = BaseRecordSchema<RawKey, RawValue, ParsedKey, ParsedValue> &
10
+ SchemaUtils<Record<RawKey, RawValue>, Record<ParsedKey, ParsedValue>>;
11
+
12
+ export type BaseRecordSchema<
13
+ RawKey extends string | number,
14
+ RawValue,
15
+ ParsedKey extends string | number,
16
+ ParsedValue
17
+ > = BaseSchema<Record<RawKey, RawValue>, Record<ParsedKey, ParsedValue>>;
@@ -0,0 +1,9 @@
1
+ import { ValidationError } from "../../Schema";
2
+ import { stringifyValidationError } from "./stringifyValidationErrors";
3
+
4
+ export class JsonError extends Error {
5
+ constructor(public readonly errors: ValidationError[]) {
6
+ super(errors.map(stringifyValidationError).join("; "));
7
+ Object.setPrototypeOf(this, JsonError.prototype);
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ import { ValidationError } from "../../Schema";
2
+ import { stringifyValidationError } from "./stringifyValidationErrors";
3
+
4
+ export class ParseError extends Error {
5
+ constructor(public readonly errors: ValidationError[]) {
6
+ super(errors.map(stringifyValidationError).join("; "));
7
+ Object.setPrototypeOf(this, ParseError.prototype);
8
+ }
9
+ }
@@ -0,0 +1,105 @@
1
+ import { BaseSchema, Schema, SchemaOptions, SchemaType } from "../../Schema";
2
+ import { JsonError } from "./JsonError";
3
+ import { ParseError } from "./ParseError";
4
+
5
+ export interface SchemaUtils<Raw, Parsed> {
6
+ optional: () => Schema<Raw | null | undefined, Parsed | undefined>;
7
+ transform: <Transformed>(transformer: SchemaTransformer<Parsed, Transformed>) => Schema<Raw, Transformed>;
8
+ parseOrThrow: (raw: unknown, opts?: SchemaOptions) => Parsed;
9
+ jsonOrThrow: (raw: unknown, opts?: SchemaOptions) => Raw;
10
+ }
11
+
12
+ export interface SchemaTransformer<Parsed, Transformed> {
13
+ transform: (parsed: Parsed) => Transformed;
14
+ untransform: (transformed: any) => Parsed;
15
+ }
16
+
17
+ export function getSchemaUtils<Raw, Parsed>(schema: BaseSchema<Raw, Parsed>): SchemaUtils<Raw, Parsed> {
18
+ return {
19
+ optional: () => optional(schema),
20
+ transform: (transformer) => transform(schema, transformer),
21
+ parseOrThrow: (raw, opts) => {
22
+ const parsed = schema.parse(raw, opts);
23
+ if (parsed.ok) {
24
+ return parsed.value;
25
+ }
26
+ throw new ParseError(parsed.errors);
27
+ },
28
+ jsonOrThrow: (parsed, opts) => {
29
+ const raw = schema.json(parsed, opts);
30
+ if (raw.ok) {
31
+ return raw.value;
32
+ }
33
+ throw new JsonError(raw.errors);
34
+ },
35
+ };
36
+ }
37
+
38
+ /**
39
+ * schema utils are defined in one file to resolve issues with circular imports
40
+ */
41
+
42
+ export function optional<Raw, Parsed>(
43
+ schema: BaseSchema<Raw, Parsed>
44
+ ): Schema<Raw | null | undefined, Parsed | undefined> {
45
+ const baseSchema: BaseSchema<Raw | null | undefined, Parsed | undefined> = {
46
+ parse: (raw, opts) => {
47
+ if (raw == null) {
48
+ return {
49
+ ok: true,
50
+ value: undefined,
51
+ };
52
+ }
53
+ return schema.parse(raw, opts);
54
+ },
55
+ json: (parsed, opts) => {
56
+ if (opts?.omitUndefined && parsed === undefined) {
57
+ return {
58
+ ok: true,
59
+ value: undefined,
60
+ };
61
+ }
62
+ if (parsed == null) {
63
+ return {
64
+ ok: true,
65
+ value: null,
66
+ };
67
+ }
68
+ return schema.json(parsed, opts);
69
+ },
70
+ getType: () => SchemaType.OPTIONAL,
71
+ };
72
+
73
+ return {
74
+ ...baseSchema,
75
+ ...getSchemaUtils(baseSchema),
76
+ };
77
+ }
78
+
79
+ export function transform<Raw, Parsed, Transformed>(
80
+ schema: BaseSchema<Raw, Parsed>,
81
+ transformer: SchemaTransformer<Parsed, Transformed>
82
+ ): Schema<Raw, Transformed> {
83
+ const baseSchema: BaseSchema<Raw, Transformed> = {
84
+ parse: (raw, opts) => {
85
+ const parsed = schema.parse(raw, opts);
86
+ if (!parsed.ok) {
87
+ return parsed;
88
+ }
89
+ return {
90
+ ok: true,
91
+ value: transformer.transform(parsed.value),
92
+ };
93
+ },
94
+ json: (transformed, opts) => {
95
+ const parsed = transformer.untransform(transformed);
96
+ return schema.json(parsed, opts);
97
+ },
98
+ getType: () => schema.getType(),
99
+ };
100
+
101
+ return {
102
+ ...baseSchema,
103
+ ...getSchemaUtils(baseSchema),
104
+ };
105
+ }
@@ -0,0 +1,4 @@
1
+ export { getSchemaUtils, optional, transform } from "./getSchemaUtils";
2
+ export type { SchemaUtils } from "./getSchemaUtils";
3
+ export { JsonError } from "./JsonError";
4
+ export { ParseError } from "./ParseError";
@@ -0,0 +1,8 @@
1
+ import { ValidationError } from "../../Schema";
2
+
3
+ export function stringifyValidationError(error: ValidationError): string {
4
+ if (error.path.length === 0) {
5
+ return error.message;
6
+ }
7
+ return `${error.path.join(" -> ")}: ${error.message}`;
8
+ }
@@ -0,0 +1 @@
1
+ export { set } from "./set";
@@ -0,0 +1,43 @@
1
+ import { BaseSchema, Schema, SchemaType } from "../../Schema";
2
+ import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType";
3
+ import { maybeSkipValidation } from "../../utils/maybeSkipValidation";
4
+ import { list } from "../list";
5
+ import { getSchemaUtils } from "../schema-utils";
6
+
7
+ export function set<Raw, Parsed>(schema: Schema<Raw, Parsed>): Schema<Raw[], Set<Parsed>> {
8
+ const listSchema = list(schema);
9
+ const baseSchema: BaseSchema<Raw[], Set<Parsed>> = {
10
+ parse: (raw, opts) => {
11
+ const parsedList = listSchema.parse(raw, opts);
12
+ if (parsedList.ok) {
13
+ return {
14
+ ok: true,
15
+ value: new Set(parsedList.value),
16
+ };
17
+ } else {
18
+ return parsedList;
19
+ }
20
+ },
21
+ json: (parsed, opts) => {
22
+ if (!(parsed instanceof Set)) {
23
+ return {
24
+ ok: false,
25
+ errors: [
26
+ {
27
+ path: opts?.breadcrumbsPrefix ?? [],
28
+ message: getErrorMessageForIncorrectType(parsed, "Set"),
29
+ },
30
+ ],
31
+ };
32
+ }
33
+ const jsonList = listSchema.json([...parsed], opts);
34
+ return jsonList;
35
+ },
36
+ getType: () => SchemaType.SET,
37
+ };
38
+
39
+ return {
40
+ ...maybeSkipValidation(baseSchema),
41
+ ...getSchemaUtils(baseSchema),
42
+ };
43
+ }
@@ -0,0 +1,6 @@
1
+ export type {
2
+ inferParsedUnidiscriminatedUnionSchema,
3
+ inferRawUnidiscriminatedUnionSchema,
4
+ UndiscriminatedUnionSchema,
5
+ } from "./types";
6
+ export { undiscriminatedUnion } from "./undiscriminatedUnion";
@@ -0,0 +1,10 @@
1
+ import { inferParsed, inferRaw, Schema } from "../../Schema";
2
+
3
+ export type UndiscriminatedUnionSchema<Schemas extends [...Schema[]]> = Schema<
4
+ inferRawUnidiscriminatedUnionSchema<Schemas>,
5
+ inferParsedUnidiscriminatedUnionSchema<Schemas>
6
+ >;
7
+
8
+ export type inferRawUnidiscriminatedUnionSchema<Schemas extends [...Schema[]]> = inferRaw<Schemas[number]>;
9
+
10
+ export type inferParsedUnidiscriminatedUnionSchema<Schemas extends [...Schema[]]> = inferParsed<Schemas[number]>;
@@ -0,0 +1,60 @@
1
+ import { BaseSchema, MaybeValid, Schema, SchemaOptions, SchemaType, ValidationError } from "../../Schema";
2
+ import { maybeSkipValidation } from "../../utils/maybeSkipValidation";
3
+ import { getSchemaUtils } from "../schema-utils";
4
+ import { inferParsedUnidiscriminatedUnionSchema, inferRawUnidiscriminatedUnionSchema } from "./types";
5
+
6
+ export function undiscriminatedUnion<Schemas extends [Schema<any, any>, ...Schema<any, any>[]]>(
7
+ schemas: Schemas
8
+ ): Schema<inferRawUnidiscriminatedUnionSchema<Schemas>, inferParsedUnidiscriminatedUnionSchema<Schemas>> {
9
+ const baseSchema: BaseSchema<
10
+ inferRawUnidiscriminatedUnionSchema<Schemas>,
11
+ inferParsedUnidiscriminatedUnionSchema<Schemas>
12
+ > = {
13
+ parse: (raw, opts) => {
14
+ return validateAndTransformUndiscriminatedUnion<inferParsedUnidiscriminatedUnionSchema<Schemas>>(
15
+ (schema, opts) => schema.parse(raw, opts),
16
+ schemas,
17
+ opts
18
+ );
19
+ },
20
+ json: (parsed, opts) => {
21
+ return validateAndTransformUndiscriminatedUnion<inferRawUnidiscriminatedUnionSchema<Schemas>>(
22
+ (schema, opts) => schema.json(parsed, opts),
23
+ schemas,
24
+ opts
25
+ );
26
+ },
27
+ getType: () => SchemaType.UNDISCRIMINATED_UNION,
28
+ };
29
+
30
+ return {
31
+ ...maybeSkipValidation(baseSchema),
32
+ ...getSchemaUtils(baseSchema),
33
+ };
34
+ }
35
+
36
+ function validateAndTransformUndiscriminatedUnion<Transformed>(
37
+ transform: (schema: Schema<any, any>, opts: SchemaOptions) => MaybeValid<Transformed>,
38
+ schemas: Schema<any, any>[],
39
+ opts: SchemaOptions | undefined
40
+ ): MaybeValid<Transformed> {
41
+ const errors: ValidationError[] = [];
42
+ for (const [index, schema] of schemas.entries()) {
43
+ const transformed = transform(schema, { ...opts, skipValidation: false });
44
+ if (transformed.ok) {
45
+ return transformed;
46
+ } else {
47
+ for (const error of transformed.errors) {
48
+ errors.push({
49
+ path: error.path,
50
+ message: `[Variant ${index}] ${error.message}`,
51
+ });
52
+ }
53
+ }
54
+ }
55
+
56
+ return {
57
+ ok: false,
58
+ errors,
59
+ };
60
+ }
@@ -0,0 +1,14 @@
1
+ export function discriminant<RawDiscriminant extends string, ParsedDiscriminant extends string>(
2
+ parsedDiscriminant: ParsedDiscriminant,
3
+ rawDiscriminant: RawDiscriminant
4
+ ): Discriminant<RawDiscriminant, ParsedDiscriminant> {
5
+ return {
6
+ parsedDiscriminant,
7
+ rawDiscriminant,
8
+ };
9
+ }
10
+
11
+ export interface Discriminant<RawDiscriminant extends string, ParsedDiscriminant extends string> {
12
+ parsedDiscriminant: ParsedDiscriminant;
13
+ rawDiscriminant: RawDiscriminant;
14
+ }
@@ -0,0 +1,10 @@
1
+ export { discriminant } from "./discriminant";
2
+ export type { Discriminant } from "./discriminant";
3
+ export type {
4
+ inferParsedDiscriminant,
5
+ inferParsedUnion,
6
+ inferRawDiscriminant,
7
+ inferRawUnion,
8
+ UnionSubtypes,
9
+ } from "./types";
10
+ export { union } from "./union";
@@ -0,0 +1,26 @@
1
+ import { inferParsedObject, inferRawObject, ObjectSchema } from "../object";
2
+ import { Discriminant } from "./discriminant";
3
+
4
+ export type UnionSubtypes<DiscriminantValues extends string | number | symbol> = {
5
+ [K in DiscriminantValues]: ObjectSchema<any, any>;
6
+ };
7
+
8
+ export type inferRawUnion<D extends string | Discriminant<any, any>, U extends UnionSubtypes<keyof U>> = {
9
+ [K in keyof U]: Record<inferRawDiscriminant<D>, K> & inferRawObject<U[K]>;
10
+ }[keyof U];
11
+
12
+ export type inferParsedUnion<D extends string | Discriminant<any, any>, U extends UnionSubtypes<keyof U>> = {
13
+ [K in keyof U]: Record<inferParsedDiscriminant<D>, K> & inferParsedObject<U[K]>;
14
+ }[keyof U];
15
+
16
+ export type inferRawDiscriminant<D extends string | Discriminant<any, any>> = D extends string
17
+ ? D
18
+ : D extends Discriminant<infer Raw, any>
19
+ ? Raw
20
+ : never;
21
+
22
+ export type inferParsedDiscriminant<D extends string | Discriminant<any, any>> = D extends string
23
+ ? D
24
+ : D extends Discriminant<any, infer Parsed>
25
+ ? Parsed
26
+ : never;
@@ -0,0 +1,170 @@
1
+ import { BaseSchema, MaybeValid, SchemaType } from "../../Schema";
2
+ import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType";
3
+ import { isPlainObject } from "../../utils/isPlainObject";
4
+ import { keys } from "../../utils/keys";
5
+ import { maybeSkipValidation } from "../../utils/maybeSkipValidation";
6
+ import { enum_ } from "../enum";
7
+ import { ObjectSchema } from "../object";
8
+ import { getObjectLikeUtils, ObjectLikeSchema } from "../object-like";
9
+ import { getSchemaUtils } from "../schema-utils";
10
+ import { Discriminant } from "./discriminant";
11
+ import { inferParsedDiscriminant, inferParsedUnion, inferRawDiscriminant, inferRawUnion, UnionSubtypes } from "./types";
12
+
13
+ export function union<D extends string | Discriminant<any, any>, U extends UnionSubtypes<any>>(
14
+ discriminant: D,
15
+ union: U
16
+ ): ObjectLikeSchema<inferRawUnion<D, U>, inferParsedUnion<D, U>> {
17
+ const rawDiscriminant =
18
+ typeof discriminant === "string" ? discriminant : (discriminant.rawDiscriminant as inferRawDiscriminant<D>);
19
+ const parsedDiscriminant =
20
+ typeof discriminant === "string"
21
+ ? discriminant
22
+ : (discriminant.parsedDiscriminant as inferParsedDiscriminant<D>);
23
+
24
+ const discriminantValueSchema = enum_(keys(union) as string[]);
25
+
26
+ const baseSchema: BaseSchema<inferRawUnion<D, U>, inferParsedUnion<D, U>> = {
27
+ parse: (raw, opts) => {
28
+ return transformAndValidateUnion({
29
+ value: raw,
30
+ discriminant: rawDiscriminant,
31
+ transformedDiscriminant: parsedDiscriminant,
32
+ transformDiscriminantValue: (discriminantValue) =>
33
+ discriminantValueSchema.parse(discriminantValue, {
34
+ allowUnrecognizedEnumValues: opts?.allowUnrecognizedUnionMembers,
35
+ breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), rawDiscriminant],
36
+ }),
37
+ getAdditionalPropertiesSchema: (discriminantValue) => union[discriminantValue],
38
+ allowUnrecognizedUnionMembers: opts?.allowUnrecognizedUnionMembers,
39
+ transformAdditionalProperties: (additionalProperties, additionalPropertiesSchema) =>
40
+ additionalPropertiesSchema.parse(additionalProperties, opts),
41
+ breadcrumbsPrefix: opts?.breadcrumbsPrefix,
42
+ });
43
+ },
44
+ json: (parsed, opts) => {
45
+ return transformAndValidateUnion({
46
+ value: parsed,
47
+ discriminant: parsedDiscriminant,
48
+ transformedDiscriminant: rawDiscriminant,
49
+ transformDiscriminantValue: (discriminantValue) =>
50
+ discriminantValueSchema.json(discriminantValue, {
51
+ allowUnrecognizedEnumValues: opts?.allowUnrecognizedUnionMembers,
52
+ breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), parsedDiscriminant],
53
+ }),
54
+ getAdditionalPropertiesSchema: (discriminantValue) => union[discriminantValue],
55
+ allowUnrecognizedUnionMembers: opts?.allowUnrecognizedUnionMembers,
56
+ transformAdditionalProperties: (additionalProperties, additionalPropertiesSchema) =>
57
+ additionalPropertiesSchema.json(additionalProperties, opts),
58
+ breadcrumbsPrefix: opts?.breadcrumbsPrefix,
59
+ });
60
+ },
61
+ getType: () => SchemaType.UNION,
62
+ };
63
+
64
+ return {
65
+ ...maybeSkipValidation(baseSchema),
66
+ ...getSchemaUtils(baseSchema),
67
+ ...getObjectLikeUtils(baseSchema),
68
+ };
69
+ }
70
+
71
+ function transformAndValidateUnion<
72
+ TransformedDiscriminant extends string,
73
+ TransformedDiscriminantValue extends string,
74
+ TransformedAdditionalProperties
75
+ >({
76
+ value,
77
+ discriminant,
78
+ transformedDiscriminant,
79
+ transformDiscriminantValue,
80
+ getAdditionalPropertiesSchema,
81
+ allowUnrecognizedUnionMembers = false,
82
+ transformAdditionalProperties,
83
+ breadcrumbsPrefix = [],
84
+ }: {
85
+ value: unknown;
86
+ discriminant: string;
87
+ transformedDiscriminant: TransformedDiscriminant;
88
+ transformDiscriminantValue: (discriminantValue: unknown) => MaybeValid<TransformedDiscriminantValue>;
89
+ getAdditionalPropertiesSchema: (discriminantValue: string) => ObjectSchema<any, any> | undefined;
90
+ allowUnrecognizedUnionMembers: boolean | undefined;
91
+ transformAdditionalProperties: (
92
+ additionalProperties: unknown,
93
+ additionalPropertiesSchema: ObjectSchema<any, any>
94
+ ) => MaybeValid<TransformedAdditionalProperties>;
95
+ breadcrumbsPrefix: string[] | undefined;
96
+ }): MaybeValid<Record<TransformedDiscriminant, TransformedDiscriminantValue> & TransformedAdditionalProperties> {
97
+ if (!isPlainObject(value)) {
98
+ return {
99
+ ok: false,
100
+ errors: [
101
+ {
102
+ path: breadcrumbsPrefix,
103
+ message: getErrorMessageForIncorrectType(value, "object"),
104
+ },
105
+ ],
106
+ };
107
+ }
108
+
109
+ const { [discriminant]: discriminantValue, ...additionalProperties } = value;
110
+
111
+ if (discriminantValue == null) {
112
+ return {
113
+ ok: false,
114
+ errors: [
115
+ {
116
+ path: breadcrumbsPrefix,
117
+ message: `Missing discriminant ("${discriminant}")`,
118
+ },
119
+ ],
120
+ };
121
+ }
122
+
123
+ const transformedDiscriminantValue = transformDiscriminantValue(discriminantValue);
124
+ if (!transformedDiscriminantValue.ok) {
125
+ return {
126
+ ok: false,
127
+ errors: transformedDiscriminantValue.errors,
128
+ };
129
+ }
130
+
131
+ const additionalPropertiesSchema = getAdditionalPropertiesSchema(transformedDiscriminantValue.value);
132
+
133
+ if (additionalPropertiesSchema == null) {
134
+ if (allowUnrecognizedUnionMembers) {
135
+ return {
136
+ ok: true,
137
+ value: {
138
+ [transformedDiscriminant]: transformedDiscriminantValue.value,
139
+ ...additionalProperties,
140
+ } as Record<TransformedDiscriminant, TransformedDiscriminantValue> & TransformedAdditionalProperties,
141
+ };
142
+ } else {
143
+ return {
144
+ ok: false,
145
+ errors: [
146
+ {
147
+ path: [...breadcrumbsPrefix, discriminant],
148
+ message: "Unexpected discriminant value",
149
+ },
150
+ ],
151
+ };
152
+ }
153
+ }
154
+
155
+ const transformedAdditionalProperties = transformAdditionalProperties(
156
+ additionalProperties,
157
+ additionalPropertiesSchema
158
+ );
159
+ if (!transformedAdditionalProperties.ok) {
160
+ return transformedAdditionalProperties;
161
+ }
162
+
163
+ return {
164
+ ok: true,
165
+ value: {
166
+ [transformedDiscriminant]: discriminantValue,
167
+ ...transformedAdditionalProperties.value,
168
+ } as Record<TransformedDiscriminant, TransformedDiscriminantValue> & TransformedAdditionalProperties,
169
+ };
170
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./builders";
2
+ export type { inferParsed, inferRaw, Schema, SchemaOptions } from "./Schema";
@@ -0,0 +1 @@
1
+ export type MaybePromise<T> = T | Promise<T>;
@@ -0,0 +1,15 @@
1
+ export type addQuestionMarksToNullableProperties<T> = {
2
+ [K in OptionalKeys<T>]?: T[K];
3
+ } & Pick<T, RequiredKeys<T>>;
4
+
5
+ export type OptionalKeys<T> = {
6
+ [K in keyof T]-?: undefined extends T[K]
7
+ ? K
8
+ : null extends T[K]
9
+ ? K
10
+ : 1 extends (any extends T[K] ? 0 : 1)
11
+ ? never
12
+ : K;
13
+ }[keyof T];
14
+
15
+ export type RequiredKeys<T> = Exclude<keyof T, OptionalKeys<T>>;