Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor according to Vectorize V2 spec #660

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions worker-sys/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mod r2;
mod schedule;
mod socket;
mod tls_client_auth;
mod vectorize;
mod version;
mod websocket_pair;

Expand All @@ -33,5 +34,6 @@ pub use r2::*;
pub use schedule::*;
pub use socket::*;
pub use tls_client_auth::*;
pub use vectorize::*;
pub use version::*;
pub use websocket_pair::*;
30 changes: 30 additions & 0 deletions worker-sys/src/types/vectorize.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(extends=js_sys::Object)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub type Vectorize;

#[wasm_bindgen(method, catch)]
pub fn insert(this: &Vectorize, vectors: js_sys::Object) -> Result<js_sys::Promise, JsValue>;

#[wasm_bindgen(method, catch)]
pub fn upsert(this: &Vectorize, vectors: js_sys::Object) -> Result<js_sys::Promise, JsValue>;

#[wasm_bindgen(method, catch)]
pub fn describe(this: &Vectorize) -> Result<js_sys::Promise, JsValue>;

#[wasm_bindgen(method, catch)]
pub fn query(
this: &Vectorize,
vector: JsValue,
options: js_sys::Object,
) -> Result<js_sys::Promise, JsValue>;

#[wasm_bindgen(method, catch, js_name = "getByIds")]
pub fn get_by_ids(this: &Vectorize, ids: JsValue) -> Result<js_sys::Promise, JsValue>;

#[wasm_bindgen(method, catch, js_name = "deleteByIds")]
pub fn delete_by_ids(this: &Vectorize, ids: JsValue) -> Result<js_sys::Promise, JsValue>;
}
5 changes: 5 additions & 0 deletions worker/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::fmt::Display;
use crate::d1::D1Database;
#[cfg(feature = "queue")]
use crate::Queue;
use crate::Vectorize;
use crate::{durable::ObjectNamespace, Bucket, DynamicDispatcher, Fetcher, Result};
use crate::{error::Error, hyperdrive::Hyperdrive};

Expand Down Expand Up @@ -89,6 +90,10 @@ impl Env {
pub fn hyperdrive(&self, binding: &str) -> Result<Hyperdrive> {
self.get_binding(binding)
}

pub fn vectorize(&self, binding: &str) -> Result<Vectorize> {
self.get_binding(binding)
}
}

pub trait EnvBinding: Sized + JsCast {
Expand Down
2 changes: 2 additions & 0 deletions worker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ pub use crate::router::{RouteContext, RouteParams, Router};
pub use crate::schedule::*;
pub use crate::socket::*;
pub use crate::streams::*;
pub use crate::vectorize::*;
pub use crate::version::*;
pub use crate::websocket::*;

Expand Down Expand Up @@ -226,6 +227,7 @@ mod schedule;
pub mod send;
mod socket;
mod streams;
mod vectorize;
mod version;
mod websocket;

Expand Down
Loading
Loading