@minnowdb/core 0.7.2 → 0.7.7

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.
@@ -1,7 +1,7 @@
1
1
  import { type CompactionJobRecord, type GarbageCollectionJobRecord, type StorageIntegrityMode, type StorageIntegrityReport, type StorageStats, type InterruptedSnapshotImport, type InterruptedSnapshotImportAbortResult } from "../storage/types.js";
2
2
  import { type BatchRow, type InsertBatchInput } from "./batch.js";
3
3
  import type { Catalog } from "./catalog.js";
4
- import type { BatchValue, BufferPoolStats, StagedWriteResult, BufferedFlushResult, BufferedWriterOptions, CancelCompactionJobResult, CollectGarbageOptions, CollectGarbageStepOptions, CompactTableOptions, CompactTableResult, CompactTableStepOptions, CompactionJobProgress, CreateTableInput, DatabaseRow, MigrateOptions, DeleteBatchInput, DeleteBatchResult, ExecuteOptions, ExecuteResult, GarbageCollectionProgress, GarbageCollectionResult, MaintenanceStatus, InsertBatchResult, QueryOptions, QueryExecutionStats, QueryCursorOptions, QuerySpillCleanupOptions, QuerySpillCleanupResult, ReadTableOptions, RunStatementOptions, SnapshotExportOptions, SnapshotImportOptions, TableDefinition, UpdateBatchInput, UpdateBatchResult, UpsertBatchResult, UpsertOptions, VisibleSegmentPage, VisibleSegmentPageOptions } from "./database.js";
4
+ import type { BatchValue, BufferPoolStats, StagedWriteResult, StagedUpsertResult, BufferedFlushResult, BufferedWriterOptions, CancelCompactionJobResult, CollectGarbageOptions, CollectGarbageStepOptions, CompactTableOptions, CompactTableResult, CompactTableStepOptions, CompactionJobProgress, CreateTableInput, DatabaseRow, MigrateOptions, DeleteBatchInput, DeleteBatchResult, ExecuteOptions, ExecuteResult, GarbageCollectionProgress, GarbageCollectionResult, MaintenanceStatus, InsertBatchResult, QueryOptions, QueryExecutionStats, QueryCursorOptions, QuerySpillCleanupOptions, QuerySpillCleanupResult, ReadTableOptions, RunStatementOptions, SnapshotExportOptions, SnapshotImportOptions, TableDefinition, UpdateBatchInput, UpdateBatchResult, UpsertBatchResult, UpsertOptions, VisibleSegmentPage, VisibleSegmentPageOptions } from "./database.js";
5
5
  import type { LiveQueryInput, LiveQueryInvalidation, LiveQueryObserveOptions, LiveQueryStats, LiveQuerySubscribeOptions } from "./live.js";
6
6
  import type { CompiledQuery, CompiledStatement, QueryResult, QueryValue } from "./query.js";
7
7
  import type { AnyTable, SchemaDefinition } from "./schema.js";
@@ -210,7 +210,7 @@ export interface ClientWriteSession {
210
210
  query(sql: string, options?: QueryOptions): Promise<QueryResult>;
211
211
  execute(sql: string, params?: readonly QueryValue[]): Promise<ExecuteResult>;
212
212
  insertBatch(tableName: string, input: InsertBatchInput): Promise<StagedWriteResult>;
213
- upsertBatch(tableName: string, input: InsertBatchInput): Promise<StagedWriteResult>;
213
+ upsertBatch(tableName: string, input: InsertBatchInput, options?: UpsertOptions): Promise<StagedUpsertResult>;
214
214
  updateBatch(tableName: string, input: UpdateBatchInput): Promise<StagedWriteResult>;
215
215
  deleteBatch(tableName: string, input: DeleteBatchInput): Promise<StagedWriteResult>;
216
216
  }
@@ -290,7 +290,12 @@ class MinnowDatabaseClient {
290
290
  }
291
291
  async write(action) {
292
292
  const opened = await this.#call("writeOpen", []);
293
- const stage = (op, tableName, input) => this._invoke(opened.handleId, "stage", [op, tableName, input]);
293
+ const stage = (op, tableName, input, options) => this._invoke(opened.handleId, "stage", [
294
+ op,
295
+ tableName,
296
+ input,
297
+ options
298
+ ]);
294
299
  const session = {
295
300
  query: async (sql, options = {}) => {
296
301
  const { signal, onStats, ...wireOptions } = options;
@@ -298,7 +303,7 @@ class MinnowDatabaseClient {
298
303
  },
299
304
  execute: (sql, params) => this._invoke(opened.handleId, "execute", params === void 0 ? [sql] : [sql, params]),
300
305
  insertBatch: (tableName, input) => stage("insertBatch", tableName, input),
301
- upsertBatch: (tableName, input) => stage("upsertBatch", tableName, input),
306
+ upsertBatch: (tableName, input, options) => stage("upsertBatch", tableName, input, options),
302
307
  updateBatch: (tableName, input) => stage("updateBatch", tableName, input),
303
308
  deleteBatch: (tableName, input) => stage("deleteBatch", tableName, input)
304
309
  };
@@ -174,6 +174,10 @@ export interface StagedWriteResult {
174
174
  /** Values filled by defaults or auto-increment while the rows were staged. */
175
175
  generatedColumns?: Record<string, QueryValue[]>;
176
176
  }
177
+ export interface StagedUpsertResult extends StagedWriteResult {
178
+ /** Input rows rejected by `conflictWhere`; always 0 without it. */
179
+ skippedRowCount: number;
180
+ }
177
181
  /**
178
182
  * The scope handed to `write()`: every mutation stages into one transaction and publishes
179
183
  * as one commit — all of it or none of it, in every tab. Reads observe the pre-scope snapshot
@@ -194,7 +198,7 @@ export interface WriteSession {
194
198
  /** Runs a SELECT, INSERT, UPDATE, or DELETE inside this write scope. */
195
199
  execute(sql: string, params?: readonly QueryValue[]): Promise<ExecuteResult>;
196
200
  insertBatch(tableName: string, input: InsertBatchInput): Promise<StagedWriteResult>;
197
- upsertBatch(tableName: string, input: InsertBatchInput): Promise<StagedWriteResult>;
201
+ upsertBatch(tableName: string, input: InsertBatchInput, options?: UpsertOptions): Promise<StagedUpsertResult>;
198
202
  updateBatch(tableName: string, input: UpdateBatchInput): Promise<StagedWriteResult>;
199
203
  deleteBatch(tableName: string, input: DeleteBatchInput): Promise<StagedWriteResult>;
200
204
  }
@@ -587,6 +591,12 @@ export type ExecuteResult = {
587
591
  kind: "drop-view";
588
592
  view: string;
589
593
  dropped: boolean;
594
+ }
595
+ /** A session setting statement (`SET`, `RESET`), accepted and ignored. */
596
+ | {
597
+ kind: "set";
598
+ action: "set" | "reset";
599
+ name: string;
590
600
  } | {
591
601
  kind: "create-trigger";
592
602
  table: string;