vectra 0.12.2 → 0.14.0

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 (392) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +92 -100
  3. package/bin/vectra.js +3 -0
  4. package/lib/BrowserWebFetcher.d.ts +75 -0
  5. package/lib/BrowserWebFetcher.d.ts.map +1 -0
  6. package/lib/BrowserWebFetcher.js +290 -0
  7. package/lib/BrowserWebFetcher.js.map +1 -0
  8. package/lib/FileFetcher.d.ts +5 -0
  9. package/lib/FileFetcher.d.ts.map +1 -0
  10. package/lib/FileFetcher.js +89 -0
  11. package/lib/FileFetcher.js.map +1 -0
  12. package/lib/FileFetcher.spec.d.ts +2 -0
  13. package/lib/FileFetcher.spec.d.ts.map +1 -0
  14. package/lib/FileFetcher.spec.js +244 -0
  15. package/lib/FileFetcher.spec.js.map +1 -0
  16. package/lib/FolderWatcher.d.ts +91 -0
  17. package/lib/FolderWatcher.d.ts.map +1 -0
  18. package/lib/FolderWatcher.js +304 -0
  19. package/lib/FolderWatcher.js.map +1 -0
  20. package/lib/FolderWatcher.spec.d.ts +2 -0
  21. package/lib/FolderWatcher.spec.d.ts.map +1 -0
  22. package/lib/FolderWatcher.spec.js +308 -0
  23. package/lib/FolderWatcher.spec.js.map +1 -0
  24. package/lib/GPT3Tokenizer.d.ts +9 -0
  25. package/lib/GPT3Tokenizer.spec.d.ts +2 -0
  26. package/lib/GPT3Tokenizer.spec.d.ts.map +1 -0
  27. package/lib/GPT3Tokenizer.spec.js +45 -0
  28. package/lib/GPT3Tokenizer.spec.js.map +1 -0
  29. package/lib/ItemSelector.d.ts +41 -0
  30. package/lib/ItemSelector.d.ts.map +1 -0
  31. package/lib/ItemSelector.js +179 -0
  32. package/lib/ItemSelector.js.map +1 -0
  33. package/lib/ItemSelector.spec.d.ts +2 -0
  34. package/lib/ItemSelector.spec.d.ts.map +1 -0
  35. package/lib/ItemSelector.spec.js +204 -0
  36. package/lib/ItemSelector.spec.js.map +1 -0
  37. package/lib/LocalDocument.d.ts +54 -0
  38. package/lib/LocalDocument.d.ts.map +1 -1
  39. package/lib/LocalDocument.js +116 -0
  40. package/lib/LocalDocument.js.map +1 -0
  41. package/lib/LocalDocument.spec.d.ts +2 -0
  42. package/lib/LocalDocument.spec.d.ts.map +1 -0
  43. package/lib/LocalDocument.spec.js +214 -0
  44. package/lib/LocalDocument.spec.js.map +1 -0
  45. package/lib/LocalDocumentIndex.d.ts +152 -0
  46. package/lib/LocalDocumentIndex.d.ts.map +1 -1
  47. package/lib/LocalDocumentIndex.js +420 -0
  48. package/lib/LocalDocumentIndex.js.map +1 -0
  49. package/lib/LocalDocumentIndex.spec.d.ts +2 -0
  50. package/lib/LocalDocumentIndex.spec.d.ts.map +1 -0
  51. package/lib/LocalDocumentIndex.spec.js +494 -0
  52. package/lib/LocalDocumentIndex.spec.js.map +1 -0
  53. package/lib/LocalDocumentResult.d.ts +66 -0
  54. package/lib/LocalDocumentResult.d.ts.map +1 -1
  55. package/lib/LocalDocumentResult.js +376 -0
  56. package/lib/LocalDocumentResult.js.map +1 -0
  57. package/lib/LocalDocumentResult.spec.d.ts +2 -0
  58. package/lib/LocalDocumentResult.spec.d.ts.map +1 -0
  59. package/lib/LocalDocumentResult.spec.js +373 -0
  60. package/lib/LocalDocumentResult.spec.js.map +1 -0
  61. package/lib/LocalEmbeddings.d.ts +59 -0
  62. package/lib/LocalEmbeddings.d.ts.map +1 -0
  63. package/lib/LocalEmbeddings.js +101 -0
  64. package/lib/LocalEmbeddings.js.map +1 -0
  65. package/lib/LocalEmbeddings.spec.d.ts +2 -0
  66. package/lib/LocalEmbeddings.spec.d.ts.map +1 -0
  67. package/lib/LocalEmbeddings.spec.js +155 -0
  68. package/lib/LocalEmbeddings.spec.js.map +1 -0
  69. package/lib/LocalIndex.d.ts +159 -0
  70. package/lib/LocalIndex.d.ts.map +1 -1
  71. package/lib/LocalIndex.js +519 -0
  72. package/lib/LocalIndex.js.map +1 -0
  73. package/lib/LocalIndex.spec.d.ts +2 -0
  74. package/lib/LocalIndex.spec.js +611 -9
  75. package/lib/LocalIndex.spec.js.map +1 -1
  76. package/lib/OpenAIEmbeddings.d.ts +124 -0
  77. package/lib/OpenAIEmbeddings.d.ts.map +1 -0
  78. package/lib/OpenAIEmbeddings.js +166 -0
  79. package/lib/OpenAIEmbeddings.js.map +1 -0
  80. package/lib/OpenAIEmbeddings.spec.d.ts +2 -0
  81. package/lib/OpenAIEmbeddings.spec.d.ts.map +1 -0
  82. package/lib/OpenAIEmbeddings.spec.js +298 -0
  83. package/lib/OpenAIEmbeddings.spec.js.map +1 -0
  84. package/lib/TextSplitter.d.ts +21 -0
  85. package/lib/TextSplitter.d.ts.map +1 -1
  86. package/lib/TextSplitter.js +500 -0
  87. package/lib/TextSplitter.js.map +1 -0
  88. package/lib/TextSplitter.spec.d.ts +2 -0
  89. package/lib/TextSplitter.spec.d.ts.map +1 -0
  90. package/lib/TextSplitter.spec.js +337 -0
  91. package/lib/TextSplitter.spec.js.map +1 -0
  92. package/lib/TransformersEmbeddings.d.ts +121 -0
  93. package/lib/TransformersEmbeddings.d.ts.map +1 -0
  94. package/lib/TransformersEmbeddings.js +176 -0
  95. package/lib/TransformersEmbeddings.js.map +1 -0
  96. package/lib/TransformersEmbeddings.spec.d.ts +2 -0
  97. package/lib/TransformersEmbeddings.spec.d.ts.map +1 -0
  98. package/lib/TransformersEmbeddings.spec.js +198 -0
  99. package/lib/TransformersEmbeddings.spec.js.map +1 -0
  100. package/lib/TransformersTokenizer.d.ts +33 -0
  101. package/lib/TransformersTokenizer.d.ts.map +1 -0
  102. package/lib/TransformersTokenizer.js +44 -0
  103. package/lib/TransformersTokenizer.js.map +1 -0
  104. package/lib/TransformersTokenizer.spec.d.ts +2 -0
  105. package/lib/TransformersTokenizer.spec.d.ts.map +1 -0
  106. package/lib/TransformersTokenizer.spec.js +112 -0
  107. package/lib/TransformersTokenizer.spec.js.map +1 -0
  108. package/lib/WebFetcher.d.ts +14 -0
  109. package/lib/WebFetcher.d.ts.map +1 -0
  110. package/lib/WebFetcher.js +238 -0
  111. package/lib/WebFetcher.js.map +1 -0
  112. package/lib/WebFetcher.spec.d.ts +2 -0
  113. package/lib/WebFetcher.spec.d.ts.map +1 -0
  114. package/lib/WebFetcher.spec.js +263 -0
  115. package/lib/WebFetcher.spec.js.map +1 -0
  116. package/lib/browser.d.ts +30 -0
  117. package/lib/browser.d.ts.map +1 -0
  118. package/lib/browser.js +52 -0
  119. package/lib/browser.js.map +1 -0
  120. package/lib/codecs/IndexCodec.d.ts +37 -0
  121. package/lib/codecs/IndexCodec.d.ts.map +1 -0
  122. package/lib/codecs/IndexCodec.js +3 -0
  123. package/lib/codecs/IndexCodec.js.map +1 -0
  124. package/lib/codecs/JsonCodec.d.ts +19 -0
  125. package/lib/codecs/JsonCodec.d.ts.map +1 -0
  126. package/lib/codecs/JsonCodec.js +35 -0
  127. package/lib/codecs/JsonCodec.js.map +1 -0
  128. package/lib/codecs/JsonCodec.spec.d.ts +2 -0
  129. package/lib/codecs/JsonCodec.spec.d.ts.map +1 -0
  130. package/lib/codecs/JsonCodec.spec.js +66 -0
  131. package/lib/codecs/JsonCodec.spec.js.map +1 -0
  132. package/lib/codecs/LocalIndex.protobuf.spec.d.ts +2 -0
  133. package/lib/codecs/LocalIndex.protobuf.spec.d.ts.map +1 -0
  134. package/lib/codecs/LocalIndex.protobuf.spec.js +108 -0
  135. package/lib/codecs/LocalIndex.protobuf.spec.js.map +1 -0
  136. package/lib/codecs/ProtobufCodec.d.ts +20 -0
  137. package/lib/codecs/ProtobufCodec.d.ts.map +1 -0
  138. package/lib/codecs/ProtobufCodec.js +225 -0
  139. package/lib/codecs/ProtobufCodec.js.map +1 -0
  140. package/lib/codecs/ProtobufCodec.spec.d.ts +2 -0
  141. package/lib/codecs/ProtobufCodec.spec.d.ts.map +1 -0
  142. package/lib/codecs/ProtobufCodec.spec.js +155 -0
  143. package/lib/codecs/ProtobufCodec.spec.js.map +1 -0
  144. package/lib/codecs/index.d.ts +5 -0
  145. package/lib/codecs/index.d.ts.map +1 -0
  146. package/lib/codecs/index.js +21 -0
  147. package/lib/codecs/index.js.map +1 -0
  148. package/lib/codecs/migrateIndex.d.ts +24 -0
  149. package/lib/codecs/migrateIndex.d.ts.map +1 -0
  150. package/lib/codecs/migrateIndex.js +119 -0
  151. package/lib/codecs/migrateIndex.js.map +1 -0
  152. package/lib/codecs/migrateIndex.spec.d.ts +2 -0
  153. package/lib/codecs/migrateIndex.spec.d.ts.map +1 -0
  154. package/lib/codecs/migrateIndex.spec.js +151 -0
  155. package/lib/codecs/migrateIndex.spec.js.map +1 -0
  156. package/lib/codecs/schemas/index.proto +34 -0
  157. package/lib/index.d.ts +20 -0
  158. package/lib/index.d.ts.map +1 -1
  159. package/lib/index.js +36 -0
  160. package/lib/index.js.map +1 -0
  161. package/lib/internals/Colorize.d.ts +14 -0
  162. package/lib/internals/Colorize.d.ts.map +1 -0
  163. package/lib/internals/Colorize.js +69 -0
  164. package/lib/internals/Colorize.js.map +1 -0
  165. package/lib/internals/index.d.ts +3 -0
  166. package/lib/internals/index.d.ts.map +1 -0
  167. package/lib/internals/index.js +19 -0
  168. package/lib/internals/index.js.map +1 -0
  169. package/lib/internals/types.d.ts +43 -0
  170. package/lib/internals/types.d.ts.map +1 -0
  171. package/lib/internals/types.js +3 -0
  172. package/lib/internals/types.js.map +1 -0
  173. package/lib/server/IndexManager.d.ts +78 -0
  174. package/lib/server/IndexManager.d.ts.map +1 -0
  175. package/lib/server/IndexManager.js +259 -0
  176. package/lib/server/IndexManager.js.map +1 -0
  177. package/lib/server/VectraServer.d.ts +40 -0
  178. package/lib/server/VectraServer.d.ts.map +1 -0
  179. package/lib/server/VectraServer.js +151 -0
  180. package/lib/server/VectraServer.js.map +1 -0
  181. package/lib/server/VectraServer.spec.d.ts +2 -0
  182. package/lib/server/VectraServer.spec.d.ts.map +1 -0
  183. package/lib/server/VectraServer.spec.js +322 -0
  184. package/lib/server/VectraServer.spec.js.map +1 -0
  185. package/lib/server/handlers/documentHandlers.d.ts +15 -0
  186. package/lib/server/handlers/documentHandlers.d.ts.map +1 -0
  187. package/lib/server/handlers/documentHandlers.js +95 -0
  188. package/lib/server/handlers/documentHandlers.js.map +1 -0
  189. package/lib/server/handlers/helpers.d.ts +23 -0
  190. package/lib/server/handlers/helpers.d.ts.map +1 -0
  191. package/lib/server/handlers/helpers.js +138 -0
  192. package/lib/server/handlers/helpers.js.map +1 -0
  193. package/lib/server/handlers/index.d.ts +8 -0
  194. package/lib/server/handlers/index.d.ts.map +1 -0
  195. package/lib/server/handlers/index.js +22 -0
  196. package/lib/server/handlers/index.js.map +1 -0
  197. package/lib/server/handlers/indexHandlers.d.ts +14 -0
  198. package/lib/server/handlers/indexHandlers.d.ts.map +1 -0
  199. package/lib/server/handlers/indexHandlers.js +85 -0
  200. package/lib/server/handlers/indexHandlers.js.map +1 -0
  201. package/lib/server/handlers/itemHandlers.d.ts +34 -0
  202. package/lib/server/handlers/itemHandlers.d.ts.map +1 -0
  203. package/lib/server/handlers/itemHandlers.js +166 -0
  204. package/lib/server/handlers/itemHandlers.js.map +1 -0
  205. package/lib/server/handlers/lifecycleHandlers.d.ts +11 -0
  206. package/lib/server/handlers/lifecycleHandlers.d.ts.map +1 -0
  207. package/lib/server/handlers/lifecycleHandlers.js +31 -0
  208. package/lib/server/handlers/lifecycleHandlers.js.map +1 -0
  209. package/lib/server/handlers/queryHandlers.d.ts +27 -0
  210. package/lib/server/handlers/queryHandlers.d.ts.map +1 -0
  211. package/lib/server/handlers/queryHandlers.js +135 -0
  212. package/lib/server/handlers/queryHandlers.js.map +1 -0
  213. package/lib/server/handlers/statsHandlers.d.ts +17 -0
  214. package/lib/server/handlers/statsHandlers.d.ts.map +1 -0
  215. package/lib/server/handlers/statsHandlers.js +81 -0
  216. package/lib/server/handlers/statsHandlers.js.map +1 -0
  217. package/lib/server/index.d.ts +4 -0
  218. package/lib/server/index.d.ts.map +1 -0
  219. package/lib/server/index.js +23 -0
  220. package/lib/server/index.js.map +1 -0
  221. package/lib/storage/FileStorage.d.ts +92 -0
  222. package/lib/storage/FileStorage.d.ts.map +1 -0
  223. package/lib/storage/FileStorage.js +3 -0
  224. package/lib/storage/FileStorage.js.map +1 -0
  225. package/lib/storage/FileStorageUtilities.d.ts +36 -0
  226. package/lib/storage/FileStorageUtilities.d.ts.map +1 -0
  227. package/lib/storage/FileStorageUtilities.js +91 -0
  228. package/lib/storage/FileStorageUtilities.js.map +1 -0
  229. package/lib/storage/FileStorageUtilities.spec.d.ts +2 -0
  230. package/lib/storage/FileStorageUtilities.spec.d.ts.map +1 -0
  231. package/lib/storage/FileStorageUtilities.spec.js +98 -0
  232. package/lib/storage/FileStorageUtilities.spec.js.map +1 -0
  233. package/lib/storage/FileType.d.ts +29 -0
  234. package/lib/storage/FileType.d.ts.map +1 -0
  235. package/lib/storage/FileType.js +38 -0
  236. package/lib/storage/FileType.js.map +1 -0
  237. package/lib/storage/IndexedDBStorage.d.ts +47 -0
  238. package/lib/storage/IndexedDBStorage.d.ts.map +1 -0
  239. package/lib/storage/IndexedDBStorage.js +347 -0
  240. package/lib/storage/IndexedDBStorage.js.map +1 -0
  241. package/lib/storage/LocalFileStorage.browser.d.ts +19 -0
  242. package/lib/storage/LocalFileStorage.browser.d.ts.map +1 -0
  243. package/lib/storage/LocalFileStorage.browser.js +43 -0
  244. package/lib/storage/LocalFileStorage.browser.js.map +1 -0
  245. package/lib/storage/LocalFileStorage.d.ts +23 -0
  246. package/lib/storage/LocalFileStorage.d.ts.map +1 -0
  247. package/lib/storage/LocalFileStorage.js +152 -0
  248. package/lib/storage/LocalFileStorage.js.map +1 -0
  249. package/lib/storage/LocalFileStorage.spec.d.ts +2 -0
  250. package/lib/storage/LocalFileStorage.spec.d.ts.map +1 -0
  251. package/lib/storage/LocalFileStorage.spec.js +249 -0
  252. package/lib/storage/LocalFileStorage.spec.js.map +1 -0
  253. package/lib/storage/VirtualFileStorage.d.ts +18 -0
  254. package/lib/storage/VirtualFileStorage.d.ts.map +1 -0
  255. package/lib/storage/VirtualFileStorage.js +178 -0
  256. package/lib/storage/VirtualFileStorage.js.map +1 -0
  257. package/lib/storage/VirtualFileStorage.spec.d.ts +2 -0
  258. package/lib/storage/VirtualFileStorage.spec.d.ts.map +1 -0
  259. package/lib/storage/VirtualFileStorage.spec.js +302 -0
  260. package/lib/storage/VirtualFileStorage.spec.js.map +1 -0
  261. package/lib/storage/index.d.ts +6 -0
  262. package/lib/storage/index.d.ts.map +1 -0
  263. package/lib/storage/index.js +22 -0
  264. package/lib/storage/index.js.map +1 -0
  265. package/lib/templates/templates/csharp/README.md +48 -0
  266. package/lib/templates/templates/csharp/VectraClient.cs +234 -0
  267. package/lib/templates/templates/go/README.md +71 -0
  268. package/lib/templates/templates/go/vectra_client.go +322 -0
  269. package/lib/templates/templates/java/README.md +81 -0
  270. package/lib/templates/templates/java/VectraClient.java +232 -0
  271. package/lib/templates/templates/python/README.md +37 -0
  272. package/lib/templates/templates/python/vectra_client.py +279 -0
  273. package/lib/templates/templates/rust/Cargo.toml +14 -0
  274. package/lib/templates/templates/rust/README.md +39 -0
  275. package/lib/templates/templates/rust/build.rs +4 -0
  276. package/lib/templates/templates/rust/lib.rs +284 -0
  277. package/lib/templates/templates/typescript/README.md +96 -0
  278. package/lib/templates/templates/typescript/VectraClient.ts +374 -0
  279. package/lib/templates/typescript/VectraClient.d.ts +114 -0
  280. package/lib/templates/typescript/VectraClient.d.ts.map +1 -0
  281. package/lib/templates/typescript/VectraClient.js +328 -0
  282. package/lib/templates/typescript/VectraClient.js.map +1 -0
  283. package/lib/types.d.ts +153 -0
  284. package/lib/types.d.ts.map +1 -0
  285. package/lib/types.js +3 -0
  286. package/lib/types.js.map +1 -0
  287. package/lib/utils/index.d.ts +2 -0
  288. package/lib/utils/index.d.ts.map +1 -0
  289. package/lib/utils/index.js +18 -0
  290. package/lib/utils/index.js.map +1 -0
  291. package/lib/utils/pathUtils.d.ts +40 -0
  292. package/lib/utils/pathUtils.d.ts.map +1 -0
  293. package/lib/utils/pathUtils.js +98 -0
  294. package/lib/utils/pathUtils.js.map +1 -0
  295. package/lib/vectra-cli.d.ts +2 -0
  296. package/lib/vectra-cli.d.ts.map +1 -1
  297. package/lib/vectra-cli.generate.spec.d.ts +2 -0
  298. package/lib/vectra-cli.generate.spec.d.ts.map +1 -0
  299. package/lib/vectra-cli.generate.spec.js +112 -0
  300. package/lib/vectra-cli.generate.spec.js.map +1 -0
  301. package/lib/vectra-cli.js +760 -0
  302. package/lib/vectra-cli.js.map +1 -0
  303. package/lib/vectra-cli.spec.d.ts +1 -0
  304. package/lib/vectra-cli.spec.d.ts.map +1 -0
  305. package/lib/vectra-cli.spec.js +2 -0
  306. package/lib/vectra-cli.spec.js.map +1 -0
  307. package/package.json +91 -16
  308. package/proto/vectra_service.proto +276 -0
  309. package/src/BrowserWebFetcher.ts +345 -0
  310. package/src/FileFetcher.spec.ts +234 -0
  311. package/src/FileFetcher.ts +37 -25
  312. package/src/FolderWatcher.spec.ts +288 -0
  313. package/src/FolderWatcher.ts +304 -0
  314. package/src/GPT3Tokenizer.spec.ts +50 -0
  315. package/src/ItemSelector.spec.ts +252 -0
  316. package/src/ItemSelector.ts +163 -150
  317. package/src/LocalDocument.spec.ts +211 -0
  318. package/src/LocalDocument.ts +88 -94
  319. package/src/LocalDocumentIndex.spec.ts +481 -0
  320. package/src/LocalDocumentIndex.ts +39 -40
  321. package/src/LocalDocumentResult.spec.ts +373 -0
  322. package/src/LocalDocumentResult.ts +489 -319
  323. package/src/LocalEmbeddings.spec.ts +138 -0
  324. package/src/LocalEmbeddings.ts +120 -0
  325. package/src/LocalIndex.spec.ts +808 -66
  326. package/src/LocalIndex.ts +479 -429
  327. package/src/OpenAIEmbeddings.spec.ts +354 -0
  328. package/src/OpenAIEmbeddings.ts +26 -27
  329. package/src/TextSplitter.spec.ts +342 -0
  330. package/src/TextSplitter.ts +517 -532
  331. package/src/TransformersEmbeddings.spec.ts +188 -0
  332. package/src/TransformersEmbeddings.ts +232 -0
  333. package/src/TransformersTokenizer.spec.ts +143 -0
  334. package/src/TransformersTokenizer.ts +45 -0
  335. package/src/WebFetcher.spec.ts +288 -0
  336. package/src/WebFetcher.ts +184 -186
  337. package/src/browser.ts +69 -0
  338. package/src/codecs/IndexCodec.ts +40 -0
  339. package/src/codecs/JsonCodec.spec.ts +70 -0
  340. package/src/codecs/JsonCodec.ts +37 -0
  341. package/src/codecs/LocalIndex.protobuf.spec.ts +115 -0
  342. package/src/codecs/ProtobufCodec.spec.ts +166 -0
  343. package/src/codecs/ProtobufCodec.ts +193 -0
  344. package/src/codecs/index.ts +4 -0
  345. package/src/codecs/migrateIndex.spec.ts +176 -0
  346. package/src/codecs/migrateIndex.ts +125 -0
  347. package/src/codecs/schemas/index.proto +34 -0
  348. package/src/index.ts +9 -1
  349. package/src/internals/Colorize.ts +19 -16
  350. package/src/server/IndexManager.ts +243 -0
  351. package/src/server/VectraServer.spec.ts +303 -0
  352. package/src/server/VectraServer.ts +156 -0
  353. package/src/server/handlers/documentHandlers.ts +59 -0
  354. package/src/server/handlers/helpers.ts +93 -0
  355. package/src/server/handlers/index.ts +7 -0
  356. package/src/server/handlers/indexHandlers.ts +44 -0
  357. package/src/server/handlers/itemHandlers.ts +140 -0
  358. package/src/server/handlers/lifecycleHandlers.ts +26 -0
  359. package/src/server/handlers/queryHandlers.ts +96 -0
  360. package/src/server/handlers/statsHandlers.ts +38 -0
  361. package/src/server/index.ts +3 -0
  362. package/src/storage/FileStorage.ts +105 -0
  363. package/src/storage/FileStorageUtilities.spec.ts +106 -0
  364. package/src/storage/FileStorageUtilities.ts +77 -0
  365. package/src/storage/FileType.ts +61 -0
  366. package/src/storage/IndexedDBStorage.ts +365 -0
  367. package/src/storage/LocalFileStorage.browser.ts +52 -0
  368. package/src/storage/LocalFileStorage.spec.ts +292 -0
  369. package/src/storage/LocalFileStorage.ts +98 -0
  370. package/src/storage/VirtualFileStorage.spec.ts +307 -0
  371. package/src/storage/VirtualFileStorage.ts +169 -0
  372. package/src/storage/index.ts +5 -0
  373. package/src/templates/csharp/README.md +48 -0
  374. package/src/templates/csharp/VectraClient.cs +234 -0
  375. package/src/templates/go/README.md +71 -0
  376. package/src/templates/go/vectra_client.go +322 -0
  377. package/src/templates/java/README.md +81 -0
  378. package/src/templates/java/VectraClient.java +232 -0
  379. package/src/templates/python/README.md +37 -0
  380. package/src/templates/python/vectra_client.py +279 -0
  381. package/src/templates/rust/Cargo.toml +14 -0
  382. package/src/templates/rust/README.md +39 -0
  383. package/src/templates/rust/build.rs +4 -0
  384. package/src/templates/rust/lib.rs +284 -0
  385. package/src/templates/typescript/README.md +96 -0
  386. package/src/templates/typescript/VectraClient.ts +374 -0
  387. package/src/types.ts +131 -123
  388. package/src/utils/index.ts +1 -0
  389. package/src/utils/pathUtils.ts +106 -0
  390. package/src/vectra-cli.generate.spec.ts +72 -0
  391. package/src/vectra-cli.spec.ts +0 -0
  392. package/src/vectra-cli.ts +687 -246
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.createQueryHandlers = createQueryHandlers;
46
+ const grpc = __importStar(require("@grpc/grpc-js"));
47
+ const helpers_1 = require("./helpers");
48
+ function createQueryHandlers(manager, embeddings) {
49
+ return {
50
+ QueryItems: (0, helpers_1.wrapHandler)((call) => __awaiter(this, void 0, void 0, function* () {
51
+ const req = call.request;
52
+ if (!req.index_name) {
53
+ throw (0, helpers_1.grpcError)(grpc.status.INVALID_ARGUMENT, 'index_name is required');
54
+ }
55
+ const idx = manager.requireIndex(req.index_name).index;
56
+ const topK = req.top_k || 10;
57
+ const filter = (0, helpers_1.parseFilterJson)(req.filter);
58
+ let vector;
59
+ if (req.vector && req.vector.length > 0) {
60
+ vector = req.vector;
61
+ }
62
+ else if (req.text && req.text.length > 0) {
63
+ if (!embeddings) {
64
+ throw (0, helpers_1.grpcError)(grpc.status.FAILED_PRECONDITION, 'No embeddings model configured on the server');
65
+ }
66
+ const response = yield embeddings.createEmbeddings(req.text);
67
+ if (response.status !== 'success' || !response.output) {
68
+ throw (0, helpers_1.grpcError)(grpc.status.INTERNAL, `Embeddings error: ${response.message || 'unknown'}`);
69
+ }
70
+ vector = response.output[0];
71
+ }
72
+ else {
73
+ throw (0, helpers_1.grpcError)(grpc.status.INVALID_ARGUMENT, 'Either text or vector must be provided');
74
+ }
75
+ const results = yield idx.queryItems(vector, req.text || '', topK, filter);
76
+ return {
77
+ results: results.map((r) => ({
78
+ id: r.item.id,
79
+ metadata: (0, helpers_1.toProtoMetadata)(r.item.metadata),
80
+ vector: Array.from(r.item.vector),
81
+ norm: r.item.norm,
82
+ score: r.score,
83
+ })),
84
+ };
85
+ })),
86
+ QueryDocuments: (0, helpers_1.wrapHandler)((call) => __awaiter(this, void 0, void 0, function* () {
87
+ const req = call.request;
88
+ if (!req.index_name) {
89
+ throw (0, helpers_1.grpcError)(grpc.status.INVALID_ARGUMENT, 'index_name is required');
90
+ }
91
+ const { docIndex } = manager.requireDocumentIndex(req.index_name);
92
+ if (!req.query) {
93
+ throw (0, helpers_1.grpcError)(grpc.status.INVALID_ARGUMENT, 'query is required');
94
+ }
95
+ const filter = (0, helpers_1.parseFilterJson)(req.filter);
96
+ const results = yield docIndex.queryDocuments(req.query, {
97
+ maxDocuments: req.max_documents || 10,
98
+ maxChunks: req.max_chunks || 50,
99
+ filter,
100
+ isBm25: req.use_bm25 || false,
101
+ });
102
+ const protoResults = [];
103
+ for (const result of results) {
104
+ const chunks = [];
105
+ for (const chunk of result.chunks) {
106
+ const text = yield (() => __awaiter(this, void 0, void 0, function* () {
107
+ try {
108
+ const doc = result;
109
+ const startPos = chunk.item.metadata.startPos || 0;
110
+ const endPos = chunk.item.metadata.endPos || 0;
111
+ const fullText = yield doc.loadText();
112
+ return fullText.substring(startPos, endPos + 1);
113
+ }
114
+ catch (_a) {
115
+ return '';
116
+ }
117
+ }))();
118
+ chunks.push({
119
+ text,
120
+ score: chunk.score,
121
+ token_count: 0,
122
+ });
123
+ }
124
+ protoResults.push({
125
+ uri: result.uri,
126
+ document_id: result.id,
127
+ chunks,
128
+ score: result.score,
129
+ });
130
+ }
131
+ return { results: protoResults };
132
+ })),
133
+ };
134
+ }
135
+ //# sourceMappingURL=queryHandlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queryHandlers.js","sourceRoot":"","sources":["../../../src/server/handlers/queryHandlers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,kDAyFC;AA/FD,oDAAsC;AAItC,uCAAqF;AAErF,SAAgB,mBAAmB,CAAC,OAAqB,EAAE,UAA4B;IACnF,OAAO;QACH,UAAU,EAAE,IAAA,qBAAW,EAAC,CAAO,IAAoC,EAAE,EAAE;YACnE,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC;YACzB,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;gBAClB,MAAM,IAAA,mBAAS,EAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,wBAAwB,CAAC,CAAC;YAC5E,CAAC;YACD,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,KAAmB,CAAC;YACrE,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;YAC7B,MAAM,MAAM,GAAG,IAAA,yBAAe,EAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAE3C,IAAI,MAAgB,CAAC;YACrB,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACtC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;YACxB,CAAC;iBAAM,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACzC,IAAI,CAAC,UAAU,EAAE,CAAC;oBACd,MAAM,IAAA,mBAAS,EAAC,IAAI,C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Q,GAAG,MAAM,GAAG,CAAC,QAAQ,EAAE,CAAC;4BACtC,OAAO,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;wBACpD,CAAC;wBAAC,WAAM,CAAC;4BACL,OAAO,EAAE,CAAC;wBACd,CAAC;oBACL,CAAC,CAAA,CAAC,EAAE,CAAC;oBACL,MAAM,CAAC,IAAI,CAAC;wBACR,IAAI;wBACJ,KAAK,EAAE,KAAK,CAAC,KAAK;wBAClB,WAAW,EAAE,CAAC;qBACjB,CAAC,CAAC;gBACP,CAAC;gBACD,YAAY,CAAC,IAAI,CAAC;oBACd,GAAG,EAAE,MAAM,CAAC,GAAG;oBACf,WAAW,EAAE,MAAM,CAAC,EAAE;oBACtB,MAAM;oBACN,KAAK,EAAE,MAAM,CAAC,KAAK;iBACtB,CAAC,CAAC;YACP,CAAC;YAED,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;QACrC,CAAC,CAAA,CAAC;KACL,CAAC;AACN,CAAC"}
@@ -0,0 +1,17 @@
1
+ import * as grpc from '@grpc/grpc-js';
2
+ import { IndexManager } from '../IndexManager';
3
+ export declare function createStatsHandlers(manager: IndexManager): {
4
+ GetIndexStats: grpc.handleUnaryCall<any, {
5
+ version: number;
6
+ format: string;
7
+ item_count: number;
8
+ metadata_config_count: number;
9
+ }>;
10
+ GetCatalogStats: grpc.handleUnaryCall<any, {
11
+ version: number;
12
+ document_count: number;
13
+ chunk_count: number;
14
+ metadata_counts: {};
15
+ }>;
16
+ };
17
+ //# sourceMappingURL=statsHandlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statsHandlers.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/statsHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,YAAY;;;;;;;;;;;;;EAgCxD"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.createStatsHandlers = createStatsHandlers;
46
+ const grpc = __importStar(require("@grpc/grpc-js"));
47
+ const helpers_1 = require("./helpers");
48
+ function createStatsHandlers(manager) {
49
+ return {
50
+ GetIndexStats: (0, helpers_1.wrapHandler)((call) => __awaiter(this, void 0, void 0, function* () {
51
+ var _a, _b;
52
+ const req = call.request;
53
+ if (!req.index_name) {
54
+ throw (0, helpers_1.grpcError)(grpc.status.INVALID_ARGUMENT, 'index_name is required');
55
+ }
56
+ const managed = manager.requireIndex(req.index_name);
57
+ const stats = yield managed.index.getIndexStats();
58
+ return {
59
+ version: stats.version,
60
+ format: managed.format,
61
+ item_count: stats.items,
62
+ metadata_config_count: ((_b = (_a = stats.metadata_config) === null || _a === void 0 ? void 0 : _a.indexed) === null || _b === void 0 ? void 0 : _b.length) || 0,
63
+ };
64
+ })),
65
+ GetCatalogStats: (0, helpers_1.wrapHandler)((call) => __awaiter(this, void 0, void 0, function* () {
66
+ const req = call.request;
67
+ if (!req.index_name) {
68
+ throw (0, helpers_1.grpcError)(grpc.status.INVALID_ARGUMENT, 'index_name is required');
69
+ }
70
+ const { docIndex } = manager.requireDocumentIndex(req.index_name);
71
+ const stats = yield docIndex.getCatalogStats();
72
+ return {
73
+ version: stats.version,
74
+ document_count: stats.documents,
75
+ chunk_count: stats.chunks,
76
+ metadata_counts: {},
77
+ };
78
+ })),
79
+ };
80
+ }
81
+ //# sourceMappingURL=statsHandlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statsHandlers.js","sourceRoot":"","sources":["../../../src/server/handlers/statsHandlers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,kDAgCC;AArCD,oDAAsC;AAGtC,uCAAmD;AAEnD,SAAgB,mBAAmB,CAAC,OAAqB;IACrD,OAAO;QACH,aAAa,EAAE,IAAA,qBAAW,EAAC,CAAO,IAAoC,EAAE,EAA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}
@@ -0,0 +1,4 @@
1
+ export { VectraServer, VectraServerConfig } from './VectraServer';
2
+ export { IndexManager, IndexManagerConfig, ManagedIndex } from './IndexManager';
3
+ export * from './handlers';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAChF,cAAc,YAAY,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.IndexManager = exports.VectraServer = void 0;
18
+ var VectraServer_1 = require("./VectraServer");
19
+ Object.defineProperty(exports, "VectraServer", { enumerable: true, get: function () { return VectraServer_1.VectraServer; } });
20
+ var IndexManager_1 = require("./IndexManager");
21
+ Object.defineProperty(exports, "IndexManager", { enumerable: true, get: function () { return IndexManager_1.IndexManager; } });
22
+ __exportStar(require("./handlers"), exports);
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAAkE;AAAzD,4GAAA,YAAY,OAAA;AACrB,+CAAgF;AAAvE,4GAAA,YAAY,OAAA;AACrB,6CAA2B"}
@@ -0,0 +1,92 @@
1
+ import { FileType } from "./FileType";
2
+ /**
3
+ * Filter to apply when listing files.
4
+ */
5
+ export type ListFilesFilter = 'files' | 'folders' | 'all';
6
+ /**
7
+ * Interface implemented by storage plugins.
8
+ */
9
+ export interface FileStorage {
10
+ /**
11
+ * Creates a new file with the given path and content.
12
+ * @remarks
13
+ * Throws an error if the file already exists.
14
+ * @param filePath Path to file to create.
15
+ * @param content Content to write to the file.
16
+ */
17
+ createFile(filePath: string, content: Buffer | string): Promise<void>;
18
+ /**
19
+ * Creates a folder with the given path.
20
+ * @remarks
21
+ * Any missing parent folders will also be created.
22
+ * @param folderPath Path to folder to create.
23
+ */
24
+ createFolder(folderPath: string): Promise<void>;
25
+ /**
26
+ * Deletes the file at the given path if it exists.
27
+ * @param filePath Path to file to delete.
28
+ */
29
+ deleteFile(filePath: string): Promise<void>;
30
+ /**
31
+ * Deletes the folder at the given path if it exists.
32
+ * @remarks
33
+ * All files and folders within the folder will also be deleted.
34
+ * @param folderPath Path to folder to delete.
35
+ */
36
+ deleteFolder(folderPath: string): Promise<void>;
37
+ /**
38
+ * Returns the details of an existing file or folder.
39
+ * @remarks
40
+ * Throws an error if the file or folder does not exist.
41
+ * @param fileOrFolderPath File or folder path to get details for.
42
+ * @returns Details of the file or folder.
43
+ */
44
+ getDetails(fileOrFolderPath: string): Promise<FileDetails>;
45
+ /**
46
+ * Lists all files in the given folder.
47
+ * @param folderPath Folder to list files in.
48
+ * @param filter Optional. Type of entries to return. Defaults to 'all'.
49
+ */
50
+ listFiles(folderPath: string, filter?: ListFilesFilter): Promise<FileDetails[]>;
51
+ /**
52
+ * Returns true if a file or folder exists at the given path.
53
+ * @param fileOrFolderPath File or folder path to check.
54
+ */
55
+ pathExists(fileOrFolderPath: string): Promise<boolean>;
56
+ /**
57
+ * Reads the file at the given path.
58
+ * @param filePath Path to file to read.
59
+ */
60
+ readFile(filePath: string): Promise<Buffer>;
61
+ /**
62
+ * Creates or replaces the file at the given path with the given content.
63
+ * @param filePath Path to file to write.
64
+ * @param content Content to write to the file.
65
+ */
66
+ upsertFile(filePath: string, content: Buffer | string): Promise<void>;
67
+ }
68
+ /**
69
+ * Details of a file or folder.
70
+ */
71
+ export interface FileDetails {
72
+ /**
73
+ * Name of the file or folder.
74
+ */
75
+ name: string;
76
+ /**
77
+ * Path to the file or folder.
78
+ */
79
+ path: string;
80
+ /**
81
+ * True if the entry is a folder.
82
+ */
83
+ isFolder: boolean;
84
+ /**
85
+ * The files type if known.
86
+ * @remarks
87
+ * Based off the file extension. This will be undefined for folders and for extensions that are not
88
+ * in the `FileExt[]` array.
89
+ */
90
+ fileType?: FileType;
91
+ }
92
+ //# sourceMappingURL=FileStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileStorage.d.ts","sourceRoot":"","sources":["../../src/storage/FileStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB;;;;;;OAMG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpE;;;;;OAKG;IACH,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhD;;;OAGG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5C;;;;;OAKG;IACH,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhD;;;;;;OAMG;IACH,UAAU,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAE3D;;;;OAIG;IACH,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAEhF;;;OAGG;IACH,UAAU,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEvD;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE5C;;;;OAIG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACvB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=FileStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileStorage.js","sourceRoot":"","sources":["../../src/storage/FileStorage.ts"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ import { FileStorage } from "./FileStorage";
2
+ import { FileType } from "./FileType";
3
+ /**
4
+ * Utility functions for working with FileStorage abstractions.
5
+ */
6
+ export declare class FileStorageUtilities {
7
+ /**
8
+ * Ensures that a folder exists in the given storage.
9
+ * @param storage Storage to create the folder in.
10
+ * @param folderPath Path to folder to ensure is created.
11
+ */
12
+ static ensureFolderExists(storage: FileStorage, folderPath: string): Promise<void>;
13
+ /**
14
+ * Returns the file type of a file based on its extension.
15
+ * @remarks
16
+ * The file type is determined by the file extension. Only extensions found in the
17
+ * `FileExt[]` array are returned.
18
+ * @param filePath Path to file to get type for.
19
+ * @returns The file type, or undefined if the file type is unknown.
20
+ */
21
+ static getFileType(filePath: string): FileType | undefined;
22
+ /**
23
+ * Maps a content type to a file type.
24
+ * @param contentType Content type to map.
25
+ * @returns File type, or undefined if the content type is unknown.
26
+ */
27
+ static getFileTypeFromContentType(contentType: string): FileType | undefined;
28
+ /**
29
+ * Deletes a file from storage if it exists.
30
+ * @param storage Storage to delete the file from.
31
+ * @param filePath Path to the file to delete.
32
+ * @returns An Error if the file could not be deleted, otherwise undefined.
33
+ */
34
+ static tryDeleteFile(storage: FileStorage, filePath: string): Promise<Error | undefined>;
35
+ }
36
+ //# sourceMappingURL=FileStorageUtilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileStorageUtilities.d.ts","sourceRoot":"","sources":["../../src/storage/FileStorageUtilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAW,QAAQ,EAAkB,MAAM,YAAY,CAAC;AAE/D;;GAEG;AACH,qBAAa,oBAAoB;IAC7B;;;;OAIG;WACiB,kBAAkB,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM/F;;;;;;;OAOG;WACW,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAcjE;;;;OAIG;WACW,0BAA0B,CAAC,WAAW,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAiBnF;;;;;OAKG;WACiB,aAAa,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC;CAQxG"}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.FileStorageUtilities = void 0;
13
+ const FileType_1 = require("./FileType");
14
+ const pathUtils_1 = require("../utils/pathUtils");
15
+ /**
16
+ * Utility functions for working with FileStorage abstractions.
17
+ */
18
+ class FileStorageUtilities {
19
+ /**
20
+ * Ensures that a folder exists in the given storage.
21
+ * @param storage Storage to create the folder in.
22
+ * @param folderPath Path to folder to ensure is created.
23
+ */
24
+ static ensureFolderExists(storage, folderPath) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ if (!(yield storage.pathExists(folderPath))) {
27
+ yield storage.createFolder(folderPath);
28
+ }
29
+ });
30
+ }
31
+ /**
32
+ * Returns the file type of a file based on its extension.
33
+ * @remarks
34
+ * The file type is determined by the file extension. Only extensions found in the
35
+ * `FileExt[]` array are returned.
36
+ * @param filePath Path to file to get type for.
37
+ * @returns The file type, or undefined if the file type is unknown.
38
+ */
39
+ static getFileType(filePath) {
40
+ // Get extension from file
41
+ const ext = pathUtils_1.pathUtils.extname(filePath).toLowerCase();
42
+ if (ext.length > 1) {
43
+ // Ensure the extension is valid
44
+ const fileType = ext.substring(1);
45
+ if (FileType_1.FileExt.includes(fileType)) {
46
+ return fileType;
47
+ }
48
+ }
49
+ return undefined;
50
+ }
51
+ /**
52
+ * Maps a content type to a file type.
53
+ * @param contentType Content type to map.
54
+ * @returns File type, or undefined if the content type is unknown.
55
+ */
56
+ static getFileTypeFromContentType(contentType) {
57
+ if (Object.prototype.hasOwnProperty.call(FileType_1.ContentTypeMap, contentType)) {
58
+ return FileType_1.ContentTypeMap[contentType];
59
+ }
60
+ else {
61
+ // Try to find a matching file type
62
+ const parts = contentType.split('/');
63
+ if (parts.length == 2) {
64
+ const fileType = parts[1].includes('+') ? parts[1].split('+')[0] : parts[1];
65
+ if (FileType_1.FileExt.includes(fileType)) {
66
+ return fileType;
67
+ }
68
+ }
69
+ }
70
+ return undefined;
71
+ }
72
+ /**
73
+ * Deletes a file from storage if it exists.
74
+ * @param storage Storage to delete the file from.
75
+ * @param filePath Path to the file to delete.
76
+ * @returns An Error if the file could not be deleted, otherwise undefined.
77
+ */
78
+ static tryDeleteFile(storage, filePath) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ try {
81
+ yield storage.deleteFile(filePath);
82
+ return undefined;
83
+ }
84
+ catch (err) {
85
+ return err;
86
+ }
87
+ });
88
+ }
89
+ }
90
+ exports.FileStorageUtilities = FileStorageUtilities;
91
+ //# sourceMappingURL=FileStorageUtilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileStorageUtilities.js","sourceRoot":"","sources":["../../src/storage/FileStorageUtilities.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,yCAA+D;AAC/D,kDAAuD;AACvD;;GAEG;AACH,MAAa,oBAAoB;IAC7B;;;;OAIG;IACI,MAAM,CAAO,kBAAkB,CAAC,OAAoB,EAAE,UAAkB;;YAC3E,IAAI,CAAC,CAAA,MAAM,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA,EAAE,CAAC;gBACxC,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;YAC3C,CAAC;QACL,CAAC;KAAA;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,WAAW,CAAC,QAAgB;QACtC,0BAA0B;QAC1B,MAAM,GAAG,GAAG,qBAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;QACjD,IAAI,GAAG,CAAC,M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B,CAAC;QACL,CAAC;KAAA;CACJ;AAtED,oDAsEC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FileStorageUtilities.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileStorageUtilities.spec.d.ts","sourceRoot":"","sources":["../../src/storage/FileStorageUtilities.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const strict_1 = __importDefault(require("node:assert/strict"));
16
+ const sinon_1 = __importDefault(require("sinon"));
17
+ const FileStorageUtilities_1 = require("./FileStorageUtilities");
18
+ describe('FileStorageUtilities', () => {
19
+ afterEach(() => {
20
+ sinon_1.default.restore();
21
+ });
22
+ describe('ensureFolderExists', () => {
23
+ it('does not create the folder when it already exists', () => __awaiter(void 0, void 0, void 0, function* () {
24
+ const folderPath = '/already/there';
25
+ const storage = {
26
+ pathExists: sinon_1.default.stub().resolves(true),
27
+ createFolder: sinon_1.default.stub(),
28
+ };
29
+ yield FileStorageUtilities_1.FileStorageUtilities.ensureFolderExists(storage, folderPath);
30
+ sinon_1.default.assert.calledOnceWithExactly(storage.pathExists, folderPath);
31
+ sinon_1.default.assert.notCalled(storage.createFolder);
32
+ }));
33
+ it('creates the folder when it does not exist', () => __awaiter(void 0, void 0, void 0, function* () {
34
+ const folderPath = '/needs/creation';
35
+ const storage = {
36
+ pathExists: sinon_1.default.stub().resolves(false),
37
+ createFolder: sinon_1.default.stub().resolves(),
38
+ };
39
+ yield FileStorageUtilities_1.FileStorageUtilities.ensureFolderExists(storage, folderPath);
40
+ sinon_1.default.assert.calledOnceWithExactly(storage.pathExists, folderPath);
41
+ sinon_1.default.assert.calledOnceWithExactly(storage.createFolder, folderPath);
42
+ }));
43
+ });
44
+ describe('getFileType', () => {
45
+ it('returns type for known extension (lowercase)', () => {
46
+ strict_1.default.strictEqual(FileStorageUtilities_1.FileStorageUtilities.getFileType('/any/path/file.txt'), 'txt');
47
+ });
48
+ it('returns type for known extension (case-insensitive)', () => {
49
+ strict_1.default.strictEqual(FileStorageUtilities_1.FileStorageUtilities.getFileType('/any/path/FILE.TXT'), 'txt');
50
+ });
51
+ it('returns undefined for unknown extension', () => {
52
+ strict_1.default.strictEqual(FileStorageUtilities_1.FileStorageUtilities.getFileType('/any/path/file.unknown'), undefined);
53
+ });
54
+ it('returns undefined when no extension', () => {
55
+ strict_1.default.strictEqual(FileStorageUtilities_1.FileStorageUtilities.getFileType('/any/path/filename'), undefined);
56
+ });
57
+ it('returns undefined for trailing dot', () => {
58
+ strict_1.default.strictEqual(FileStorageUtilities_1.FileStorageUtilities.getFileType('/any/path/file.'), undefined);
59
+ });
60
+ });
61
+ describe('getFileTypeFromContentType', () => {
62
+ it('returns mapped type when content type is directly mapped', () => {
63
+ strict_1.default.strictEqual(FileStorageUtilities_1.FileStorageUtilities.getFileTypeFromContentType('text/plain'), 'txt');
64
+ });
65
+ it('falls back to subtype when not directly mapped', () => {
66
+ // Not directly mapped but subtype is a known extension
67
+ strict_1.default.strictEqual(FileStorageUtilities_1.FileStorageUtilities.getFileTypeFromContentType('application/png'), 'png');
68
+ });
69
+ it('handles "+" in subtype by using part before plus (may be unknown)', () => {
70
+ strict_1.default.strictEqual(FileStorageUtilities_1.FileStorageUtilities.getFileTypeFromContentType('application/ld+json'), undefined);
71
+ });
72
+ it('returns undefined for invalid content type format (no slash)', () => {
73
+ strict_1.default.strictEqual(FileStorageUtilities_1.FileStorageUtilities.getFileTypeFromContentType('invalid'), undefined);
74
+ });
75
+ });
76
+ describe('tryDeleteFile', () => {
77
+ it('returns undefined on successful delete', () => __awaiter(void 0, void 0, void 0, function* () {
78
+ const filePath = '/tmp/success.bin';
79
+ const storage = {
80
+ deleteFile: sinon_1.default.stub().resolves(),
81
+ };
82
+ const result = yield FileStorageUtilities_1.FileStorageUtilities.tryDeleteFile(storage, filePath);
83
+ sinon_1.default.assert.calledOnceWithExactly(storage.deleteFile, filePath);
84
+ strict_1.default.strictEqual(result, undefined);
85
+ }));
86
+ it('returns the error on failed delete', () => __awaiter(void 0, void 0, void 0, function* () {
87
+ const filePath = '/tmp/fail.bin';
88
+ const error = new Error('boom');
89
+ const storage = {
90
+ deleteFile: sinon_1.default.stub().rejects(error),
91
+ };
92
+ const result = yield FileStorageUtilities_1.FileStorageUtilities.tryDeleteFile(storage, filePath);
93
+ sinon_1.default.assert.calledOnceWithExactly(storage.deleteFile, filePath);
94
+ strict_1.default.strictEqual(result, error);
95
+ }));
96
+ });
97
+ });
98
+ //# sourceMappingURL=FileStorageUtilities.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileStorageUtilities.spec.js","sourceRoot":"","sources":["../../src/storage/FileStorageUtilities.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAAwC;AACxC,kDAA0B;AAC1B,iEAA8D;AAG9D,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,SAAS,CAAC,GAAG,EAAE;QACb,eAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAClC,EAAE,CAAC,mDAAmD,EAAE,GAAS,EAAE;YACjE,MAAM,UAAU,GAAG,gBAAgB,CAAC;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