@moltendb-web/query 1.0.0-rc.3 → 1.0.0-rc.4
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/README.md +8 -8
- package/dist/index.d.ts +7 -7
- package/dist/index.esm.js +10 -10
- package/dist/index.js +11 -11
- package/package.json +2 -2
- package/src/index.ts +11 -11
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# @moltendb-web/query
|
|
2
2
|
|
|
3
|
-
Type-safe, chainable query builder for [
|
|
3
|
+
Type-safe, chainable query builder for [MoltenDb](https://github.com/maximilian27/MoltenDb).
|
|
4
4
|
|
|
5
5
|
Works in vanilla JavaScript and TypeScript. Compiles as an npm module (CJS + ESM + `.d.ts`).
|
|
6
6
|
|
|
7
7
|
### 🌋 Explore the Full Functionality
|
|
8
8
|
|
|
9
|
-
The best way to experience the
|
|
9
|
+
The best way to experience the MoltenDb query builder is through our **[Interactive Demo on StackBlitz](https://stackblitz.com/~/github.com/maximilian27/moltendb-wasm-demo?file=package.json)**. It contains a complete, live environment where you can test query builder expressions, perform mutations, and see real-time events without any local setup.
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
@@ -21,15 +21,15 @@ npm install @moltendb-web/query
|
|
|
21
21
|
## Quick start
|
|
22
22
|
|
|
23
23
|
```ts
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
24
|
+
import { MoltenDb } from '@moltendb-web/core';
|
|
25
|
+
import { MoltenDbClient, WorkerTransport } from '@moltendb-web/query';
|
|
26
26
|
|
|
27
27
|
// 1. Initialize the Core Engine (boots WASM worker)
|
|
28
|
-
const db = new
|
|
28
|
+
const db = new MoltenDb('moltendb_demo');
|
|
29
29
|
await db.init();
|
|
30
30
|
|
|
31
31
|
// 2. Connect the Query Builder to the worker
|
|
32
|
-
const client = new
|
|
32
|
+
const client = new MoltenDbClient(db);
|
|
33
33
|
|
|
34
34
|
// SET — insert / upsert
|
|
35
35
|
await client.collection('laptops')
|
|
@@ -196,7 +196,7 @@ await client.collection('laptops')
|
|
|
196
196
|
Implement `MoltenTransport` to connect to any backend:
|
|
197
197
|
|
|
198
198
|
```ts
|
|
199
|
-
import { MoltenTransport,
|
|
199
|
+
import { MoltenTransport, MoltenDbClient, Document, JsonValue } from '@moltendb-web/query';
|
|
200
200
|
|
|
201
201
|
class FetchTransport implements MoltenTransport {
|
|
202
202
|
constructor(private baseUrl: string, private token: string) {}
|
|
@@ -214,7 +214,7 @@ class FetchTransport implements MoltenTransport {
|
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
const db = new
|
|
217
|
+
const db = new MoltenDbClient(new FetchTransport('[https://api.mydomain.com](https://api.mydomain.com)', myToken));
|
|
218
218
|
```
|
|
219
219
|
|
|
220
220
|
---
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
3
3
|
[key: string]: JsonValue;
|
|
4
4
|
};
|
|
5
|
-
/** A document stored in
|
|
5
|
+
/** A document stored in MoltenDb — any object with string keys. */
|
|
6
6
|
export type Document = {
|
|
7
7
|
[key: string]: JsonValue;
|
|
8
8
|
};
|
|
@@ -54,7 +54,7 @@ export type ExtendsMap = {
|
|
|
54
54
|
[alias: string]: string;
|
|
55
55
|
};
|
|
56
56
|
/**
|
|
57
|
-
* The transport layer used by
|
|
57
|
+
* The transport layer used by MoltenDbClient to send messages.
|
|
58
58
|
* Implement this interface to connect the query builder to any backend:
|
|
59
59
|
* - A Web Worker (WASM in-browser)
|
|
60
60
|
* - A fetch-based HTTP client
|
|
@@ -269,7 +269,7 @@ export declare class DeleteQuery {
|
|
|
269
269
|
}
|
|
270
270
|
/**
|
|
271
271
|
* A handle to a specific collection.
|
|
272
|
-
* Returned by `
|
|
272
|
+
* Returned by `MoltenDbClient.collection(name)`.
|
|
273
273
|
* Use it to start any of the four operation builders.
|
|
274
274
|
*/
|
|
275
275
|
export declare class CollectionHandle {
|
|
@@ -313,17 +313,17 @@ export declare class CollectionHandle {
|
|
|
313
313
|
delete(): DeleteQuery;
|
|
314
314
|
}
|
|
315
315
|
/**
|
|
316
|
-
* The main entry point for the
|
|
316
|
+
* The main entry point for the MoltenDb query builder.
|
|
317
317
|
*
|
|
318
318
|
* Accepts any {@link MoltenTransport} implementation — use {@link WorkerTransport}
|
|
319
|
-
* to connect to a
|
|
319
|
+
* to connect to a MoltenDb WASM Web Worker, or provide your own transport
|
|
320
320
|
* for HTTP, WebSocket, or testing.
|
|
321
321
|
*
|
|
322
322
|
* @example
|
|
323
323
|
* // Browser + WASM Web Worker
|
|
324
324
|
* const worker = new Worker('./moltendb-worker.js', { type: 'module' });
|
|
325
325
|
* const transport = new WorkerTransport(worker);
|
|
326
|
-
* const db = new
|
|
326
|
+
* const db = new MoltenDbClient(transport);
|
|
327
327
|
*
|
|
328
328
|
* const results = await db.collection('laptops')
|
|
329
329
|
* .get()
|
|
@@ -332,7 +332,7 @@ export declare class CollectionHandle {
|
|
|
332
332
|
* .count(5)
|
|
333
333
|
* .exec();
|
|
334
334
|
*/
|
|
335
|
-
export declare class
|
|
335
|
+
export declare class MoltenDbClient {
|
|
336
336
|
private transport;
|
|
337
337
|
constructor(transport: MoltenTransport);
|
|
338
338
|
/**
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// ───
|
|
2
|
-
// Chainable, type-safe query builder for
|
|
1
|
+
// ─── MoltenDb Query Builder ───────────────────────────────────────────────────
|
|
2
|
+
// Chainable, type-safe query builder for MoltenDb.
|
|
3
3
|
//
|
|
4
4
|
// Each operation has its own builder class that only exposes the methods
|
|
5
5
|
// that are valid for that operation — matching the server's allowed-property
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
//
|
|
14
14
|
// Usage (vanilla JS or TypeScript):
|
|
15
15
|
//
|
|
16
|
-
// const db = new
|
|
16
|
+
// const db = new MoltenDbClient(worker);
|
|
17
17
|
//
|
|
18
18
|
// // GET — chainable query
|
|
19
19
|
// const results = await db.collection('laptops')
|
|
@@ -326,7 +326,7 @@ export { DeleteQuery as DeleteQuery };
|
|
|
326
326
|
// ─── CollectionHandle ─────────────────────────────────────────────────────────
|
|
327
327
|
/**
|
|
328
328
|
* A handle to a specific collection.
|
|
329
|
-
* Returned by `
|
|
329
|
+
* Returned by `MoltenDbClient.collection(name)`.
|
|
330
330
|
* Use it to start any of the four operation builders.
|
|
331
331
|
*/
|
|
332
332
|
class CollectionHandle {
|
|
@@ -379,19 +379,19 @@ class CollectionHandle {
|
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
export { CollectionHandle as CollectionHandle };
|
|
382
|
-
// ───
|
|
382
|
+
// ─── MoltenDbClient ───────────────────────────────────────────────────────────
|
|
383
383
|
/**
|
|
384
|
-
* The main entry point for the
|
|
384
|
+
* The main entry point for the MoltenDb query builder.
|
|
385
385
|
*
|
|
386
386
|
* Accepts any {@link MoltenTransport} implementation — use {@link WorkerTransport}
|
|
387
|
-
* to connect to a
|
|
387
|
+
* to connect to a MoltenDb WASM Web Worker, or provide your own transport
|
|
388
388
|
* for HTTP, WebSocket, or testing.
|
|
389
389
|
*
|
|
390
390
|
* @example
|
|
391
391
|
* // Browser + WASM Web Worker
|
|
392
392
|
* const worker = new Worker('./moltendb-worker.js', { type: 'module' });
|
|
393
393
|
* const transport = new WorkerTransport(worker);
|
|
394
|
-
* const db = new
|
|
394
|
+
* const db = new MoltenDbClient(transport);
|
|
395
395
|
*
|
|
396
396
|
* const results = await db.collection('laptops')
|
|
397
397
|
* .get()
|
|
@@ -400,7 +400,7 @@ export { CollectionHandle as CollectionHandle };
|
|
|
400
400
|
* .count(5)
|
|
401
401
|
* .exec();
|
|
402
402
|
*/
|
|
403
|
-
class
|
|
403
|
+
class MoltenDbClient {
|
|
404
404
|
constructor(transport) {
|
|
405
405
|
this.transport = transport;
|
|
406
406
|
}
|
|
@@ -414,5 +414,5 @@ class MoltenDBClient {
|
|
|
414
414
|
return new CollectionHandle(this.transport, name);
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
|
-
export {
|
|
417
|
+
export { MoltenDbClient as MoltenDbClient };
|
|
418
418
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// ───
|
|
3
|
-
// Chainable, type-safe query builder for
|
|
2
|
+
// ─── MoltenDb Query Builder ───────────────────────────────────────────────────
|
|
3
|
+
// Chainable, type-safe query builder for MoltenDb.
|
|
4
4
|
//
|
|
5
5
|
// Each operation has its own builder class that only exposes the methods
|
|
6
6
|
// that are valid for that operation — matching the server's allowed-property
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
//
|
|
15
15
|
// Usage (vanilla JS or TypeScript):
|
|
16
16
|
//
|
|
17
|
-
// const db = new
|
|
17
|
+
// const db = new MoltenDbClient(worker);
|
|
18
18
|
//
|
|
19
19
|
// // GET — chainable query
|
|
20
20
|
// const results = await db.collection('laptops')
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
// await db.collection('laptops').delete().drop().exec();
|
|
42
42
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
43
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
exports.
|
|
44
|
+
exports.MoltenDbClient = exports.CollectionHandle = exports.DeleteQuery = exports.UpdateQuery = exports.SetQuery = exports.GetQuery = void 0;
|
|
45
45
|
// ─── GetQuery ─────────────────────────────────────────────────────────────────
|
|
46
46
|
/**
|
|
47
47
|
* Builder for GET (read/query) operations.
|
|
@@ -328,7 +328,7 @@ exports.DeleteQuery = DeleteQuery;
|
|
|
328
328
|
// ─── CollectionHandle ─────────────────────────────────────────────────────────
|
|
329
329
|
/**
|
|
330
330
|
* A handle to a specific collection.
|
|
331
|
-
* Returned by `
|
|
331
|
+
* Returned by `MoltenDbClient.collection(name)`.
|
|
332
332
|
* Use it to start any of the four operation builders.
|
|
333
333
|
*/
|
|
334
334
|
class CollectionHandle {
|
|
@@ -381,19 +381,19 @@ class CollectionHandle {
|
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
383
|
exports.CollectionHandle = CollectionHandle;
|
|
384
|
-
// ───
|
|
384
|
+
// ─── MoltenDbClient ───────────────────────────────────────────────────────────
|
|
385
385
|
/**
|
|
386
|
-
* The main entry point for the
|
|
386
|
+
* The main entry point for the MoltenDb query builder.
|
|
387
387
|
*
|
|
388
388
|
* Accepts any {@link MoltenTransport} implementation — use {@link WorkerTransport}
|
|
389
|
-
* to connect to a
|
|
389
|
+
* to connect to a MoltenDb WASM Web Worker, or provide your own transport
|
|
390
390
|
* for HTTP, WebSocket, or testing.
|
|
391
391
|
*
|
|
392
392
|
* @example
|
|
393
393
|
* // Browser + WASM Web Worker
|
|
394
394
|
* const worker = new Worker('./moltendb-worker.js', { type: 'module' });
|
|
395
395
|
* const transport = new WorkerTransport(worker);
|
|
396
|
-
* const db = new
|
|
396
|
+
* const db = new MoltenDbClient(transport);
|
|
397
397
|
*
|
|
398
398
|
* const results = await db.collection('laptops')
|
|
399
399
|
* .get()
|
|
@@ -402,7 +402,7 @@ exports.CollectionHandle = CollectionHandle;
|
|
|
402
402
|
* .count(5)
|
|
403
403
|
* .exec();
|
|
404
404
|
*/
|
|
405
|
-
class
|
|
405
|
+
class MoltenDbClient {
|
|
406
406
|
constructor(transport) {
|
|
407
407
|
this.transport = transport;
|
|
408
408
|
}
|
|
@@ -416,5 +416,5 @@ class MoltenDBClient {
|
|
|
416
416
|
return new CollectionHandle(this.transport, name);
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
|
-
exports.
|
|
419
|
+
exports.MoltenDbClient = MoltenDbClient;
|
|
420
420
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moltendb-web/query",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
4
|
-
"description": "Type-safe query builder for
|
|
3
|
+
"version": "1.0.0-rc.4",
|
|
4
|
+
"description": "Type-safe query builder for MoltenDb — chainable API for get, set, update and delete operations.",
|
|
5
5
|
"author": "Maximilian Both <maximilian.both27@outlook.com>",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.esm.js",
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// ───
|
|
2
|
-
// Chainable, type-safe query builder for
|
|
1
|
+
// ─── MoltenDb Query Builder ───────────────────────────────────────────────────
|
|
2
|
+
// Chainable, type-safe query builder for MoltenDb.
|
|
3
3
|
//
|
|
4
4
|
// Each operation has its own builder class that only exposes the methods
|
|
5
5
|
// that are valid for that operation — matching the server's allowed-property
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
//
|
|
14
14
|
// Usage (vanilla JS or TypeScript):
|
|
15
15
|
//
|
|
16
|
-
// const db = new
|
|
16
|
+
// const db = new MoltenDbClient(worker);
|
|
17
17
|
//
|
|
18
18
|
// // GET — chainable query
|
|
19
19
|
// const results = await db.collection('laptops')
|
|
@@ -51,7 +51,7 @@ export type JsonValue =
|
|
|
51
51
|
| JsonValue[]
|
|
52
52
|
| { [key: string]: JsonValue };
|
|
53
53
|
|
|
54
|
-
/** A document stored in
|
|
54
|
+
/** A document stored in MoltenDb — any object with string keys. */
|
|
55
55
|
export type Document = { [key: string]: JsonValue };
|
|
56
56
|
|
|
57
57
|
/** A map of document key → document body used in set/update payloads. */
|
|
@@ -114,7 +114,7 @@ export type ExtendsMap = { [alias: string]: string };
|
|
|
114
114
|
// ── Transport interface ───────────────────────────────────────────────────────
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
|
-
* The transport layer used by
|
|
117
|
+
* The transport layer used by MoltenDbClient to send messages.
|
|
118
118
|
* Implement this interface to connect the query builder to any backend:
|
|
119
119
|
* - A Web Worker (WASM in-browser)
|
|
120
120
|
* - A fetch-based HTTP client
|
|
@@ -447,7 +447,7 @@ export class DeleteQuery {
|
|
|
447
447
|
|
|
448
448
|
/**
|
|
449
449
|
* A handle to a specific collection.
|
|
450
|
-
* Returned by `
|
|
450
|
+
* Returned by `MoltenDbClient.collection(name)`.
|
|
451
451
|
* Use it to start any of the four operation builders.
|
|
452
452
|
*/
|
|
453
453
|
export class CollectionHandle {
|
|
@@ -507,20 +507,20 @@ export class CollectionHandle {
|
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
509
|
|
|
510
|
-
// ───
|
|
510
|
+
// ─── MoltenDbClient ───────────────────────────────────────────────────────────
|
|
511
511
|
|
|
512
512
|
/**
|
|
513
|
-
* The main entry point for the
|
|
513
|
+
* The main entry point for the MoltenDb query builder.
|
|
514
514
|
*
|
|
515
515
|
* Accepts any {@link MoltenTransport} implementation — use {@link WorkerTransport}
|
|
516
|
-
* to connect to a
|
|
516
|
+
* to connect to a MoltenDb WASM Web Worker, or provide your own transport
|
|
517
517
|
* for HTTP, WebSocket, or testing.
|
|
518
518
|
*
|
|
519
519
|
* @example
|
|
520
520
|
* // Browser + WASM Web Worker
|
|
521
521
|
* const worker = new Worker('./moltendb-worker.js', { type: 'module' });
|
|
522
522
|
* const transport = new WorkerTransport(worker);
|
|
523
|
-
* const db = new
|
|
523
|
+
* const db = new MoltenDbClient(transport);
|
|
524
524
|
*
|
|
525
525
|
* const results = await db.collection('laptops')
|
|
526
526
|
* .get()
|
|
@@ -529,7 +529,7 @@ export class CollectionHandle {
|
|
|
529
529
|
* .count(5)
|
|
530
530
|
* .exec();
|
|
531
531
|
*/
|
|
532
|
-
export class
|
|
532
|
+
export class MoltenDbClient {
|
|
533
533
|
private transport: MoltenTransport;
|
|
534
534
|
|
|
535
535
|
constructor(transport: MoltenTransport) {
|