@minnowdb/core 0.5.0 → 0.6.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.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/dist/engine/cancellation.d.ts +2 -0
  3. package/dist/engine/cancellation.js +4 -0
  4. package/dist/engine/catalog.d.ts +3 -1
  5. package/dist/engine/catalog.js +1 -0
  6. package/dist/engine/client.d.ts +32 -4
  7. package/dist/engine/client.js +82 -15
  8. package/dist/engine/database.d.ts +23 -14
  9. package/dist/engine/database.js +516 -74
  10. package/dist/engine/defaults.js +11 -0
  11. package/dist/engine/errors.d.ts +13 -0
  12. package/dist/engine/errors.js +22 -0
  13. package/dist/engine/fts.d.ts +2 -15
  14. package/dist/engine/live.d.ts +1 -7
  15. package/dist/engine/live.js +2 -12
  16. package/dist/engine/optimizer.js +540 -38
  17. package/dist/engine/query.d.ts +5 -278
  18. package/dist/engine/query.js +78 -32
  19. package/dist/engine/schema-wire.d.ts +7 -1
  20. package/dist/engine/schema-wire.js +4 -0
  21. package/dist/engine/schema.d.ts +67 -33
  22. package/dist/engine/schema.js +138 -7
  23. package/dist/engine/sql-domains.d.ts +8 -0
  24. package/dist/engine/sql-domains.js +25 -0
  25. package/dist/engine/sql-json.js +22 -3
  26. package/dist/engine/vector.d.ts +2 -2
  27. package/dist/engine/vector.js +301 -39
  28. package/dist/engine/worker-host.js +119 -44
  29. package/dist/plan/index.d.ts +5 -4
  30. package/dist/plan/index.js +3 -3
  31. package/dist/plan/model.d.ts +218 -0
  32. package/dist/plan/model.js +1 -0
  33. package/dist/storage/types.d.ts +7 -0
  34. package/dist/storage/types.js +16 -0
  35. package/dist/transactions/index.d.ts +5 -3
  36. package/dist/transactions/index.js +58 -8
  37. package/dist/worker-protocol/index.d.ts +6 -1
  38. package/dist/worker-protocol/index.js +5 -2
  39. package/package.json +1 -1
  40. package/sql-feature-matrix.json +69 -19
