@minnowdb/core 0.7.8 → 0.8.0
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/dist/engine/client.d.ts +5 -2
- package/dist/engine/client.js +14 -4
- package/dist/engine/database.js +632 -39
- package/dist/engine/errors.d.ts +2 -2
- package/dist/engine/errors.js +1 -1
- package/dist/engine/keyed-live.js +55 -18
- package/dist/engine/live-aggregate.d.ts +12 -0
- package/dist/engine/live-aggregate.js +226 -0
- package/dist/engine/live-patch.d.ts +21 -0
- package/dist/engine/live-patch.js +31 -0
- package/dist/engine/live.d.ts +107 -8
- package/dist/engine/live.js +353 -187
- package/dist/engine/optimizer.js +11 -6
- package/dist/engine/query-cache.js +2 -13
- package/dist/engine/query-generations.d.ts +8 -0
- package/dist/engine/query-generations.js +61 -0
- package/dist/engine/query-identity.d.ts +3 -0
- package/dist/engine/query-identity.js +41 -0
- package/dist/engine/query.d.ts +6 -11
- package/dist/engine/query.js +294 -428
- package/dist/engine/sql-domains.d.ts +4 -0
- package/dist/engine/sql-domains.js +121 -0
- package/dist/engine/sql-semantics.js +7 -4
- package/dist/engine/typed-live.d.ts +12 -1
- package/dist/engine/typed-live.js +110 -25
- package/dist/engine/windows.d.ts +12 -0
- package/dist/engine/windows.js +386 -0
- package/dist/engine/worker-server.js +12 -5
- package/dist/plan/model.d.ts +1 -1
- package/dist/worker-protocol/index.d.ts +1 -1
- package/dist/worker-protocol/index.js +1 -1
- package/package.json +1 -1
- package/postgres-feature-profile.json +6 -1
- package/sql-feature-matrix.json +20 -27
package/dist/engine/client.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { type LiveQueryPatchOptions } from "./live-patch.js";
|
|
1
2
|
import { type CompactionJobRecord, type GarbageCollectionJobRecord, type StorageIntegrityMode, type StorageIntegrityReport, type StorageStats, type InterruptedSnapshotImport, type InterruptedSnapshotImportAbortResult } from "../storage/types.js";
|
|
2
3
|
import { type BatchRow } from "./batch.js";
|
|
3
4
|
import type { Catalog } from "./catalog.js";
|
|
4
5
|
import type { BufferPoolStats, StagedWriteResult, StagedUpsertResult, BufferedFlushResult, BufferedWriterOptions, CancelCompactionJobResult, CollectGarbageOptions, CollectGarbageStepOptions, CompactTableOptions, CompactTableResult, CompactTableStepOptions, CompactionJobProgress, CreateTableInput, MigrateOptions, DeleteBatchResult, ExecuteOptions, ExecuteResult, GarbageCollectionProgress, GarbageCollectionResult, MaintenanceStatus, InsertBatchResult, QueryOptions, QueryExecutionStats, QueryCursorOptions, QuerySpillCleanupOptions, QuerySpillCleanupResult, RunStatementOptions, SnapshotExportOptions, SnapshotImportOptions, TableDefinition, UpdateBatchResult, UpsertBatchResult, VisibleSegmentPage, VisibleSegmentPageOptions } from "./database.js";
|
|
5
|
-
import type { LiveQueryInput, LiveQueryInvalidation, LiveQueryObserveOptions, LiveQueryStats, LiveQuerySubscribeOptions } from "./live.js";
|
|
6
|
+
import type { LiveQueryDelivery, LiveQueryInput, LiveQueryInvalidation, LiveQueryObserveOptions, LiveQueryStats, LiveQuerySubscribeOptions } from "./live.js";
|
|
6
7
|
import type { CompiledQuery, CompiledStatement, QueryResult, QueryValue } from "./query.js";
|
|
7
8
|
import type { AnySchema, UntypedSchema, AnyTable, BatchColumnName, BatchDeleteInput, BatchInsertInput, BatchInsertRow, BatchKeyValue, BatchReadOptions, BatchReadRow, BatchUpdateChanges, BatchUpdateInput, BatchUpsertOptions, SchemaDefinition, TableName } from "./schema.js";
|
|
8
9
|
import { type WireMigrationStep } from "./schema-wire.js";
|
|
@@ -65,7 +66,7 @@ export interface ClientMigrationResult {
|
|
|
65
66
|
steps: WireMigrationStep[];
|
|
66
67
|
}
|
|
67
68
|
interface EventRoute {
|
|
68
|
-
onChange?: (result: QueryResult) => void;
|
|
69
|
+
onChange?: (result: QueryResult, delivery: LiveQueryDelivery) => void;
|
|
69
70
|
onInvalidate?: (invalidation: LiveQueryInvalidation) => void;
|
|
70
71
|
onError?: (error: unknown) => void;
|
|
71
72
|
onComplete?: () => void;
|
|
@@ -264,6 +265,8 @@ export declare class ClientLiveQuerySet {
|
|
|
264
265
|
constructor(client: MinnowDatabaseClient, handleId: string, created: Promise<unknown>);
|
|
265
266
|
/** Registers a query (SQL or a compiled-plan envelope) and re-runs it on relevant changes. */
|
|
266
267
|
subscribe(query: LiveQueryInput, options: LiveQuerySubscribeOptions): Promise<ClientLiveSubscription>;
|
|
268
|
+
/** Delivers changed row payloads; the worker transport still sends its result snapshot. */
|
|
269
|
+
subscribePatches(query: LiveQueryInput, options: LiveQueryPatchOptions): Promise<ClientLiveSubscription>;
|
|
267
270
|
/** Registers dependency observation while leaving execution/result mapping to an adapter. */
|
|
268
271
|
observe(query: LiveQueryInput, options: LiveQueryObserveOptions): Promise<ClientLiveSubscription>;
|
|
269
272
|
stats(): Promise<LiveQueryStats>;
|
package/dist/engine/client.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createLiveQueryPatch } from "./live-patch.js";
|
|
1
2
|
import { BlockReadBatchTooLargeError, CompactionBacklogError, CompactionJobConflictError, GarbageCollectionJobConflictError, IndexedDbSchemaUpgradeBlockedError, LeaseConflictError, LeaseExpiredError, LeaseOwnerConflictError, PostingBuildConflictError, SnapshotManifestMissingError, SnapshotImportConflictError, SchemaConflictError, StorageResourceLimitError, TableInUseError, TableRecordConflictError, TempOwnerConflictError, TransactionRecordConflictError, UniqueKeyBuildConflictError, UniqueKeyConflictError, UniqueIndexCoverageError, WriteConflictError, StorageCorruptionError, StorageFormatVersionError, OpfsUncertainOutcomeError } from "../storage/types.js";
|
|
2
3
|
import { MAX_SNAPSHOT_STREAM_CHUNK_BYTES } from "../storage/snapshot.js";
|
|
3
4
|
import { parseRpcResponse, MAX_DATABASE_RPC_IN_FLIGHT, protocolVersion } from "../worker-protocol/index.js";
|
|
@@ -556,9 +557,10 @@ class MinnowDatabaseClient {
|
|
|
556
557
|
const route = this.#events.get(response.handleId);
|
|
557
558
|
if (route === void 0)
|
|
558
559
|
return;
|
|
559
|
-
if (response.event === "change")
|
|
560
|
-
|
|
561
|
-
|
|
560
|
+
if (response.event === "change") {
|
|
561
|
+
const { result, delivery } = response.payload;
|
|
562
|
+
route.onChange?.(decodeQueryResult(result), delivery);
|
|
563
|
+
} else if (response.event === "invalidate") {
|
|
562
564
|
route.onInvalidate?.(response.payload);
|
|
563
565
|
} else if (response.event === "error") {
|
|
564
566
|
route.onError?.(rehydrateResponseError(response.payload));
|
|
@@ -682,6 +684,13 @@ class ClientLiveQuerySet {
|
|
|
682
684
|
throw error;
|
|
683
685
|
}
|
|
684
686
|
}
|
|
687
|
+
subscribePatches(query, options) {
|
|
688
|
+
return this.subscribe(query, {
|
|
689
|
+
onChange: (result, delivery) => options.onPatch(createLiveQueryPatch(result, delivery), delivery),
|
|
690
|
+
...options.onError === void 0 ? {} : { onError: options.onError.bind(options) },
|
|
691
|
+
...options.onComplete === void 0 ? {} : { onComplete: options.onComplete.bind(options) }
|
|
692
|
+
});
|
|
693
|
+
}
|
|
685
694
|
async observe(query, options) {
|
|
686
695
|
await this.#created;
|
|
687
696
|
const subscriptionId = crypto.randomUUID();
|
|
@@ -698,7 +707,8 @@ class ClientLiveQuerySet {
|
|
|
698
707
|
try {
|
|
699
708
|
const created = await this.client._invoke(this.handleId, "observe", [
|
|
700
709
|
subscriptionId,
|
|
701
|
-
query
|
|
710
|
+
query,
|
|
711
|
+
{ suppressUnchanged: options.suppressUnchanged === true }
|
|
702
712
|
]);
|
|
703
713
|
this.#subscriptionIds.add(subscriptionId);
|
|
704
714
|
return new ClientLiveSubscription(this.client, subscriptionId, created.dependencyTableIds, () => this.#subscriptionIds.delete(subscriptionId), state);
|