mcard-js 2.1.32 → 2.1.34

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 (41) hide show
  1. package/README.md +27 -2
  2. package/dist/CardCollection-GUEYGN2Y.js +9 -0
  3. package/dist/LLMRuntime-GIGDMDEZ.js +16 -0
  4. package/dist/LambdaRuntime-LDA3G7IR.js +16 -0
  5. package/dist/LambdaRuntime-O7JBVHO2.js +16 -0
  6. package/dist/LambdaRuntime-Q6ISCHAD.js +16 -0
  7. package/dist/Loader-HQ3QKMYM.js +11 -0
  8. package/dist/NetworkRuntime-3MIUBNOF.js +1571 -0
  9. package/dist/OllamaProvider-Q45BMOVN.js +8 -0
  10. package/dist/StorageAdapter-DdDUiIvH.d.cts +391 -0
  11. package/dist/StorageAdapter-DdDUiIvH.d.ts +391 -0
  12. package/dist/chunk-37EEYISR.js +372 -0
  13. package/dist/chunk-3JBSRALP.js +296 -0
  14. package/dist/chunk-4MQINOOG.js +1218 -0
  15. package/dist/chunk-53S2EZCY.js +290 -0
  16. package/dist/chunk-C2TKISBR.js +1213 -0
  17. package/dist/chunk-DOC55MPG.js +355 -0
  18. package/dist/chunk-DP7HBRDL.js +2309 -0
  19. package/dist/chunk-HGENNKOJ.js +355 -0
  20. package/dist/chunk-J4HOFUKM.js +2309 -0
  21. package/dist/chunk-QA2XQMMJ.js +2313 -0
  22. package/dist/chunk-WY7EYSYC.js +1236 -0
  23. package/dist/chunk-XPG6B5IW.js +411 -0
  24. package/dist/chunk-YSVHXKSZ.js +373 -0
  25. package/dist/index.browser.cjs +196 -17
  26. package/dist/index.browser.d.cts +65 -14
  27. package/dist/index.browser.d.ts +65 -14
  28. package/dist/index.browser.js +3 -3
  29. package/dist/index.cjs +524 -200
  30. package/dist/index.d.cts +21 -10
  31. package/dist/index.d.ts +21 -10
  32. package/dist/index.js +153 -108
  33. package/dist/storage/SqliteNodeEngine.cjs +57 -0
  34. package/dist/storage/SqliteNodeEngine.d.cts +15 -1
  35. package/dist/storage/SqliteNodeEngine.d.ts +15 -1
  36. package/dist/storage/SqliteNodeEngine.js +1 -1
  37. package/dist/storage/SqliteWasmEngine.cjs +61 -0
  38. package/dist/storage/SqliteWasmEngine.d.cts +8 -1
  39. package/dist/storage/SqliteWasmEngine.d.ts +8 -1
  40. package/dist/storage/SqliteWasmEngine.js +1 -1
  41. package/package.json +2 -1
package/README.md CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  Full-featured TypeScript implementation of MCard content-addressable storage, supporting both browser and Node.js environments.
4
4
 
