Skip to content

Commit 4b05be7

Browse files
committed
fix(packages/node): update package README and replace NPM_TOKEN with OIDC auth
1 parent d8eb722 commit 4b05be7

File tree

3 files changed

+21
-194
lines changed

3 files changed

+21
-194
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55

66
permissions:
77
contents: write
8-
# id-token: write # TODO: Enable after first release for npm provenance with OIDC
8+
id-token: write
99

1010
jobs:
1111
build:
@@ -328,10 +328,11 @@ jobs:
328328
node-version: '20'
329329
registry-url: 'https://registry.npmjs.org'
330330

331+
- name: update npm # npm 11.5.1 is required for OIDC auth https://docs.npmjs.com/trusted-publishers
332+
run: npm install -g [email protected]
333+
331334
- name: build and publish npm packages
332335
if: steps.tag.outputs.version != ''
333-
env:
334-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
335336
run: |
336337
cd packages/node
337338
@@ -377,17 +378,15 @@ jobs:
377378
platform_name=$(basename "$platform_dir")
378379
echo " Publishing @sqliteai/sqlite-vector-${platform_name}..."
379380
cd "$platform_dir"
380-
npm publish --access public
381-
# TODO: Add --provenance flag after switching to OIDC (requires package to exist first)
381+
npm publish --provenance --access public
382382
cd ..
383383
echo " ✓ Published @sqliteai/sqlite-vector-${platform_name}"
384384
done
385385
cd ..
386386
387387
# Publish main package
388388
echo "Publishing main package to npm..."
389-
npm publish --access public
390-
# TODO: Add --provenance flag after switching to OIDC (requires package to exist first)
389+
npm publish --provenance --access public
391390
echo "✓ Published @sqliteai/sqlite-vector@${{ steps.tag.outputs.version }}"
392391
393392
echo ""

packages/node/README.md

Lines changed: 14 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# @sqliteai/sqlite-vector
22

