@hydradb/sdk 2.0.1 → 2.1.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 (363) hide show
  1. package/README.md +493 -554
  2. package/dist/Client.d.ts +33 -8
  3. package/dist/Client.js +124 -18
  4. package/dist/api/client/requests/ListProvidersRequest.d.ts +10 -0
  5. package/dist/api/client/requests/SearchQueryRequest.d.ts +55 -15
  6. package/dist/api/client/requests/index.d.ts +1 -0
  7. package/dist/api/errors/BadGatewayError.d.ts +6 -0
  8. package/dist/api/errors/{TooManyRequestsError.js → BadGatewayError.js} +5 -5
  9. package/dist/api/errors/{TooManyRequestsError.d.ts → ContentTooLargeError.d.ts} +1 -1
  10. package/dist/api/errors/ContentTooLargeError.js +54 -0
  11. package/dist/api/errors/NotFoundError.d.ts +1 -2
  12. package/dist/api/errors/ServiceUnavailableError.d.ts +6 -0
  13. package/dist/api/errors/ServiceUnavailableError.js +54 -0
  14. package/dist/api/errors/index.d.ts +3 -1
  15. package/dist/api/errors/index.js +3 -1
  16. package/dist/api/resources/connectors/client/Client.d.ts +240 -0
  17. package/dist/api/resources/connectors/client/Client.js +1034 -0
  18. package/dist/api/resources/connectors/client/requests/DeleteConnectorsRequest.d.ts +10 -0
  19. package/dist/api/resources/connectors/client/requests/DeleteResourceConnectorsRequest.d.ts +13 -0
  20. package/dist/api/resources/connectors/client/requests/DiscoverConnectorsRequest.d.ts +10 -0
  21. package/dist/api/resources/connectors/client/requests/GetConnectorsRequest.d.ts +10 -0
  22. package/dist/api/resources/connectors/client/requests/HandlerConfigureReq.d.ts +34 -0
  23. package/dist/api/resources/connectors/client/requests/HandlerConnectorCreateReq.d.ts +41 -0
  24. package/dist/api/resources/connectors/client/requests/HandlerDiscoverPreviewReq.d.ts +17 -0
  25. package/dist/api/resources/connectors/client/requests/HandlerResourceCreateReq.d.ts +34 -0
  26. package/dist/api/resources/connectors/client/requests/ListConnectorsRequest.d.ts +10 -0
  27. package/dist/api/resources/connectors/client/requests/ListResourcesConnectorsRequest.d.ts +10 -0
  28. package/dist/api/resources/connectors/client/requests/PatchConnectorsIdCredentialsRequest.d.ts +14 -0
  29. package/dist/api/resources/connectors/client/requests/SyncConnectorsRequest.d.ts +10 -0
  30. package/dist/api/resources/connectors/client/requests/index.d.ts +12 -0
  31. package/dist/api/resources/connectors/exports.d.ts +2 -0
  32. package/dist/api/resources/{embeddings → connectors}/exports.js +2 -2
  33. package/dist/api/resources/context/client/Client.d.ts +33 -6
  34. package/dist/api/resources/context/client/Client.js +134 -19
  35. package/dist/api/resources/context/client/requests/HandlerContextMetadataUpdateRequest.d.ts +30 -0
  36. package/dist/api/resources/context/client/requests/IngestContextRequest.d.ts +6 -3
  37. package/dist/api/resources/context/client/requests/InspectContextRequest.d.ts +12 -5
  38. package/dist/api/resources/context/client/requests/ListV2ListContentRequest.d.ts +16 -1
  39. package/dist/api/resources/context/client/requests/RelationsContextRequest.d.ts +14 -6
  40. package/dist/api/resources/context/client/requests/SourcesV2SourceDeleteRequest.d.ts +14 -1
  41. package/dist/api/resources/context/client/requests/StatusContextRequest.d.ts +10 -3
  42. package/dist/api/resources/context/client/requests/index.d.ts +1 -0
  43. package/dist/api/resources/context/index.d.ts +1 -0
  44. package/dist/api/resources/context/index.js +1 -0
  45. package/dist/api/resources/context/types/IngestContextRequestType.d.ts +5 -0
  46. package/dist/api/resources/context/types/IngestContextRequestType.js +8 -0
  47. package/dist/api/resources/context/types/ListV2ListContentRequestType.d.ts +6 -0
  48. package/dist/api/resources/context/types/ListV2ListContentRequestType.js +9 -0
  49. package/dist/api/resources/context/types/RelationsContextRequestType.d.ts +5 -0
  50. package/dist/api/resources/context/types/RelationsContextRequestType.js +8 -0
  51. package/dist/api/resources/context/types/SourcesV2SourceDeleteRequestType.d.ts +6 -0
  52. package/dist/api/resources/context/types/SourcesV2SourceDeleteRequestType.js +9 -0
  53. package/dist/api/resources/context/types/index.d.ts +4 -0
  54. package/dist/api/resources/context/types/index.js +20 -0
  55. package/dist/api/resources/databases/client/Client.d.ts +127 -0
  56. package/dist/api/resources/{tenants → databases}/client/Client.js +146 -78
  57. package/dist/api/resources/databases/client/requests/CollectionsDatabasesRequest.d.ts +10 -0
  58. package/dist/api/resources/databases/client/requests/DeleteDatabasesRequest.d.ts +10 -0
  59. package/dist/api/resources/databases/client/requests/StatsDatabasesRequest.d.ts +10 -0
  60. package/dist/api/resources/databases/client/requests/StatusDatabasesRequest.d.ts +10 -0
  61. package/dist/api/resources/databases/client/requests/TenantsTenantCreateRequest.d.ts +23 -0
  62. package/dist/api/resources/databases/client/requests/TenantsTenantMetadataSchemaUpdateRequest.d.ts +13 -0
  63. package/dist/api/resources/databases/client/requests/TenantsTenantMetadataSchemaUpdateRequest.js +3 -0
  64. package/dist/api/resources/databases/client/requests/index.d.ts +6 -0
  65. package/dist/api/resources/databases/exports.d.ts +2 -0
  66. package/dist/api/resources/{tenants → databases}/exports.js +2 -2
  67. package/dist/api/resources/index.d.ts +5 -4
  68. package/dist/api/resources/index.js +6 -5
  69. package/dist/api/resources/webhooks/client/Client.d.ts +15 -3
  70. package/dist/api/resources/webhooks/client/Client.js +19 -31
  71. package/dist/api/resources/webhooks/client/requests/GetDeliveryWebhooksRequest.d.ts +1 -1
  72. package/dist/api/resources/webhooks/client/requests/RetryDeliveryWebhooksRequest.d.ts +1 -1
  73. package/dist/api/resources/webhooks/client/requests/WebhooksWebhookRegisterRequest.d.ts +3 -0
  74. package/dist/api/types/ConnectorsConnector.d.ts +58 -0
  75. package/dist/api/types/ConnectorsConnector.js +3 -0
  76. package/dist/api/types/ConnectorsResource.d.ts +71 -0
  77. package/dist/api/types/ConnectorsResource.js +3 -0
  78. package/dist/api/types/DashboardPaginationMeta.d.ts +6 -0
  79. package/dist/api/types/FetchV2SourceFetchResponse.d.ts +10 -0
  80. package/dist/api/types/GithubComHydradbHydradbApplicationInternalServiceMetadataEditResult.d.ts +26 -0
  81. package/dist/api/types/GithubComHydradbHydradbApplicationInternalServiceMetadataEditResult.js +3 -0
  82. package/dist/api/types/GraphEntity.d.ts +12 -0
  83. package/dist/api/types/GraphGraphRelationsResponse.d.ts +4 -0
  84. package/dist/api/types/GraphRelationEvidence.d.ts +6 -0
  85. package/dist/api/types/GraphTripletWithEvidence.d.ts +2 -0
  86. package/dist/api/types/HandlerApiError.d.ts +2 -0
  87. package/dist/api/types/HandlerDeprecationNotice.d.ts +12 -0
  88. package/dist/api/types/HandlerDeprecationNotice.js +3 -0
  89. package/dist/api/types/HandlerEnvelopeFetchV2SourceFetchResponse.d.ts +2 -0
  90. package/dist/api/types/HandlerEnvelopeGithubComHydradbHydradbApplicationInternalServiceMetadataEditResult.d.ts +9 -0
  91. package/dist/api/types/HandlerEnvelopeGithubComHydradbHydradbApplicationInternalServiceMetadataEditResult.js +3 -0
  92. package/dist/api/types/HandlerEnvelopeGraphGraphRelationsResponse.d.ts +2 -0
  93. package/dist/api/types/HandlerEnvelopeIngestionV2BatchProcessingStatus.d.ts +2 -0
  94. package/dist/api/types/HandlerEnvelopeIngestionV2SourceUploadResponse.d.ts +2 -0
  95. package/dist/api/types/HandlerEnvelopeListV2SourceListResponse.d.ts +2 -0
  96. package/dist/api/types/HandlerEnvelopeSearchV2RetrievalResult.d.ts +2 -0
  97. package/dist/api/types/HandlerEnvelopeSourcesMemoryDeleteResponse.d.ts +9 -0
  98. package/dist/api/types/HandlerEnvelopeSourcesMemoryDeleteResponse.js +3 -0
  99. package/dist/api/types/HandlerEnvelopeTenantsInfraStatusResponseV2.d.ts +2 -0
  100. package/dist/api/types/HandlerEnvelopeTenantsSubTenantIdsResponse.d.ts +2 -0
  101. package/dist/api/types/HandlerEnvelopeTenantsTenantCreateAcceptedResponse.d.ts +2 -0
  102. package/dist/api/types/HandlerEnvelopeTenantsTenantDeleteResponse.d.ts +2 -0
  103. package/dist/api/types/HandlerEnvelopeTenantsTenantIdsResponse.d.ts +2 -0
  104. package/dist/api/types/HandlerEnvelopeTenantsTenantStatsResponse.d.ts +2 -0
  105. package/dist/api/types/HandlerEnvelopeWebhooksDeliveryItem.d.ts +2 -0
  106. package/dist/api/types/HandlerEnvelopeWebhooksDeliveryListResponse.d.ts +2 -0
  107. package/dist/api/types/HandlerEnvelopeWebhooksRetryResponse.d.ts +2 -0
  108. package/dist/api/types/HandlerEnvelopeWebhooksWebhookDeleteResponse.d.ts +2 -0
  109. package/dist/api/types/HandlerEnvelopeWebhooksWebhookGetResponse.d.ts +2 -0
  110. package/dist/api/types/HandlerEnvelopeWebhooksWebhookRegisterResponse.d.ts +2 -0
  111. package/dist/api/types/HandlerEnvelopeWebhooksWebhookTestResponse.d.ts +2 -0
  112. package/dist/api/types/HandlerErrorDetail.d.ts +9 -0
  113. package/dist/api/types/HandlerErrorResponse.d.ts +1 -0
  114. package/dist/api/types/HandlerMetadataSchemaUpdateResponse.d.ts +7 -0
  115. package/dist/api/types/HandlerMetadataSchemaUpdateResponse.js +3 -0
  116. package/dist/api/types/HandlerResourceMapping.d.ts +46 -0
  117. package/dist/api/types/HandlerResourceMapping.js +3 -0
  118. package/dist/api/types/HandlerResponseMeta.d.ts +19 -0
  119. package/dist/api/types/IngestionV2BatchProcessingStatus.d.ts +1 -0
  120. package/dist/api/types/IngestionV2ProcessingStatus.d.ts +6 -0
  121. package/dist/api/types/IngestionV2SourceUploadResponse.d.ts +5 -0
  122. package/dist/api/types/IngestionV2SourceUploadResultItem.d.ts +7 -0
  123. package/dist/api/types/ListContentFilter.d.ts +8 -2
  124. package/dist/api/types/ListSourceListResponse.d.ts +4 -0
  125. package/dist/api/types/SearchGraphContext.d.ts +9 -0
  126. package/dist/api/types/SearchMetadataFilters.d.ts +4 -0
  127. package/dist/api/types/SearchMetadataFilters.js +3 -0
  128. package/dist/api/types/SearchPathTriplet.d.ts +3 -0
  129. package/dist/api/types/SearchQueryRequestCollections.d.ts +4 -0
  130. package/dist/api/types/SearchQueryRequestCollections.js +3 -0
  131. package/dist/api/types/SearchQueryRequestSubTenantIds.d.ts +4 -0
  132. package/dist/api/types/SearchQueryRequestSubTenantIds.js +3 -0
  133. package/dist/api/types/SearchRecallMode.d.ts +1 -0
  134. package/dist/api/types/SearchRecallMode.js +1 -0
  135. package/dist/api/types/SearchScoredPathResponse.d.ts +5 -0
  136. package/dist/api/types/SearchSourceInfo.d.ts +11 -0
  137. package/dist/api/types/SearchV2Chunk.d.ts +13 -0
  138. package/dist/api/types/SearchV2RetrievalResult.d.ts +3 -0
  139. package/dist/api/types/SourcesMemoryDeleteResponse.d.ts +13 -0
  140. package/dist/api/types/SourcesMemoryDeleteResponse.js +3 -0
  141. package/dist/api/types/SourcesSourceDeleteResultItem.d.ts +3 -0
  142. package/dist/api/types/TenantsCollectionStats.d.ts +2 -0
  143. package/dist/api/types/TenantsCustomPropertyDefinition.d.ts +7 -0
  144. package/dist/api/types/TenantsFailedTenant.d.ts +3 -0
  145. package/dist/api/types/TenantsInfraStatusResponseV2.d.ts +4 -0
  146. package/dist/api/types/TenantsInfraV2.d.ts +2 -0
  147. package/dist/api/types/TenantsSubTenantIdsResponse.d.ts +4 -0
  148. package/dist/api/types/TenantsTenantCreateAcceptedResponse.d.ts +4 -0
  149. package/dist/api/types/TenantsTenantDeleteResponse.d.ts +4 -0
  150. package/dist/api/types/TenantsTenantIdsResponse.d.ts +7 -0
  151. package/dist/api/types/TenantsTenantStatsResponse.d.ts +3 -0
  152. package/dist/api/types/TenantsVectorstoreStatusV2.d.ts +2 -0
  153. package/dist/api/types/WebhooksDeliveryItem.d.ts +10 -0
  154. package/dist/api/types/WebhooksDeliveryListResponse.d.ts +3 -0
  155. package/dist/api/types/WebhooksRetryResponse.d.ts +3 -0
  156. package/dist/api/types/WebhooksWebhookDeleteResponse.d.ts +2 -0
  157. package/dist/api/types/WebhooksWebhookGetResponse.d.ts +4 -0
  158. package/dist/api/types/WebhooksWebhookRegisterResponse.d.ts +5 -0
  159. package/dist/api/types/WebhooksWebhookTestResponse.d.ts +3 -0
  160. package/dist/api/types/index.d.ts +12 -10
  161. package/dist/api/types/index.js +12 -10
  162. package/dist/auth/BearerAuthProvider.d.ts +1 -1
  163. package/dist/serialization/client/catalog.d.ts +6 -0
  164. package/dist/serialization/{types/EmbeddingsRawEmbeddingVector.js → client/catalog.js} +2 -5
  165. package/dist/serialization/client/index.d.ts +2 -0
  166. package/dist/serialization/client/index.js +25 -0
  167. package/dist/serialization/client/listProviders.d.ts +6 -0
  168. package/dist/serialization/{types/EmbeddingsDeleteResult.js → client/listProviders.js} +2 -6
  169. package/dist/serialization/client/requests/SearchQueryRequest.d.ts +11 -3
  170. package/dist/serialization/client/requests/SearchQueryRequest.js +11 -3
  171. package/dist/serialization/resources/connectors/client/configure.d.ts +6 -0
  172. package/dist/serialization/resources/connectors/client/configure.js +39 -0
  173. package/dist/serialization/resources/connectors/client/delete.d.ts +6 -0
  174. package/dist/serialization/resources/connectors/client/delete.js +39 -0
  175. package/dist/serialization/resources/connectors/client/deleteResource.d.ts +6 -0
  176. package/dist/serialization/resources/connectors/client/deleteResource.js +39 -0
  177. package/dist/serialization/resources/connectors/client/discover.d.ts +6 -0
  178. package/dist/serialization/resources/connectors/client/discover.js +39 -0
  179. package/dist/serialization/resources/connectors/client/discoverPreview.d.ts +6 -0
  180. package/dist/serialization/resources/connectors/client/discoverPreview.js +39 -0
  181. package/dist/serialization/resources/connectors/client/index.d.ts +10 -0
  182. package/dist/serialization/resources/connectors/client/index.js +49 -0
  183. package/dist/serialization/resources/connectors/client/list.d.ts +6 -0
  184. package/dist/serialization/resources/connectors/client/list.js +39 -0
  185. package/dist/serialization/resources/connectors/client/listResources.d.ts +6 -0
  186. package/dist/serialization/resources/connectors/client/listResources.js +39 -0
  187. package/dist/serialization/resources/connectors/client/requests/HandlerConfigureReq.d.ts +12 -0
  188. package/dist/serialization/resources/{embeddings/client/requests/EmbeddingsInsertRawEmbeddingsRequest.js → connectors/client/requests/HandlerConfigureReq.js} +6 -7
  189. package/dist/serialization/resources/connectors/client/requests/HandlerConnectorCreateReq.d.ts +21 -0
  190. package/dist/serialization/resources/{embeddings/client/requests/EmbeddingsSearchRawEmbeddingsRequest.js → connectors/client/requests/HandlerConnectorCreateReq.js} +15 -8
  191. package/dist/serialization/resources/connectors/client/requests/HandlerDiscoverPreviewReq.d.ts +11 -0
  192. package/dist/serialization/resources/connectors/client/requests/HandlerDiscoverPreviewReq.js +43 -0
  193. package/dist/serialization/resources/connectors/client/requests/HandlerResourceCreateReq.d.ts +19 -0
  194. package/dist/serialization/{types/EmbeddingsRawEmbeddingSearchResult.js → resources/connectors/client/requests/HandlerResourceCreateReq.js} +13 -8
  195. package/dist/serialization/resources/connectors/client/requests/index.d.ts +4 -0
  196. package/dist/serialization/resources/connectors/client/requests/index.js +11 -0
  197. package/dist/serialization/resources/connectors/client/rotateAConnectorsStoredOAuthRefreshToken.d.ts +10 -0
  198. package/dist/serialization/resources/connectors/client/rotateAConnectorsStoredOAuthRefreshToken.js +40 -0
  199. package/dist/serialization/resources/connectors/client/sync.d.ts +6 -0
  200. package/dist/serialization/resources/connectors/client/sync.js +39 -0
  201. package/dist/serialization/resources/context/client/requests/HandlerContextMetadataUpdateRequest.d.ts +16 -0
  202. package/dist/serialization/resources/{embeddings/client/requests/EmbeddingsFilterRawEmbeddingsRequest.js → context/client/requests/HandlerContextMetadataUpdateRequest.js} +10 -8
  203. package/dist/serialization/resources/context/client/requests/ListV2ListContentRequest.d.ts +4 -1
  204. package/dist/serialization/resources/context/client/requests/ListV2ListContentRequest.js +4 -1
  205. package/dist/serialization/resources/context/client/requests/SourcesV2SourceDeleteRequest.d.ts +4 -1
  206. package/dist/serialization/resources/context/client/requests/SourcesV2SourceDeleteRequest.js +4 -1
  207. package/dist/serialization/resources/context/client/requests/index.d.ts +1 -0
  208. package/dist/serialization/resources/context/client/requests/index.js +3 -1
  209. package/dist/serialization/resources/context/index.d.ts +1 -0
  210. package/dist/serialization/resources/context/index.js +1 -0
  211. package/dist/serialization/resources/context/types/IngestContextRequestType.d.ts +7 -0
  212. package/dist/serialization/resources/context/types/IngestContextRequestType.js +39 -0
  213. package/dist/serialization/resources/context/types/ListV2ListContentRequestType.d.ts +7 -0
  214. package/dist/serialization/resources/context/types/ListV2ListContentRequestType.js +39 -0
  215. package/dist/serialization/resources/context/types/RelationsContextRequestType.d.ts +7 -0
  216. package/dist/serialization/resources/context/types/RelationsContextRequestType.js +39 -0
  217. package/dist/serialization/resources/context/types/SourcesV2SourceDeleteRequestType.d.ts +7 -0
  218. package/dist/serialization/resources/context/types/SourcesV2SourceDeleteRequestType.js +39 -0
  219. package/dist/serialization/resources/context/types/index.d.ts +4 -0
  220. package/dist/serialization/resources/context/types/index.js +20 -0
  221. package/dist/serialization/resources/{tenants → databases}/client/requests/TenantsTenantCreateRequest.d.ts +2 -0
  222. package/dist/serialization/resources/{tenants → databases}/client/requests/TenantsTenantCreateRequest.js +2 -0
  223. package/dist/serialization/resources/databases/client/requests/TenantsTenantMetadataSchemaUpdateRequest.d.ts +10 -0
  224. package/dist/serialization/resources/databases/client/requests/TenantsTenantMetadataSchemaUpdateRequest.js +42 -0
  225. package/dist/serialization/resources/databases/client/requests/index.d.ts +2 -0
  226. package/dist/serialization/resources/databases/client/requests/index.js +7 -0
  227. package/dist/serialization/resources/index.d.ts +5 -4
  228. package/dist/serialization/resources/index.js +6 -5
  229. package/dist/serialization/types/ConnectorsConnector.d.ts +30 -0
  230. package/dist/serialization/types/ConnectorsConnector.js +62 -0
  231. package/dist/serialization/types/ConnectorsResource.d.ts +26 -0
  232. package/dist/serialization/types/ConnectorsResource.js +58 -0
  233. package/dist/serialization/types/GithubComHydradbHydradbApplicationInternalServiceMetadataEditResult.d.ts +20 -0
  234. package/dist/serialization/types/GithubComHydradbHydradbApplicationInternalServiceMetadataEditResult.js +52 -0
  235. package/dist/serialization/types/GraphEntity.d.ts +1 -0
  236. package/dist/serialization/types/GraphEntity.js +1 -0
  237. package/dist/serialization/types/HandlerDeprecationNotice.d.ts +13 -0
  238. package/dist/serialization/types/HandlerDeprecationNotice.js +45 -0
  239. package/dist/serialization/types/HandlerEnvelopeGithubComHydradbHydradbApplicationInternalServiceMetadataEditResult.d.ts +15 -0
  240. package/dist/serialization/types/{HandlerEnvelopeEmbeddingsInsertResult.js → HandlerEnvelopeGithubComHydradbHydradbApplicationInternalServiceMetadataEditResult.js} +4 -4
  241. package/dist/serialization/types/{HandlerEnvelopeSourcesSourceDeleteResponse.d.ts → HandlerEnvelopeSourcesMemoryDeleteResponse.d.ts} +4 -4
  242. package/dist/serialization/types/{HandlerEnvelopeSourcesSourceDeleteResponse.js → HandlerEnvelopeSourcesMemoryDeleteResponse.js} +4 -4
  243. package/dist/serialization/types/HandlerErrorDetail.d.ts +3 -0
  244. package/dist/serialization/types/HandlerErrorDetail.js +3 -0
  245. package/dist/serialization/types/HandlerMetadataSchemaUpdateResponse.d.ts +11 -0
  246. package/dist/serialization/types/HandlerMetadataSchemaUpdateResponse.js +43 -0
  247. package/dist/serialization/types/HandlerResourceMapping.d.ts +17 -0
  248. package/dist/serialization/types/{EmbeddingsRawEmbeddingDocument.js → HandlerResourceMapping.js} +8 -5
  249. package/dist/serialization/types/HandlerResponseMeta.d.ts +7 -0
  250. package/dist/serialization/types/HandlerResponseMeta.js +7 -0
  251. package/dist/serialization/types/ListContentFilter.d.ts +2 -2
  252. package/dist/serialization/types/ListContentFilter.js +2 -2
  253. package/dist/serialization/types/SearchMetadataFilters.d.ts +7 -0
  254. package/dist/serialization/types/{EmbeddingsInsertResult.js → SearchMetadataFilters.js} +2 -7
  255. package/dist/serialization/types/SearchQueryRequestCollections.d.ts +7 -0
  256. package/dist/serialization/types/SearchQueryRequestCollections.js +42 -0
  257. package/dist/serialization/types/SearchQueryRequestSubTenantIds.d.ts +7 -0
  258. package/dist/serialization/types/SearchQueryRequestSubTenantIds.js +42 -0
  259. package/dist/serialization/types/SearchRecallMode.d.ts +1 -1
  260. package/dist/serialization/types/SearchRecallMode.js +1 -1
  261. package/dist/serialization/types/SearchSourceInfo.d.ts +1 -0
  262. package/dist/serialization/types/SearchSourceInfo.js +1 -0
  263. package/dist/serialization/types/SearchV2Chunk.d.ts +1 -0
  264. package/dist/serialization/types/SearchV2Chunk.js +1 -0
  265. package/dist/serialization/types/{SourcesSourceDeleteResponse.d.ts → SourcesMemoryDeleteResponse.d.ts} +3 -2
  266. package/dist/serialization/types/{SourcesSourceDeleteResponse.js → SourcesMemoryDeleteResponse.js} +3 -2
  267. package/dist/serialization/types/TenantsFailedTenant.d.ts +1 -0
  268. package/dist/serialization/types/TenantsFailedTenant.js +1 -0
  269. package/dist/serialization/types/TenantsInfraStatusResponseV2.d.ts +1 -0
  270. package/dist/serialization/types/TenantsInfraStatusResponseV2.js +1 -0
  271. package/dist/serialization/types/TenantsSubTenantIdsResponse.d.ts +1 -0
  272. package/dist/serialization/types/TenantsSubTenantIdsResponse.js +1 -0
  273. package/dist/serialization/types/TenantsTenantCreateAcceptedResponse.d.ts +1 -0
  274. package/dist/serialization/types/TenantsTenantCreateAcceptedResponse.js +1 -0
  275. package/dist/serialization/types/TenantsTenantDeleteResponse.d.ts +1 -0
  276. package/dist/serialization/types/TenantsTenantDeleteResponse.js +1 -0
  277. package/dist/serialization/types/TenantsTenantIdsResponse.d.ts +2 -0
  278. package/dist/serialization/types/TenantsTenantIdsResponse.js +2 -0
  279. package/dist/serialization/types/TenantsTenantStatsResponse.d.ts +1 -0
  280. package/dist/serialization/types/TenantsTenantStatsResponse.js +1 -0
  281. package/dist/serialization/types/index.d.ts +12 -10
  282. package/dist/serialization/types/index.js +12 -10
  283. package/package.json +1 -1
  284. package/dist/api/resources/embeddings/client/Client.d.ts +0 -80
  285. package/dist/api/resources/embeddings/client/Client.js +0 -351
  286. package/dist/api/resources/embeddings/client/requests/DeleteEmbeddingsRequest.d.ts +0 -18
  287. package/dist/api/resources/embeddings/client/requests/EmbeddingsFilterRawEmbeddingsRequest.d.ts +0 -15
  288. package/dist/api/resources/embeddings/client/requests/EmbeddingsInsertRawEmbeddingsRequest.d.ts +0 -14
  289. package/dist/api/resources/embeddings/client/requests/EmbeddingsSearchRawEmbeddingsRequest.d.ts +0 -16
  290. package/dist/api/resources/embeddings/client/requests/index.d.ts +0 -4
  291. package/dist/api/resources/embeddings/exports.d.ts +0 -2
  292. package/dist/api/resources/tenants/client/Client.d.ts +0 -109
  293. package/dist/api/resources/tenants/client/requests/DeleteTenantsRequest.d.ts +0 -10
  294. package/dist/api/resources/tenants/client/requests/StatsTenantsRequest.d.ts +0 -10
  295. package/dist/api/resources/tenants/client/requests/StatusTenantsRequest.d.ts +0 -10
  296. package/dist/api/resources/tenants/client/requests/SubTenantsTenantsRequest.d.ts +0 -10
  297. package/dist/api/resources/tenants/client/requests/TenantsTenantCreateRequest.d.ts +0 -11
  298. package/dist/api/resources/tenants/client/requests/index.d.ts +0 -5
  299. package/dist/api/resources/tenants/exports.d.ts +0 -2
  300. package/dist/api/types/EmbeddingsDeleteResult.d.ts +0 -5
  301. package/dist/api/types/EmbeddingsInsertResult.d.ts +0 -6
  302. package/dist/api/types/EmbeddingsRawEmbeddingDocument.d.ts +0 -8
  303. package/dist/api/types/EmbeddingsRawEmbeddingSearchResult.d.ts +0 -8
  304. package/dist/api/types/EmbeddingsRawEmbeddingVector.d.ts +0 -5
  305. package/dist/api/types/HandlerEnvelopeArrayEmbeddingsRawEmbeddingSearchResult.d.ts +0 -7
  306. package/dist/api/types/HandlerEnvelopeEmbeddingsDeleteResult.d.ts +0 -7
  307. package/dist/api/types/HandlerEnvelopeEmbeddingsInsertResult.d.ts +0 -7
  308. package/dist/api/types/HandlerEnvelopeSourcesSourceDeleteResponse.d.ts +0 -7
  309. package/dist/api/types/SourcesSourceDeleteResponse.d.ts +0 -7
  310. package/dist/serialization/resources/embeddings/client/requests/EmbeddingsFilterRawEmbeddingsRequest.d.ts +0 -14
  311. package/dist/serialization/resources/embeddings/client/requests/EmbeddingsInsertRawEmbeddingsRequest.d.ts +0 -13
  312. package/dist/serialization/resources/embeddings/client/requests/EmbeddingsSearchRawEmbeddingsRequest.d.ts +0 -14
  313. package/dist/serialization/resources/embeddings/client/requests/index.d.ts +0 -3
  314. package/dist/serialization/resources/embeddings/client/requests/index.js +0 -9
  315. package/dist/serialization/resources/tenants/client/index.d.ts +0 -1
  316. package/dist/serialization/resources/tenants/client/index.js +0 -17
  317. package/dist/serialization/resources/tenants/client/requests/index.d.ts +0 -1
  318. package/dist/serialization/resources/tenants/client/requests/index.js +0 -5
  319. package/dist/serialization/types/EmbeddingsDeleteResult.d.ts +0 -11
  320. package/dist/serialization/types/EmbeddingsInsertResult.d.ts +0 -12
  321. package/dist/serialization/types/EmbeddingsRawEmbeddingDocument.d.ts +0 -14
  322. package/dist/serialization/types/EmbeddingsRawEmbeddingSearchResult.d.ts +0 -14
  323. package/dist/serialization/types/EmbeddingsRawEmbeddingVector.d.ts +0 -10
  324. package/dist/serialization/types/HandlerEnvelopeArrayEmbeddingsRawEmbeddingSearchResult.d.ts +0 -15
  325. package/dist/serialization/types/HandlerEnvelopeArrayEmbeddingsRawEmbeddingSearchResult.js +0 -47
  326. package/dist/serialization/types/HandlerEnvelopeEmbeddingsDeleteResult.d.ts +0 -15
  327. package/dist/serialization/types/HandlerEnvelopeEmbeddingsDeleteResult.js +0 -47
  328. package/dist/serialization/types/HandlerEnvelopeEmbeddingsInsertResult.d.ts +0 -15
  329. /package/dist/api/{resources/embeddings/client/requests/DeleteEmbeddingsRequest.js → client/requests/ListProvidersRequest.js} +0 -0
  330. /package/dist/api/resources/{embeddings → connectors}/client/index.d.ts +0 -0
  331. /package/dist/api/resources/{embeddings → connectors}/client/index.js +0 -0
  332. /package/dist/api/resources/{embeddings/client/requests/EmbeddingsFilterRawEmbeddingsRequest.js → connectors/client/requests/DeleteConnectorsRequest.js} +0 -0
  333. /package/dist/api/resources/{embeddings/client/requests/EmbeddingsInsertRawEmbeddingsRequest.js → connectors/client/requests/DeleteResourceConnectorsRequest.js} +0 -0
  334. /package/dist/api/resources/{embeddings/client/requests/EmbeddingsSearchRawEmbeddingsRequest.js → connectors/client/requests/DiscoverConnectorsRequest.js} +0 -0
  335. /package/dist/api/resources/{tenants/client/requests/DeleteTenantsRequest.js → connectors/client/requests/GetConnectorsRequest.js} +0 -0
  336. /package/dist/api/resources/{tenants/client/requests/StatsTenantsRequest.js → connectors/client/requests/HandlerConfigureReq.js} +0 -0
  337. /package/dist/api/resources/{tenants/client/requests/StatusTenantsRequest.js → connectors/client/requests/HandlerConnectorCreateReq.js} +0 -0
  338. /package/dist/api/resources/{tenants/client/requests/SubTenantsTenantsRequest.js → connectors/client/requests/HandlerDiscoverPreviewReq.js} +0 -0
  339. /package/dist/api/resources/{tenants/client/requests/TenantsTenantCreateRequest.js → connectors/client/requests/HandlerResourceCreateReq.js} +0 -0
  340. /package/dist/api/{types/EmbeddingsDeleteResult.js → resources/connectors/client/requests/ListConnectorsRequest.js} +0 -0
  341. /package/dist/api/{types/EmbeddingsInsertResult.js → resources/connectors/client/requests/ListResourcesConnectorsRequest.js} +0 -0
  342. /package/dist/api/{types/EmbeddingsRawEmbeddingDocument.js → resources/connectors/client/requests/PatchConnectorsIdCredentialsRequest.js} +0 -0
  343. /package/dist/api/{types/EmbeddingsRawEmbeddingSearchResult.js → resources/connectors/client/requests/SyncConnectorsRequest.js} +0 -0
  344. /package/dist/api/resources/{embeddings → connectors}/client/requests/index.js +0 -0
  345. /package/dist/api/resources/{embeddings → connectors}/index.d.ts +0 -0
  346. /package/dist/api/resources/{embeddings → connectors}/index.js +0 -0
  347. /package/dist/api/{types/EmbeddingsRawEmbeddingVector.js → resources/context/client/requests/HandlerContextMetadataUpdateRequest.js} +0 -0
  348. /package/dist/api/resources/{tenants → databases}/client/index.d.ts +0 -0
  349. /package/dist/api/resources/{tenants → databases}/client/index.js +0 -0
  350. /package/dist/api/{types/HandlerEnvelopeArrayEmbeddingsRawEmbeddingSearchResult.js → resources/databases/client/requests/CollectionsDatabasesRequest.js} +0 -0
  351. /package/dist/api/{types/HandlerEnvelopeEmbeddingsDeleteResult.js → resources/databases/client/requests/DeleteDatabasesRequest.js} +0 -0
  352. /package/dist/api/{types/HandlerEnvelopeEmbeddingsInsertResult.js → resources/databases/client/requests/StatsDatabasesRequest.js} +0 -0
  353. /package/dist/api/{types/HandlerEnvelopeSourcesSourceDeleteResponse.js → resources/databases/client/requests/StatusDatabasesRequest.js} +0 -0
  354. /package/dist/api/{types/SourcesSourceDeleteResponse.js → resources/databases/client/requests/TenantsTenantCreateRequest.js} +0 -0
  355. /package/dist/api/resources/{tenants → databases}/client/requests/index.js +0 -0
  356. /package/dist/api/resources/{tenants → databases}/index.d.ts +0 -0
  357. /package/dist/api/resources/{tenants → databases}/index.js +0 -0
  358. /package/dist/serialization/resources/{embeddings → connectors}/index.d.ts +0 -0
  359. /package/dist/serialization/resources/{embeddings → connectors}/index.js +0 -0
  360. /package/dist/serialization/resources/{embeddings → databases}/client/index.d.ts +0 -0
  361. /package/dist/serialization/resources/{embeddings → databases}/client/index.js +0 -0
  362. /package/dist/serialization/resources/{tenants → databases}/index.d.ts +0 -0
  363. /package/dist/serialization/resources/{tenants → databases}/index.js +0 -0