@@ -35,6 +35,17 @@ export async function fillColumnDefaults(table, input, evaluateExpression, known
35
35
  const provided = input.columns[column.name];
36
36
  const omitted = input.omitted?.[column.name];
37
37
  const isOmitted = (index) => provided === undefined || omitted?.[index] === true;
38
+ if (column.generatedValue !== undefined) {
39
+ if (provided !== undefined) {
40
+ for (let index = 0; index < rowCount; index += 1) {
41
+ if (!isOmitted(index)) {
42
+ throw new TypeError(`Generated column cannot be assigned: ${column.name}`);
43
+ }
44
+ }
45
+ }
46
+ columns[column.name] = new Array(rowCount).fill(null);
47
+ continue;
48
+ }
38
49
  if (defaultValue === undefined) {
39
50
  if (provided === undefined || omitted?.some(Boolean) === true) {
40
51
  const values = provided === undefined ? new Array(rowCount).fill(null) : [...provided];
@@ -9,6 +9,19 @@ export declare class UnknownTableError extends TypeError {
9
9
  readonly name = "UnknownTableError";
10
10
  constructor(tableName: string);
11
11
  }
12
+ /** Refuses another read before one database instance retains an unbounded request backlog. */
13
+ export declare class DatabaseReadBacklogError extends Error {
14
+ readonly limit: number;
15
+ readonly name = "DatabaseReadBacklogError";
16
+ constructor(limit?: number);
17
+ }
18
+ /** A live-query owner reached one of its documented resident-resource ceilings. */
19
+ export declare class LiveQueryLimitError extends Error {
20
+ readonly resource: "set" | "group" | "subscription";
21
+ readonly limit: number;
22
+ readonly name = "LiveQueryLimitError";
23
+ constructor(resource: "set" | "group" | "subscription", limit: number);
24
+ }
12
25
  export declare class UniqueConstraintError extends Error {
13
26
  readonly tableName: string;
14
27
  readonly columnName: string;
@@ -14,6 +14,28 @@ export class UnknownTableError extends TypeError {
14
14
  this.tableName = tableName;
15
15
  }
16
16
  }
17
+ /** Refuses another read before one database instance retains an unbounded request backlog. */
18
+ export class DatabaseReadBacklogError extends Error {
19
+ limit;
20
+ name = "DatabaseReadBacklogError";
21
+ constructor(limit = 256) {
22
+ super(`A database cannot retain more than ${String(limit)} active reads; await a read`);
23
+ this.limit = limit;
24
+ }
25
+ }
26
+ /** A live-query owner reached one of its documented resident-resource ceilings. */
27
+ export class LiveQueryLimitError extends Error {
28
+ resource;
29
+ limit;
30
+ name = "LiveQueryLimitError";
31
+ constructor(resource, limit) {
32
+ super(resource === "set"
33
+ ? `A database cannot retain more than ${String(limit)} live-query sets`
34
+ : `A live-query set cannot retain more than ${String(limit)} ${resource} records`);
35
+ this.resource = resource;
36
+ this.limit = limit;
37
+ }
38
+ }
17
39
  export class UniqueConstraintError extends Error {
18
40
  tableName;
19
41
  columnName;
@@ -11,27 +11,14 @@
11
11
  * count, total token count), so the row and columnar executors produce bit-identical scores no
12
12
  * matter what order they accumulate in. Keep it that way: never feed it a running float.
13
13
  */
14
+ import type { FtsStats } from "../plan/model.js";
15
+ export type { FtsStats } from "../plan/model.js";
14
16
  export declare const FTS_TOKENIZER_VERSION = 1;
15
17
  /** One parsed query term; `prefix` terms match any token they prefix. */
16
18
  export interface FtsQueryTerm {
17
19
  readonly term: string;
18
20
  readonly prefix: boolean;
19
21
  }
20
- /**
21
- * Corpus statistics for one (columns, query) signature — O(#query terms) integers. Every row of
22
- * the corpus counts as a document (an all-null document has length 0): this definition is what
23
- * lets a persisted index serve exact statistics without a scan, since the document count is
24
- * just the table's row count. All producers — the row executor, the columnar scan, and the
25
- * postings index — must share it, or BM25 scores drift between paths.
26
- */
27
- export interface FtsStats {
28
- /** Every row of the corpus, including all-null documents. */
29
- docCount: number;
30
- /** Total tokens across all documents. */
31
- totalTokens: number;
32
- /** Documents containing each query term, aligned with the query's term order. */
33
- dfByTerm: number[];
34
- }
35
22
  /** Tokenizes one cell's text: NFKC, locale-independent lowercase, letter/number runs. */
36
23
  export declare function tokenize(text: string): string[];
37
24
  /**
@@ -32,12 +32,7 @@ export declare const DEFAULT_LIVE_QUERY_MAX_SUBSCRIPTIONS = 1024;
32
32
  export declare const MAX_LIVE_QUERY_GROUPS = 4096;
33
33
  export declare const MAX_LIVE_QUERY_SUBSCRIPTIONS = 16384;
34
34
  export declare const MAX_LIVE_QUERY_SETS_PER_DATABASE = 256;
35
- export declare class LiveQueryLimitError extends Error {
36
- readonly resource: "set" | "group" | "subscription";
37
- readonly limit: number;
38
- readonly name = "LiveQueryLimitError";
39
- constructor(resource: "set" | "group" | "subscription", limit: number);
40
- }
35
+ export { LiveQueryLimitError } from "./errors.js";
41
36
  export interface LiveQuerySubscribeOptions {
42
37
  onChange(result: QueryResult): void;
43
38
  onError?(error: unknown): void;
@@ -104,4 +99,3 @@ export declare class LiveQuerySet {
104
99
  refresh(): Promise<void>;
105
100
  close(): void;
106
101
  }
107
- export {};
@@ -1,20 +1,10 @@
1
+ import { LiveQueryLimitError } from "./errors.js";
1
2
  export const DEFAULT_LIVE_QUERY_MAX_GROUPS = 256;
2
3
  export const DEFAULT_LIVE_QUERY_MAX_SUBSCRIPTIONS = 1_024;
3
4
  export const MAX_LIVE_QUERY_GROUPS = 4_096;
4
5
  export const MAX_LIVE_QUERY_SUBSCRIPTIONS = 16_384;
5
6
  export const MAX_LIVE_QUERY_SETS_PER_DATABASE = 256;
6
- export class LiveQueryLimitError extends Error {
7
- resource;
8
- limit;
9
- name = "LiveQueryLimitError";
10
- constructor(resource, limit) {
11
- super(resource === "set"
12
- ? `A database cannot retain more than ${String(limit)} live-query sets`
13
- : `A live-query set cannot retain more than ${String(limit)} ${resource} records`);
14
- this.resource = resource;
15
- this.limit = limit;
16
- }
17
- }
7
+ export { LiveQueryLimitError } from "./errors.js";
18
8
  const digestScratch = new DataView(new ArrayBuffer(8));
19
9
  /** Fast inequality filter. Equal digests are always followed by exact comparison. */
20
10
  function digestResult(result) {