33
[![npm version](https://badge.fury.io/js/@sqliteai%2Fsqlite-vector.svg)](https://www.npmjs.com/package/@sqliteai/sqlite-vector)
4-
[![License](https://img.shields.io/badge/license-Elastic%202.0-blue.svg)](../../../LICENSE.md)
4+
[![License](https://img.shields.io/badge/license-Elastic%202.0-blue.svg)](LICENSE.md)
55

6-
> SQLite Vector extension for Node.js - Cross-platform vector embeddings and similarity search
6+
> SQLite Vector extension packaged for Node.js
77
8-
**SQLite Vector** brings powerful vector search capabilities to SQLite in Node.js. Perfect for Edge AI, semantic search, RAG applications, and similarity matching - all running locally without external dependencies.
8+
**SQLite Vector** is a cross-platform, ultra-efficient SQLite extension that brings vector search capabilities to your embedded database. It works seamlessly on **iOS, Android, Windows, Linux, and macOS**, using just **30MB of memory** by default. With support for **Float32, Float16, BFloat16, Int8, and UInt8**, and **highly optimized distance functions**, it's the ideal solution for **Edge AI** applications.
99

1010
## Features
1111

1212
-**Cross-platform** - Works on macOS, Linux (glibc/musl), and Windows
1313
-**Zero configuration** - Automatically detects and loads the correct binary for your platform
1414
-**TypeScript native** - Full type definitions included
1515
-**Modern ESM + CJS** - Works with both ES modules and CommonJS
16-
-**Small footprint** - Only downloads binaries for your platform (~30MB)
16+
-**Small footprint** - Only downloads binaries for your platform
1717
-**Offline-ready** - No external services required
1818

1919
## Installation
@@ -36,61 +36,16 @@ The package automatically downloads the correct native extension for your platfo
3636
| Linux | x86_64 (musl/Alpine) | `@sqliteai/sqlite-vector-linux-x86_64-musl` |
3737
| Windows | x86_64 | `@sqliteai/sqlite-vector-win32-x86_64` |
3838

39-
## Usage
39+
## sqlite-vector API
40+
41+
For detailed information on how to use the vector extension features, see the [main documentation](https://github.com/sqliteai/sqlite-vector/blob/main/README.md).
4042

41-
### Basic Usage
43+
## Usage
4244

4345
```typescript
4446
import { getExtensionPath } from '@sqliteai/sqlite-vector';
4547
import Database from 'better-sqlite3';
4648

47-
// Get the path to the vector extension
48-
const extensionPath = getExtensionPath();
49-
50-
// Load it into your SQLite database
51-
const db = new Database(':memory:');
52-
db.loadExtension(extensionPath);
53-
54-
// Use vector functions
55-
db.exec(`
56-
CREATE TABLE embeddings (
57-
id INTEGER PRIMARY KEY,
58-
vector BLOB,
59-
text TEXT
60-
);
61-
`);
62-
63-
// Initialize vector search
64-
db.prepare("SELECT vector_init('embeddings', 'vector', 'type=FLOAT32,dimension=384')").run();
65-
66-
// Insert vectors (using your embedding model)
67-
const embedding = new Float32Array(384);
68-
// ... fill embedding with your model's output
69-
70-
db.prepare('INSERT INTO embeddings (vector, text) VALUES (?, ?)').run(
71-
Buffer.from(embedding.buffer),
72-
'Sample text'
73-
);
74-
75-
// Perform similarity search
76-
const query = new Float32Array(384); // Your query embedding
77-
const results = db.prepare(`
78-
SELECT e.id, e.text, v.distance
79-
FROM embeddings AS e
80-
JOIN vector_quantize_scan('embeddings', 'vector', ?, 10) AS v
81-
ON e.id = v.rowid
82-
ORDER BY v.distance ASC
83-
`).all(Buffer.from(query.buffer));
84-
85-
console.log(results);
86-
```
87-
88-
### CommonJS
89-
90-
```javascript
91-
const { getExtensionPath } = require('@sqliteai/sqlite-vector');
92-
const Database = require('better-sqlite3');
93-
9449
const db = new Database(':memory:');
9550
db.loadExtension(getExtensionPath());
9651

@@ -99,28 +54,9 @@ const version = db.prepare('SELECT vector_version()').pluck().get();
9954
console.log('Vector extension version:', version);
10055
```
10156

102-
### Get Extension Information
103-
104-
```typescript
105-
import { getExtensionInfo } from '@sqliteai/sqlite-vector';
106-
107-
const info = getExtensionInfo();
108-
console.log(info);
109-
// {
110-
// platform: 'darwin-arm64',
111-
// packageName: '@sqliteai/sqlite-vector-darwin-arm64',
112-
// binaryName: 'vector.dylib',
113-
// path: '/path/to/node_modules/@sqliteai/sqlite-vector-darwin-arm64/vector.dylib'
114-
// }
115-
```
116-
11757
## Examples
11858

119-
For complete, runnable examples, see the [sqlite-extensions-guide](https://github.com/sqliteai/sqlite-extensions-guide/tree/main/examples/node):
120-
121-
- **[basic-usage.js](https://github.com/sqliteai/sqlite-extensions-guide/blob/main/examples/node/basic-usage.js)** - Generic extension loading for any @sqliteai extension
122-
- **[semantic-search.js](https://github.com/sqliteai/sqlite-extensions-guide/blob/main/examples/node/semantic-search.js)** - Complete semantic search with OpenAI or on-device embeddings
123-
- **[with-multiple-extensions.js](https://github.com/sqliteai/sqlite-extensions-guide/blob/main/examples/node/with-multiple-extensions.js)** - Loading multiple extensions together (vector + sync + AI + js)
59+
For complete, runnable examples, see the [sqlite-extensions-guide](https://github.com/sqliteai/sqlite-extensions-guide/tree/main/examples/node).
12460

12561
These examples are generic and work with all SQLite extensions: `sqlite-vector`, `sqlite-sync`, `sqlite-js`, and `sqlite-ai`.
12662

@@ -196,131 +132,23 @@ Detects if the system uses musl libc (Alpine Linux, etc.).
196132

197133
Error thrown when the SQLite Vector extension cannot be found for the current platform.
198134

199-
## Vector Search Guide
200-
201-
For detailed information on how to use the vector search features, see the [main documentation](https://github.com/sqliteai/sqlite-vector/blob/main/README.md).
202-
203-
### Quick Reference
204-
205-
```sql
206-
-- Initialize vector column
207-
SELECT vector_init('table', 'column', 'type=FLOAT32,dimension=384');
208-
209-
-- Quantize vectors for faster search
210-
SELECT vector_quantize('table', 'column');
211-
212-
-- Preload into memory for 4-5x speedup
213-
SELECT vector_quantize_preload('table', 'column');
214-
215-
-- Search for similar vectors
216-
SELECT * FROM table AS t
217-
JOIN vector_quantize_scan('table', 'column', <query_vector>, <limit>) AS v
218-
ON t.rowid = v.rowid
219-
ORDER BY v.distance;
220-
```
221-
222-
### Distance Metrics
223-
224-
Specify the distance metric during initialization:
225-
226-
```sql
227-
-- L2 (Euclidean) - default
228-
SELECT vector_init('table', 'column', 'type=FLOAT32,dimension=384,distance=L2');
229-
230-
-- Cosine similarity
231-
SELECT vector_init('table', 'column', 'type=FLOAT32,dimension=384,distance=COSINE');
232-
233-
-- Dot product
234-
SELECT vector_init('table', 'column', 'type=FLOAT32,dimension=384,distance=DOT');
235-
236-
-- L1 (Manhattan)
237-
SELECT vector_init('table', 'column', 'type=FLOAT32,dimension=384,distance=L1');
238-
```
239-
240-
## Troubleshooting
241-
242-
### Extension Not Found
243-
244-
If you get `ExtensionNotFoundError`, try:
245-
246-
```bash
247-
# Force reinstall dependencies
248-
npm install --force
249-
250-
# Or manually install the platform package
251-
npm install @sqliteai/sqlite-vector-darwin-arm64 # Replace with your platform
252-
```
253-
254-
### Platform Not Detected
255-
256-
The package should automatically detect your platform. If detection fails, please [open an issue](https://github.com/sqliteai/sqlite-vector/issues) with:
257-
- Your OS and architecture
258-
- Node.js version
259-
- Output of `node -p "process.platform + '-' + process.arch"`
260-
261-
### Alpine Linux / musl
262-
263-
On Alpine Linux or other musl-based systems, the package automatically detects musl and installs the correct variant. If you encounter issues:
264-
265-
```bash
266-
# Verify musl detection
267-
node -e "console.log(require('@sqliteai/sqlite-vector').isMusl())"
268-
269-
# Should print: true
270-
```
271-
272-
## Development
273-
274-
### Building from Source
275-
276-
```bash
277-
# Clone the repository
278-
git clone https://github.com/sqliteai/sqlite-vector.git
279-
cd sqlite-vector/packages/node
280-
281-
# Install dependencies
282-
npm install
283-
284-
# Build TypeScript
285-
npm run build
286-
287-
# Run tests
288-
npm test
289-
```
290-
291-
### Project Structure
292-
293-
```
294-
packages/node/
295-
├── src/
296-
│ ├── index.ts # Main entry point
297-
│ ├── platform.ts # Platform detection logic
298-
│ └── index.test.ts # Test suite
299-
├── dist/ # Compiled JavaScript (generated)
300-
├── generate-platform-packages.js # Platform package generator
301-
├── package.json
302-
├── tsconfig.json
303-
└── README.md
304-
```
305-
306135
## Related Projects
307136

308-
- **[SQLite-AI](https://github.com/sqliteai/sqlite-ai)** - On-device AI inference and embedding generation
309-
- **[SQLite-Sync](https://github.com/sqliteai/sqlite-sync)** - Sync on-device databases with the cloud
310-
- **[SQLite-JS](https://github.com/sqliteai/sqlite-js)** - Define SQLite functions in JavaScript
137+
- **[@sqliteai/sqlite-ai](https://www.npmjs.com/package/@sqliteai/sqlite-ai)** - On-device AI inference and embedding generation
138+
- **[@sqliteai/sqlite-sync](https://www.npmjs.com/package/@sqliteai/sqlite-sync)** - Sync on-device databases with the cloud
139+
- **[@sqliteai/sqlite-js](https://www.npmjs.com/package/@sqliteai/sqlite-js)** - Define SQLite functions in JavaScript
311140

312141
## License
313142

314-
This project is licensed under the [Elastic License 2.0](../../../LICENSE.md).
143+
This project is licensed under the [Elastic License 2.0](LICENSE.md).
315144

316145
For production or managed service use, please [contact SQLite Cloud, Inc](mailto:[email protected]) for a commercial license.
317146

318147
## Contributing
319148

320-
Contributions are welcome! Please see the [main repository](https://github.com/sqliteai/sqlite-vector) for contribution guidelines.
149+
Contributions are welcome! Please see the [main repository](https://github.com/sqliteai/sqlite-vector) to open an issue.
321150

322151
## Support
323152

324153
- 📖 [Documentation](https://github.com/sqliteai/sqlite-vector/blob/main/API.md)
325154
- 🐛 [Report Issues](https://github.com/sqliteai/sqlite-vector/issues)
326-
- 💬 [Discussions](https://github.com/sqliteai/sqlite-vector/discussions)

src/sqlite-vector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
extern "C" {
2525
#endif
2626

27-
#define SQLITE_VECTOR_VERSION "0.9.46"
27+
#define SQLITE_VECTOR_VERSION "0.9.47"
2828

2929
SQLITE_VECTOR_API int sqlite3_vector_init (sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi);
3030

0 commit comments

Comments
 (0)