package/README.md CHANGED
@@ -1,750 +1,689 @@
1
- # Hydra DB TypeScript SDK
2
-
3
- The official TypeScript SDK for the Hydra DB platform.
4
-
5
- Hydra DB provides memory, knowledge ingestion, retrieval, and graph context for AI applications.
6
-
7
- [Hydra DB docs](https://docs.hydradb.com/)
8
-
9
- ## Features
10
-
11
- - Ingest knowledge files, app-generated knowledge, and memories
12
- - Track ingestion/indexing status of sources
13
- - Retrieve knowledge and/or memory with a single `query` call (hybrid or keyword search, optional graph context)
14
- - Inspect, list, and delete sources, and fetch graph relations
15
- - Manage tenants and sub-tenants
16
- - Register and manage webhooks and inspect deliveries
17
- - Format retrieval results for LLM prompts with `buildString`
18
- - Make authenticated passthrough requests for endpoints not yet wrapped by the SDK
1
+ # HydraDB TypeScript SDK
2
+
3
+ The official TypeScript/JavaScript SDK for [HydraDB](https://hydradb.com) a managed retrieval
4
+ engine that combines vector search, full‑text search, and a knowledge graph behind a single API.
5
+
6
+ - **Package:** `@hydradb/sdk`
7
+ - **Client class:** `HydraDBClient`
8
+ - **Version:** `2.1.1` (API version `2`)
9
+ - **Docs:** https://docs.hydradb.com
10
+ - **Runtime:** Node.js 18+ (works with any `fetch`-capable runtime)
11
+
12
+ ---
13
+
14
+ ## Table of contents
15
+
16
+ - [Installation](#installation)
17
+ - [Quick start](#quick-start)
18
+ - [Client configuration](#client-configuration)
19
+ - [Core concepts](#core-concepts)
20
+ - [Responses & raw access](#responses--raw-access)
21
+ - [Endpoints](#endpoints)
22
+ - [`query` — unified retrieval](#query--unified-retrieval)
23
+ - [Context (`client.context`)](#context-clientcontext)
24
+ - [`ingest`](#contextingest)
25
+ - [`list`](#contextlist)
26
+ - [`inspect`](#contextinspect)
27
+ - [`status`](#contextstatus)
28
+ - [`relations`](#contextrelations)
29
+ - [`updateSourceMetadata`](#contextupdatesourcemetadata)
30
+ - [`delete`](#contextdelete)
31
+ - [Databases (`client.databases`)](#databases-clientdatabases)
32
+ - [`create`](#databasescreate)
33
+ - [`list`](#databaseslist)
34
+ - [`collections`](#databasescollections)
35
+ - [`stats`](#databasesstats)
36
+ - [`status`](#databasesstatus)
37
+ - [`delete`](#databasesdelete)
38
+ - [Webhooks (`client.webhooks`)](#webhooks-clientwebhooks)
39
+ - [`register`](#webhooksregister)
40
+ - [`get`](#webhooksget)
41
+ - [`test`](#webhookstest)
42
+ - [`delete`](#webhooksdelete)
43
+ - [`listDeliveries`](#webhookslistdeliveries)
44
+ - [`getDelivery`](#webhooksgetdelivery)
45
+ - [`retryDelivery`](#webhooksretrydelivery)
46
+ - [Error handling](#error-handling)
47
+ - [Advanced](#advanced)
48
+ - [Per-request options (timeouts, retries, abort)](#per-request-options-timeouts-retries-abort)
49
+ - [Passthrough `fetch`](#passthrough-fetch)
50
+ - [Custom fetch & logging](#custom-fetch--logging)
51
+
52
+ ---
19
53
 
20
54
  ## Installation
21
55
 
22
56
  ```bash
23
57
  npm install @hydradb/sdk
24
- # or
25
- yarn add @hydradb/sdk
26
- # or
27
- pnpm add @hydradb/sdk
58
+ # or: pnpm add @hydradb/sdk / yarn add @hydradb/sdk
28
59
  ```
29
60
 
30
- ## Client setup
61
+ ## Quick start
31
62
 
32
- ```ts
63
+ ```typescript
33
64
  import { HydraDBClient } from "@hydradb/sdk";
34
65
 
35
66
  const client = new HydraDBClient({
36
- token: process.env.HYDRA_DB_API_KEY,
67
+ token: "YOUR_API_KEY", // bearer token
37
68
  });
38
69
 
39
- const TENANT_ID = process.env.HYDRA_TENANT_ID ?? "my-company";
40
- const SUB_TENANT_ID = process.env.HYDRA_SUB_TENANT_ID ?? "my-sub-tenant";
70
+ // Run a hybrid search over a database ("tenant")
71
+ const result = await client.query({
72
+ query: "What is our refund policy?",
73
+ database: "acme-corp",
74
+ type: "knowledge",
75
+ maxResults: 5,
76
+ });
77
+
78
+ console.log(result.data);
41
79
  ```
42
80
 
43
- The default API base URL is:
81
+ Every method returns an awaitable `HttpResponsePromise`. `await`-ing it resolves to the parsed
82
+ response body (a `HandlerEnvelope…` object whose payload is on `.data`). See
83
+ [Responses & raw access](#responses--raw-access).
44
84
 
45
- ```text
46
- https://api.hydradb.com
47
- ```
85
+ ---
86
+
87
+ ## Client configuration
48
88
 
49
- For an on-prem deployment, pass `baseUrl`:
89
+ ```typescript
90
+ import { HydraDBClient, HydraDBEnvironment } from "@hydradb/sdk";
50
91
 
51
- ```ts
52
- const localClient = new HydraDBClient({
53
- token: process.env.HYDRA_DB_API_KEY,
54
- baseUrl: "https://<id>.hydradb.<domain>",
92
+ const client = new HydraDBClient({
93
+ token: "YOUR_API_KEY",
94
+ apiVersion: "2", // optional, defaults to "2"
95
+ environment: HydraDBEnvironment.Default, // https://api.hydradb.com
96
+ // baseUrl: "https://api.hydradb.com", // override for self-hosted / staging
97
+ timeoutInSeconds: 60, // default 60
98
+ maxRetries: 2, // default 2
99
+ headers: { "X-Custom-Header": "value" }, // sent on every request
55
100
  });
56
101
  ```
57
102
 
58
- The client targets API version `2` by default; override it with `apiVersion`. Other client options include `headers`, `timeoutInSeconds` (default `60`), `maxRetries`, `environment`, and a custom `fetch` implementation.
103
+ | Option | Type | Default | Notes |
104
+ | ------------------ | ------------------------------------- | ------------------------ | ----- |
105
+ | `token` | `string \| () => string \| Promise` | – | Bearer token. Accepts a supplier for dynamic/refreshing tokens. |
106
+ | `apiVersion` | `string` | `"2"` | Sets the `API-Version` header. |
107
+ | `environment` | `HydraDBEnvironment \| string` | `Default` | `Default` → `https://api.hydradb.com`. |
108
+ | `baseUrl` | `string` | – | Explicit URL; overrides `environment`. |
109
+ | `timeoutInSeconds` | `number` | `60` | Per‑request timeout. |
110
+ | `maxRetries` | `number` | `2` | Automatic retries on transient failures. |
111
+ | `headers` | `Record<string, string>` | – | Extra headers on every request. |
112
+ | `fetch` | `typeof fetch` | runtime default | Custom fetch implementation. |
113
+ | `logging` | `LogConfig \| Logger` | silent | SDK logging. |
59
114
 
60
- > Note: request fields use **camelCase** (`tenantId`, `subTenantId`, `maxResults`, …). The SDK serializes them to the API's snake_case on the wire.
115
+ > **Note:** all request fields use **camelCase** in TypeScript (e.g. `subTenantId`,
116
+ > `maxResults`); the SDK maps them to the API's snake_case wire format for you.
61
117
 
62
- ## Client structure
118
+ ---
63
119
 
64
- All functionality is reached through one top-level method and three sub-clients:
120
+ ## Core concepts
65
121
 
66
- | Accessor | Purpose |
67
- |---|---|
68
- | `client.query(...)` | Retrieve knowledge and/or memory in a single call. |
69
- | `client.context` | Ingest, inspect, list, delete sources, and fetch graph relations. |
70
- | `client.tenants` | Create, list, delete, and inspect tenants. |
71
- | `client.webhooks` | Register and manage webhooks and inspect deliveries. |
122
+ **Database vs. Collection (tenant vs. sub‑tenant).** HydraDB v2 renamed the isolation scopes:
72
123
 
73
- ## Important tenant and sub-tenant rule
124
+ | v2 name (canonical) | v1 alias (deprecated, still accepted) | Meaning |
125
+ | ------------------- | ------------------------------------- | ------- |
126
+ | `database` | `tenantId` | Top‑level isolation boundary. |
127
+ | `collection` | `subTenantId` | A namespace within a database. |
74
128
 
75
- Use the same `tenantId` and `subTenantId` across ingest, status, query, inspect, list, and delete calls.
129
+ The server’s `TenantAliases` middleware reconciles the two, so you can pass either but new
130
+ code should use `database` / `collection`. The legacy aliases will be removed in a future release.
76
131
 
77
- If you ingest with a `subTenantId` and then check status or search without it, you may be looking at a different namespace. Omitting `subTenantId` uses the default sub-tenant created during tenant setup.
132
+ **Corpora (`type`).** Data is split into two corpora you can target independently:
133
+ `"knowledge"` (documents), `"memory"` (agent memories), or `"all"`.
78
134
 
79
- ## Tenant management
135
+ ---
80
136
 
81
- A tenant is the top-level isolated database. A sub-tenant is an optional isolated collection inside a tenant.
137
+ ## Responses & raw access
82
138
 
83
- ### Create a standard tenant
139
+ `await`-ing any call gives you the parsed body:
84
140
 
85
- ```ts
86
- await client.tenants.create({
87
- tenantId: TENANT_ID,
88
- });
141
+ ```typescript
142
+ const res = await client.databases.list();
143
+ console.log(res.data); // the payload
144
+ console.log(res.meta); // request metadata
89
145
  ```
90
146
 
91
- ### Create an embeddings tenant
147
+ To also get the HTTP status and headers, call `.withRawResponse()`:
92
148
 
93
- Provide `embeddingsDimension` and set `isEmbeddingsTenant: true`.
149
+ ```typescript
150
+ const { data, rawResponse } = await client.query({ query: "hi", database: "acme-corp" })
151
+ .withRawResponse();
94
152
 
95
- ```ts
96
- await client.tenants.create({
97
- tenantId: "my-embeddings-tenant",
98
- isEmbeddingsTenant: true,
99
- embeddingsDimension: 1536,
100
- });
153
+ console.log(rawResponse.status);
154
+ console.log(rawResponse.headers.get("x-request-id"));
155
+ console.log(data);
101
156
  ```
102
157
 
103
- ### Create a tenant with a metadata schema
158
+ ---
104
159
 
105
- Each field can enable filtering (`enableMatch`), semantic search (`enableDenseEmbedding`), and/or keyword search (`enableSparseEmbedding`). Fields with embeddings enabled must be string-typed.
106
-
107
- ```ts
108
- await client.tenants.create({
109
- tenantId: TENANT_ID,
110
- tenantMetadataSchema: [
111
- {
112
- name: "department",
113
- dataType: "string",
114
- enableMatch: true,
115
- enableDenseEmbedding: false,
116
- enableSparseEmbedding: false,
117
- },
118
- ],
119
- });
120
- ```
160
+ ## Endpoints
121
161
 
122
- ### List tenants
162
+ ### `query` — unified retrieval
123
163
 
124
- ```ts
125
- const tenants = await client.tenants.list();
126
- console.log(tenants);
127
- ```
164
+ `POST /query` → `HandlerEnvelopeSearchV2RetrievalResult`
128
165
 
129
- ### List sub-tenants
166
+ The single retrieval endpoint. Dispatches across corpus (`type`) and retrieval method
167
+ (`queryBy`), optionally enriching results with knowledge‑graph context.
130
168
 
131
- ```ts
132
- const subTenants = await client.tenants.subTenants({
133
- tenantId: TENANT_ID,
169
+ ```typescript
170
+ const result = await client.query({
171
+ query: "How do I rotate API keys?",
172
+ database: "acme-corp", // v2 name for the tenant scope
173
+ type: "knowledge", // "knowledge" | "memory" | "all"
174
+ queryBy: "hybrid", // "hybrid" | "text"
175
+ mode: "auto", // "fast" | "thinking" | "auto"
176
+ operator: "or", // "or" | "and" | "phrase"
177
+ maxResults: 10,
178
+ numRelatedChunks: 3,
179
+ graphContext: true, // include KG context (default true)
180
+ recencyBias: 0.2,
181
+ metadataFilters: { // exact-match on tenant/document metadata
182
+ department: "security",
183
+ additional_metadata: { author: "ada" },
184
+ },
134
185
  });
135
186
 
136
- console.log(subTenants);
187
+ console.log(result.data);
137
188
  ```
138
189
 
139
- ### Check tenant infrastructure status
190
+ **Scoping to specific collections** (preferred over the deprecated `subTenantIds`):
140
191
 
141
- ```ts
142
- const infraStatus = await client.tenants.status({
143
- tenantId: TENANT_ID,
144
- });
192
+ ```typescript
193
+ // Equal weighting across collections
194
+ await client.query({ query: "pricing", database: "acme-corp", collections: ["eu", "us"] });
145
195
 
146
- console.log(infraStatus);
196
+ // Weighted ranking (one decimal place max)
197
+ await client.query({ query: "pricing", database: "acme-corp", collections: { eu: 1.0, us: 0.5 } });
147
198
  ```
148
199
 
149
- ### Tenant stats
150
-
151
- ```ts
152
- const stats = await client.tenants.stats({
153
- tenantId: TENANT_ID,
154
- });
200
+ **Scoping to specific source IDs** — `ids` applies a hard `source_id in [...]` pre‑filter; if
201
+ nothing matches it returns empty rather than widening to the whole corpus:
155
202
 
156
- console.log(stats);
203
+ ```typescript
204
+ await client.query({ query: "onboarding", database: "acme-corp", ids: ["doc_123", "doc_456"] });
157
205
  ```
158
206
 
159
- ### Delete a tenant
207
+ Key fields (`SearchQueryRequest`):
160
208
 
161
- > Warning: this permanently deletes the tenant and its data.
209
+ | Field | Type | Notes |
210
+ | ------------------------- | ----------------------------------- | ----- |
211
+ | `query` | `string` | The search text. |
212
+ | `database` | `string` | Tenant scope (v2). Alias: `tenantId`. |
213
+ | `collection` / `collections` | `string` / `string[] \| Record<string, number>` | Sub‑tenant scope. Prefer over `subTenantId(s)`. |
214
+ | `type` | `"knowledge" \| "memory" \| "all"` | Corpus to query. |
215
+ | `queryBy` | `"hybrid" \| "text"` | Retrieval method. |
216
+ | `mode` | `"fast" \| "thinking" \| "auto"` | Recall mode. |
217
+ | `operator` | `"or" \| "and" \| "phrase"` | Text‑match operator. |
218
+ | `maxResults` | `number` | Result cap. |
219
+ | `numRelatedChunks` | `number` | Neighboring chunks to attach. |
220
+ | `graphContext` | `boolean` | Include KG context. Default `true`. |
221
+ | `queryApps` | `boolean` | App‑aware knowledge retrieval. |
222
+ | `queryForcefulRelations` | `boolean` | Force relation expansion. Default `true`. |
223
+ | `metadataFilters` | `Record<string, unknown>` | Exact‑match (nest doc metadata under `additional_metadata`). |
224
+ | `recencyBias` | `number` | Boost newer sources. |
225
+ | `ids` | `string[]` | Restrict to specific source IDs. |
162
226
 
163
- ```ts
164
- await client.tenants.delete({
165
- tenantId: TENANT_ID,
166
- });
167
- ```
227
+ ---
168
228
 
169
- ## Ingest knowledge and memory
229
+ ### Context (`client.context`)
170
230
 
171
- `client.context.ingest()` handles both knowledge files and memory, selected via the `type` field (`"knowledge"` or `"memory"`).
231
+ Everything about the data *inside* a database: ingesting, listing, inspecting, updating
232
+ metadata, checking processing status, reading graph relations, and deleting.
172
233
 
173
- ### Ingest one file
234
+ #### `context.ingest`
174
235
 
175
- `documents` accepts a list of uploadable files. Each entry can be a file path (`{ path, filename?, contentType? }`), a file-like object with metadata (`{ data, filename?, contentType? }`), or a raw buffer/blob/stream.
236
+ `POST /context/ingest` (multipart) `HandlerEnvelopeIngestionV2SourceUploadResponse`
176
237
 
177
- ```ts
178
- const uploadResult = await client.context.ingest({
179
- tenantId: TENANT_ID,
180
- subTenantId: SUB_TENANT_ID,
181
- type: "knowledge",
182
- documents: [
183
- {
184
- path: "./report.pdf",
185
- filename: "report.pdf",
186
- contentType: "application/pdf",
187
- },
188
- ],
189
- upsert: true,
190
- });
238
+ Ingest knowledge documents or memories. `documents` is a file upload; the other structured
239
+ fields are JSON strings.
191
240
 
192
- console.log(uploadResult);
193
- ```
241
+ ```typescript
242
+ import { createReadStream } from "fs";
194
243
 
195
- The initial response typically reports a `queued` status — the file was accepted into the ingestion queue, not finished. Use `client.context.status()` to track progress.
244
+ // Ingest a document file
245
+ const res = await client.context.ingest({
246
+ database: "acme-corp", // required
247
+ documents: createReadStream("handbook.pdf"),
248
+ collection: "hr",
249
+ type: "knowledge",
250
+ // documentMetadata is a JSON *array* — one object per uploaded file.
251
+ documentMetadata: JSON.stringify([{ title: "Employee Handbook", author: "HR" }]),
252
+ upsert: "true", // form field is a string
253
+ });
196
254
 
197
- ### Ingest multiple files
255
+ console.log(res.data);
198
256
 
199
- ```ts
257
+ // Ingest memories (no file). Each item needs "text" (or "user_assistant_pairs").
200
258
  await client.context.ingest({
201
- tenantId: TENANT_ID,
202
- subTenantId: SUB_TENANT_ID,
203
- type: "knowledge",
204
- documents: [
205
- { path: "./a.pdf", filename: "a.pdf", contentType: "application/pdf" },
206
- { path: "./notes.txt", filename: "notes.txt", contentType: "text/plain" },
207
- ],
208
- upsert: true,
259
+ database: "acme-corp",
260
+ memories: JSON.stringify([{ text: "User prefers dark mode" }]),
261
+ type: "memory",
209
262
  });
210
263
  ```
211
264
 
212
- Buffers, blobs, and streams also work:
265
+ | Field | Type | Notes |
266
+ | ------------------ | ------------------------ | ----- |
267
+ | `database` | `string` (required) | Database (tenant scope). Alias: `tenantId`. |
268
+ | `documents` | `Uploadable` | File upload (stream, `Blob`, `Buffer`, etc.). |
269
+ | `memories` | `string` | JSON **array** string; each item needs `text` (or `user_assistant_pairs`). |
270
+ | `documentMetadata` | `string` | JSON **array** string of per‑document metadata — one object per uploaded file (count must match). |
271
+ | `appKnowledge` | `string` | App‑knowledge items as a JSON **array** string (not raw text). |
272
+ | `graphPayload` | `string` | Pre‑computed graph payload. |
273
+ | `collection` | `string` | Collection (sub‑tenant scope). Alias: `subTenantId`. |
274
+ | `type` | `string` | `"knowledge"` or `"memory"`. |
275
+ | `upsert` | `string` | `"true"` to upsert on existing IDs. |
213
276
 
214
- ```ts
215
- import { readFileSync } from "node:fs";
277
+ #### `context.list`
216
278
 
217
- await client.context.ingest({
218
- tenantId: TENANT_ID,
219
- subTenantId: SUB_TENANT_ID,
279
+ `POST /context/list` → `HandlerEnvelopeListV2SourceListResponse`
280
+
281
+ List sources or memories (IDs + metadata) for a database, with filtering and pagination.
282
+
283
+ ```typescript
284
+ const res = await client.context.list({
285
+ database: "acme-corp",
286
+ collection: "hr",
220
287
  type: "knowledge",
221
- documents: [
222
- {
223
- data: readFileSync("./report.pdf"),
224
- filename: "report.pdf",
225
- contentType: "application/pdf",
226
- },
227
- ],
288
+ page: 1,
289
+ pageSize: 50,
290
+ includeFields: ["title", "type", "timestamp"],
291
+ filters: {
292
+ metadata: { department: "finance" }, // tenant/source metadata
293
+ additionalMetadata: { author: "ada" }, // document metadata
294
+ sourceFields: { type: "pdf" }, // well-known source fields
295
+ },
228
296
  });
297
+
298
+ for (const source of res.data?.inner?.sources ?? []) {
299
+ console.log(source);
300
+ }
229
301
  ```
230
302
 
231
- ### Ingest files with per-file metadata
303
+ #### `context.inspect`
232
304
 
233
- `documentMetadata` is a JSON **string** — a JSON array of per-file metadata objects (knowledge only). Each object may include `id`, `metadata`, `additional_metadata`, `infer`, and `relations`. Array length should match `documents`.
305
+ `GET /context/inspect` `HandlerEnvelopeFetchV2SourceFetchResponse`
234
306
 
235
- ```ts
236
- const documentMetadata = [
237
- {
238
- id: "doc_a",
239
- metadata: { department: "sales" },
240
- additional_metadata: { author: "Alice" },
241
- },
242
- {
243
- id: "doc_b",
244
- metadata: { department: "marketing" },
245
- additional_metadata: { author: "Bob" },
246
- relations: {
247
- cortex_source_ids: ["doc_a"],
248
- properties: { relation: "same_upload_batch" },
249
- },
250
- },
251
- ];
307
+ Fetch a single ingested source: its content, inferred content, and a presigned download URL.
252
308
 
253
- await client.context.ingest({
254
- tenantId: TENANT_ID,
255
- subTenantId: SUB_TENANT_ID,
256
- type: "knowledge",
257
- documents: [
258
- { path: "./a.pdf", filename: "a.pdf", contentType: "application/pdf" },
259
- { path: "./b.pdf", filename: "b.pdf", contentType: "application/pdf" },
260
- ],
261
- documentMetadata: JSON.stringify(documentMetadata),
262
- upsert: true,
309
+ ```typescript
310
+ const res = await client.context.inspect({
311
+ id: "doc_1234", // required — source ID
312
+ database: "acme-corp", // required
313
+ collection: "hr",
314
+ expirySeconds: 3600, // presigned URL lifetime
315
+ mode: "both", // fetch mode: "content", "url", or "both"
263
316
  });
317
+ console.log(res.data);
264
318
  ```
265
319
 
266
- ### Ingest app-generated knowledge
320
+ #### `context.status`
267
321
 
268
- `appKnowledge` is a JSON **string** — a single source object or an array of source objects (knowledge only).
322
+ `GET /context/status` `HandlerEnvelopeIngestionV2BatchProcessingStatus`
269
323
 
270
- ```ts
271
- const appKnowledge = [
272
- {
273
- id: "app_source_1",
274
- title: "CRM Account Note",
275
- content: { text: "Acme is interested in the enterprise plan." },
276
- type: "document",
277
- tenant_metadata: { department: "sales" },
278
- document_metadata: { source: "crm" },
279
- },
280
- ];
324
+ Check processing status for one or more source IDs.
281
325
 
282
- await client.context.ingest({
283
- tenantId: TENANT_ID,
284
- subTenantId: SUB_TENANT_ID,
285
- type: "knowledge",
286
- appKnowledge: JSON.stringify(appKnowledge),
287
- upsert: true,
326
+ ```typescript
327
+ // Single source
328
+ await client.context.status({ database: "acme-corp", id: "doc_1234", collection: "hr" });
329
+
330
+ // Batch
331
+ const res = await client.context.status({
332
+ database: "acme-corp",
333
+ ids: ["doc_1", "doc_2", "doc_3"],
288
334
  });
335
+ console.log(res.data);
289
336
  ```
290
337
 
291
- ### Add memories
338
+ #### `context.relations`
292
339
 
293
- `memories` is a JSON **string** — a JSON array of memory items (memory only). Each item can include `text`, `title`, `infer`, and `metadata`.
340
+ `GET /context/relations` `HandlerEnvelopeGraphGraphRelationsResponse`
294
341
 
295
- ```ts
296
- const memories = [
297
- {
298
- source_id: "memory_001",
299
- text: "User prefers detailed technical explanations.",
300
- title: "User preference",
301
- infer: true,
302
- metadata: { category: "preference" },
303
- },
304
- ];
342
+ Return knowledge‑graph relations for a whole database or a single source.
305
343
 
306
- await client.context.ingest({
307
- tenantId: TENANT_ID,
308
- subTenantId: SUB_TENANT_ID,
309
- type: "memory",
310
- memories: JSON.stringify(memories),
311
- upsert: true,
344
+ ```typescript
345
+ const res = await client.context.relations({
346
+ database: "acme-corp", // required
347
+ collection: "hr",
348
+ id: "doc_1234", // omit for database-wide relations
349
+ type: "knowledge", // "knowledge" | "memory"
350
+ limit: 100,
351
+ cursor: 0, // pagination cursor
312
352
  });
353
+ console.log(res.data);
313
354
  ```
314
355
 
315
- ## Check ingestion status
356
+ #### `context.updateSourceMetadata`
316
357
 
317
- `client.context.status()` reports indexing status for one or more source IDs. Pass a single `id` or a list via `ids`.
358
+ `PATCH /context/{id}/metadata` `HandlerEnvelope…MetadataEditResult`
318
359
 
319
- ```ts
320
- const status = await client.context.status({
321
- tenantId: TENANT_ID,
322
- subTenantId: SUB_TENANT_ID,
323
- ids: ["source-id-1", "source-id-2"],
324
- });
360
+ Merge/upsert `tenantMetadata` and `additionalMetadata` for one source. `collection`
361
+ (alias `subTenantId`) is required by the server.
325
362
 
326
- console.log(status);
363
+ ```typescript
364
+ const res = await client.context.updateSourceMetadata({
365
+ id: "doc_1234", // required — source ID (path param)
366
+ database: "acme-corp",
367
+ collection: "hr", // required by the server
368
+ // tenantMetadata keys must be declared in the database's tenant_metadata_schema
369
+ // (and match the declared type). Use additionalMetadata for free-form fields.
370
+ tenantMetadata: { department: "finance" },
371
+ additionalMetadata: { author: "ada", tags: ["policy", "2026"], reviewed: true },
372
+ });
373
+ console.log(res.data);
327
374
  ```
328
375
 
329
- ### Poll until ingestion finishes
376
+ > **Note:** although the SDK exposes a `documentMetadata` parameter here, this endpoint
377
+ > **rejects** it (HTTP 400 "document_metadata is not accepted; use additional_metadata").
378
+ > Put per-document fields in `additionalMetadata` instead.
330
379
 
331
- ```ts
332
- const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
380
+ #### `context.delete`
333
381
 
334
- async function waitForIngestion(ids: string[]) {
335
- while (true) {
336
- const status = await client.context.status({
337
- tenantId: TENANT_ID,
338
- subTenantId: SUB_TENANT_ID,
339
- ids,
340
- });
382
+ `DELETE /context` `HandlerEnvelopeSourcesMemoryDeleteResponse`
341
383
 
342
- // Inspect the returned status fields (per the SourceStatusApiResponse
343
- // schema) and break once everything has completed or errored.
344
- console.log(status);
384
+ Delete one or more sources or memories by ID.
345
385
 
346
- await sleep(5000);
347
- }
348
- }
386
+ ```typescript
387
+ const res = await client.context.delete({
388
+ database: "acme-corp",
389
+ collection: "hr",
390
+ ids: ["doc_1234", "doc_5678"],
391
+ type: "knowledge",
392
+ });
393
+ console.log(res.data);
349
394
  ```
350
395
 
351
- ## Query (retrieval)
352
-
353
- `client.query()` is the single retrieval entry point. It searches knowledge, memory, or both, with optional graph context. It returns a promise resolving to a `QueryApiResponse`; the retrieval payload is on `.data`.
354
-
355
- ```ts
356
- const response = await client.query({
357
- tenantId: TENANT_ID,
358
- subTenantId: SUB_TENANT_ID,
359
- query: "What did the account notes say about Acme?",
360
- maxResults: 10,
361
- mode: "fast",
362
- alpha: 0.8,
363
- recencyBias: 0,
364
- graphContext: true,
365
- });
396
+ ---
366
397
 
367
- console.log(response.data?.chunks);
368
- console.log(response.data?.sources);
369
- ```
398
+ ### Databases (`client.databases`)
370
399
 
371
- ### Search knowledge, memory, or both
400
+ Manage databases (tenants) and inspect their collections, stats, and provisioning status.
372
401
 
373
- Use the `type` field:
402
+ #### `databases.create`
374
403
 
375
- ```ts
376
- // Knowledge only
377
- await client.query({ tenantId: TENANT_ID, query: "quarterly revenue", type: "knowledge" });
404
+ `POST /databases` → `HandlerEnvelopeTenantsTenantCreateAcceptedResponse`
378
405
 
379
- // Memory only
380
- await client.query({ tenantId: TENANT_ID, query: "user preferences", type: "memory" });
406
+ Create a new database, optionally with a custom metadata schema for its collections.
381
407
 
382
- // Both, merged
383
- await client.query({ tenantId: TENANT_ID, query: "what does the user prefer", type: "all" });
408
+ ```typescript
409
+ const res = await client.databases.create({
410
+ database: "acme-corp",
411
+ embeddingsDimension: 1536,
412
+ databaseMetadataSchema: [
413
+ {
414
+ name: "department",
415
+ dataType: "VARCHAR", // BOOL | INT8..INT64 | FLOAT | DOUBLE | VARCHAR | JSON | ARRAY
416
+ maxLength: 128,
417
+ enableMatch: true,
418
+ },
419
+ { name: "priority", dataType: "INT32" },
420
+ ],
421
+ });
422
+ console.log(res.data);
384
423
  ```
385
424
 
386
- ### Hybrid vs. keyword search
425
+ > Creation is asynchronous — poll [`databases.status`](#databasesstatus) until infrastructure
426
+ > is provisioned before ingesting.
387
427
 
388
- `alpha` controls the hybrid balance and can be a number in `0.0`–`1.0` or the string `"auto"`:
428
+ #### `databases.list`
389
429
 
390
- - `1.0`: more semantic/vector weighted
391
- - `0.0`: more keyword/BM25 weighted
392
- - `"auto"`: backend chooses the balance
430
+ `GET /databases` `HandlerEnvelopeTenantsTenantIdsResponse`
393
431
 
394
- For pure keyword/BM25 search, set `queryBy: "text"` and choose an `operator`:
432
+ List all databases for the authenticated user. Takes no request body.
395
433
 
396
- ```ts
397
- const response = await client.query({
398
- tenantId: TENANT_ID,
399
- subTenantId: SUB_TENANT_ID,
400
- query: "enterprise plan",
401
- queryBy: "text",
402
- operator: "phrase", // "or" | "and" | "phrase"
403
- type: "knowledge",
404
- });
434
+ ```typescript
435
+ const res = await client.databases.list();
436
+ console.log(res.data);
405
437
  ```
406
438
 
407
- `queryBy` accepts `"hybrid"` (vector + BM25, default) or `"text"` (BM25 only). `operator` applies only when `queryBy: "text"`.
439
+ #### `databases.collections`
408
440
 
409
- ### Metadata filters
441
+ `GET /databases/collections` → `HandlerEnvelopeTenantsSubTenantIdsResponse`
410
442
 
411
- Top-level keys match tenant metadata (and must correspond to fields defined in `tenantMetadataSchema`). To filter on document-level fields you sent as `additional_metadata` at ingestion, nest them under `additional_metadata` (the key `document_metadata` is also accepted as a legacy alias).
443
+ List all collections within a database.
412
444
 
413
- ```ts
414
- const response = await client.query({
415
- tenantId: TENANT_ID,
416
- subTenantId: SUB_TENANT_ID,
417
- query: "revenue forecast",
418
- maxResults: 10,
419
- metadataFilters: {
420
- department: "sales",
421
- additional_metadata: { author: "Alice" },
422
- },
423
- });
445
+ ```typescript
446
+ const res = await client.databases.collections({ database: "acme-corp" });
447
+ console.log(res.data);
424
448
  ```
425
449
 
426
- ### All `query` options
450
+ #### `databases.stats`
427
451
 
428
- | Option | Type | Description |
429
- |---|---|---|
430
- | `tenantId` | `string` | Tenant identifier (required). |
431
- | `query` | `string` | Search terms (required). |
432
- | `subTenantId` | `string` | Optional sub-tenant identifier. |
433
- | `maxResults` | `number` | Maximum number of results. |
434
- | `mode` | `string` | `"fast"` or `"thinking"`. |
435
- | `alpha` | `string \| number` | Hybrid balance (`0.0`–`1.0` or `"auto"`). |
436
- | `recencyBias` | `number` | Preference for newer content (`0.0`–`1.0`). |
437
- | `graphContext` | `boolean` | Enable graph context (on by default in v2; set `false` to omit). |
438
- | `queryForcefulRelations` | `boolean` | Search forceful relations in thinking mode. |
439
- | `additionalContext` | `string` | Extra context to guide retrieval. |
440
- | `queryApps` | `boolean` | Run a parallel app-aware retrieval lane and fuse results. |
441
- | `metadataFilters` | `object` | Key-value metadata filters. |
442
- | `type` | `string` | `"knowledge"`, `"memory"`, or `"all"`. |
443
- | `queryBy` | `string` | `"hybrid"` or `"text"`. |
444
- | `operator` | `string` | `"or"`, `"and"`, or `"phrase"` (only with `queryBy: "text"`). |
452
+ `GET /databases/stats` `HandlerEnvelopeTenantsTenantStatsResponse`
445
453
 
446
- ## Formatting results for an LLM
454
+ Get collection statistics for a database.
447
455
 
448
- `buildString` formats a query result (or its `.data`) into a plain string ready for prompt injection. It is exported from the package root and from `@hydradb/sdk/helpers`.
456
+ ```typescript
457
+ const res = await client.databases.stats({ database: "acme-corp" });
458
+ console.log(res.data);
459
+ ```
449
460
 
450
- ```ts
451
- import { HydraDBClient, buildString } from "@hydradb/sdk";
461
+ #### `databases.status`
452
462
 
453
- const client = new HydraDBClient({ token: process.env.HYDRA_DB_API_KEY });
463
+ `GET /databases/status` `HandlerEnvelopeTenantsInfraStatusResponseV2`
454
464
 
455
- const response = await client.query({
456
- tenantId: TENANT_ID,
457
- query: "What does the user prefer?",
458
- });
465
+ Check infrastructure provisioning status for a database.
459
466
 
460
- // Pass the full envelope or just the data — buildString handles both.
461
- console.log(buildString(response));
462
- console.log(buildString(response.data!));
467
+ ```typescript
468
+ const res = await client.databases.status({ database: "acme-corp" });
469
+ console.log(res.data);
463
470
  ```
464
471
 
465
- The output renders chunks under a `=== CONTEXT ===` header, with graph relations and synthesis context appended when present. If there is nothing to render, it returns `"No relevant context found."`.
466
-
467
- ## Inspect, list, and delete sources
472
+ #### `databases.delete`
468
473
 
469
- ### List sources
474
+ `DELETE /databases` → `HandlerEnvelopeTenantsTenantDeleteResponse`
470
475
 
471
- ```ts
472
- const sources = await client.context.list({
473
- tenantId: TENANT_ID,
474
- subTenantId: SUB_TENANT_ID,
475
- type: "knowledge",
476
- page: 1,
477
- pageSize: 50,
478
- });
476
+ Delete a database and **all** associated data.
479
477
 
480
- console.log(sources);
478
+ ```typescript
479
+ const res = await client.databases.delete({ database: "acme-corp" });
480
+ console.log(res.data);
481
481
  ```
482
482
 
483
- List memories with `type: "memory"`.
483
+ ---
484
484
 
485
- ### Fetch specific source IDs
485
+ ### Webhooks (`client.webhooks`)
486
486
 
487
- ```ts
488
- const sources = await client.context.list({
489
- tenantId: TENANT_ID,
490
- subTenantId: SUB_TENANT_ID,
491
- type: "knowledge",
492
- ids: ["doc_a", "doc_b"],
493
- });
494
- ```
487
+ Register a single indexing webhook per org and inspect/replay its deliveries.
495
488
 
496
- ### Filter listed data
489
+ #### `webhooks.register`
497
490
 
498
- ```ts
499
- const filtered = await client.context.list({
500
- tenantId: TENANT_ID,
501
- subTenantId: SUB_TENANT_ID,
502
- type: "knowledge",
503
- filters: {
504
- tenant_metadata: { department: "sales" },
505
- document_metadata: { author: "Alice" },
506
- },
507
- });
508
- ```
491
+ `POST /webhooks/indexing` → `HandlerEnvelopeWebhooksWebhookRegisterResponse`
509
492
 
510
- ### Include only selected fields
493
+ Register (or update) the indexing webhook for this API key’s org.
511
494
 
512
- ```ts
513
- const sources = await client.context.list({
514
- tenantId: TENANT_ID,
515
- subTenantId: SUB_TENANT_ID,
516
- type: "knowledge",
517
- includeFields: ["title", "document_metadata", "tenant_metadata"],
495
+ ```typescript
496
+ const res = await client.webhooks.register({
497
+ url: "https://example.com/hooks/hydradb",
498
+ eventTypes: ["indexing.status_changed"], // the only supported event type
499
+ signingSecret: "whsec_at_least_16_chars", // must be >= 16 characters
518
500
  });
501
+ console.log(res.data);
519
502
  ```
520
503
 
521
- Allowed field names:
504
+ #### `webhooks.get`
522
505
 
523
- ```text
524
- attachments, content, description, document_metadata, note, relations,
525
- tenant_metadata, timestamp, title, type, url
526
- ```
527
-
528
- ### Inspect a single source
506
+ `GET /webhooks/indexing` → `HandlerEnvelopeWebhooksWebhookGetResponse`
529
507
 
530
- ```ts
531
- const source = await client.context.inspect({
532
- tenantId: TENANT_ID,
533
- subTenantId: SUB_TENANT_ID,
534
- id: "source-id-1",
535
- mode: "content",
536
- });
508
+ Fetch the currently registered webhook. Takes no request body.
537
509
 
538
- console.log(source);
510
+ ```typescript
511
+ const res = await client.webhooks.get();
512
+ console.log(res.data);
539
513
  ```
540
514
 
541
- Supported `mode` values: `content` | `url` | `both`. For presigned URLs, set `expirySeconds`:
515
+ #### `webhooks.test`
542
516
 
543
- ```ts
544
- const source = await client.context.inspect({
545
- tenantId: TENANT_ID,
546
- subTenantId: SUB_TENANT_ID,
547
- id: "source-id-1",
548
- mode: "url",
549
- expirySeconds: 3600,
550
- });
551
- ```
517
+ `POST /webhooks/indexing/test` → `HandlerEnvelopeWebhooksWebhookTestResponse`
552
518
 
553
- ### Fetch graph relations
519
+ Send a test delivery to the registered endpoint.
554
520
 
555
- ```ts
556
- const relations = await client.context.relations({
557
- tenantId: TENANT_ID,
558
- subTenantId: SUB_TENANT_ID,
559
- id: "source-id-1",
560
- type: "knowledge",
561
- limit: 10,
562
- });
563
-
564
- console.log(relations);
521
+ ```typescript
522
+ const res = await client.webhooks.test();
523
+ console.log(res.data);
565
524
  ```
566
525
 
567
- Omit `id` to fetch relations across the whole sub-tenant. Use `cursor` for pagination.
526
+ #### `webhooks.delete`
568
527
 
569
- ### Delete sources
528
+ `DELETE /webhooks/indexing` → `HandlerEnvelopeWebhooksWebhookDeleteResponse`
570
529
 
571
- Use `type` to target knowledge or memory.
530
+ Remove the registered webhook.
572
531
 
573
- ```ts
574
- await client.context.delete({
575
- tenantId: TENANT_ID,
576
- subTenantId: SUB_TENANT_ID,
577
- ids: ["source-id-1", "source-id-2"],
578
- type: "knowledge",
579
- });
532
+ ```typescript
533
+ const res = await client.webhooks.delete();
534
+ console.log(res.data);
580
535
  ```
581
536
 
582
- ## Webhooks
537
+ #### `webhooks.listDeliveries`
583
538
 
584
- Hydra DB can notify your application about events such as indexing status changes.
539
+ `GET /webhooks/indexing/deliveries` `HandlerEnvelopeWebhooksDeliveryListResponse`
585
540
 
586
- ### Register a webhook
541
+ List recent webhook deliveries, with filtering and cursor pagination.
587
542
 
588
- ```ts
589
- const hook = await client.webhooks.register({
590
- url: "https://example.com/hydra-webhook",
591
- eventTypes: ["indexing.status_changed"],
592
- signingSecret: "a-secret-at-least-16-chars",
543
+ ```typescript
544
+ const res = await client.webhooks.listDeliveries({
545
+ limit: 50,
546
+ cursor: undefined, // pass the previous page's cursor to continue
547
+ status: "failed", // filter by delivery status
593
548
  });
594
-
595
- console.log(hook);
549
+ console.log(res.data);
596
550
  ```
597
551
 
598
- When `signingSecret` is set, every delivery includes an `X-HydraDB-Signature: sha256=<hmac>` header computed as `HMAC-SHA256(key=signingSecret, msg=raw_body)`. The secret must be at least 16 characters; omit it to disable signing.
552
+ #### `webhooks.getDelivery`
553
+
554
+ `GET` → `HandlerEnvelopeWebhooksDeliveryItem`
599
555
 
600
- ### Get the current webhook
556
+ Fetch a single delivery by ID.
601
557
 
602
- ```ts
603
- console.log(await client.webhooks.get());
558
+ ```typescript
559
+ const res = await client.webhooks.getDelivery({ deliveryId: "dlv_1234" });
560
+ console.log(res.data);
604
561
  ```
605
562
 
606
- ### Delete the webhook
563
+ #### `webhooks.retryDelivery`
607
564
 
608
- ```ts
609
- await client.webhooks.delete();
610
- ```
565
+ `POST` → `HandlerEnvelopeWebhooksRetryResponse`
611
566
 
612
- ### Send a test event
567
+ Re‑attempt a failed delivery.
613
568
 
614
- ```ts
615
- await client.webhooks.test();
569
+ ```typescript
570
+ const res = await client.webhooks.retryDelivery({ deliveryId: "dlv_1234" });
571
+ console.log(res.data);
616
572
  ```
617
573
 
618
- ### List and inspect deliveries
574
+ ---
619
575
 
620
- ```ts
621
- const deliveries = await client.webhooks.listDeliveries({
622
- limit: 20,
623
- status: "failed", // pending | failed | delivered | permanently_failed
624
- });
625
- console.log(deliveries);
576
+ ## Error handling
626
577
 
627
- const one = await client.webhooks.getDelivery({ deliveryId: "delivery_id" });
628
- console.log(one);
629
- ```
578
+ Non‑2xx responses throw typed errors. Each carries `statusCode`, the parsed `body`, and the
579
+ `rawResponse`. All extend `HydraDBError`.
630
580
 
631
- Use `cursor` to paginate deliveries.
581
+ ```typescript
582
+ import {
583
+ HydraDBClient,
584
+ HydraDB, // namespace with the typed error classes
585
+ HydraDBError,
586
+ } from "@hydradb/sdk";
632
587
 
633
- ### Retry a delivery
588
+ const client = new HydraDBClient({ token: "YOUR_API_KEY" });
634
589
 
635
- ```ts
636
- await client.webhooks.retryDelivery({ deliveryId: "delivery_id" });
590
+ try {
591
+ await client.databases.status({ database: "does-not-exist" });
592
+ } catch (err) {
593
+ if (err instanceof HydraDB.NotFoundError) {
594
+ console.error("not found:", err.body);
595
+ } else if (err instanceof HydraDBError) {
596
+ console.error(`API error ${err.statusCode}:`, err.body);
597
+ } else {
598
+ throw err;
599
+ }
600
+ }
637
601
  ```
638
602
 
639
- ## Accessing raw responses
603
+ Typed error classes (under the `HydraDB` namespace): `BadRequestError` (400),
604
+ `ForbiddenError` (403), `NotFoundError` (404), `ConflictError` (409),
605
+ `UnprocessableEntityError` (422), `InternalServerError` (500). Network/timeout failures throw
606
+ `HydraDBTimeoutError` / `HydraDBError`.
640
607
 
641
- Most methods return an `HttpResponsePromise`, which you can `await` for the parsed body or call `.withRawResponse()` on to also get headers and status.
608
+ ---
642
609
 
643
- ```ts
644
- const { data, rawResponse } = await client
645
- .query({ tenantId: TENANT_ID, query: "revenue" })
646
- .withRawResponse();
610
+ ## Advanced
611
+
612
+ ### Per-request options (timeouts, retries, abort)
613
+
614
+ Every method accepts a second `requestOptions` argument that overrides client defaults for
615
+ that call.
647
616
 
648
- console.log(rawResponse.status, data.data?.chunks);
617
+ ```typescript
618
+ const controller = new AbortController();
619
+
620
+ await client.query(
621
+ { query: "hello", database: "acme-corp" },
622
+ {
623
+ timeoutInSeconds: 30,
624
+ maxRetries: 3,
625
+ apiVersion: "2",
626
+ headers: { "X-Trace-Id": "abc123" },
627
+ abortSignal: controller.signal,
628
+ },
629
+ );
649
630
  ```
650
631
 
651
- ## Passthrough fetch
632
+ ### Passthrough `fetch`
652
633
 
653
- Use `client.fetch()` for endpoints not yet wrapped by the SDK. It uses the SDK's configured auth, base URL, timeout, and retry settings. Relative paths resolve against the configured base URL.
634
+ For endpoints not yet wrapped by the SDK, `client.fetch` issues a request using the SDK's
635
+ configured auth, retries, and logging. Relative paths resolve against the configured base URL.
654
636
 
655
- ```ts
656
- const response = await client.fetch("/metrics", { method: "GET" });
657
- const data = await response.json();
637
+ ```typescript
638
+ const response = await client.fetch("/some/new/endpoint", {
639
+ method: "POST",
640
+ body: JSON.stringify({ hello: "world" }),
641
+ });
642
+ console.log(await response.json());
658
643
  ```
659
644
 
660
- ## Error handling
645
+ ### Custom fetch & logging
661
646
 
662
- ```ts
663
- import {
664
- HydraDBError,
665
- HydraDBTimeoutError,
666
- HydraDB,
667
- } from "@hydradb/sdk";
647
+ ```typescript
648
+ import { HydraDBClient } from "@hydradb/sdk";
649
+ import nodeFetch from "node-fetch";
668
650
 
669
- try {
670
- await client.context.ingest({
671
- tenantId: TENANT_ID,
672
- subTenantId: SUB_TENANT_ID,
673
- type: "knowledge",
674
- documents: [{ path: "./missing.pdf" }],
675
- });
676
- } catch (error) {
677
- if (error instanceof HydraDBTimeoutError) {
678
- console.error("Request timed out", error);
679
- } else if (error instanceof HydraDB.UnauthorizedError) {
680
- console.error("Invalid or missing API key");
681
- } else if (error instanceof HydraDBError) {
682
- console.error("Hydra DB API error", error.statusCode, error.body);
683
- } else {
684
- console.error("Unexpected error", error);
685
- }
686
- }
651
+ const client = new HydraDBClient({
652
+ token: "YOUR_API_KEY",
653
+ fetch: nodeFetch as unknown as typeof fetch,
654
+ logging: { level: "debug" },
655
+ });
687
656
  ```
688
657
 
689
- Typed status errors are available under the `HydraDB` namespace:
690
-
691
- ```text
692
- HydraDB.BadRequestError
693
- HydraDB.UnauthorizedError
694
- HydraDB.ForbiddenError
695
- HydraDB.NotFoundError
696
- HydraDB.UnprocessableEntityError
697
- HydraDB.TooManyRequestsError
698
- HydraDB.InternalServerError
699
- HydraDB.ServiceUnavailableError
700
- ```
701
-
702
- `HydraDBError` (base) and `HydraDBTimeoutError` are exported from the package root.
703
-
704
- ## SDK method reference
705
-
706
- | SDK method | Description |
707
- |---|---|
708
- | `client.query()` | Retrieve knowledge and/or memory in a single call. |
709
- | `client.context.ingest()` | Ingest knowledge files, app-generated knowledge, or memories. |
710
- | `client.context.status()` | Check ingestion/indexing status for source IDs. |
711
- | `client.context.inspect()` | Fetch a single source's content or URL. |
712
- | `client.context.list()` | List knowledge sources or memories. |
713
- | `client.context.delete()` | Delete one or more source IDs. |
714
- | `client.context.relations()` | Fetch graph relations for a source or sub-tenant. |
715
- | `client.tenants.create()` | Create a standard or embeddings tenant. |
716
- | `client.tenants.list()` | List tenants. |
717
- | `client.tenants.delete()` | Delete a tenant. |
718
- | `client.tenants.status()` | Check tenant infrastructure status. |
719
- | `client.tenants.subTenants()` | List sub-tenants for a tenant. |
720
- | `client.tenants.stats()` | Get tenant stats. |
721
- | `client.webhooks.register()` | Register a webhook. |
722
- | `client.webhooks.get()` | Get the current webhook. |
723
- | `client.webhooks.delete()` | Delete the webhook. |
724
- | `client.webhooks.test()` | Send a test event. |
725
- | `client.webhooks.listDeliveries()` | List webhook deliveries. |
726
- | `client.webhooks.getDelivery()` | Get a single delivery. |
727
- | `client.webhooks.retryDelivery()` | Retry a delivery. |
728
- | `client.fetch()` | Authenticated passthrough request. |
729
- | `buildString()` | Format a query result into an LLM-ready string. |
730
-
731
- ## Notes for contributors
732
-
733
- This SDK is generated from the Hydra DB API definition with Fern. The generated clients live in `Client.ts` and under `api/resources/{context,tenants,webhooks}/client/Client.ts`. If method signatures change in the generated code, update this README to match.
734
-
735
- Before publishing, verify these stay consistent:
736
-
737
- - Package name and version in `package.json` (`@hydradb/sdk`)
738
- - Installation command in this README
739
- - Request fields use camelCase
740
- - The ingest payload shapes (`documentMetadata`, `appKnowledge`, and `memories` are JSON strings)
741
-
742
- ## Links
743
-
744
- - **Homepage:** [hydradb.com](https://www.hydradb.com/)
745
- - **Documentation:** [docs.hydradb.com](https://docs.hydradb.com/)
746
- - **API Reference:** [docs.hydradb.com/api-reference/introduction](https://docs.hydradb.com/api-reference/introduction)
747
-
748
- ## Support
749
-
750
- If you have any questions or need help, reach out at [founders@hydradb.com](mailto:founders@hydradb.com).
658
+ ---
659
+
660
+ ## Endpoint reference
661
+
662
+ | Group | Method | HTTP | Description |
663
+ | --------- | ----------------------- | ------------------------------------------ | ----------- |
664
+ | — | `query` | `POST /query` | Unified hybrid/text retrieval with optional graph context. |
665
+ | context | `ingest` | `POST /context/ingest` | Ingest documents or memories (multipart). |
666
+ | context | `list` | `POST /context/list` | List sources/memories with filters + pagination. |
667
+ | context | `inspect` | `GET /context/inspect` | Fetch a source’s content + presigned URL. |
668
+ | context | `status` | `GET /context/status` | Processing status for one or many source IDs. |
669
+ | context | `relations` | `GET /context/relations` | KG relations for a database or source. |
670
+ | context | `updateSourceMetadata` | `PATCH /context/{id}/metadata` | Merge/upsert metadata for a source. |
671
+ | context | `delete` | `DELETE /context` | Delete sources/memories by ID. |
672
+ | databases | `create` | `POST /databases` | Create a database with optional schema. |
673
+ | databases | `list` | `GET /databases` | List all databases. |
674
+ | databases | `collections` | `GET /databases/collections` | List collections in a database. |
675
+ | databases | `stats` | `GET /databases/stats` | Collection statistics. |
676
+ | databases | `status` | `GET /databases/status` | Infra provisioning status. |
677
+ | databases | `delete` | `DELETE /databases` | Delete a database and its data. |
678
+ | webhooks | `register` | `POST /webhooks/indexing` | Register/update the org indexing webhook. |
679
+ | webhooks | `get` | `GET /webhooks/indexing` | Get the registered webhook. |
680
+ | webhooks | `test` | `POST /webhooks/indexing/test` | Send a test delivery. |
681
+ | webhooks | `delete` | `DELETE /webhooks/indexing` | Remove the webhook. |
682
+ | webhooks | `listDeliveries` | `GET /webhooks/indexing/deliveries` | List recent deliveries. |
683
+ | webhooks | `getDelivery` | `GET` | Fetch one delivery by ID. |
684
+ | webhooks | `retryDelivery` | `POST` | Retry a failed delivery. |
685
+
686
+ ---
687
+
688
+ _This SDK is generated from the HydraDB API definition. For the full type reference see the
689
+ `api/` directory or https://docs.hydradb.com._