5
- [![Tests](https://img.shields.io/badge/tests-155%20passed-brightgreen)](./tests)
5
+ [![Tests](https://img.shields.io/badge/tests-814%20passed%20(52%20files)-brightgreen)](./tests)
6
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue)](https://www.typescriptlang.org/)
7
7
  [![Node.js](https://img.shields.io/badge/Node.js-18%2B-green)](https://nodejs.org/)
8
8
 
9
9
  ## Features
10
10
 
11
11
  - **Content Addressing**: SHA-256 via Web Crypto API (browser) or Node.js crypto
12
- - **Dual Storage**: IndexedDB (browser) + SQLite via better-sqlite3 (Node.js)
12
+ - **3 Interchangeable Storage Engines**: `IndexedDBEngine` (browser), `SqliteNodeEngine` (Node.js/better-sqlite3), `SqliteWasmEngine` (browser/sql.js) — verified by 162 cross-engine interchangeability tests
13
13
  - **UTF-8 Handles**: International support (文檔, مستند, ドキュメント, документ)
14
14
  - **Monadic API**: Maybe, Either, IO monads for functional composition
15
15
  - **PTR Runtime**: Polynomial Type Runtime with polyglot execution (JS, Python, Rust, C, WASM, Lean)
@@ -617,6 +617,31 @@ To run integration tests against a live Ollama instance:
617
617
  npx vitest tests/rag/Integration.test.ts
618
618
  ```
619
619
 
620
+ ## Version 0.1.50 / 2.1.32 Release Notes (March 12, 2026)
621
+ > StorageEngine Interchangeability, FK Fix, Security, Code Quality
622
+
623
+ ### 🔄 StorageEngine Interchangeability
624
+ * **162-Test Cross-Engine Suite**: New `StorageEngine.Interchangeability.test.ts` runs identical tests against all 3 engines (`IndexedDBEngine`, `SqliteNodeEngine`, `SqliteWasmEngine`), covering Card CRUD, queries, pagination, handle lifecycle, rename, prune, history deletion, and cross-cutting scenarios (Unicode handles, 50-card batch pagination, multi-alias).
625
+ * **`fake-indexeddb`**: Added as a dev dependency to enable `IndexedDBEngine` testing in Node.js.
626
+
627
+ ### 🐛 Bug Fix — Foreign Key Constraint in `renameHandle`
628
+ * **Root Cause**: `SqliteNodeEngine.renameHandleSync` updated `handle_registry` before `handle_history`, violating the FK constraint `handle_history.handle → handle_registry.handle` since both tables reference each other.
629
+ * **Fix**: Added `PRAGMA defer_foreign_keys = ON` inside the transaction so FK checks are deferred until commit, when both tables are consistent.
630
+
631
+ ### 🔒 Security — SQL Injection Prevention
632
+ * Replaced 6 string-interpolated SQL queries in `SqliteWasmEngine` with parameterized `prepare`/`bind`/`step`.
633
+
634
+ ### 📦 Code Quality
635
+ * **`rowToCard()` helper** (`SqliteNodeEngine`): 9 inline hydration patterns → 1.
636
+ * **`createPage()` factory** (`StorageAdapter`): Eliminated ~10 duplicated `Page` constructions across all 3 engines.
637
+ * Implemented `pruneHandleHistory` in `SqliteWasmEngine` and `IndexedDBEngine`.
638
+
639
+ ### 🧪 Test Results
640
+ * 814 passed, 23 skipped, 0 failures (52 test files)
641
+ * `tsc --noEmit` clean
642
+
643
+ ---
644
+
620
645
  ## Version 0.1.47 / 2.1.28 Release Notes (January 17, 2026)
621
646
  > Directory Structure Alignment, Strict Schema, and Store Refactoring
622
647
 
@@ -0,0 +1,9 @@
1
+ import {
2
+ CardCollection
3
+ } from "./chunk-3JBSRALP.js";
4
+ import "./chunk-QPZ2HNSU.js";
5
+ import "./chunk-7NKII2JA.js";
6
+ import "./chunk-MLKGABMK.js";
7
+ export {
8
+ CardCollection
9
+ };
@@ -0,0 +1,16 @@
1
+ import {
2
+ LLMRuntime,
3
+ chatMonad,
4
+ get_provider,
5
+ promptMonad
6
+ } from "./chunk-XPG6B5IW.js";
7
+ import "./chunk-DOC55MPG.js";
8
+ import "./chunk-MPMRBT5R.js";
9
+ import "./chunk-2KADE3SE.js";
10
+ import "./chunk-MLKGABMK.js";
11
+ export {
12
+ LLMRuntime,
13
+ chatMonad,
14
+ get_provider,
15
+ promptMonad
16
+ };
@@ -0,0 +1,16 @@
1
+ import {
2
+ LambdaRuntime,
3
+ parseLambdaExpression
4
+ } from "./chunk-QA2XQMMJ.js";
5
+ import "./chunk-MPMRBT5R.js";
6
+ import "./chunk-2KADE3SE.js";
7
+ import "./chunk-YSVHXKSZ.js";
8
+ import "./chunk-WTNVQ5WS.js";
9
+ import "./chunk-3JBSRALP.js";
10
+ import "./chunk-QPZ2HNSU.js";
11
+ import "./chunk-7NKII2JA.js";
12
+ import "./chunk-MLKGABMK.js";
13
+ export {
14
+ LambdaRuntime,
15
+ parseLambdaExpression
16
+ };
@@ -0,0 +1,16 @@
1
+ import {
2
+ LambdaRuntime,
3
+ parseLambdaExpression
4
+ } from "./chunk-J4HOFUKM.js";
5
+ import "./chunk-MPMRBT5R.js";
6
+ import "./chunk-2KADE3SE.js";
7
+ import "./chunk-YSVHXKSZ.js";
8
+ import "./chunk-WTNVQ5WS.js";
9
+ import "./chunk-3JBSRALP.js";
10
+ import "./chunk-QPZ2HNSU.js";
11
+ import "./chunk-7NKII2JA.js";
12
+ import "./chunk-MLKGABMK.js";
13
+ export {
14
+ LambdaRuntime,
15
+ parseLambdaExpression
16
+ };
@@ -0,0 +1,16 @@
1
+ import {
2
+ LambdaRuntime,
3
+ parseLambdaExpression
4
+ } from "./chunk-DP7HBRDL.js";
5
+ import "./chunk-MPMRBT5R.js";
6
+ import "./chunk-2KADE3SE.js";
7
+ import "./chunk-37EEYISR.js";
8
+ import "./chunk-WTNVQ5WS.js";
9
+ import "./chunk-3JBSRALP.js";
10
+ import "./chunk-QPZ2HNSU.js";
11
+ import "./chunk-7NKII2JA.js";
12
+ import "./chunk-MLKGABMK.js";
13
+ export {
14
+ LambdaRuntime,
15
+ parseLambdaExpression
16
+ };
@@ -0,0 +1,11 @@
1
+ import {
2
+ loadFileToCollection,
3
+ processAndStoreFile
4
+ } from "./chunk-HGENNKOJ.js";
5
+ import "./chunk-QPZ2HNSU.js";
6
+ import "./chunk-7NKII2JA.js";
7
+ import "./chunk-MLKGABMK.js";
8
+ export {
9
+ loadFileToCollection,
10
+ processAndStoreFile
11
+ };