@libredb/libredb 0.0.3 → 0.1.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.
@@ -16,7 +16,7 @@ export declare const RESERVED_MARKER = "\0";
16
16
  * `libredb:catalog:` tail keeps the namespace self-describing if a raw-KV tool
17
17
  * dumps the file before it understands the catalog.
18
18
  */
19
- export declare const CATALOG_PREFIX = "\0libredb:catalog:";
19
+ export declare const CATALOG_PREFIX: string;
20
20
  /**
21
21
  * Reject a user namespace name that begins with the reserved marker — a loud
22
22
  * error, the same class of correctness rule as the prefix-soundness checks the
@@ -116,7 +116,10 @@ export function doc(store, collection) {
116
116
  for (const entry of tx.getRange(start, end)) {
117
117
  const document = decodeDoc(entry.value);
118
118
  if (keep(document)) {
119
- rows.push({ id: fromUtf8.decode(entry.key).slice(prefix.length), doc: document });
119
+ rows.push({
120
+ id: fromUtf8.decode(entry.key).slice(prefix.length),
121
+ doc: document,
122
+ });
120
123
  }
121
124
  }
122
125
  return rows;
@@ -38,6 +38,10 @@ function matchesType(value, type) {
38
38
  case "boolean":
39
39
  return typeof value === "boolean";
40
40
  case "object":
41
+ // typeof null === "object" at runtime, so this null guard is real
42
+ // defensive validation even though the static Row type excludes null:
43
+ // a JS caller (no TypeScript) can still pass null into a column.
44
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
41
45
  return typeof value === "object" && value !== null && !Array.isArray(value);
42
46
  }
43
47
  }
@@ -191,7 +195,10 @@ export function table(store, name, schema) {
191
195
  // drop the document lens's DocEntry id wrapper (the pk lives in the row), then
192
196
  // let where/select compose over it. Each call rebuilds the Query so laziness
193
197
  // and re-iterability carry through from the document scan.
194
- const allRows = () => query(name, () => rows.all().toArray().map((entry) => entry.doc));
198
+ const allRows = () => query(name, () => rows
199
+ .all()
200
+ .toArray()
201
+ .map((entry) => entry.doc));
195
202
  return {
196
203
  name,
197
204
  insert(row) {
@@ -3,8 +3,8 @@
3
3
  *
4
4
  * A lens (kv, document, relational) is a typed view over the kernel in core.ts.
5
5
  * Lenses differ wildly in HOW you ask for data — a kv key range, a document
6
- * filter, a relational SELECT — and that is on purpose: DESIGN.md section 2 (and
7
- * the founding brainstorm in HANDOFF.md) reject a single unified query
6
+ * filter, a relational SELECT — and that is on purpose: DESIGN.md section 2
7
+ * rejects a single unified query
8
8
  * *language* as a lowest-common-denominator trap. So what lenses share is not
9
9
  * the query syntax but the RESULT envelope: every read hands back a
10
10
  * {@link Result}, every write reports a {@link WriteResult}. Pinning these two
@@ -3,8 +3,8 @@
3
3
  *
4
4
  * A lens (kv, document, relational) is a typed view over the kernel in core.ts.
5
5
  * Lenses differ wildly in HOW you ask for data — a kv key range, a document
6
- * filter, a relational SELECT — and that is on purpose: DESIGN.md section 2 (and
7
- * the founding brainstorm in HANDOFF.md) reject a single unified query
6
+ * filter, a relational SELECT — and that is on purpose: DESIGN.md section 2
7
+ * rejects a single unified query
8
8
  * *language* as a lowest-common-denominator trap. So what lenses share is not
9
9
  * the query syntax but the RESULT envelope: every read hands back a
10
10
  * {@link Result}, every write reports a {@link WriteResult}. Pinning these two
package/package.json CHANGED
@@ -1,9 +1,31 @@
1
1
  {
2
2
  "name": "@libredb/libredb",
3
- "version": "0.0.3",
3
+ "version": "0.1.0",
4
4
  "description": "A small, readable, embeddable, multi-model database. One ordered key-value core, thin model lenses on top.",
5
+ "keywords": [
6
+ "database",
7
+ "embedded",
8
+ "embeddable",
9
+ "key-value",
10
+ "document",
11
+ "relational",
12
+ "multi-model",
13
+ "typescript",
14
+ "bun"
15
+ ],
16
+ "homepage": "https://github.com/libredb/libredb-database#readme",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/libredb/libredb-database.git"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/libredb/libredb-database/issues"
23
+ },
5
24
  "type": "module",
6
25
  "license": "MIT",
26
+ "bin": {
27
+ "libredb": "./dist/cli/main.js"
28
+ },
7
29
  "files": [
8
30
  "dist"
9
31
  ],
@@ -15,25 +37,63 @@
15
37
  "types": "./dist/index.d.ts",
16
38
  "exports": {
17
39
  ".": {
40
+ "browser": {
41
+ "types": "./dist/browser.d.ts",
42
+ "import": "./dist/browser.js"
43
+ },
18
44
  "types": "./dist/index.d.ts",
19
45
  "import": "./dist/index.js"
46
+ },
47
+ "./browser": {
48
+ "types": "./dist/browser.d.ts",
49
+ "import": "./dist/browser.js"
20
50
  }
21
51
  },
52
+ "sideEffects": false,
22
53
  "engines": {
23
- "bun": ">=1.3.0"
54
+ "bun": ">=1.3.0",
55
+ "node": ">=22"
24
56
  },
25
57
  "scripts": {
26
58
  "typecheck": "tsc --noEmit",
27
- "lint": "eslint .",
59
+ "format": "biome format src eslint.config.js",
60
+ "format:fix": "biome format --write src eslint.config.js",
61
+ "lint": "oxlint && eslint .",
28
62
  "test": "bun test --coverage",
29
63
  "build": "tsc --project tsconfig.build.json",
30
- "gate": "bun run typecheck && bun run lint && bun run test && bun run build"
64
+ "compile": "bun build --compile src/cli/main.ts --outfile libredb",
65
+ "size": "size-limit",
66
+ "attw": "rm -rf .attw && bun pm pack --quiet --destination .attw && attw .attw/*.tgz --profile esm-only",
67
+ "publint": "publint",
68
+ "audit": "bun audit --ignore GHSA-h67p-54hq-rp68",
69
+ "secrets": "secretlint '**/*'",
70
+ "commitlint": "commitlint",
71
+ "license:check": "sh scripts/license-check.sh",
72
+ "changeset": "changeset",
73
+ "sync-version": "bun scripts/sync-version.ts",
74
+ "changeset:version": "changeset version && bun run sync-version",
75
+ "knip": "knip-bun",
76
+ "knip:production": "knip-bun --production --strict",
77
+ "prepublishOnly": "bun run build && bun run attw && bun run publint",
78
+ "prepare": "git config core.hooksPath .githooks",
79
+ "gate": "bun run typecheck && bun run format && bun run lint && bun run knip && bun run build && bun run size && bun run test"
31
80
  },
32
81
  "devDependencies": {
33
- "@eslint/js": "^9.0.0",
82
+ "@arethetypeswrong/cli": "^0.18.4",
83
+ "@biomejs/biome": "^2.5.1",
84
+ "@changesets/cli": "2.31.0",
85
+ "@commitlint/cli": "21.1.0",
86
+ "@commitlint/config-conventional": "21.1.0",
87
+ "@secretlint/secretlint-rule-preset-recommend": "13.0.2",
88
+ "@size-limit/preset-small-lib": "^12.1.0",
34
89
  "@types/bun": "latest",
35
- "eslint": "^9.0.0",
36
- "typescript": "^5.4.0",
90
+ "eslint": "^10.0.0",
91
+ "knip": "^6.20.0",
92
+ "oxlint": "^1.71.0",
93
+ "publint": "^0.3.21",
94
+ "secretlint": "13.0.2",
95
+ "size-limit": "^12.1.0",
96
+ "typescript": "^6.0.0",
37
97
  "typescript-eslint": "^8.0.0"
38
98
  }
39
99
  }