
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
Opinionated, fully-typed Typesense client powered by Arktype
bun add tsense arktype
import { type } from "arktype";
import { TSense } from "tsense";
const UsersCollection = new TSense({
name: "users",
schema: type({
"id?": "string",
email: "string",
age: type("number.integer").configure({ type: "int32", sort: true }),
"company?": type.enumerated("netflix", "google").configure({ facet: true }),
"phone?": "string",
name: type("string").configure({ sort: true }),
"work_history?": type({
company: "string",
date: "string",
})
.array()
.configure({ type: "object[]", index: false }),
}),
connection: {
host: "127.0.0.1",
port: 8108,
protocol: "http",
apiKey: "123",
},
defaultSearchField: "name",
validateOnUpsert: true,
});
type User = typeof UsersCollection.infer;
await UsersCollection.create();
await UsersCollection.upsert([
{ id: "1", email: "john@example.com", age: 30, name: "John Doe", company: "netflix" },
{ id: "2", email: "jane@example.com", age: 25, name: "Jane Smith", company: "google" },
]);
const results = await UsersCollection.search({
query: "john",
queryBy: ["name", "email"],
sortBy: ["age:desc", "name:asc"],
filter: {
age: { min: 20 },
OR: [{ company: "google" }, { company: "netflix" }],
},
});
const faceted = await UsersCollection.search({
query: "john",
facetBy: ["company"],
});
const highlighted = await UsersCollection.search({
query: "john",
highlight: true,
});
await UsersCollection.drop();
Use .configure() to set Typesense field options:
type("string").configure({
type: "string",
facet: true,
sort: true,
index: true,
});
| Method/Property | Description |
|---|---|
create() | Creates the collection in Typesense |
drop() | Deletes the collection |
get(id) | Retrieves a document by ID |
delete(id) | Deletes a document by ID |
deleteMany(filter) | Deletes documents matching filter |
update(id, data) | Updates a document by ID |
updateMany(filter, data) | Updates documents matching filter |
upsert(docs) | Inserts or updates documents |
search(options) | Searches the collection |
syncSchema() | Syncs schema (creates/patches collection) |
syncData(options) | Syncs data from external source |
fields | Array of generated field schemas |
Automatically sync schema before the first operation:
const Collection = new TSense({
// ...
autoSyncSchema: true,
});
Or manually:
await Collection.syncSchema();
Sync documents from an external source (database, API, etc.):
const Collection = new TSense({
// ...
dataSync: {
getAllIds: async () => {
return db
.selectFrom("users")
.select("id")
.execute()
.then((rows) => rows.map((r) => r.id));
},
getItems: async (ids) => {
return db.selectFrom("users").where("id", "in", ids).execute();
},
chunkSize: 100, // optional, default 500
},
});
// Full sync
await Collection.syncData();
// Partial sync (specific IDs)
await Collection.syncData({ ids: ["id1", "id2"] });
// Full sync + remove orphan documents
await Collection.syncData({ purge: true });
// Override chunk size
await Collection.syncData({ chunkSize: 50 });
filter: { name: "John" } // Exact match
filter: { age: 30 } // Numeric match
filter: { age: [25, 30, 35] } // IN
filter: { age: { min: 20, max: 40 } } // Range
filter: { name: { not: "John" } } // Not equal
filter: { OR: [{ age: 25 }, { age: 30 }] } // OR conditions
FAQs
Opinionated, fully typed typesense client
We found that tsense demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.