@silvermine/quarry 0.0.0-stage → 0.1.1

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jeremy Thomerson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,95 @@
1
- # Temporary Holding Version
1
+ # quarry-node
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A Node.js binding for Quarry: the npm package `@silvermine/quarry`. It gives a JavaScript
4
+ or TypeScript host the [producer API][producer-api] and the
5
+ engine's [entry points][hosts]. The package also contains
6
+ `lambda/bootstrap`, the [Lambda hosts][lambda-hosts] built for
7
+ Linux x64, so one package supplies a deployment's Node.js functions and its build and task
8
+ functions.
9
+
10
+ ```bash
11
+ cd crates/quarry-node
12
+ npm run build -- --linux
13
+ npm test
14
+ npm pack
15
+ ```
16
+
17
+ `npm run build` builds the binding for this machine. With `--linux`, it also builds the
18
+ binding and `lambda/bootstrap` for Linux x64 with `cargo zigbuild`. Install `zig` and
19
+ `cargo-zigbuild` first, and add the Rust target `x86_64-unknown-linux-gnu`. The package
20
+ contains one `.node` file for each platform, and `index.js` loads the file for the
21
+ platform it runs on: macOS on arm64, or Linux on x64 with glibc 2.28 or later. Git ignores
22
+ every file that the build makes, and `npm pack` stops when one of them is not there or is
23
+ older than the source.
24
+
25
+ ## Use
26
+
27
+ ```bash
28
+ npm install @silvermine/quarry
29
+ ```
30
+
31
+ ```js
32
+ const { open } = require('@silvermine/quarry');
33
+
34
+ const quarry = await open({ durableBucket: 'my-durable', servingBucket: 'my-serving--use1-az4--x-s3' });
35
+
36
+ const transaction = await quarry.beginReplace('articles', { schema });
37
+
38
+ await transaction.upsert({
39
+ id: 'article-48112',
40
+ fields: { title: { exact: [ 'storm', 'closes', 'harbor', 'bridge' ] } },
41
+ stored: { title: 'Storm Closes Harbor Bridge' },
42
+ });
43
+
44
+ const commitId = await transaction.commit();
45
+
46
+ await quarry.build('articles');
47
+ await quarry.status('articles', commitId); // { state: 'applied', epoch: 1 }
48
+
49
+ const response = await quarry.search({ index: 'articles', tokens: { exact: [ 'harbor' ] } });
50
+ ```
51
+
52
+ [`index.d.ts`][types] declares every function, option, and error code.
53
+
54
+ * **One `Quarry` for each process.** `open` makes one engine, with its memory cache,
55
+ and one producer. Call it one time and keep the result. A `Quarry` reads the list of
56
+ epochs again only after the index's `refreshSeconds`, as each
57
+ [query worker][reader-protocol] does.
58
+ * **Stores.** `durableBucket` and `servingBucket` select the S3 adapters, with the
59
+ credentials and the region of the environment. `dataDirectory` selects two local
60
+ folders, as the [`quarry` command][command]
61
+ does. The binding has no [allow list][allow-list],
62
+ so the host selects the buckets.
63
+ * **A process that only searches.** `readOnlyServing` makes the binding request
64
+ [read-only sessions][read-only-sessions] on the serving bucket. Then `build` and `gc`
65
+ reject.
66
+ * **JSON.** Documents, schemas, requests, responses, and records are the JSON that the
67
+ Quarry documents specify. The binding sends them to Rust as text and does not rename
68
+ a field.
69
+ * **Errors.** Each failure rejects with an `Error`. Its `message` is Quarry's text, and
70
+ its `code` is the kind of failure: `InvalidRequest` for a document or a request that
71
+ Quarry refuses, `NotFound`, `CorruptData`, `Other` for storage and all other
72
+ failures, and `InvalidArg` for an argument that the binding refuses.
73
+ * **Transactions.** An invalid document rejects, and the transaction stays open without
74
+ it. Await each call before the next call. After `commit`, the transaction is closed.
75
+ * **Build and garbage collection.** `build` and `gc` run in the process, on a thread of
76
+ their own, in the `single` [rebuild mode][rebuild-modes]. A
77
+ function host with a time limit uses the build host in `lambda/bootstrap` for
78
+ rebuilds and merges.
79
+
80
+ ## On AWS Lambda
81
+
82
+ [Quarry on AWS Lambda][lambda] tells how a function sets up the memory
83
+ cache, the disk cache, and the local replica, how it keeps copies running after each
84
+ response, and which indexes it copies at start.
85
+
86
+ [producer-api]: https://github.com/silvermine/quarry/blob/master/docs/producers.md#the-producer-api
87
+ [hosts]: https://github.com/silvermine/quarry/blob/master/docs/run-modes.md#hosts
88
+ [lambda-hosts]: https://github.com/silvermine/quarry/blob/master/docs/run-modes.md#lambda-hosts
89
+ [types]: https://github.com/silvermine/quarry/blob/master/crates/quarry-node/index.d.ts
90
+ [reader-protocol]: https://github.com/silvermine/quarry/blob/master/docs/query.md#reader-protocol
91
+ [command]: https://github.com/silvermine/quarry/blob/master/docs/run-modes.md#the-command-line-tool
92
+ [read-only-sessions]: https://github.com/silvermine/quarry/blob/master/docs/storage.md#s3-adapter
93
+ [allow-list]: https://github.com/silvermine/quarry/blob/master/docs/run-modes.md#the-safety-allow-list
94
+ [rebuild-modes]: https://github.com/silvermine/quarry/blob/master/docs/builder.md#rebuild-modes
95
+ [lambda]: https://github.com/silvermine/quarry/blob/master/docs/lambda.md
package/index.d.ts ADDED
@@ -0,0 +1,281 @@
1
+ // The producer API (docs/producers.md) and the engine's entry points (docs/run-modes.md)
2
+ // for a Node.js host. Requests, responses, documents, and records are the JSON those
3
+ // documents and docs/query.md specify.
4
+
5
+ /**
6
+ * What an error's `code` says failed. Every rejection is an `Error` with Quarry's text as
7
+ * its `message` and one of these as its `code`:
8
+ *
9
+ * * `InvalidArg`: the binding refused an argument, such as a version that is not a
10
+ * whole number, options that name no store, or a transaction used after its commit.
11
+ * * `InvalidRequest`: Quarry refused a document, schema, request, setting, or ID.
12
+ * * `NotFound`: an object Quarry expected does not exist, such as an index with no
13
+ * epoch yet.
14
+ * * `CorruptData`: an object's bytes do not decode as its format.
15
+ * * `Other`: anything else, such as a storage or network failure.
16
+ *
17
+ * An argument of the wrong JavaScript type rejects with a `TypeError` whose `code` is
18
+ * napi's, such as `StringExpected`.
19
+ */
20
+ export type QuarryErrorCode = 'InvalidArg' | 'InvalidRequest' | 'NotFound' | 'CorruptData' | 'Other';
21
+
22
+ export interface QuarryError extends Error {
23
+ code: QuarryErrorCode;
24
+ }
25
+
26
+ /** Give either `durableBucket` (S3) or `dataDirectory` (local), never both. */
27
+ export interface QuarryOptions {
28
+
29
+ /** S3: the durable (general purpose) bucket. */
30
+ durableBucket?: string;
31
+
32
+ /**
33
+ * S3: the serving (S3 Express One Zone directory) bucket. Omit to serve from the
34
+ * durable bucket.
35
+ */
36
+ servingBucket?: string;
37
+
38
+ /**
39
+ * Local stores instead of S3: a data directory, as the command-line tool's `--data`.
40
+ * For tests and local runs.
41
+ */
42
+ dataDirectory?: string;
43
+
44
+ /** The memory cache's size in MiB (the Lambda hosts' `CACHE_MB`). */
45
+ cacheMb?: number;
46
+
47
+ /**
48
+ * Disk cache for the serving tier's small reads: a folder, for example `/tmp`, and
49
+ * its size in MiB (the Lambda query host's `DISK_CACHE_MB`). Give both or neither.
50
+ * The cache keeps its files in the subfolder `quarry-disk-cache`. `open` empties that
51
+ * subfolder and changes nothing else in the folder.
52
+ */
53
+ diskCacheDirectory?: string;
54
+ diskCacheMb?: number;
55
+
56
+ /**
57
+ * Local replica of the serving tier's vector objects: a folder, for example `/tmp`,
58
+ * and its size in MiB (the Lambda query host's `REPLICA_MB`). Give both or neither.
59
+ * Vector reads are never cached in memory, so without a replica every vector query
60
+ * reads its matrices from storage. The replica keeps its copies in the subfolder
61
+ * `quarry-replica`. `open` empties that subfolder and changes nothing else in the
62
+ * folder.
63
+ */
64
+ replicaDirectory?: string;
65
+ replicaMb?: number;
66
+
67
+ /** Ranged reads in flight while copying to the replica; 4 when omitted. */
68
+ replicaStreams?: number;
69
+
70
+ /**
71
+ * For a process that serves many indexes: count the queries of each index, keep only
72
+ * the objects of this many most queried indexes in the memory cache, and copy an index
73
+ * to the replica only when it is queried (the Lambda query host's `HOT_INDEXES`).
74
+ * Without it, the replica copies the vector objects of each index on their first read.
75
+ */
76
+ hotIndexes?: number;
77
+
78
+ /**
79
+ * With `hotIndexes`, the query count an index needs before the replica copies its
80
+ * objects; 4 when omitted.
81
+ */
82
+ replicaMinQueries?: number;
83
+
84
+ /**
85
+ * Indexes to copy to the replica as soon as `open` resolves, most wanted first, for the
86
+ * indexes that the process expects to be busy. `Quarry.warm` copies more later.
87
+ */
88
+ warmIndexes?: string[];
89
+
90
+ /** Which objects of a warm index to copy; `all` when omitted. */
91
+ warmObjects?: WarmObjects;
92
+
93
+ /** Connections to the serving bucket (the Lambda hosts' `MAX_SOCKETS`); 64 when omitted. */
94
+ maxSockets?: number;
95
+
96
+ /**
97
+ * Ask for read-only S3 Express sessions on the serving bucket (the Lambda query host's
98
+ * `READ_ONLY_SERVING`), for a process that only searches. Needs `servingBucket`. Then
99
+ * `build` and `gc` reject, because they write to the serving bucket.
100
+ */
101
+ readOnlyServing?: boolean;
102
+
103
+ /** Compress the parts a transaction writes with gzip, for a slow link to storage. */
104
+ compressParts?: boolean;
105
+ }
106
+
107
+ /**
108
+ * `all`: every object a query may read. `vectors`: the small objects that every query
109
+ * reads and the vector objects, which are the only reads that the memory cache never
110
+ * keeps. `none`: nothing, which makes an index warm no more and removes its copies.
111
+ */
112
+ export type WarmObjects = 'all' | 'vectors' | 'none';
113
+
114
+ export interface ReplicaStats {
115
+ readyObjects: number;
116
+ readyBytes: number;
117
+ pendingObjects: number;
118
+ }
119
+
120
+ export interface QuarryStats {
121
+
122
+ /** What the local replica holds, or `null` without one. */
123
+ replica: ReplicaStats | null;
124
+ isAfterResponseStarted: boolean;
125
+ }
126
+
127
+ export interface ReplaceOptions {
128
+
129
+ /** The index's new schema (docs/schema.md). Required when the index does not exist yet. */
130
+ schema?: object;
131
+
132
+ /** The replace version; the begin time when omitted. */
133
+ replaceVersion?: number;
134
+ }
135
+
136
+ export interface GetOptions {
137
+
138
+ /** The epoch to read; the newest when omitted. */
139
+ epoch?: number;
140
+
141
+ /** The searcher's claims (docs/query.md). */
142
+ claims?: object[];
143
+ }
144
+
145
+ export type TransactionStatus =
146
+ { state: 'pending' } |
147
+ { state: 'applied'; epoch: number } |
148
+ { state: 'rejected'; report: QuarantineReport };
149
+
150
+ /** Why a builder rejected a whole transaction. */
151
+ export interface QuarantineReport {
152
+ commit: string;
153
+ file: string;
154
+ reason: string;
155
+ line: number | null;
156
+ epoch: number;
157
+ builder: string;
158
+ }
159
+
160
+ /**
161
+ * On AWS Lambda, keeps each invocation open after its response while copies to a local
162
+ * replica remain, for up to `budgetMs` (5,000 when omitted), so that a replica fills
163
+ * between requests (docs/lambda.md). Call it while the module of the handler loads: Lambda
164
+ * refuses it later. It blocks until Lambda answers. Returns false outside Lambda. The
165
+ * handler must then record each response, which `wrapHandler` does.
166
+ */
167
+ export function startAfterResponse(options?: { budgetMs?: number }): boolean;
168
+
169
+ /** Tells the binding that the handler has its response. `wrapHandler` calls it. */
170
+ export function recordResponse(): void;
171
+
172
+ /** A handler that records its response when it resolves or rejects. */
173
+ export function wrapHandler<T extends (...args: any[]) => Promise<unknown>>(handler: T): T;
174
+
175
+ /**
176
+ * Opens the stores and makes the engine and the producer that the returned `Quarry`
177
+ * shares for its lifetime. Call it once per process and keep the result.
178
+ */
179
+ export function open(options: QuarryOptions): Promise<Quarry>;
180
+
181
+ /** One engine, with its caches, and one producer. Made by `open`. */
182
+ export class Quarry {
183
+
184
+ private constructor();
185
+
186
+ /** Opens a transaction against the index's live schema. The index must exist. */
187
+ begin(indexId: string): Promise<Transaction>;
188
+
189
+ /**
190
+ * Opens a replace: a transaction that replaces every document of the index and, when
191
+ * a schema is given, the schema. A replace with a schema creates an index.
192
+ */
193
+ beginReplace(indexId: string, options?: ReplaceOptions): Promise<Transaction>;
194
+
195
+ /** What became of a committed transaction. */
196
+ status(indexId: string, commitId: string): Promise<TransactionStatus>;
197
+
198
+ /** Commits a settings change alone. Resolves with the commit ID. */
199
+ setSettings(indexId: string, settings: Record<string, number>): Promise<string>;
200
+
201
+ /** Runs one query. The request and the response are the JSON of docs/query.md. */
202
+ search(request: object): Promise<object>;
203
+
204
+ /** Lists the rewrites a search request would make, without searching. */
205
+ suggest(request: object): Promise<object>;
206
+
207
+ /** Reads documents by ID: `{ index, epoch, documents, reads }`. */
208
+ get(indexId: string, ids: string[], options?: GetOptions): Promise<object>;
209
+
210
+ /**
211
+ * Queues copies of the objects of these indexes to the local replica, most wanted
212
+ * index first, and pins them. The copies run in the background. Resolves with the
213
+ * count of objects; 0 without a replica. `options.objects` is `warmObjects` of `open`
214
+ * when omitted, and replaces what an earlier call gave for the same index.
215
+ *
216
+ * A warm index stays warm: when a search reads a new epoch of it, the objects of that
217
+ * epoch are copied, and the copies of objects that the epoch no longer has are
218
+ * removed. `objects: 'none'` ends that, for example for an index that another
219
+ * replaced.
220
+ */
221
+ warm(indexIds: string[], options?: { objects?: WarmObjects }): Promise<{ objects: number }>;
222
+
223
+ /** What the local replica holds, and whether `startAfterResponse` registered. */
224
+ stats(): Promise<QuarryStats>;
225
+
226
+ /**
227
+ * Runs the builder loop for one index until nothing is due. Resolves with one build
228
+ * record (docs/observability.md) per epoch it committed or attempted.
229
+ */
230
+ build(indexId: string): Promise<object[]>;
231
+
232
+ /**
233
+ * Runs garbage collection for one index, serving-tier sweep included. Resolves with
234
+ * the collection record (docs/observability.md).
235
+ */
236
+ gc(indexId: string): Promise<object>;
237
+ }
238
+
239
+ /**
240
+ * A group of changes to one index that a builder applies all at once, or not at all.
241
+ * Every version is a whole number from 0 through 2^53 - 1; the transaction's begin time
242
+ * in milliseconds when omitted. Await each call before the next.
243
+ */
244
+ export class Transaction {
245
+
246
+ private constructor();
247
+
248
+ /**
249
+ * Adds or replaces a whole document: an upsert operation (docs/producers.md) without
250
+ * its `op` and `version`. Rejects with `InvalidRequest` for an invalid document; the
251
+ * transaction stays usable and the document is not added.
252
+ */
253
+ upsert(document: object, version?: number): Promise<void>;
254
+
255
+ /** Deletes one document by ID. */
256
+ delete(id: string, version?: number): Promise<void>;
257
+
258
+ /**
259
+ * Deletes every document that matches all the filters and whose version is less than
260
+ * `version`.
261
+ */
262
+ deleteWhere(filters: object[], version?: number): Promise<void>;
263
+
264
+ /** Records the analysis fingerprint of each field variant's tokens. */
265
+ setAnalysis(fingerprints: Record<string, string>): Promise<void>;
266
+
267
+ /**
268
+ * Changes index settings (docs/builder.md) as of the epoch that applies the transaction.
269
+ * A replace that creates an index sets them for its first epoch.
270
+ */
271
+ setSettings(settings: Record<string, number>): Promise<void>;
272
+
273
+ /** Waits for every part written so far. Optional: `commit` waits too. */
274
+ flush(): Promise<void>;
275
+
276
+ /**
277
+ * Writes the commit record and resolves with the commit ID, a KSUID. The transaction
278
+ * cannot be used afterwards, whether or not the commit succeeded.
279
+ */
280
+ commit(): Promise<string>;
281
+ }
package/index.js ADDED
@@ -0,0 +1,198 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+
5
+ // The binaries this package ships, by Node's platform and architecture. Lambda runs
6
+ // Linux on glibc, which is what the linux build links against.
7
+ const BINARIES = {
8
+ 'darwin-arm64': 'quarry-node.darwin-arm64.node',
9
+ 'linux-x64': 'quarry-node.linux-x64-gnu.node',
10
+ };
11
+
12
+ const binary = BINARIES[`${process.platform}-${process.arch}`];
13
+
14
+ if (!binary) {
15
+ throw new Error(`@silvermine/quarry has no binary for ${process.platform}-${process.arch}`);
16
+ }
17
+
18
+ const native = require(path.join(__dirname, binary));
19
+
20
+ function invalidArg(message) {
21
+ const error = new TypeError(message);
22
+
23
+ error.code = 'InvalidArg';
24
+ return error;
25
+ }
26
+
27
+ // Requests, documents, and options cross into Rust as JSON text.
28
+ function toJson(value, name) {
29
+ const json = JSON.stringify(value);
30
+
31
+ if (typeof json !== 'string') {
32
+ throw invalidArg(`${name} must be a value that JSON can hold; it is ${String(value)}`);
33
+ }
34
+
35
+ return json;
36
+ }
37
+
38
+ function toOptionalJson(value, name) {
39
+ return value === undefined ? undefined : toJson(value, name);
40
+ }
41
+
42
+ // A napi `async` method can reject only with napi's own status, so every native method
43
+ // resolves with either its result as JSON text or Quarry's error as a value, and this
44
+ // rejects with an `Error` whose `code` names the kind of failure.
45
+ async function settle(pending) {
46
+ const { value, error } = await pending;
47
+
48
+ if (error) {
49
+ const thrown = new Error(error.message);
50
+
51
+ thrown.code = error.code;
52
+ throw thrown;
53
+ }
54
+
55
+ return typeof value === 'string' ? JSON.parse(value) : undefined;
56
+ }
57
+
58
+ class Transaction {
59
+
60
+ #native;
61
+
62
+ constructor(nativeTransaction) {
63
+ this.#native = nativeTransaction;
64
+ }
65
+
66
+ async upsert(document, version) {
67
+ await settle(this.#native.upsert(toJson(document, 'document'), version));
68
+ }
69
+
70
+ async delete(id, version) {
71
+ await settle(this.#native.delete(id, version));
72
+ }
73
+
74
+ async deleteWhere(filters, version) {
75
+ await settle(this.#native.deleteWhere(toJson(filters, 'filters'), version));
76
+ }
77
+
78
+ async setAnalysis(fingerprints) {
79
+ await settle(this.#native.setAnalysis(toJson(fingerprints, 'fingerprints')));
80
+ }
81
+
82
+ async setSettings(settings) {
83
+ await settle(this.#native.setSettings(toJson(settings, 'settings')));
84
+ }
85
+
86
+ async flush() {
87
+ await settle(this.#native.flush());
88
+ }
89
+
90
+ async commit() {
91
+ return settle(this.#native.commit());
92
+ }
93
+
94
+ }
95
+
96
+ class Quarry {
97
+
98
+ #native;
99
+
100
+ constructor(nativeQuarry) {
101
+ this.#native = nativeQuarry;
102
+ }
103
+
104
+ async begin(indexId) {
105
+ const transaction = this.#native.transaction();
106
+
107
+ await settle(transaction.begin(indexId));
108
+ return new Transaction(transaction);
109
+ }
110
+
111
+ async beginReplace(indexId, options) {
112
+ const transaction = this.#native.transaction();
113
+
114
+ await settle(transaction.beginReplace(indexId, toOptionalJson(options, 'options')));
115
+ return new Transaction(transaction);
116
+ }
117
+
118
+ async status(indexId, commitId) {
119
+ return settle(this.#native.status(indexId, commitId));
120
+ }
121
+
122
+ async setSettings(indexId, settings) {
123
+ return settle(this.#native.setSettings(indexId, toJson(settings, 'settings')));
124
+ }
125
+
126
+ async search(request) {
127
+ return settle(this.#native.search(toJson(request, 'request')));
128
+ }
129
+
130
+ async suggest(request) {
131
+ return settle(this.#native.suggest(toJson(request, 'request')));
132
+ }
133
+
134
+ async get(indexId, ids, options) {
135
+ return settle(this.#native.get(indexId, ids, toOptionalJson(options, 'options')));
136
+ }
137
+
138
+ async warm(indexIds, options) {
139
+ return settle(this.#native.warm(indexIds, toOptionalJson(options, 'options')));
140
+ }
141
+
142
+ async stats() {
143
+ return settle(this.#native.stats());
144
+ }
145
+
146
+ async build(indexId) {
147
+ return settle(this.#native.build(indexId));
148
+ }
149
+
150
+ async gc(indexId) {
151
+ return settle(this.#native.gc(indexId));
152
+ }
153
+
154
+ }
155
+
156
+ async function open(options) {
157
+ const quarry = new native.Quarry();
158
+
159
+ await settle(quarry.open(toJson(options, 'options')));
160
+ return new Quarry(quarry);
161
+ }
162
+
163
+ // Lambda takes the registration of an extension only while the function starts, and a
164
+ // module that loads cannot wait for a promise, so this call blocks until Lambda answers.
165
+ function startAfterResponse(options) {
166
+ const budgetMs = options === undefined ? 5000 : options.budgetMs;
167
+
168
+ if (typeof budgetMs !== 'number') {
169
+ throw invalidArg('budgetMs must be a number of milliseconds');
170
+ }
171
+
172
+ return native.startAfterResponse(budgetMs);
173
+ }
174
+
175
+ function recordResponse() {
176
+ native.recordResponse();
177
+ }
178
+
179
+ // The extension waits for each handler call to end before it lets background work go on,
180
+ // so a handler that never records its response holds its invocation open.
181
+ function wrapHandler(handler) {
182
+ return async function(...args) {
183
+ try {
184
+ return await handler.apply(this, args);
185
+ } finally {
186
+ recordResponse();
187
+ }
188
+ };
189
+ }
190
+
191
+ module.exports = {
192
+ open,
193
+ startAfterResponse,
194
+ recordResponse,
195
+ wrapHandler,
196
+ Quarry,
197
+ Transaction,
198
+ };
Binary file
package/package.json CHANGED
@@ -1,6 +1,35 @@
1
1
  {
2
- "name": "@silvermine/quarry",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@silvermine/quarry",
3
+ "version": "0.1.1",
4
+ "description": "Node.js binding for Quarry, a serverless hybrid search engine that keeps its index in object storage",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "files": [
8
+ "index.js",
9
+ "index.d.ts",
10
+ "*.node",
11
+ "lambda/bootstrap"
12
+ ],
13
+ "scripts": {
14
+ "build": "node scripts/build.mjs",
15
+ "prepack": "node scripts/check-package.mjs",
16
+ "test": "node --test test/*.test.js"
17
+ },
18
+ "author": "Jeremy Thomerson",
19
+ "license": "MIT",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/silvermine/quarry.git",
23
+ "directory": "crates/quarry-node"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/silvermine/quarry/issues"
27
+ },
28
+ "homepage": "https://github.com/silvermine/quarry#readme",
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "engines": {
33
+ "node": ">=20"
34
+ }
35
+ }
Binary file
Binary file