VectorStoreService
Upgather SDK / VectorStoreService
Class: VectorStoreService
Orchestrates file operations (add/update/remove) in your OpenAI vector store, scoped by eventId in Strapi.
Constructors
new VectorStoreService()
new VectorStoreService(
strapi,logger?):VectorStoreService
Creates an instance of VectorStoreService.
Parameters
strapi
The StrapiService instance for interacting with Strapi CMS
logger?
Optional logger instance. If not provided, uses a silent logger.
Returns
Methods
addFile()
addFile(
eventId,file,options,filename?):Promise<UploadedFile>
Add a new file to the vector store for a given event.
Parameters
eventId
string
Strapi event identifier.
file
File to upload (Buffer, Readable, or FileObject).
FileObject | Buffer<ArrayBufferLike> | Readable
options
The OpenAI key to use. Required: the organization's own key is private to Strapi and is never returned over the API.
filename?
string
Optional filename for buffer uploads.
Returns
Promise<UploadedFile>
The uploaded file information.
Throws
Error if upload or association fails.
getVectorConfig()
getVectorConfig(
eventId,openAiKey):Promise<{openAiKey:string;vectorStoreId:string; }>
Fetches the OpenAI API key and vector-store ID for a given event.
The organization's openai_key is a private Strapi attribute, so it is
never present in a REST response. The key has to come from the caller.
Parameters
eventId
string
The Strapi eventId (api::event.event → eventId)
openAiKey
string
OpenAI key to use for this event's vector store
Returns
Promise<{ openAiKey: string; vectorStoreId: string; }>
An object containing:
- openAiKey: the key that was supplied
- vectorStoreId: the vector store identifier (
VectorStore.vector_store_id)
Throws
Error if no key is supplied, or the event or vector store is missing.
removeFile()
removeFile(
eventId,fileId,options):Promise<FileDeleted&object>
Remove a file from the vector store and delete it from OpenAI's file storage.
Parameters
eventId
string
Strapi event identifier.
fileId
string
ID of the file to remove.
options
The OpenAI key to use. Required: the organization's own key is private to Strapi and is never returned over the API.
Returns
Promise<FileDeleted & object>
The OpenAI delete response (usually { deleted: true }).
Throws
Error if disassociation or deletion fails.
Remarks
This method performs two operations:
- Removes the file association from the vector store
- Deletes the actual file from OpenAI's file storage
updateFile()
updateFile(
eventId,oldFileId,newFile,options,filename?):Promise<UploadedFile>
Replace an existing file in the vector store. Under the hood, disassociates & deletes the old file, then uploads & re-associates.
Parameters
eventId
string
Strapi event identifier.
oldFileId
string
ID of the file to replace.
newFile
New file (Buffer, Readable, or FileObject).
FileObject | Buffer<ArrayBufferLike> | Readable
options
The OpenAI key to use. Required: the organization's own key is private to Strapi and is never returned over the API.
filename?
string
Optional filename for buffer uploads.
Returns
Promise<UploadedFile>
The new uploaded file information.
Throws
Error if any step fails.